From d7301e26c39c864a028008d3bbe8733189b6d861 Mon Sep 17 00:00:00 2001 From: jlevine18 Date: Sun, 6 Jan 2019 13:02:35 -0600 Subject: [PATCH] Add files via upload --- .../@google-cloud/common/CONTRIBUTORS | 19 + .../node_modules/@google-cloud/common/LICENSE | 202 + .../@google-cloud/common/README.md | 79 + .../node_modules/retry-request/index.d.ts | 22 + .../node_modules/retry-request/index.js | 209 + .../common/node_modules/retry-request/license | 20 + .../node_modules/retry-request/package.json | 70 + .../node_modules/retry-request/readme.md | 152 + .../@google-cloud/common/package.json | 166 + .../@google-cloud/common/src/index.js | 51 + .../@google-cloud/common/src/logger.js | 71 + .../@google-cloud/common/src/operation.js | 193 + .../@google-cloud/common/src/paginator.js | 267 + .../common/src/service-object.js | 392 + .../@google-cloud/common/src/service.js | 200 + .../@google-cloud/common/src/util.js | 830 + .../@google-cloud/firestore/LICENSE | 202 + .../@google-cloud/firestore/README.md | 141 + .../firestore/build/protos/README.md | 33 + .../build/protos/firestore_proto_api.d.ts | 10582 ++++++ .../build/protos/firestore_proto_api.js | 26706 ++++++++++++++++ .../google/firestore/v1beta1/common.proto | 83 + .../google/firestore/v1beta1/document.proto | 150 + .../google/firestore/v1beta1/firestore.proto | 760 + .../google/firestore/v1beta1/query.proto | 235 + .../google/firestore/v1beta1/write.proto | 214 + .../firestore/build/src/backoff.js | 197 + .../firestore/build/src/convert.js | 213 + .../firestore/build/src/document-change.js | 173 + .../firestore/build/src/document.js | 1025 + .../firestore/build/src/field-value.js | 324 + .../firestore/build/src/geo-point.js | 108 + .../firestore/build/src/index.js | 1275 + .../firestore/build/src/logger.js | 60 + .../firestore/build/src/order.js | 238 + .../@google-cloud/firestore/build/src/path.js | 510 + .../@google-cloud/firestore/build/src/pool.js | 124 + .../firestore/build/src/reference.js | 1782 ++ .../firestore/build/src/serializer.js | 228 + .../firestore/build/src/timestamp.js | 225 + .../firestore/build/src/transaction.js | 311 + .../firestore/build/src/types.js | 17 + .../@google-cloud/firestore/build/src/util.js | 46 + .../google/firestore/v1beta1/doc_common.js | 107 + .../google/firestore/v1beta1/doc_document.js | 183 + .../google/firestore/v1beta1/doc_firestore.js | 881 + .../doc/google/firestore/v1beta1/doc_query.js | 379 + .../doc/google/firestore/v1beta1/doc_write.js | 262 + .../v1beta1/doc/google/protobuf/doc_any.js | 130 + .../v1beta1/doc/google/protobuf/doc_empty.js | 33 + .../doc/google/protobuf/doc_timestamp.js | 115 + .../doc/google/protobuf/doc_wrappers.js | 151 + .../src/v1beta1/doc/google/rpc/doc_status.js | 92 + .../build/src/v1beta1/firestore_client.js | 1398 + .../src/v1beta1/firestore_client_config.json | 100 + .../firestore/build/src/v1beta1/index.js | 29 + .../firestore/build/src/validate.js | 184 + .../firestore/build/src/watch.js | 664 + .../firestore/build/src/write-batch.js | 510 + .../@google-cloud/firestore/package.json | 145 + .../firestore/types/firestore.d.ts | 1244 + .../@google-cloud/projectify/CHANGELOG.md | 58 + .../@google-cloud/projectify/LICENSE | 202 + .../@google-cloud/projectify/README.md | 15 + .../projectify/build/src/index.d.ts | 31 + .../projectify/build/src/index.js | 64 + .../@google-cloud/projectify/package.json | 86 + .../@google-cloud/storage/CONTRIBUTORS | 26 + .../@google-cloud/storage/LICENSE | 202 + .../@google-cloud/storage/README.md | 134 + .../@google-cloud/storage/package.json | 209 + .../@google-cloud/storage/src/acl.js | 766 + .../@google-cloud/storage/src/bucket.js | 2458 ++ .../@google-cloud/storage/src/channel.js | 116 + .../@google-cloud/storage/src/file.js | 2475 ++ .../@google-cloud/storage/src/iam.js | 300 + .../@google-cloud/storage/src/index.js | 591 + .../@google-cloud/storage/src/notification.js | 350 + 78 files changed, 63595 insertions(+) create mode 100644 website/functions/node_modules/@google-cloud/common/CONTRIBUTORS create mode 100644 website/functions/node_modules/@google-cloud/common/LICENSE create mode 100644 website/functions/node_modules/@google-cloud/common/README.md create mode 100644 website/functions/node_modules/@google-cloud/common/node_modules/retry-request/index.d.ts create mode 100644 website/functions/node_modules/@google-cloud/common/node_modules/retry-request/index.js create mode 100644 website/functions/node_modules/@google-cloud/common/node_modules/retry-request/license create mode 100644 website/functions/node_modules/@google-cloud/common/node_modules/retry-request/package.json create mode 100644 website/functions/node_modules/@google-cloud/common/node_modules/retry-request/readme.md create mode 100644 website/functions/node_modules/@google-cloud/common/package.json create mode 100644 website/functions/node_modules/@google-cloud/common/src/index.js create mode 100644 website/functions/node_modules/@google-cloud/common/src/logger.js create mode 100644 website/functions/node_modules/@google-cloud/common/src/operation.js create mode 100644 website/functions/node_modules/@google-cloud/common/src/paginator.js create mode 100644 website/functions/node_modules/@google-cloud/common/src/service-object.js create mode 100644 website/functions/node_modules/@google-cloud/common/src/service.js create mode 100644 website/functions/node_modules/@google-cloud/common/src/util.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/LICENSE create mode 100644 website/functions/node_modules/@google-cloud/firestore/README.md create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/protos/README.md create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/protos/firestore_proto_api.d.ts create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/protos/firestore_proto_api.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/protos/google/firestore/v1beta1/common.proto create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/protos/google/firestore/v1beta1/document.proto create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/protos/google/firestore/v1beta1/firestore.proto create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/protos/google/firestore/v1beta1/query.proto create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/protos/google/firestore/v1beta1/write.proto create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/backoff.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/convert.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/document-change.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/document.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/field-value.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/geo-point.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/index.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/logger.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/order.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/path.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/pool.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/reference.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/serializer.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/timestamp.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/transaction.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/types.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/util.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/firestore/v1beta1/doc_common.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/firestore/v1beta1/doc_document.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/firestore/v1beta1/doc_firestore.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/firestore/v1beta1/doc_query.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/firestore/v1beta1/doc_write.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/protobuf/doc_any.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/protobuf/doc_empty.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/protobuf/doc_timestamp.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/protobuf/doc_wrappers.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/rpc/doc_status.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/firestore_client.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/firestore_client_config.json create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/index.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/validate.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/watch.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/build/src/write-batch.js create mode 100644 website/functions/node_modules/@google-cloud/firestore/package.json create mode 100644 website/functions/node_modules/@google-cloud/firestore/types/firestore.d.ts create mode 100644 website/functions/node_modules/@google-cloud/projectify/CHANGELOG.md create mode 100644 website/functions/node_modules/@google-cloud/projectify/LICENSE create mode 100644 website/functions/node_modules/@google-cloud/projectify/README.md create mode 100644 website/functions/node_modules/@google-cloud/projectify/build/src/index.d.ts create mode 100644 website/functions/node_modules/@google-cloud/projectify/build/src/index.js create mode 100644 website/functions/node_modules/@google-cloud/projectify/package.json create mode 100644 website/functions/node_modules/@google-cloud/storage/CONTRIBUTORS create mode 100644 website/functions/node_modules/@google-cloud/storage/LICENSE create mode 100644 website/functions/node_modules/@google-cloud/storage/README.md create mode 100644 website/functions/node_modules/@google-cloud/storage/package.json create mode 100644 website/functions/node_modules/@google-cloud/storage/src/acl.js create mode 100644 website/functions/node_modules/@google-cloud/storage/src/bucket.js create mode 100644 website/functions/node_modules/@google-cloud/storage/src/channel.js create mode 100644 website/functions/node_modules/@google-cloud/storage/src/file.js create mode 100644 website/functions/node_modules/@google-cloud/storage/src/iam.js create mode 100644 website/functions/node_modules/@google-cloud/storage/src/index.js create mode 100644 website/functions/node_modules/@google-cloud/storage/src/notification.js diff --git a/website/functions/node_modules/@google-cloud/common/CONTRIBUTORS b/website/functions/node_modules/@google-cloud/common/CONTRIBUTORS new file mode 100644 index 00000000..0c2a77ae --- /dev/null +++ b/website/functions/node_modules/@google-cloud/common/CONTRIBUTORS @@ -0,0 +1,19 @@ +# The names of individuals who have contributed to this project. +# +# Names are formatted as: +# name +# +Ali Ijaz Sheikh +Austin Peterson +Dave Gramlich +Eric Uldall +Ernest Landrito +Jason Dobry +Justin King +Karolis Narkevicius +Kelvin Jin +Luke Sneeringer +Matthew Loring +Michael Prentice +Stephen Sawchuk +Tim Swast diff --git a/website/functions/node_modules/@google-cloud/common/LICENSE b/website/functions/node_modules/@google-cloud/common/LICENSE new file mode 100644 index 00000000..7a4a3ea2 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/common/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. \ No newline at end of file diff --git a/website/functions/node_modules/@google-cloud/common/README.md b/website/functions/node_modules/@google-cloud/common/README.md new file mode 100644 index 00000000..73527bc6 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/common/README.md @@ -0,0 +1,79 @@ +Google Cloud Platform logo + +# [Google Cloud Common Module: Node.js Client](https://github.com/googlecloudplatform/google-cloud-node) + +[![release level](https://img.shields.io/badge/release%20level-alpha-orange.svg?style=flat)](https://cloud.google.com/terms/launch-stages) +[![CircleCI](https://img.shields.io/circleci/project/github/googleapis/nodejs-common.svg?style=flat)](https://circleci.com/gh/googleapis/nodejs-common) +[![AppVeyor](https://ci.appveyor.com/api/projects/status/github/googleapis/nodejs-common?branch=master&svg=true)](https://ci.appveyor.com/project/googleapis/nodejs-common) +[![codecov](https://img.shields.io/codecov/c/github/googleapis/nodejs-common/master.svg?style=flat)](https://codecov.io/gh/googleapis/nodejs-common) + +> Node.js Common package + +Google Cloud Common node.js module contains stuff used by other Cloud API modules. + +* [github.com/googlecloudplatform/google-cloud-node](https://github.com/googlecloudplatform/google-cloud-node) + +Read more about the client libraries for Cloud APIs, including the older +Google APIs Client Libraries, in [Client Libraries Explained][explained]. + +[explained]: https://cloud.google.com/apis/docs/client-libraries-explained + +**Table of contents:** + +* [Quickstart](#quickstart) + * [Before you begin](#before-you-begin) + * [Installing the client library](#installing-the-client-library) + * [Using the client library](#using-the-client-library) +* [Versioning](#versioning) +* [Contributing](#contributing) +* [License](#license) + +## Quickstart + +### Before you begin + +1. Select or create a Cloud Platform project. + + [Go to the projects page][projects] + +1. Enable billing for your project. + + [Enable billing][billing] + +1. [Set up authentication with a service account][auth] so you can access the + API from your local workstation. + +[projects]: https://console.cloud.google.com/project +[billing]: https://support.google.com/cloud/answer/6293499#enable-billing +[auth]: https://cloud.google.com/docs/authentication/getting-started + +### Installing the package + + npm install --save @google-cloud/common + +It's unlikely you will need to install this package directly, as it will be +installed as a dependency when you install other `@google-cloud` packages. + +## Versioning + +This library follows [Semantic Versioning](http://semver.org/). + +This library is considered to be in **alpha**. This means it is still a +work-in-progress and under active development. Any release is subject to +backwards-incompatible changes at any time. + +More Information: [Google Cloud Platform Launch Stages][launch_stages] + +[launch_stages]: https://cloud.google.com/terms/launch-stages + +## Contributing + +Contributions welcome! See the [Contributing Guide](https://github.com/googlecloudplatform/google-cloud-node/blob/master/.github/CONTRIBUTING.md). + +## License + +Apache Version 2.0 + +See [LICENSE](https://github.com/googlecloudplatform/google-cloud-node/blob/master/LICENSE) + +[shell_img]: http://gstatic.com/cloudssh/images/open-btn.png diff --git a/website/functions/node_modules/@google-cloud/common/node_modules/retry-request/index.d.ts b/website/functions/node_modules/@google-cloud/common/node_modules/retry-request/index.d.ts new file mode 100644 index 00000000..2fdb9e92 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/common/node_modules/retry-request/index.d.ts @@ -0,0 +1,22 @@ +declare module 'retry-request' { + import * as request from 'request'; + + namespace retryRequest { + function getNextRetryDelay(retryNumber: number): void; + interface Options { + objectMode?: boolean, + request?: typeof request, + retries?: number, + noResponseRetries?: number, + currentRetryAttempt?: number, + shouldRetryFn?: (response: request.RequestResponse) => boolean + } + } + + function retryRequest(requestOpts: request.Options, opts: retryRequest.Options, callback?: request.RequestCallback) + : { abort: () => void }; + function retryRequest(requestOpts: request.Options, callback?: request.RequestCallback) + : { abort: () => void }; + + export = retryRequest; +} diff --git a/website/functions/node_modules/@google-cloud/common/node_modules/retry-request/index.js b/website/functions/node_modules/@google-cloud/common/node_modules/retry-request/index.js new file mode 100644 index 00000000..125876a3 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/common/node_modules/retry-request/index.js @@ -0,0 +1,209 @@ +'use strict'; + +var request = require('request'); +var through = require('through2'); + +var DEFAULTS = { + objectMode: false, + request: request, + retries: 2, + noResponseRetries: 2, + currentRetryAttempt: 0, + shouldRetryFn: function (response) { + var retryRanges = [ + // https://en.wikipedia.org/wiki/List_of_HTTP_status_codes + // 1xx - Retry (Informational, request still processing) + // 2xx - Do not retry (Success) + // 3xx - Do not retry (Redirect) + // 4xx - Do not retry (Client errors) + // 429 - Retry ("Too Many Requests") + // 5xx - Retry (Server errors) + [100, 199], + [429, 429], + [500, 599] + ]; + + var statusCode = response.statusCode; + + var range; + while ((range = retryRanges.shift())) { + if (statusCode >= range[0] && statusCode <= range[1]) { + // Not a successful status or redirect. + return true; + } + } + } +}; + +function retryRequest(requestOpts, opts, callback) { + var streamMode = typeof arguments[arguments.length - 1] !== 'function'; + + if (typeof opts === 'function') { + callback = opts; + } + + opts = opts || DEFAULTS; + + if (typeof opts.objectMode === 'undefined') { + opts.objectMode = DEFAULTS.objectMode; + } + if (typeof opts.request === 'undefined') { + opts.request = DEFAULTS.request; + } + if (typeof opts.retries !== 'number') { + opts.retries = DEFAULTS.retries; + } + if (typeof opts.currentRetryAttempt !== 'number') { + opts.currentRetryAttempt = DEFAULTS.currentRetryAttempt; + } + if (typeof opts.noResponseRetries !== 'number') { + opts.noResponseRetries = DEFAULTS.noResponseRetries; + } + if (typeof opts.shouldRetryFn !== 'function') { + opts.shouldRetryFn = DEFAULTS.shouldRetryFn; + } + + var currentRetryAttempt = opts.currentRetryAttempt; + + var numNoResponseAttempts = 0; + var streamResponseHandled = false; + + var retryStream; + var requestStream; + var delayStream; + + var activeRequest; + var retryRequest = { + abort: function () { + if (activeRequest && activeRequest.abort) { + activeRequest.abort(); + } + } + }; + + if (streamMode) { + retryStream = through({ objectMode: opts.objectMode }); + retryStream.abort = resetStreams; + } + + if (currentRetryAttempt > 0) { + retryAfterDelay(currentRetryAttempt); + } else { + makeRequest(); + } + + if (streamMode) { + return retryStream; + } else { + return retryRequest; + } + + function resetStreams() { + delayStream = null; + + if (requestStream) { + requestStream.abort && requestStream.abort(); + requestStream.cancel && requestStream.cancel(); + + if (requestStream.destroy) { + requestStream.destroy(); + } else if (requestStream.end) { + requestStream.end(); + } + } + } + + function makeRequest() { + currentRetryAttempt++; + + if (streamMode) { + streamResponseHandled = false; + + delayStream = through({ objectMode: opts.objectMode }); + requestStream = opts.request(requestOpts); + + setImmediate(function () { + retryStream.emit('request'); + }); + + requestStream + // gRPC via google-cloud-node can emit an `error` as well as a `response` + // Whichever it emits, we run with-- we can't run with both. That's what + // is up with the `streamResponseHandled` tracking. + .on('error', function (err) { + if (streamResponseHandled) { + return; + } + + streamResponseHandled = true; + onResponse(err); + }) + .on('response', function (resp, body) { + if (streamResponseHandled) { + return; + } + + streamResponseHandled = true; + onResponse(null, resp, body); + }) + .on('complete', retryStream.emit.bind(retryStream, 'complete')); + + requestStream.pipe(delayStream); + } else { + activeRequest = opts.request(requestOpts, onResponse); + } + } + + function retryAfterDelay(currentRetryAttempt) { + if (streamMode) { + resetStreams(); + } + + setTimeout(makeRequest, getNextRetryDelay(currentRetryAttempt)); + } + + function onResponse(err, response, body) { + // An error such as DNS resolution. + if (err) { + numNoResponseAttempts++; + + if (numNoResponseAttempts <= opts.noResponseRetries) { + retryAfterDelay(numNoResponseAttempts); + } else { + if (streamMode) { + retryStream.emit('error', err); + retryStream.end(); + } else { + callback(err, response, body); + } + } + + return; + } + + // Send the response to see if we should try again. + if (currentRetryAttempt <= opts.retries && opts.shouldRetryFn(response)) { + retryAfterDelay(currentRetryAttempt); + return; + } + + // No more attempts need to be made, just continue on. + if (streamMode) { + retryStream.emit('response', response); + delayStream.pipe(retryStream); + requestStream.on('error', function (err) { + retryStream.destroy(err); + }); + } else { + callback(err, response, body); + } + } +} + +module.exports = retryRequest; + +function getNextRetryDelay(retryNumber) { + return (Math.pow(2, retryNumber) * 1000) + Math.floor(Math.random() * 1000); +} + +module.exports.getNextRetryDelay = getNextRetryDelay; diff --git a/website/functions/node_modules/@google-cloud/common/node_modules/retry-request/license b/website/functions/node_modules/@google-cloud/common/node_modules/retry-request/license new file mode 100644 index 00000000..df6eeb55 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/common/node_modules/retry-request/license @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2015 Stephen Sawchuk + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/website/functions/node_modules/@google-cloud/common/node_modules/retry-request/package.json b/website/functions/node_modules/@google-cloud/common/node_modules/retry-request/package.json new file mode 100644 index 00000000..740a0545 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/common/node_modules/retry-request/package.json @@ -0,0 +1,70 @@ +{ + "_from": "retry-request@^3.0.0", + "_id": "retry-request@3.3.2", + "_inBundle": false, + "_integrity": "sha512-WIiGp37XXDC6e7ku3LFoi7LCL/Gs9luGeeqvbPRb+Zl6OQMw4RCRfSaW+aLfE6lhz1R941UavE6Svl3Dm5xGIQ==", + "_location": "/@google-cloud/common/retry-request", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "retry-request@^3.0.0", + "name": "retry-request", + "escapedName": "retry-request", + "rawSpec": "^3.0.0", + "saveSpec": null, + "fetchSpec": "^3.0.0" + }, + "_requiredBy": [ + "/@google-cloud/common" + ], + "_resolved": "https://registry.npmjs.org/retry-request/-/retry-request-3.3.2.tgz", + "_shasum": "fd8e0079e7b0dfc7056e500b6f089437db0da4df", + "_spec": "retry-request@^3.0.0", + "_where": "C:\\Users\\jlevi\\Downloads\\tr2022-strategy-master\\tr2022-strategy-master\\data analysis\\functions\\node_modules\\@google-cloud\\common", + "author": { + "name": "Stephen Sawchuk", + "email": "sawchuk@gmail.com" + }, + "bugs": { + "url": "https://github.com/stephenplusplus/retry-request/issues" + }, + "bundleDependencies": false, + "dependencies": { + "request": "^2.81.0", + "through2": "^2.0.0" + }, + "deprecated": false, + "description": "Retry a request.", + "devDependencies": { + "async": "^2.5.0", + "lodash.range": "^3.2.0", + "mocha": "^2.2.5" + }, + "engines": { + "node": ">=4" + }, + "files": [ + "index.js", + "index.d.ts", + "license" + ], + "homepage": "https://github.com/stephenplusplus/retry-request#readme", + "keywords": [ + "request", + "retry", + "stream" + ], + "license": "MIT", + "main": "index.js", + "name": "retry-request", + "repository": { + "type": "git", + "url": "git+https://github.com/stephenplusplus/retry-request.git" + }, + "scripts": { + "test": "mocha --timeout 0" + }, + "types": "index.d.ts", + "version": "3.3.2" +} diff --git a/website/functions/node_modules/@google-cloud/common/node_modules/retry-request/readme.md b/website/functions/node_modules/@google-cloud/common/node_modules/retry-request/readme.md new file mode 100644 index 00000000..62feabd2 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/common/node_modules/retry-request/readme.md @@ -0,0 +1,152 @@ +|![retry-request](logo.png) +|:-: +|Retry a [request][request] with built-in [exponential backoff](https://developers.google.com/analytics/devguides/reporting/core/v3/coreErrors#backoff). + +```sh +$ npm install --save retry-request +``` +```js +var request = require('retry-request'); +``` + +It should work the same as `request` in both callback mode and stream mode. + +Note: This module only works when used as a readable stream, i.e. POST requests aren't supported ([#3](https://github.com/stephenplusplus/retry-request/issues/3)). + +#### Callback + +`urlThatReturns503` will be requested 3 total times before giving up and executing the callback. + +```js +request(urlThatReturns503, function (err, resp, body) {}); +``` + +#### Stream + +`urlThatReturns503` will be requested 3 total times before giving up and emitting the `response` and `complete` event as usual. + +```js +request(urlThatReturns503) + .on('error', function () {}) + .on('response', function () {}) + .on('complete', function () {}); +``` + +## request(requestOptions, [opts], [cb]) + +### requestOptions + +Passed directly to `request`. See the list of options supported: https://github.com/request/request/#requestoptions-callback. + +### opts *(optional)* + +#### `opts.noResponseRetries` + +Type: `Number` + +Default: `2` + +The number of times to retry after a response fails to come through, such as a DNS resolution error or a socket hangup. + +```js +var opts = { + noResponseRetries: 0 +}; + +request(url, opts, function (err, resp, body) { + // url was requested 1 time before giving up and + // executing this callback. +}); +``` + +#### `opts.objectMode` + +Type: `Boolean` + +Default: `false` + +Set to `true` if your custom `opts.request` function returns a stream in object mode. + +#### `opts.retries` + +Type: `Number` + +Default: `2` + +```js +var opts = { + retries: 4 +}; + +request(urlThatReturns503, opts, function (err, resp, body) { + // urlThatReturns503 was requested a total of 5 times + // before giving up and executing this callback. +}); +``` + +#### `opts.currentRetryAttempt` + +Type: `Number` + +Default: `0` + +```js +var opts = { + currentRetryAttempt: 1 +}; + +request(urlThatReturns503, opts, function (err, resp, body) { + // urlThatReturns503 was requested as if it already failed once. +}); +``` + +#### `opts.shouldRetryFn` + +Type: `Function` + +Default: Returns `true` if [http.incomingMessage](https://nodejs.org/api/http.html#http_http_incomingmessage).statusCode is < 200 or >= 400. + +```js +var opts = { + shouldRetryFn: function (incomingHttpMessage) { + return incomingHttpMessage.statusMessage !== 'OK'; + } +}; + +request(urlThatReturnsNonOKStatusMessage, opts, function (err, resp, body) { + // urlThatReturnsNonOKStatusMessage was requested a + // total of 3 times, each time using `opts.shouldRetryFn` + // to decide if it should continue before giving up and + // executing this callback. +}); +``` + +#### `opts.request` + +Type: `Function` + +Default: [`request`][request] + +*NOTE: If you override the request function, and it returns a stream in object mode, be sure to set `opts.objectMode` to `true`.* + +```js +var originalRequest = require('request').defaults({ + pool: { + maxSockets: Infinity + } +}); + +var opts = { + request: originalRequest +}; + +request(urlThatReturns503, opts, function (err, resp, body) { + // Your provided `originalRequest` instance was used. +}); +``` + +### cb *(optional)* + +Passed directly to `request`. See the callback section: https://github.com/request/request/#requestoptions-callback. + +[request]: https://github.com/request/request diff --git a/website/functions/node_modules/@google-cloud/common/package.json b/website/functions/node_modules/@google-cloud/common/package.json new file mode 100644 index 00000000..02090733 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/common/package.json @@ -0,0 +1,166 @@ +{ + "_from": "@google-cloud/common@^0.17.0", + "_id": "@google-cloud/common@0.17.0", + "_inBundle": false, + "_integrity": "sha512-HRZLSU762E6HaKoGfJGa8W95yRjb9rY7LePhjaHK9ILAnFacMuUGVamDbTHu1csZomm1g3tZTtXfX/aAhtie/Q==", + "_location": "/@google-cloud/common", + "_phantomChildren": { + "request": "2.88.0", + "through2": "2.0.5" + }, + "_requested": { + "type": "range", + "registry": true, + "raw": "@google-cloud/common@^0.17.0", + "name": "@google-cloud/common", + "escapedName": "@google-cloud%2fcommon", + "scope": "@google-cloud", + "rawSpec": "^0.17.0", + "saveSpec": null, + "fetchSpec": "^0.17.0" + }, + "_requiredBy": [ + "/@google-cloud/storage" + ], + "_resolved": "https://registry.npmjs.org/@google-cloud/common/-/common-0.17.0.tgz", + "_shasum": "8ef558750db481fc10a13757a49479ab9a1c8c07", + "_spec": "@google-cloud/common@^0.17.0", + "_where": "C:\\Users\\jlevi\\Downloads\\tr2022-strategy-master\\tr2022-strategy-master\\data analysis\\functions\\node_modules\\@google-cloud\\storage", + "author": { + "name": "Google Inc." + }, + "bugs": { + "url": "https://github.com/googleapis/nodejs-common/issues" + }, + "bundleDependencies": false, + "contributors": [ + { + "name": "Ali Ijaz Sheikh", + "email": "ofrobots@google.com" + }, + { + "name": "Austin Peterson", + "email": "austin@akpwebdesign.com" + }, + { + "name": "Dave Gramlich", + "email": "callmehiphop@gmail.com" + }, + { + "name": "Eric Uldall", + "email": "ericuldall@gmail.com" + }, + { + "name": "Ernest Landrito", + "email": "landrito@google.com" + }, + { + "name": "Jason Dobry", + "email": "jdobry@google.com" + }, + { + "name": "Justin King", + "email": "jcking@mtu.edu" + }, + { + "name": "Karolis Narkevicius", + "email": "karolis.n@gmail.com" + }, + { + "name": "Kelvin Jin", + "email": "kelvinjin@google.com" + }, + { + "name": "Luke Sneeringer", + "email": "lukesneeringer@google.com" + }, + { + "name": "Matthew Loring", + "email": "matthewloring@users.noreply.github.com" + }, + { + "name": "Michael Prentice", + "email": "splaktar@gmail.com" + }, + { + "name": "Stephen Sawchuk", + "email": "sawchuk@gmail.com" + }, + { + "name": "Tim Swast", + "email": "swast@google.com" + } + ], + "dependencies": { + "array-uniq": "^1.0.3", + "arrify": "^1.0.1", + "concat-stream": "^1.6.0", + "create-error-class": "^3.0.2", + "duplexify": "^3.5.0", + "ent": "^2.2.0", + "extend": "^3.0.1", + "google-auto-auth": "^0.10.0", + "is": "^3.2.0", + "log-driver": "1.2.7", + "methmeth": "^1.1.0", + "modelo": "^4.2.0", + "request": "^2.79.0", + "retry-request": "^3.0.0", + "split-array-stream": "^1.0.0", + "stream-events": "^1.0.1", + "string-format-obj": "^1.1.0", + "through2": "^2.0.3" + }, + "deprecated": false, + "description": "Common components for Cloud APIs Node.js Client Libraries", + "devDependencies": { + "@google-cloud/nodejs-repo-tools": "^2.1.1", + "async": "^2.6.0", + "codecov": "^3.0.0", + "eslint": "^4.10.0", + "eslint-config-prettier": "^2.7.0", + "eslint-plugin-node": "^6.0.0", + "eslint-plugin-prettier": "^2.3.1", + "ink-docstrap": "^1.3.0", + "intelli-espower-loader": "^1.0.1", + "js-green-licenses": "^0.5.0", + "jsdoc": "^3.5.5", + "mocha": "^5.0.0", + "nyc": "^11.3.0", + "power-assert": "^1.4.4", + "prettier": "^1.11.1", + "proxyquire": "^2.0.0", + "uuid": "^3.0.1" + }, + "engines": { + "node": ">=4.0.0" + }, + "files": [ + "src", + "AUTHORS", + "CONTRIBUTORS", + "LICENSE" + ], + "homepage": "https://github.com/googleapis/nodejs-common#readme", + "license": "Apache-2.0", + "main": "./src/index.js", + "name": "@google-cloud/common", + "repository": { + "type": "git", + "url": "git+https://github.com/googleapis/nodejs-common.git" + }, + "scripts": { + "cover": "nyc --reporter=lcov mocha --require intelli-espower-loader test/*.js && nyc report", + "docs": "repo-tools exec -- jsdoc -c .jsdoc.js", + "generate-scaffolding": "repo-tools generate all", + "license-check": "jsgl --local .", + "lint": "repo-tools lint --cmd eslint -- src/ samples/ system-test/ test/", + "posttest": "npm run license-check", + "prettier": "repo-tools exec -- prettier --write src/*.js src/*/*.js samples/*.js samples/*/*.js test/*.js test/*/*.js system-test/*.js system-test/*/*.js", + "publish-module": "node ../../scripts/publish.js common", + "samples-test": "cd samples/ && npm link ../ && npm test && cd ../", + "test": "repo-tools test run --cmd npm -- run cover", + "test-no-cover": "repo-tools test run --cmd mocha -- test/*.js --no-timeouts" + }, + "version": "0.17.0" +} diff --git a/website/functions/node_modules/@google-cloud/common/src/index.js b/website/functions/node_modules/@google-cloud/common/src/index.js new file mode 100644 index 00000000..f27cd73b --- /dev/null +++ b/website/functions/node_modules/@google-cloud/common/src/index.js @@ -0,0 +1,51 @@ +/*! + * Copyright 2016 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. + */ + +/** + * @type {module:common/logger} + * @private + */ +exports.logger = require('./logger.js'); + +/** + * @type {module:common/operation} + * @private + */ +exports.Operation = require('./operation.js'); + +/** + * @type {module:common/paginator} + * @private + */ +exports.paginator = require('./paginator.js'); + +/** + * @type {module:common/service} + * @private + */ +exports.Service = require('./service.js'); + +/** + * @type {module:common/serviceObject} + * @private + */ +exports.ServiceObject = require('./service-object.js'); + +/** + * @type {module:common/util} + * @private + */ +exports.util = require('./util.js'); diff --git a/website/functions/node_modules/@google-cloud/common/src/logger.js b/website/functions/node_modules/@google-cloud/common/src/logger.js new file mode 100644 index 00000000..3206aca5 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/common/src/logger.js @@ -0,0 +1,71 @@ +/*! + * Copyright 2016 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. + */ + +'use strict'; + +/*! + * @module common/logger + */ + +const format = require('string-format-obj'); +const is = require('is'); +const logDriver = require('log-driver'); + +/** + * The default list of log levels. + * @type {string[]} + */ +const LEVELS = ['silent', 'error', 'warn', 'info', 'debug', 'silly']; + +/** + * Create a logger to print output to the console. + * + * @param {string=|object=} options - Configuration object. If a string, it is + * treated as `options.level`. + * @param {string=} options.level - The minimum log level that will print to the + * console. (Default: `error`) + * @param {Array.=} options.levels - The list of levels to use. (Default: + * logger.LEVELS) + * @param {string=} options.tag - A tag to use in log messages. + */ +function logger(options) { + if (is.string(options)) { + options = { + level: options, + }; + } + + options = options || {}; + + return logDriver({ + levels: options.levels || LEVELS, + + level: options.level || 'error', + + format: function() { + const args = [].slice.call(arguments); + + return format('{level}{tag} {message}', { + level: args.shift().toUpperCase(), + tag: options.tag ? ':' + options.tag + ':' : '', + message: args.join(' '), + }); + }, + }); +} + +module.exports = logger; +module.exports.LEVELS = LEVELS; diff --git a/website/functions/node_modules/@google-cloud/common/src/operation.js b/website/functions/node_modules/@google-cloud/common/src/operation.js new file mode 100644 index 00000000..978b972f --- /dev/null +++ b/website/functions/node_modules/@google-cloud/common/src/operation.js @@ -0,0 +1,193 @@ +/*! + * Copyright 2016 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. + */ + +/*! + * @module common/operation + */ + +'use strict'; + +const events = require('events'); +const extend = require('extend'); +const modelo = require('modelo'); + +/** + * @type {module:common/serviceObject} + * @private + */ +const ServiceObject = require('./service-object.js'); + +// jscs:disable maximumLineLength +/** + * An Operation object allows you to interact with APIs that take longer to + * process things. + * + * @constructor + * @alias module:common/operation + * + * @param {object} config - Configuration object. + * @param {module:common/service|module:common/serviceObject|module:common/grpcService|module:common/grpcServiceObject} config.parent - The + * parent object. + * @param {string} id - The operation ID. + */ +// jscs:enable maximumLineLength +function Operation(config) { + const methods = { + /** + * Checks to see if an operation exists. + */ + exists: true, + + /** + * Retrieves the operation. + */ + get: true, + + /** + * Retrieves metadata for the operation. + */ + getMetadata: { + reqOpts: { + name: config.id, + }, + }, + }; + + config = extend( + { + baseUrl: '', + }, + config + ); + + config.methods = config.methods || methods; + + ServiceObject.call(this, config); + events.EventEmitter.call(this); + + this.completeListeners = 0; + this.hasActiveListeners = false; + + this.listenForEvents_(); +} + +modelo.inherits(Operation, ServiceObject, events.EventEmitter); + +/** + * Wraps the `complete` and `error` events in a Promise. + * + * @return {promise} + */ +Operation.prototype.promise = function() { + const self = this; + + return new self.Promise(function(resolve, reject) { + self.on('error', reject).on('complete', function(metadata) { + resolve([metadata]); + }); + }); +}; + +/** + * Begin listening for events on the operation. This method keeps track of how + * many "complete" listeners are registered and removed, making sure polling is + * handled automatically. + * + * As long as there is one active "complete" listener, the connection is open. + * When there are no more listeners, the polling stops. + * + * @private + */ +Operation.prototype.listenForEvents_ = function() { + const self = this; + + this.on('newListener', function(event) { + if (event === 'complete') { + self.completeListeners++; + + if (!self.hasActiveListeners) { + self.hasActiveListeners = true; + self.startPolling_(); + } + } + }); + + this.on('removeListener', function(event) { + if (event === 'complete' && --self.completeListeners === 0) { + self.hasActiveListeners = false; + } + }); +}; + +/** + * Poll for a status update. Execute the callback: + * + * - callback(err): Operation failed + * - callback(): Operation incomplete + * - callback(null, metadata): Operation complete + * + * @private + * + * @param {function} callback + */ +Operation.prototype.poll_ = function(callback) { + this.getMetadata(function(err, resp) { + if (err || resp.error) { + callback(err || resp.error); + return; + } + + if (!resp.done) { + callback(); + return; + } + + callback(null, resp); + }); +}; + +/** + * Poll `getMetadata` to check the operation's status. This runs a loop to ping + * the API on an interval. + * + * Note: This method is automatically called once a "complete" event handler is + * registered on the operation. + * + * @private + */ +Operation.prototype.startPolling_ = function() { + const self = this; + + if (!this.hasActiveListeners) { + return; + } + + this.poll_(function(err, metadata) { + if (err) { + self.emit('error', err); + return; + } + + if (!metadata) { + setTimeout(self.startPolling_.bind(self), 500); + return; + } + + self.emit('complete', metadata); + }); +}; + +module.exports = Operation; diff --git a/website/functions/node_modules/@google-cloud/common/src/paginator.js b/website/functions/node_modules/@google-cloud/common/src/paginator.js new file mode 100644 index 00000000..732e9f01 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/common/src/paginator.js @@ -0,0 +1,267 @@ +/*! + * Copyright 2015 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. + */ + +/*! + * @module common/paginator + */ + +'use strict'; + +const arrify = require('arrify'); +const concat = require('concat-stream'); +const extend = require('extend'); +const is = require('is'); +const split = require('split-array-stream'); + +/** + * @type {module:common/util} + * @private + */ +const util = require('./util.js'); + +/*! Developer Documentation + * + * paginator is used to auto-paginate `nextQuery` methods as well as + * streamifying them. + * + * Before: + * + * search.query('done=true', function(err, results, nextQuery) { + * search.query(nextQuery, function(err, results, nextQuery) {}); + * }); + * + * After: + * + * search.query('done=true', function(err, results) {}); + * + * Methods to extend should be written to accept callbacks and return a + * `nextQuery`. + */ +const paginator = {}; + +/** + * Cache the original method, then overwrite it on the Class's prototype. + * + * @param {function} Class - The parent class of the methods to extend. + * @param {string|string[]} methodNames - Name(s) of the methods to extend. + */ +paginator.extend = function(Class, methodNames) { + methodNames = arrify(methodNames); + + methodNames.forEach(function(methodName) { + const originalMethod = Class.prototype[methodName]; + + // map the original method to a private member + Class.prototype[methodName + '_'] = originalMethod; + + // overwrite the original to auto-paginate + Class.prototype[methodName] = function() { + const parsedArguments = paginator.parseArguments_(arguments); + return paginator.run_(parsedArguments, originalMethod.bind(this)); + }; + }); +}; + +/** + * Wraps paginated API calls in a readable object stream. + * + * This method simply calls the nextQuery recursively, emitting results to a + * stream. The stream ends when `nextQuery` is null. + * + * `maxResults` will act as a cap for how many results are fetched and emitted + * to the stream. + * + * @param {string} methodName - Name of the method to streamify. + * @return {function} - Wrapped function. + */ +paginator.streamify = function(methodName) { + return function() { + const parsedArguments = paginator.parseArguments_(arguments); + const originalMethod = this[methodName + '_'] || this[methodName]; + + return paginator.runAsStream_(parsedArguments, originalMethod.bind(this)); + }; +}; + +/** + * Parse a pseudo-array `arguments` for a query and callback. + * + * @param {array} args - The original `arguments` pseduo-array that the original + * method received. + */ +paginator.parseArguments_ = function(args) { + let query; + let autoPaginate = true; + let maxApiCalls = -1; + let maxResults = -1; + let callback; + + const firstArgument = args[0]; + const lastArgument = args[args.length - 1]; + + if (is.fn(firstArgument)) { + callback = firstArgument; + } else { + query = firstArgument; + } + + if (is.fn(lastArgument)) { + callback = lastArgument; + } + + if (is.object(query)) { + query = extend(true, {}, query); + + // Check if the user only asked for a certain amount of results. + if (is.number(query.maxResults)) { + // `maxResults` is used API-wide. + maxResults = query.maxResults; + } else if (is.number(query.pageSize)) { + // `pageSize` is Pub/Sub's `maxResults`. + maxResults = query.pageSize; + } + + if (is.number(query.maxApiCalls)) { + maxApiCalls = query.maxApiCalls; + delete query.maxApiCalls; + } + + if ( + callback && + (maxResults !== -1 || // The user specified a limit. + query.autoPaginate === false) + ) { + autoPaginate = false; + } + } + + const parsedArguments = { + query: query || {}, + autoPaginate: autoPaginate, + maxApiCalls: maxApiCalls, + maxResults: maxResults, + callback: callback, + }; + + parsedArguments.streamOptions = extend(true, {}, parsedArguments.query); + delete parsedArguments.streamOptions.autoPaginate; + delete parsedArguments.streamOptions.maxResults; + delete parsedArguments.streamOptions.pageSize; + + return parsedArguments; +}; + +/** + * This simply checks to see if `autoPaginate` is set or not, if it's true + * then we buffer all results, otherwise simply call the original method. + * + * @param {array} parsedArguments - Parsed arguments from the original method + * call. + * @param {object=|string=} parsedArguments.query - Query object. This is most + * commonly an object, but to make the API more simple, it can also be a + * string in some places. + * @param {function=} parsedArguments.callback - Callback function. + * @param {boolean} parsedArguments.autoPaginate - Auto-pagination enabled. + * @param {boolean} parsedArguments.maxApiCalls - Maximum API calls to make. + * @param {number} parsedArguments.maxResults - Maximum results to return. + * @param {function} originalMethod - The cached method that accepts a callback + * and returns `nextQuery` to receive more results. + */ +paginator.run_ = function(parsedArguments, originalMethod) { + const query = parsedArguments.query; + const callback = parsedArguments.callback; + const autoPaginate = parsedArguments.autoPaginate; + + if (autoPaginate) { + this.runAsStream_(parsedArguments, originalMethod) + .on('error', callback) + .pipe( + concat(function(results) { + callback(null, results); + }) + ); + } else { + originalMethod(query, callback); + } +}; + +/** + * This method simply calls the nextQuery recursively, emitting results to a + * stream. The stream ends when `nextQuery` is null. + * + * `maxResults` will act as a cap for how many results are fetched and emitted + * to the stream. + * + * @param {object=|string=} parsedArguments.query - Query object. This is most + * commonly an object, but to make the API more simple, it can also be a + * string in some places. + * @param {function=} parsedArguments.callback - Callback function. + * @param {boolean} parsedArguments.autoPaginate - Auto-pagination enabled. + * @param {boolean} parsedArguments.maxApiCalls - Maximum API calls to make. + * @param {number} parsedArguments.maxResults - Maximum results to return. + * @param {function} originalMethod - The cached method that accepts a callback + * and returns `nextQuery` to receive more results. + * @return {stream} - Readable object stream. + */ +paginator.runAsStream_ = function(parsedArguments, originalMethod) { + let query = parsedArguments.query; + let resultsToSend = parsedArguments.maxResults; + + const limiter = util.createLimiter(makeRequest, { + maxApiCalls: parsedArguments.maxApiCalls, + streamOptions: parsedArguments.streamOptions, + }); + + const stream = limiter.stream; + + stream.once('reading', function() { + makeRequest(query); + }); + + function makeRequest(query) { + originalMethod(query, onResultSet); + } + + function onResultSet(err, results, nextQuery) { + if (err) { + stream.destroy(err); + return; + } + + if (resultsToSend >= 0 && results.length > resultsToSend) { + results = results.splice(0, resultsToSend); + } + + resultsToSend -= results.length; + + split(results, stream, function(streamEnded) { + if (streamEnded) { + return; + } + + if (nextQuery && resultsToSend !== 0) { + limiter.makeRequest(nextQuery); + return; + } + + stream.push(null); + }); + } + + return limiter.stream; +}; + +module.exports = paginator; diff --git a/website/functions/node_modules/@google-cloud/common/src/service-object.js b/website/functions/node_modules/@google-cloud/common/src/service-object.js new file mode 100644 index 00000000..0fe9b1c9 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/common/src/service-object.js @@ -0,0 +1,392 @@ +/*! + * Copyright 2015 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. + */ + +/*! + * @module common/service-object + */ + +'use strict'; + +const arrify = require('arrify'); +const exec = require('methmeth'); +const extend = require('extend'); +const is = require('is'); + +/** + * @type {module:common/util} + * @private + */ +const util = require('./util.js'); + +/** + * ServiceObject is a base class, meant to be inherited from by a "service + * object," like a BigQuery dataset or Storage bucket. + * + * Most of the time, these objects share common functionality; they can be + * created or deleted, and you can get or set their metadata. + * + * By inheriting from this class, a service object will be extended with these + * shared behaviors. Note that any method can be overridden when the service + * object requires specific behavior. + * + * @constructor + * @alias module:common/service-object + * + * @private + * + * @param {object} config - Configuration object. + * @param {string} config.baseUrl - The base URL to make API requests to. + * @param {string} config.createMethod - The method which creates this object. + * @param {string=} config.id - The identifier of the object. For example, the + * name of a Storage bucket or Pub/Sub topic. + * @param {object=} config.methods - A map of each method name that should be + * inherited. + * @param {object} config.methods[].reqOpts - Default request options for this + * particular method. A common use case is when `setMetadata` requires a + * `PUT` method to override the default `PATCH`. + * @param {object} config.parent - The parent service instance. For example, an + * instance of Storage if the object is Bucket. + */ +function ServiceObject(config) { + const self = this; + + util.privatize(this, 'metadata', {}); + + util.privatize(this, 'baseUrl', config.baseUrl); + util.privatize(this, 'parent', config.parent); // Parent class. + util.privatize(this, 'id', config.id); // Name or ID (e.g. dataset ID, bucket name, etc.) + util.privatize(this, 'createMethod', config.createMethod); + util.privatize(this, 'methods', config.methods || {}); + util.privatize(this, 'interceptors', []); + util.privatize(this, 'Promise', this.parent.Promise); + + if (config.methods) { + const allMethodNames = Object.keys(ServiceObject.prototype); + allMethodNames + .filter(function(methodName) { + return ( + // All ServiceObjects need `request`. + !/^request/.test(methodName) && + // The ServiceObject didn't redefine the method. + self[methodName] === ServiceObject.prototype[methodName] && + // This method isn't wanted. + !config.methods[methodName] + ); + }) + .forEach(function(methodName) { + self[methodName] = undefined; + }); + } +} + +/** + * Create the object. + * + * @param {object=} options - Configuration object. + * @param {function} callback - The callback function. + * @param {?error} callback.err - An error returned while making this request. + * @param {object} callback.instance - The instance. + * @param {object} callback.apiResponse - The full API response. + */ +ServiceObject.prototype.create = function(options, callback) { + const self = this; + const args = [this.id]; + + if (is.fn(options)) { + callback = options; + } + + if (is.object(options)) { + args.push(options); + } + + // Wrap the callback to return *this* instance of the object, not the newly- + // created one. + function onCreate(err, instance) { + const args = [].slice.call(arguments); + + if (!err) { + self.metadata = instance.metadata; + args[1] = self; // replace the created `instance` with this one. + } + + callback.apply(null, args); + } + + args.push(onCreate); + + this.createMethod.apply(null, args); +}; + +/** + * Delete the object. + * + * @param {function=} callback - The callback function. + * @param {?error} callback.err - An error returned while making this request. + * @param {object} callback.apiResponse - The full API response. + */ +ServiceObject.prototype.delete = function(callback) { + const methodConfig = this.methods.delete || {}; + callback = callback || util.noop; + + const reqOpts = extend( + { + method: 'DELETE', + uri: '', + }, + methodConfig.reqOpts + ); + + // The `request` method may have been overridden to hold any special behavior. + // Ensure we call the original `request` method. + ServiceObject.prototype.request.call(this, reqOpts, function(err, resp) { + callback(err, resp); + }); +}; + +/** + * Check if the object exists. + * + * @param {function} callback - The callback function. + * @param {?error} callback.err - An error returned while making this request. + * @param {boolean} callback.exists - Whether the object exists or not. + */ +ServiceObject.prototype.exists = function(callback) { + this.get(function(err) { + if (err) { + if (err.code === 404) { + callback(null, false); + } else { + callback(err); + } + + return; + } + + callback(null, true); + }); +}; + +/** + * Get the object if it exists. Optionally have the object created if an options + * object is provided with `autoCreate: true`. + * + * @param {object=} config - The configuration object that will be used to + * create the object if necessary. + * @param {boolean} config.autoCreate - Create the object if it doesn't already + * exist. + * @param {function} callback - The callback function. + * @param {?error} callback.err - An error returned while making this request. + * @param {object} callback.instance - The instance. + * @param {object} callback.apiResponse - The full API response. + */ +ServiceObject.prototype.get = function(config, callback) { + const self = this; + + if (is.fn(config)) { + callback = config; + config = {}; + } + + config = config || {}; + + const autoCreate = config.autoCreate && is.fn(this.create); + delete config.autoCreate; + + function onCreate(err, instance, apiResponse) { + if (err) { + if (err.code === 409) { + self.get(config, callback); + return; + } + + callback(err, null, apiResponse); + return; + } + + callback(null, instance, apiResponse); + } + + this.getMetadata(function(err, metadata) { + if (err) { + if (err.code === 404 && autoCreate) { + const args = []; + + if (!is.empty(config)) { + args.push(config); + } + + args.push(onCreate); + + self.create.apply(self, args); + return; + } + + callback(err, null, metadata); + return; + } + + callback(null, self, metadata); + }); +}; + +/** + * Get the metadata of this object. + * + * @param {function} callback - The callback function. + * @param {?error} callback.err - An error returned while making this request. + * @param {object} callback.metadata - The metadata for this object. + * @param {object} callback.apiResponse - The full API response. + */ +ServiceObject.prototype.getMetadata = function(callback) { + const self = this; + + const methodConfig = this.methods.getMetadata || {}; + + const reqOpts = extend( + { + uri: '', + }, + methodConfig.reqOpts + ); + + // The `request` method may have been overridden to hold any special behavior. + // Ensure we call the original `request` method. + ServiceObject.prototype.request.call(this, reqOpts, function(err, resp) { + if (err) { + callback(err, null, resp); + return; + } + + self.metadata = resp; + + callback(null, self.metadata, resp); + }); +}; + +/** + * Set the metadata for this object. + * + * @param {object} metadata - The metadata to set on this object. + * @param {function=} callback - The callback function. + * @param {?error} callback.err - An error returned while making this request. + * @param {object} callback.instance - The instance. + * @param {object} callback.apiResponse - The full API response. + */ +ServiceObject.prototype.setMetadata = function(metadata, callback) { + const self = this; + + callback = callback || util.noop; + + const methodConfig = this.methods.setMetadata || {}; + + const reqOpts = extend( + true, + { + method: 'PATCH', + uri: '', + json: metadata, + }, + methodConfig.reqOpts + ); + + // The `request` method may have been overridden to hold any special behavior. + // Ensure we call the original `request` method. + ServiceObject.prototype.request.call(this, reqOpts, function(err, resp) { + if (err) { + callback(err, resp); + return; + } + + self.metadata = resp; + + callback(null, resp); + }); +}; + +/** + * Make an authenticated API request. + * + * @private + * + * @param {object} reqOpts - Request options that are passed to `request`. + * @param {string} reqOpts.uri - A URI relative to the baseUrl. + * @param {function} callback - The callback function passed to `request`. + */ +ServiceObject.prototype.request_ = function(reqOpts, callback) { + reqOpts = extend(true, {}, reqOpts); + + const isAbsoluteUrl = reqOpts.uri.indexOf('http') === 0; + + const uriComponents = [this.baseUrl, this.id || '', reqOpts.uri]; + + if (isAbsoluteUrl) { + uriComponents.splice(0, uriComponents.indexOf(reqOpts.uri)); + } + + reqOpts.uri = uriComponents + .filter(exec('trim')) // Limit to non-empty strings. + .map(function(uriComponent) { + const trimSlashesRegex = /^\/*|\/*$/g; + return uriComponent.replace(trimSlashesRegex, ''); + }) + .join('/'); + + const childInterceptors = arrify(reqOpts.interceptors_); + const localInterceptors = [].slice.call(this.interceptors); + + reqOpts.interceptors_ = childInterceptors.concat(localInterceptors); + + if (!callback) { + return this.parent.requestStream(reqOpts); + } + + this.parent.request(reqOpts, callback); +}; + +/** + * Make an authenticated API request. + * + * @private + * + * @param {object} reqOpts - Request options that are passed to `request`. + * @param {string} reqOpts.uri - A URI relative to the baseUrl. + * @param {function} callback - The callback function passed to `request`. + */ +ServiceObject.prototype.request = function(reqOpts, callback) { + ServiceObject.prototype.request_.call(this, reqOpts, callback); +}; + +/** + * Make an authenticated API request. + * + * @private + * + * @param {object} reqOpts - Request options that are passed to `request`. + * @param {string} reqOpts.uri - A URI relative to the baseUrl. + */ +ServiceObject.prototype.requestStream = function(reqOpts) { + return ServiceObject.prototype.request_.call(this, reqOpts); +}; + +/*! Developer Documentation + * + * All async methods (except for streams) will return a Promise in the event + * that a callback is omitted. + */ +util.promisifyAll(ServiceObject); + +module.exports = ServiceObject; diff --git a/website/functions/node_modules/@google-cloud/common/src/service.js b/website/functions/node_modules/@google-cloud/common/src/service.js new file mode 100644 index 00000000..c6f3348c --- /dev/null +++ b/website/functions/node_modules/@google-cloud/common/src/service.js @@ -0,0 +1,200 @@ +/*! + * Copyright 2015 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. + */ + +/*! + * @module common/service + */ + +'use strict'; + +const arrify = require('arrify'); +const extend = require('extend'); + +/** + * @type {module:common/util} + * @private + */ +const util = require('./util.js'); + +const PROJECT_ID_TOKEN = '{{projectId}}'; + +/** + * Service is a base class, meant to be inherited from by a "service," like + * BigQuery or Storage. + * + * This handles making authenticated requests by exposing a `makeReq_` function. + * + * @constructor + * @alias module:common/service + * + * @param {object} config - Configuration object. + * @param {string} config.baseUrl - The base URL to make API requests to. + * @param {string[]} config.scopes - The scopes required for the request. + * @param {object=} options - [Configuration object](#/docs). + */ +function Service(config, options) { + options = options || {}; + + util.privatize(this, 'baseUrl', config.baseUrl); + util.privatize(this, 'globalInterceptors', arrify(options.interceptors_)); + util.privatize(this, 'interceptors', []); + util.privatize(this, 'packageJson', config.packageJson); + util.privatize(this, 'projectId', options.projectId || PROJECT_ID_TOKEN); + util.privatize(this, 'projectIdRequired', config.projectIdRequired !== false); + util.privatize(this, 'Promise', options.promise || Promise); + + const reqCfg = extend({}, config, { + projectIdRequired: this.projectIdRequired, + projectId: this.projectId, + credentials: options.credentials, + keyFile: options.keyFilename, + email: options.email, + token: options.token, + }); + + util.privatize( + this, + 'makeAuthenticatedRequest', + util.makeAuthenticatedRequestFactory(reqCfg) + ); + util.privatize(this, 'authClient', this.makeAuthenticatedRequest.authClient); + util.privatize( + this, + 'getCredentials', + this.makeAuthenticatedRequest.getCredentials + ); + + const isCloudFunctionEnv = !!process.env.FUNCTION_NAME; + + if (isCloudFunctionEnv) { + this.interceptors.push({ + request: function(reqOpts) { + reqOpts.forever = false; + return reqOpts; + }, + }); + } +} + +/** + * Get and update the Service's project ID. + * + * @param {function} callback - The callback function. + */ +Service.prototype.getProjectId = function(callback) { + const self = this; + + this.authClient.getProjectId(function(err, projectId) { + if (err) { + callback(err); + return; + } + + if (self.projectId === PROJECT_ID_TOKEN && projectId) { + self.projectId = projectId; + } + + callback(null, self.projectId); + }); +}; + +/** + * Make an authenticated API request. + * + * @private + * + * @param {object} reqOpts - Request options that are passed to `request`. + * @param {string} reqOpts.uri - A URI relative to the baseUrl. + * @param {function} callback - The callback function passed to `request`. + */ +Service.prototype.request_ = function(reqOpts, callback) { + reqOpts = extend(true, {}, reqOpts); + + const isAbsoluteUrl = reqOpts.uri.indexOf('http') === 0; + + const uriComponents = [this.baseUrl]; + + if (this.projectIdRequired) { + uriComponents.push('projects'); + uriComponents.push(this.projectId); + } + + uriComponents.push(reqOpts.uri); + + if (isAbsoluteUrl) { + uriComponents.splice(0, uriComponents.indexOf(reqOpts.uri)); + } + + reqOpts.uri = uriComponents + .map(function(uriComponent) { + const trimSlashesRegex = /^\/*|\/*$/g; + return uriComponent.replace(trimSlashesRegex, ''); + }) + .join('/') + // Some URIs have colon separators. + // Bad: https://.../projects/:list + // Good: https://.../projects:list + .replace(/\/:/g, ':'); + + // Interceptors should be called in the order they were assigned. + const combinedInterceptors = [].slice + .call(this.globalInterceptors) + .concat(this.interceptors) + .concat(arrify(reqOpts.interceptors_)); + + let interceptor; + + while ((interceptor = combinedInterceptors.shift()) && interceptor.request) { + reqOpts = interceptor.request(reqOpts); + } + + delete reqOpts.interceptors_; + + const pkg = this.packageJson; + reqOpts.headers = extend({}, reqOpts.headers, { + 'User-Agent': util.getUserAgentFromPackageJson(pkg), + 'x-goog-api-client': `gl-node/${process.versions.node} gccl/${pkg.version}`, + }); + + return this.makeAuthenticatedRequest(reqOpts, callback); +}; + +/** + * Make an authenticated API request. + * + * @private + * + * @param {object} reqOpts - Request options that are passed to `request`. + * @param {string} reqOpts.uri - A URI relative to the baseUrl. + * @param {function} callback - The callback function passed to `request`. + */ +Service.prototype.request = function(reqOpts, callback) { + Service.prototype.request_.call(this, reqOpts, callback); +}; + +/** + * Make an authenticated API request. + * + * @private + * + * @param {object} reqOpts - Request options that are passed to `request`. + * @param {string} reqOpts.uri - A URI relative to the baseUrl. + */ +Service.prototype.requestStream = function(reqOpts) { + return Service.prototype.request_.call(this, reqOpts); +}; + +module.exports = Service; diff --git a/website/functions/node_modules/@google-cloud/common/src/util.js b/website/functions/node_modules/@google-cloud/common/src/util.js new file mode 100644 index 00000000..7178f528 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/common/src/util.js @@ -0,0 +1,830 @@ +/** + * Copyright 2014 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. + */ + +/*! + * @module common/util + */ + +'use strict'; + +const createErrorClass = require('create-error-class'); +const duplexify = require('duplexify'); +const ent = require('ent'); +const extend = require('extend'); +const googleAuth = require('google-auto-auth'); +const is = require('is'); +const request = require('request').defaults({ + timeout: 60000, + gzip: true, + forever: true, + pool: { + maxSockets: Infinity, + }, +}); +const retryRequest = require('retry-request'); +const streamEvents = require('stream-events'); +const through = require('through2'); +const uniq = require('array-uniq'); + +const util = module.exports; + +/** + * Custom error type for missing project ID errors. + */ +util.MissingProjectIdError = createErrorClass( + 'MissingProjectIdError', + function() { + this.message = `Sorry, we cannot connect to Cloud Services without a project + ID. You may specify one with an environment variable named + "GOOGLE_CLOUD_PROJECT".`.replace(/ +/g, ' '); + } +); + +/** + * No op. + * + * @example + * function doSomething(callback) { + * callback = callback || noop; + * } + */ +function noop() {} + +util.noop = noop; + +/** + * Custom error type for API errors. + * + * @param {object} errorBody - Error object. + */ +util.ApiError = createErrorClass('ApiError', function(errorBody) { + this.code = errorBody.code; + this.errors = errorBody.errors; + this.response = errorBody.response; + + try { + this.errors = JSON.parse(this.response.body).error.errors; + } catch (e) { + this.errors = errorBody.errors; + } + + const messages = []; + + if (errorBody.message) { + messages.push(errorBody.message); + } + + if (this.errors && this.errors.length === 1) { + messages.push(this.errors[0].message); + } else if (this.response && this.response.body) { + messages.push(ent.decode(errorBody.response.body.toString())); + } else if (!errorBody.message) { + messages.push('Error during request.'); + } + + this.message = uniq(messages).join(' - '); +}); + +/** + * Custom error type for partial errors returned from the API. + * + * @param {object} b - Error object. + */ +util.PartialFailureError = createErrorClass('PartialFailureError', function(b) { + const errorObject = b; + + this.errors = errorObject.errors; + this.response = errorObject.response; + + const defaultErrorMessage = 'A failure occurred during this request.'; + this.message = errorObject.message || defaultErrorMessage; +}); + +/** + * Uniformly process an API response. + * + * @param {*} err - Error value. + * @param {*} resp - Response value. + * @param {*} body - Body value. + * @param {function} callback - The callback function. + */ +function handleResp(err, resp, body, callback) { + callback = callback || util.noop; + + const parsedResp = extend( + true, + {err: err || null}, + resp && util.parseHttpRespMessage(resp), + body && util.parseHttpRespBody(body) + ); + + callback(parsedResp.err, parsedResp.body, parsedResp.resp); +} + +util.handleResp = handleResp; + +/** + * Sniff an incoming HTTP response message for errors. + * + * @param {object} httpRespMessage - An incoming HTTP response message from + * `request`. + * @return {object} parsedHttpRespMessage - The parsed response. + * @param {?error} parsedHttpRespMessage.err - An error detected. + * @param {object} parsedHttpRespMessage.resp - The original response object. + */ +function parseHttpRespMessage(httpRespMessage) { + const parsedHttpRespMessage = { + resp: httpRespMessage, + }; + + if (httpRespMessage.statusCode < 200 || httpRespMessage.statusCode > 299) { + // Unknown error. Format according to ApiError standard. + parsedHttpRespMessage.err = new util.ApiError({ + errors: [], + code: httpRespMessage.statusCode, + message: httpRespMessage.statusMessage, + response: httpRespMessage, + }); + } + + return parsedHttpRespMessage; +} + +util.parseHttpRespMessage = parseHttpRespMessage; + +/** + * Parse the response body from an HTTP request. + * + * @param {object} body - The response body. + * @return {object} parsedHttpRespMessage - The parsed response. + * @param {?error} parsedHttpRespMessage.err - An error detected. + * @param {object} parsedHttpRespMessage.body - The original body value provided + * will try to be JSON.parse'd. If it's successful, the parsed value will be + * returned here, otherwise the original value. + */ +function parseHttpRespBody(body) { + const parsedHttpRespBody = { + body: body, + }; + + if (is.string(body)) { + try { + parsedHttpRespBody.body = JSON.parse(body); + } catch (err) { + parsedHttpRespBody.err = new util.ApiError('Cannot parse JSON response'); + } + } + + if (parsedHttpRespBody.body && parsedHttpRespBody.body.error) { + // Error from JSON API. + parsedHttpRespBody.err = new util.ApiError(parsedHttpRespBody.body.error); + } + + return parsedHttpRespBody; +} + +util.parseHttpRespBody = parseHttpRespBody; + +/** + * Take a Duplexify stream, fetch an authenticated connection header, and create + * an outgoing writable stream. + * + * @param {Duplexify} dup - Duplexify stream. + * @param {object} options - Configuration object. + * @param {module:common/connection} options.connection - A connection instance, + * used to get a token with and send the request through. + * @param {object} options.metadata - Metadata to send at the head of the + * request. + * @param {object} options.request - Request object, in the format of a standard + * Node.js http.request() object. + * @param {string=} options.request.method - Default: "POST". + * @param {string=} options.request.qs.uploadType - Default: "multipart". + * @param {string=} options.streamContentType - Default: + * "application/octet-stream". + * @param {function} onComplete - Callback, executed after the writable Request + * stream has completed. + */ +function makeWritableStream(dup, options, onComplete) { + onComplete = onComplete || util.noop; + + const writeStream = through(); + dup.setWritable(writeStream); + + const defaultReqOpts = { + method: 'POST', + qs: { + uploadType: 'multipart', + }, + }; + + const metadata = options.metadata || {}; + + const reqOpts = extend(true, defaultReqOpts, options.request, { + multipart: [ + { + 'Content-Type': 'application/json', + body: JSON.stringify(metadata), + }, + { + 'Content-Type': metadata.contentType || 'application/octet-stream', + body: writeStream, + }, + ], + }); + + options.makeAuthenticatedRequest(reqOpts, { + onAuthenticated: function(err, authenticatedReqOpts) { + if (err) { + dup.destroy(err); + return; + } + + request(authenticatedReqOpts, function(err, resp, body) { + util.handleResp(err, resp, body, function(err, data) { + if (err) { + dup.destroy(err); + return; + } + + dup.emit('response', resp); + onComplete(data); + }); + }); + }, + }); +} + +util.makeWritableStream = makeWritableStream; + +/** + * Returns true if the API request should be retried, given the error that was + * given the first time the request was attempted. This is used for rate limit + * related errors as well as intermittent server errors. + * + * @param {error} err - The API error to check if it is appropriate to retry. + * @return {boolean} True if the API request should be retried, false otherwise. + */ +function shouldRetryRequest(err) { + if (err) { + if ([429, 500, 502, 503].indexOf(err.code) !== -1) { + return true; + } + + if (err.errors) { + for (const i in err.errors) { + const reason = err.errors[i].reason; + if (reason === 'rateLimitExceeded') { + return true; + } + if (reason === 'userRateLimitExceeded') { + return true; + } + } + } + } + + return false; +} + +util.shouldRetryRequest = shouldRetryRequest; + +/** + * Get a function for making authenticated requests. + * + * @throws {Error} If a projectId is requested, but not able to be detected. + * + * @param {object} config - Configuration object. + * @param {boolean=} config.autoRetry - Automatically retry requests if the + * response is related to rate limits or certain intermittent server errors. + * We will exponentially backoff subsequent requests by default. (default: + * true) + * @param {object=} config.credentials - Credentials object. + * @param {boolean=} config.customEndpoint - If true, just return the provided + * request options. Default: false. + * @param {string=} config.email - Account email address, required for PEM/P12 + * usage. + * @param {number=} config.maxRetries - Maximum number of automatic retries + * attempted before returning the error. (default: 3) + * @param {string=} config.keyFile - Path to a .json, .pem, or .p12 keyfile. + * @param {array} config.scopes - Array of scopes required for the API. + */ +function makeAuthenticatedRequestFactory(config) { + config = config || {}; + + const googleAutoAuthConfig = extend({}, config); + + if (googleAutoAuthConfig.projectId === '{{projectId}}') { + delete googleAutoAuthConfig.projectId; + } + + const authClient = googleAuth(googleAutoAuthConfig); + + /** + * The returned function that will make an authenticated request. + * + * @param {type} reqOpts - Request options in the format `request` expects. + * @param {object|function} options - Configuration object or callback + * function. + * @param {function=} options.onAuthenticated - If provided, a request will + * not be made. Instead, this function is passed the error & authenticated + * request options. + */ + function makeAuthenticatedRequest(reqOpts, options) { + let stream; + const reqConfig = extend({}, config); + let activeRequest_; + + if (!options) { + stream = duplexify(); + reqConfig.stream = stream; + } + + function onAuthenticated(err, authenticatedReqOpts) { + const autoAuthFailed = + err && + err.message.indexOf('Could not load the default credentials') > -1; + + if (autoAuthFailed) { + // Even though authentication failed, the API might not actually care. + authenticatedReqOpts = reqOpts; + } + + if (!err || autoAuthFailed) { + let projectId = authClient.projectId; + + if (config.projectId && config.projectId !== '{{projectId}}') { + projectId = config.projectId; + } + + try { + authenticatedReqOpts = util.decorateRequest( + authenticatedReqOpts, + projectId + ); + err = null; + } catch (e) { + // A projectId was required, but we don't have one. + // Re-use the "Could not load the default credentials error" if auto + // auth failed. + err = err || e; + } + } + + if (err) { + if (stream) { + stream.destroy(err); + } else { + (options.onAuthenticated || options)(err); + } + + return; + } + + if (options && options.onAuthenticated) { + options.onAuthenticated(null, authenticatedReqOpts); + } else { + activeRequest_ = util.makeRequest( + authenticatedReqOpts, + reqConfig, + options + ); + } + } + + if (reqConfig.customEndpoint) { + // Using a custom API override. Do not use `google-auto-auth` for + // authentication. (ex: connecting to a local Datastore server) + onAuthenticated(null, reqOpts); + } else { + authClient.authorizeRequest(reqOpts, onAuthenticated); + } + + if (stream) { + return stream; + } + + return { + abort: function() { + if (activeRequest_) { + activeRequest_.abort(); + activeRequest_ = null; + } + }, + }; + } + + makeAuthenticatedRequest.getCredentials = authClient.getCredentials.bind( + authClient + ); + + makeAuthenticatedRequest.authClient = authClient; + + return makeAuthenticatedRequest; +} + +util.makeAuthenticatedRequestFactory = makeAuthenticatedRequestFactory; + +/** + * Make a request through the `retryRequest` module with built-in error handling + * and exponential back off. + * + * @param {object} reqOpts - Request options in the format `request` expects. + * @param {object=} config - Configuration object. + * @param {boolean=} config.autoRetry - Automatically retry requests if the + * response is related to rate limits or certain intermittent server errors. + * We will exponentially backoff subsequent requests by default. (default: + * true) + * @param {number=} config.maxRetries - Maximum number of automatic retries + * attempted before returning the error. (default: 3) + * @param {function} callback - The callback function. + */ +function makeRequest(reqOpts, config, callback) { + if (is.fn(config)) { + callback = config; + config = {}; + } + + config = config || {}; + + const options = { + request: request, + + retries: config.autoRetry !== false ? config.maxRetries || 3 : 0, + + shouldRetryFn: function(httpRespMessage) { + const err = util.parseHttpRespMessage(httpRespMessage).err; + return err && util.shouldRetryRequest(err); + }, + }; + + if (config.stream) { + const dup = config.stream; + let requestStream; + const isGetRequest = (reqOpts.method || 'GET').toUpperCase() === 'GET'; + + if (isGetRequest) { + requestStream = retryRequest(reqOpts, options); + dup.setReadable(requestStream); + } else { + // Streaming writable HTTP requests cannot be retried. + requestStream = request(reqOpts); + dup.setWritable(requestStream); + } + + // Replay the Request events back to the stream. + requestStream + .on('error', dup.destroy.bind(dup)) + .on('response', dup.emit.bind(dup, 'response')) + .on('complete', dup.emit.bind(dup, 'complete')); + + dup.abort = requestStream.abort; + } else { + return retryRequest(reqOpts, options, function(err, response, body) { + util.handleResp(err, response, body, callback); + }); + } +} + +util.makeRequest = makeRequest; + +/** + * Decorate the options about to be made in a request. + * + * @param {object} reqOpts - The options to be passed to `request`. + * @param {string} projectId - The project ID. + * @return {object} reqOpts - The decorated reqOpts. + */ +function decorateRequest(reqOpts, projectId) { + delete reqOpts.autoPaginate; + delete reqOpts.autoPaginateVal; + delete reqOpts.objectMode; + + if (is.object(reqOpts.qs)) { + delete reqOpts.qs.autoPaginate; + delete reqOpts.qs.autoPaginateVal; + reqOpts.qs = util.replaceProjectIdToken(reqOpts.qs, projectId); + } + + if (is.object(reqOpts.json)) { + delete reqOpts.json.autoPaginate; + delete reqOpts.json.autoPaginateVal; + reqOpts.json = util.replaceProjectIdToken(reqOpts.json, projectId); + } + + reqOpts.uri = util.replaceProjectIdToken(reqOpts.uri, projectId); + + return reqOpts; +} + +util.decorateRequest = decorateRequest; + +/** + * Populate the `{{projectId}}` placeholder. + * + * @throws {Error} If a projectId is required, but one is not provided. + * + * @param {*} - Any input value that may contain a placeholder. Arrays and + * objects will be looped. + * @param {string} projectId - A projectId. If not provided + * @return {*} - The original argument with all placeholders populated. + */ +function replaceProjectIdToken(value, projectId) { + if (is.array(value)) { + value = value.map(function(val) { + return replaceProjectIdToken(val, projectId); + }); + } + + if (is.object(value) && is.fn(value.hasOwnProperty)) { + for (const opt in value) { + if (value.hasOwnProperty(opt)) { + value[opt] = replaceProjectIdToken(value[opt], projectId); + } + } + } + + if (is.string(value) && value.indexOf('{{projectId}}') > -1) { + if (!projectId || projectId === '{{projectId}}') { + throw new util.MissingProjectIdError(); + } + value = value.replace(/{{projectId}}/g, projectId); + } + + return value; +} + +util.replaceProjectIdToken = replaceProjectIdToken; + +/** + * Extend a global configuration object with user options provided at the time + * of sub-module instantiation. + * + * Connection details currently come in two ways: `credentials` or + * `keyFilename`. Because of this, we have a special exception when overriding a + * global configuration object. If a user provides either to the global + * configuration, then provides another at submodule instantiation-time, the + * latter is preferred. + * + * @param {object} globalConfig - The global configuration object. + * @param {object=} overrides - The instantiation-time configuration object. + * @return {object} + */ +function extendGlobalConfig(globalConfig, overrides) { + globalConfig = globalConfig || {}; + overrides = overrides || {}; + + const defaultConfig = {}; + + if (process.env.GCLOUD_PROJECT) { + defaultConfig.projectId = process.env.GCLOUD_PROJECT; + } + + const options = extend({}, globalConfig); + + const hasGlobalConnection = options.credentials || options.keyFilename; + const isOverridingConnection = overrides.credentials || overrides.keyFilename; + + if (hasGlobalConnection && isOverridingConnection) { + delete options.credentials; + delete options.keyFilename; + } + + const extendedConfig = extend(true, defaultConfig, options, overrides); + + // Preserve the original (not cloned) interceptors. + extendedConfig.interceptors_ = globalConfig.interceptors_; + + return extendedConfig; +} + +util.extendGlobalConfig = extendGlobalConfig; + +/** + * Merge and validate API configurations. + * + * @param {object} globalContext - gcloud-level context. + * @param {object} globalContext.config_ - gcloud-level configuration. + * @param {object} localConfig - Service-level configurations. + * @return {object} config - Merged and validated configuration. + */ +function normalizeArguments(globalContext, localConfig) { + const globalConfig = globalContext && globalContext.config_; + + return util.extendGlobalConfig(globalConfig, localConfig); +} + +util.normalizeArguments = normalizeArguments; + +/** + * Limit requests according to a `maxApiCalls` limit. + * + * @param {function} makeRequestFn - The function that will be called. + * @param {object=} options - Configuration object. + * @param {number} options.maxApiCalls - The maximum number of API calls to + * make. + * @param {object} options.streamOptions - Options to pass to the Stream + * constructor. + */ +function createLimiter(makeRequestFn, options) { + options = options || {}; + + const stream = streamEvents(through.obj(options.streamOptions)); + + let requestsMade = 0; + let requestsToMake = -1; + + if (is.number(options.maxApiCalls)) { + requestsToMake = options.maxApiCalls; + } + + return { + makeRequest: function() { + requestsMade++; + + if (requestsToMake >= 0 && requestsMade > requestsToMake) { + stream.push(null); + return; + } + + makeRequestFn.apply(null, arguments); + + return stream; + }, + + stream: stream, + }; +} + +util.createLimiter = createLimiter; + +function isCustomType(unknown, module) { + function getConstructorName(obj) { + return obj.constructor && obj.constructor.name.toLowerCase(); + } + + const moduleNameParts = module.split('/'); + + const parentModuleName = + moduleNameParts[0] && moduleNameParts[0].toLowerCase(); + const subModuleName = moduleNameParts[1] && moduleNameParts[1].toLowerCase(); + + if (subModuleName && getConstructorName(unknown) !== subModuleName) { + return false; + } + + let walkingModule = unknown; + do { + if (getConstructorName(walkingModule) === parentModuleName) { + return true; + } + } while ((walkingModule = walkingModule.parent)); + + return false; +} + +util.isCustomType = isCustomType; + +/** + * Create a properly-formatted User-Agent string from a package.json file. + * + * @param {object} packageJson - A module's package.json file. + * @return {string} userAgent - The formatted User-Agent string. + */ +function getUserAgentFromPackageJson(packageJson) { + const hyphenatedPackageName = packageJson.name + .replace('@google-cloud', 'gcloud-node') // For legacy purposes. + .replace('/', '-'); // For UA spec-compliance purposes. + + return hyphenatedPackageName + '/' + packageJson.version; +} + +util.getUserAgentFromPackageJson = getUserAgentFromPackageJson; + +/** + * Wraps a callback style function to conditionally return a promise. + * + * @param {function} originalMethod - The method to promisify. + * @param {object=} options - Promise options. + * @param {boolean} options.singular - Resolve the promise with single arg + * instead of an array. + * @return {function} wrapped + */ +function promisify(originalMethod, options) { + if (originalMethod.promisified_) { + return originalMethod; + } + + options = options || {}; + + const slice = Array.prototype.slice; + + const wrapper = function() { + const context = this; + let last; + + for (last = arguments.length - 1; last >= 0; last--) { + const arg = arguments[last]; + + if (is.undefined(arg)) { + continue; // skip trailing undefined. + } + + if (!is.fn(arg)) { + break; // non-callback last argument found. + } + + return originalMethod.apply(context, arguments); + } + + // peel trailing undefined. + const args = slice.call(arguments, 0, last + 1); + + let PromiseCtor = Promise; + + // Because dedupe will likely create a single install of + // @google-cloud/common to be shared amongst all modules, we need to + // localize it at the Service level. + if (context && context.Promise) { + PromiseCtor = context.Promise; + } + + return new PromiseCtor(function(resolve, reject) { + args.push(function() { + const callbackArgs = slice.call(arguments); + const err = callbackArgs.shift(); + + if (err) { + return reject(err); + } + + if (options.singular && callbackArgs.length === 1) { + resolve(callbackArgs[0]); + } else { + resolve(callbackArgs); + } + }); + + originalMethod.apply(context, args); + }); + }; + + wrapper.promisified_ = true; + return wrapper; +} + +util.promisify = promisify; + +/** + * Promisifies certain Class methods. This will not promisify private or + * streaming methods. + * + * @param {module:common/service} Class - Service class. + * @param {object=} options - Configuration object. + */ +function promisifyAll(Class, options) { + const exclude = (options && options.exclude) || []; + + const methods = Object.keys(Class.prototype).filter(function(methodName) { + return ( + is.fn(Class.prototype[methodName]) && // is it a function? + !/(^_|(Stream|_)|promise$)/.test(methodName) && // is it promisable? + exclude.indexOf(methodName) === -1 + ); // is it blacklisted? + }); + + methods.forEach(function(methodName) { + const originalMethod = Class.prototype[methodName]; + + if (!originalMethod.promisified_) { + Class.prototype[methodName] = util.promisify(originalMethod, options); + } + }); +} + +util.promisifyAll = promisifyAll; + +/** + * This will mask properties of an object from console.log. + * + * @param {object} object - The object to assign the property to. + * @param {string} propName - Property name. + * @param {*} value - Value. + */ +function privatize(object, propName, value) { + Object.defineProperty(object, propName, {value, writable: true}); +} + +util.privatize = privatize; diff --git a/website/functions/node_modules/@google-cloud/firestore/LICENSE b/website/functions/node_modules/@google-cloud/firestore/LICENSE new file mode 100644 index 00000000..7a4a3ea2 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. \ No newline at end of file diff --git a/website/functions/node_modules/@google-cloud/firestore/README.md b/website/functions/node_modules/@google-cloud/firestore/README.md new file mode 100644 index 00000000..94dc0250 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/README.md @@ -0,0 +1,141 @@ +Google Cloud Platform logo + +# [Google Cloud Firestore: Node.js Server SDK](https://github.com/googleapis/nodejs-firestore) + +[![release level](https://img.shields.io/badge/release%20level-beta-yellow.svg?style=flat)](https://cloud.google.com/terms/launch-stages) +[![CircleCI](https://img.shields.io/circleci/project/github/googleapis/nodejs-firestore.svg?style=flat)](https://circleci.com/gh/googleapis/nodejs-firestore) +[![AppVeyor](https://ci.appveyor.com/api/projects/status/github/googleapis/nodejs-firestore?branch=master&svg=true)](https://ci.appveyor.com/project/googleapis/nodejs-firestore) +[![codecov](https://img.shields.io/codecov/c/github/googleapis/nodejs-firestore/master.svg?style=flat)](https://codecov.io/gh/googleapis/nodejs-firestore) + +This is the Node.js Server SDK for +[Google Cloud Firestore](https://firebase.google.com/docs/firestore/). Google +Cloud Firestore is a NoSQL document database built for automatic scaling, high +performance, and ease of application development. + +This Cloud Firestore Server SDK uses Google’s [Cloud Identity and Access +Management](https://cloud.google.com/firestore/docs/security/iam) 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`](https://www.npmjs.com/package/firebase) +Client SDK. + +**Table of contents:** + +* [Quickstart](#quickstart) + * [Before you begin](#before-you-begin) + * [Installing the client library](#installing-the-client-library) + * [Using the client library](#using-the-client-library) +* [Versioning](#versioning) +* [Contributing](#contributing) +* [License](#license) + +## Quickstart + +Read more about the client libraries for Cloud APIs, including the older +Google APIs Client Libraries, in [Client Libraries Explained][explained]. + +[explained]: https://cloud.google.com/apis/docs/client-libraries-explained + +* [Cloud Firestore Node.js Client API Reference][client-docs] +* [github.com/googleapis/nodejs-firestore](https://github.com/googleapis/nodejs-firestore) +* [Cloud Firestore Documentation][product-docs] + +### Before you begin + +1. Select or create a Cloud Platform project. + + [Go to the projects page][projects] + +1. Enable the Google Cloud Firestore API. + + [Enable the API][enable_api] + +1. [Set up authentication with a service account][auth] so you can access the + API from your local workstation. + +[projects]: https://console.cloud.google.com/project +[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=firestore.googleapis.com +[auth]: https://cloud.google.com/docs/authentication/getting-started + +### Installing the client library + + npm install --save @google-cloud/firestore + +### Using the client library + +```javascript +const Firestore = require('@google-cloud/firestore'); + +const firestore = new Firestore({ + projectId: 'YOUR_PROJECT_ID', + keyFilename: '/path/to/keyfile.json', +}); + +const document = firestore.doc('posts/intro-to-firestore'); + +// Enter new data into the document. +document.set({ + title: 'Welcome to Firestore', + body: 'Hello World', +}).then(() => { + // Document created successfully. +}); + +// Update an existing document. +document.update({ + body: 'My first Firestore app', +}).then(() => { + // Document updated successfully. +}); + +// Read the document. +document.get().then(doc => { + // Document read successfully. +}); + +// Delete the document. +document.delete().then(() => { + // Document deleted successfully. +}); +``` + + +The [Cloud Firestore Node.js Client API Reference][client-docs] documentation +also contains samples. + +## Versioning + +This library follows [Semantic Versioning](http://semver.org/). + +This library is considered to be in **beta**. This means it is expected to be +mostly stable while we work toward a general availability release; however, +complete stability is not guaranteed. We will address issues and requests +against beta libraries with a high priority. + +More Information: [Google Cloud Platform Launch Stages][launch_stages] + +[launch_stages]: https://cloud.google.com/terms/launch-stages + +## Contributing + +Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/nodejs-firestore/blob/master/.github/CONTRIBUTING.md). + +## License + +Apache Version 2.0 + +See [LICENSE](https://github.com/googleapis/nodejs-firestore/blob/master/LICENSE) + +[client-docs]: https://cloud.google.com/nodejs/docs/reference/firestore/latest/ +[product-docs]: https://firebase.google.com/docs/firestore/ +[shell_img]: //gstatic.com/cloudssh/images/open-btn.png diff --git a/website/functions/node_modules/@google-cloud/firestore/build/protos/README.md b/website/functions/node_modules/@google-cloud/firestore/build/protos/README.md new file mode 100644 index 00000000..54468be9 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/protos/README.md @@ -0,0 +1,33 @@ +The `firestore_proto_api.d.ts` and `firestore_proto_api.js` are generated from the Firestore +protofbuf definitions. While there are certainly more proper ways of doing this, the following +process was used: + +- Check out `google-proto-files` from NPM. +``` +npm install --save google-proto-files +``` + +- Copy the `google/firestore/v1beta/*.proto` and place them in current folder. +``` +cp node_modules/google-proto-files/google/firestore/v1beta1/*.proto . +``` + +- Remove the `google/firestore/v1beta` path from any import statements in these files. + +``` +sed -i '' 's/import \"google\/firestore\/v1beta1\//import \"/g' *.proto +``` + +- Generate the output files +``` +mkdir -p out && pbjs --proto_path node_modules/google-proto-files -t static-module -w commonjs -o out/firestore_proto_api.js firestore.proto && pbts -o out/firestore_proto_api.d.ts out/firestore_proto_api.js +``` + +- Edit the type used for integers greater than 2^53. The GRPC settings we use represent them as +Strings, but pbjs uses the "Long" type. + +``` +sed -i '' 's/number\|Long/number\|string \"/g' firestore_proto_api.d.ts firestore_proto_api.js +``` + +TODO: Find a way to properly specify the proto paths for the Firestore imports so this can be automated. \ No newline at end of file diff --git a/website/functions/node_modules/@google-cloud/firestore/build/protos/firestore_proto_api.d.ts b/website/functions/node_modules/@google-cloud/firestore/build/protos/firestore_proto_api.d.ts new file mode 100644 index 00000000..46225472 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/protos/firestore_proto_api.d.ts @@ -0,0 +1,10582 @@ +import * as $protobuf from "protobufjs"; + +// Note: This file was manually edited to use "string" instead of "Long" for +// types that can potentially hold large integer values (> 2^53). + +/** Namespace google. */ +export namespace google { + + /** Namespace firestore. */ + namespace firestore { + + /** Namespace v1beta1. */ + namespace v1beta1 { + + /** 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); + + /** + * Creates new Firestore service using the specified rpc implementation. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + * @returns RPC service. Useful where requests and/or responses are streamed. + */ + public static create(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean): Firestore; + + /** + * 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 new GetDocumentRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetDocumentRequest instance + */ + public static create(properties?: google.firestore.v1beta1.IGetDocumentRequest): google.firestore.v1beta1.GetDocumentRequest; + + /** + * Encodes the specified GetDocumentRequest message. Does not implicitly {@link google.firestore.v1beta1.GetDocumentRequest.verify|verify} messages. + * @param message GetDocumentRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IGetDocumentRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetDocumentRequest message, length delimited. Does not implicitly {@link google.firestore.v1beta1.GetDocumentRequest.verify|verify} messages. + * @param message GetDocumentRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IGetDocumentRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetDocumentRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetDocumentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.GetDocumentRequest; + + /** + * Decodes a GetDocumentRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetDocumentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.GetDocumentRequest; + + /** + * Verifies a GetDocumentRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new ListDocumentsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListDocumentsRequest instance + */ + public static create(properties?: google.firestore.v1beta1.IListDocumentsRequest): google.firestore.v1beta1.ListDocumentsRequest; + + /** + * Encodes the specified ListDocumentsRequest message. Does not implicitly {@link google.firestore.v1beta1.ListDocumentsRequest.verify|verify} messages. + * @param message ListDocumentsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IListDocumentsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListDocumentsRequest message, length delimited. Does not implicitly {@link google.firestore.v1beta1.ListDocumentsRequest.verify|verify} messages. + * @param message ListDocumentsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IListDocumentsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListDocumentsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListDocumentsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.ListDocumentsRequest; + + /** + * Decodes a ListDocumentsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListDocumentsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.ListDocumentsRequest; + + /** + * Verifies a ListDocumentsRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new ListDocumentsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListDocumentsResponse instance + */ + public static create(properties?: google.firestore.v1beta1.IListDocumentsResponse): google.firestore.v1beta1.ListDocumentsResponse; + + /** + * Encodes the specified ListDocumentsResponse message. Does not implicitly {@link google.firestore.v1beta1.ListDocumentsResponse.verify|verify} messages. + * @param message ListDocumentsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IListDocumentsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListDocumentsResponse message, length delimited. Does not implicitly {@link google.firestore.v1beta1.ListDocumentsResponse.verify|verify} messages. + * @param message ListDocumentsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IListDocumentsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListDocumentsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListDocumentsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.ListDocumentsResponse; + + /** + * Decodes a ListDocumentsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListDocumentsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.ListDocumentsResponse; + + /** + * Verifies a ListDocumentsResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new CreateDocumentRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateDocumentRequest instance + */ + public static create(properties?: google.firestore.v1beta1.ICreateDocumentRequest): google.firestore.v1beta1.CreateDocumentRequest; + + /** + * Encodes the specified CreateDocumentRequest message. Does not implicitly {@link google.firestore.v1beta1.CreateDocumentRequest.verify|verify} messages. + * @param message CreateDocumentRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.ICreateDocumentRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateDocumentRequest message, length delimited. Does not implicitly {@link google.firestore.v1beta1.CreateDocumentRequest.verify|verify} messages. + * @param message CreateDocumentRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.ICreateDocumentRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateDocumentRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateDocumentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.CreateDocumentRequest; + + /** + * Decodes a CreateDocumentRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateDocumentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.CreateDocumentRequest; + + /** + * Verifies a CreateDocumentRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|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 a new UpdateDocumentRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateDocumentRequest instance + */ + public static create(properties?: google.firestore.v1beta1.IUpdateDocumentRequest): google.firestore.v1beta1.UpdateDocumentRequest; + + /** + * Encodes the specified UpdateDocumentRequest message. Does not implicitly {@link google.firestore.v1beta1.UpdateDocumentRequest.verify|verify} messages. + * @param message UpdateDocumentRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IUpdateDocumentRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateDocumentRequest message, length delimited. Does not implicitly {@link google.firestore.v1beta1.UpdateDocumentRequest.verify|verify} messages. + * @param message UpdateDocumentRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IUpdateDocumentRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateDocumentRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateDocumentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.UpdateDocumentRequest; + + /** + * Decodes an UpdateDocumentRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateDocumentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.UpdateDocumentRequest; + + /** + * Verifies an UpdateDocumentRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|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 new DeleteDocumentRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteDocumentRequest instance + */ + public static create(properties?: google.firestore.v1beta1.IDeleteDocumentRequest): google.firestore.v1beta1.DeleteDocumentRequest; + + /** + * Encodes the specified DeleteDocumentRequest message. Does not implicitly {@link google.firestore.v1beta1.DeleteDocumentRequest.verify|verify} messages. + * @param message DeleteDocumentRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IDeleteDocumentRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteDocumentRequest message, length delimited. Does not implicitly {@link google.firestore.v1beta1.DeleteDocumentRequest.verify|verify} messages. + * @param message DeleteDocumentRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IDeleteDocumentRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteDocumentRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteDocumentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.DeleteDocumentRequest; + + /** + * Decodes a DeleteDocumentRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteDocumentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.DeleteDocumentRequest; + + /** + * Verifies a DeleteDocumentRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|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 new BatchGetDocumentsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns BatchGetDocumentsRequest instance + */ + public static create(properties?: google.firestore.v1beta1.IBatchGetDocumentsRequest): google.firestore.v1beta1.BatchGetDocumentsRequest; + + /** + * Encodes the specified BatchGetDocumentsRequest message. Does not implicitly {@link google.firestore.v1beta1.BatchGetDocumentsRequest.verify|verify} messages. + * @param message BatchGetDocumentsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IBatchGetDocumentsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BatchGetDocumentsRequest message, length delimited. Does not implicitly {@link google.firestore.v1beta1.BatchGetDocumentsRequest.verify|verify} messages. + * @param message BatchGetDocumentsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IBatchGetDocumentsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BatchGetDocumentsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BatchGetDocumentsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.BatchGetDocumentsRequest; + + /** + * Decodes a BatchGetDocumentsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BatchGetDocumentsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.BatchGetDocumentsRequest; + + /** + * Verifies a BatchGetDocumentsRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new BatchGetDocumentsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns BatchGetDocumentsResponse instance + */ + public static create(properties?: google.firestore.v1beta1.IBatchGetDocumentsResponse): google.firestore.v1beta1.BatchGetDocumentsResponse; + + /** + * Encodes the specified BatchGetDocumentsResponse message. Does not implicitly {@link google.firestore.v1beta1.BatchGetDocumentsResponse.verify|verify} messages. + * @param message BatchGetDocumentsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IBatchGetDocumentsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BatchGetDocumentsResponse message, length delimited. Does not implicitly {@link google.firestore.v1beta1.BatchGetDocumentsResponse.verify|verify} messages. + * @param message BatchGetDocumentsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IBatchGetDocumentsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BatchGetDocumentsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BatchGetDocumentsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.BatchGetDocumentsResponse; + + /** + * Decodes a BatchGetDocumentsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BatchGetDocumentsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.BatchGetDocumentsResponse; + + /** + * Verifies a BatchGetDocumentsResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new BeginTransactionRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns BeginTransactionRequest instance + */ + public static create(properties?: google.firestore.v1beta1.IBeginTransactionRequest): google.firestore.v1beta1.BeginTransactionRequest; + + /** + * Encodes the specified BeginTransactionRequest message. Does not implicitly {@link google.firestore.v1beta1.BeginTransactionRequest.verify|verify} messages. + * @param message BeginTransactionRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IBeginTransactionRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BeginTransactionRequest message, length delimited. Does not implicitly {@link google.firestore.v1beta1.BeginTransactionRequest.verify|verify} messages. + * @param message BeginTransactionRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IBeginTransactionRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BeginTransactionRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BeginTransactionRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.BeginTransactionRequest; + + /** + * Decodes a BeginTransactionRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BeginTransactionRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.BeginTransactionRequest; + + /** + * Verifies a BeginTransactionRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|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 new BeginTransactionResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns BeginTransactionResponse instance + */ + public static create(properties?: google.firestore.v1beta1.IBeginTransactionResponse): google.firestore.v1beta1.BeginTransactionResponse; + + /** + * Encodes the specified BeginTransactionResponse message. Does not implicitly {@link google.firestore.v1beta1.BeginTransactionResponse.verify|verify} messages. + * @param message BeginTransactionResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IBeginTransactionResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BeginTransactionResponse message, length delimited. Does not implicitly {@link google.firestore.v1beta1.BeginTransactionResponse.verify|verify} messages. + * @param message BeginTransactionResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IBeginTransactionResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BeginTransactionResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BeginTransactionResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.BeginTransactionResponse; + + /** + * Decodes a BeginTransactionResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BeginTransactionResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.BeginTransactionResponse; + + /** + * Verifies a BeginTransactionResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new CommitRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CommitRequest instance + */ + public static create(properties?: google.firestore.v1beta1.ICommitRequest): google.firestore.v1beta1.CommitRequest; + + /** + * Encodes the specified CommitRequest message. Does not implicitly {@link google.firestore.v1beta1.CommitRequest.verify|verify} messages. + * @param message CommitRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.ICommitRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CommitRequest message, length delimited. Does not implicitly {@link google.firestore.v1beta1.CommitRequest.verify|verify} messages. + * @param message CommitRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.ICommitRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CommitRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CommitRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.CommitRequest; + + /** + * Decodes a CommitRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CommitRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.CommitRequest; + + /** + * Verifies a CommitRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new CommitResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns CommitResponse instance + */ + public static create(properties?: google.firestore.v1beta1.ICommitResponse): google.firestore.v1beta1.CommitResponse; + + /** + * Encodes the specified CommitResponse message. Does not implicitly {@link google.firestore.v1beta1.CommitResponse.verify|verify} messages. + * @param message CommitResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.ICommitResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CommitResponse message, length delimited. Does not implicitly {@link google.firestore.v1beta1.CommitResponse.verify|verify} messages. + * @param message CommitResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.ICommitResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CommitResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CommitResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.CommitResponse; + + /** + * Decodes a CommitResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CommitResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.CommitResponse; + + /** + * Verifies a CommitResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|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 new RollbackRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns RollbackRequest instance + */ + public static create(properties?: google.firestore.v1beta1.IRollbackRequest): google.firestore.v1beta1.RollbackRequest; + + /** + * Encodes the specified RollbackRequest message. Does not implicitly {@link google.firestore.v1beta1.RollbackRequest.verify|verify} messages. + * @param message RollbackRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IRollbackRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RollbackRequest message, length delimited. Does not implicitly {@link google.firestore.v1beta1.RollbackRequest.verify|verify} messages. + * @param message RollbackRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IRollbackRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RollbackRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RollbackRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.RollbackRequest; + + /** + * Decodes a RollbackRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RollbackRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.RollbackRequest; + + /** + * Verifies a RollbackRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new RunQueryRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns RunQueryRequest instance + */ + public static create(properties?: google.firestore.v1beta1.IRunQueryRequest): google.firestore.v1beta1.RunQueryRequest; + + /** + * Encodes the specified RunQueryRequest message. Does not implicitly {@link google.firestore.v1beta1.RunQueryRequest.verify|verify} messages. + * @param message RunQueryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IRunQueryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RunQueryRequest message, length delimited. Does not implicitly {@link google.firestore.v1beta1.RunQueryRequest.verify|verify} messages. + * @param message RunQueryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IRunQueryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RunQueryRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RunQueryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.RunQueryRequest; + + /** + * Decodes a RunQueryRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RunQueryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.RunQueryRequest; + + /** + * Verifies a RunQueryRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new RunQueryResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns RunQueryResponse instance + */ + public static create(properties?: google.firestore.v1beta1.IRunQueryResponse): google.firestore.v1beta1.RunQueryResponse; + + /** + * Encodes the specified RunQueryResponse message. Does not implicitly {@link google.firestore.v1beta1.RunQueryResponse.verify|verify} messages. + * @param message RunQueryResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IRunQueryResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RunQueryResponse message, length delimited. Does not implicitly {@link google.firestore.v1beta1.RunQueryResponse.verify|verify} messages. + * @param message RunQueryResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IRunQueryResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RunQueryResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RunQueryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.RunQueryResponse; + + /** + * Decodes a RunQueryResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RunQueryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.RunQueryResponse; + + /** + * Verifies a RunQueryResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new WriteRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns WriteRequest instance + */ + public static create(properties?: google.firestore.v1beta1.IWriteRequest): google.firestore.v1beta1.WriteRequest; + + /** + * Encodes the specified WriteRequest message. Does not implicitly {@link google.firestore.v1beta1.WriteRequest.verify|verify} messages. + * @param message WriteRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IWriteRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified WriteRequest message, length delimited. Does not implicitly {@link google.firestore.v1beta1.WriteRequest.verify|verify} messages. + * @param message WriteRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IWriteRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a WriteRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns WriteRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.WriteRequest; + + /** + * Decodes a WriteRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns WriteRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.WriteRequest; + + /** + * Verifies a WriteRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new WriteResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns WriteResponse instance + */ + public static create(properties?: google.firestore.v1beta1.IWriteResponse): google.firestore.v1beta1.WriteResponse; + + /** + * Encodes the specified WriteResponse message. Does not implicitly {@link google.firestore.v1beta1.WriteResponse.verify|verify} messages. + * @param message WriteResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IWriteResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified WriteResponse message, length delimited. Does not implicitly {@link google.firestore.v1beta1.WriteResponse.verify|verify} messages. + * @param message WriteResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IWriteResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a WriteResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns WriteResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.WriteResponse; + + /** + * Decodes a WriteResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns WriteResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.WriteResponse; + + /** + * Verifies a WriteResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|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 new ListenRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListenRequest instance + */ + public static create(properties?: google.firestore.v1beta1.IListenRequest): google.firestore.v1beta1.ListenRequest; + + /** + * Encodes the specified ListenRequest message. Does not implicitly {@link google.firestore.v1beta1.ListenRequest.verify|verify} messages. + * @param message ListenRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IListenRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListenRequest message, length delimited. Does not implicitly {@link google.firestore.v1beta1.ListenRequest.verify|verify} messages. + * @param message ListenRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IListenRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListenRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListenRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.ListenRequest; + + /** + * Decodes a ListenRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListenRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.ListenRequest; + + /** + * Verifies a ListenRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new ListenResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListenResponse instance + */ + public static create(properties?: google.firestore.v1beta1.IListenResponse): google.firestore.v1beta1.ListenResponse; + + /** + * Encodes the specified ListenResponse message. Does not implicitly {@link google.firestore.v1beta1.ListenResponse.verify|verify} messages. + * @param message ListenResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IListenResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListenResponse message, length delimited. Does not implicitly {@link google.firestore.v1beta1.ListenResponse.verify|verify} messages. + * @param message ListenResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IListenResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListenResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListenResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.ListenResponse; + + /** + * Decodes a ListenResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListenResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.ListenResponse; + + /** + * Verifies a ListenResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new Target instance using the specified properties. + * @param [properties] Properties to set + * @returns Target instance + */ + public static create(properties?: google.firestore.v1beta1.ITarget): google.firestore.v1beta1.Target; + + /** + * Encodes the specified Target message. Does not implicitly {@link google.firestore.v1beta1.Target.verify|verify} messages. + * @param message Target message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.ITarget, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Target message, length delimited. Does not implicitly {@link google.firestore.v1beta1.Target.verify|verify} messages. + * @param message Target message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.ITarget, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Target message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Target + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.Target; + + /** + * Decodes a Target message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Target + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.Target; + + /** + * Verifies a Target message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new DocumentsTarget instance using the specified properties. + * @param [properties] Properties to set + * @returns DocumentsTarget instance + */ + public static create(properties?: google.firestore.v1beta1.Target.IDocumentsTarget): google.firestore.v1beta1.Target.DocumentsTarget; + + /** + * Encodes the specified DocumentsTarget message. Does not implicitly {@link google.firestore.v1beta1.Target.DocumentsTarget.verify|verify} messages. + * @param message DocumentsTarget message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.Target.IDocumentsTarget, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DocumentsTarget message, length delimited. Does not implicitly {@link google.firestore.v1beta1.Target.DocumentsTarget.verify|verify} messages. + * @param message DocumentsTarget message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.Target.IDocumentsTarget, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DocumentsTarget message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DocumentsTarget + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.Target.DocumentsTarget; + + /** + * Decodes a DocumentsTarget message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DocumentsTarget + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.Target.DocumentsTarget; + + /** + * Verifies a DocumentsTarget message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new QueryTarget instance using the specified properties. + * @param [properties] Properties to set + * @returns QueryTarget instance + */ + public static create(properties?: google.firestore.v1beta1.Target.IQueryTarget): google.firestore.v1beta1.Target.QueryTarget; + + /** + * Encodes the specified QueryTarget message. Does not implicitly {@link google.firestore.v1beta1.Target.QueryTarget.verify|verify} messages. + * @param message QueryTarget message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.Target.IQueryTarget, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified QueryTarget message, length delimited. Does not implicitly {@link google.firestore.v1beta1.Target.QueryTarget.verify|verify} messages. + * @param message QueryTarget message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.Target.IQueryTarget, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a QueryTarget message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns QueryTarget + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.Target.QueryTarget; + + /** + * Decodes a QueryTarget message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns QueryTarget + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.Target.QueryTarget; + + /** + * Verifies a QueryTarget message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new TargetChange instance using the specified properties. + * @param [properties] Properties to set + * @returns TargetChange instance + */ + public static create(properties?: google.firestore.v1beta1.ITargetChange): google.firestore.v1beta1.TargetChange; + + /** + * Encodes the specified TargetChange message. Does not implicitly {@link google.firestore.v1beta1.TargetChange.verify|verify} messages. + * @param message TargetChange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.ITargetChange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TargetChange message, length delimited. Does not implicitly {@link google.firestore.v1beta1.TargetChange.verify|verify} messages. + * @param message TargetChange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.ITargetChange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TargetChange message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TargetChange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.TargetChange; + + /** + * Decodes a TargetChange message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TargetChange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.TargetChange; + + /** + * Verifies a TargetChange message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|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. */ + enum TargetChangeType { + NO_CHANGE = 0, + ADD = 1, + REMOVE = 2, + CURRENT = 3, + RESET = 4 + } + } + + /** 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 new ListCollectionIdsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListCollectionIdsRequest instance + */ + public static create(properties?: google.firestore.v1beta1.IListCollectionIdsRequest): google.firestore.v1beta1.ListCollectionIdsRequest; + + /** + * Encodes the specified ListCollectionIdsRequest message. Does not implicitly {@link google.firestore.v1beta1.ListCollectionIdsRequest.verify|verify} messages. + * @param message ListCollectionIdsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IListCollectionIdsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListCollectionIdsRequest message, length delimited. Does not implicitly {@link google.firestore.v1beta1.ListCollectionIdsRequest.verify|verify} messages. + * @param message ListCollectionIdsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IListCollectionIdsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListCollectionIdsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListCollectionIdsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.ListCollectionIdsRequest; + + /** + * Decodes a ListCollectionIdsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListCollectionIdsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.ListCollectionIdsRequest; + + /** + * Verifies a ListCollectionIdsRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new ListCollectionIdsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListCollectionIdsResponse instance + */ + public static create(properties?: google.firestore.v1beta1.IListCollectionIdsResponse): google.firestore.v1beta1.ListCollectionIdsResponse; + + /** + * Encodes the specified ListCollectionIdsResponse message. Does not implicitly {@link google.firestore.v1beta1.ListCollectionIdsResponse.verify|verify} messages. + * @param message ListCollectionIdsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IListCollectionIdsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListCollectionIdsResponse message, length delimited. Does not implicitly {@link google.firestore.v1beta1.ListCollectionIdsResponse.verify|verify} messages. + * @param message ListCollectionIdsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IListCollectionIdsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListCollectionIdsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListCollectionIdsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.ListCollectionIdsResponse; + + /** + * Decodes a ListCollectionIdsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListCollectionIdsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.ListCollectionIdsResponse; + + /** + * Verifies a ListCollectionIdsResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 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 new DocumentMask instance using the specified properties. + * @param [properties] Properties to set + * @returns DocumentMask instance + */ + public static create(properties?: google.firestore.v1beta1.IDocumentMask): google.firestore.v1beta1.DocumentMask; + + /** + * Encodes the specified DocumentMask message. Does not implicitly {@link google.firestore.v1beta1.DocumentMask.verify|verify} messages. + * @param message DocumentMask message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IDocumentMask, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DocumentMask message, length delimited. Does not implicitly {@link google.firestore.v1beta1.DocumentMask.verify|verify} messages. + * @param message DocumentMask message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IDocumentMask, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DocumentMask message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DocumentMask + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.DocumentMask; + + /** + * Decodes a DocumentMask message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DocumentMask + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.DocumentMask; + + /** + * Verifies a DocumentMask message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new Precondition instance using the specified properties. + * @param [properties] Properties to set + * @returns Precondition instance + */ + public static create(properties?: google.firestore.v1beta1.IPrecondition): google.firestore.v1beta1.Precondition; + + /** + * Encodes the specified Precondition message. Does not implicitly {@link google.firestore.v1beta1.Precondition.verify|verify} messages. + * @param message Precondition message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IPrecondition, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Precondition message, length delimited. Does not implicitly {@link google.firestore.v1beta1.Precondition.verify|verify} messages. + * @param message Precondition message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IPrecondition, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Precondition message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Precondition + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.Precondition; + + /** + * Decodes a Precondition message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Precondition + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.Precondition; + + /** + * Verifies a Precondition message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new TransactionOptions instance using the specified properties. + * @param [properties] Properties to set + * @returns TransactionOptions instance + */ + public static create(properties?: google.firestore.v1beta1.ITransactionOptions): google.firestore.v1beta1.TransactionOptions; + + /** + * Encodes the specified TransactionOptions message. Does not implicitly {@link google.firestore.v1beta1.TransactionOptions.verify|verify} messages. + * @param message TransactionOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.ITransactionOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TransactionOptions message, length delimited. Does not implicitly {@link google.firestore.v1beta1.TransactionOptions.verify|verify} messages. + * @param message TransactionOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.ITransactionOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TransactionOptions message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TransactionOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.TransactionOptions; + + /** + * Decodes a TransactionOptions message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TransactionOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.TransactionOptions; + + /** + * Verifies a TransactionOptions message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new ReadWrite instance using the specified properties. + * @param [properties] Properties to set + * @returns ReadWrite instance + */ + public static create(properties?: google.firestore.v1beta1.TransactionOptions.IReadWrite): google.firestore.v1beta1.TransactionOptions.ReadWrite; + + /** + * Encodes the specified ReadWrite message. Does not implicitly {@link google.firestore.v1beta1.TransactionOptions.ReadWrite.verify|verify} messages. + * @param message ReadWrite message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.TransactionOptions.IReadWrite, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ReadWrite message, length delimited. Does not implicitly {@link google.firestore.v1beta1.TransactionOptions.ReadWrite.verify|verify} messages. + * @param message ReadWrite message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.TransactionOptions.IReadWrite, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ReadWrite message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ReadWrite + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.TransactionOptions.ReadWrite; + + /** + * Decodes a ReadWrite message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ReadWrite + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.TransactionOptions.ReadWrite; + + /** + * Verifies a ReadWrite message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new ReadOnly instance using the specified properties. + * @param [properties] Properties to set + * @returns ReadOnly instance + */ + public static create(properties?: google.firestore.v1beta1.TransactionOptions.IReadOnly): google.firestore.v1beta1.TransactionOptions.ReadOnly; + + /** + * Encodes the specified ReadOnly message. Does not implicitly {@link google.firestore.v1beta1.TransactionOptions.ReadOnly.verify|verify} messages. + * @param message ReadOnly message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.TransactionOptions.IReadOnly, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ReadOnly message, length delimited. Does not implicitly {@link google.firestore.v1beta1.TransactionOptions.ReadOnly.verify|verify} messages. + * @param message ReadOnly message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.TransactionOptions.IReadOnly, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ReadOnly message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ReadOnly + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.TransactionOptions.ReadOnly; + + /** + * Decodes a ReadOnly message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ReadOnly + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.TransactionOptions.ReadOnly; + + /** + * Verifies a ReadOnly message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new Document instance using the specified properties. + * @param [properties] Properties to set + * @returns Document instance + */ + public static create(properties?: google.firestore.v1beta1.IDocument): google.firestore.v1beta1.Document; + + /** + * Encodes the specified Document message. Does not implicitly {@link google.firestore.v1beta1.Document.verify|verify} messages. + * @param message Document message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IDocument, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Document message, length delimited. Does not implicitly {@link google.firestore.v1beta1.Document.verify|verify} messages. + * @param message Document message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IDocument, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Document message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Document + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.Document; + + /** + * Decodes a Document message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Document + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.Document; + + /** + * Verifies a Document message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|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 new Value instance using the specified properties. + * @param [properties] Properties to set + * @returns Value instance + */ + public static create(properties?: google.firestore.v1beta1.IValue): google.firestore.v1beta1.Value; + + /** + * Encodes the specified Value message. Does not implicitly {@link google.firestore.v1beta1.Value.verify|verify} messages. + * @param message Value message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Value message, length delimited. Does not implicitly {@link google.firestore.v1beta1.Value.verify|verify} messages. + * @param message Value message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Value message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.Value; + + /** + * Decodes a Value message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.Value; + + /** + * Verifies a Value message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 a new ArrayValue instance using the specified properties. + * @param [properties] Properties to set + * @returns ArrayValue instance + */ + public static create(properties?: google.firestore.v1beta1.IArrayValue): google.firestore.v1beta1.ArrayValue; + + /** + * Encodes the specified ArrayValue message. Does not implicitly {@link google.firestore.v1beta1.ArrayValue.verify|verify} messages. + * @param message ArrayValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IArrayValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ArrayValue message, length delimited. Does not implicitly {@link google.firestore.v1beta1.ArrayValue.verify|verify} messages. + * @param message ArrayValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IArrayValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ArrayValue message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ArrayValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.ArrayValue; + + /** + * Decodes an ArrayValue message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ArrayValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.ArrayValue; + + /** + * Verifies an ArrayValue message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new MapValue instance using the specified properties. + * @param [properties] Properties to set + * @returns MapValue instance + */ + public static create(properties?: google.firestore.v1beta1.IMapValue): google.firestore.v1beta1.MapValue; + + /** + * Encodes the specified MapValue message. Does not implicitly {@link google.firestore.v1beta1.MapValue.verify|verify} messages. + * @param message MapValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IMapValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified MapValue message, length delimited. Does not implicitly {@link google.firestore.v1beta1.MapValue.verify|verify} messages. + * @param message MapValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IMapValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a MapValue message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns MapValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.MapValue; + + /** + * Decodes a MapValue message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns MapValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.MapValue; + + /** + * Verifies a MapValue message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 }; + } + + /** 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 new StructuredQuery instance using the specified properties. + * @param [properties] Properties to set + * @returns StructuredQuery instance + */ + public static create(properties?: google.firestore.v1beta1.IStructuredQuery): google.firestore.v1beta1.StructuredQuery; + + /** + * Encodes the specified StructuredQuery message. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.verify|verify} messages. + * @param message StructuredQuery message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IStructuredQuery, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified StructuredQuery message, length delimited. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.verify|verify} messages. + * @param message StructuredQuery message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IStructuredQuery, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a StructuredQuery message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns StructuredQuery + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.StructuredQuery; + + /** + * Decodes a StructuredQuery message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns StructuredQuery + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.StructuredQuery; + + /** + * Verifies a StructuredQuery message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|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 new CollectionSelector instance using the specified properties. + * @param [properties] Properties to set + * @returns CollectionSelector instance + */ + public static create(properties?: google.firestore.v1beta1.StructuredQuery.ICollectionSelector): google.firestore.v1beta1.StructuredQuery.CollectionSelector; + + /** + * Encodes the specified CollectionSelector message. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.CollectionSelector.verify|verify} messages. + * @param message CollectionSelector message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.StructuredQuery.ICollectionSelector, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CollectionSelector message, length delimited. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.CollectionSelector.verify|verify} messages. + * @param message CollectionSelector message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.StructuredQuery.ICollectionSelector, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CollectionSelector message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CollectionSelector + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.StructuredQuery.CollectionSelector; + + /** + * Decodes a CollectionSelector message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CollectionSelector + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.StructuredQuery.CollectionSelector; + + /** + * Verifies a CollectionSelector message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new Filter instance using the specified properties. + * @param [properties] Properties to set + * @returns Filter instance + */ + public static create(properties?: google.firestore.v1beta1.StructuredQuery.IFilter): google.firestore.v1beta1.StructuredQuery.Filter; + + /** + * Encodes the specified Filter message. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.Filter.verify|verify} messages. + * @param message Filter message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.StructuredQuery.IFilter, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Filter message, length delimited. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.Filter.verify|verify} messages. + * @param message Filter message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.StructuredQuery.IFilter, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Filter message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Filter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.StructuredQuery.Filter; + + /** + * Decodes a Filter message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Filter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.StructuredQuery.Filter; + + /** + * Verifies a Filter message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new CompositeFilter instance using the specified properties. + * @param [properties] Properties to set + * @returns CompositeFilter instance + */ + public static create(properties?: google.firestore.v1beta1.StructuredQuery.ICompositeFilter): google.firestore.v1beta1.StructuredQuery.CompositeFilter; + + /** + * Encodes the specified CompositeFilter message. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.CompositeFilter.verify|verify} messages. + * @param message CompositeFilter message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.StructuredQuery.ICompositeFilter, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CompositeFilter message, length delimited. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.CompositeFilter.verify|verify} messages. + * @param message CompositeFilter message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.StructuredQuery.ICompositeFilter, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CompositeFilter message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CompositeFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.StructuredQuery.CompositeFilter; + + /** + * Decodes a CompositeFilter message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CompositeFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.StructuredQuery.CompositeFilter; + + /** + * Verifies a CompositeFilter message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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. */ + enum Operator { + OPERATOR_UNSPECIFIED = 0, + AND = 1 + } + } + + /** 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 new FieldFilter instance using the specified properties. + * @param [properties] Properties to set + * @returns FieldFilter instance + */ + public static create(properties?: google.firestore.v1beta1.StructuredQuery.IFieldFilter): google.firestore.v1beta1.StructuredQuery.FieldFilter; + + /** + * Encodes the specified FieldFilter message. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.FieldFilter.verify|verify} messages. + * @param message FieldFilter message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.StructuredQuery.IFieldFilter, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FieldFilter message, length delimited. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.FieldFilter.verify|verify} messages. + * @param message FieldFilter message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.StructuredQuery.IFieldFilter, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FieldFilter message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FieldFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.StructuredQuery.FieldFilter; + + /** + * Decodes a FieldFilter message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FieldFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.StructuredQuery.FieldFilter; + + /** + * Verifies a FieldFilter message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|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. */ + enum Operator { + OPERATOR_UNSPECIFIED = 0, + LESS_THAN = 1, + LESS_THAN_OR_EQUAL = 2, + GREATER_THAN = 3, + GREATER_THAN_OR_EQUAL = 4, + EQUAL = 5, + ARRAY_CONTAINS = 7 + } + } + + /** 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 a new UnaryFilter instance using the specified properties. + * @param [properties] Properties to set + * @returns UnaryFilter instance + */ + public static create(properties?: google.firestore.v1beta1.StructuredQuery.IUnaryFilter): google.firestore.v1beta1.StructuredQuery.UnaryFilter; + + /** + * Encodes the specified UnaryFilter message. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.UnaryFilter.verify|verify} messages. + * @param message UnaryFilter message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.StructuredQuery.IUnaryFilter, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UnaryFilter message, length delimited. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.UnaryFilter.verify|verify} messages. + * @param message UnaryFilter message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.StructuredQuery.IUnaryFilter, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UnaryFilter message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UnaryFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.StructuredQuery.UnaryFilter; + + /** + * Decodes an UnaryFilter message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UnaryFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.StructuredQuery.UnaryFilter; + + /** + * Verifies an UnaryFilter message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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. */ + enum Operator { + OPERATOR_UNSPECIFIED = 0, + IS_NAN = 2, + IS_NULL = 3 + } + } + + /** 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 a new Order instance using the specified properties. + * @param [properties] Properties to set + * @returns Order instance + */ + public static create(properties?: google.firestore.v1beta1.StructuredQuery.IOrder): google.firestore.v1beta1.StructuredQuery.Order; + + /** + * Encodes the specified Order message. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.Order.verify|verify} messages. + * @param message Order message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.StructuredQuery.IOrder, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Order message, length delimited. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.Order.verify|verify} messages. + * @param message Order message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.StructuredQuery.IOrder, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Order message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Order + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.StructuredQuery.Order; + + /** + * Decodes an Order message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Order + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.StructuredQuery.Order; + + /** + * Verifies an Order message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new FieldReference instance using the specified properties. + * @param [properties] Properties to set + * @returns FieldReference instance + */ + public static create(properties?: google.firestore.v1beta1.StructuredQuery.IFieldReference): google.firestore.v1beta1.StructuredQuery.FieldReference; + + /** + * Encodes the specified FieldReference message. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.FieldReference.verify|verify} messages. + * @param message FieldReference message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.StructuredQuery.IFieldReference, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FieldReference message, length delimited. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.FieldReference.verify|verify} messages. + * @param message FieldReference message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.StructuredQuery.IFieldReference, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FieldReference message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FieldReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.StructuredQuery.FieldReference; + + /** + * Decodes a FieldReference message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FieldReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.StructuredQuery.FieldReference; + + /** + * Verifies a FieldReference message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new Projection instance using the specified properties. + * @param [properties] Properties to set + * @returns Projection instance + */ + public static create(properties?: google.firestore.v1beta1.StructuredQuery.IProjection): google.firestore.v1beta1.StructuredQuery.Projection; + + /** + * Encodes the specified Projection message. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.Projection.verify|verify} messages. + * @param message Projection message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.StructuredQuery.IProjection, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Projection message, length delimited. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.Projection.verify|verify} messages. + * @param message Projection message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.StructuredQuery.IProjection, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Projection message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Projection + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.StructuredQuery.Projection; + + /** + * Decodes a Projection message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Projection + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.StructuredQuery.Projection; + + /** + * Verifies a Projection message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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. */ + enum Direction { + DIRECTION_UNSPECIFIED = 0, + ASCENDING = 1, + DESCENDING = 2 + } + } + + /** 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 new Cursor instance using the specified properties. + * @param [properties] Properties to set + * @returns Cursor instance + */ + public static create(properties?: google.firestore.v1beta1.ICursor): google.firestore.v1beta1.Cursor; + + /** + * Encodes the specified Cursor message. Does not implicitly {@link google.firestore.v1beta1.Cursor.verify|verify} messages. + * @param message Cursor message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.ICursor, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Cursor message, length delimited. Does not implicitly {@link google.firestore.v1beta1.Cursor.verify|verify} messages. + * @param message Cursor message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.ICursor, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Cursor message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Cursor + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.Cursor; + + /** + * Decodes a Cursor message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Cursor + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.Cursor; + + /** + * Verifies a Cursor message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new Write instance using the specified properties. + * @param [properties] Properties to set + * @returns Write instance + */ + public static create(properties?: google.firestore.v1beta1.IWrite): google.firestore.v1beta1.Write; + + /** + * Encodes the specified Write message. Does not implicitly {@link google.firestore.v1beta1.Write.verify|verify} messages. + * @param message Write message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IWrite, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Write message, length delimited. Does not implicitly {@link google.firestore.v1beta1.Write.verify|verify} messages. + * @param message Write message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IWrite, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Write message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Write + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.Write; + + /** + * Decodes a Write message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Write + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.Write; + + /** + * Verifies a Write message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new DocumentTransform instance using the specified properties. + * @param [properties] Properties to set + * @returns DocumentTransform instance + */ + public static create(properties?: google.firestore.v1beta1.IDocumentTransform): google.firestore.v1beta1.DocumentTransform; + + /** + * Encodes the specified DocumentTransform message. Does not implicitly {@link google.firestore.v1beta1.DocumentTransform.verify|verify} messages. + * @param message DocumentTransform message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IDocumentTransform, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DocumentTransform message, length delimited. Does not implicitly {@link google.firestore.v1beta1.DocumentTransform.verify|verify} messages. + * @param message DocumentTransform message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IDocumentTransform, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DocumentTransform message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DocumentTransform + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.DocumentTransform; + + /** + * Decodes a DocumentTransform message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DocumentTransform + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.DocumentTransform; + + /** + * Verifies a DocumentTransform message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 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 appendMissingElements. */ + public appendMissingElements?: (google.firestore.v1beta1.IArrayValue|null); + + /** FieldTransform removeAllFromArray. */ + public removeAllFromArray?: (google.firestore.v1beta1.IArrayValue|null); + + /** FieldTransform transformType. */ + public transformType?: ("setToServerValue"|"appendMissingElements"|"removeAllFromArray"); + + /** + * Creates a new FieldTransform instance using the specified properties. + * @param [properties] Properties to set + * @returns FieldTransform instance + */ + public static create(properties?: google.firestore.v1beta1.DocumentTransform.IFieldTransform): google.firestore.v1beta1.DocumentTransform.FieldTransform; + + /** + * Encodes the specified FieldTransform message. Does not implicitly {@link google.firestore.v1beta1.DocumentTransform.FieldTransform.verify|verify} messages. + * @param message FieldTransform message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.DocumentTransform.IFieldTransform, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FieldTransform message, length delimited. Does not implicitly {@link google.firestore.v1beta1.DocumentTransform.FieldTransform.verify|verify} messages. + * @param message FieldTransform message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.DocumentTransform.IFieldTransform, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FieldTransform message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FieldTransform + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.DocumentTransform.FieldTransform; + + /** + * Decodes a FieldTransform message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FieldTransform + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.DocumentTransform.FieldTransform; + + /** + * Verifies a FieldTransform message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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. */ + enum ServerValue { + SERVER_VALUE_UNSPECIFIED = 0, + REQUEST_TIME = 1 + } + } + } + + /** 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 new WriteResult instance using the specified properties. + * @param [properties] Properties to set + * @returns WriteResult instance + */ + public static create(properties?: google.firestore.v1beta1.IWriteResult): google.firestore.v1beta1.WriteResult; + + /** + * Encodes the specified WriteResult message. Does not implicitly {@link google.firestore.v1beta1.WriteResult.verify|verify} messages. + * @param message WriteResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IWriteResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified WriteResult message, length delimited. Does not implicitly {@link google.firestore.v1beta1.WriteResult.verify|verify} messages. + * @param message WriteResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IWriteResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a WriteResult message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns WriteResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.WriteResult; + + /** + * Decodes a WriteResult message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns WriteResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.WriteResult; + + /** + * Verifies a WriteResult message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new DocumentChange instance using the specified properties. + * @param [properties] Properties to set + * @returns DocumentChange instance + */ + public static create(properties?: google.firestore.v1beta1.IDocumentChange): google.firestore.v1beta1.DocumentChange; + + /** + * Encodes the specified DocumentChange message. Does not implicitly {@link google.firestore.v1beta1.DocumentChange.verify|verify} messages. + * @param message DocumentChange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IDocumentChange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DocumentChange message, length delimited. Does not implicitly {@link google.firestore.v1beta1.DocumentChange.verify|verify} messages. + * @param message DocumentChange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IDocumentChange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DocumentChange message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DocumentChange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.DocumentChange; + + /** + * Decodes a DocumentChange message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DocumentChange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.DocumentChange; + + /** + * Verifies a DocumentChange message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new DocumentDelete instance using the specified properties. + * @param [properties] Properties to set + * @returns DocumentDelete instance + */ + public static create(properties?: google.firestore.v1beta1.IDocumentDelete): google.firestore.v1beta1.DocumentDelete; + + /** + * Encodes the specified DocumentDelete message. Does not implicitly {@link google.firestore.v1beta1.DocumentDelete.verify|verify} messages. + * @param message DocumentDelete message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IDocumentDelete, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DocumentDelete message, length delimited. Does not implicitly {@link google.firestore.v1beta1.DocumentDelete.verify|verify} messages. + * @param message DocumentDelete message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IDocumentDelete, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DocumentDelete message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DocumentDelete + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.DocumentDelete; + + /** + * Decodes a DocumentDelete message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DocumentDelete + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.DocumentDelete; + + /** + * Verifies a DocumentDelete message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|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 new DocumentRemove instance using the specified properties. + * @param [properties] Properties to set + * @returns DocumentRemove instance + */ + public static create(properties?: google.firestore.v1beta1.IDocumentRemove): google.firestore.v1beta1.DocumentRemove; + + /** + * Encodes the specified DocumentRemove message. Does not implicitly {@link google.firestore.v1beta1.DocumentRemove.verify|verify} messages. + * @param message DocumentRemove message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IDocumentRemove, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DocumentRemove message, length delimited. Does not implicitly {@link google.firestore.v1beta1.DocumentRemove.verify|verify} messages. + * @param message DocumentRemove message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IDocumentRemove, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DocumentRemove message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DocumentRemove + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.DocumentRemove; + + /** + * Decodes a DocumentRemove message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DocumentRemove + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.DocumentRemove; + + /** + * Verifies a DocumentRemove message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|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 a new ExistenceFilter instance using the specified properties. + * @param [properties] Properties to set + * @returns ExistenceFilter instance + */ + public static create(properties?: google.firestore.v1beta1.IExistenceFilter): google.firestore.v1beta1.ExistenceFilter; + + /** + * Encodes the specified ExistenceFilter message. Does not implicitly {@link google.firestore.v1beta1.ExistenceFilter.verify|verify} messages. + * @param message ExistenceFilter message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.firestore.v1beta1.IExistenceFilter, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExistenceFilter message, length delimited. Does not implicitly {@link google.firestore.v1beta1.ExistenceFilter.verify|verify} messages. + * @param message ExistenceFilter message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.firestore.v1beta1.IExistenceFilter, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExistenceFilter message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExistenceFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.firestore.v1beta1.ExistenceFilter; + + /** + * Decodes an ExistenceFilter message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExistenceFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.firestore.v1beta1.ExistenceFilter; + + /** + * Verifies an ExistenceFilter message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new Http instance using the specified properties. + * @param [properties] Properties to set + * @returns Http instance + */ + public static create(properties?: google.api.IHttp): google.api.Http; + + /** + * Encodes the specified Http message. Does not implicitly {@link google.api.Http.verify|verify} messages. + * @param message Http message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.IHttp, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Http message, length delimited. Does not implicitly {@link google.api.Http.verify|verify} messages. + * @param message Http message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.IHttp, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Http message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Http + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.Http; + + /** + * Decodes a Http message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Http + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.Http; + + /** + * Verifies a Http message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new HttpRule instance using the specified properties. + * @param [properties] Properties to set + * @returns HttpRule instance + */ + public static create(properties?: google.api.IHttpRule): google.api.HttpRule; + + /** + * Encodes the specified HttpRule message. Does not implicitly {@link google.api.HttpRule.verify|verify} messages. + * @param message HttpRule message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.IHttpRule, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified HttpRule message, length delimited. Does not implicitly {@link google.api.HttpRule.verify|verify} messages. + * @param message HttpRule message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.IHttpRule, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a HttpRule message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns HttpRule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.HttpRule; + + /** + * Decodes a HttpRule message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns HttpRule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.HttpRule; + + /** + * Verifies a HttpRule message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new CustomHttpPattern instance using the specified properties. + * @param [properties] Properties to set + * @returns CustomHttpPattern instance + */ + public static create(properties?: google.api.ICustomHttpPattern): google.api.CustomHttpPattern; + + /** + * Encodes the specified CustomHttpPattern message. Does not implicitly {@link google.api.CustomHttpPattern.verify|verify} messages. + * @param message CustomHttpPattern message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.ICustomHttpPattern, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CustomHttpPattern message, length delimited. Does not implicitly {@link google.api.CustomHttpPattern.verify|verify} messages. + * @param message CustomHttpPattern message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.ICustomHttpPattern, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CustomHttpPattern message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CustomHttpPattern + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.CustomHttpPattern; + + /** + * Decodes a CustomHttpPattern message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CustomHttpPattern + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.CustomHttpPattern; + + /** + * Verifies a CustomHttpPattern message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 }; + } + } + + /** 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 new FileDescriptorSet instance using the specified properties. + * @param [properties] Properties to set + * @returns FileDescriptorSet instance + */ + public static create(properties?: google.protobuf.IFileDescriptorSet): google.protobuf.FileDescriptorSet; + + /** + * Encodes the specified FileDescriptorSet message. Does not implicitly {@link google.protobuf.FileDescriptorSet.verify|verify} messages. + * @param message FileDescriptorSet message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IFileDescriptorSet, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FileDescriptorSet message, length delimited. Does not implicitly {@link google.protobuf.FileDescriptorSet.verify|verify} messages. + * @param message FileDescriptorSet message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IFileDescriptorSet, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FileDescriptorSet message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FileDescriptorSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.FileDescriptorSet; + + /** + * Decodes a FileDescriptorSet message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FileDescriptorSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.FileDescriptorSet; + + /** + * Verifies a FileDescriptorSet message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new FileDescriptorProto instance using the specified properties. + * @param [properties] Properties to set + * @returns FileDescriptorProto instance + */ + public static create(properties?: google.protobuf.IFileDescriptorProto): google.protobuf.FileDescriptorProto; + + /** + * Encodes the specified FileDescriptorProto message. Does not implicitly {@link google.protobuf.FileDescriptorProto.verify|verify} messages. + * @param message FileDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IFileDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FileDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.FileDescriptorProto.verify|verify} messages. + * @param message FileDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IFileDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FileDescriptorProto message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FileDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.FileDescriptorProto; + + /** + * Decodes a FileDescriptorProto message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FileDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.FileDescriptorProto; + + /** + * Verifies a FileDescriptorProto message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new DescriptorProto instance using the specified properties. + * @param [properties] Properties to set + * @returns DescriptorProto instance + */ + public static create(properties?: google.protobuf.IDescriptorProto): google.protobuf.DescriptorProto; + + /** + * Encodes the specified DescriptorProto message. Does not implicitly {@link google.protobuf.DescriptorProto.verify|verify} messages. + * @param message DescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.DescriptorProto.verify|verify} messages. + * @param message DescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DescriptorProto message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.DescriptorProto; + + /** + * Decodes a DescriptorProto message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.DescriptorProto; + + /** + * Verifies a DescriptorProto message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 a new ExtensionRange instance using the specified properties. + * @param [properties] Properties to set + * @returns ExtensionRange instance + */ + public static create(properties?: google.protobuf.DescriptorProto.IExtensionRange): google.protobuf.DescriptorProto.ExtensionRange; + + /** + * Encodes the specified ExtensionRange message. Does not implicitly {@link google.protobuf.DescriptorProto.ExtensionRange.verify|verify} messages. + * @param message ExtensionRange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.DescriptorProto.IExtensionRange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExtensionRange message, length delimited. Does not implicitly {@link google.protobuf.DescriptorProto.ExtensionRange.verify|verify} messages. + * @param message ExtensionRange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.DescriptorProto.IExtensionRange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExtensionRange message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExtensionRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.DescriptorProto.ExtensionRange; + + /** + * Decodes an ExtensionRange message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExtensionRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.DescriptorProto.ExtensionRange; + + /** + * Verifies an ExtensionRange message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new ReservedRange instance using the specified properties. + * @param [properties] Properties to set + * @returns ReservedRange instance + */ + public static create(properties?: google.protobuf.DescriptorProto.IReservedRange): google.protobuf.DescriptorProto.ReservedRange; + + /** + * Encodes the specified ReservedRange message. Does not implicitly {@link google.protobuf.DescriptorProto.ReservedRange.verify|verify} messages. + * @param message ReservedRange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.DescriptorProto.IReservedRange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ReservedRange message, length delimited. Does not implicitly {@link google.protobuf.DescriptorProto.ReservedRange.verify|verify} messages. + * @param message ReservedRange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.DescriptorProto.IReservedRange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ReservedRange message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ReservedRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.DescriptorProto.ReservedRange; + + /** + * Decodes a ReservedRange message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ReservedRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.DescriptorProto.ReservedRange; + + /** + * Verifies a ReservedRange message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new FieldDescriptorProto instance using the specified properties. + * @param [properties] Properties to set + * @returns FieldDescriptorProto instance + */ + public static create(properties?: google.protobuf.IFieldDescriptorProto): google.protobuf.FieldDescriptorProto; + + /** + * Encodes the specified FieldDescriptorProto message. Does not implicitly {@link google.protobuf.FieldDescriptorProto.verify|verify} messages. + * @param message FieldDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IFieldDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FieldDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.FieldDescriptorProto.verify|verify} messages. + * @param message FieldDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IFieldDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FieldDescriptorProto message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FieldDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.FieldDescriptorProto; + + /** + * Decodes a FieldDescriptorProto message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FieldDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.FieldDescriptorProto; + + /** + * Verifies a FieldDescriptorProto message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|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. */ + enum Type { + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + TYPE_GROUP = 10, + TYPE_MESSAGE = 11, + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + TYPE_SINT32 = 17, + TYPE_SINT64 = 18 + } + + /** Label enum. */ + enum Label { + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3 + } + } + + /** 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 a new OneofDescriptorProto instance using the specified properties. + * @param [properties] Properties to set + * @returns OneofDescriptorProto instance + */ + public static create(properties?: google.protobuf.IOneofDescriptorProto): google.protobuf.OneofDescriptorProto; + + /** + * Encodes the specified OneofDescriptorProto message. Does not implicitly {@link google.protobuf.OneofDescriptorProto.verify|verify} messages. + * @param message OneofDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IOneofDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified OneofDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.OneofDescriptorProto.verify|verify} messages. + * @param message OneofDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IOneofDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an OneofDescriptorProto message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns OneofDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.OneofDescriptorProto; + + /** + * Decodes an OneofDescriptorProto message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns OneofDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.OneofDescriptorProto; + + /** + * Verifies an OneofDescriptorProto message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|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 a new EnumDescriptorProto instance using the specified properties. + * @param [properties] Properties to set + * @returns EnumDescriptorProto instance + */ + public static create(properties?: google.protobuf.IEnumDescriptorProto): google.protobuf.EnumDescriptorProto; + + /** + * Encodes the specified EnumDescriptorProto message. Does not implicitly {@link google.protobuf.EnumDescriptorProto.verify|verify} messages. + * @param message EnumDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IEnumDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified EnumDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.EnumDescriptorProto.verify|verify} messages. + * @param message EnumDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IEnumDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an EnumDescriptorProto message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns EnumDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.EnumDescriptorProto; + + /** + * Decodes an EnumDescriptorProto message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns EnumDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.EnumDescriptorProto; + + /** + * Verifies an EnumDescriptorProto message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|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 a new EnumValueDescriptorProto instance using the specified properties. + * @param [properties] Properties to set + * @returns EnumValueDescriptorProto instance + */ + public static create(properties?: google.protobuf.IEnumValueDescriptorProto): google.protobuf.EnumValueDescriptorProto; + + /** + * Encodes the specified EnumValueDescriptorProto message. Does not implicitly {@link google.protobuf.EnumValueDescriptorProto.verify|verify} messages. + * @param message EnumValueDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IEnumValueDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified EnumValueDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.EnumValueDescriptorProto.verify|verify} messages. + * @param message EnumValueDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IEnumValueDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an EnumValueDescriptorProto message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns EnumValueDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.EnumValueDescriptorProto; + + /** + * Decodes an EnumValueDescriptorProto message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns EnumValueDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.EnumValueDescriptorProto; + + /** + * Verifies an EnumValueDescriptorProto message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|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 new ServiceDescriptorProto instance using the specified properties. + * @param [properties] Properties to set + * @returns ServiceDescriptorProto instance + */ + public static create(properties?: google.protobuf.IServiceDescriptorProto): google.protobuf.ServiceDescriptorProto; + + /** + * Encodes the specified ServiceDescriptorProto message. Does not implicitly {@link google.protobuf.ServiceDescriptorProto.verify|verify} messages. + * @param message ServiceDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IServiceDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ServiceDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.ServiceDescriptorProto.verify|verify} messages. + * @param message ServiceDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IServiceDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ServiceDescriptorProto message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ServiceDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.ServiceDescriptorProto; + + /** + * Decodes a ServiceDescriptorProto message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ServiceDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.ServiceDescriptorProto; + + /** + * Verifies a ServiceDescriptorProto message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|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 new MethodDescriptorProto instance using the specified properties. + * @param [properties] Properties to set + * @returns MethodDescriptorProto instance + */ + public static create(properties?: google.protobuf.IMethodDescriptorProto): google.protobuf.MethodDescriptorProto; + + /** + * Encodes the specified MethodDescriptorProto message. Does not implicitly {@link google.protobuf.MethodDescriptorProto.verify|verify} messages. + * @param message MethodDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IMethodDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified MethodDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.MethodDescriptorProto.verify|verify} messages. + * @param message MethodDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IMethodDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a MethodDescriptorProto message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns MethodDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.MethodDescriptorProto; + + /** + * Decodes a MethodDescriptorProto message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns MethodDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.MethodDescriptorProto; + + /** + * Verifies a MethodDescriptorProto message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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); + } + + /** 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 new FileOptions instance using the specified properties. + * @param [properties] Properties to set + * @returns FileOptions instance + */ + public static create(properties?: google.protobuf.IFileOptions): google.protobuf.FileOptions; + + /** + * Encodes the specified FileOptions message. Does not implicitly {@link google.protobuf.FileOptions.verify|verify} messages. + * @param message FileOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IFileOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FileOptions message, length delimited. Does not implicitly {@link google.protobuf.FileOptions.verify|verify} messages. + * @param message FileOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IFileOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FileOptions message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FileOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.FileOptions; + + /** + * Decodes a FileOptions message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FileOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.FileOptions; + + /** + * Verifies a FileOptions message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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. */ + enum OptimizeMode { + SPEED = 1, + CODE_SIZE = 2, + LITE_RUNTIME = 3 + } + } + + /** 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); + } + + /** 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 new MessageOptions instance using the specified properties. + * @param [properties] Properties to set + * @returns MessageOptions instance + */ + public static create(properties?: google.protobuf.IMessageOptions): google.protobuf.MessageOptions; + + /** + * Encodes the specified MessageOptions message. Does not implicitly {@link google.protobuf.MessageOptions.verify|verify} messages. + * @param message MessageOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IMessageOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified MessageOptions message, length delimited. Does not implicitly {@link google.protobuf.MessageOptions.verify|verify} messages. + * @param message MessageOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IMessageOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a MessageOptions message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns MessageOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.MessageOptions; + + /** + * Decodes a MessageOptions message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns MessageOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.MessageOptions; + + /** + * Verifies a MessageOptions message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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); + } + + /** 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 new FieldOptions instance using the specified properties. + * @param [properties] Properties to set + * @returns FieldOptions instance + */ + public static create(properties?: google.protobuf.IFieldOptions): google.protobuf.FieldOptions; + + /** + * Encodes the specified FieldOptions message. Does not implicitly {@link google.protobuf.FieldOptions.verify|verify} messages. + * @param message FieldOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IFieldOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FieldOptions message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.verify|verify} messages. + * @param message FieldOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IFieldOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FieldOptions message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FieldOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.FieldOptions; + + /** + * Decodes a FieldOptions message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FieldOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.FieldOptions; + + /** + * Verifies a FieldOptions message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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. */ + enum CType { + STRING = 0, + CORD = 1, + STRING_PIECE = 2 + } + + /** JSType enum. */ + enum JSType { + JS_NORMAL = 0, + JS_STRING = 1, + JS_NUMBER = 2 + } + } + + /** 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 a new OneofOptions instance using the specified properties. + * @param [properties] Properties to set + * @returns OneofOptions instance + */ + public static create(properties?: google.protobuf.IOneofOptions): google.protobuf.OneofOptions; + + /** + * Encodes the specified OneofOptions message. Does not implicitly {@link google.protobuf.OneofOptions.verify|verify} messages. + * @param message OneofOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IOneofOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified OneofOptions message, length delimited. Does not implicitly {@link google.protobuf.OneofOptions.verify|verify} messages. + * @param message OneofOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IOneofOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an OneofOptions message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns OneofOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.OneofOptions; + + /** + * Decodes an OneofOptions message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns OneofOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.OneofOptions; + + /** + * Verifies an OneofOptions message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 a new EnumOptions instance using the specified properties. + * @param [properties] Properties to set + * @returns EnumOptions instance + */ + public static create(properties?: google.protobuf.IEnumOptions): google.protobuf.EnumOptions; + + /** + * Encodes the specified EnumOptions message. Does not implicitly {@link google.protobuf.EnumOptions.verify|verify} messages. + * @param message EnumOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IEnumOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified EnumOptions message, length delimited. Does not implicitly {@link google.protobuf.EnumOptions.verify|verify} messages. + * @param message EnumOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IEnumOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an EnumOptions message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns EnumOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.EnumOptions; + + /** + * Decodes an EnumOptions message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns EnumOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.EnumOptions; + + /** + * Verifies an EnumOptions message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 a new EnumValueOptions instance using the specified properties. + * @param [properties] Properties to set + * @returns EnumValueOptions instance + */ + public static create(properties?: google.protobuf.IEnumValueOptions): google.protobuf.EnumValueOptions; + + /** + * Encodes the specified EnumValueOptions message. Does not implicitly {@link google.protobuf.EnumValueOptions.verify|verify} messages. + * @param message EnumValueOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IEnumValueOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified EnumValueOptions message, length delimited. Does not implicitly {@link google.protobuf.EnumValueOptions.verify|verify} messages. + * @param message EnumValueOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IEnumValueOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an EnumValueOptions message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns EnumValueOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.EnumValueOptions; + + /** + * Decodes an EnumValueOptions message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns EnumValueOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.EnumValueOptions; + + /** + * Verifies an EnumValueOptions message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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); + } + + /** 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 new ServiceOptions instance using the specified properties. + * @param [properties] Properties to set + * @returns ServiceOptions instance + */ + public static create(properties?: google.protobuf.IServiceOptions): google.protobuf.ServiceOptions; + + /** + * Encodes the specified ServiceOptions message. Does not implicitly {@link google.protobuf.ServiceOptions.verify|verify} messages. + * @param message ServiceOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IServiceOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ServiceOptions message, length delimited. Does not implicitly {@link google.protobuf.ServiceOptions.verify|verify} messages. + * @param message ServiceOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IServiceOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ServiceOptions message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ServiceOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.ServiceOptions; + + /** + * Decodes a ServiceOptions message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ServiceOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.ServiceOptions; + + /** + * Verifies a ServiceOptions message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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); + } + + /** 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 new MethodOptions instance using the specified properties. + * @param [properties] Properties to set + * @returns MethodOptions instance + */ + public static create(properties?: google.protobuf.IMethodOptions): google.protobuf.MethodOptions; + + /** + * Encodes the specified MethodOptions message. Does not implicitly {@link google.protobuf.MethodOptions.verify|verify} messages. + * @param message MethodOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IMethodOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified MethodOptions message, length delimited. Does not implicitly {@link google.protobuf.MethodOptions.verify|verify} messages. + * @param message MethodOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IMethodOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a MethodOptions message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns MethodOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.MethodOptions; + + /** + * Decodes a MethodOptions message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns MethodOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.MethodOptions; + + /** + * Verifies a MethodOptions message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 a new UninterpretedOption instance using the specified properties. + * @param [properties] Properties to set + * @returns UninterpretedOption instance + */ + public static create(properties?: google.protobuf.IUninterpretedOption): google.protobuf.UninterpretedOption; + + /** + * Encodes the specified UninterpretedOption message. Does not implicitly {@link google.protobuf.UninterpretedOption.verify|verify} messages. + * @param message UninterpretedOption message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IUninterpretedOption, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UninterpretedOption message, length delimited. Does not implicitly {@link google.protobuf.UninterpretedOption.verify|verify} messages. + * @param message UninterpretedOption message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IUninterpretedOption, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UninterpretedOption message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UninterpretedOption + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.UninterpretedOption; + + /** + * Decodes an UninterpretedOption message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UninterpretedOption + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.UninterpretedOption; + + /** + * Verifies an UninterpretedOption message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new NamePart instance using the specified properties. + * @param [properties] Properties to set + * @returns NamePart instance + */ + public static create(properties?: google.protobuf.UninterpretedOption.INamePart): google.protobuf.UninterpretedOption.NamePart; + + /** + * Encodes the specified NamePart message. Does not implicitly {@link google.protobuf.UninterpretedOption.NamePart.verify|verify} messages. + * @param message NamePart message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.UninterpretedOption.INamePart, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified NamePart message, length delimited. Does not implicitly {@link google.protobuf.UninterpretedOption.NamePart.verify|verify} messages. + * @param message NamePart message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.UninterpretedOption.INamePart, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a NamePart message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns NamePart + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.UninterpretedOption.NamePart; + + /** + * Decodes a NamePart message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns NamePart + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.UninterpretedOption.NamePart; + + /** + * Verifies a NamePart message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new SourceCodeInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns SourceCodeInfo instance + */ + public static create(properties?: google.protobuf.ISourceCodeInfo): google.protobuf.SourceCodeInfo; + + /** + * Encodes the specified SourceCodeInfo message. Does not implicitly {@link google.protobuf.SourceCodeInfo.verify|verify} messages. + * @param message SourceCodeInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.ISourceCodeInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SourceCodeInfo message, length delimited. Does not implicitly {@link google.protobuf.SourceCodeInfo.verify|verify} messages. + * @param message SourceCodeInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.ISourceCodeInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SourceCodeInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SourceCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.SourceCodeInfo; + + /** + * Decodes a SourceCodeInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SourceCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.SourceCodeInfo; + + /** + * Verifies a SourceCodeInfo message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new Location instance using the specified properties. + * @param [properties] Properties to set + * @returns Location instance + */ + public static create(properties?: google.protobuf.SourceCodeInfo.ILocation): google.protobuf.SourceCodeInfo.Location; + + /** + * Encodes the specified Location message. Does not implicitly {@link google.protobuf.SourceCodeInfo.Location.verify|verify} messages. + * @param message Location message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.SourceCodeInfo.ILocation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Location message, length delimited. Does not implicitly {@link google.protobuf.SourceCodeInfo.Location.verify|verify} messages. + * @param message Location message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.SourceCodeInfo.ILocation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Location message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Location + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.SourceCodeInfo.Location; + + /** + * Decodes a Location message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Location + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.SourceCodeInfo.Location; + + /** + * Verifies a Location message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new GeneratedCodeInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns GeneratedCodeInfo instance + */ + public static create(properties?: google.protobuf.IGeneratedCodeInfo): google.protobuf.GeneratedCodeInfo; + + /** + * Encodes the specified GeneratedCodeInfo message. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.verify|verify} messages. + * @param message GeneratedCodeInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IGeneratedCodeInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GeneratedCodeInfo message, length delimited. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.verify|verify} messages. + * @param message GeneratedCodeInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IGeneratedCodeInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GeneratedCodeInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GeneratedCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.GeneratedCodeInfo; + + /** + * Decodes a GeneratedCodeInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GeneratedCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.GeneratedCodeInfo; + + /** + * Verifies a GeneratedCodeInfo message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 a new Annotation instance using the specified properties. + * @param [properties] Properties to set + * @returns Annotation instance + */ + public static create(properties?: google.protobuf.GeneratedCodeInfo.IAnnotation): google.protobuf.GeneratedCodeInfo.Annotation; + + /** + * Encodes the specified Annotation message. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.Annotation.verify|verify} messages. + * @param message Annotation message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.GeneratedCodeInfo.IAnnotation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Annotation message, length delimited. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.Annotation.verify|verify} messages. + * @param message Annotation message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.GeneratedCodeInfo.IAnnotation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Annotation message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Annotation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.GeneratedCodeInfo.Annotation; + + /** + * Decodes an Annotation message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Annotation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.GeneratedCodeInfo.Annotation; + + /** + * Verifies an Annotation message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 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 new Timestamp instance using the specified properties. + * @param [properties] Properties to set + * @returns Timestamp instance + */ + public static create(properties?: google.protobuf.ITimestamp): google.protobuf.Timestamp; + + /** + * Encodes the specified Timestamp message. Does not implicitly {@link google.protobuf.Timestamp.verify|verify} messages. + * @param message Timestamp message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.ITimestamp, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Timestamp message, length delimited. Does not implicitly {@link google.protobuf.Timestamp.verify|verify} messages. + * @param message Timestamp message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.ITimestamp, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Timestamp message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Timestamp + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.Timestamp; + + /** + * Decodes a Timestamp message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Timestamp + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.Timestamp; + + /** + * Verifies a Timestamp message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 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 new Struct instance using the specified properties. + * @param [properties] Properties to set + * @returns Struct instance + */ + public static create(properties?: google.protobuf.IStruct): google.protobuf.Struct; + + /** + * Encodes the specified Struct message. Does not implicitly {@link google.protobuf.Struct.verify|verify} messages. + * @param message Struct message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IStruct, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Struct message, length delimited. Does not implicitly {@link google.protobuf.Struct.verify|verify} messages. + * @param message Struct message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IStruct, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Struct message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Struct + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.Struct; + + /** + * Decodes a Struct message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Struct + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.Struct; + + /** + * Verifies a Struct message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new Value instance using the specified properties. + * @param [properties] Properties to set + * @returns Value instance + */ + public static create(properties?: google.protobuf.IValue): google.protobuf.Value; + + /** + * Encodes the specified Value message. Does not implicitly {@link google.protobuf.Value.verify|verify} messages. + * @param message Value message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Value message, length delimited. Does not implicitly {@link google.protobuf.Value.verify|verify} messages. + * @param message Value message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Value message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.Value; + + /** + * Decodes a Value message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.Value; + + /** + * Verifies a Value message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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. */ + enum NullValue { + NULL_VALUE = 0 + } + + /** 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 new ListValue instance using the specified properties. + * @param [properties] Properties to set + * @returns ListValue instance + */ + public static create(properties?: google.protobuf.IListValue): google.protobuf.ListValue; + + /** + * Encodes the specified ListValue message. Does not implicitly {@link google.protobuf.ListValue.verify|verify} messages. + * @param message ListValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IListValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListValue message, length delimited. Does not implicitly {@link google.protobuf.ListValue.verify|verify} messages. + * @param message ListValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IListValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListValue message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.ListValue; + + /** + * Decodes a ListValue message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.ListValue; + + /** + * Verifies a ListValue message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new DoubleValue instance using the specified properties. + * @param [properties] Properties to set + * @returns DoubleValue instance + */ + public static create(properties?: google.protobuf.IDoubleValue): google.protobuf.DoubleValue; + + /** + * Encodes the specified DoubleValue message. Does not implicitly {@link google.protobuf.DoubleValue.verify|verify} messages. + * @param message DoubleValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IDoubleValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DoubleValue message, length delimited. Does not implicitly {@link google.protobuf.DoubleValue.verify|verify} messages. + * @param message DoubleValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IDoubleValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DoubleValue message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DoubleValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.DoubleValue; + + /** + * Decodes a DoubleValue message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DoubleValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.DoubleValue; + + /** + * Verifies a DoubleValue message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new FloatValue instance using the specified properties. + * @param [properties] Properties to set + * @returns FloatValue instance + */ + public static create(properties?: google.protobuf.IFloatValue): google.protobuf.FloatValue; + + /** + * Encodes the specified FloatValue message. Does not implicitly {@link google.protobuf.FloatValue.verify|verify} messages. + * @param message FloatValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IFloatValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FloatValue message, length delimited. Does not implicitly {@link google.protobuf.FloatValue.verify|verify} messages. + * @param message FloatValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IFloatValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FloatValue message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FloatValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.FloatValue; + + /** + * Decodes a FloatValue message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FloatValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.FloatValue; + + /** + * Verifies a FloatValue message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 a new Int64Value instance using the specified properties. + * @param [properties] Properties to set + * @returns Int64Value instance + */ + public static create(properties?: google.protobuf.IInt64Value): google.protobuf.Int64Value; + + /** + * Encodes the specified Int64Value message. Does not implicitly {@link google.protobuf.Int64Value.verify|verify} messages. + * @param message Int64Value message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IInt64Value, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Int64Value message, length delimited. Does not implicitly {@link google.protobuf.Int64Value.verify|verify} messages. + * @param message Int64Value message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IInt64Value, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Int64Value message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Int64Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.Int64Value; + + /** + * Decodes an Int64Value message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Int64Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.Int64Value; + + /** + * Verifies an Int64Value message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new UInt64Value instance using the specified properties. + * @param [properties] Properties to set + * @returns UInt64Value instance + */ + public static create(properties?: google.protobuf.IUInt64Value): google.protobuf.UInt64Value; + + /** + * Encodes the specified UInt64Value message. Does not implicitly {@link google.protobuf.UInt64Value.verify|verify} messages. + * @param message UInt64Value message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IUInt64Value, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UInt64Value message, length delimited. Does not implicitly {@link google.protobuf.UInt64Value.verify|verify} messages. + * @param message UInt64Value message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IUInt64Value, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a UInt64Value message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UInt64Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.UInt64Value; + + /** + * Decodes a UInt64Value message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UInt64Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.UInt64Value; + + /** + * Verifies a UInt64Value message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 a new Int32Value instance using the specified properties. + * @param [properties] Properties to set + * @returns Int32Value instance + */ + public static create(properties?: google.protobuf.IInt32Value): google.protobuf.Int32Value; + + /** + * Encodes the specified Int32Value message. Does not implicitly {@link google.protobuf.Int32Value.verify|verify} messages. + * @param message Int32Value message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IInt32Value, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Int32Value message, length delimited. Does not implicitly {@link google.protobuf.Int32Value.verify|verify} messages. + * @param message Int32Value message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IInt32Value, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Int32Value message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Int32Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.Int32Value; + + /** + * Decodes an Int32Value message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Int32Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.Int32Value; + + /** + * Verifies an Int32Value message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new UInt32Value instance using the specified properties. + * @param [properties] Properties to set + * @returns UInt32Value instance + */ + public static create(properties?: google.protobuf.IUInt32Value): google.protobuf.UInt32Value; + + /** + * Encodes the specified UInt32Value message. Does not implicitly {@link google.protobuf.UInt32Value.verify|verify} messages. + * @param message UInt32Value message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IUInt32Value, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UInt32Value message, length delimited. Does not implicitly {@link google.protobuf.UInt32Value.verify|verify} messages. + * @param message UInt32Value message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IUInt32Value, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a UInt32Value message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UInt32Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.UInt32Value; + + /** + * Decodes a UInt32Value message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UInt32Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.UInt32Value; + + /** + * Verifies a UInt32Value message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new BoolValue instance using the specified properties. + * @param [properties] Properties to set + * @returns BoolValue instance + */ + public static create(properties?: google.protobuf.IBoolValue): google.protobuf.BoolValue; + + /** + * Encodes the specified BoolValue message. Does not implicitly {@link google.protobuf.BoolValue.verify|verify} messages. + * @param message BoolValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IBoolValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BoolValue message, length delimited. Does not implicitly {@link google.protobuf.BoolValue.verify|verify} messages. + * @param message BoolValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IBoolValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BoolValue message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BoolValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.BoolValue; + + /** + * Decodes a BoolValue message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BoolValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.BoolValue; + + /** + * Verifies a BoolValue message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new StringValue instance using the specified properties. + * @param [properties] Properties to set + * @returns StringValue instance + */ + public static create(properties?: google.protobuf.IStringValue): google.protobuf.StringValue; + + /** + * Encodes the specified StringValue message. Does not implicitly {@link google.protobuf.StringValue.verify|verify} messages. + * @param message StringValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IStringValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified StringValue message, length delimited. Does not implicitly {@link google.protobuf.StringValue.verify|verify} messages. + * @param message StringValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IStringValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a StringValue message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns StringValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.StringValue; + + /** + * Decodes a StringValue message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns StringValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.StringValue; + + /** + * Verifies a StringValue message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new BytesValue instance using the specified properties. + * @param [properties] Properties to set + * @returns BytesValue instance + */ + public static create(properties?: google.protobuf.IBytesValue): google.protobuf.BytesValue; + + /** + * Encodes the specified BytesValue message. Does not implicitly {@link google.protobuf.BytesValue.verify|verify} messages. + * @param message BytesValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IBytesValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BytesValue message, length delimited. Does not implicitly {@link google.protobuf.BytesValue.verify|verify} messages. + * @param message BytesValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IBytesValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BytesValue message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BytesValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.BytesValue; + + /** + * Decodes a BytesValue message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BytesValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.BytesValue; + + /** + * Verifies a BytesValue message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 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 a new Empty instance using the specified properties. + * @param [properties] Properties to set + * @returns Empty instance + */ + public static create(properties?: google.protobuf.IEmpty): google.protobuf.Empty; + + /** + * Encodes the specified Empty message. Does not implicitly {@link google.protobuf.Empty.verify|verify} messages. + * @param message Empty message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IEmpty, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Empty message, length delimited. Does not implicitly {@link google.protobuf.Empty.verify|verify} messages. + * @param message Empty message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IEmpty, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Empty message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Empty + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.Empty; + + /** + * Decodes an Empty message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Empty + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.Empty; + + /** + * Verifies an Empty message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 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 a new Any instance using the specified properties. + * @param [properties] Properties to set + * @returns Any instance + */ + public static create(properties?: google.protobuf.IAny): google.protobuf.Any; + + /** + * Encodes the specified Any message. Does not implicitly {@link google.protobuf.Any.verify|verify} messages. + * @param message Any message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IAny, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Any message, length delimited. Does not implicitly {@link google.protobuf.Any.verify|verify} messages. + * @param message Any message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IAny, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Any message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Any + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.Any; + + /** + * Decodes an Any message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Any + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.Any; + + /** + * Verifies an Any message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 }; + } + } + + /** 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 new LatLng instance using the specified properties. + * @param [properties] Properties to set + * @returns LatLng instance + */ + public static create(properties?: google.type.ILatLng): google.type.LatLng; + + /** + * Encodes the specified LatLng message. Does not implicitly {@link google.type.LatLng.verify|verify} messages. + * @param message LatLng message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.type.ILatLng, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified LatLng message, length delimited. Does not implicitly {@link google.type.LatLng.verify|verify} messages. + * @param message LatLng message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.type.ILatLng, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a LatLng message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns LatLng + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.type.LatLng; + + /** + * Decodes a LatLng message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns LatLng + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.type.LatLng; + + /** + * Verifies a LatLng message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 new Status instance using the specified properties. + * @param [properties] Properties to set + * @returns Status instance + */ + public static create(properties?: google.rpc.IStatus): google.rpc.Status; + + /** + * Encodes the specified Status message. Does not implicitly {@link google.rpc.Status.verify|verify} messages. + * @param message Status message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.rpc.IStatus, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Status message, length delimited. Does not implicitly {@link google.rpc.Status.verify|verify} messages. + * @param message Status message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.rpc.IStatus, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Status message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Status + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.rpc.Status; + + /** + * Decodes a Status message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Status + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.rpc.Status; + + /** + * Verifies a Status message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * 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 }; + } + } +} diff --git a/website/functions/node_modules/@google-cloud/firestore/build/protos/firestore_proto_api.js b/website/functions/node_modules/@google-cloud/firestore/build/protos/firestore_proto_api.js new file mode 100644 index 00000000..b3d1db77 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/protos/firestore_proto_api.js @@ -0,0 +1,26706 @@ +/*eslint-disable block-scoped-var, no-redeclare, no-control-regex, no-prototype-builtins*/ +"use strict"; + +// Note: This file was manually edited to use "string" instead of "Long" for +// types that can potentially hold large integer values (> 2^53). + +var $protobuf = require("protobufjs/minimal"); + +// Common aliases +var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $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.v1beta1 = (function() { + + /** + * Namespace v1beta1. + * @memberof google.firestore + * @namespace + */ + var v1beta1 = {}; + + 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; + + /** + * Creates new Firestore service using the specified rpc implementation. + * @function create + * @memberof google.firestore.v1beta1.Firestore + * @static + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + * @returns {Firestore} RPC service. Useful where requests and/or responses are streamed. + */ + Firestore.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * 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 + */ + Firestore.prototype.getDocument = function getDocument(request, callback) { + return this.rpcCall(getDocument, $root.google.firestore.v1beta1.GetDocumentRequest, $root.google.firestore.v1beta1.Document, request, callback); + }; + + /** + * 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 + */ + Firestore.prototype.listDocuments = function listDocuments(request, callback) { + return this.rpcCall(listDocuments, $root.google.firestore.v1beta1.ListDocumentsRequest, $root.google.firestore.v1beta1.ListDocumentsResponse, request, callback); + }; + + /** + * 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 + */ + Firestore.prototype.createDocument = function createDocument(request, callback) { + return this.rpcCall(createDocument, $root.google.firestore.v1beta1.CreateDocumentRequest, $root.google.firestore.v1beta1.Document, request, callback); + }; + + /** + * 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 + */ + Firestore.prototype.updateDocument = function updateDocument(request, callback) { + return this.rpcCall(updateDocument, $root.google.firestore.v1beta1.UpdateDocumentRequest, $root.google.firestore.v1beta1.Document, request, callback); + }; + + /** + * 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 + */ + Firestore.prototype.deleteDocument = function deleteDocument(request, callback) { + return this.rpcCall(deleteDocument, $root.google.firestore.v1beta1.DeleteDocumentRequest, $root.google.protobuf.Empty, request, callback); + }; + + /** + * 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 + */ + Firestore.prototype.batchGetDocuments = function batchGetDocuments(request, callback) { + return this.rpcCall(batchGetDocuments, $root.google.firestore.v1beta1.BatchGetDocumentsRequest, $root.google.firestore.v1beta1.BatchGetDocumentsResponse, request, callback); + }; + + /** + * 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 + */ + Firestore.prototype.beginTransaction = function beginTransaction(request, callback) { + return this.rpcCall(beginTransaction, $root.google.firestore.v1beta1.BeginTransactionRequest, $root.google.firestore.v1beta1.BeginTransactionResponse, request, callback); + }; + + /** + * 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 + */ + Firestore.prototype.commit = function commit(request, callback) { + return this.rpcCall(commit, $root.google.firestore.v1beta1.CommitRequest, $root.google.firestore.v1beta1.CommitResponse, request, callback); + }; + + /** + * 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 + */ + Firestore.prototype.rollback = function rollback(request, callback) { + return this.rpcCall(rollback, $root.google.firestore.v1beta1.RollbackRequest, $root.google.protobuf.Empty, request, callback); + }; + + /** + * 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 + */ + Firestore.prototype.runQuery = function runQuery(request, callback) { + return this.rpcCall(runQuery, $root.google.firestore.v1beta1.RunQueryRequest, $root.google.firestore.v1beta1.RunQueryResponse, request, callback); + }; + + /** + * 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 + */ + Firestore.prototype.write = function write(request, callback) { + return this.rpcCall(write, $root.google.firestore.v1beta1.WriteRequest, $root.google.firestore.v1beta1.WriteResponse, request, callback); + }; + + /** + * 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 + */ + Firestore.prototype.listen = function listen(request, callback) { + return this.rpcCall(listen, $root.google.firestore.v1beta1.ListenRequest, $root.google.firestore.v1beta1.ListenResponse, request, callback); + }; + + /** + * 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 + */ + Firestore.prototype.listCollectionIds = function listCollectionIds(request, callback) { + return this.rpcCall(listCollectionIds, $root.google.firestore.v1beta1.ListCollectionIdsRequest, $root.google.firestore.v1beta1.ListCollectionIdsResponse, request, callback); + }; + + /** + * 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) + }); + + /** + * Creates a new GetDocumentRequest instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.GetDocumentRequest + * @static + * @param {google.firestore.v1beta1.IGetDocumentRequest=} [properties] Properties to set + * @returns {google.firestore.v1beta1.GetDocumentRequest} GetDocumentRequest instance + */ + GetDocumentRequest.create = function create(properties) { + return new GetDocumentRequest(properties); + }; + + /** + * Encodes the specified GetDocumentRequest message. Does not implicitly {@link google.firestore.v1beta1.GetDocumentRequest.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.GetDocumentRequest + * @static + * @param {google.firestore.v1beta1.IGetDocumentRequest} message GetDocumentRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDocumentRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && message.hasOwnProperty("name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.mask != null && message.hasOwnProperty("mask")) + $root.google.firestore.v1beta1.DocumentMask.encode(message.mask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.transaction != null && message.hasOwnProperty("transaction")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.transaction); + if (message.readTime != null && message.hasOwnProperty("readTime")) + $root.google.protobuf.Timestamp.encode(message.readTime, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified GetDocumentRequest message, length delimited. Does not implicitly {@link google.firestore.v1beta1.GetDocumentRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.GetDocumentRequest + * @static + * @param {google.firestore.v1beta1.IGetDocumentRequest} message GetDocumentRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDocumentRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetDocumentRequest message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.GetDocumentRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.GetDocumentRequest} GetDocumentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDocumentRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.GetDocumentRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.mask = $root.google.firestore.v1beta1.DocumentMask.decode(reader, reader.uint32()); + break; + case 3: + message.transaction = reader.bytes(); + break; + case 5: + message.readTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetDocumentRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.GetDocumentRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.GetDocumentRequest} GetDocumentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDocumentRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetDocumentRequest message. + * @function verify + * @memberof google.firestore.v1beta1.GetDocumentRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetDocumentRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.mask != null && message.hasOwnProperty("mask")) { + var error = $root.google.firestore.v1beta1.DocumentMask.verify(message.mask); + if (error) + return "mask." + error; + } + if (message.transaction != null && message.hasOwnProperty("transaction")) { + properties.consistencySelector = 1; + if (!(message.transaction && typeof message.transaction.length === "number" || $util.isString(message.transaction))) + return "transaction: buffer expected"; + } + if (message.readTime != null && message.hasOwnProperty("readTime")) { + if (properties.consistencySelector === 1) + return "consistencySelector: multiple values"; + properties.consistencySelector = 1; + { + var error = $root.google.protobuf.Timestamp.verify(message.readTime); + if (error) + return "readTime." + error; + } + } + return null; + }; + + /** + * 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; + })(); + + 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) + }); + + /** + * Creates a new ListDocumentsRequest instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.ListDocumentsRequest + * @static + * @param {google.firestore.v1beta1.IListDocumentsRequest=} [properties] Properties to set + * @returns {google.firestore.v1beta1.ListDocumentsRequest} ListDocumentsRequest instance + */ + ListDocumentsRequest.create = function create(properties) { + return new ListDocumentsRequest(properties); + }; + + /** + * Encodes the specified ListDocumentsRequest message. Does not implicitly {@link google.firestore.v1beta1.ListDocumentsRequest.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.ListDocumentsRequest + * @static + * @param {google.firestore.v1beta1.IListDocumentsRequest} message ListDocumentsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListDocumentsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && message.hasOwnProperty("parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.collectionId != null && message.hasOwnProperty("collectionId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.collectionId); + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.pageSize); + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.pageToken); + if (message.orderBy != null && message.hasOwnProperty("orderBy")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.orderBy); + if (message.mask != null && message.hasOwnProperty("mask")) + $root.google.firestore.v1beta1.DocumentMask.encode(message.mask, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.transaction != null && message.hasOwnProperty("transaction")) + writer.uint32(/* id 8, wireType 2 =*/66).bytes(message.transaction); + if (message.readTime != null && message.hasOwnProperty("readTime")) + $root.google.protobuf.Timestamp.encode(message.readTime, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); + if (message.showMissing != null && message.hasOwnProperty("showMissing")) + writer.uint32(/* id 12, wireType 0 =*/96).bool(message.showMissing); + return writer; + }; + + /** + * Encodes the specified ListDocumentsRequest message, length delimited. Does not implicitly {@link google.firestore.v1beta1.ListDocumentsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.ListDocumentsRequest + * @static + * @param {google.firestore.v1beta1.IListDocumentsRequest} message ListDocumentsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListDocumentsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListDocumentsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.ListDocumentsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.ListDocumentsRequest} ListDocumentsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListDocumentsRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.ListDocumentsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.collectionId = reader.string(); + break; + case 3: + message.pageSize = reader.int32(); + break; + case 4: + message.pageToken = reader.string(); + break; + case 6: + message.orderBy = reader.string(); + break; + case 7: + message.mask = $root.google.firestore.v1beta1.DocumentMask.decode(reader, reader.uint32()); + break; + case 8: + message.transaction = reader.bytes(); + break; + case 10: + message.readTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + case 12: + message.showMissing = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListDocumentsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.ListDocumentsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.ListDocumentsRequest} ListDocumentsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListDocumentsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListDocumentsRequest message. + * @function verify + * @memberof google.firestore.v1beta1.ListDocumentsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListDocumentsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.collectionId != null && message.hasOwnProperty("collectionId")) + if (!$util.isString(message.collectionId)) + return "collectionId: string expected"; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + if (!$util.isInteger(message.pageSize)) + return "pageSize: integer expected"; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + if (!$util.isString(message.pageToken)) + return "pageToken: string expected"; + if (message.orderBy != null && message.hasOwnProperty("orderBy")) + if (!$util.isString(message.orderBy)) + return "orderBy: string expected"; + if (message.mask != null && message.hasOwnProperty("mask")) { + var error = $root.google.firestore.v1beta1.DocumentMask.verify(message.mask); + if (error) + return "mask." + error; + } + if (message.transaction != null && message.hasOwnProperty("transaction")) { + properties.consistencySelector = 1; + if (!(message.transaction && typeof message.transaction.length === "number" || $util.isString(message.transaction))) + return "transaction: buffer expected"; + } + if (message.readTime != null && message.hasOwnProperty("readTime")) { + if (properties.consistencySelector === 1) + return "consistencySelector: multiple values"; + properties.consistencySelector = 1; + { + var error = $root.google.protobuf.Timestamp.verify(message.readTime); + if (error) + return "readTime." + error; + } + } + if (message.showMissing != null && message.hasOwnProperty("showMissing")) + if (typeof message.showMissing !== "boolean") + return "showMissing: boolean expected"; + return null; + }; + + /** + * 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 + */ + 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; + })(); + + 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 new ListDocumentsResponse instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.ListDocumentsResponse + * @static + * @param {google.firestore.v1beta1.IListDocumentsResponse=} [properties] Properties to set + * @returns {google.firestore.v1beta1.ListDocumentsResponse} ListDocumentsResponse instance + */ + ListDocumentsResponse.create = function create(properties) { + return new ListDocumentsResponse(properties); + }; + + /** + * Encodes the specified ListDocumentsResponse message. Does not implicitly {@link google.firestore.v1beta1.ListDocumentsResponse.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.ListDocumentsResponse + * @static + * @param {google.firestore.v1beta1.IListDocumentsResponse} message ListDocumentsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListDocumentsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.documents != null && message.documents.length) + for (var i = 0; i < message.documents.length; ++i) + $root.google.firestore.v1beta1.Document.encode(message.documents[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.nextPageToken); + return writer; + }; + + /** + * Encodes the specified ListDocumentsResponse message, length delimited. Does not implicitly {@link google.firestore.v1beta1.ListDocumentsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.ListDocumentsResponse + * @static + * @param {google.firestore.v1beta1.IListDocumentsResponse} message ListDocumentsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListDocumentsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListDocumentsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.ListDocumentsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.ListDocumentsResponse} ListDocumentsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListDocumentsResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.ListDocumentsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.documents && message.documents.length)) + message.documents = []; + message.documents.push($root.google.firestore.v1beta1.Document.decode(reader, reader.uint32())); + break; + case 2: + message.nextPageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListDocumentsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.ListDocumentsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.ListDocumentsResponse} ListDocumentsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListDocumentsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListDocumentsResponse message. + * @function verify + * @memberof google.firestore.v1beta1.ListDocumentsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListDocumentsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.documents != null && message.hasOwnProperty("documents")) { + if (!Array.isArray(message.documents)) + return "documents: array expected"; + for (var i = 0; i < message.documents.length; ++i) { + var error = $root.google.firestore.v1beta1.Document.verify(message.documents[i]); + if (error) + return "documents." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * 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 new CreateDocumentRequest instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.CreateDocumentRequest + * @static + * @param {google.firestore.v1beta1.ICreateDocumentRequest=} [properties] Properties to set + * @returns {google.firestore.v1beta1.CreateDocumentRequest} CreateDocumentRequest instance + */ + CreateDocumentRequest.create = function create(properties) { + return new CreateDocumentRequest(properties); + }; + + /** + * Encodes the specified CreateDocumentRequest message. Does not implicitly {@link google.firestore.v1beta1.CreateDocumentRequest.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.CreateDocumentRequest + * @static + * @param {google.firestore.v1beta1.ICreateDocumentRequest} message CreateDocumentRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateDocumentRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && message.hasOwnProperty("parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.collectionId != null && message.hasOwnProperty("collectionId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.collectionId); + if (message.documentId != null && message.hasOwnProperty("documentId")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.documentId); + if (message.document != null && message.hasOwnProperty("document")) + $root.google.firestore.v1beta1.Document.encode(message.document, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.mask != null && message.hasOwnProperty("mask")) + $root.google.firestore.v1beta1.DocumentMask.encode(message.mask, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified CreateDocumentRequest message, length delimited. Does not implicitly {@link google.firestore.v1beta1.CreateDocumentRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.CreateDocumentRequest + * @static + * @param {google.firestore.v1beta1.ICreateDocumentRequest} message CreateDocumentRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateDocumentRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateDocumentRequest message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.CreateDocumentRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.CreateDocumentRequest} CreateDocumentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateDocumentRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.CreateDocumentRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.collectionId = reader.string(); + break; + case 3: + message.documentId = reader.string(); + break; + case 4: + message.document = $root.google.firestore.v1beta1.Document.decode(reader, reader.uint32()); + break; + case 5: + message.mask = $root.google.firestore.v1beta1.DocumentMask.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateDocumentRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.CreateDocumentRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.CreateDocumentRequest} CreateDocumentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateDocumentRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateDocumentRequest message. + * @function verify + * @memberof google.firestore.v1beta1.CreateDocumentRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateDocumentRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.collectionId != null && message.hasOwnProperty("collectionId")) + if (!$util.isString(message.collectionId)) + return "collectionId: string expected"; + if (message.documentId != null && message.hasOwnProperty("documentId")) + if (!$util.isString(message.documentId)) + return "documentId: string expected"; + if (message.document != null && message.hasOwnProperty("document")) { + var error = $root.google.firestore.v1beta1.Document.verify(message.document); + if (error) + return "document." + error; + } + if (message.mask != null && message.hasOwnProperty("mask")) { + var error = $root.google.firestore.v1beta1.DocumentMask.verify(message.mask); + if (error) + return "mask." + error; + } + return 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 a new UpdateDocumentRequest instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.UpdateDocumentRequest + * @static + * @param {google.firestore.v1beta1.IUpdateDocumentRequest=} [properties] Properties to set + * @returns {google.firestore.v1beta1.UpdateDocumentRequest} UpdateDocumentRequest instance + */ + UpdateDocumentRequest.create = function create(properties) { + return new UpdateDocumentRequest(properties); + }; + + /** + * Encodes the specified UpdateDocumentRequest message. Does not implicitly {@link google.firestore.v1beta1.UpdateDocumentRequest.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.UpdateDocumentRequest + * @static + * @param {google.firestore.v1beta1.IUpdateDocumentRequest} message UpdateDocumentRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateDocumentRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.document != null && message.hasOwnProperty("document")) + $root.google.firestore.v1beta1.Document.encode(message.document, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + $root.google.firestore.v1beta1.DocumentMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.mask != null && message.hasOwnProperty("mask")) + $root.google.firestore.v1beta1.DocumentMask.encode(message.mask, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.currentDocument != null && message.hasOwnProperty("currentDocument")) + $root.google.firestore.v1beta1.Precondition.encode(message.currentDocument, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UpdateDocumentRequest message, length delimited. Does not implicitly {@link google.firestore.v1beta1.UpdateDocumentRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.UpdateDocumentRequest + * @static + * @param {google.firestore.v1beta1.IUpdateDocumentRequest} message UpdateDocumentRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateDocumentRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateDocumentRequest message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.UpdateDocumentRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.UpdateDocumentRequest} UpdateDocumentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateDocumentRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.UpdateDocumentRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.document = $root.google.firestore.v1beta1.Document.decode(reader, reader.uint32()); + break; + case 2: + message.updateMask = $root.google.firestore.v1beta1.DocumentMask.decode(reader, reader.uint32()); + break; + case 3: + message.mask = $root.google.firestore.v1beta1.DocumentMask.decode(reader, reader.uint32()); + break; + case 4: + message.currentDocument = $root.google.firestore.v1beta1.Precondition.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateDocumentRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.UpdateDocumentRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.UpdateDocumentRequest} UpdateDocumentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateDocumentRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateDocumentRequest message. + * @function verify + * @memberof google.firestore.v1beta1.UpdateDocumentRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateDocumentRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.document != null && message.hasOwnProperty("document")) { + var error = $root.google.firestore.v1beta1.Document.verify(message.document); + if (error) + return "document." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.firestore.v1beta1.DocumentMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + if (message.mask != null && message.hasOwnProperty("mask")) { + var error = $root.google.firestore.v1beta1.DocumentMask.verify(message.mask); + if (error) + return "mask." + error; + } + if (message.currentDocument != null && message.hasOwnProperty("currentDocument")) { + var error = $root.google.firestore.v1beta1.Precondition.verify(message.currentDocument); + if (error) + return "currentDocument." + error; + } + return 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 new DeleteDocumentRequest instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.DeleteDocumentRequest + * @static + * @param {google.firestore.v1beta1.IDeleteDocumentRequest=} [properties] Properties to set + * @returns {google.firestore.v1beta1.DeleteDocumentRequest} DeleteDocumentRequest instance + */ + DeleteDocumentRequest.create = function create(properties) { + return new DeleteDocumentRequest(properties); + }; + + /** + * Encodes the specified DeleteDocumentRequest message. Does not implicitly {@link google.firestore.v1beta1.DeleteDocumentRequest.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.DeleteDocumentRequest + * @static + * @param {google.firestore.v1beta1.IDeleteDocumentRequest} message DeleteDocumentRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteDocumentRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && message.hasOwnProperty("name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.currentDocument != null && message.hasOwnProperty("currentDocument")) + $root.google.firestore.v1beta1.Precondition.encode(message.currentDocument, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified DeleteDocumentRequest message, length delimited. Does not implicitly {@link google.firestore.v1beta1.DeleteDocumentRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.DeleteDocumentRequest + * @static + * @param {google.firestore.v1beta1.IDeleteDocumentRequest} message DeleteDocumentRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteDocumentRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteDocumentRequest message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.DeleteDocumentRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.DeleteDocumentRequest} DeleteDocumentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteDocumentRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.DeleteDocumentRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.currentDocument = $root.google.firestore.v1beta1.Precondition.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DeleteDocumentRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.DeleteDocumentRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.DeleteDocumentRequest} DeleteDocumentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteDocumentRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteDocumentRequest message. + * @function verify + * @memberof google.firestore.v1beta1.DeleteDocumentRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteDocumentRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.currentDocument != null && message.hasOwnProperty("currentDocument")) { + var error = $root.google.firestore.v1beta1.Precondition.verify(message.currentDocument); + if (error) + return "currentDocument." + error; + } + return 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 new BatchGetDocumentsRequest instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest + * @static + * @param {google.firestore.v1beta1.IBatchGetDocumentsRequest=} [properties] Properties to set + * @returns {google.firestore.v1beta1.BatchGetDocumentsRequest} BatchGetDocumentsRequest instance + */ + BatchGetDocumentsRequest.create = function create(properties) { + return new BatchGetDocumentsRequest(properties); + }; + + /** + * Encodes the specified BatchGetDocumentsRequest message. Does not implicitly {@link google.firestore.v1beta1.BatchGetDocumentsRequest.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest + * @static + * @param {google.firestore.v1beta1.IBatchGetDocumentsRequest} message BatchGetDocumentsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BatchGetDocumentsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.database != null && message.hasOwnProperty("database")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.database); + if (message.documents != null && message.documents.length) + for (var i = 0; i < message.documents.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.documents[i]); + if (message.mask != null && message.hasOwnProperty("mask")) + $root.google.firestore.v1beta1.DocumentMask.encode(message.mask, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.transaction != null && message.hasOwnProperty("transaction")) + writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.transaction); + if (message.newTransaction != null && message.hasOwnProperty("newTransaction")) + $root.google.firestore.v1beta1.TransactionOptions.encode(message.newTransaction, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.readTime != null && message.hasOwnProperty("readTime")) + $root.google.protobuf.Timestamp.encode(message.readTime, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified BatchGetDocumentsRequest message, length delimited. Does not implicitly {@link google.firestore.v1beta1.BatchGetDocumentsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest + * @static + * @param {google.firestore.v1beta1.IBatchGetDocumentsRequest} message BatchGetDocumentsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BatchGetDocumentsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BatchGetDocumentsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.BatchGetDocumentsRequest} BatchGetDocumentsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BatchGetDocumentsRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.BatchGetDocumentsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.database = reader.string(); + break; + case 2: + if (!(message.documents && message.documents.length)) + message.documents = []; + message.documents.push(reader.string()); + break; + case 3: + message.mask = $root.google.firestore.v1beta1.DocumentMask.decode(reader, reader.uint32()); + break; + case 4: + message.transaction = reader.bytes(); + break; + case 5: + message.newTransaction = $root.google.firestore.v1beta1.TransactionOptions.decode(reader, reader.uint32()); + break; + case 7: + message.readTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BatchGetDocumentsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.BatchGetDocumentsRequest} BatchGetDocumentsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BatchGetDocumentsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BatchGetDocumentsRequest message. + * @function verify + * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BatchGetDocumentsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.database != null && message.hasOwnProperty("database")) + if (!$util.isString(message.database)) + return "database: string expected"; + if (message.documents != null && message.hasOwnProperty("documents")) { + if (!Array.isArray(message.documents)) + return "documents: array expected"; + for (var i = 0; i < message.documents.length; ++i) + if (!$util.isString(message.documents[i])) + return "documents: string[] expected"; + } + if (message.mask != null && message.hasOwnProperty("mask")) { + var error = $root.google.firestore.v1beta1.DocumentMask.verify(message.mask); + if (error) + return "mask." + error; + } + if (message.transaction != null && message.hasOwnProperty("transaction")) { + properties.consistencySelector = 1; + if (!(message.transaction && typeof message.transaction.length === "number" || $util.isString(message.transaction))) + return "transaction: buffer expected"; + } + if (message.newTransaction != null && message.hasOwnProperty("newTransaction")) { + if (properties.consistencySelector === 1) + return "consistencySelector: multiple values"; + properties.consistencySelector = 1; + { + var error = $root.google.firestore.v1beta1.TransactionOptions.verify(message.newTransaction); + if (error) + return "newTransaction." + error; + } + } + if (message.readTime != null && message.hasOwnProperty("readTime")) { + if (properties.consistencySelector === 1) + return "consistencySelector: multiple values"; + properties.consistencySelector = 1; + { + var error = $root.google.protobuf.Timestamp.verify(message.readTime); + if (error) + return "readTime." + error; + } + } + return null; + }; + + /** + * 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 new BatchGetDocumentsResponse instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.BatchGetDocumentsResponse + * @static + * @param {google.firestore.v1beta1.IBatchGetDocumentsResponse=} [properties] Properties to set + * @returns {google.firestore.v1beta1.BatchGetDocumentsResponse} BatchGetDocumentsResponse instance + */ + BatchGetDocumentsResponse.create = function create(properties) { + return new BatchGetDocumentsResponse(properties); + }; + + /** + * Encodes the specified BatchGetDocumentsResponse message. Does not implicitly {@link google.firestore.v1beta1.BatchGetDocumentsResponse.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.BatchGetDocumentsResponse + * @static + * @param {google.firestore.v1beta1.IBatchGetDocumentsResponse} message BatchGetDocumentsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BatchGetDocumentsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.found != null && message.hasOwnProperty("found")) + $root.google.firestore.v1beta1.Document.encode(message.found, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.missing != null && message.hasOwnProperty("missing")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.missing); + if (message.transaction != null && message.hasOwnProperty("transaction")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.transaction); + if (message.readTime != null && message.hasOwnProperty("readTime")) + $root.google.protobuf.Timestamp.encode(message.readTime, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified BatchGetDocumentsResponse message, length delimited. Does not implicitly {@link google.firestore.v1beta1.BatchGetDocumentsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.BatchGetDocumentsResponse + * @static + * @param {google.firestore.v1beta1.IBatchGetDocumentsResponse} message BatchGetDocumentsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BatchGetDocumentsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BatchGetDocumentsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.BatchGetDocumentsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.BatchGetDocumentsResponse} BatchGetDocumentsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BatchGetDocumentsResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.BatchGetDocumentsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.found = $root.google.firestore.v1beta1.Document.decode(reader, reader.uint32()); + break; + case 2: + message.missing = reader.string(); + break; + case 3: + message.transaction = reader.bytes(); + break; + case 4: + message.readTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BatchGetDocumentsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.BatchGetDocumentsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.BatchGetDocumentsResponse} BatchGetDocumentsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BatchGetDocumentsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BatchGetDocumentsResponse message. + * @function verify + * @memberof google.firestore.v1beta1.BatchGetDocumentsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BatchGetDocumentsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.found != null && message.hasOwnProperty("found")) { + properties.result = 1; + { + var error = $root.google.firestore.v1beta1.Document.verify(message.found); + if (error) + return "found." + error; + } + } + if (message.missing != null && message.hasOwnProperty("missing")) { + if (properties.result === 1) + return "result: multiple values"; + properties.result = 1; + if (!$util.isString(message.missing)) + return "missing: string expected"; + } + if (message.transaction != null && message.hasOwnProperty("transaction")) + if (!(message.transaction && typeof message.transaction.length === "number" || $util.isString(message.transaction))) + return "transaction: buffer expected"; + if (message.readTime != null && message.hasOwnProperty("readTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.readTime); + if (error) + return "readTime." + error; + } + return null; + }; + + /** + * 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) { + object.transaction = options.bytes === String ? "" : []; + 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 new BeginTransactionRequest instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.BeginTransactionRequest + * @static + * @param {google.firestore.v1beta1.IBeginTransactionRequest=} [properties] Properties to set + * @returns {google.firestore.v1beta1.BeginTransactionRequest} BeginTransactionRequest instance + */ + BeginTransactionRequest.create = function create(properties) { + return new BeginTransactionRequest(properties); + }; + + /** + * Encodes the specified BeginTransactionRequest message. Does not implicitly {@link google.firestore.v1beta1.BeginTransactionRequest.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.BeginTransactionRequest + * @static + * @param {google.firestore.v1beta1.IBeginTransactionRequest} message BeginTransactionRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BeginTransactionRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.database != null && message.hasOwnProperty("database")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.database); + if (message.options != null && message.hasOwnProperty("options")) + $root.google.firestore.v1beta1.TransactionOptions.encode(message.options, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified BeginTransactionRequest message, length delimited. Does not implicitly {@link google.firestore.v1beta1.BeginTransactionRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.BeginTransactionRequest + * @static + * @param {google.firestore.v1beta1.IBeginTransactionRequest} message BeginTransactionRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BeginTransactionRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BeginTransactionRequest message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.BeginTransactionRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.BeginTransactionRequest} BeginTransactionRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BeginTransactionRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.BeginTransactionRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.database = reader.string(); + break; + case 2: + message.options = $root.google.firestore.v1beta1.TransactionOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BeginTransactionRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.BeginTransactionRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.BeginTransactionRequest} BeginTransactionRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BeginTransactionRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BeginTransactionRequest message. + * @function verify + * @memberof google.firestore.v1beta1.BeginTransactionRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BeginTransactionRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.database != null && message.hasOwnProperty("database")) + if (!$util.isString(message.database)) + return "database: string expected"; + if (message.options != null && message.hasOwnProperty("options")) { + var error = $root.google.firestore.v1beta1.TransactionOptions.verify(message.options); + if (error) + return "options." + error; + } + return 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 new BeginTransactionResponse instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.BeginTransactionResponse + * @static + * @param {google.firestore.v1beta1.IBeginTransactionResponse=} [properties] Properties to set + * @returns {google.firestore.v1beta1.BeginTransactionResponse} BeginTransactionResponse instance + */ + BeginTransactionResponse.create = function create(properties) { + return new BeginTransactionResponse(properties); + }; + + /** + * Encodes the specified BeginTransactionResponse message. Does not implicitly {@link google.firestore.v1beta1.BeginTransactionResponse.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.BeginTransactionResponse + * @static + * @param {google.firestore.v1beta1.IBeginTransactionResponse} message BeginTransactionResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BeginTransactionResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.transaction != null && message.hasOwnProperty("transaction")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.transaction); + return writer; + }; + + /** + * Encodes the specified BeginTransactionResponse message, length delimited. Does not implicitly {@link google.firestore.v1beta1.BeginTransactionResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.BeginTransactionResponse + * @static + * @param {google.firestore.v1beta1.IBeginTransactionResponse} message BeginTransactionResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BeginTransactionResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BeginTransactionResponse message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.BeginTransactionResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.BeginTransactionResponse} BeginTransactionResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BeginTransactionResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.BeginTransactionResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.transaction = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BeginTransactionResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.BeginTransactionResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.BeginTransactionResponse} BeginTransactionResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BeginTransactionResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BeginTransactionResponse message. + * @function verify + * @memberof google.firestore.v1beta1.BeginTransactionResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BeginTransactionResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.transaction != null && message.hasOwnProperty("transaction")) + if (!(message.transaction && typeof message.transaction.length === "number" || $util.isString(message.transaction))) + return "transaction: buffer expected"; + return null; + }; + + /** + * 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) + object.transaction = options.bytes === String ? "" : []; + 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 new CommitRequest instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.CommitRequest + * @static + * @param {google.firestore.v1beta1.ICommitRequest=} [properties] Properties to set + * @returns {google.firestore.v1beta1.CommitRequest} CommitRequest instance + */ + CommitRequest.create = function create(properties) { + return new CommitRequest(properties); + }; + + /** + * Encodes the specified CommitRequest message. Does not implicitly {@link google.firestore.v1beta1.CommitRequest.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.CommitRequest + * @static + * @param {google.firestore.v1beta1.ICommitRequest} message CommitRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CommitRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.database != null && message.hasOwnProperty("database")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.database); + if (message.writes != null && message.writes.length) + for (var i = 0; i < message.writes.length; ++i) + $root.google.firestore.v1beta1.Write.encode(message.writes[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.transaction != null && message.hasOwnProperty("transaction")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.transaction); + return writer; + }; + + /** + * Encodes the specified CommitRequest message, length delimited. Does not implicitly {@link google.firestore.v1beta1.CommitRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.CommitRequest + * @static + * @param {google.firestore.v1beta1.ICommitRequest} message CommitRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CommitRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CommitRequest message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.CommitRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.CommitRequest} CommitRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CommitRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.CommitRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.database = reader.string(); + break; + case 2: + if (!(message.writes && message.writes.length)) + message.writes = []; + message.writes.push($root.google.firestore.v1beta1.Write.decode(reader, reader.uint32())); + break; + case 3: + message.transaction = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CommitRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.CommitRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.CommitRequest} CommitRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CommitRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CommitRequest message. + * @function verify + * @memberof google.firestore.v1beta1.CommitRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CommitRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.database != null && message.hasOwnProperty("database")) + if (!$util.isString(message.database)) + return "database: string expected"; + if (message.writes != null && message.hasOwnProperty("writes")) { + if (!Array.isArray(message.writes)) + return "writes: array expected"; + for (var i = 0; i < message.writes.length; ++i) { + var error = $root.google.firestore.v1beta1.Write.verify(message.writes[i]); + if (error) + return "writes." + error; + } + } + if (message.transaction != null && message.hasOwnProperty("transaction")) + if (!(message.transaction && typeof message.transaction.length === "number" || $util.isString(message.transaction))) + return "transaction: buffer expected"; + return null; + }; + + /** + * 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 = ""; + object.transaction = options.bytes === String ? "" : []; + } + 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 new CommitResponse instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.CommitResponse + * @static + * @param {google.firestore.v1beta1.ICommitResponse=} [properties] Properties to set + * @returns {google.firestore.v1beta1.CommitResponse} CommitResponse instance + */ + CommitResponse.create = function create(properties) { + return new CommitResponse(properties); + }; + + /** + * Encodes the specified CommitResponse message. Does not implicitly {@link google.firestore.v1beta1.CommitResponse.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.CommitResponse + * @static + * @param {google.firestore.v1beta1.ICommitResponse} message CommitResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CommitResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.writeResults != null && message.writeResults.length) + for (var i = 0; i < message.writeResults.length; ++i) + $root.google.firestore.v1beta1.WriteResult.encode(message.writeResults[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.commitTime != null && message.hasOwnProperty("commitTime")) + $root.google.protobuf.Timestamp.encode(message.commitTime, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified CommitResponse message, length delimited. Does not implicitly {@link google.firestore.v1beta1.CommitResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.CommitResponse + * @static + * @param {google.firestore.v1beta1.ICommitResponse} message CommitResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CommitResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CommitResponse message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.CommitResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.CommitResponse} CommitResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CommitResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.CommitResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.writeResults && message.writeResults.length)) + message.writeResults = []; + message.writeResults.push($root.google.firestore.v1beta1.WriteResult.decode(reader, reader.uint32())); + break; + case 2: + message.commitTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CommitResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.CommitResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.CommitResponse} CommitResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CommitResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CommitResponse message. + * @function verify + * @memberof google.firestore.v1beta1.CommitResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CommitResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.writeResults != null && message.hasOwnProperty("writeResults")) { + if (!Array.isArray(message.writeResults)) + return "writeResults: array expected"; + for (var i = 0; i < message.writeResults.length; ++i) { + var error = $root.google.firestore.v1beta1.WriteResult.verify(message.writeResults[i]); + if (error) + return "writeResults." + error; + } + } + if (message.commitTime != null && message.hasOwnProperty("commitTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.commitTime); + if (error) + return "commitTime." + error; + } + return 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 new RollbackRequest instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.RollbackRequest + * @static + * @param {google.firestore.v1beta1.IRollbackRequest=} [properties] Properties to set + * @returns {google.firestore.v1beta1.RollbackRequest} RollbackRequest instance + */ + RollbackRequest.create = function create(properties) { + return new RollbackRequest(properties); + }; + + /** + * Encodes the specified RollbackRequest message. Does not implicitly {@link google.firestore.v1beta1.RollbackRequest.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.RollbackRequest + * @static + * @param {google.firestore.v1beta1.IRollbackRequest} message RollbackRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RollbackRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.database != null && message.hasOwnProperty("database")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.database); + if (message.transaction != null && message.hasOwnProperty("transaction")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.transaction); + return writer; + }; + + /** + * Encodes the specified RollbackRequest message, length delimited. Does not implicitly {@link google.firestore.v1beta1.RollbackRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.RollbackRequest + * @static + * @param {google.firestore.v1beta1.IRollbackRequest} message RollbackRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RollbackRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RollbackRequest message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.RollbackRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.RollbackRequest} RollbackRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RollbackRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.RollbackRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.database = reader.string(); + break; + case 2: + message.transaction = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RollbackRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.RollbackRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.RollbackRequest} RollbackRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RollbackRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RollbackRequest message. + * @function verify + * @memberof google.firestore.v1beta1.RollbackRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RollbackRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.database != null && message.hasOwnProperty("database")) + if (!$util.isString(message.database)) + return "database: string expected"; + if (message.transaction != null && message.hasOwnProperty("transaction")) + if (!(message.transaction && typeof message.transaction.length === "number" || $util.isString(message.transaction))) + return "transaction: buffer expected"; + return null; + }; + + /** + * 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 = ""; + object.transaction = options.bytes === String ? "" : []; + } + 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 new RunQueryRequest instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.RunQueryRequest + * @static + * @param {google.firestore.v1beta1.IRunQueryRequest=} [properties] Properties to set + * @returns {google.firestore.v1beta1.RunQueryRequest} RunQueryRequest instance + */ + RunQueryRequest.create = function create(properties) { + return new RunQueryRequest(properties); + }; + + /** + * Encodes the specified RunQueryRequest message. Does not implicitly {@link google.firestore.v1beta1.RunQueryRequest.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.RunQueryRequest + * @static + * @param {google.firestore.v1beta1.IRunQueryRequest} message RunQueryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RunQueryRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && message.hasOwnProperty("parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.structuredQuery != null && message.hasOwnProperty("structuredQuery")) + $root.google.firestore.v1beta1.StructuredQuery.encode(message.structuredQuery, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.transaction != null && message.hasOwnProperty("transaction")) + writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.transaction); + if (message.newTransaction != null && message.hasOwnProperty("newTransaction")) + $root.google.firestore.v1beta1.TransactionOptions.encode(message.newTransaction, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.readTime != null && message.hasOwnProperty("readTime")) + $root.google.protobuf.Timestamp.encode(message.readTime, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified RunQueryRequest message, length delimited. Does not implicitly {@link google.firestore.v1beta1.RunQueryRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.RunQueryRequest + * @static + * @param {google.firestore.v1beta1.IRunQueryRequest} message RunQueryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RunQueryRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RunQueryRequest message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.RunQueryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.RunQueryRequest} RunQueryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RunQueryRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.RunQueryRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.structuredQuery = $root.google.firestore.v1beta1.StructuredQuery.decode(reader, reader.uint32()); + break; + case 5: + message.transaction = reader.bytes(); + break; + case 6: + message.newTransaction = $root.google.firestore.v1beta1.TransactionOptions.decode(reader, reader.uint32()); + break; + case 7: + message.readTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RunQueryRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.RunQueryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.RunQueryRequest} RunQueryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RunQueryRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RunQueryRequest message. + * @function verify + * @memberof google.firestore.v1beta1.RunQueryRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RunQueryRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.structuredQuery != null && message.hasOwnProperty("structuredQuery")) { + properties.queryType = 1; + { + var error = $root.google.firestore.v1beta1.StructuredQuery.verify(message.structuredQuery); + if (error) + return "structuredQuery." + error; + } + } + if (message.transaction != null && message.hasOwnProperty("transaction")) { + properties.consistencySelector = 1; + if (!(message.transaction && typeof message.transaction.length === "number" || $util.isString(message.transaction))) + return "transaction: buffer expected"; + } + if (message.newTransaction != null && message.hasOwnProperty("newTransaction")) { + if (properties.consistencySelector === 1) + return "consistencySelector: multiple values"; + properties.consistencySelector = 1; + { + var error = $root.google.firestore.v1beta1.TransactionOptions.verify(message.newTransaction); + if (error) + return "newTransaction." + error; + } + } + if (message.readTime != null && message.hasOwnProperty("readTime")) { + if (properties.consistencySelector === 1) + return "consistencySelector: multiple values"; + properties.consistencySelector = 1; + { + var error = $root.google.protobuf.Timestamp.verify(message.readTime); + if (error) + return "readTime." + error; + } + } + return null; + }; + + /** + * 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 new RunQueryResponse instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.RunQueryResponse + * @static + * @param {google.firestore.v1beta1.IRunQueryResponse=} [properties] Properties to set + * @returns {google.firestore.v1beta1.RunQueryResponse} RunQueryResponse instance + */ + RunQueryResponse.create = function create(properties) { + return new RunQueryResponse(properties); + }; + + /** + * Encodes the specified RunQueryResponse message. Does not implicitly {@link google.firestore.v1beta1.RunQueryResponse.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.RunQueryResponse + * @static + * @param {google.firestore.v1beta1.IRunQueryResponse} message RunQueryResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RunQueryResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.document != null && message.hasOwnProperty("document")) + $root.google.firestore.v1beta1.Document.encode(message.document, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.transaction != null && message.hasOwnProperty("transaction")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.transaction); + if (message.readTime != null && message.hasOwnProperty("readTime")) + $root.google.protobuf.Timestamp.encode(message.readTime, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.skippedResults != null && message.hasOwnProperty("skippedResults")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.skippedResults); + return writer; + }; + + /** + * Encodes the specified RunQueryResponse message, length delimited. Does not implicitly {@link google.firestore.v1beta1.RunQueryResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.RunQueryResponse + * @static + * @param {google.firestore.v1beta1.IRunQueryResponse} message RunQueryResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RunQueryResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RunQueryResponse message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.RunQueryResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.RunQueryResponse} RunQueryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RunQueryResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.RunQueryResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.transaction = reader.bytes(); + break; + case 1: + message.document = $root.google.firestore.v1beta1.Document.decode(reader, reader.uint32()); + break; + case 3: + message.readTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + case 4: + message.skippedResults = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RunQueryResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.RunQueryResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.RunQueryResponse} RunQueryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RunQueryResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RunQueryResponse message. + * @function verify + * @memberof google.firestore.v1beta1.RunQueryResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RunQueryResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.transaction != null && message.hasOwnProperty("transaction")) + if (!(message.transaction && typeof message.transaction.length === "number" || $util.isString(message.transaction))) + return "transaction: buffer expected"; + if (message.document != null && message.hasOwnProperty("document")) { + var error = $root.google.firestore.v1beta1.Document.verify(message.document); + if (error) + return "document." + error; + } + if (message.readTime != null && message.hasOwnProperty("readTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.readTime); + if (error) + return "readTime." + error; + } + if (message.skippedResults != null && message.hasOwnProperty("skippedResults")) + if (!$util.isInteger(message.skippedResults)) + return "skippedResults: integer expected"; + return null; + }; + + /** + * 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; + object.transaction = options.bytes === String ? "" : []; + 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 new WriteRequest instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.WriteRequest + * @static + * @param {google.firestore.v1beta1.IWriteRequest=} [properties] Properties to set + * @returns {google.firestore.v1beta1.WriteRequest} WriteRequest instance + */ + WriteRequest.create = function create(properties) { + return new WriteRequest(properties); + }; + + /** + * Encodes the specified WriteRequest message. Does not implicitly {@link google.firestore.v1beta1.WriteRequest.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.WriteRequest + * @static + * @param {google.firestore.v1beta1.IWriteRequest} message WriteRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WriteRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.database != null && message.hasOwnProperty("database")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.database); + if (message.streamId != null && message.hasOwnProperty("streamId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.streamId); + if (message.writes != null && message.writes.length) + for (var i = 0; i < message.writes.length; ++i) + $root.google.firestore.v1beta1.Write.encode(message.writes[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.streamToken != null && message.hasOwnProperty("streamToken")) + writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.streamToken); + if (message.labels != null && message.hasOwnProperty("labels")) + for (var keys = Object.keys(message.labels), i = 0; i < keys.length; ++i) + writer.uint32(/* id 5, wireType 2 =*/42).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.labels[keys[i]]).ldelim(); + return writer; + }; + + /** + * Encodes the specified WriteRequest message, length delimited. Does not implicitly {@link google.firestore.v1beta1.WriteRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.WriteRequest + * @static + * @param {google.firestore.v1beta1.IWriteRequest} message WriteRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WriteRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a WriteRequest message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.WriteRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.WriteRequest} WriteRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WriteRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.WriteRequest(), key; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.database = reader.string(); + break; + case 2: + message.streamId = reader.string(); + break; + case 3: + if (!(message.writes && message.writes.length)) + message.writes = []; + message.writes.push($root.google.firestore.v1beta1.Write.decode(reader, reader.uint32())); + break; + case 4: + message.streamToken = reader.bytes(); + break; + case 5: + reader.skip().pos++; + if (message.labels === $util.emptyObject) + message.labels = {}; + key = reader.string(); + reader.pos++; + message.labels[key] = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a WriteRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.WriteRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.WriteRequest} WriteRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WriteRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a WriteRequest message. + * @function verify + * @memberof google.firestore.v1beta1.WriteRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + WriteRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.database != null && message.hasOwnProperty("database")) + if (!$util.isString(message.database)) + return "database: string expected"; + if (message.streamId != null && message.hasOwnProperty("streamId")) + if (!$util.isString(message.streamId)) + return "streamId: string expected"; + if (message.writes != null && message.hasOwnProperty("writes")) { + if (!Array.isArray(message.writes)) + return "writes: array expected"; + for (var i = 0; i < message.writes.length; ++i) { + var error = $root.google.firestore.v1beta1.Write.verify(message.writes[i]); + if (error) + return "writes." + error; + } + } + if (message.streamToken != null && message.hasOwnProperty("streamToken")) + if (!(message.streamToken && typeof message.streamToken.length === "number" || $util.isString(message.streamToken))) + return "streamToken: buffer expected"; + if (message.labels != null && message.hasOwnProperty("labels")) { + if (!$util.isObject(message.labels)) + return "labels: object expected"; + var key = Object.keys(message.labels); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.labels[key[i]])) + return "labels: string{k:string} expected"; + } + return null; + }; + + /** + * 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 = ""; + object.streamToken = options.bytes === String ? "" : []; + } + 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 new WriteResponse instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.WriteResponse + * @static + * @param {google.firestore.v1beta1.IWriteResponse=} [properties] Properties to set + * @returns {google.firestore.v1beta1.WriteResponse} WriteResponse instance + */ + WriteResponse.create = function create(properties) { + return new WriteResponse(properties); + }; + + /** + * Encodes the specified WriteResponse message. Does not implicitly {@link google.firestore.v1beta1.WriteResponse.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.WriteResponse + * @static + * @param {google.firestore.v1beta1.IWriteResponse} message WriteResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WriteResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.streamId != null && message.hasOwnProperty("streamId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.streamId); + if (message.streamToken != null && message.hasOwnProperty("streamToken")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.streamToken); + if (message.writeResults != null && message.writeResults.length) + for (var i = 0; i < message.writeResults.length; ++i) + $root.google.firestore.v1beta1.WriteResult.encode(message.writeResults[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.commitTime != null && message.hasOwnProperty("commitTime")) + $root.google.protobuf.Timestamp.encode(message.commitTime, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified WriteResponse message, length delimited. Does not implicitly {@link google.firestore.v1beta1.WriteResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.WriteResponse + * @static + * @param {google.firestore.v1beta1.IWriteResponse} message WriteResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WriteResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a WriteResponse message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.WriteResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.WriteResponse} WriteResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WriteResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.WriteResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.streamId = reader.string(); + break; + case 2: + message.streamToken = reader.bytes(); + break; + case 3: + if (!(message.writeResults && message.writeResults.length)) + message.writeResults = []; + message.writeResults.push($root.google.firestore.v1beta1.WriteResult.decode(reader, reader.uint32())); + break; + case 4: + message.commitTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a WriteResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.WriteResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.WriteResponse} WriteResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WriteResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a WriteResponse message. + * @function verify + * @memberof google.firestore.v1beta1.WriteResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + WriteResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.streamId != null && message.hasOwnProperty("streamId")) + if (!$util.isString(message.streamId)) + return "streamId: string expected"; + if (message.streamToken != null && message.hasOwnProperty("streamToken")) + if (!(message.streamToken && typeof message.streamToken.length === "number" || $util.isString(message.streamToken))) + return "streamToken: buffer expected"; + if (message.writeResults != null && message.hasOwnProperty("writeResults")) { + if (!Array.isArray(message.writeResults)) + return "writeResults: array expected"; + for (var i = 0; i < message.writeResults.length; ++i) { + var error = $root.google.firestore.v1beta1.WriteResult.verify(message.writeResults[i]); + if (error) + return "writeResults." + error; + } + } + if (message.commitTime != null && message.hasOwnProperty("commitTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.commitTime); + if (error) + return "commitTime." + error; + } + return 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 = ""; + object.streamToken = options.bytes === String ? "" : []; + 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 new ListenRequest instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.ListenRequest + * @static + * @param {google.firestore.v1beta1.IListenRequest=} [properties] Properties to set + * @returns {google.firestore.v1beta1.ListenRequest} ListenRequest instance + */ + ListenRequest.create = function create(properties) { + return new ListenRequest(properties); + }; + + /** + * Encodes the specified ListenRequest message. Does not implicitly {@link google.firestore.v1beta1.ListenRequest.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.ListenRequest + * @static + * @param {google.firestore.v1beta1.IListenRequest} message ListenRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListenRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.database != null && message.hasOwnProperty("database")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.database); + if (message.addTarget != null && message.hasOwnProperty("addTarget")) + $root.google.firestore.v1beta1.Target.encode(message.addTarget, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.removeTarget != null && message.hasOwnProperty("removeTarget")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.removeTarget); + if (message.labels != null && message.hasOwnProperty("labels")) + for (var keys = Object.keys(message.labels), i = 0; i < keys.length; ++i) + writer.uint32(/* id 4, wireType 2 =*/34).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.labels[keys[i]]).ldelim(); + return writer; + }; + + /** + * Encodes the specified ListenRequest message, length delimited. Does not implicitly {@link google.firestore.v1beta1.ListenRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.ListenRequest + * @static + * @param {google.firestore.v1beta1.IListenRequest} message ListenRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListenRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListenRequest message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.ListenRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.ListenRequest} ListenRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListenRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.ListenRequest(), key; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.database = reader.string(); + break; + case 2: + message.addTarget = $root.google.firestore.v1beta1.Target.decode(reader, reader.uint32()); + break; + case 3: + message.removeTarget = reader.int32(); + break; + case 4: + reader.skip().pos++; + if (message.labels === $util.emptyObject) + message.labels = {}; + key = reader.string(); + reader.pos++; + message.labels[key] = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListenRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.ListenRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.ListenRequest} ListenRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListenRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListenRequest message. + * @function verify + * @memberof google.firestore.v1beta1.ListenRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListenRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.database != null && message.hasOwnProperty("database")) + if (!$util.isString(message.database)) + return "database: string expected"; + if (message.addTarget != null && message.hasOwnProperty("addTarget")) { + properties.targetChange = 1; + { + var error = $root.google.firestore.v1beta1.Target.verify(message.addTarget); + if (error) + return "addTarget." + error; + } + } + if (message.removeTarget != null && message.hasOwnProperty("removeTarget")) { + if (properties.targetChange === 1) + return "targetChange: multiple values"; + properties.targetChange = 1; + if (!$util.isInteger(message.removeTarget)) + return "removeTarget: integer expected"; + } + if (message.labels != null && message.hasOwnProperty("labels")) { + if (!$util.isObject(message.labels)) + return "labels: object expected"; + var key = Object.keys(message.labels); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.labels[key[i]])) + return "labels: string{k:string} expected"; + } + return null; + }; + + /** + * 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 new ListenResponse instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.ListenResponse + * @static + * @param {google.firestore.v1beta1.IListenResponse=} [properties] Properties to set + * @returns {google.firestore.v1beta1.ListenResponse} ListenResponse instance + */ + ListenResponse.create = function create(properties) { + return new ListenResponse(properties); + }; + + /** + * Encodes the specified ListenResponse message. Does not implicitly {@link google.firestore.v1beta1.ListenResponse.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.ListenResponse + * @static + * @param {google.firestore.v1beta1.IListenResponse} message ListenResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListenResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.targetChange != null && message.hasOwnProperty("targetChange")) + $root.google.firestore.v1beta1.TargetChange.encode(message.targetChange, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.documentChange != null && message.hasOwnProperty("documentChange")) + $root.google.firestore.v1beta1.DocumentChange.encode(message.documentChange, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.documentDelete != null && message.hasOwnProperty("documentDelete")) + $root.google.firestore.v1beta1.DocumentDelete.encode(message.documentDelete, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.filter != null && message.hasOwnProperty("filter")) + $root.google.firestore.v1beta1.ExistenceFilter.encode(message.filter, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.documentRemove != null && message.hasOwnProperty("documentRemove")) + $root.google.firestore.v1beta1.DocumentRemove.encode(message.documentRemove, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ListenResponse message, length delimited. Does not implicitly {@link google.firestore.v1beta1.ListenResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.ListenResponse + * @static + * @param {google.firestore.v1beta1.IListenResponse} message ListenResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListenResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListenResponse message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.ListenResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.ListenResponse} ListenResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListenResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.ListenResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.targetChange = $root.google.firestore.v1beta1.TargetChange.decode(reader, reader.uint32()); + break; + case 3: + message.documentChange = $root.google.firestore.v1beta1.DocumentChange.decode(reader, reader.uint32()); + break; + case 4: + message.documentDelete = $root.google.firestore.v1beta1.DocumentDelete.decode(reader, reader.uint32()); + break; + case 6: + message.documentRemove = $root.google.firestore.v1beta1.DocumentRemove.decode(reader, reader.uint32()); + break; + case 5: + message.filter = $root.google.firestore.v1beta1.ExistenceFilter.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListenResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.ListenResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.ListenResponse} ListenResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListenResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListenResponse message. + * @function verify + * @memberof google.firestore.v1beta1.ListenResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListenResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.targetChange != null && message.hasOwnProperty("targetChange")) { + properties.responseType = 1; + { + var error = $root.google.firestore.v1beta1.TargetChange.verify(message.targetChange); + if (error) + return "targetChange." + error; + } + } + if (message.documentChange != null && message.hasOwnProperty("documentChange")) { + if (properties.responseType === 1) + return "responseType: multiple values"; + properties.responseType = 1; + { + var error = $root.google.firestore.v1beta1.DocumentChange.verify(message.documentChange); + if (error) + return "documentChange." + error; + } + } + if (message.documentDelete != null && message.hasOwnProperty("documentDelete")) { + if (properties.responseType === 1) + return "responseType: multiple values"; + properties.responseType = 1; + { + var error = $root.google.firestore.v1beta1.DocumentDelete.verify(message.documentDelete); + if (error) + return "documentDelete." + error; + } + } + if (message.documentRemove != null && message.hasOwnProperty("documentRemove")) { + if (properties.responseType === 1) + return "responseType: multiple values"; + properties.responseType = 1; + { + var error = $root.google.firestore.v1beta1.DocumentRemove.verify(message.documentRemove); + if (error) + return "documentRemove." + error; + } + } + if (message.filter != null && message.hasOwnProperty("filter")) { + if (properties.responseType === 1) + return "responseType: multiple values"; + properties.responseType = 1; + { + var error = $root.google.firestore.v1beta1.ExistenceFilter.verify(message.filter); + if (error) + return "filter." + error; + } + } + return null; + }; + + /** + * 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 new Target instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.Target + * @static + * @param {google.firestore.v1beta1.ITarget=} [properties] Properties to set + * @returns {google.firestore.v1beta1.Target} Target instance + */ + Target.create = function create(properties) { + return new Target(properties); + }; + + /** + * Encodes the specified Target message. Does not implicitly {@link google.firestore.v1beta1.Target.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.Target + * @static + * @param {google.firestore.v1beta1.ITarget} message Target message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Target.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.query != null && message.hasOwnProperty("query")) + $root.google.firestore.v1beta1.Target.QueryTarget.encode(message.query, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.documents != null && message.hasOwnProperty("documents")) + $root.google.firestore.v1beta1.Target.DocumentsTarget.encode(message.documents, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.resumeToken != null && message.hasOwnProperty("resumeToken")) + writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.resumeToken); + if (message.targetId != null && message.hasOwnProperty("targetId")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.targetId); + if (message.once != null && message.hasOwnProperty("once")) + writer.uint32(/* id 6, wireType 0 =*/48).bool(message.once); + if (message.readTime != null && message.hasOwnProperty("readTime")) + $root.google.protobuf.Timestamp.encode(message.readTime, writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Target message, length delimited. Does not implicitly {@link google.firestore.v1beta1.Target.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.Target + * @static + * @param {google.firestore.v1beta1.ITarget} message Target message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Target.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Target message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.Target + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.Target} Target + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Target.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.Target(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.query = $root.google.firestore.v1beta1.Target.QueryTarget.decode(reader, reader.uint32()); + break; + case 3: + message.documents = $root.google.firestore.v1beta1.Target.DocumentsTarget.decode(reader, reader.uint32()); + break; + case 4: + message.resumeToken = reader.bytes(); + break; + case 11: + message.readTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + case 5: + message.targetId = reader.int32(); + break; + case 6: + message.once = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Target message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.Target + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.Target} Target + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Target.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Target message. + * @function verify + * @memberof google.firestore.v1beta1.Target + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Target.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.query != null && message.hasOwnProperty("query")) { + properties.targetType = 1; + { + var error = $root.google.firestore.v1beta1.Target.QueryTarget.verify(message.query); + if (error) + return "query." + error; + } + } + if (message.documents != null && message.hasOwnProperty("documents")) { + if (properties.targetType === 1) + return "targetType: multiple values"; + properties.targetType = 1; + { + var error = $root.google.firestore.v1beta1.Target.DocumentsTarget.verify(message.documents); + if (error) + return "documents." + error; + } + } + if (message.resumeToken != null && message.hasOwnProperty("resumeToken")) { + properties.resumeType = 1; + if (!(message.resumeToken && typeof message.resumeToken.length === "number" || $util.isString(message.resumeToken))) + return "resumeToken: buffer expected"; + } + if (message.readTime != null && message.hasOwnProperty("readTime")) { + if (properties.resumeType === 1) + return "resumeType: multiple values"; + properties.resumeType = 1; + { + var error = $root.google.protobuf.Timestamp.verify(message.readTime); + if (error) + return "readTime." + error; + } + } + if (message.targetId != null && message.hasOwnProperty("targetId")) + if (!$util.isInteger(message.targetId)) + return "targetId: integer expected"; + if (message.once != null && message.hasOwnProperty("once")) + if (typeof message.once !== "boolean") + return "once: boolean expected"; + return null; + }; + + /** + * 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 new DocumentsTarget instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.Target.DocumentsTarget + * @static + * @param {google.firestore.v1beta1.Target.IDocumentsTarget=} [properties] Properties to set + * @returns {google.firestore.v1beta1.Target.DocumentsTarget} DocumentsTarget instance + */ + DocumentsTarget.create = function create(properties) { + return new DocumentsTarget(properties); + }; + + /** + * Encodes the specified DocumentsTarget message. Does not implicitly {@link google.firestore.v1beta1.Target.DocumentsTarget.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.Target.DocumentsTarget + * @static + * @param {google.firestore.v1beta1.Target.IDocumentsTarget} message DocumentsTarget message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DocumentsTarget.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.documents != null && message.documents.length) + for (var i = 0; i < message.documents.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.documents[i]); + return writer; + }; + + /** + * Encodes the specified DocumentsTarget message, length delimited. Does not implicitly {@link google.firestore.v1beta1.Target.DocumentsTarget.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.Target.DocumentsTarget + * @static + * @param {google.firestore.v1beta1.Target.IDocumentsTarget} message DocumentsTarget message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DocumentsTarget.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DocumentsTarget message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.Target.DocumentsTarget + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.Target.DocumentsTarget} DocumentsTarget + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DocumentsTarget.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.Target.DocumentsTarget(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + if (!(message.documents && message.documents.length)) + message.documents = []; + message.documents.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DocumentsTarget message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.Target.DocumentsTarget + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.Target.DocumentsTarget} DocumentsTarget + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DocumentsTarget.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DocumentsTarget message. + * @function verify + * @memberof google.firestore.v1beta1.Target.DocumentsTarget + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DocumentsTarget.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.documents != null && message.hasOwnProperty("documents")) { + if (!Array.isArray(message.documents)) + return "documents: array expected"; + for (var i = 0; i < message.documents.length; ++i) + if (!$util.isString(message.documents[i])) + return "documents: string[] expected"; + } + return null; + }; + + /** + * 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 new QueryTarget instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.Target.QueryTarget + * @static + * @param {google.firestore.v1beta1.Target.IQueryTarget=} [properties] Properties to set + * @returns {google.firestore.v1beta1.Target.QueryTarget} QueryTarget instance + */ + QueryTarget.create = function create(properties) { + return new QueryTarget(properties); + }; + + /** + * Encodes the specified QueryTarget message. Does not implicitly {@link google.firestore.v1beta1.Target.QueryTarget.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.Target.QueryTarget + * @static + * @param {google.firestore.v1beta1.Target.IQueryTarget} message QueryTarget message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + QueryTarget.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && message.hasOwnProperty("parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.structuredQuery != null && message.hasOwnProperty("structuredQuery")) + $root.google.firestore.v1beta1.StructuredQuery.encode(message.structuredQuery, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified QueryTarget message, length delimited. Does not implicitly {@link google.firestore.v1beta1.Target.QueryTarget.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.Target.QueryTarget + * @static + * @param {google.firestore.v1beta1.Target.IQueryTarget} message QueryTarget message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + QueryTarget.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a QueryTarget message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.Target.QueryTarget + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.Target.QueryTarget} QueryTarget + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + QueryTarget.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.Target.QueryTarget(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.structuredQuery = $root.google.firestore.v1beta1.StructuredQuery.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a QueryTarget message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.Target.QueryTarget + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.Target.QueryTarget} QueryTarget + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + QueryTarget.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a QueryTarget message. + * @function verify + * @memberof google.firestore.v1beta1.Target.QueryTarget + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + QueryTarget.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.structuredQuery != null && message.hasOwnProperty("structuredQuery")) { + properties.queryType = 1; + { + var error = $root.google.firestore.v1beta1.StructuredQuery.verify(message.structuredQuery); + if (error) + return "structuredQuery." + error; + } + } + return null; + }; + + /** + * 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 new TargetChange instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.TargetChange + * @static + * @param {google.firestore.v1beta1.ITargetChange=} [properties] Properties to set + * @returns {google.firestore.v1beta1.TargetChange} TargetChange instance + */ + TargetChange.create = function create(properties) { + return new TargetChange(properties); + }; + + /** + * Encodes the specified TargetChange message. Does not implicitly {@link google.firestore.v1beta1.TargetChange.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.TargetChange + * @static + * @param {google.firestore.v1beta1.ITargetChange} message TargetChange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TargetChange.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.targetChangeType != null && message.hasOwnProperty("targetChangeType")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.targetChangeType); + if (message.targetIds != null && message.targetIds.length) { + writer.uint32(/* id 2, wireType 2 =*/18).fork(); + for (var i = 0; i < message.targetIds.length; ++i) + writer.int32(message.targetIds[i]); + writer.ldelim(); + } + if (message.cause != null && message.hasOwnProperty("cause")) + $root.google.rpc.Status.encode(message.cause, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.resumeToken != null && message.hasOwnProperty("resumeToken")) + writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.resumeToken); + if (message.readTime != null && message.hasOwnProperty("readTime")) + $root.google.protobuf.Timestamp.encode(message.readTime, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified TargetChange message, length delimited. Does not implicitly {@link google.firestore.v1beta1.TargetChange.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.TargetChange + * @static + * @param {google.firestore.v1beta1.ITargetChange} message TargetChange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TargetChange.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TargetChange message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.TargetChange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.TargetChange} TargetChange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TargetChange.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.TargetChange(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.targetChangeType = reader.int32(); + break; + case 2: + if (!(message.targetIds && message.targetIds.length)) + message.targetIds = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.targetIds.push(reader.int32()); + } else + message.targetIds.push(reader.int32()); + break; + case 3: + message.cause = $root.google.rpc.Status.decode(reader, reader.uint32()); + break; + case 4: + message.resumeToken = reader.bytes(); + break; + case 6: + message.readTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TargetChange message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.TargetChange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.TargetChange} TargetChange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TargetChange.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TargetChange message. + * @function verify + * @memberof google.firestore.v1beta1.TargetChange + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TargetChange.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.targetChangeType != null && message.hasOwnProperty("targetChangeType")) + switch (message.targetChangeType) { + default: + return "targetChangeType: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } + if (message.targetIds != null && message.hasOwnProperty("targetIds")) { + if (!Array.isArray(message.targetIds)) + return "targetIds: array expected"; + for (var i = 0; i < message.targetIds.length; ++i) + if (!$util.isInteger(message.targetIds[i])) + return "targetIds: integer[] expected"; + } + if (message.cause != null && message.hasOwnProperty("cause")) { + var error = $root.google.rpc.Status.verify(message.cause); + if (error) + return "cause." + error; + } + if (message.resumeToken != null && message.hasOwnProperty("resumeToken")) + if (!(message.resumeToken && typeof message.resumeToken.length === "number" || $util.isString(message.resumeToken))) + return "resumeToken: buffer expected"; + if (message.readTime != null && message.hasOwnProperty("readTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.readTime); + if (error) + return "readTime." + error; + } + return 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; + object.resumeToken = options.bytes === String ? "" : []; + 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 {number} NO_CHANGE=0 NO_CHANGE value + * @property {number} ADD=1 ADD value + * @property {number} REMOVE=2 REMOVE value + * @property {number} CURRENT=3 CURRENT value + * @property {number} RESET=4 RESET value + */ + TargetChange.TargetChangeType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "NO_CHANGE"] = 0; + values[valuesById[1] = "ADD"] = 1; + values[valuesById[2] = "REMOVE"] = 2; + values[valuesById[3] = "CURRENT"] = 3; + values[valuesById[4] = "RESET"] = 4; + 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 new ListCollectionIdsRequest instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.ListCollectionIdsRequest + * @static + * @param {google.firestore.v1beta1.IListCollectionIdsRequest=} [properties] Properties to set + * @returns {google.firestore.v1beta1.ListCollectionIdsRequest} ListCollectionIdsRequest instance + */ + ListCollectionIdsRequest.create = function create(properties) { + return new ListCollectionIdsRequest(properties); + }; + + /** + * Encodes the specified ListCollectionIdsRequest message. Does not implicitly {@link google.firestore.v1beta1.ListCollectionIdsRequest.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.ListCollectionIdsRequest + * @static + * @param {google.firestore.v1beta1.IListCollectionIdsRequest} message ListCollectionIdsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListCollectionIdsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && message.hasOwnProperty("parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.pageSize); + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.pageToken); + return writer; + }; + + /** + * Encodes the specified ListCollectionIdsRequest message, length delimited. Does not implicitly {@link google.firestore.v1beta1.ListCollectionIdsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.ListCollectionIdsRequest + * @static + * @param {google.firestore.v1beta1.IListCollectionIdsRequest} message ListCollectionIdsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListCollectionIdsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListCollectionIdsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.ListCollectionIdsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.ListCollectionIdsRequest} ListCollectionIdsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListCollectionIdsRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.ListCollectionIdsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.pageSize = reader.int32(); + break; + case 3: + message.pageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListCollectionIdsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.ListCollectionIdsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.ListCollectionIdsRequest} ListCollectionIdsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListCollectionIdsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListCollectionIdsRequest message. + * @function verify + * @memberof google.firestore.v1beta1.ListCollectionIdsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListCollectionIdsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + if (!$util.isInteger(message.pageSize)) + return "pageSize: integer expected"; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + if (!$util.isString(message.pageToken)) + return "pageToken: string expected"; + return null; + }; + + /** + * 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 new ListCollectionIdsResponse instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.ListCollectionIdsResponse + * @static + * @param {google.firestore.v1beta1.IListCollectionIdsResponse=} [properties] Properties to set + * @returns {google.firestore.v1beta1.ListCollectionIdsResponse} ListCollectionIdsResponse instance + */ + ListCollectionIdsResponse.create = function create(properties) { + return new ListCollectionIdsResponse(properties); + }; + + /** + * Encodes the specified ListCollectionIdsResponse message. Does not implicitly {@link google.firestore.v1beta1.ListCollectionIdsResponse.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.ListCollectionIdsResponse + * @static + * @param {google.firestore.v1beta1.IListCollectionIdsResponse} message ListCollectionIdsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListCollectionIdsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.collectionIds != null && message.collectionIds.length) + for (var i = 0; i < message.collectionIds.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.collectionIds[i]); + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.nextPageToken); + return writer; + }; + + /** + * Encodes the specified ListCollectionIdsResponse message, length delimited. Does not implicitly {@link google.firestore.v1beta1.ListCollectionIdsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.ListCollectionIdsResponse + * @static + * @param {google.firestore.v1beta1.IListCollectionIdsResponse} message ListCollectionIdsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListCollectionIdsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListCollectionIdsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.ListCollectionIdsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.ListCollectionIdsResponse} ListCollectionIdsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListCollectionIdsResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.ListCollectionIdsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.collectionIds && message.collectionIds.length)) + message.collectionIds = []; + message.collectionIds.push(reader.string()); + break; + case 2: + message.nextPageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListCollectionIdsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.ListCollectionIdsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.ListCollectionIdsResponse} ListCollectionIdsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListCollectionIdsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListCollectionIdsResponse message. + * @function verify + * @memberof google.firestore.v1beta1.ListCollectionIdsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListCollectionIdsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.collectionIds != null && message.hasOwnProperty("collectionIds")) { + if (!Array.isArray(message.collectionIds)) + return "collectionIds: array expected"; + for (var i = 0; i < message.collectionIds.length; ++i) + if (!$util.isString(message.collectionIds[i])) + return "collectionIds: string[] expected"; + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * 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.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; + + /** + * Creates a new DocumentMask instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.DocumentMask + * @static + * @param {google.firestore.v1beta1.IDocumentMask=} [properties] Properties to set + * @returns {google.firestore.v1beta1.DocumentMask} DocumentMask instance + */ + DocumentMask.create = function create(properties) { + return new DocumentMask(properties); + }; + + /** + * Encodes the specified DocumentMask message. Does not implicitly {@link google.firestore.v1beta1.DocumentMask.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.DocumentMask + * @static + * @param {google.firestore.v1beta1.IDocumentMask} message DocumentMask message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DocumentMask.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.fieldPaths != null && message.fieldPaths.length) + for (var i = 0; i < message.fieldPaths.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.fieldPaths[i]); + return writer; + }; + + /** + * Encodes the specified DocumentMask message, length delimited. Does not implicitly {@link google.firestore.v1beta1.DocumentMask.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.DocumentMask + * @static + * @param {google.firestore.v1beta1.IDocumentMask} message DocumentMask message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DocumentMask.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DocumentMask message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.DocumentMask + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.DocumentMask} DocumentMask + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DocumentMask.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.DocumentMask(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.fieldPaths && message.fieldPaths.length)) + message.fieldPaths = []; + message.fieldPaths.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DocumentMask message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.DocumentMask + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.DocumentMask} DocumentMask + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DocumentMask.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DocumentMask message. + * @function verify + * @memberof google.firestore.v1beta1.DocumentMask + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DocumentMask.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.fieldPaths != null && message.hasOwnProperty("fieldPaths")) { + if (!Array.isArray(message.fieldPaths)) + return "fieldPaths: array expected"; + for (var i = 0; i < message.fieldPaths.length; ++i) + if (!$util.isString(message.fieldPaths[i])) + return "fieldPaths: string[] expected"; + } + return null; + }; + + /** + * 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; + })(); + + 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) + }); + + /** + * Creates a new Precondition instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.Precondition + * @static + * @param {google.firestore.v1beta1.IPrecondition=} [properties] Properties to set + * @returns {google.firestore.v1beta1.Precondition} Precondition instance + */ + Precondition.create = function create(properties) { + return new Precondition(properties); + }; + + /** + * Encodes the specified Precondition message. Does not implicitly {@link google.firestore.v1beta1.Precondition.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.Precondition + * @static + * @param {google.firestore.v1beta1.IPrecondition} message Precondition message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Precondition.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.exists != null && message.hasOwnProperty("exists")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.exists); + if (message.updateTime != null && message.hasOwnProperty("updateTime")) + $root.google.protobuf.Timestamp.encode(message.updateTime, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Precondition message, length delimited. Does not implicitly {@link google.firestore.v1beta1.Precondition.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.Precondition + * @static + * @param {google.firestore.v1beta1.IPrecondition} message Precondition message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Precondition.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Precondition message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.Precondition + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.Precondition} Precondition + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Precondition.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.Precondition(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.exists = reader.bool(); + break; + case 2: + message.updateTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Precondition message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.Precondition + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.Precondition} Precondition + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Precondition.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Precondition message. + * @function verify + * @memberof google.firestore.v1beta1.Precondition + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Precondition.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.exists != null && message.hasOwnProperty("exists")) { + properties.conditionType = 1; + if (typeof message.exists !== "boolean") + return "exists: boolean expected"; + } + if (message.updateTime != null && message.hasOwnProperty("updateTime")) { + if (properties.conditionType === 1) + return "conditionType: multiple values"; + properties.conditionType = 1; + { + var error = $root.google.protobuf.Timestamp.verify(message.updateTime); + if (error) + return "updateTime." + error; + } + } + return null; + }; + + /** + * 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; + })(); + + 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) + }); + + /** + * Creates a new TransactionOptions instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.TransactionOptions + * @static + * @param {google.firestore.v1beta1.ITransactionOptions=} [properties] Properties to set + * @returns {google.firestore.v1beta1.TransactionOptions} TransactionOptions instance + */ + TransactionOptions.create = function create(properties) { + return new TransactionOptions(properties); + }; + + /** + * Encodes the specified TransactionOptions message. Does not implicitly {@link google.firestore.v1beta1.TransactionOptions.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.TransactionOptions + * @static + * @param {google.firestore.v1beta1.ITransactionOptions} message TransactionOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TransactionOptions.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.readOnly != null && message.hasOwnProperty("readOnly")) + $root.google.firestore.v1beta1.TransactionOptions.ReadOnly.encode(message.readOnly, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.readWrite != null && message.hasOwnProperty("readWrite")) + $root.google.firestore.v1beta1.TransactionOptions.ReadWrite.encode(message.readWrite, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified TransactionOptions message, length delimited. Does not implicitly {@link google.firestore.v1beta1.TransactionOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.TransactionOptions + * @static + * @param {google.firestore.v1beta1.ITransactionOptions} message TransactionOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TransactionOptions.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TransactionOptions message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.TransactionOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.TransactionOptions} TransactionOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TransactionOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.TransactionOptions(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.readOnly = $root.google.firestore.v1beta1.TransactionOptions.ReadOnly.decode(reader, reader.uint32()); + break; + case 3: + message.readWrite = $root.google.firestore.v1beta1.TransactionOptions.ReadWrite.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TransactionOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.TransactionOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.TransactionOptions} TransactionOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TransactionOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TransactionOptions message. + * @function verify + * @memberof google.firestore.v1beta1.TransactionOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TransactionOptions.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.readOnly != null && message.hasOwnProperty("readOnly")) { + properties.mode = 1; + { + var error = $root.google.firestore.v1beta1.TransactionOptions.ReadOnly.verify(message.readOnly); + if (error) + return "readOnly." + error; + } + } + if (message.readWrite != null && message.hasOwnProperty("readWrite")) { + if (properties.mode === 1) + return "mode: multiple values"; + properties.mode = 1; + { + var error = $root.google.firestore.v1beta1.TransactionOptions.ReadWrite.verify(message.readWrite); + if (error) + return "readWrite." + error; + } + } + return null; + }; + + /** + * 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 new ReadWrite instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.TransactionOptions.ReadWrite + * @static + * @param {google.firestore.v1beta1.TransactionOptions.IReadWrite=} [properties] Properties to set + * @returns {google.firestore.v1beta1.TransactionOptions.ReadWrite} ReadWrite instance + */ + ReadWrite.create = function create(properties) { + return new ReadWrite(properties); + }; + + /** + * Encodes the specified ReadWrite message. Does not implicitly {@link google.firestore.v1beta1.TransactionOptions.ReadWrite.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.TransactionOptions.ReadWrite + * @static + * @param {google.firestore.v1beta1.TransactionOptions.IReadWrite} message ReadWrite message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReadWrite.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.retryTransaction != null && message.hasOwnProperty("retryTransaction")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.retryTransaction); + return writer; + }; + + /** + * Encodes the specified ReadWrite message, length delimited. Does not implicitly {@link google.firestore.v1beta1.TransactionOptions.ReadWrite.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.TransactionOptions.ReadWrite + * @static + * @param {google.firestore.v1beta1.TransactionOptions.IReadWrite} message ReadWrite message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReadWrite.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReadWrite message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.TransactionOptions.ReadWrite + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.TransactionOptions.ReadWrite} ReadWrite + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReadWrite.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.TransactionOptions.ReadWrite(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.retryTransaction = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReadWrite message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.TransactionOptions.ReadWrite + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.TransactionOptions.ReadWrite} ReadWrite + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReadWrite.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReadWrite message. + * @function verify + * @memberof google.firestore.v1beta1.TransactionOptions.ReadWrite + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReadWrite.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.retryTransaction != null && message.hasOwnProperty("retryTransaction")) + if (!(message.retryTransaction && typeof message.retryTransaction.length === "number" || $util.isString(message.retryTransaction))) + return "retryTransaction: buffer expected"; + return null; + }; + + /** + * 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) + object.retryTransaction = options.bytes === String ? "" : []; + 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 new ReadOnly instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.TransactionOptions.ReadOnly + * @static + * @param {google.firestore.v1beta1.TransactionOptions.IReadOnly=} [properties] Properties to set + * @returns {google.firestore.v1beta1.TransactionOptions.ReadOnly} ReadOnly instance + */ + ReadOnly.create = function create(properties) { + return new ReadOnly(properties); + }; + + /** + * Encodes the specified ReadOnly message. Does not implicitly {@link google.firestore.v1beta1.TransactionOptions.ReadOnly.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.TransactionOptions.ReadOnly + * @static + * @param {google.firestore.v1beta1.TransactionOptions.IReadOnly} message ReadOnly message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReadOnly.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.readTime != null && message.hasOwnProperty("readTime")) + $root.google.protobuf.Timestamp.encode(message.readTime, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ReadOnly message, length delimited. Does not implicitly {@link google.firestore.v1beta1.TransactionOptions.ReadOnly.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.TransactionOptions.ReadOnly + * @static + * @param {google.firestore.v1beta1.TransactionOptions.IReadOnly} message ReadOnly message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReadOnly.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReadOnly message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.TransactionOptions.ReadOnly + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.TransactionOptions.ReadOnly} ReadOnly + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReadOnly.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.TransactionOptions.ReadOnly(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.readTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReadOnly message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.TransactionOptions.ReadOnly + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.TransactionOptions.ReadOnly} ReadOnly + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReadOnly.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReadOnly message. + * @function verify + * @memberof google.firestore.v1beta1.TransactionOptions.ReadOnly + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReadOnly.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.readTime != null && message.hasOwnProperty("readTime")) { + properties.consistencySelector = 1; + { + var error = $root.google.protobuf.Timestamp.verify(message.readTime); + if (error) + return "readTime." + error; + } + } + return null; + }; + + /** + * 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; + })(); + + 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; + + /** + * Creates a new Document instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.Document + * @static + * @param {google.firestore.v1beta1.IDocument=} [properties] Properties to set + * @returns {google.firestore.v1beta1.Document} Document instance + */ + Document.create = function create(properties) { + return new Document(properties); + }; + + /** + * Encodes the specified Document message. Does not implicitly {@link google.firestore.v1beta1.Document.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.Document + * @static + * @param {google.firestore.v1beta1.IDocument} message Document message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Document.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && message.hasOwnProperty("name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.fields != null && message.hasOwnProperty("fields")) + for (var keys = Object.keys(message.fields), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 2, wireType 2 =*/18).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); + $root.google.firestore.v1beta1.Value.encode(message.fields[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.createTime != null && message.hasOwnProperty("createTime")) + $root.google.protobuf.Timestamp.encode(message.createTime, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.updateTime != null && message.hasOwnProperty("updateTime")) + $root.google.protobuf.Timestamp.encode(message.updateTime, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Document message, length delimited. Does not implicitly {@link google.firestore.v1beta1.Document.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.Document + * @static + * @param {google.firestore.v1beta1.IDocument} message Document message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Document.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Document message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.Document + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.Document} Document + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Document.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.Document(), key; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + reader.skip().pos++; + if (message.fields === $util.emptyObject) + message.fields = {}; + key = reader.string(); + reader.pos++; + message.fields[key] = $root.google.firestore.v1beta1.Value.decode(reader, reader.uint32()); + break; + case 3: + message.createTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + case 4: + message.updateTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Document message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.Document + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.Document} Document + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Document.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Document message. + * @function verify + * @memberof google.firestore.v1beta1.Document + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Document.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.fields != null && message.hasOwnProperty("fields")) { + if (!$util.isObject(message.fields)) + return "fields: object expected"; + var key = Object.keys(message.fields); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.firestore.v1beta1.Value.verify(message.fields[key[i]]); + if (error) + return "fields." + error; + } + } + if (message.createTime != null && message.hasOwnProperty("createTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.createTime); + if (error) + return "createTime." + error; + } + if (message.updateTime != null && message.hasOwnProperty("updateTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.updateTime); + if (error) + return "updateTime." + error; + } + return 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; + })(); + + 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|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 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|string} 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) + }); + + /** + * Creates a new Value instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.Value + * @static + * @param {google.firestore.v1beta1.IValue=} [properties] Properties to set + * @returns {google.firestore.v1beta1.Value} Value instance + */ + Value.create = function create(properties) { + return new Value(properties); + }; + + /** + * Encodes the specified Value message. Does not implicitly {@link google.firestore.v1beta1.Value.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.Value + * @static + * @param {google.firestore.v1beta1.IValue} message Value message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Value.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.booleanValue != null && message.hasOwnProperty("booleanValue")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.booleanValue); + if (message.integerValue != null && message.hasOwnProperty("integerValue")) + writer.uint32(/* id 2, wireType 0 =*/16).int64(message.integerValue); + if (message.doubleValue != null && message.hasOwnProperty("doubleValue")) + writer.uint32(/* id 3, wireType 1 =*/25).double(message.doubleValue); + if (message.referenceValue != null && message.hasOwnProperty("referenceValue")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.referenceValue); + if (message.mapValue != null && message.hasOwnProperty("mapValue")) + $root.google.firestore.v1beta1.MapValue.encode(message.mapValue, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.geoPointValue != null && message.hasOwnProperty("geoPointValue")) + $root.google.type.LatLng.encode(message.geoPointValue, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.arrayValue != null && message.hasOwnProperty("arrayValue")) + $root.google.firestore.v1beta1.ArrayValue.encode(message.arrayValue, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.timestampValue != null && message.hasOwnProperty("timestampValue")) + $root.google.protobuf.Timestamp.encode(message.timestampValue, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); + if (message.nullValue != null && message.hasOwnProperty("nullValue")) + writer.uint32(/* id 11, wireType 0 =*/88).int32(message.nullValue); + if (message.stringValue != null && message.hasOwnProperty("stringValue")) + writer.uint32(/* id 17, wireType 2 =*/138).string(message.stringValue); + if (message.bytesValue != null && message.hasOwnProperty("bytesValue")) + writer.uint32(/* id 18, wireType 2 =*/146).bytes(message.bytesValue); + return writer; + }; + + /** + * Encodes the specified Value message, length delimited. Does not implicitly {@link google.firestore.v1beta1.Value.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.Value + * @static + * @param {google.firestore.v1beta1.IValue} message Value message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Value.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Value message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.Value + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.Value} Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Value.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.Value(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 11: + message.nullValue = reader.int32(); + break; + case 1: + message.booleanValue = reader.bool(); + break; + case 2: + message.integerValue = reader.int64(); + break; + case 3: + message.doubleValue = reader.double(); + break; + case 10: + message.timestampValue = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + case 17: + message.stringValue = reader.string(); + break; + case 18: + message.bytesValue = reader.bytes(); + break; + case 5: + message.referenceValue = reader.string(); + break; + case 8: + message.geoPointValue = $root.google.type.LatLng.decode(reader, reader.uint32()); + break; + case 9: + message.arrayValue = $root.google.firestore.v1beta1.ArrayValue.decode(reader, reader.uint32()); + break; + case 6: + message.mapValue = $root.google.firestore.v1beta1.MapValue.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Value message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.Value + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.Value} Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Value.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Value message. + * @function verify + * @memberof google.firestore.v1beta1.Value + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Value.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.nullValue != null && message.hasOwnProperty("nullValue")) { + properties.valueType = 1; + switch (message.nullValue) { + default: + return "nullValue: enum value expected"; + case 0: + break; + } + } + if (message.booleanValue != null && message.hasOwnProperty("booleanValue")) { + if (properties.valueType === 1) + return "valueType: multiple values"; + properties.valueType = 1; + if (typeof message.booleanValue !== "boolean") + return "booleanValue: boolean expected"; + } + if (message.integerValue != null && message.hasOwnProperty("integerValue")) { + if (properties.valueType === 1) + return "valueType: multiple values"; + properties.valueType = 1; + if (!$util.isInteger(message.integerValue) && !(message.integerValue && $util.isInteger(message.integerValue.low) && $util.isInteger(message.integerValue.high))) + return "integerValue: integer|Long expected"; + } + if (message.doubleValue != null && message.hasOwnProperty("doubleValue")) { + if (properties.valueType === 1) + return "valueType: multiple values"; + properties.valueType = 1; + if (typeof message.doubleValue !== "number") + return "doubleValue: number expected"; + } + if (message.timestampValue != null && message.hasOwnProperty("timestampValue")) { + if (properties.valueType === 1) + return "valueType: multiple values"; + properties.valueType = 1; + { + var error = $root.google.protobuf.Timestamp.verify(message.timestampValue); + if (error) + return "timestampValue." + error; + } + } + if (message.stringValue != null && message.hasOwnProperty("stringValue")) { + if (properties.valueType === 1) + return "valueType: multiple values"; + properties.valueType = 1; + if (!$util.isString(message.stringValue)) + return "stringValue: string expected"; + } + if (message.bytesValue != null && message.hasOwnProperty("bytesValue")) { + if (properties.valueType === 1) + return "valueType: multiple values"; + properties.valueType = 1; + if (!(message.bytesValue && typeof message.bytesValue.length === "number" || $util.isString(message.bytesValue))) + return "bytesValue: buffer expected"; + } + if (message.referenceValue != null && message.hasOwnProperty("referenceValue")) { + if (properties.valueType === 1) + return "valueType: multiple values"; + properties.valueType = 1; + if (!$util.isString(message.referenceValue)) + return "referenceValue: string expected"; + } + if (message.geoPointValue != null && message.hasOwnProperty("geoPointValue")) { + if (properties.valueType === 1) + return "valueType: multiple values"; + properties.valueType = 1; + { + var error = $root.google.type.LatLng.verify(message.geoPointValue); + if (error) + return "geoPointValue." + error; + } + } + if (message.arrayValue != null && message.hasOwnProperty("arrayValue")) { + if (properties.valueType === 1) + return "valueType: multiple values"; + properties.valueType = 1; + { + var error = $root.google.firestore.v1beta1.ArrayValue.verify(message.arrayValue); + if (error) + return "arrayValue." + error; + } + } + if (message.mapValue != null && message.hasOwnProperty("mapValue")) { + if (properties.valueType === 1) + return "valueType: multiple values"; + properties.valueType = 1; + { + var error = $root.google.firestore.v1beta1.MapValue.verify(message.mapValue); + if (error) + return "mapValue." + error; + } + } + return null; + }; + + /** + * 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 + */ + 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; + })(); + + 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; + + /** + * Creates a new ArrayValue instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.ArrayValue + * @static + * @param {google.firestore.v1beta1.IArrayValue=} [properties] Properties to set + * @returns {google.firestore.v1beta1.ArrayValue} ArrayValue instance + */ + ArrayValue.create = function create(properties) { + return new ArrayValue(properties); + }; + + /** + * Encodes the specified ArrayValue message. Does not implicitly {@link google.firestore.v1beta1.ArrayValue.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.ArrayValue + * @static + * @param {google.firestore.v1beta1.IArrayValue} message ArrayValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ArrayValue.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.values != null && message.values.length) + for (var i = 0; i < message.values.length; ++i) + $root.google.firestore.v1beta1.Value.encode(message.values[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ArrayValue message, length delimited. Does not implicitly {@link google.firestore.v1beta1.ArrayValue.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.ArrayValue + * @static + * @param {google.firestore.v1beta1.IArrayValue} message ArrayValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ArrayValue.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ArrayValue message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.ArrayValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.ArrayValue} ArrayValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ArrayValue.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.ArrayValue(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.values && message.values.length)) + message.values = []; + message.values.push($root.google.firestore.v1beta1.Value.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ArrayValue message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.ArrayValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.ArrayValue} ArrayValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ArrayValue.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ArrayValue message. + * @function verify + * @memberof google.firestore.v1beta1.ArrayValue + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ArrayValue.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.values != null && message.hasOwnProperty("values")) { + if (!Array.isArray(message.values)) + return "values: array expected"; + for (var i = 0; i < message.values.length; ++i) { + var error = $root.google.firestore.v1beta1.Value.verify(message.values[i]); + if (error) + return "values." + error; + } + } + return null; + }; + + /** + * 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 + */ + ArrayValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + 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; + + /** + * Creates a new MapValue instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.MapValue + * @static + * @param {google.firestore.v1beta1.IMapValue=} [properties] Properties to set + * @returns {google.firestore.v1beta1.MapValue} MapValue instance + */ + MapValue.create = function create(properties) { + return new MapValue(properties); + }; + + /** + * Encodes the specified MapValue message. Does not implicitly {@link google.firestore.v1beta1.MapValue.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.MapValue + * @static + * @param {google.firestore.v1beta1.IMapValue} message MapValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MapValue.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.fields != null && message.hasOwnProperty("fields")) + for (var keys = Object.keys(message.fields), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 1, wireType 2 =*/10).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); + $root.google.firestore.v1beta1.Value.encode(message.fields[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + return writer; + }; + + /** + * Encodes the specified MapValue message, length delimited. Does not implicitly {@link google.firestore.v1beta1.MapValue.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.MapValue + * @static + * @param {google.firestore.v1beta1.IMapValue} message MapValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MapValue.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a MapValue message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.MapValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.MapValue} MapValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MapValue.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.MapValue(), key; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + reader.skip().pos++; + if (message.fields === $util.emptyObject) + message.fields = {}; + key = reader.string(); + reader.pos++; + message.fields[key] = $root.google.firestore.v1beta1.Value.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a MapValue message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.MapValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.MapValue} MapValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MapValue.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a MapValue message. + * @function verify + * @memberof google.firestore.v1beta1.MapValue + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MapValue.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.fields != null && message.hasOwnProperty("fields")) { + if (!$util.isObject(message.fields)) + return "fields: object expected"; + var key = Object.keys(message.fields); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.firestore.v1beta1.Value.verify(message.fields[key[i]]); + if (error) + return "fields." + error; + } + } + return null; + }; + + /** + * 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; + }; + + /** + * 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.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 new StructuredQuery instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.StructuredQuery + * @static + * @param {google.firestore.v1beta1.IStructuredQuery=} [properties] Properties to set + * @returns {google.firestore.v1beta1.StructuredQuery} StructuredQuery instance + */ + StructuredQuery.create = function create(properties) { + return new StructuredQuery(properties); + }; + + /** + * Encodes the specified StructuredQuery message. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.StructuredQuery + * @static + * @param {google.firestore.v1beta1.IStructuredQuery} message StructuredQuery message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StructuredQuery.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.select != null && message.hasOwnProperty("select")) + $root.google.firestore.v1beta1.StructuredQuery.Projection.encode(message.select, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.from != null && message.from.length) + for (var i = 0; i < message.from.length; ++i) + $root.google.firestore.v1beta1.StructuredQuery.CollectionSelector.encode(message.from[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.where != null && message.hasOwnProperty("where")) + $root.google.firestore.v1beta1.StructuredQuery.Filter.encode(message.where, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.orderBy != null && message.orderBy.length) + for (var i = 0; i < message.orderBy.length; ++i) + $root.google.firestore.v1beta1.StructuredQuery.Order.encode(message.orderBy[i], writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.limit != null && message.hasOwnProperty("limit")) + $root.google.protobuf.Int32Value.encode(message.limit, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.offset != null && message.hasOwnProperty("offset")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.offset); + if (message.startAt != null && message.hasOwnProperty("startAt")) + $root.google.firestore.v1beta1.Cursor.encode(message.startAt, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.endAt != null && message.hasOwnProperty("endAt")) + $root.google.firestore.v1beta1.Cursor.encode(message.endAt, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified StructuredQuery message, length delimited. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.StructuredQuery + * @static + * @param {google.firestore.v1beta1.IStructuredQuery} message StructuredQuery message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StructuredQuery.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a StructuredQuery message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.StructuredQuery + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.StructuredQuery} StructuredQuery + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StructuredQuery.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.StructuredQuery(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.select = $root.google.firestore.v1beta1.StructuredQuery.Projection.decode(reader, reader.uint32()); + break; + case 2: + if (!(message.from && message.from.length)) + message.from = []; + message.from.push($root.google.firestore.v1beta1.StructuredQuery.CollectionSelector.decode(reader, reader.uint32())); + break; + case 3: + message.where = $root.google.firestore.v1beta1.StructuredQuery.Filter.decode(reader, reader.uint32()); + break; + case 4: + if (!(message.orderBy && message.orderBy.length)) + message.orderBy = []; + message.orderBy.push($root.google.firestore.v1beta1.StructuredQuery.Order.decode(reader, reader.uint32())); + break; + case 7: + message.startAt = $root.google.firestore.v1beta1.Cursor.decode(reader, reader.uint32()); + break; + case 8: + message.endAt = $root.google.firestore.v1beta1.Cursor.decode(reader, reader.uint32()); + break; + case 6: + message.offset = reader.int32(); + break; + case 5: + message.limit = $root.google.protobuf.Int32Value.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a StructuredQuery message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.StructuredQuery + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.StructuredQuery} StructuredQuery + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StructuredQuery.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a StructuredQuery message. + * @function verify + * @memberof google.firestore.v1beta1.StructuredQuery + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + StructuredQuery.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.select != null && message.hasOwnProperty("select")) { + var error = $root.google.firestore.v1beta1.StructuredQuery.Projection.verify(message.select); + if (error) + return "select." + error; + } + if (message.from != null && message.hasOwnProperty("from")) { + if (!Array.isArray(message.from)) + return "from: array expected"; + for (var i = 0; i < message.from.length; ++i) { + var error = $root.google.firestore.v1beta1.StructuredQuery.CollectionSelector.verify(message.from[i]); + if (error) + return "from." + error; + } + } + if (message.where != null && message.hasOwnProperty("where")) { + var error = $root.google.firestore.v1beta1.StructuredQuery.Filter.verify(message.where); + if (error) + return "where." + error; + } + if (message.orderBy != null && message.hasOwnProperty("orderBy")) { + if (!Array.isArray(message.orderBy)) + return "orderBy: array expected"; + for (var i = 0; i < message.orderBy.length; ++i) { + var error = $root.google.firestore.v1beta1.StructuredQuery.Order.verify(message.orderBy[i]); + if (error) + return "orderBy." + error; + } + } + if (message.startAt != null && message.hasOwnProperty("startAt")) { + var error = $root.google.firestore.v1beta1.Cursor.verify(message.startAt); + if (error) + return "startAt." + error; + } + if (message.endAt != null && message.hasOwnProperty("endAt")) { + var error = $root.google.firestore.v1beta1.Cursor.verify(message.endAt); + if (error) + return "endAt." + error; + } + if (message.offset != null && message.hasOwnProperty("offset")) + if (!$util.isInteger(message.offset)) + return "offset: integer expected"; + if (message.limit != null && message.hasOwnProperty("limit")) { + var error = $root.google.protobuf.Int32Value.verify(message.limit); + if (error) + return "limit." + error; + } + return 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 new CollectionSelector instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.StructuredQuery.CollectionSelector + * @static + * @param {google.firestore.v1beta1.StructuredQuery.ICollectionSelector=} [properties] Properties to set + * @returns {google.firestore.v1beta1.StructuredQuery.CollectionSelector} CollectionSelector instance + */ + CollectionSelector.create = function create(properties) { + return new CollectionSelector(properties); + }; + + /** + * Encodes the specified CollectionSelector message. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.CollectionSelector.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.StructuredQuery.CollectionSelector + * @static + * @param {google.firestore.v1beta1.StructuredQuery.ICollectionSelector} message CollectionSelector message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CollectionSelector.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.collectionId != null && message.hasOwnProperty("collectionId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.collectionId); + if (message.allDescendants != null && message.hasOwnProperty("allDescendants")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.allDescendants); + return writer; + }; + + /** + * Encodes the specified CollectionSelector message, length delimited. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.CollectionSelector.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.StructuredQuery.CollectionSelector + * @static + * @param {google.firestore.v1beta1.StructuredQuery.ICollectionSelector} message CollectionSelector message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CollectionSelector.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CollectionSelector message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.StructuredQuery.CollectionSelector + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.StructuredQuery.CollectionSelector} CollectionSelector + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CollectionSelector.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.StructuredQuery.CollectionSelector(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.collectionId = reader.string(); + break; + case 3: + message.allDescendants = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CollectionSelector message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.StructuredQuery.CollectionSelector + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.StructuredQuery.CollectionSelector} CollectionSelector + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CollectionSelector.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CollectionSelector message. + * @function verify + * @memberof google.firestore.v1beta1.StructuredQuery.CollectionSelector + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CollectionSelector.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.collectionId != null && message.hasOwnProperty("collectionId")) + if (!$util.isString(message.collectionId)) + return "collectionId: string expected"; + if (message.allDescendants != null && message.hasOwnProperty("allDescendants")) + if (typeof message.allDescendants !== "boolean") + return "allDescendants: boolean expected"; + return null; + }; + + /** + * 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 new Filter instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.StructuredQuery.Filter + * @static + * @param {google.firestore.v1beta1.StructuredQuery.IFilter=} [properties] Properties to set + * @returns {google.firestore.v1beta1.StructuredQuery.Filter} Filter instance + */ + Filter.create = function create(properties) { + return new Filter(properties); + }; + + /** + * Encodes the specified Filter message. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.Filter.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.StructuredQuery.Filter + * @static + * @param {google.firestore.v1beta1.StructuredQuery.IFilter} message Filter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Filter.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.compositeFilter != null && message.hasOwnProperty("compositeFilter")) + $root.google.firestore.v1beta1.StructuredQuery.CompositeFilter.encode(message.compositeFilter, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.fieldFilter != null && message.hasOwnProperty("fieldFilter")) + $root.google.firestore.v1beta1.StructuredQuery.FieldFilter.encode(message.fieldFilter, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.unaryFilter != null && message.hasOwnProperty("unaryFilter")) + $root.google.firestore.v1beta1.StructuredQuery.UnaryFilter.encode(message.unaryFilter, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Filter message, length delimited. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.Filter.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.StructuredQuery.Filter + * @static + * @param {google.firestore.v1beta1.StructuredQuery.IFilter} message Filter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Filter.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Filter message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.StructuredQuery.Filter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.StructuredQuery.Filter} Filter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Filter.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.StructuredQuery.Filter(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.compositeFilter = $root.google.firestore.v1beta1.StructuredQuery.CompositeFilter.decode(reader, reader.uint32()); + break; + case 2: + message.fieldFilter = $root.google.firestore.v1beta1.StructuredQuery.FieldFilter.decode(reader, reader.uint32()); + break; + case 3: + message.unaryFilter = $root.google.firestore.v1beta1.StructuredQuery.UnaryFilter.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Filter message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.StructuredQuery.Filter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.StructuredQuery.Filter} Filter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Filter.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Filter message. + * @function verify + * @memberof google.firestore.v1beta1.StructuredQuery.Filter + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Filter.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.compositeFilter != null && message.hasOwnProperty("compositeFilter")) { + properties.filterType = 1; + { + var error = $root.google.firestore.v1beta1.StructuredQuery.CompositeFilter.verify(message.compositeFilter); + if (error) + return "compositeFilter." + error; + } + } + if (message.fieldFilter != null && message.hasOwnProperty("fieldFilter")) { + if (properties.filterType === 1) + return "filterType: multiple values"; + properties.filterType = 1; + { + var error = $root.google.firestore.v1beta1.StructuredQuery.FieldFilter.verify(message.fieldFilter); + if (error) + return "fieldFilter." + error; + } + } + if (message.unaryFilter != null && message.hasOwnProperty("unaryFilter")) { + if (properties.filterType === 1) + return "filterType: multiple values"; + properties.filterType = 1; + { + var error = $root.google.firestore.v1beta1.StructuredQuery.UnaryFilter.verify(message.unaryFilter); + if (error) + return "unaryFilter." + error; + } + } + return null; + }; + + /** + * 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 new CompositeFilter instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.StructuredQuery.CompositeFilter + * @static + * @param {google.firestore.v1beta1.StructuredQuery.ICompositeFilter=} [properties] Properties to set + * @returns {google.firestore.v1beta1.StructuredQuery.CompositeFilter} CompositeFilter instance + */ + CompositeFilter.create = function create(properties) { + return new CompositeFilter(properties); + }; + + /** + * Encodes the specified CompositeFilter message. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.CompositeFilter.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.StructuredQuery.CompositeFilter + * @static + * @param {google.firestore.v1beta1.StructuredQuery.ICompositeFilter} message CompositeFilter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompositeFilter.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.op != null && message.hasOwnProperty("op")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.op); + if (message.filters != null && message.filters.length) + for (var i = 0; i < message.filters.length; ++i) + $root.google.firestore.v1beta1.StructuredQuery.Filter.encode(message.filters[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified CompositeFilter message, length delimited. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.CompositeFilter.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.StructuredQuery.CompositeFilter + * @static + * @param {google.firestore.v1beta1.StructuredQuery.ICompositeFilter} message CompositeFilter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompositeFilter.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CompositeFilter message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.StructuredQuery.CompositeFilter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.StructuredQuery.CompositeFilter} CompositeFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompositeFilter.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.StructuredQuery.CompositeFilter(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.op = reader.int32(); + break; + case 2: + if (!(message.filters && message.filters.length)) + message.filters = []; + message.filters.push($root.google.firestore.v1beta1.StructuredQuery.Filter.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CompositeFilter message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.StructuredQuery.CompositeFilter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.StructuredQuery.CompositeFilter} CompositeFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompositeFilter.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CompositeFilter message. + * @function verify + * @memberof google.firestore.v1beta1.StructuredQuery.CompositeFilter + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CompositeFilter.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.op != null && message.hasOwnProperty("op")) + switch (message.op) { + default: + return "op: enum value expected"; + case 0: + case 1: + break; + } + if (message.filters != null && message.hasOwnProperty("filters")) { + if (!Array.isArray(message.filters)) + return "filters: array expected"; + for (var i = 0; i < message.filters.length; ++i) { + var error = $root.google.firestore.v1beta1.StructuredQuery.Filter.verify(message.filters[i]); + if (error) + return "filters." + error; + } + } + return null; + }; + + /** + * 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 {number} OPERATOR_UNSPECIFIED=0 OPERATOR_UNSPECIFIED value + * @property {number} AND=1 AND value + */ + CompositeFilter.Operator = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "OPERATOR_UNSPECIFIED"] = 0; + values[valuesById[1] = "AND"] = 1; + 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 new FieldFilter instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.StructuredQuery.FieldFilter + * @static + * @param {google.firestore.v1beta1.StructuredQuery.IFieldFilter=} [properties] Properties to set + * @returns {google.firestore.v1beta1.StructuredQuery.FieldFilter} FieldFilter instance + */ + FieldFilter.create = function create(properties) { + return new FieldFilter(properties); + }; + + /** + * Encodes the specified FieldFilter message. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.FieldFilter.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.StructuredQuery.FieldFilter + * @static + * @param {google.firestore.v1beta1.StructuredQuery.IFieldFilter} message FieldFilter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldFilter.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.field != null && message.hasOwnProperty("field")) + $root.google.firestore.v1beta1.StructuredQuery.FieldReference.encode(message.field, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.op != null && message.hasOwnProperty("op")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.op); + if (message.value != null && message.hasOwnProperty("value")) + $root.google.firestore.v1beta1.Value.encode(message.value, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified FieldFilter message, length delimited. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.FieldFilter.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.StructuredQuery.FieldFilter + * @static + * @param {google.firestore.v1beta1.StructuredQuery.IFieldFilter} message FieldFilter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldFilter.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FieldFilter message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.StructuredQuery.FieldFilter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.StructuredQuery.FieldFilter} FieldFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldFilter.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.StructuredQuery.FieldFilter(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.field = $root.google.firestore.v1beta1.StructuredQuery.FieldReference.decode(reader, reader.uint32()); + break; + case 2: + message.op = reader.int32(); + break; + case 3: + message.value = $root.google.firestore.v1beta1.Value.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FieldFilter message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.StructuredQuery.FieldFilter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.StructuredQuery.FieldFilter} FieldFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldFilter.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FieldFilter message. + * @function verify + * @memberof google.firestore.v1beta1.StructuredQuery.FieldFilter + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FieldFilter.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.field != null && message.hasOwnProperty("field")) { + var error = $root.google.firestore.v1beta1.StructuredQuery.FieldReference.verify(message.field); + if (error) + return "field." + error; + } + if (message.op != null && message.hasOwnProperty("op")) + switch (message.op) { + default: + return "op: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 7: + break; + } + if (message.value != null && message.hasOwnProperty("value")) { + var error = $root.google.firestore.v1beta1.Value.verify(message.value); + if (error) + return "value." + error; + } + return 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; + } + 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 {number} OPERATOR_UNSPECIFIED=0 OPERATOR_UNSPECIFIED value + * @property {number} LESS_THAN=1 LESS_THAN value + * @property {number} LESS_THAN_OR_EQUAL=2 LESS_THAN_OR_EQUAL value + * @property {number} GREATER_THAN=3 GREATER_THAN value + * @property {number} GREATER_THAN_OR_EQUAL=4 GREATER_THAN_OR_EQUAL value + * @property {number} EQUAL=5 EQUAL value + * @property {number} ARRAY_CONTAINS=7 ARRAY_CONTAINS value + */ + FieldFilter.Operator = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "OPERATOR_UNSPECIFIED"] = 0; + values[valuesById[1] = "LESS_THAN"] = 1; + values[valuesById[2] = "LESS_THAN_OR_EQUAL"] = 2; + values[valuesById[3] = "GREATER_THAN"] = 3; + values[valuesById[4] = "GREATER_THAN_OR_EQUAL"] = 4; + values[valuesById[5] = "EQUAL"] = 5; + values[valuesById[7] = "ARRAY_CONTAINS"] = 7; + 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 a new UnaryFilter instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.StructuredQuery.UnaryFilter + * @static + * @param {google.firestore.v1beta1.StructuredQuery.IUnaryFilter=} [properties] Properties to set + * @returns {google.firestore.v1beta1.StructuredQuery.UnaryFilter} UnaryFilter instance + */ + UnaryFilter.create = function create(properties) { + return new UnaryFilter(properties); + }; + + /** + * Encodes the specified UnaryFilter message. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.UnaryFilter.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.StructuredQuery.UnaryFilter + * @static + * @param {google.firestore.v1beta1.StructuredQuery.IUnaryFilter} message UnaryFilter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UnaryFilter.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.op != null && message.hasOwnProperty("op")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.op); + if (message.field != null && message.hasOwnProperty("field")) + $root.google.firestore.v1beta1.StructuredQuery.FieldReference.encode(message.field, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UnaryFilter message, length delimited. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.UnaryFilter.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.StructuredQuery.UnaryFilter + * @static + * @param {google.firestore.v1beta1.StructuredQuery.IUnaryFilter} message UnaryFilter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UnaryFilter.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UnaryFilter message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.StructuredQuery.UnaryFilter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.StructuredQuery.UnaryFilter} UnaryFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UnaryFilter.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.StructuredQuery.UnaryFilter(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.op = reader.int32(); + break; + case 2: + message.field = $root.google.firestore.v1beta1.StructuredQuery.FieldReference.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UnaryFilter message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.StructuredQuery.UnaryFilter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.StructuredQuery.UnaryFilter} UnaryFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UnaryFilter.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UnaryFilter message. + * @function verify + * @memberof google.firestore.v1beta1.StructuredQuery.UnaryFilter + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UnaryFilter.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.op != null && message.hasOwnProperty("op")) + switch (message.op) { + default: + return "op: enum value expected"; + case 0: + case 2: + case 3: + break; + } + if (message.field != null && message.hasOwnProperty("field")) { + properties.operandType = 1; + { + var error = $root.google.firestore.v1beta1.StructuredQuery.FieldReference.verify(message.field); + if (error) + return "field." + error; + } + } + return null; + }; + + /** + * 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 {number} OPERATOR_UNSPECIFIED=0 OPERATOR_UNSPECIFIED value + * @property {number} IS_NAN=2 IS_NAN value + * @property {number} IS_NULL=3 IS_NULL value + */ + UnaryFilter.Operator = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "OPERATOR_UNSPECIFIED"] = 0; + values[valuesById[2] = "IS_NAN"] = 2; + values[valuesById[3] = "IS_NULL"] = 3; + 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 a new Order instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.StructuredQuery.Order + * @static + * @param {google.firestore.v1beta1.StructuredQuery.IOrder=} [properties] Properties to set + * @returns {google.firestore.v1beta1.StructuredQuery.Order} Order instance + */ + Order.create = function create(properties) { + return new Order(properties); + }; + + /** + * Encodes the specified Order message. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.Order.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.StructuredQuery.Order + * @static + * @param {google.firestore.v1beta1.StructuredQuery.IOrder} message Order message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Order.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.field != null && message.hasOwnProperty("field")) + $root.google.firestore.v1beta1.StructuredQuery.FieldReference.encode(message.field, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.direction != null && message.hasOwnProperty("direction")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.direction); + return writer; + }; + + /** + * Encodes the specified Order message, length delimited. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.Order.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.StructuredQuery.Order + * @static + * @param {google.firestore.v1beta1.StructuredQuery.IOrder} message Order message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Order.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Order message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.StructuredQuery.Order + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.StructuredQuery.Order} Order + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Order.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.StructuredQuery.Order(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.field = $root.google.firestore.v1beta1.StructuredQuery.FieldReference.decode(reader, reader.uint32()); + break; + case 2: + message.direction = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Order message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.StructuredQuery.Order + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.StructuredQuery.Order} Order + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Order.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Order message. + * @function verify + * @memberof google.firestore.v1beta1.StructuredQuery.Order + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Order.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.field != null && message.hasOwnProperty("field")) { + var error = $root.google.firestore.v1beta1.StructuredQuery.FieldReference.verify(message.field); + if (error) + return "field." + error; + } + if (message.direction != null && message.hasOwnProperty("direction")) + switch (message.direction) { + default: + return "direction: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * 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 new FieldReference instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.StructuredQuery.FieldReference + * @static + * @param {google.firestore.v1beta1.StructuredQuery.IFieldReference=} [properties] Properties to set + * @returns {google.firestore.v1beta1.StructuredQuery.FieldReference} FieldReference instance + */ + FieldReference.create = function create(properties) { + return new FieldReference(properties); + }; + + /** + * Encodes the specified FieldReference message. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.FieldReference.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.StructuredQuery.FieldReference + * @static + * @param {google.firestore.v1beta1.StructuredQuery.IFieldReference} message FieldReference message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldReference.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.fieldPath != null && message.hasOwnProperty("fieldPath")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.fieldPath); + return writer; + }; + + /** + * Encodes the specified FieldReference message, length delimited. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.FieldReference.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.StructuredQuery.FieldReference + * @static + * @param {google.firestore.v1beta1.StructuredQuery.IFieldReference} message FieldReference message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldReference.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FieldReference message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.StructuredQuery.FieldReference + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.StructuredQuery.FieldReference} FieldReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldReference.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.StructuredQuery.FieldReference(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.fieldPath = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FieldReference message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.StructuredQuery.FieldReference + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.StructuredQuery.FieldReference} FieldReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldReference.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FieldReference message. + * @function verify + * @memberof google.firestore.v1beta1.StructuredQuery.FieldReference + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FieldReference.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.fieldPath != null && message.hasOwnProperty("fieldPath")) + if (!$util.isString(message.fieldPath)) + return "fieldPath: string expected"; + return null; + }; + + /** + * 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 new Projection instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.StructuredQuery.Projection + * @static + * @param {google.firestore.v1beta1.StructuredQuery.IProjection=} [properties] Properties to set + * @returns {google.firestore.v1beta1.StructuredQuery.Projection} Projection instance + */ + Projection.create = function create(properties) { + return new Projection(properties); + }; + + /** + * Encodes the specified Projection message. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.Projection.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.StructuredQuery.Projection + * @static + * @param {google.firestore.v1beta1.StructuredQuery.IProjection} message Projection message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Projection.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.fields != null && message.fields.length) + for (var i = 0; i < message.fields.length; ++i) + $root.google.firestore.v1beta1.StructuredQuery.FieldReference.encode(message.fields[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Projection message, length delimited. Does not implicitly {@link google.firestore.v1beta1.StructuredQuery.Projection.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.StructuredQuery.Projection + * @static + * @param {google.firestore.v1beta1.StructuredQuery.IProjection} message Projection message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Projection.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Projection message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.StructuredQuery.Projection + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.StructuredQuery.Projection} Projection + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Projection.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.StructuredQuery.Projection(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + if (!(message.fields && message.fields.length)) + message.fields = []; + message.fields.push($root.google.firestore.v1beta1.StructuredQuery.FieldReference.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Projection message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.StructuredQuery.Projection + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.StructuredQuery.Projection} Projection + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Projection.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Projection message. + * @function verify + * @memberof google.firestore.v1beta1.StructuredQuery.Projection + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Projection.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.fields != null && message.hasOwnProperty("fields")) { + if (!Array.isArray(message.fields)) + return "fields: array expected"; + for (var i = 0; i < message.fields.length; ++i) { + var error = $root.google.firestore.v1beta1.StructuredQuery.FieldReference.verify(message.fields[i]); + if (error) + return "fields." + error; + } + } + return null; + }; + + /** + * 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 {number} DIRECTION_UNSPECIFIED=0 DIRECTION_UNSPECIFIED value + * @property {number} ASCENDING=1 ASCENDING value + * @property {number} DESCENDING=2 DESCENDING value + */ + StructuredQuery.Direction = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DIRECTION_UNSPECIFIED"] = 0; + values[valuesById[1] = "ASCENDING"] = 1; + values[valuesById[2] = "DESCENDING"] = 2; + 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 new Cursor instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.Cursor + * @static + * @param {google.firestore.v1beta1.ICursor=} [properties] Properties to set + * @returns {google.firestore.v1beta1.Cursor} Cursor instance + */ + Cursor.create = function create(properties) { + return new Cursor(properties); + }; + + /** + * Encodes the specified Cursor message. Does not implicitly {@link google.firestore.v1beta1.Cursor.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.Cursor + * @static + * @param {google.firestore.v1beta1.ICursor} message Cursor message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Cursor.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.values != null && message.values.length) + for (var i = 0; i < message.values.length; ++i) + $root.google.firestore.v1beta1.Value.encode(message.values[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.before != null && message.hasOwnProperty("before")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.before); + return writer; + }; + + /** + * Encodes the specified Cursor message, length delimited. Does not implicitly {@link google.firestore.v1beta1.Cursor.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.Cursor + * @static + * @param {google.firestore.v1beta1.ICursor} message Cursor message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Cursor.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Cursor message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.Cursor + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.Cursor} Cursor + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Cursor.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.Cursor(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.values && message.values.length)) + message.values = []; + message.values.push($root.google.firestore.v1beta1.Value.decode(reader, reader.uint32())); + break; + case 2: + message.before = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Cursor message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.Cursor + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.Cursor} Cursor + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Cursor.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Cursor message. + * @function verify + * @memberof google.firestore.v1beta1.Cursor + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Cursor.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.values != null && message.hasOwnProperty("values")) { + if (!Array.isArray(message.values)) + return "values: array expected"; + for (var i = 0; i < message.values.length; ++i) { + var error = $root.google.firestore.v1beta1.Value.verify(message.values[i]); + if (error) + return "values." + error; + } + } + if (message.before != null && message.hasOwnProperty("before")) + if (typeof message.before !== "boolean") + return "before: boolean expected"; + return null; + }; + + /** + * 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 new Write instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.Write + * @static + * @param {google.firestore.v1beta1.IWrite=} [properties] Properties to set + * @returns {google.firestore.v1beta1.Write} Write instance + */ + Write.create = function create(properties) { + return new Write(properties); + }; + + /** + * Encodes the specified Write message. Does not implicitly {@link google.firestore.v1beta1.Write.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.Write + * @static + * @param {google.firestore.v1beta1.IWrite} message Write message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Write.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.update != null && message.hasOwnProperty("update")) + $root.google.firestore.v1beta1.Document.encode(message.update, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message["delete"] != null && message.hasOwnProperty("delete")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message["delete"]); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + $root.google.firestore.v1beta1.DocumentMask.encode(message.updateMask, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.currentDocument != null && message.hasOwnProperty("currentDocument")) + $root.google.firestore.v1beta1.Precondition.encode(message.currentDocument, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.transform != null && message.hasOwnProperty("transform")) + $root.google.firestore.v1beta1.DocumentTransform.encode(message.transform, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Write message, length delimited. Does not implicitly {@link google.firestore.v1beta1.Write.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.Write + * @static + * @param {google.firestore.v1beta1.IWrite} message Write message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Write.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Write message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.Write + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.Write} Write + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Write.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.Write(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.update = $root.google.firestore.v1beta1.Document.decode(reader, reader.uint32()); + break; + case 2: + message["delete"] = reader.string(); + break; + case 6: + message.transform = $root.google.firestore.v1beta1.DocumentTransform.decode(reader, reader.uint32()); + break; + case 3: + message.updateMask = $root.google.firestore.v1beta1.DocumentMask.decode(reader, reader.uint32()); + break; + case 4: + message.currentDocument = $root.google.firestore.v1beta1.Precondition.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Write message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.Write + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.Write} Write + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Write.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Write message. + * @function verify + * @memberof google.firestore.v1beta1.Write + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Write.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.update != null && message.hasOwnProperty("update")) { + properties.operation = 1; + { + var error = $root.google.firestore.v1beta1.Document.verify(message.update); + if (error) + return "update." + error; + } + } + if (message["delete"] != null && message.hasOwnProperty("delete")) { + if (properties.operation === 1) + return "operation: multiple values"; + properties.operation = 1; + if (!$util.isString(message["delete"])) + return "delete: string expected"; + } + if (message.transform != null && message.hasOwnProperty("transform")) { + if (properties.operation === 1) + return "operation: multiple values"; + properties.operation = 1; + { + var error = $root.google.firestore.v1beta1.DocumentTransform.verify(message.transform); + if (error) + return "transform." + error; + } + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.firestore.v1beta1.DocumentMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + if (message.currentDocument != null && message.hasOwnProperty("currentDocument")) { + var error = $root.google.firestore.v1beta1.Precondition.verify(message.currentDocument); + if (error) + return "currentDocument." + error; + } + return null; + }; + + /** + * 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 new DocumentTransform instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.DocumentTransform + * @static + * @param {google.firestore.v1beta1.IDocumentTransform=} [properties] Properties to set + * @returns {google.firestore.v1beta1.DocumentTransform} DocumentTransform instance + */ + DocumentTransform.create = function create(properties) { + return new DocumentTransform(properties); + }; + + /** + * Encodes the specified DocumentTransform message. Does not implicitly {@link google.firestore.v1beta1.DocumentTransform.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.DocumentTransform + * @static + * @param {google.firestore.v1beta1.IDocumentTransform} message DocumentTransform message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DocumentTransform.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.document != null && message.hasOwnProperty("document")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.document); + if (message.fieldTransforms != null && message.fieldTransforms.length) + for (var i = 0; i < message.fieldTransforms.length; ++i) + $root.google.firestore.v1beta1.DocumentTransform.FieldTransform.encode(message.fieldTransforms[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified DocumentTransform message, length delimited. Does not implicitly {@link google.firestore.v1beta1.DocumentTransform.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.DocumentTransform + * @static + * @param {google.firestore.v1beta1.IDocumentTransform} message DocumentTransform message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DocumentTransform.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DocumentTransform message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.DocumentTransform + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.DocumentTransform} DocumentTransform + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DocumentTransform.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.DocumentTransform(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.document = reader.string(); + break; + case 2: + if (!(message.fieldTransforms && message.fieldTransforms.length)) + message.fieldTransforms = []; + message.fieldTransforms.push($root.google.firestore.v1beta1.DocumentTransform.FieldTransform.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DocumentTransform message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.DocumentTransform + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.DocumentTransform} DocumentTransform + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DocumentTransform.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DocumentTransform message. + * @function verify + * @memberof google.firestore.v1beta1.DocumentTransform + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DocumentTransform.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.document != null && message.hasOwnProperty("document")) + if (!$util.isString(message.document)) + return "document: string expected"; + if (message.fieldTransforms != null && message.hasOwnProperty("fieldTransforms")) { + if (!Array.isArray(message.fieldTransforms)) + return "fieldTransforms: array expected"; + for (var i = 0; i < message.fieldTransforms.length; ++i) { + var error = $root.google.firestore.v1beta1.DocumentTransform.FieldTransform.verify(message.fieldTransforms[i]); + if (error) + return "fieldTransforms." + error; + } + } + return null; + }; + + /** + * 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.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 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"|"appendMissingElements"|"removeAllFromArray"|undefined} transformType + * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * @instance + */ + Object.defineProperty(FieldTransform.prototype, "transformType", { + get: $util.oneOfGetter($oneOfFields = ["setToServerValue", "appendMissingElements", "removeAllFromArray"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new FieldTransform instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * @static + * @param {google.firestore.v1beta1.DocumentTransform.IFieldTransform=} [properties] Properties to set + * @returns {google.firestore.v1beta1.DocumentTransform.FieldTransform} FieldTransform instance + */ + FieldTransform.create = function create(properties) { + return new FieldTransform(properties); + }; + + /** + * Encodes the specified FieldTransform message. Does not implicitly {@link google.firestore.v1beta1.DocumentTransform.FieldTransform.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * @static + * @param {google.firestore.v1beta1.DocumentTransform.IFieldTransform} message FieldTransform message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldTransform.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.fieldPath != null && message.hasOwnProperty("fieldPath")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.fieldPath); + if (message.setToServerValue != null && message.hasOwnProperty("setToServerValue")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.setToServerValue); + if (message.appendMissingElements != null && message.hasOwnProperty("appendMissingElements")) + $root.google.firestore.v1beta1.ArrayValue.encode(message.appendMissingElements, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.removeAllFromArray != null && message.hasOwnProperty("removeAllFromArray")) + $root.google.firestore.v1beta1.ArrayValue.encode(message.removeAllFromArray, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified FieldTransform message, length delimited. Does not implicitly {@link google.firestore.v1beta1.DocumentTransform.FieldTransform.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * @static + * @param {google.firestore.v1beta1.DocumentTransform.IFieldTransform} message FieldTransform message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldTransform.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FieldTransform message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.DocumentTransform.FieldTransform} FieldTransform + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldTransform.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.DocumentTransform.FieldTransform(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.fieldPath = reader.string(); + break; + case 2: + message.setToServerValue = reader.int32(); + break; + case 6: + message.appendMissingElements = $root.google.firestore.v1beta1.ArrayValue.decode(reader, reader.uint32()); + break; + case 7: + message.removeAllFromArray = $root.google.firestore.v1beta1.ArrayValue.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FieldTransform message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.DocumentTransform.FieldTransform} FieldTransform + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldTransform.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FieldTransform message. + * @function verify + * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FieldTransform.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.fieldPath != null && message.hasOwnProperty("fieldPath")) + if (!$util.isString(message.fieldPath)) + return "fieldPath: string expected"; + if (message.setToServerValue != null && message.hasOwnProperty("setToServerValue")) { + properties.transformType = 1; + switch (message.setToServerValue) { + default: + return "setToServerValue: enum value expected"; + case 0: + case 1: + break; + } + } + if (message.appendMissingElements != null && message.hasOwnProperty("appendMissingElements")) { + if (properties.transformType === 1) + return "transformType: multiple values"; + properties.transformType = 1; + { + var error = $root.google.firestore.v1beta1.ArrayValue.verify(message.appendMissingElements); + if (error) + return "appendMissingElements." + error; + } + } + if (message.removeAllFromArray != null && message.hasOwnProperty("removeAllFromArray")) { + if (properties.transformType === 1) + return "transformType: multiple values"; + properties.transformType = 1; + { + var error = $root.google.firestore.v1beta1.ArrayValue.verify(message.removeAllFromArray); + if (error) + return "removeAllFromArray." + error; + } + } + return null; + }; + + /** + * 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.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.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 {number} SERVER_VALUE_UNSPECIFIED=0 SERVER_VALUE_UNSPECIFIED value + * @property {number} REQUEST_TIME=1 REQUEST_TIME value + */ + FieldTransform.ServerValue = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SERVER_VALUE_UNSPECIFIED"] = 0; + values[valuesById[1] = "REQUEST_TIME"] = 1; + 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 new WriteResult instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.WriteResult + * @static + * @param {google.firestore.v1beta1.IWriteResult=} [properties] Properties to set + * @returns {google.firestore.v1beta1.WriteResult} WriteResult instance + */ + WriteResult.create = function create(properties) { + return new WriteResult(properties); + }; + + /** + * Encodes the specified WriteResult message. Does not implicitly {@link google.firestore.v1beta1.WriteResult.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.WriteResult + * @static + * @param {google.firestore.v1beta1.IWriteResult} message WriteResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WriteResult.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.updateTime != null && message.hasOwnProperty("updateTime")) + $root.google.protobuf.Timestamp.encode(message.updateTime, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.transformResults != null && message.transformResults.length) + for (var i = 0; i < message.transformResults.length; ++i) + $root.google.firestore.v1beta1.Value.encode(message.transformResults[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified WriteResult message, length delimited. Does not implicitly {@link google.firestore.v1beta1.WriteResult.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.WriteResult + * @static + * @param {google.firestore.v1beta1.IWriteResult} message WriteResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WriteResult.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a WriteResult message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.WriteResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.WriteResult} WriteResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WriteResult.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.WriteResult(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.updateTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + case 2: + if (!(message.transformResults && message.transformResults.length)) + message.transformResults = []; + message.transformResults.push($root.google.firestore.v1beta1.Value.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a WriteResult message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.WriteResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.WriteResult} WriteResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WriteResult.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a WriteResult message. + * @function verify + * @memberof google.firestore.v1beta1.WriteResult + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + WriteResult.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.updateTime != null && message.hasOwnProperty("updateTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.updateTime); + if (error) + return "updateTime." + error; + } + if (message.transformResults != null && message.hasOwnProperty("transformResults")) { + if (!Array.isArray(message.transformResults)) + return "transformResults: array expected"; + for (var i = 0; i < message.transformResults.length; ++i) { + var error = $root.google.firestore.v1beta1.Value.verify(message.transformResults[i]); + if (error) + return "transformResults." + error; + } + } + return null; + }; + + /** + * 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 new DocumentChange instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.DocumentChange + * @static + * @param {google.firestore.v1beta1.IDocumentChange=} [properties] Properties to set + * @returns {google.firestore.v1beta1.DocumentChange} DocumentChange instance + */ + DocumentChange.create = function create(properties) { + return new DocumentChange(properties); + }; + + /** + * Encodes the specified DocumentChange message. Does not implicitly {@link google.firestore.v1beta1.DocumentChange.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.DocumentChange + * @static + * @param {google.firestore.v1beta1.IDocumentChange} message DocumentChange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DocumentChange.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.document != null && message.hasOwnProperty("document")) + $root.google.firestore.v1beta1.Document.encode(message.document, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.targetIds != null && message.targetIds.length) { + writer.uint32(/* id 5, wireType 2 =*/42).fork(); + for (var i = 0; i < message.targetIds.length; ++i) + writer.int32(message.targetIds[i]); + writer.ldelim(); + } + if (message.removedTargetIds != null && message.removedTargetIds.length) { + writer.uint32(/* id 6, wireType 2 =*/50).fork(); + for (var i = 0; i < message.removedTargetIds.length; ++i) + writer.int32(message.removedTargetIds[i]); + writer.ldelim(); + } + return writer; + }; + + /** + * Encodes the specified DocumentChange message, length delimited. Does not implicitly {@link google.firestore.v1beta1.DocumentChange.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.DocumentChange + * @static + * @param {google.firestore.v1beta1.IDocumentChange} message DocumentChange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DocumentChange.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DocumentChange message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.DocumentChange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.DocumentChange} DocumentChange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DocumentChange.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.DocumentChange(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.document = $root.google.firestore.v1beta1.Document.decode(reader, reader.uint32()); + break; + case 5: + if (!(message.targetIds && message.targetIds.length)) + message.targetIds = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.targetIds.push(reader.int32()); + } else + message.targetIds.push(reader.int32()); + break; + case 6: + if (!(message.removedTargetIds && message.removedTargetIds.length)) + message.removedTargetIds = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.removedTargetIds.push(reader.int32()); + } else + message.removedTargetIds.push(reader.int32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DocumentChange message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.DocumentChange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.DocumentChange} DocumentChange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DocumentChange.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DocumentChange message. + * @function verify + * @memberof google.firestore.v1beta1.DocumentChange + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DocumentChange.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.document != null && message.hasOwnProperty("document")) { + var error = $root.google.firestore.v1beta1.Document.verify(message.document); + if (error) + return "document." + error; + } + if (message.targetIds != null && message.hasOwnProperty("targetIds")) { + if (!Array.isArray(message.targetIds)) + return "targetIds: array expected"; + for (var i = 0; i < message.targetIds.length; ++i) + if (!$util.isInteger(message.targetIds[i])) + return "targetIds: integer[] expected"; + } + if (message.removedTargetIds != null && message.hasOwnProperty("removedTargetIds")) { + if (!Array.isArray(message.removedTargetIds)) + return "removedTargetIds: array expected"; + for (var i = 0; i < message.removedTargetIds.length; ++i) + if (!$util.isInteger(message.removedTargetIds[i])) + return "removedTargetIds: integer[] expected"; + } + return null; + }; + + /** + * 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 new DocumentDelete instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.DocumentDelete + * @static + * @param {google.firestore.v1beta1.IDocumentDelete=} [properties] Properties to set + * @returns {google.firestore.v1beta1.DocumentDelete} DocumentDelete instance + */ + DocumentDelete.create = function create(properties) { + return new DocumentDelete(properties); + }; + + /** + * Encodes the specified DocumentDelete message. Does not implicitly {@link google.firestore.v1beta1.DocumentDelete.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.DocumentDelete + * @static + * @param {google.firestore.v1beta1.IDocumentDelete} message DocumentDelete message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DocumentDelete.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.document != null && message.hasOwnProperty("document")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.document); + if (message.readTime != null && message.hasOwnProperty("readTime")) + $root.google.protobuf.Timestamp.encode(message.readTime, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.removedTargetIds != null && message.removedTargetIds.length) { + writer.uint32(/* id 6, wireType 2 =*/50).fork(); + for (var i = 0; i < message.removedTargetIds.length; ++i) + writer.int32(message.removedTargetIds[i]); + writer.ldelim(); + } + return writer; + }; + + /** + * Encodes the specified DocumentDelete message, length delimited. Does not implicitly {@link google.firestore.v1beta1.DocumentDelete.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.DocumentDelete + * @static + * @param {google.firestore.v1beta1.IDocumentDelete} message DocumentDelete message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DocumentDelete.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DocumentDelete message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.DocumentDelete + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.DocumentDelete} DocumentDelete + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DocumentDelete.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.DocumentDelete(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.document = reader.string(); + break; + case 6: + if (!(message.removedTargetIds && message.removedTargetIds.length)) + message.removedTargetIds = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.removedTargetIds.push(reader.int32()); + } else + message.removedTargetIds.push(reader.int32()); + break; + case 4: + message.readTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DocumentDelete message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.DocumentDelete + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.DocumentDelete} DocumentDelete + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DocumentDelete.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DocumentDelete message. + * @function verify + * @memberof google.firestore.v1beta1.DocumentDelete + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DocumentDelete.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.document != null && message.hasOwnProperty("document")) + if (!$util.isString(message.document)) + return "document: string expected"; + if (message.removedTargetIds != null && message.hasOwnProperty("removedTargetIds")) { + if (!Array.isArray(message.removedTargetIds)) + return "removedTargetIds: array expected"; + for (var i = 0; i < message.removedTargetIds.length; ++i) + if (!$util.isInteger(message.removedTargetIds[i])) + return "removedTargetIds: integer[] expected"; + } + if (message.readTime != null && message.hasOwnProperty("readTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.readTime); + if (error) + return "readTime." + error; + } + return 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 new DocumentRemove instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.DocumentRemove + * @static + * @param {google.firestore.v1beta1.IDocumentRemove=} [properties] Properties to set + * @returns {google.firestore.v1beta1.DocumentRemove} DocumentRemove instance + */ + DocumentRemove.create = function create(properties) { + return new DocumentRemove(properties); + }; + + /** + * Encodes the specified DocumentRemove message. Does not implicitly {@link google.firestore.v1beta1.DocumentRemove.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.DocumentRemove + * @static + * @param {google.firestore.v1beta1.IDocumentRemove} message DocumentRemove message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DocumentRemove.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.document != null && message.hasOwnProperty("document")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.document); + if (message.removedTargetIds != null && message.removedTargetIds.length) { + writer.uint32(/* id 2, wireType 2 =*/18).fork(); + for (var i = 0; i < message.removedTargetIds.length; ++i) + writer.int32(message.removedTargetIds[i]); + writer.ldelim(); + } + if (message.readTime != null && message.hasOwnProperty("readTime")) + $root.google.protobuf.Timestamp.encode(message.readTime, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified DocumentRemove message, length delimited. Does not implicitly {@link google.firestore.v1beta1.DocumentRemove.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.DocumentRemove + * @static + * @param {google.firestore.v1beta1.IDocumentRemove} message DocumentRemove message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DocumentRemove.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DocumentRemove message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.DocumentRemove + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.DocumentRemove} DocumentRemove + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DocumentRemove.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.DocumentRemove(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.document = reader.string(); + break; + case 2: + if (!(message.removedTargetIds && message.removedTargetIds.length)) + message.removedTargetIds = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.removedTargetIds.push(reader.int32()); + } else + message.removedTargetIds.push(reader.int32()); + break; + case 4: + message.readTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DocumentRemove message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.DocumentRemove + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.DocumentRemove} DocumentRemove + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DocumentRemove.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DocumentRemove message. + * @function verify + * @memberof google.firestore.v1beta1.DocumentRemove + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DocumentRemove.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.document != null && message.hasOwnProperty("document")) + if (!$util.isString(message.document)) + return "document: string expected"; + if (message.removedTargetIds != null && message.hasOwnProperty("removedTargetIds")) { + if (!Array.isArray(message.removedTargetIds)) + return "removedTargetIds: array expected"; + for (var i = 0; i < message.removedTargetIds.length; ++i) + if (!$util.isInteger(message.removedTargetIds[i])) + return "removedTargetIds: integer[] expected"; + } + if (message.readTime != null && message.hasOwnProperty("readTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.readTime); + if (error) + return "readTime." + error; + } + return 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 a new ExistenceFilter instance using the specified properties. + * @function create + * @memberof google.firestore.v1beta1.ExistenceFilter + * @static + * @param {google.firestore.v1beta1.IExistenceFilter=} [properties] Properties to set + * @returns {google.firestore.v1beta1.ExistenceFilter} ExistenceFilter instance + */ + ExistenceFilter.create = function create(properties) { + return new ExistenceFilter(properties); + }; + + /** + * Encodes the specified ExistenceFilter message. Does not implicitly {@link google.firestore.v1beta1.ExistenceFilter.verify|verify} messages. + * @function encode + * @memberof google.firestore.v1beta1.ExistenceFilter + * @static + * @param {google.firestore.v1beta1.IExistenceFilter} message ExistenceFilter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExistenceFilter.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.targetId != null && message.hasOwnProperty("targetId")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.targetId); + if (message.count != null && message.hasOwnProperty("count")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.count); + return writer; + }; + + /** + * Encodes the specified ExistenceFilter message, length delimited. Does not implicitly {@link google.firestore.v1beta1.ExistenceFilter.verify|verify} messages. + * @function encodeDelimited + * @memberof google.firestore.v1beta1.ExistenceFilter + * @static + * @param {google.firestore.v1beta1.IExistenceFilter} message ExistenceFilter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExistenceFilter.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExistenceFilter message from the specified reader or buffer. + * @function decode + * @memberof google.firestore.v1beta1.ExistenceFilter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.firestore.v1beta1.ExistenceFilter} ExistenceFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExistenceFilter.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.firestore.v1beta1.ExistenceFilter(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.targetId = reader.int32(); + break; + case 2: + message.count = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExistenceFilter message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.firestore.v1beta1.ExistenceFilter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.firestore.v1beta1.ExistenceFilter} ExistenceFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExistenceFilter.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExistenceFilter message. + * @function verify + * @memberof google.firestore.v1beta1.ExistenceFilter + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExistenceFilter.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.targetId != null && message.hasOwnProperty("targetId")) + if (!$util.isInteger(message.targetId)) + return "targetId: integer expected"; + if (message.count != null && message.hasOwnProperty("count")) + if (!$util.isInteger(message.count)) + return "count: integer expected"; + return null; + }; + + /** + * 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; + })(); + + 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; + + /** + * Creates a new Http instance using the specified properties. + * @function create + * @memberof google.api.Http + * @static + * @param {google.api.IHttp=} [properties] Properties to set + * @returns {google.api.Http} Http instance + */ + Http.create = function create(properties) { + return new Http(properties); + }; + + /** + * Encodes the specified Http message. Does not implicitly {@link google.api.Http.verify|verify} messages. + * @function encode + * @memberof google.api.Http + * @static + * @param {google.api.IHttp} message Http message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Http.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.rules != null && message.rules.length) + for (var i = 0; i < message.rules.length; ++i) + $root.google.api.HttpRule.encode(message.rules[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Http message, length delimited. Does not implicitly {@link google.api.Http.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.Http + * @static + * @param {google.api.IHttp} message Http message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Http.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Http message from the specified reader or buffer. + * @function decode + * @memberof google.api.Http + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.Http} Http + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Http.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.Http(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.rules && message.rules.length)) + message.rules = []; + message.rules.push($root.google.api.HttpRule.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Http message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.Http + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.Http} Http + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Http.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Http message. + * @function verify + * @memberof google.api.Http + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Http.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.rules != null && message.hasOwnProperty("rules")) { + if (!Array.isArray(message.rules)) + return "rules: array expected"; + for (var i = 0; i < message.rules.length; ++i) { + var error = $root.google.api.HttpRule.verify(message.rules[i]); + if (error) + return "rules." + error; + } + } + return null; + }; + + /** + * 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 new HttpRule instance using the specified properties. + * @function create + * @memberof google.api.HttpRule + * @static + * @param {google.api.IHttpRule=} [properties] Properties to set + * @returns {google.api.HttpRule} HttpRule instance + */ + HttpRule.create = function create(properties) { + return new HttpRule(properties); + }; + + /** + * Encodes the specified HttpRule message. Does not implicitly {@link google.api.HttpRule.verify|verify} messages. + * @function encode + * @memberof google.api.HttpRule + * @static + * @param {google.api.IHttpRule} message HttpRule message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HttpRule.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.selector != null && message.hasOwnProperty("selector")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.selector); + if (message.get != null && message.hasOwnProperty("get")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.get); + if (message.put != null && message.hasOwnProperty("put")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.put); + if (message.post != null && message.hasOwnProperty("post")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.post); + if (message["delete"] != null && message.hasOwnProperty("delete")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message["delete"]); + if (message.patch != null && message.hasOwnProperty("patch")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.patch); + if (message.body != null && message.hasOwnProperty("body")) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.body); + if (message.custom != null && message.hasOwnProperty("custom")) + $root.google.api.CustomHttpPattern.encode(message.custom, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.additionalBindings != null && message.additionalBindings.length) + for (var i = 0; i < message.additionalBindings.length; ++i) + $root.google.api.HttpRule.encode(message.additionalBindings[i], writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified HttpRule message, length delimited. Does not implicitly {@link google.api.HttpRule.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.HttpRule + * @static + * @param {google.api.IHttpRule} message HttpRule message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HttpRule.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a HttpRule message from the specified reader or buffer. + * @function decode + * @memberof google.api.HttpRule + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.HttpRule} HttpRule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HttpRule.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.HttpRule(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message["delete"] = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = $root.google.api.CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 1: + message.selector = reader.string(); + break; + case 7: + message.body = reader.string(); + break; + case 11: + if (!(message.additionalBindings && message.additionalBindings.length)) + message.additionalBindings = []; + message.additionalBindings.push($root.google.api.HttpRule.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a HttpRule message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.HttpRule + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.HttpRule} HttpRule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HttpRule.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a HttpRule message. + * @function verify + * @memberof google.api.HttpRule + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + HttpRule.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.get != null && message.hasOwnProperty("get")) { + properties.pattern = 1; + if (!$util.isString(message.get)) + return "get: string expected"; + } + if (message.put != null && message.hasOwnProperty("put")) { + if (properties.pattern === 1) + return "pattern: multiple values"; + properties.pattern = 1; + if (!$util.isString(message.put)) + return "put: string expected"; + } + if (message.post != null && message.hasOwnProperty("post")) { + if (properties.pattern === 1) + return "pattern: multiple values"; + properties.pattern = 1; + if (!$util.isString(message.post)) + return "post: string expected"; + } + if (message["delete"] != null && message.hasOwnProperty("delete")) { + if (properties.pattern === 1) + return "pattern: multiple values"; + properties.pattern = 1; + if (!$util.isString(message["delete"])) + return "delete: string expected"; + } + if (message.patch != null && message.hasOwnProperty("patch")) { + if (properties.pattern === 1) + return "pattern: multiple values"; + properties.pattern = 1; + if (!$util.isString(message.patch)) + return "patch: string expected"; + } + if (message.custom != null && message.hasOwnProperty("custom")) { + if (properties.pattern === 1) + return "pattern: multiple values"; + properties.pattern = 1; + { + var error = $root.google.api.CustomHttpPattern.verify(message.custom); + if (error) + return "custom." + error; + } + } + if (message.selector != null && message.hasOwnProperty("selector")) + if (!$util.isString(message.selector)) + return "selector: string expected"; + if (message.body != null && message.hasOwnProperty("body")) + if (!$util.isString(message.body)) + return "body: string expected"; + if (message.additionalBindings != null && message.hasOwnProperty("additionalBindings")) { + if (!Array.isArray(message.additionalBindings)) + return "additionalBindings: array expected"; + for (var i = 0; i < message.additionalBindings.length; ++i) { + var error = $root.google.api.HttpRule.verify(message.additionalBindings[i]); + if (error) + return "additionalBindings." + error; + } + } + return null; + }; + + /** + * 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 new CustomHttpPattern instance using the specified properties. + * @function create + * @memberof google.api.CustomHttpPattern + * @static + * @param {google.api.ICustomHttpPattern=} [properties] Properties to set + * @returns {google.api.CustomHttpPattern} CustomHttpPattern instance + */ + CustomHttpPattern.create = function create(properties) { + return new CustomHttpPattern(properties); + }; + + /** + * Encodes the specified CustomHttpPattern message. Does not implicitly {@link google.api.CustomHttpPattern.verify|verify} messages. + * @function encode + * @memberof google.api.CustomHttpPattern + * @static + * @param {google.api.ICustomHttpPattern} message CustomHttpPattern message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CustomHttpPattern.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.kind != null && message.hasOwnProperty("kind")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.kind); + if (message.path != null && message.hasOwnProperty("path")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.path); + return writer; + }; + + /** + * Encodes the specified CustomHttpPattern message, length delimited. Does not implicitly {@link google.api.CustomHttpPattern.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.CustomHttpPattern + * @static + * @param {google.api.ICustomHttpPattern} message CustomHttpPattern message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CustomHttpPattern.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CustomHttpPattern message from the specified reader or buffer. + * @function decode + * @memberof google.api.CustomHttpPattern + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.CustomHttpPattern} CustomHttpPattern + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CustomHttpPattern.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.CustomHttpPattern(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CustomHttpPattern message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.CustomHttpPattern + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.CustomHttpPattern} CustomHttpPattern + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CustomHttpPattern.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CustomHttpPattern message. + * @function verify + * @memberof google.api.CustomHttpPattern + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CustomHttpPattern.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.kind != null && message.hasOwnProperty("kind")) + if (!$util.isString(message.kind)) + return "kind: string expected"; + if (message.path != null && message.hasOwnProperty("path")) + if (!$util.isString(message.path)) + return "path: string expected"; + return null; + }; + + /** + * 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; + })(); + + 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; + + /** + * Creates a new FileDescriptorSet instance using the specified properties. + * @function create + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet instance + */ + FileDescriptorSet.create = function create(properties) { + return new FileDescriptorSet(properties); + }; + + /** + * Encodes the specified FileDescriptorSet message. Does not implicitly {@link google.protobuf.FileDescriptorSet.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.IFileDescriptorSet} message FileDescriptorSet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileDescriptorSet.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.file != null && message.file.length) + for (var i = 0; i < message.file.length; ++i) + $root.google.protobuf.FileDescriptorProto.encode(message.file[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified FileDescriptorSet message, length delimited. Does not implicitly {@link google.protobuf.FileDescriptorSet.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.IFileDescriptorSet} message FileDescriptorSet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileDescriptorSet.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FileDescriptorSet message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileDescriptorSet.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FileDescriptorSet(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.file && message.file.length)) + message.file = []; + message.file.push($root.google.protobuf.FileDescriptorProto.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FileDescriptorSet message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileDescriptorSet.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FileDescriptorSet message. + * @function verify + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FileDescriptorSet.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.file != null && message.hasOwnProperty("file")) { + if (!Array.isArray(message.file)) + return "file: array expected"; + for (var i = 0; i < message.file.length; ++i) { + var error = $root.google.protobuf.FileDescriptorProto.verify(message.file[i]); + if (error) + return "file." + error; + } + } + return null; + }; + + /** + * 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 new FileDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {google.protobuf.IFileDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.FileDescriptorProto} FileDescriptorProto instance + */ + FileDescriptorProto.create = function create(properties) { + return new FileDescriptorProto(properties); + }; + + /** + * Encodes the specified FileDescriptorProto message. Does not implicitly {@link google.protobuf.FileDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {google.protobuf.IFileDescriptorProto} message FileDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileDescriptorProto.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && message.hasOwnProperty("name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message["package"] != null && message.hasOwnProperty("package")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message["package"]); + if (message.dependency != null && message.dependency.length) + for (var i = 0; i < message.dependency.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.dependency[i]); + if (message.messageType != null && message.messageType.length) + for (var i = 0; i < message.messageType.length; ++i) + $root.google.protobuf.DescriptorProto.encode(message.messageType[i], writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.enumType != null && message.enumType.length) + for (var i = 0; i < message.enumType.length; ++i) + $root.google.protobuf.EnumDescriptorProto.encode(message.enumType[i], writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.service != null && message.service.length) + for (var i = 0; i < message.service.length; ++i) + $root.google.protobuf.ServiceDescriptorProto.encode(message.service[i], writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.extension != null && message.extension.length) + for (var i = 0; i < message.extension.length; ++i) + $root.google.protobuf.FieldDescriptorProto.encode(message.extension[i], writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.options != null && message.hasOwnProperty("options")) + $root.google.protobuf.FileOptions.encode(message.options, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.sourceCodeInfo != null && message.hasOwnProperty("sourceCodeInfo")) + $root.google.protobuf.SourceCodeInfo.encode(message.sourceCodeInfo, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.publicDependency != null && message.publicDependency.length) + for (var i = 0; i < message.publicDependency.length; ++i) + writer.uint32(/* id 10, wireType 0 =*/80).int32(message.publicDependency[i]); + if (message.weakDependency != null && message.weakDependency.length) + for (var i = 0; i < message.weakDependency.length; ++i) + writer.uint32(/* id 11, wireType 0 =*/88).int32(message.weakDependency[i]); + if (message.syntax != null && message.hasOwnProperty("syntax")) + writer.uint32(/* id 12, wireType 2 =*/98).string(message.syntax); + return writer; + }; + + /** + * Encodes the specified FileDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.FileDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {google.protobuf.IFileDescriptorProto} message FileDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileDescriptorProto.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FileDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FileDescriptorProto} FileDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FileDescriptorProto(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message["package"] = reader.string(); + break; + case 3: + if (!(message.dependency && message.dependency.length)) + message.dependency = []; + message.dependency.push(reader.string()); + break; + case 10: + if (!(message.publicDependency && message.publicDependency.length)) + message.publicDependency = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.publicDependency.push(reader.int32()); + } else + message.publicDependency.push(reader.int32()); + break; + case 11: + if (!(message.weakDependency && message.weakDependency.length)) + message.weakDependency = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.weakDependency.push(reader.int32()); + } else + message.weakDependency.push(reader.int32()); + break; + case 4: + if (!(message.messageType && message.messageType.length)) + message.messageType = []; + message.messageType.push($root.google.protobuf.DescriptorProto.decode(reader, reader.uint32())); + break; + case 5: + if (!(message.enumType && message.enumType.length)) + message.enumType = []; + message.enumType.push($root.google.protobuf.EnumDescriptorProto.decode(reader, reader.uint32())); + break; + case 6: + if (!(message.service && message.service.length)) + message.service = []; + message.service.push($root.google.protobuf.ServiceDescriptorProto.decode(reader, reader.uint32())); + break; + case 7: + if (!(message.extension && message.extension.length)) + message.extension = []; + message.extension.push($root.google.protobuf.FieldDescriptorProto.decode(reader, reader.uint32())); + break; + case 8: + message.options = $root.google.protobuf.FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = $root.google.protobuf.SourceCodeInfo.decode(reader, reader.uint32()); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FileDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FileDescriptorProto} FileDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileDescriptorProto.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FileDescriptorProto message. + * @function verify + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FileDescriptorProto.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message["package"] != null && message.hasOwnProperty("package")) + if (!$util.isString(message["package"])) + return "package: string expected"; + if (message.dependency != null && message.hasOwnProperty("dependency")) { + if (!Array.isArray(message.dependency)) + return "dependency: array expected"; + for (var i = 0; i < message.dependency.length; ++i) + if (!$util.isString(message.dependency[i])) + return "dependency: string[] expected"; + } + if (message.publicDependency != null && message.hasOwnProperty("publicDependency")) { + if (!Array.isArray(message.publicDependency)) + return "publicDependency: array expected"; + for (var i = 0; i < message.publicDependency.length; ++i) + if (!$util.isInteger(message.publicDependency[i])) + return "publicDependency: integer[] expected"; + } + if (message.weakDependency != null && message.hasOwnProperty("weakDependency")) { + if (!Array.isArray(message.weakDependency)) + return "weakDependency: array expected"; + for (var i = 0; i < message.weakDependency.length; ++i) + if (!$util.isInteger(message.weakDependency[i])) + return "weakDependency: integer[] expected"; + } + if (message.messageType != null && message.hasOwnProperty("messageType")) { + if (!Array.isArray(message.messageType)) + return "messageType: array expected"; + for (var i = 0; i < message.messageType.length; ++i) { + var error = $root.google.protobuf.DescriptorProto.verify(message.messageType[i]); + if (error) + return "messageType." + error; + } + } + if (message.enumType != null && message.hasOwnProperty("enumType")) { + if (!Array.isArray(message.enumType)) + return "enumType: array expected"; + for (var i = 0; i < message.enumType.length; ++i) { + var error = $root.google.protobuf.EnumDescriptorProto.verify(message.enumType[i]); + if (error) + return "enumType." + error; + } + } + if (message.service != null && message.hasOwnProperty("service")) { + if (!Array.isArray(message.service)) + return "service: array expected"; + for (var i = 0; i < message.service.length; ++i) { + var error = $root.google.protobuf.ServiceDescriptorProto.verify(message.service[i]); + if (error) + return "service." + error; + } + } + if (message.extension != null && message.hasOwnProperty("extension")) { + if (!Array.isArray(message.extension)) + return "extension: array expected"; + for (var i = 0; i < message.extension.length; ++i) { + var error = $root.google.protobuf.FieldDescriptorProto.verify(message.extension[i]); + if (error) + return "extension." + error; + } + } + if (message.options != null && message.hasOwnProperty("options")) { + var error = $root.google.protobuf.FileOptions.verify(message.options); + if (error) + return "options." + error; + } + if (message.sourceCodeInfo != null && message.hasOwnProperty("sourceCodeInfo")) { + var error = $root.google.protobuf.SourceCodeInfo.verify(message.sourceCodeInfo); + if (error) + return "sourceCodeInfo." + error; + } + if (message.syntax != null && message.hasOwnProperty("syntax")) + if (!$util.isString(message.syntax)) + return "syntax: string expected"; + return null; + }; + + /** + * 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 new DescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.DescriptorProto + * @static + * @param {google.protobuf.IDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.DescriptorProto} DescriptorProto instance + */ + DescriptorProto.create = function create(properties) { + return new DescriptorProto(properties); + }; + + /** + * Encodes the specified DescriptorProto message. Does not implicitly {@link google.protobuf.DescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.DescriptorProto + * @static + * @param {google.protobuf.IDescriptorProto} message DescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DescriptorProto.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && message.hasOwnProperty("name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.field != null && message.field.length) + for (var i = 0; i < message.field.length; ++i) + $root.google.protobuf.FieldDescriptorProto.encode(message.field[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.nestedType != null && message.nestedType.length) + for (var i = 0; i < message.nestedType.length; ++i) + $root.google.protobuf.DescriptorProto.encode(message.nestedType[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.enumType != null && message.enumType.length) + for (var i = 0; i < message.enumType.length; ++i) + $root.google.protobuf.EnumDescriptorProto.encode(message.enumType[i], writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.extensionRange != null && message.extensionRange.length) + for (var i = 0; i < message.extensionRange.length; ++i) + $root.google.protobuf.DescriptorProto.ExtensionRange.encode(message.extensionRange[i], writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.extension != null && message.extension.length) + for (var i = 0; i < message.extension.length; ++i) + $root.google.protobuf.FieldDescriptorProto.encode(message.extension[i], writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.options != null && message.hasOwnProperty("options")) + $root.google.protobuf.MessageOptions.encode(message.options, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.oneofDecl != null && message.oneofDecl.length) + for (var i = 0; i < message.oneofDecl.length; ++i) + $root.google.protobuf.OneofDescriptorProto.encode(message.oneofDecl[i], writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.reservedRange != null && message.reservedRange.length) + for (var i = 0; i < message.reservedRange.length; ++i) + $root.google.protobuf.DescriptorProto.ReservedRange.encode(message.reservedRange[i], writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.reservedName != null && message.reservedName.length) + for (var i = 0; i < message.reservedName.length; ++i) + writer.uint32(/* id 10, wireType 2 =*/82).string(message.reservedName[i]); + return writer; + }; + + /** + * Encodes the specified DescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.DescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.DescriptorProto + * @static + * @param {google.protobuf.IDescriptorProto} message DescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DescriptorProto.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.DescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.DescriptorProto} DescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.DescriptorProto(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + if (!(message.field && message.field.length)) + message.field = []; + message.field.push($root.google.protobuf.FieldDescriptorProto.decode(reader, reader.uint32())); + break; + case 6: + if (!(message.extension && message.extension.length)) + message.extension = []; + message.extension.push($root.google.protobuf.FieldDescriptorProto.decode(reader, reader.uint32())); + break; + case 3: + if (!(message.nestedType && message.nestedType.length)) + message.nestedType = []; + message.nestedType.push($root.google.protobuf.DescriptorProto.decode(reader, reader.uint32())); + break; + case 4: + if (!(message.enumType && message.enumType.length)) + message.enumType = []; + message.enumType.push($root.google.protobuf.EnumDescriptorProto.decode(reader, reader.uint32())); + break; + case 5: + if (!(message.extensionRange && message.extensionRange.length)) + message.extensionRange = []; + message.extensionRange.push($root.google.protobuf.DescriptorProto.ExtensionRange.decode(reader, reader.uint32())); + break; + case 8: + if (!(message.oneofDecl && message.oneofDecl.length)) + message.oneofDecl = []; + message.oneofDecl.push($root.google.protobuf.OneofDescriptorProto.decode(reader, reader.uint32())); + break; + case 7: + message.options = $root.google.protobuf.MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + if (!(message.reservedRange && message.reservedRange.length)) + message.reservedRange = []; + message.reservedRange.push($root.google.protobuf.DescriptorProto.ReservedRange.decode(reader, reader.uint32())); + break; + case 10: + if (!(message.reservedName && message.reservedName.length)) + message.reservedName = []; + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.DescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.DescriptorProto} DescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DescriptorProto.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DescriptorProto message. + * @function verify + * @memberof google.protobuf.DescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DescriptorProto.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.field != null && message.hasOwnProperty("field")) { + if (!Array.isArray(message.field)) + return "field: array expected"; + for (var i = 0; i < message.field.length; ++i) { + var error = $root.google.protobuf.FieldDescriptorProto.verify(message.field[i]); + if (error) + return "field." + error; + } + } + if (message.extension != null && message.hasOwnProperty("extension")) { + if (!Array.isArray(message.extension)) + return "extension: array expected"; + for (var i = 0; i < message.extension.length; ++i) { + var error = $root.google.protobuf.FieldDescriptorProto.verify(message.extension[i]); + if (error) + return "extension." + error; + } + } + if (message.nestedType != null && message.hasOwnProperty("nestedType")) { + if (!Array.isArray(message.nestedType)) + return "nestedType: array expected"; + for (var i = 0; i < message.nestedType.length; ++i) { + var error = $root.google.protobuf.DescriptorProto.verify(message.nestedType[i]); + if (error) + return "nestedType." + error; + } + } + if (message.enumType != null && message.hasOwnProperty("enumType")) { + if (!Array.isArray(message.enumType)) + return "enumType: array expected"; + for (var i = 0; i < message.enumType.length; ++i) { + var error = $root.google.protobuf.EnumDescriptorProto.verify(message.enumType[i]); + if (error) + return "enumType." + error; + } + } + if (message.extensionRange != null && message.hasOwnProperty("extensionRange")) { + if (!Array.isArray(message.extensionRange)) + return "extensionRange: array expected"; + for (var i = 0; i < message.extensionRange.length; ++i) { + var error = $root.google.protobuf.DescriptorProto.ExtensionRange.verify(message.extensionRange[i]); + if (error) + return "extensionRange." + error; + } + } + if (message.oneofDecl != null && message.hasOwnProperty("oneofDecl")) { + if (!Array.isArray(message.oneofDecl)) + return "oneofDecl: array expected"; + for (var i = 0; i < message.oneofDecl.length; ++i) { + var error = $root.google.protobuf.OneofDescriptorProto.verify(message.oneofDecl[i]); + if (error) + return "oneofDecl." + error; + } + } + if (message.options != null && message.hasOwnProperty("options")) { + var error = $root.google.protobuf.MessageOptions.verify(message.options); + if (error) + return "options." + error; + } + if (message.reservedRange != null && message.hasOwnProperty("reservedRange")) { + if (!Array.isArray(message.reservedRange)) + return "reservedRange: array expected"; + for (var i = 0; i < message.reservedRange.length; ++i) { + var error = $root.google.protobuf.DescriptorProto.ReservedRange.verify(message.reservedRange[i]); + if (error) + return "reservedRange." + error; + } + } + if (message.reservedName != null && message.hasOwnProperty("reservedName")) { + if (!Array.isArray(message.reservedName)) + return "reservedName: array expected"; + for (var i = 0; i < message.reservedName.length; ++i) + if (!$util.isString(message.reservedName[i])) + return "reservedName: string[] expected"; + } + return null; + }; + + /** + * 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 a new ExtensionRange instance using the specified properties. + * @function create + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {google.protobuf.DescriptorProto.IExtensionRange=} [properties] Properties to set + * @returns {google.protobuf.DescriptorProto.ExtensionRange} ExtensionRange instance + */ + ExtensionRange.create = function create(properties) { + return new ExtensionRange(properties); + }; + + /** + * Encodes the specified ExtensionRange message. Does not implicitly {@link google.protobuf.DescriptorProto.ExtensionRange.verify|verify} messages. + * @function encode + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {google.protobuf.DescriptorProto.IExtensionRange} message ExtensionRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExtensionRange.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.start != null && message.hasOwnProperty("start")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.start); + if (message.end != null && message.hasOwnProperty("end")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.end); + return writer; + }; + + /** + * Encodes the specified ExtensionRange message, length delimited. Does not implicitly {@link google.protobuf.DescriptorProto.ExtensionRange.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {google.protobuf.DescriptorProto.IExtensionRange} message ExtensionRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExtensionRange.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExtensionRange message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.DescriptorProto.ExtensionRange} ExtensionRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExtensionRange.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.DescriptorProto.ExtensionRange(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExtensionRange message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.DescriptorProto.ExtensionRange} ExtensionRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExtensionRange.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExtensionRange message. + * @function verify + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExtensionRange.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.start != null && message.hasOwnProperty("start")) + if (!$util.isInteger(message.start)) + return "start: integer expected"; + if (message.end != null && message.hasOwnProperty("end")) + if (!$util.isInteger(message.end)) + return "end: integer expected"; + return null; + }; + + /** + * 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 new ReservedRange instance using the specified properties. + * @function create + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {google.protobuf.DescriptorProto.IReservedRange=} [properties] Properties to set + * @returns {google.protobuf.DescriptorProto.ReservedRange} ReservedRange instance + */ + ReservedRange.create = function create(properties) { + return new ReservedRange(properties); + }; + + /** + * Encodes the specified ReservedRange message. Does not implicitly {@link google.protobuf.DescriptorProto.ReservedRange.verify|verify} messages. + * @function encode + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {google.protobuf.DescriptorProto.IReservedRange} message ReservedRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReservedRange.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.start != null && message.hasOwnProperty("start")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.start); + if (message.end != null && message.hasOwnProperty("end")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.end); + return writer; + }; + + /** + * Encodes the specified ReservedRange message, length delimited. Does not implicitly {@link google.protobuf.DescriptorProto.ReservedRange.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {google.protobuf.DescriptorProto.IReservedRange} message ReservedRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReservedRange.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReservedRange message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.DescriptorProto.ReservedRange} ReservedRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReservedRange.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.DescriptorProto.ReservedRange(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReservedRange message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.DescriptorProto.ReservedRange} ReservedRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReservedRange.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReservedRange message. + * @function verify + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReservedRange.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.start != null && message.hasOwnProperty("start")) + if (!$util.isInteger(message.start)) + return "start: integer expected"; + if (message.end != null && message.hasOwnProperty("end")) + if (!$util.isInteger(message.end)) + return "end: integer expected"; + return null; + }; + + /** + * 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 new FieldDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {google.protobuf.IFieldDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.FieldDescriptorProto} FieldDescriptorProto instance + */ + FieldDescriptorProto.create = function create(properties) { + return new FieldDescriptorProto(properties); + }; + + /** + * Encodes the specified FieldDescriptorProto message. Does not implicitly {@link google.protobuf.FieldDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {google.protobuf.IFieldDescriptorProto} message FieldDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldDescriptorProto.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && message.hasOwnProperty("name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.extendee != null && message.hasOwnProperty("extendee")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.extendee); + if (message.number != null && message.hasOwnProperty("number")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.number); + if (message.label != null && message.hasOwnProperty("label")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.label); + if (message.type != null && message.hasOwnProperty("type")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.type); + if (message.typeName != null && message.hasOwnProperty("typeName")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.typeName); + if (message.defaultValue != null && message.hasOwnProperty("defaultValue")) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.defaultValue); + if (message.options != null && message.hasOwnProperty("options")) + $root.google.protobuf.FieldOptions.encode(message.options, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.oneofIndex != null && message.hasOwnProperty("oneofIndex")) + writer.uint32(/* id 9, wireType 0 =*/72).int32(message.oneofIndex); + if (message.jsonName != null && message.hasOwnProperty("jsonName")) + writer.uint32(/* id 10, wireType 2 =*/82).string(message.jsonName); + return writer; + }; + + /** + * Encodes the specified FieldDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.FieldDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {google.protobuf.IFieldDescriptorProto} message FieldDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldDescriptorProto.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FieldDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FieldDescriptorProto} FieldDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FieldDescriptorProto(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32(); + break; + case 5: + message.type = reader.int32(); + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = $root.google.protobuf.FieldOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FieldDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FieldDescriptorProto} FieldDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldDescriptorProto.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FieldDescriptorProto message. + * @function verify + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FieldDescriptorProto.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.number != null && message.hasOwnProperty("number")) + if (!$util.isInteger(message.number)) + return "number: integer expected"; + if (message.label != null && message.hasOwnProperty("label")) + switch (message.label) { + default: + return "label: enum value expected"; + case 1: + case 2: + case 3: + break; + } + if (message.type != null && message.hasOwnProperty("type")) + switch (message.type) { + default: + return "type: enum value expected"; + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + case 18: + break; + } + if (message.typeName != null && message.hasOwnProperty("typeName")) + if (!$util.isString(message.typeName)) + return "typeName: string expected"; + if (message.extendee != null && message.hasOwnProperty("extendee")) + if (!$util.isString(message.extendee)) + return "extendee: string expected"; + if (message.defaultValue != null && message.hasOwnProperty("defaultValue")) + if (!$util.isString(message.defaultValue)) + return "defaultValue: string expected"; + if (message.oneofIndex != null && message.hasOwnProperty("oneofIndex")) + if (!$util.isInteger(message.oneofIndex)) + return "oneofIndex: integer expected"; + if (message.jsonName != null && message.hasOwnProperty("jsonName")) + if (!$util.isString(message.jsonName)) + return "jsonName: string expected"; + if (message.options != null && message.hasOwnProperty("options")) { + var error = $root.google.protobuf.FieldOptions.verify(message.options); + if (error) + return "options." + error; + } + return 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 {number} TYPE_DOUBLE=1 TYPE_DOUBLE value + * @property {number} TYPE_FLOAT=2 TYPE_FLOAT value + * @property {number} TYPE_INT64=3 TYPE_INT64 value + * @property {number} TYPE_UINT64=4 TYPE_UINT64 value + * @property {number} TYPE_INT32=5 TYPE_INT32 value + * @property {number} TYPE_FIXED64=6 TYPE_FIXED64 value + * @property {number} TYPE_FIXED32=7 TYPE_FIXED32 value + * @property {number} TYPE_BOOL=8 TYPE_BOOL value + * @property {number} TYPE_STRING=9 TYPE_STRING value + * @property {number} TYPE_GROUP=10 TYPE_GROUP value + * @property {number} TYPE_MESSAGE=11 TYPE_MESSAGE value + * @property {number} TYPE_BYTES=12 TYPE_BYTES value + * @property {number} TYPE_UINT32=13 TYPE_UINT32 value + * @property {number} TYPE_ENUM=14 TYPE_ENUM value + * @property {number} TYPE_SFIXED32=15 TYPE_SFIXED32 value + * @property {number} TYPE_SFIXED64=16 TYPE_SFIXED64 value + * @property {number} TYPE_SINT32=17 TYPE_SINT32 value + * @property {number} TYPE_SINT64=18 TYPE_SINT64 value + */ + FieldDescriptorProto.Type = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "TYPE_DOUBLE"] = 1; + values[valuesById[2] = "TYPE_FLOAT"] = 2; + values[valuesById[3] = "TYPE_INT64"] = 3; + values[valuesById[4] = "TYPE_UINT64"] = 4; + values[valuesById[5] = "TYPE_INT32"] = 5; + values[valuesById[6] = "TYPE_FIXED64"] = 6; + values[valuesById[7] = "TYPE_FIXED32"] = 7; + values[valuesById[8] = "TYPE_BOOL"] = 8; + values[valuesById[9] = "TYPE_STRING"] = 9; + values[valuesById[10] = "TYPE_GROUP"] = 10; + values[valuesById[11] = "TYPE_MESSAGE"] = 11; + values[valuesById[12] = "TYPE_BYTES"] = 12; + values[valuesById[13] = "TYPE_UINT32"] = 13; + values[valuesById[14] = "TYPE_ENUM"] = 14; + values[valuesById[15] = "TYPE_SFIXED32"] = 15; + values[valuesById[16] = "TYPE_SFIXED64"] = 16; + values[valuesById[17] = "TYPE_SINT32"] = 17; + values[valuesById[18] = "TYPE_SINT64"] = 18; + return values; + })(); + + /** + * Label enum. + * @name google.protobuf.FieldDescriptorProto.Label + * @enum {string} + * @property {number} LABEL_OPTIONAL=1 LABEL_OPTIONAL value + * @property {number} LABEL_REQUIRED=2 LABEL_REQUIRED value + * @property {number} LABEL_REPEATED=3 LABEL_REPEATED value + */ + FieldDescriptorProto.Label = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "LABEL_OPTIONAL"] = 1; + values[valuesById[2] = "LABEL_REQUIRED"] = 2; + values[valuesById[3] = "LABEL_REPEATED"] = 3; + 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 a new OneofDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {google.protobuf.IOneofDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.OneofDescriptorProto} OneofDescriptorProto instance + */ + OneofDescriptorProto.create = function create(properties) { + return new OneofDescriptorProto(properties); + }; + + /** + * Encodes the specified OneofDescriptorProto message. Does not implicitly {@link google.protobuf.OneofDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {google.protobuf.IOneofDescriptorProto} message OneofDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OneofDescriptorProto.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && message.hasOwnProperty("name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.options != null && message.hasOwnProperty("options")) + $root.google.protobuf.OneofOptions.encode(message.options, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified OneofDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.OneofDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {google.protobuf.IOneofDescriptorProto} message OneofDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OneofDescriptorProto.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an OneofDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.OneofDescriptorProto} OneofDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OneofDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.OneofDescriptorProto(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = $root.google.protobuf.OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an OneofDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.OneofDescriptorProto} OneofDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OneofDescriptorProto.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an OneofDescriptorProto message. + * @function verify + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + OneofDescriptorProto.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.options != null && message.hasOwnProperty("options")) { + var error = $root.google.protobuf.OneofOptions.verify(message.options); + if (error) + return "options." + error; + } + return 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 a new EnumDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {google.protobuf.IEnumDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.EnumDescriptorProto} EnumDescriptorProto instance + */ + EnumDescriptorProto.create = function create(properties) { + return new EnumDescriptorProto(properties); + }; + + /** + * Encodes the specified EnumDescriptorProto message. Does not implicitly {@link google.protobuf.EnumDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {google.protobuf.IEnumDescriptorProto} message EnumDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumDescriptorProto.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && message.hasOwnProperty("name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.value != null && message.value.length) + for (var i = 0; i < message.value.length; ++i) + $root.google.protobuf.EnumValueDescriptorProto.encode(message.value[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.options != null && message.hasOwnProperty("options")) + $root.google.protobuf.EnumOptions.encode(message.options, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified EnumDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.EnumDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {google.protobuf.IEnumDescriptorProto} message EnumDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumDescriptorProto.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an EnumDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.EnumDescriptorProto} EnumDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.EnumDescriptorProto(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + if (!(message.value && message.value.length)) + message.value = []; + message.value.push($root.google.protobuf.EnumValueDescriptorProto.decode(reader, reader.uint32())); + break; + case 3: + message.options = $root.google.protobuf.EnumOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an EnumDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.EnumDescriptorProto} EnumDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumDescriptorProto.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an EnumDescriptorProto message. + * @function verify + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EnumDescriptorProto.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.value != null && message.hasOwnProperty("value")) { + if (!Array.isArray(message.value)) + return "value: array expected"; + for (var i = 0; i < message.value.length; ++i) { + var error = $root.google.protobuf.EnumValueDescriptorProto.verify(message.value[i]); + if (error) + return "value." + error; + } + } + if (message.options != null && message.hasOwnProperty("options")) { + var error = $root.google.protobuf.EnumOptions.verify(message.options); + if (error) + return "options." + error; + } + return 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 a new EnumValueDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {google.protobuf.IEnumValueDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.EnumValueDescriptorProto} EnumValueDescriptorProto instance + */ + EnumValueDescriptorProto.create = function create(properties) { + return new EnumValueDescriptorProto(properties); + }; + + /** + * Encodes the specified EnumValueDescriptorProto message. Does not implicitly {@link google.protobuf.EnumValueDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {google.protobuf.IEnumValueDescriptorProto} message EnumValueDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumValueDescriptorProto.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && message.hasOwnProperty("name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.number != null && message.hasOwnProperty("number")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.number); + if (message.options != null && message.hasOwnProperty("options")) + $root.google.protobuf.EnumValueOptions.encode(message.options, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified EnumValueDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.EnumValueDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {google.protobuf.IEnumValueDescriptorProto} message EnumValueDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumValueDescriptorProto.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an EnumValueDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.EnumValueDescriptorProto} EnumValueDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumValueDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.EnumValueDescriptorProto(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = $root.google.protobuf.EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an EnumValueDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.EnumValueDescriptorProto} EnumValueDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumValueDescriptorProto.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an EnumValueDescriptorProto message. + * @function verify + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EnumValueDescriptorProto.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.number != null && message.hasOwnProperty("number")) + if (!$util.isInteger(message.number)) + return "number: integer expected"; + if (message.options != null && message.hasOwnProperty("options")) { + var error = $root.google.protobuf.EnumValueOptions.verify(message.options); + if (error) + return "options." + error; + } + return 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 new ServiceDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {google.protobuf.IServiceDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.ServiceDescriptorProto} ServiceDescriptorProto instance + */ + ServiceDescriptorProto.create = function create(properties) { + return new ServiceDescriptorProto(properties); + }; + + /** + * Encodes the specified ServiceDescriptorProto message. Does not implicitly {@link google.protobuf.ServiceDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {google.protobuf.IServiceDescriptorProto} message ServiceDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServiceDescriptorProto.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && message.hasOwnProperty("name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.method != null && message.method.length) + for (var i = 0; i < message.method.length; ++i) + $root.google.protobuf.MethodDescriptorProto.encode(message.method[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.options != null && message.hasOwnProperty("options")) + $root.google.protobuf.ServiceOptions.encode(message.options, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ServiceDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.ServiceDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {google.protobuf.IServiceDescriptorProto} message ServiceDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServiceDescriptorProto.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ServiceDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.ServiceDescriptorProto} ServiceDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServiceDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.ServiceDescriptorProto(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + if (!(message.method && message.method.length)) + message.method = []; + message.method.push($root.google.protobuf.MethodDescriptorProto.decode(reader, reader.uint32())); + break; + case 3: + message.options = $root.google.protobuf.ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ServiceDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.ServiceDescriptorProto} ServiceDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServiceDescriptorProto.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ServiceDescriptorProto message. + * @function verify + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ServiceDescriptorProto.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.method != null && message.hasOwnProperty("method")) { + if (!Array.isArray(message.method)) + return "method: array expected"; + for (var i = 0; i < message.method.length; ++i) { + var error = $root.google.protobuf.MethodDescriptorProto.verify(message.method[i]); + if (error) + return "method." + error; + } + } + if (message.options != null && message.hasOwnProperty("options")) { + var error = $root.google.protobuf.ServiceOptions.verify(message.options); + if (error) + return "options." + error; + } + return 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 new MethodDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {google.protobuf.IMethodDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.MethodDescriptorProto} MethodDescriptorProto instance + */ + MethodDescriptorProto.create = function create(properties) { + return new MethodDescriptorProto(properties); + }; + + /** + * Encodes the specified MethodDescriptorProto message. Does not implicitly {@link google.protobuf.MethodDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {google.protobuf.IMethodDescriptorProto} message MethodDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MethodDescriptorProto.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && message.hasOwnProperty("name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.inputType != null && message.hasOwnProperty("inputType")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.inputType); + if (message.outputType != null && message.hasOwnProperty("outputType")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.outputType); + if (message.options != null && message.hasOwnProperty("options")) + $root.google.protobuf.MethodOptions.encode(message.options, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.clientStreaming != null && message.hasOwnProperty("clientStreaming")) + writer.uint32(/* id 5, wireType 0 =*/40).bool(message.clientStreaming); + if (message.serverStreaming != null && message.hasOwnProperty("serverStreaming")) + writer.uint32(/* id 6, wireType 0 =*/48).bool(message.serverStreaming); + return writer; + }; + + /** + * Encodes the specified MethodDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.MethodDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {google.protobuf.IMethodDescriptorProto} message MethodDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MethodDescriptorProto.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a MethodDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.MethodDescriptorProto} MethodDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MethodDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.MethodDescriptorProto(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = $root.google.protobuf.MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a MethodDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.MethodDescriptorProto} MethodDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MethodDescriptorProto.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a MethodDescriptorProto message. + * @function verify + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MethodDescriptorProto.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.inputType != null && message.hasOwnProperty("inputType")) + if (!$util.isString(message.inputType)) + return "inputType: string expected"; + if (message.outputType != null && message.hasOwnProperty("outputType")) + if (!$util.isString(message.outputType)) + return "outputType: string expected"; + if (message.options != null && message.hasOwnProperty("options")) { + var error = $root.google.protobuf.MethodOptions.verify(message.options); + if (error) + return "options." + error; + } + if (message.clientStreaming != null && message.hasOwnProperty("clientStreaming")) + if (typeof message.clientStreaming !== "boolean") + return "clientStreaming: boolean expected"; + if (message.serverStreaming != null && message.hasOwnProperty("serverStreaming")) + if (typeof message.serverStreaming !== "boolean") + return "serverStreaming: boolean expected"; + return null; + }; + + /** + * 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 + */ + + /** + * 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 = []; + if (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; + + /** + * Creates a new FileOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.FileOptions + * @static + * @param {google.protobuf.IFileOptions=} [properties] Properties to set + * @returns {google.protobuf.FileOptions} FileOptions instance + */ + FileOptions.create = function create(properties) { + return new FileOptions(properties); + }; + + /** + * Encodes the specified FileOptions message. Does not implicitly {@link google.protobuf.FileOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FileOptions + * @static + * @param {google.protobuf.IFileOptions} message FileOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileOptions.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.javaPackage != null && message.hasOwnProperty("javaPackage")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.javaPackage); + if (message.javaOuterClassname != null && message.hasOwnProperty("javaOuterClassname")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.javaOuterClassname); + if (message.optimizeFor != null && message.hasOwnProperty("optimizeFor")) + writer.uint32(/* id 9, wireType 0 =*/72).int32(message.optimizeFor); + if (message.javaMultipleFiles != null && message.hasOwnProperty("javaMultipleFiles")) + writer.uint32(/* id 10, wireType 0 =*/80).bool(message.javaMultipleFiles); + if (message.goPackage != null && message.hasOwnProperty("goPackage")) + writer.uint32(/* id 11, wireType 2 =*/90).string(message.goPackage); + if (message.ccGenericServices != null && message.hasOwnProperty("ccGenericServices")) + writer.uint32(/* id 16, wireType 0 =*/128).bool(message.ccGenericServices); + if (message.javaGenericServices != null && message.hasOwnProperty("javaGenericServices")) + writer.uint32(/* id 17, wireType 0 =*/136).bool(message.javaGenericServices); + if (message.pyGenericServices != null && message.hasOwnProperty("pyGenericServices")) + writer.uint32(/* id 18, wireType 0 =*/144).bool(message.pyGenericServices); + if (message.javaGenerateEqualsAndHash != null && message.hasOwnProperty("javaGenerateEqualsAndHash")) + writer.uint32(/* id 20, wireType 0 =*/160).bool(message.javaGenerateEqualsAndHash); + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + writer.uint32(/* id 23, wireType 0 =*/184).bool(message.deprecated); + if (message.javaStringCheckUtf8 != null && message.hasOwnProperty("javaStringCheckUtf8")) + writer.uint32(/* id 27, wireType 0 =*/216).bool(message.javaStringCheckUtf8); + if (message.ccEnableArenas != null && message.hasOwnProperty("ccEnableArenas")) + writer.uint32(/* id 31, wireType 0 =*/248).bool(message.ccEnableArenas); + if (message.objcClassPrefix != null && message.hasOwnProperty("objcClassPrefix")) + writer.uint32(/* id 36, wireType 2 =*/290).string(message.objcClassPrefix); + if (message.csharpNamespace != null && message.hasOwnProperty("csharpNamespace")) + writer.uint32(/* id 37, wireType 2 =*/298).string(message.csharpNamespace); + if (message.uninterpretedOption != null && message.uninterpretedOption.length) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified FileOptions message, length delimited. Does not implicitly {@link google.protobuf.FileOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FileOptions + * @static + * @param {google.protobuf.IFileOptions} message FileOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileOptions.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FileOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FileOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FileOptions} FileOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FileOptions(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32(); + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 999: + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FileOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FileOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FileOptions} FileOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FileOptions message. + * @function verify + * @memberof google.protobuf.FileOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FileOptions.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.javaPackage != null && message.hasOwnProperty("javaPackage")) + if (!$util.isString(message.javaPackage)) + return "javaPackage: string expected"; + if (message.javaOuterClassname != null && message.hasOwnProperty("javaOuterClassname")) + if (!$util.isString(message.javaOuterClassname)) + return "javaOuterClassname: string expected"; + if (message.javaMultipleFiles != null && message.hasOwnProperty("javaMultipleFiles")) + if (typeof message.javaMultipleFiles !== "boolean") + return "javaMultipleFiles: boolean expected"; + if (message.javaGenerateEqualsAndHash != null && message.hasOwnProperty("javaGenerateEqualsAndHash")) + if (typeof message.javaGenerateEqualsAndHash !== "boolean") + return "javaGenerateEqualsAndHash: boolean expected"; + if (message.javaStringCheckUtf8 != null && message.hasOwnProperty("javaStringCheckUtf8")) + if (typeof message.javaStringCheckUtf8 !== "boolean") + return "javaStringCheckUtf8: boolean expected"; + if (message.optimizeFor != null && message.hasOwnProperty("optimizeFor")) + switch (message.optimizeFor) { + default: + return "optimizeFor: enum value expected"; + case 1: + case 2: + case 3: + break; + } + if (message.goPackage != null && message.hasOwnProperty("goPackage")) + if (!$util.isString(message.goPackage)) + return "goPackage: string expected"; + if (message.ccGenericServices != null && message.hasOwnProperty("ccGenericServices")) + if (typeof message.ccGenericServices !== "boolean") + return "ccGenericServices: boolean expected"; + if (message.javaGenericServices != null && message.hasOwnProperty("javaGenericServices")) + if (typeof message.javaGenericServices !== "boolean") + return "javaGenericServices: boolean expected"; + if (message.pyGenericServices != null && message.hasOwnProperty("pyGenericServices")) + if (typeof message.pyGenericServices !== "boolean") + return "pyGenericServices: boolean expected"; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (typeof message.deprecated !== "boolean") + return "deprecated: boolean expected"; + if (message.ccEnableArenas != null && message.hasOwnProperty("ccEnableArenas")) + if (typeof message.ccEnableArenas !== "boolean") + return "ccEnableArenas: boolean expected"; + if (message.objcClassPrefix != null && message.hasOwnProperty("objcClassPrefix")) + if (!$util.isString(message.objcClassPrefix)) + return "objcClassPrefix: string expected"; + if (message.csharpNamespace != null && message.hasOwnProperty("csharpNamespace")) + if (!$util.isString(message.csharpNamespace)) + return "csharpNamespace: string expected"; + if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { + if (!Array.isArray(message.uninterpretedOption)) + return "uninterpretedOption: array expected"; + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify(message.uninterpretedOption[i]); + if (error) + return "uninterpretedOption." + error; + } + } + return null; + }; + + /** + * 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]); + } + } + 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 = []; + 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); + } + 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 {number} SPEED=1 SPEED value + * @property {number} CODE_SIZE=2 CODE_SIZE value + * @property {number} LITE_RUNTIME=3 LITE_RUNTIME value + */ + FileOptions.OptimizeMode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "SPEED"] = 1; + values[valuesById[2] = "CODE_SIZE"] = 2; + values[valuesById[3] = "LITE_RUNTIME"] = 3; + 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 + */ + + /** + * 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; + + /** + * Creates a new MessageOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.MessageOptions + * @static + * @param {google.protobuf.IMessageOptions=} [properties] Properties to set + * @returns {google.protobuf.MessageOptions} MessageOptions instance + */ + MessageOptions.create = function create(properties) { + return new MessageOptions(properties); + }; + + /** + * Encodes the specified MessageOptions message. Does not implicitly {@link google.protobuf.MessageOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.MessageOptions + * @static + * @param {google.protobuf.IMessageOptions} message MessageOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MessageOptions.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.messageSetWireFormat != null && message.hasOwnProperty("messageSetWireFormat")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.messageSetWireFormat); + if (message.noStandardDescriptorAccessor != null && message.hasOwnProperty("noStandardDescriptorAccessor")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.noStandardDescriptorAccessor); + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.deprecated); + if (message.mapEntry != null && message.hasOwnProperty("mapEntry")) + writer.uint32(/* id 7, wireType 0 =*/56).bool(message.mapEntry); + if (message.uninterpretedOption != null && message.uninterpretedOption.length) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified MessageOptions message, length delimited. Does not implicitly {@link google.protobuf.MessageOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.MessageOptions + * @static + * @param {google.protobuf.IMessageOptions} message MessageOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MessageOptions.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a MessageOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.MessageOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.MessageOptions} MessageOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MessageOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.MessageOptions(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a MessageOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.MessageOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.MessageOptions} MessageOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MessageOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a MessageOptions message. + * @function verify + * @memberof google.protobuf.MessageOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MessageOptions.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.messageSetWireFormat != null && message.hasOwnProperty("messageSetWireFormat")) + if (typeof message.messageSetWireFormat !== "boolean") + return "messageSetWireFormat: boolean expected"; + if (message.noStandardDescriptorAccessor != null && message.hasOwnProperty("noStandardDescriptorAccessor")) + if (typeof message.noStandardDescriptorAccessor !== "boolean") + return "noStandardDescriptorAccessor: boolean expected"; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (typeof message.deprecated !== "boolean") + return "deprecated: boolean expected"; + if (message.mapEntry != null && message.hasOwnProperty("mapEntry")) + if (typeof message.mapEntry !== "boolean") + return "mapEntry: boolean expected"; + if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { + if (!Array.isArray(message.uninterpretedOption)) + return "uninterpretedOption: array expected"; + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify(message.uninterpretedOption[i]); + if (error) + return "uninterpretedOption." + error; + } + } + return 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]); + } + } + 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; + } + 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); + } + 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 + */ + + /** + * 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 = []; + if (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; + + /** + * Creates a new FieldOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.FieldOptions + * @static + * @param {google.protobuf.IFieldOptions=} [properties] Properties to set + * @returns {google.protobuf.FieldOptions} FieldOptions instance + */ + FieldOptions.create = function create(properties) { + return new FieldOptions(properties); + }; + + /** + * Encodes the specified FieldOptions message. Does not implicitly {@link google.protobuf.FieldOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FieldOptions + * @static + * @param {google.protobuf.IFieldOptions} message FieldOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldOptions.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.ctype != null && message.hasOwnProperty("ctype")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.ctype); + if (message.packed != null && message.hasOwnProperty("packed")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.packed); + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.deprecated); + if (message.lazy != null && message.hasOwnProperty("lazy")) + writer.uint32(/* id 5, wireType 0 =*/40).bool(message.lazy); + if (message.jstype != null && message.hasOwnProperty("jstype")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.jstype); + if (message.weak != null && message.hasOwnProperty("weak")) + writer.uint32(/* id 10, wireType 0 =*/80).bool(message.weak); + if (message.uninterpretedOption != null && message.uninterpretedOption.length) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified FieldOptions message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FieldOptions + * @static + * @param {google.protobuf.IFieldOptions} message FieldOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldOptions.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FieldOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FieldOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FieldOptions} FieldOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FieldOptions(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32(); + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32(); + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FieldOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FieldOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FieldOptions} FieldOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FieldOptions message. + * @function verify + * @memberof google.protobuf.FieldOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FieldOptions.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.ctype != null && message.hasOwnProperty("ctype")) + switch (message.ctype) { + default: + return "ctype: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.packed != null && message.hasOwnProperty("packed")) + if (typeof message.packed !== "boolean") + return "packed: boolean expected"; + if (message.jstype != null && message.hasOwnProperty("jstype")) + switch (message.jstype) { + default: + return "jstype: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.lazy != null && message.hasOwnProperty("lazy")) + if (typeof message.lazy !== "boolean") + return "lazy: boolean expected"; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (typeof message.deprecated !== "boolean") + return "deprecated: boolean expected"; + if (message.weak != null && message.hasOwnProperty("weak")) + if (typeof message.weak !== "boolean") + return "weak: boolean expected"; + if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { + if (!Array.isArray(message.uninterpretedOption)) + return "uninterpretedOption: array expected"; + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify(message.uninterpretedOption[i]); + if (error) + return "uninterpretedOption." + error; + } + } + return 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]); + } + } + 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 = []; + 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; + } + 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); + } + 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 {number} STRING=0 STRING value + * @property {number} CORD=1 CORD value + * @property {number} STRING_PIECE=2 STRING_PIECE value + */ + FieldOptions.CType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STRING"] = 0; + values[valuesById[1] = "CORD"] = 1; + values[valuesById[2] = "STRING_PIECE"] = 2; + return values; + })(); + + /** + * JSType enum. + * @name google.protobuf.FieldOptions.JSType + * @enum {string} + * @property {number} JS_NORMAL=0 JS_NORMAL value + * @property {number} JS_STRING=1 JS_STRING value + * @property {number} JS_NUMBER=2 JS_NUMBER value + */ + FieldOptions.JSType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "JS_NORMAL"] = 0; + values[valuesById[1] = "JS_STRING"] = 1; + values[valuesById[2] = "JS_NUMBER"] = 2; + 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 a new OneofOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.OneofOptions + * @static + * @param {google.protobuf.IOneofOptions=} [properties] Properties to set + * @returns {google.protobuf.OneofOptions} OneofOptions instance + */ + OneofOptions.create = function create(properties) { + return new OneofOptions(properties); + }; + + /** + * Encodes the specified OneofOptions message. Does not implicitly {@link google.protobuf.OneofOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.OneofOptions + * @static + * @param {google.protobuf.IOneofOptions} message OneofOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OneofOptions.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.uninterpretedOption != null && message.uninterpretedOption.length) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified OneofOptions message, length delimited. Does not implicitly {@link google.protobuf.OneofOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.OneofOptions + * @static + * @param {google.protobuf.IOneofOptions} message OneofOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OneofOptions.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an OneofOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.OneofOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.OneofOptions} OneofOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OneofOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.OneofOptions(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an OneofOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.OneofOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.OneofOptions} OneofOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OneofOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an OneofOptions message. + * @function verify + * @memberof google.protobuf.OneofOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + OneofOptions.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { + if (!Array.isArray(message.uninterpretedOption)) + return "uninterpretedOption: array expected"; + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify(message.uninterpretedOption[i]); + if (error) + return "uninterpretedOption." + error; + } + } + return null; + }; + + /** + * 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 a new EnumOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.EnumOptions + * @static + * @param {google.protobuf.IEnumOptions=} [properties] Properties to set + * @returns {google.protobuf.EnumOptions} EnumOptions instance + */ + EnumOptions.create = function create(properties) { + return new EnumOptions(properties); + }; + + /** + * Encodes the specified EnumOptions message. Does not implicitly {@link google.protobuf.EnumOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.EnumOptions + * @static + * @param {google.protobuf.IEnumOptions} message EnumOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumOptions.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.allowAlias != null && message.hasOwnProperty("allowAlias")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.allowAlias); + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.deprecated); + if (message.uninterpretedOption != null && message.uninterpretedOption.length) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified EnumOptions message, length delimited. Does not implicitly {@link google.protobuf.EnumOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.EnumOptions + * @static + * @param {google.protobuf.IEnumOptions} message EnumOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumOptions.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an EnumOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.EnumOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.EnumOptions} EnumOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.EnumOptions(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an EnumOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.EnumOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.EnumOptions} EnumOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an EnumOptions message. + * @function verify + * @memberof google.protobuf.EnumOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EnumOptions.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.allowAlias != null && message.hasOwnProperty("allowAlias")) + if (typeof message.allowAlias !== "boolean") + return "allowAlias: boolean expected"; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (typeof message.deprecated !== "boolean") + return "deprecated: boolean expected"; + if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { + if (!Array.isArray(message.uninterpretedOption)) + return "uninterpretedOption: array expected"; + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify(message.uninterpretedOption[i]); + if (error) + return "uninterpretedOption." + error; + } + } + return null; + }; + + /** + * 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 a new EnumValueOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {google.protobuf.IEnumValueOptions=} [properties] Properties to set + * @returns {google.protobuf.EnumValueOptions} EnumValueOptions instance + */ + EnumValueOptions.create = function create(properties) { + return new EnumValueOptions(properties); + }; + + /** + * Encodes the specified EnumValueOptions message. Does not implicitly {@link google.protobuf.EnumValueOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {google.protobuf.IEnumValueOptions} message EnumValueOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumValueOptions.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.deprecated); + if (message.uninterpretedOption != null && message.uninterpretedOption.length) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified EnumValueOptions message, length delimited. Does not implicitly {@link google.protobuf.EnumValueOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {google.protobuf.IEnumValueOptions} message EnumValueOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumValueOptions.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an EnumValueOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.EnumValueOptions} EnumValueOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumValueOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.EnumValueOptions(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an EnumValueOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.EnumValueOptions} EnumValueOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumValueOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an EnumValueOptions message. + * @function verify + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EnumValueOptions.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (typeof message.deprecated !== "boolean") + return "deprecated: boolean expected"; + if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { + if (!Array.isArray(message.uninterpretedOption)) + return "uninterpretedOption: array expected"; + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify(message.uninterpretedOption[i]); + if (error) + return "uninterpretedOption." + error; + } + } + return null; + }; + + /** + * 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 + */ + + /** + * 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; + + /** + * Creates a new ServiceOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.ServiceOptions + * @static + * @param {google.protobuf.IServiceOptions=} [properties] Properties to set + * @returns {google.protobuf.ServiceOptions} ServiceOptions instance + */ + ServiceOptions.create = function create(properties) { + return new ServiceOptions(properties); + }; + + /** + * Encodes the specified ServiceOptions message. Does not implicitly {@link google.protobuf.ServiceOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.ServiceOptions + * @static + * @param {google.protobuf.IServiceOptions} message ServiceOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServiceOptions.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + writer.uint32(/* id 33, wireType 0 =*/264).bool(message.deprecated); + if (message.uninterpretedOption != null && message.uninterpretedOption.length) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ServiceOptions message, length delimited. Does not implicitly {@link google.protobuf.ServiceOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.ServiceOptions + * @static + * @param {google.protobuf.IServiceOptions} message ServiceOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServiceOptions.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ServiceOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.ServiceOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.ServiceOptions} ServiceOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServiceOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.ServiceOptions(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ServiceOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.ServiceOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.ServiceOptions} ServiceOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServiceOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ServiceOptions message. + * @function verify + * @memberof google.protobuf.ServiceOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ServiceOptions.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (typeof message.deprecated !== "boolean") + return "deprecated: boolean expected"; + if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { + if (!Array.isArray(message.uninterpretedOption)) + return "uninterpretedOption: array expected"; + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify(message.uninterpretedOption[i]); + if (error) + return "uninterpretedOption." + error; + } + } + return null; + }; + + /** + * 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]); + } + } + 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; + 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 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 + */ + + /** + * 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 = []; + if (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; + + /** + * Creates a new MethodOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.MethodOptions + * @static + * @param {google.protobuf.IMethodOptions=} [properties] Properties to set + * @returns {google.protobuf.MethodOptions} MethodOptions instance + */ + MethodOptions.create = function create(properties) { + return new MethodOptions(properties); + }; + + /** + * Encodes the specified MethodOptions message. Does not implicitly {@link google.protobuf.MethodOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.MethodOptions + * @static + * @param {google.protobuf.IMethodOptions} message MethodOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MethodOptions.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + writer.uint32(/* id 33, wireType 0 =*/264).bool(message.deprecated); + if (message.uninterpretedOption != null && message.uninterpretedOption.length) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); + if (message[".google.api.http"] != null && message.hasOwnProperty(".google.api.http")) + $root.google.api.HttpRule.encode(message[".google.api.http"], writer.uint32(/* id 72295728, wireType 2 =*/578365826).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified MethodOptions message, length delimited. Does not implicitly {@link google.protobuf.MethodOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.MethodOptions + * @static + * @param {google.protobuf.IMethodOptions} message MethodOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MethodOptions.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a MethodOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.MethodOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.MethodOptions} MethodOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MethodOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.MethodOptions(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + case 72295728: + message[".google.api.http"] = $root.google.api.HttpRule.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a MethodOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.MethodOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.MethodOptions} MethodOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MethodOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a MethodOptions message. + * @function verify + * @memberof google.protobuf.MethodOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MethodOptions.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (typeof message.deprecated !== "boolean") + return "deprecated: boolean expected"; + if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { + if (!Array.isArray(message.uninterpretedOption)) + return "uninterpretedOption: array expected"; + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify(message.uninterpretedOption[i]); + if (error) + return "uninterpretedOption." + error; + } + } + if (message[".google.api.http"] != null && message.hasOwnProperty(".google.api.http")) { + var error = $root.google.api.HttpRule.verify(message[".google.api.http"]); + if (error) + return ".google.api.http." + error; + } + return 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"]); + } + 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 = []; + if (options.defaults) { + object.deprecated = false; + 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.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 a new UninterpretedOption instance using the specified properties. + * @function create + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {google.protobuf.IUninterpretedOption=} [properties] Properties to set + * @returns {google.protobuf.UninterpretedOption} UninterpretedOption instance + */ + UninterpretedOption.create = function create(properties) { + return new UninterpretedOption(properties); + }; + + /** + * Encodes the specified UninterpretedOption message. Does not implicitly {@link google.protobuf.UninterpretedOption.verify|verify} messages. + * @function encode + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {google.protobuf.IUninterpretedOption} message UninterpretedOption message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UninterpretedOption.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && message.name.length) + for (var i = 0; i < message.name.length; ++i) + $root.google.protobuf.UninterpretedOption.NamePart.encode(message.name[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.identifierValue != null && message.hasOwnProperty("identifierValue")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.identifierValue); + if (message.positiveIntValue != null && message.hasOwnProperty("positiveIntValue")) + writer.uint32(/* id 4, wireType 0 =*/32).uint64(message.positiveIntValue); + if (message.negativeIntValue != null && message.hasOwnProperty("negativeIntValue")) + writer.uint32(/* id 5, wireType 0 =*/40).int64(message.negativeIntValue); + if (message.doubleValue != null && message.hasOwnProperty("doubleValue")) + writer.uint32(/* id 6, wireType 1 =*/49).double(message.doubleValue); + if (message.stringValue != null && message.hasOwnProperty("stringValue")) + writer.uint32(/* id 7, wireType 2 =*/58).bytes(message.stringValue); + if (message.aggregateValue != null && message.hasOwnProperty("aggregateValue")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.aggregateValue); + return writer; + }; + + /** + * Encodes the specified UninterpretedOption message, length delimited. Does not implicitly {@link google.protobuf.UninterpretedOption.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {google.protobuf.IUninterpretedOption} message UninterpretedOption message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UninterpretedOption.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UninterpretedOption message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.UninterpretedOption} UninterpretedOption + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UninterpretedOption.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.UninterpretedOption(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + if (!(message.name && message.name.length)) + message.name = []; + message.name.push($root.google.protobuf.UninterpretedOption.NamePart.decode(reader, reader.uint32())); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = reader.uint64(); + break; + case 5: + message.negativeIntValue = reader.int64(); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UninterpretedOption message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.UninterpretedOption} UninterpretedOption + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UninterpretedOption.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UninterpretedOption message. + * @function verify + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UninterpretedOption.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) { + if (!Array.isArray(message.name)) + return "name: array expected"; + for (var i = 0; i < message.name.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.NamePart.verify(message.name[i]); + if (error) + return "name." + error; + } + } + if (message.identifierValue != null && message.hasOwnProperty("identifierValue")) + if (!$util.isString(message.identifierValue)) + return "identifierValue: string expected"; + if (message.positiveIntValue != null && message.hasOwnProperty("positiveIntValue")) + if (!$util.isInteger(message.positiveIntValue) && !(message.positiveIntValue && $util.isInteger(message.positiveIntValue.low) && $util.isInteger(message.positiveIntValue.high))) + return "positiveIntValue: integer|Long expected"; + if (message.negativeIntValue != null && message.hasOwnProperty("negativeIntValue")) + if (!$util.isInteger(message.negativeIntValue) && !(message.negativeIntValue && $util.isInteger(message.negativeIntValue.low) && $util.isInteger(message.negativeIntValue.high))) + return "negativeIntValue: integer|Long expected"; + if (message.doubleValue != null && message.hasOwnProperty("doubleValue")) + if (typeof message.doubleValue !== "number") + return "doubleValue: number expected"; + if (message.stringValue != null && message.hasOwnProperty("stringValue")) + if (!(message.stringValue && typeof message.stringValue.length === "number" || $util.isString(message.stringValue))) + return "stringValue: buffer expected"; + if (message.aggregateValue != null && message.hasOwnProperty("aggregateValue")) + if (!$util.isString(message.aggregateValue)) + return "aggregateValue: string expected"; + return null; + }; + + /** + * 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; + object.stringValue = options.bytes === String ? "" : []; + 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 new NamePart instance using the specified properties. + * @function create + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {google.protobuf.UninterpretedOption.INamePart=} [properties] Properties to set + * @returns {google.protobuf.UninterpretedOption.NamePart} NamePart instance + */ + NamePart.create = function create(properties) { + return new NamePart(properties); + }; + + /** + * Encodes the specified NamePart message. Does not implicitly {@link google.protobuf.UninterpretedOption.NamePart.verify|verify} messages. + * @function encode + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {google.protobuf.UninterpretedOption.INamePart} message NamePart message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + NamePart.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + writer.uint32(/* id 1, wireType 2 =*/10).string(message.namePart); + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.isExtension); + return writer; + }; + + /** + * Encodes the specified NamePart message, length delimited. Does not implicitly {@link google.protobuf.UninterpretedOption.NamePart.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {google.protobuf.UninterpretedOption.INamePart} message NamePart message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + NamePart.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a NamePart message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.UninterpretedOption.NamePart} NamePart + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + NamePart.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.UninterpretedOption.NamePart(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + if (!message.hasOwnProperty("namePart")) + throw $util.ProtocolError("missing required 'namePart'", { instance: message }); + if (!message.hasOwnProperty("isExtension")) + throw $util.ProtocolError("missing required 'isExtension'", { instance: message }); + return message; + }; + + /** + * Decodes a NamePart message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.UninterpretedOption.NamePart} NamePart + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + NamePart.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a NamePart message. + * @function verify + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + NamePart.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (!$util.isString(message.namePart)) + return "namePart: string expected"; + if (typeof message.isExtension !== "boolean") + return "isExtension: boolean expected"; + return null; + }; + + /** + * 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 new SourceCodeInfo instance using the specified properties. + * @function create + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {google.protobuf.ISourceCodeInfo=} [properties] Properties to set + * @returns {google.protobuf.SourceCodeInfo} SourceCodeInfo instance + */ + SourceCodeInfo.create = function create(properties) { + return new SourceCodeInfo(properties); + }; + + /** + * Encodes the specified SourceCodeInfo message. Does not implicitly {@link google.protobuf.SourceCodeInfo.verify|verify} messages. + * @function encode + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {google.protobuf.ISourceCodeInfo} message SourceCodeInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SourceCodeInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.location != null && message.location.length) + for (var i = 0; i < message.location.length; ++i) + $root.google.protobuf.SourceCodeInfo.Location.encode(message.location[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified SourceCodeInfo message, length delimited. Does not implicitly {@link google.protobuf.SourceCodeInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {google.protobuf.ISourceCodeInfo} message SourceCodeInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SourceCodeInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SourceCodeInfo message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.SourceCodeInfo} SourceCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SourceCodeInfo.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.SourceCodeInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.location && message.location.length)) + message.location = []; + message.location.push($root.google.protobuf.SourceCodeInfo.Location.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SourceCodeInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.SourceCodeInfo} SourceCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SourceCodeInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SourceCodeInfo message. + * @function verify + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SourceCodeInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.location != null && message.hasOwnProperty("location")) { + if (!Array.isArray(message.location)) + return "location: array expected"; + for (var i = 0; i < message.location.length; ++i) { + var error = $root.google.protobuf.SourceCodeInfo.Location.verify(message.location[i]); + if (error) + return "location." + error; + } + } + return null; + }; + + /** + * 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 new Location instance using the specified properties. + * @function create + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {google.protobuf.SourceCodeInfo.ILocation=} [properties] Properties to set + * @returns {google.protobuf.SourceCodeInfo.Location} Location instance + */ + Location.create = function create(properties) { + return new Location(properties); + }; + + /** + * Encodes the specified Location message. Does not implicitly {@link google.protobuf.SourceCodeInfo.Location.verify|verify} messages. + * @function encode + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {google.protobuf.SourceCodeInfo.ILocation} message Location message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Location.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.path != null && message.path.length) { + writer.uint32(/* id 1, wireType 2 =*/10).fork(); + for (var i = 0; i < message.path.length; ++i) + writer.int32(message.path[i]); + writer.ldelim(); + } + if (message.span != null && message.span.length) { + writer.uint32(/* id 2, wireType 2 =*/18).fork(); + for (var i = 0; i < message.span.length; ++i) + writer.int32(message.span[i]); + writer.ldelim(); + } + if (message.leadingComments != null && message.hasOwnProperty("leadingComments")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.leadingComments); + if (message.trailingComments != null && message.hasOwnProperty("trailingComments")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.trailingComments); + if (message.leadingDetachedComments != null && message.leadingDetachedComments.length) + for (var i = 0; i < message.leadingDetachedComments.length; ++i) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.leadingDetachedComments[i]); + return writer; + }; + + /** + * Encodes the specified Location message, length delimited. Does not implicitly {@link google.protobuf.SourceCodeInfo.Location.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {google.protobuf.SourceCodeInfo.ILocation} message Location message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Location.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Location message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.SourceCodeInfo.Location} Location + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Location.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.SourceCodeInfo.Location(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.path && message.path.length)) + message.path = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.path.push(reader.int32()); + } else + message.path.push(reader.int32()); + break; + case 2: + if (!(message.span && message.span.length)) + message.span = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.span.push(reader.int32()); + } else + message.span.push(reader.int32()); + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + if (!(message.leadingDetachedComments && message.leadingDetachedComments.length)) + message.leadingDetachedComments = []; + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Location message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.SourceCodeInfo.Location} Location + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Location.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Location message. + * @function verify + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Location.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.path != null && message.hasOwnProperty("path")) { + if (!Array.isArray(message.path)) + return "path: array expected"; + for (var i = 0; i < message.path.length; ++i) + if (!$util.isInteger(message.path[i])) + return "path: integer[] expected"; + } + if (message.span != null && message.hasOwnProperty("span")) { + if (!Array.isArray(message.span)) + return "span: array expected"; + for (var i = 0; i < message.span.length; ++i) + if (!$util.isInteger(message.span[i])) + return "span: integer[] expected"; + } + if (message.leadingComments != null && message.hasOwnProperty("leadingComments")) + if (!$util.isString(message.leadingComments)) + return "leadingComments: string expected"; + if (message.trailingComments != null && message.hasOwnProperty("trailingComments")) + if (!$util.isString(message.trailingComments)) + return "trailingComments: string expected"; + if (message.leadingDetachedComments != null && message.hasOwnProperty("leadingDetachedComments")) { + if (!Array.isArray(message.leadingDetachedComments)) + return "leadingDetachedComments: array expected"; + for (var i = 0; i < message.leadingDetachedComments.length; ++i) + if (!$util.isString(message.leadingDetachedComments[i])) + return "leadingDetachedComments: string[] expected"; + } + return null; + }; + + /** + * 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 new GeneratedCodeInfo instance using the specified properties. + * @function create + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {google.protobuf.IGeneratedCodeInfo=} [properties] Properties to set + * @returns {google.protobuf.GeneratedCodeInfo} GeneratedCodeInfo instance + */ + GeneratedCodeInfo.create = function create(properties) { + return new GeneratedCodeInfo(properties); + }; + + /** + * Encodes the specified GeneratedCodeInfo message. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.verify|verify} messages. + * @function encode + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {google.protobuf.IGeneratedCodeInfo} message GeneratedCodeInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GeneratedCodeInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.annotation != null && message.annotation.length) + for (var i = 0; i < message.annotation.length; ++i) + $root.google.protobuf.GeneratedCodeInfo.Annotation.encode(message.annotation[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified GeneratedCodeInfo message, length delimited. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {google.protobuf.IGeneratedCodeInfo} message GeneratedCodeInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GeneratedCodeInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GeneratedCodeInfo message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.GeneratedCodeInfo} GeneratedCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GeneratedCodeInfo.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.GeneratedCodeInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.annotation && message.annotation.length)) + message.annotation = []; + message.annotation.push($root.google.protobuf.GeneratedCodeInfo.Annotation.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GeneratedCodeInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.GeneratedCodeInfo} GeneratedCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GeneratedCodeInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GeneratedCodeInfo message. + * @function verify + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GeneratedCodeInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.annotation != null && message.hasOwnProperty("annotation")) { + if (!Array.isArray(message.annotation)) + return "annotation: array expected"; + for (var i = 0; i < message.annotation.length; ++i) { + var error = $root.google.protobuf.GeneratedCodeInfo.Annotation.verify(message.annotation[i]); + if (error) + return "annotation." + error; + } + } + return null; + }; + + /** + * 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 a new Annotation instance using the specified properties. + * @function create + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {google.protobuf.GeneratedCodeInfo.IAnnotation=} [properties] Properties to set + * @returns {google.protobuf.GeneratedCodeInfo.Annotation} Annotation instance + */ + Annotation.create = function create(properties) { + return new Annotation(properties); + }; + + /** + * Encodes the specified Annotation message. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.Annotation.verify|verify} messages. + * @function encode + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {google.protobuf.GeneratedCodeInfo.IAnnotation} message Annotation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Annotation.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.path != null && message.path.length) { + writer.uint32(/* id 1, wireType 2 =*/10).fork(); + for (var i = 0; i < message.path.length; ++i) + writer.int32(message.path[i]); + writer.ldelim(); + } + if (message.sourceFile != null && message.hasOwnProperty("sourceFile")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.sourceFile); + if (message.begin != null && message.hasOwnProperty("begin")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.begin); + if (message.end != null && message.hasOwnProperty("end")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.end); + return writer; + }; + + /** + * Encodes the specified Annotation message, length delimited. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.Annotation.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {google.protobuf.GeneratedCodeInfo.IAnnotation} message Annotation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Annotation.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Annotation message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.GeneratedCodeInfo.Annotation} Annotation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Annotation.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.GeneratedCodeInfo.Annotation(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.path && message.path.length)) + message.path = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.path.push(reader.int32()); + } else + message.path.push(reader.int32()); + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Annotation message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.GeneratedCodeInfo.Annotation} Annotation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Annotation.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Annotation message. + * @function verify + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Annotation.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.path != null && message.hasOwnProperty("path")) { + if (!Array.isArray(message.path)) + return "path: array expected"; + for (var i = 0; i < message.path.length; ++i) + if (!$util.isInteger(message.path[i])) + return "path: integer[] expected"; + } + if (message.sourceFile != null && message.hasOwnProperty("sourceFile")) + if (!$util.isString(message.sourceFile)) + return "sourceFile: string expected"; + if (message.begin != null && message.hasOwnProperty("begin")) + if (!$util.isInteger(message.begin)) + return "begin: integer expected"; + if (message.end != null && message.hasOwnProperty("end")) + if (!$util.isInteger(message.end)) + return "end: integer expected"; + return null; + }; + + /** + * 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.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 new Timestamp instance using the specified properties. + * @function create + * @memberof google.protobuf.Timestamp + * @static + * @param {google.protobuf.ITimestamp=} [properties] Properties to set + * @returns {google.protobuf.Timestamp} Timestamp instance + */ + Timestamp.create = function create(properties) { + return new Timestamp(properties); + }; + + /** + * Encodes the specified Timestamp message. Does not implicitly {@link google.protobuf.Timestamp.verify|verify} messages. + * @function encode + * @memberof google.protobuf.Timestamp + * @static + * @param {google.protobuf.ITimestamp} message Timestamp message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Timestamp.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.seconds != null && message.hasOwnProperty("seconds")) + writer.uint32(/* id 1, wireType 0 =*/8).int64(message.seconds); + if (message.nanos != null && message.hasOwnProperty("nanos")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.nanos); + return writer; + }; + + /** + * Encodes the specified Timestamp message, length delimited. Does not implicitly {@link google.protobuf.Timestamp.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.Timestamp + * @static + * @param {google.protobuf.ITimestamp} message Timestamp message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Timestamp.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Timestamp message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.Timestamp + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.Timestamp} Timestamp + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Timestamp.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.Timestamp(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = reader.int64(); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Timestamp message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.Timestamp + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.Timestamp} Timestamp + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Timestamp.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Timestamp message. + * @function verify + * @memberof google.protobuf.Timestamp + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Timestamp.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.seconds != null && message.hasOwnProperty("seconds")) + if (!$util.isInteger(message.seconds) && !(message.seconds && $util.isInteger(message.seconds.low) && $util.isInteger(message.seconds.high))) + return "seconds: integer|Long expected"; + if (message.nanos != null && message.hasOwnProperty("nanos")) + if (!$util.isInteger(message.nanos)) + return "nanos: integer expected"; + return null; + }; + + /** + * 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.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 new Struct instance using the specified properties. + * @function create + * @memberof google.protobuf.Struct + * @static + * @param {google.protobuf.IStruct=} [properties] Properties to set + * @returns {google.protobuf.Struct} Struct instance + */ + Struct.create = function create(properties) { + return new Struct(properties); + }; + + /** + * Encodes the specified Struct message. Does not implicitly {@link google.protobuf.Struct.verify|verify} messages. + * @function encode + * @memberof google.protobuf.Struct + * @static + * @param {google.protobuf.IStruct} message Struct message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Struct.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.fields != null && message.hasOwnProperty("fields")) + for (var keys = Object.keys(message.fields), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 1, wireType 2 =*/10).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); + $root.google.protobuf.Value.encode(message.fields[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + return writer; + }; + + /** + * Encodes the specified Struct message, length delimited. Does not implicitly {@link google.protobuf.Struct.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.Struct + * @static + * @param {google.protobuf.IStruct} message Struct message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Struct.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Struct message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.Struct + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.Struct} Struct + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Struct.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.Struct(), key; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + reader.skip().pos++; + if (message.fields === $util.emptyObject) + message.fields = {}; + key = reader.string(); + reader.pos++; + message.fields[key] = $root.google.protobuf.Value.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Struct message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.Struct + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.Struct} Struct + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Struct.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Struct message. + * @function verify + * @memberof google.protobuf.Struct + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Struct.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.fields != null && message.hasOwnProperty("fields")) { + if (!$util.isObject(message.fields)) + return "fields: object expected"; + var key = Object.keys(message.fields); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.protobuf.Value.verify(message.fields[key[i]]); + if (error) + return "fields." + error; + } + } + return null; + }; + + /** + * 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 new Value instance using the specified properties. + * @function create + * @memberof google.protobuf.Value + * @static + * @param {google.protobuf.IValue=} [properties] Properties to set + * @returns {google.protobuf.Value} Value instance + */ + Value.create = function create(properties) { + return new Value(properties); + }; + + /** + * Encodes the specified Value message. Does not implicitly {@link google.protobuf.Value.verify|verify} messages. + * @function encode + * @memberof google.protobuf.Value + * @static + * @param {google.protobuf.IValue} message Value message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Value.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.nullValue != null && message.hasOwnProperty("nullValue")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.nullValue); + if (message.numberValue != null && message.hasOwnProperty("numberValue")) + writer.uint32(/* id 2, wireType 1 =*/17).double(message.numberValue); + if (message.stringValue != null && message.hasOwnProperty("stringValue")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.stringValue); + if (message.boolValue != null && message.hasOwnProperty("boolValue")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.boolValue); + if (message.structValue != null && message.hasOwnProperty("structValue")) + $root.google.protobuf.Struct.encode(message.structValue, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.listValue != null && message.hasOwnProperty("listValue")) + $root.google.protobuf.ListValue.encode(message.listValue, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Value message, length delimited. Does not implicitly {@link google.protobuf.Value.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.Value + * @static + * @param {google.protobuf.IValue} message Value message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Value.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Value message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.Value + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.Value} Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Value.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.Value(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nullValue = reader.int32(); + break; + case 2: + message.numberValue = reader.double(); + break; + case 3: + message.stringValue = reader.string(); + break; + case 4: + message.boolValue = reader.bool(); + break; + case 5: + message.structValue = $root.google.protobuf.Struct.decode(reader, reader.uint32()); + break; + case 6: + message.listValue = $root.google.protobuf.ListValue.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Value message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.Value + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.Value} Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Value.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Value message. + * @function verify + * @memberof google.protobuf.Value + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Value.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.nullValue != null && message.hasOwnProperty("nullValue")) { + properties.kind = 1; + switch (message.nullValue) { + default: + return "nullValue: enum value expected"; + case 0: + break; + } + } + if (message.numberValue != null && message.hasOwnProperty("numberValue")) { + if (properties.kind === 1) + return "kind: multiple values"; + properties.kind = 1; + if (typeof message.numberValue !== "number") + return "numberValue: number expected"; + } + if (message.stringValue != null && message.hasOwnProperty("stringValue")) { + if (properties.kind === 1) + return "kind: multiple values"; + properties.kind = 1; + if (!$util.isString(message.stringValue)) + return "stringValue: string expected"; + } + if (message.boolValue != null && message.hasOwnProperty("boolValue")) { + if (properties.kind === 1) + return "kind: multiple values"; + properties.kind = 1; + if (typeof message.boolValue !== "boolean") + return "boolValue: boolean expected"; + } + if (message.structValue != null && message.hasOwnProperty("structValue")) { + if (properties.kind === 1) + return "kind: multiple values"; + properties.kind = 1; + { + var error = $root.google.protobuf.Struct.verify(message.structValue); + if (error) + return "structValue." + error; + } + } + if (message.listValue != null && message.hasOwnProperty("listValue")) { + if (properties.kind === 1) + return "kind: multiple values"; + properties.kind = 1; + { + var error = $root.google.protobuf.ListValue.verify(message.listValue); + if (error) + return "listValue." + error; + } + } + return null; + }; + + /** + * 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; + })(); + + /** + * NullValue enum. + * @name google.protobuf.NullValue + * @enum {string} + * @property {number} NULL_VALUE=0 NULL_VALUE value + */ + protobuf.NullValue = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "NULL_VALUE"] = 0; + 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 new ListValue instance using the specified properties. + * @function create + * @memberof google.protobuf.ListValue + * @static + * @param {google.protobuf.IListValue=} [properties] Properties to set + * @returns {google.protobuf.ListValue} ListValue instance + */ + ListValue.create = function create(properties) { + return new ListValue(properties); + }; + + /** + * Encodes the specified ListValue message. Does not implicitly {@link google.protobuf.ListValue.verify|verify} messages. + * @function encode + * @memberof google.protobuf.ListValue + * @static + * @param {google.protobuf.IListValue} message ListValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListValue.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.values != null && message.values.length) + for (var i = 0; i < message.values.length; ++i) + $root.google.protobuf.Value.encode(message.values[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ListValue message, length delimited. Does not implicitly {@link google.protobuf.ListValue.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.ListValue + * @static + * @param {google.protobuf.IListValue} message ListValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListValue.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListValue message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.ListValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.ListValue} ListValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListValue.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.ListValue(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.values && message.values.length)) + message.values = []; + message.values.push($root.google.protobuf.Value.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListValue message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.ListValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.ListValue} ListValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListValue.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListValue message. + * @function verify + * @memberof google.protobuf.ListValue + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListValue.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.values != null && message.hasOwnProperty("values")) { + if (!Array.isArray(message.values)) + return "values: array expected"; + for (var i = 0; i < message.values.length; ++i) { + var error = $root.google.protobuf.Value.verify(message.values[i]); + if (error) + return "values." + error; + } + } + return null; + }; + + /** + * 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 new DoubleValue instance using the specified properties. + * @function create + * @memberof google.protobuf.DoubleValue + * @static + * @param {google.protobuf.IDoubleValue=} [properties] Properties to set + * @returns {google.protobuf.DoubleValue} DoubleValue instance + */ + DoubleValue.create = function create(properties) { + return new DoubleValue(properties); + }; + + /** + * Encodes the specified DoubleValue message. Does not implicitly {@link google.protobuf.DoubleValue.verify|verify} messages. + * @function encode + * @memberof google.protobuf.DoubleValue + * @static + * @param {google.protobuf.IDoubleValue} message DoubleValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DoubleValue.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.value != null && message.hasOwnProperty("value")) + writer.uint32(/* id 1, wireType 1 =*/9).double(message.value); + return writer; + }; + + /** + * Encodes the specified DoubleValue message, length delimited. Does not implicitly {@link google.protobuf.DoubleValue.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.DoubleValue + * @static + * @param {google.protobuf.IDoubleValue} message DoubleValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DoubleValue.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DoubleValue message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.DoubleValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.DoubleValue} DoubleValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DoubleValue.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.DoubleValue(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = reader.double(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DoubleValue message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.DoubleValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.DoubleValue} DoubleValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DoubleValue.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DoubleValue message. + * @function verify + * @memberof google.protobuf.DoubleValue + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DoubleValue.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (typeof message.value !== "number") + return "value: number expected"; + return null; + }; + + /** + * 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 new FloatValue instance using the specified properties. + * @function create + * @memberof google.protobuf.FloatValue + * @static + * @param {google.protobuf.IFloatValue=} [properties] Properties to set + * @returns {google.protobuf.FloatValue} FloatValue instance + */ + FloatValue.create = function create(properties) { + return new FloatValue(properties); + }; + + /** + * Encodes the specified FloatValue message. Does not implicitly {@link google.protobuf.FloatValue.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FloatValue + * @static + * @param {google.protobuf.IFloatValue} message FloatValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FloatValue.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.value != null && message.hasOwnProperty("value")) + writer.uint32(/* id 1, wireType 5 =*/13).float(message.value); + return writer; + }; + + /** + * Encodes the specified FloatValue message, length delimited. Does not implicitly {@link google.protobuf.FloatValue.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FloatValue + * @static + * @param {google.protobuf.IFloatValue} message FloatValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FloatValue.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FloatValue message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FloatValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FloatValue} FloatValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FloatValue.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FloatValue(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = reader.float(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FloatValue message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FloatValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FloatValue} FloatValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FloatValue.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FloatValue message. + * @function verify + * @memberof google.protobuf.FloatValue + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FloatValue.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (typeof message.value !== "number") + return "value: number expected"; + return null; + }; + + /** + * 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 a new Int64Value instance using the specified properties. + * @function create + * @memberof google.protobuf.Int64Value + * @static + * @param {google.protobuf.IInt64Value=} [properties] Properties to set + * @returns {google.protobuf.Int64Value} Int64Value instance + */ + Int64Value.create = function create(properties) { + return new Int64Value(properties); + }; + + /** + * Encodes the specified Int64Value message. Does not implicitly {@link google.protobuf.Int64Value.verify|verify} messages. + * @function encode + * @memberof google.protobuf.Int64Value + * @static + * @param {google.protobuf.IInt64Value} message Int64Value message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Int64Value.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.value != null && message.hasOwnProperty("value")) + writer.uint32(/* id 1, wireType 0 =*/8).int64(message.value); + return writer; + }; + + /** + * Encodes the specified Int64Value message, length delimited. Does not implicitly {@link google.protobuf.Int64Value.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.Int64Value + * @static + * @param {google.protobuf.IInt64Value} message Int64Value message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Int64Value.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Int64Value message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.Int64Value + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.Int64Value} Int64Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Int64Value.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.Int64Value(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Int64Value message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.Int64Value + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.Int64Value} Int64Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Int64Value.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Int64Value message. + * @function verify + * @memberof google.protobuf.Int64Value + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Int64Value.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (!$util.isInteger(message.value) && !(message.value && $util.isInteger(message.value.low) && $util.isInteger(message.value.high))) + return "value: integer|Long expected"; + return null; + }; + + /** + * 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 new UInt64Value instance using the specified properties. + * @function create + * @memberof google.protobuf.UInt64Value + * @static + * @param {google.protobuf.IUInt64Value=} [properties] Properties to set + * @returns {google.protobuf.UInt64Value} UInt64Value instance + */ + UInt64Value.create = function create(properties) { + return new UInt64Value(properties); + }; + + /** + * Encodes the specified UInt64Value message. Does not implicitly {@link google.protobuf.UInt64Value.verify|verify} messages. + * @function encode + * @memberof google.protobuf.UInt64Value + * @static + * @param {google.protobuf.IUInt64Value} message UInt64Value message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UInt64Value.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.value != null && message.hasOwnProperty("value")) + writer.uint32(/* id 1, wireType 0 =*/8).uint64(message.value); + return writer; + }; + + /** + * Encodes the specified UInt64Value message, length delimited. Does not implicitly {@link google.protobuf.UInt64Value.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.UInt64Value + * @static + * @param {google.protobuf.IUInt64Value} message UInt64Value message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UInt64Value.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a UInt64Value message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.UInt64Value + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.UInt64Value} UInt64Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UInt64Value.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.UInt64Value(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a UInt64Value message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.UInt64Value + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.UInt64Value} UInt64Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UInt64Value.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a UInt64Value message. + * @function verify + * @memberof google.protobuf.UInt64Value + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UInt64Value.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (!$util.isInteger(message.value) && !(message.value && $util.isInteger(message.value.low) && $util.isInteger(message.value.high))) + return "value: integer|Long expected"; + return null; + }; + + /** + * 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 a new Int32Value instance using the specified properties. + * @function create + * @memberof google.protobuf.Int32Value + * @static + * @param {google.protobuf.IInt32Value=} [properties] Properties to set + * @returns {google.protobuf.Int32Value} Int32Value instance + */ + Int32Value.create = function create(properties) { + return new Int32Value(properties); + }; + + /** + * Encodes the specified Int32Value message. Does not implicitly {@link google.protobuf.Int32Value.verify|verify} messages. + * @function encode + * @memberof google.protobuf.Int32Value + * @static + * @param {google.protobuf.IInt32Value} message Int32Value message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Int32Value.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.value != null && message.hasOwnProperty("value")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.value); + return writer; + }; + + /** + * Encodes the specified Int32Value message, length delimited. Does not implicitly {@link google.protobuf.Int32Value.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.Int32Value + * @static + * @param {google.protobuf.IInt32Value} message Int32Value message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Int32Value.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Int32Value message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.Int32Value + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.Int32Value} Int32Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Int32Value.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.Int32Value(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Int32Value message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.Int32Value + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.Int32Value} Int32Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Int32Value.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Int32Value message. + * @function verify + * @memberof google.protobuf.Int32Value + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Int32Value.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (!$util.isInteger(message.value)) + return "value: integer expected"; + return null; + }; + + /** + * 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 new UInt32Value instance using the specified properties. + * @function create + * @memberof google.protobuf.UInt32Value + * @static + * @param {google.protobuf.IUInt32Value=} [properties] Properties to set + * @returns {google.protobuf.UInt32Value} UInt32Value instance + */ + UInt32Value.create = function create(properties) { + return new UInt32Value(properties); + }; + + /** + * Encodes the specified UInt32Value message. Does not implicitly {@link google.protobuf.UInt32Value.verify|verify} messages. + * @function encode + * @memberof google.protobuf.UInt32Value + * @static + * @param {google.protobuf.IUInt32Value} message UInt32Value message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UInt32Value.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.value != null && message.hasOwnProperty("value")) + writer.uint32(/* id 1, wireType 0 =*/8).uint32(message.value); + return writer; + }; + + /** + * Encodes the specified UInt32Value message, length delimited. Does not implicitly {@link google.protobuf.UInt32Value.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.UInt32Value + * @static + * @param {google.protobuf.IUInt32Value} message UInt32Value message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UInt32Value.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a UInt32Value message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.UInt32Value + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.UInt32Value} UInt32Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UInt32Value.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.UInt32Value(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a UInt32Value message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.UInt32Value + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.UInt32Value} UInt32Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UInt32Value.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a UInt32Value message. + * @function verify + * @memberof google.protobuf.UInt32Value + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UInt32Value.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (!$util.isInteger(message.value)) + return "value: integer expected"; + return null; + }; + + /** + * 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 new BoolValue instance using the specified properties. + * @function create + * @memberof google.protobuf.BoolValue + * @static + * @param {google.protobuf.IBoolValue=} [properties] Properties to set + * @returns {google.protobuf.BoolValue} BoolValue instance + */ + BoolValue.create = function create(properties) { + return new BoolValue(properties); + }; + + /** + * Encodes the specified BoolValue message. Does not implicitly {@link google.protobuf.BoolValue.verify|verify} messages. + * @function encode + * @memberof google.protobuf.BoolValue + * @static + * @param {google.protobuf.IBoolValue} message BoolValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BoolValue.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.value != null && message.hasOwnProperty("value")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.value); + return writer; + }; + + /** + * Encodes the specified BoolValue message, length delimited. Does not implicitly {@link google.protobuf.BoolValue.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.BoolValue + * @static + * @param {google.protobuf.IBoolValue} message BoolValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BoolValue.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BoolValue message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.BoolValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.BoolValue} BoolValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BoolValue.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.BoolValue(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BoolValue message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.BoolValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.BoolValue} BoolValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BoolValue.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BoolValue message. + * @function verify + * @memberof google.protobuf.BoolValue + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BoolValue.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (typeof message.value !== "boolean") + return "value: boolean expected"; + return null; + }; + + /** + * 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 new StringValue instance using the specified properties. + * @function create + * @memberof google.protobuf.StringValue + * @static + * @param {google.protobuf.IStringValue=} [properties] Properties to set + * @returns {google.protobuf.StringValue} StringValue instance + */ + StringValue.create = function create(properties) { + return new StringValue(properties); + }; + + /** + * Encodes the specified StringValue message. Does not implicitly {@link google.protobuf.StringValue.verify|verify} messages. + * @function encode + * @memberof google.protobuf.StringValue + * @static + * @param {google.protobuf.IStringValue} message StringValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StringValue.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.value != null && message.hasOwnProperty("value")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.value); + return writer; + }; + + /** + * Encodes the specified StringValue message, length delimited. Does not implicitly {@link google.protobuf.StringValue.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.StringValue + * @static + * @param {google.protobuf.IStringValue} message StringValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StringValue.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a StringValue message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.StringValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.StringValue} StringValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StringValue.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.StringValue(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a StringValue message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.StringValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.StringValue} StringValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StringValue.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a StringValue message. + * @function verify + * @memberof google.protobuf.StringValue + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + StringValue.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (!$util.isString(message.value)) + return "value: string expected"; + return null; + }; + + /** + * 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 new BytesValue instance using the specified properties. + * @function create + * @memberof google.protobuf.BytesValue + * @static + * @param {google.protobuf.IBytesValue=} [properties] Properties to set + * @returns {google.protobuf.BytesValue} BytesValue instance + */ + BytesValue.create = function create(properties) { + return new BytesValue(properties); + }; + + /** + * Encodes the specified BytesValue message. Does not implicitly {@link google.protobuf.BytesValue.verify|verify} messages. + * @function encode + * @memberof google.protobuf.BytesValue + * @static + * @param {google.protobuf.IBytesValue} message BytesValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BytesValue.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.value != null && message.hasOwnProperty("value")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.value); + return writer; + }; + + /** + * Encodes the specified BytesValue message, length delimited. Does not implicitly {@link google.protobuf.BytesValue.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.BytesValue + * @static + * @param {google.protobuf.IBytesValue} message BytesValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BytesValue.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BytesValue message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.BytesValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.BytesValue} BytesValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BytesValue.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.BytesValue(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BytesValue message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.BytesValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.BytesValue} BytesValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BytesValue.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BytesValue message. + * @function verify + * @memberof google.protobuf.BytesValue + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BytesValue.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (!(message.value && typeof message.value.length === "number" || $util.isString(message.value))) + return "value: buffer expected"; + return null; + }; + + /** + * 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) + object.value = options.bytes === String ? "" : []; + 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.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 a new Empty instance using the specified properties. + * @function create + * @memberof google.protobuf.Empty + * @static + * @param {google.protobuf.IEmpty=} [properties] Properties to set + * @returns {google.protobuf.Empty} Empty instance + */ + Empty.create = function create(properties) { + return new Empty(properties); + }; + + /** + * Encodes the specified Empty message. Does not implicitly {@link google.protobuf.Empty.verify|verify} messages. + * @function encode + * @memberof google.protobuf.Empty + * @static + * @param {google.protobuf.IEmpty} message Empty message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Empty.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified Empty message, length delimited. Does not implicitly {@link google.protobuf.Empty.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.Empty + * @static + * @param {google.protobuf.IEmpty} message Empty message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Empty.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Empty message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.Empty + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.Empty} Empty + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Empty.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.Empty(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Empty message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.Empty + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.Empty} Empty + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Empty.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Empty message. + * @function verify + * @memberof google.protobuf.Empty + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Empty.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * 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.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 a new Any instance using the specified properties. + * @function create + * @memberof google.protobuf.Any + * @static + * @param {google.protobuf.IAny=} [properties] Properties to set + * @returns {google.protobuf.Any} Any instance + */ + Any.create = function create(properties) { + return new Any(properties); + }; + + /** + * Encodes the specified Any message. Does not implicitly {@link google.protobuf.Any.verify|verify} messages. + * @function encode + * @memberof google.protobuf.Any + * @static + * @param {google.protobuf.IAny} message Any message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Any.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.type_url != null && message.hasOwnProperty("type_url")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.type_url); + if (message.value != null && message.hasOwnProperty("value")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.value); + return writer; + }; + + /** + * Encodes the specified Any message, length delimited. Does not implicitly {@link google.protobuf.Any.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.Any + * @static + * @param {google.protobuf.IAny} message Any message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Any.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Any message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.Any + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.Any} Any + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Any.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.Any(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type_url = reader.string(); + break; + case 2: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Any message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.Any + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.Any} Any + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Any.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Any message. + * @function verify + * @memberof google.protobuf.Any + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Any.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.type_url != null && message.hasOwnProperty("type_url")) + if (!$util.isString(message.type_url)) + return "type_url: string expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (!(message.value && typeof message.value.length === "number" || $util.isString(message.value))) + return "value: buffer expected"; + return null; + }; + + /** + * 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 = ""; + object.value = options.bytes === String ? "" : []; + } + 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; + })(); + + 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; + + /** + * Creates a new LatLng instance using the specified properties. + * @function create + * @memberof google.type.LatLng + * @static + * @param {google.type.ILatLng=} [properties] Properties to set + * @returns {google.type.LatLng} LatLng instance + */ + LatLng.create = function create(properties) { + return new LatLng(properties); + }; + + /** + * Encodes the specified LatLng message. Does not implicitly {@link google.type.LatLng.verify|verify} messages. + * @function encode + * @memberof google.type.LatLng + * @static + * @param {google.type.ILatLng} message LatLng message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LatLng.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.latitude != null && message.hasOwnProperty("latitude")) + writer.uint32(/* id 1, wireType 1 =*/9).double(message.latitude); + if (message.longitude != null && message.hasOwnProperty("longitude")) + writer.uint32(/* id 2, wireType 1 =*/17).double(message.longitude); + return writer; + }; + + /** + * Encodes the specified LatLng message, length delimited. Does not implicitly {@link google.type.LatLng.verify|verify} messages. + * @function encodeDelimited + * @memberof google.type.LatLng + * @static + * @param {google.type.ILatLng} message LatLng message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LatLng.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a LatLng message from the specified reader or buffer. + * @function decode + * @memberof google.type.LatLng + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.type.LatLng} LatLng + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LatLng.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.type.LatLng(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.latitude = reader.double(); + break; + case 2: + message.longitude = reader.double(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a LatLng message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.type.LatLng + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.type.LatLng} LatLng + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LatLng.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a LatLng message. + * @function verify + * @memberof google.type.LatLng + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + LatLng.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.latitude != null && message.hasOwnProperty("latitude")) + if (typeof message.latitude !== "number") + return "latitude: number expected"; + if (message.longitude != null && message.hasOwnProperty("longitude")) + if (typeof message.longitude !== "number") + return "longitude: number expected"; + return null; + }; + + /** + * 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; + })(); + + 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; + + /** + * Creates a new Status instance using the specified properties. + * @function create + * @memberof google.rpc.Status + * @static + * @param {google.rpc.IStatus=} [properties] Properties to set + * @returns {google.rpc.Status} Status instance + */ + Status.create = function create(properties) { + return new Status(properties); + }; + + /** + * Encodes the specified Status message. Does not implicitly {@link google.rpc.Status.verify|verify} messages. + * @function encode + * @memberof google.rpc.Status + * @static + * @param {google.rpc.IStatus} message Status message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Status.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.code != null && message.hasOwnProperty("code")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.code); + if (message.message != null && message.hasOwnProperty("message")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.message); + if (message.details != null && message.details.length) + for (var i = 0; i < message.details.length; ++i) + $root.google.protobuf.Any.encode(message.details[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Status message, length delimited. Does not implicitly {@link google.rpc.Status.verify|verify} messages. + * @function encodeDelimited + * @memberof google.rpc.Status + * @static + * @param {google.rpc.IStatus} message Status message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Status.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Status message from the specified reader or buffer. + * @function decode + * @memberof google.rpc.Status + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.rpc.Status} Status + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Status.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.rpc.Status(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.code = reader.int32(); + break; + case 2: + message.message = reader.string(); + break; + case 3: + if (!(message.details && message.details.length)) + message.details = []; + message.details.push($root.google.protobuf.Any.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Status message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.rpc.Status + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.rpc.Status} Status + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Status.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Status message. + * @function verify + * @memberof google.rpc.Status + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Status.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.code != null && message.hasOwnProperty("code")) + if (!$util.isInteger(message.code)) + return "code: integer expected"; + if (message.message != null && message.hasOwnProperty("message")) + if (!$util.isString(message.message)) + return "message: string expected"; + if (message.details != null && message.hasOwnProperty("details")) { + if (!Array.isArray(message.details)) + return "details: array expected"; + for (var i = 0; i < message.details.length; ++i) { + var error = $root.google.protobuf.Any.verify(message.details[i]); + if (error) + return "details." + error; + } + } + return null; + }; + + /** + * 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; + })(); + + return google; +})(); + +module.exports = $root; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/protos/google/firestore/v1beta1/common.proto b/website/functions/node_modules/@google-cloud/firestore/build/protos/google/firestore/v1beta1/common.proto new file mode 100644 index 00000000..d6b3dce0 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/protos/google/firestore/v1beta1/common.proto @@ -0,0 +1,83 @@ +// 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 +// +// 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.firestore.v1beta1; + +import "google/api/annotations.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; +option go_package = "google.golang.org/genproto/googleapis/firestore/v1beta1;firestore"; +option java_multiple_files = true; +option java_outer_classname = "CommonProto"; +option java_package = "com.google.firestore.v1beta1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "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 +// fields. +// This is different from standard field masks, as this is always scoped to a +// [Document][google.firestore.v1beta1.Document], and takes in account the dynamic nature of [Value][google.firestore.v1beta1.Value]. +message DocumentMask { + // The list of field paths in the mask. See [Document.fields][google.firestore.v1beta1.Document.fields] for a field + // path syntax reference. + repeated string field_paths = 1; +} + +// A precondition on a document, used for conditional operations. +message Precondition { + // The type of precondition. + oneof condition_type { + // When set to `true`, the target document must exist. + // When set to `false`, the target document must not exist. + bool exists = 1; + + // When set, the target document must exist and have been last updated at + // that time. + google.protobuf.Timestamp update_time = 2; + } +} + +// Options for creating a new transaction. +message TransactionOptions { + // Options for a transaction that can be used to read and write documents. + message ReadWrite { + // An optional transaction to retry. + bytes retry_transaction = 1; + } + + // Options for a transaction that can only be used to read documents. + message ReadOnly { + // The consistency mode for this transaction. If not set, defaults to strong + // consistency. + oneof consistency_selector { + // Reads documents at the given time. + // This may not be older than 60 seconds. + google.protobuf.Timestamp read_time = 2; + } + } + + // The mode of the transaction. + oneof mode { + // The transaction can only be used for read operations. + ReadOnly read_only = 2; + + // The transaction can be used for both read and write operations. + ReadWrite read_write = 3; + } +} diff --git a/website/functions/node_modules/@google-cloud/firestore/build/protos/google/firestore/v1beta1/document.proto b/website/functions/node_modules/@google-cloud/firestore/build/protos/google/firestore/v1beta1/document.proto new file mode 100644 index 00000000..aaa90516 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/protos/google/firestore/v1beta1/document.proto @@ -0,0 +1,150 @@ +// 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 +// +// 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.firestore.v1beta1; + +import "google/api/annotations.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; +import "google/type/latlng.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; +option go_package = "google.golang.org/genproto/googleapis/firestore/v1beta1;firestore"; +option java_multiple_files = true; +option java_outer_classname = "DocumentProto"; +option java_package = "com.google.firestore.v1beta1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\V1beta1"; + + +// A Firestore document. +// +// Must not exceed 1 MiB - 4 bytes. +message Document { + // The resource name of the document, for example + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + string name = 1; + + // 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 ``. + map fields = 2; + + // 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. + google.protobuf.Timestamp create_time = 3; + + // 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. + google.protobuf.Timestamp update_time = 4; +} + +// A message that can hold any of the supported value types. +message Value { + // Must have a value set. + oneof value_type { + // A null value. + google.protobuf.NullValue null_value = 11; + + // A boolean value. + bool boolean_value = 1; + + // An integer value. + int64 integer_value = 2; + + // A double value. + double double_value = 3; + + // A timestamp value. + // + // Precise only to microseconds. When stored, any additional precision is + // rounded down. + google.protobuf.Timestamp timestamp_value = 10; + + // 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. + string string_value = 17; + + // A bytes value. + // + // Must not exceed 1 MiB - 89 bytes. + // Only the first 1,500 bytes are considered by queries. + bytes bytes_value = 18; + + // A reference to a document. For example: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + string reference_value = 5; + + // A geo point value representing a point on the surface of Earth. + google.type.LatLng geo_point_value = 8; + + // An array value. + // + // Cannot directly contain another array value, though can contain an + // map which contains another array. + ArrayValue array_value = 9; + + // A map value. + MapValue map_value = 6; + } +} + +// An array value. +message ArrayValue { + // Values in the array. + repeated Value values = 1; +} + +// A map value. +message MapValue { + // 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. + map fields = 1; +} diff --git a/website/functions/node_modules/@google-cloud/firestore/build/protos/google/firestore/v1beta1/firestore.proto b/website/functions/node_modules/@google-cloud/firestore/build/protos/google/firestore/v1beta1/firestore.proto new file mode 100644 index 00000000..7b6c8914 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/protos/google/firestore/v1beta1/firestore.proto @@ -0,0 +1,760 @@ +// 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 +// +// 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.firestore.v1beta1; + +import "google/api/annotations.proto"; +import "google/firestore/v1beta1/common.proto"; +import "google/firestore/v1beta1/document.proto"; +import "google/firestore/v1beta1/query.proto"; +import "google/firestore/v1beta1/write.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; +option go_package = "google.golang.org/genproto/googleapis/firestore/v1beta1;firestore"; +option java_multiple_files = true; +option java_outer_classname = "FirestoreProto"; +option java_package = "com.google.firestore.v1beta1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\V1beta1"; +// Specification of the Firestore 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. +service Firestore { + // Gets a single document. + rpc GetDocument(GetDocumentRequest) returns (Document) { + option (google.api.http) = { + get: "/v1beta1/{name=projects/*/databases/*/documents/*/**}" + }; + } + + // Lists documents. + rpc ListDocuments(ListDocumentsRequest) returns (ListDocumentsResponse) { + option (google.api.http) = { + get: "/v1beta1/{parent=projects/*/databases/*/documents/*/**}/{collection_id}" + }; + } + + // 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) = { + patch: "/v1beta1/{document.name=projects/*/databases/*/documents/*/**}" + body: "document" + }; + } + + // Deletes a document. + rpc DeleteDocument(DeleteDocumentRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1beta1/{name=projects/*/databases/*/documents/*/**}" + }; + } + + // Gets multiple documents. + // + // Documents returned by this method are not guaranteed to be returned in the + // same order that they were requested. + rpc BatchGetDocuments(BatchGetDocumentsRequest) returns (stream BatchGetDocumentsResponse) { + option (google.api.http) = { + post: "/v1beta1/{database=projects/*/databases/*}/documents:batchGet" + body: "*" + }; + } + + // Starts a new transaction. + rpc BeginTransaction(BeginTransactionRequest) returns (BeginTransactionResponse) { + option (google.api.http) = { + post: "/v1beta1/{database=projects/*/databases/*}/documents:beginTransaction" + body: "*" + }; + } + + // Commits a transaction, while optionally updating documents. + rpc Commit(CommitRequest) returns (CommitResponse) { + option (google.api.http) = { + post: "/v1beta1/{database=projects/*/databases/*}/documents:commit" + body: "*" + }; + } + + // Rolls back a transaction. + rpc Rollback(RollbackRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1beta1/{database=projects/*/databases/*}/documents:rollback" + body: "*" + }; + } + + // Runs a query. + rpc RunQuery(RunQueryRequest) returns (stream RunQueryResponse) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*/databases/*/documents}:runQuery" + body: "*" + additional_bindings { + post: "/v1beta1/{parent=projects/*/databases/*/documents/*/**}:runQuery" + body: "*" + } + }; + } + + // Streams batches of document updates and deletes, in order. + rpc Write(stream WriteRequest) returns (stream WriteResponse) { + option (google.api.http) = { + post: "/v1beta1/{database=projects/*/databases/*}/documents:write" + body: "*" + }; + } + + // Listens to changes. + rpc Listen(stream ListenRequest) returns (stream ListenResponse) { + option (google.api.http) = { + post: "/v1beta1/{database=projects/*/databases/*}/documents:listen" + body: "*" + }; + } + + // Lists all the collection IDs underneath a document. + rpc ListCollectionIds(ListCollectionIdsRequest) returns (ListCollectionIdsResponse) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*/databases/*/documents}:listCollectionIds" + body: "*" + additional_bindings { + post: "/v1beta1/{parent=projects/*/databases/*/documents/*/**}:listCollectionIds" + body: "*" + } + }; + } +} + +// The request for [Firestore.GetDocument][google.firestore.v1beta1.Firestore.GetDocument]. +message GetDocumentRequest { + // The resource name of the Document to get. In the format: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + string name = 1; + + // 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. + DocumentMask mask = 2; + + // The consistency mode for this transaction. + // If not set, defaults to strong consistency. + oneof consistency_selector { + // Reads the document in a transaction. + bytes transaction = 3; + + // Reads the version of the document at the given time. + // This may not be older than 60 seconds. + google.protobuf.Timestamp read_time = 5; + } +} + +// The request for [Firestore.ListDocuments][google.firestore.v1beta1.Firestore.ListDocuments]. +message ListDocumentsRequest { + // 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; + + // The collection ID, relative to `parent`, to list. For example: `chatrooms` + // or `messages`. + string collection_id = 2; + + // The maximum number of documents to return. + int32 page_size = 3; + + // The `next_page_token` value returned from a previous List request, if any. + string page_token = 4; + + // The order to sort results by. For example: `priority desc, name`. + string order_by = 6; + + // 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. + DocumentMask mask = 7; + + // The consistency mode for this transaction. + // If not set, defaults to strong consistency. + oneof consistency_selector { + // Reads documents in a transaction. + bytes transaction = 8; + + // Reads documents as they were at the given time. + // This may not be older than 60 seconds. + google.protobuf.Timestamp read_time = 10; + } + + // 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`. + bool show_missing = 12; +} + +// The response for [Firestore.ListDocuments][google.firestore.v1beta1.Firestore.ListDocuments]. +message ListDocumentsResponse { + // The Documents found. + repeated Document documents = 1; + + // The next page token. + string next_page_token = 2; +} + +// The request for [Firestore.CreateDocument][google.firestore.v1beta1.Firestore.CreateDocument]. +message CreateDocumentRequest { + // 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; + + // The collection ID, relative to `parent`, to list. For example: `chatrooms`. + string collection_id = 2; + + // 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; + + // 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. + DocumentMask mask = 5; +} + +// The request for [Firestore.UpdateDocument][google.firestore.v1beta1.Firestore.UpdateDocument]. +message UpdateDocumentRequest { + // The updated document. + // Creates the document if it does not already exist. + Document document = 1; + + // 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. + DocumentMask update_mask = 2; + + // 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. + DocumentMask mask = 3; + + // An optional precondition on the document. + // The request will fail if this is set and not met by the target document. + Precondition current_document = 4; +} + +// The request for [Firestore.DeleteDocument][google.firestore.v1beta1.Firestore.DeleteDocument]. +message DeleteDocumentRequest { + // The resource name of the Document to delete. In the format: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + string name = 1; + + // An optional precondition on the document. + // The request will fail if this is set and not met by the target document. + Precondition current_document = 2; +} + +// The request for [Firestore.BatchGetDocuments][google.firestore.v1beta1.Firestore.BatchGetDocuments]. +message BatchGetDocumentsRequest { + // The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + string database = 1; + + // 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. + repeated string documents = 2; + + // 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. + DocumentMask mask = 3; + + // The consistency mode for this transaction. + // If not set, defaults to strong consistency. + oneof consistency_selector { + // Reads documents in a transaction. + bytes transaction = 4; + + // 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. + TransactionOptions new_transaction = 5; + + // Reads documents as they were at the given time. + // This may not be older than 60 seconds. + google.protobuf.Timestamp read_time = 7; + } +} + +// The streamed response for [Firestore.BatchGetDocuments][google.firestore.v1beta1.Firestore.BatchGetDocuments]. +message BatchGetDocumentsResponse { + // A single result. + // This can be empty if the server is just returning a transaction. + oneof result { + // A document that was requested. + Document found = 1; + + // A document name that was requested but does not exist. In the format: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + string missing = 2; + } + + // The transaction that was started as part of this request. + // Will only be set in the first response, and only if + // [BatchGetDocumentsRequest.new_transaction][google.firestore.v1beta1.BatchGetDocumentsRequest.new_transaction] was set in the request. + bytes transaction = 3; + + // 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. + google.protobuf.Timestamp read_time = 4; +} + +// The request for [Firestore.BeginTransaction][google.firestore.v1beta1.Firestore.BeginTransaction]. +message BeginTransactionRequest { + // The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + string database = 1; + + // The options for the transaction. + // Defaults to a read-write transaction. + TransactionOptions options = 2; +} + +// The response for [Firestore.BeginTransaction][google.firestore.v1beta1.Firestore.BeginTransaction]. +message BeginTransactionResponse { + // The transaction that was started. + bytes transaction = 1; +} + +// The request for [Firestore.Commit][google.firestore.v1beta1.Firestore.Commit]. +message CommitRequest { + // The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + string database = 1; + + // The writes to apply. + // + // Always executed atomically and in order. + repeated Write writes = 2; + + // If set, applies all writes in this transaction, and commits it. + bytes transaction = 3; +} + +// The response for [Firestore.Commit][google.firestore.v1beta1.Firestore.Commit]. +message CommitResponse { + // 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 time at which the commit occurred. + google.protobuf.Timestamp commit_time = 2; +} + +// The request for [Firestore.Rollback][google.firestore.v1beta1.Firestore.Rollback]. +message RollbackRequest { + // The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + string database = 1; + + // The transaction to roll back. + bytes transaction = 2; +} + +// The request for [Firestore.RunQuery][google.firestore.v1beta1.Firestore.RunQuery]. +message RunQueryRequest { + // 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; + + // The query to run. + oneof query_type { + // A structured query. + StructuredQuery structured_query = 2; + } + + // The consistency mode for this transaction. + // If not set, defaults to strong consistency. + oneof consistency_selector { + // Reads documents in a transaction. + bytes transaction = 5; + + // 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. + TransactionOptions new_transaction = 6; + + // Reads documents as they were at the given time. + // This may not be older than 60 seconds. + google.protobuf.Timestamp read_time = 7; + } +} + +// The response for [Firestore.RunQuery][google.firestore.v1beta1.Firestore.RunQuery]. +message RunQueryResponse { + // The transaction that was started as part of this request. + // Can only be set in the first response, and only if + // [RunQueryRequest.new_transaction][google.firestore.v1beta1.RunQueryRequest.new_transaction] was set in the request. + // If set, no other fields will be set in this response. + bytes transaction = 2; + + // A query result. + // Not set when reporting partial progress. + Document document = 1; + + // 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. + google.protobuf.Timestamp read_time = 3; + + // The number of results that have been skipped due to an offset between + // the last response and the current response. + int32 skipped_results = 4; +} + +// The request for [Firestore.Write][google.firestore.v1beta1.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. +message WriteRequest { + // The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + // This is only required in the first message. + string database = 1; + + // 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. + string stream_id = 2; + + // 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. + repeated Write writes = 3; + + // A stream token that was previously sent by the server. + // + // The client should set this field to the token from the most recent + // [WriteResponse][google.firestore.v1beta1.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. + bytes stream_token = 4; + + // Labels associated with this write request. + map labels = 5; +} + +// The response for [Firestore.Write][google.firestore.v1beta1.Firestore.Write]. +message WriteResponse { + // The ID of the stream. + // Only set on the first message, when a new stream was created. + string stream_id = 1; + + // 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. + bytes stream_token = 2; + + // The result of applying the writes. + // + // This i-th write result corresponds to the i-th write in the + // request. + repeated WriteResult write_results = 3; + + // The time at which the commit occurred. + google.protobuf.Timestamp commit_time = 4; +} + +// A request for [Firestore.Listen][google.firestore.v1beta1.Firestore.Listen] +message ListenRequest { + // The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + string database = 1; + + // The supported target changes. + oneof target_change { + // A target to add to this stream. + Target add_target = 2; + + // The ID of a target to remove from this stream. + int32 remove_target = 3; + } + + // Labels associated with this target change. + map labels = 4; +} + +// The response for [Firestore.Listen][google.firestore.v1beta1.Firestore.Listen]. +message ListenResponse { + // The supported responses. + oneof response_type { + // Targets have changed. + TargetChange target_change = 2; + + // A [Document][google.firestore.v1beta1.Document] has changed. + DocumentChange document_change = 3; + + // A [Document][google.firestore.v1beta1.Document] has been deleted. + DocumentDelete document_delete = 4; + + // A [Document][google.firestore.v1beta1.Document] has been removed from a target (because it is no longer + // relevant to that target). + DocumentRemove document_remove = 6; + + // 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. + ExistenceFilter filter = 5; + } +} + +// A specification of a set of documents to listen to. +message Target { + // A target specified by a set of documents names. + message DocumentsTarget { + // 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. + repeated string documents = 2; + } + + // A target specified by a query. + message QueryTarget { + // 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; + + // The query to run. + oneof query_type { + // A structured query. + StructuredQuery structured_query = 2; + } + } + + // The type of target to listen to. + oneof target_type { + // A target specified by a query. + QueryTarget query = 2; + + // A target specified by a set of document names. + DocumentsTarget documents = 3; + } + + // When to start listening. + // + // If not specified, all matching Documents are returned before any + // subsequent changes. + oneof resume_type { + // A resume token from a prior [TargetChange][google.firestore.v1beta1.TargetChange] for an identical target. + // + // Using a resume token with a different target is unsupported and may fail. + bytes resume_token = 4; + + // Start listening after a specific `read_time`. + // + // The client must know the state of matching documents at this time. + google.protobuf.Timestamp read_time = 11; + } + + // A client provided target ID. + // + // If not set, the server will assign an ID for the target. + // + // Used for resuming a target without changing IDs. The IDs can either be + // client-assigned or be server-assigned in a previous stream. All targets + // with client provided IDs must be added before adding a target that needs + // a server-assigned id. + int32 target_id = 5; + + // If the target should be removed once it is current and consistent. + bool once = 6; +} + +// Targets being watched have changed. +message TargetChange { + // The type of change. + enum 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 type of change that occurred. + TargetChangeType target_change_type = 1; + + // The target IDs of targets that have changed. + // + // If empty, the change applies to all targets. + // + // For `target_change_type=ADD`, the order of the target IDs matches the order + // of the requests to add the targets. This allows clients to unambiguously + // associate server-assigned target IDs with added targets. + // + // For other states, the order of the target IDs is not defined. + repeated int32 target_ids = 2; + + // The error that resulted in this change, if applicable. + google.rpc.Status cause = 3; + + // 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. + bytes resume_token = 4; + + // 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. + google.protobuf.Timestamp read_time = 6; +} + +// The request for [Firestore.ListCollectionIds][google.firestore.v1beta1.Firestore.ListCollectionIds]. +message ListCollectionIdsRequest { + // 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; + + // The maximum number of results to return. + int32 page_size = 2; + + // A page token. Must be a value from + // [ListCollectionIdsResponse][google.firestore.v1beta1.ListCollectionIdsResponse]. + string page_token = 3; +} + +// The response from [Firestore.ListCollectionIds][google.firestore.v1beta1.Firestore.ListCollectionIds]. +message ListCollectionIdsResponse { + // The collection ids. + repeated string collection_ids = 1; + + // A page token that may be used to continue the list. + string next_page_token = 2; +} diff --git a/website/functions/node_modules/@google-cloud/firestore/build/protos/google/firestore/v1beta1/query.proto b/website/functions/node_modules/@google-cloud/firestore/build/protos/google/firestore/v1beta1/query.proto new file mode 100644 index 00000000..02d0aaaa --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/protos/google/firestore/v1beta1/query.proto @@ -0,0 +1,235 @@ +// 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 +// +// 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.firestore.v1beta1; + +import "google/api/annotations.proto"; +import "google/firestore/v1beta1/document.proto"; +import "google/protobuf/wrappers.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; +option go_package = "google.golang.org/genproto/googleapis/firestore/v1beta1;firestore"; +option java_multiple_files = true; +option java_outer_classname = "QueryProto"; +option java_package = "com.google.firestore.v1beta1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\V1beta1"; + + +// A Firestore query. +message StructuredQuery { + // A selection of a collection, such as `messages as m1`. + message CollectionSelector { + // The collection ID. + // When set, selects only collections with this ID. + string collection_id = 2; + + // When false, selects only collections that are immediate children of + // the `parent` specified in the containing `RunQueryRequest`. + // When true, selects all descendant collections. + bool all_descendants = 3; + } + + // A filter. + message Filter { + // The type of filter. + oneof filter_type { + // A composite filter. + CompositeFilter composite_filter = 1; + + // A filter on a document field. + FieldFilter field_filter = 2; + + // A filter that takes exactly one argument. + UnaryFilter unary_filter = 3; + } + } + + // A filter that merges multiple other filters using the given operator. + message CompositeFilter { + // A composite filter operator. + enum Operator { + // Unspecified. This value must not be used. + OPERATOR_UNSPECIFIED = 0; + + // The results are required to satisfy each of the combined filters. + AND = 1; + } + + // The operator for combining multiple filters. + Operator op = 1; + + // The list of filters to combine. + // Must contain at least one filter. + repeated Filter filters = 2; + } + + // A filter on a specific field. + message FieldFilter { + // A field filter operator. + enum 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; + } + + // The field to filter by. + FieldReference field = 1; + + // The operator to filter by. + Operator op = 2; + + // The value to compare to. + Value value = 3; + } + + // A filter with a single operand. + message UnaryFilter { + // A unary operator. + enum 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 exprestion evaluates to Null. + IS_NULL = 3; + } + + // The unary operator to apply. + Operator op = 1; + + // The argument to the filter. + oneof operand_type { + // The field to which to apply the operator. + FieldReference field = 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 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. + DIRECTION_UNSPECIFIED = 0; + + // Ascending. + ASCENDING = 1; + + // Descending. + DESCENDING = 2; + } + + // The projection to return. + Projection select = 1; + + // The collections to query. + repeated CollectionSelector from = 2; + + // The filter to apply. + Filter where = 3; + + // 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__` + repeated Order order_by = 4; + + // A starting point for the query results. + Cursor start_at = 7; + + // A end point for the query results. + Cursor end_at = 8; + + // The number of results to skip. + // + // Applies before limit, but after all other constraints. Must be >= 0 if + // specified. + int32 offset = 6; + + // The maximum number of results to return. + // + // Applies after all other constraints. + // Must be >= 0 if specified. + google.protobuf.Int32Value limit = 5; +} + +// A position in a query result set. +message Cursor { + // 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. + repeated Value values = 1; + + // If the position is just before or just after the given values, relative + // to the sort order defined by the query. + bool before = 2; +} diff --git a/website/functions/node_modules/@google-cloud/firestore/build/protos/google/firestore/v1beta1/write.proto b/website/functions/node_modules/@google-cloud/firestore/build/protos/google/firestore/v1beta1/write.proto new file mode 100644 index 00000000..9901e310 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/protos/google/firestore/v1beta1/write.proto @@ -0,0 +1,214 @@ +// 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 +// +// 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.firestore.v1beta1; + +import "google/api/annotations.proto"; +import "google/firestore/v1beta1/common.proto"; +import "google/firestore/v1beta1/document.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; +option go_package = "google.golang.org/genproto/googleapis/firestore/v1beta1;firestore"; +option java_multiple_files = true; +option java_outer_classname = "WriteProto"; +option java_package = "com.google.firestore.v1beta1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\V1beta1"; + + +// A write on a document. +message Write { + // The operation to execute. + oneof operation { + // A document to write. + Document update = 1; + + // A document name to delete. In the format: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + string delete = 2; + + // Applies a tranformation 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; + } + + // 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. + DocumentMask update_mask = 3; + + // An optional precondition on the document. + // + // The write will fail if this is set and not met by the target document. + Precondition current_document = 4; +} + +// A transformation of a document. +message DocumentTransform { + // A transformation of a field of the document. + message FieldTransform { + // A value that is calculated by the server. + enum 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 path of the field. See [Document.fields][google.firestore.v1beta1.Document.fields] for the field path syntax + // reference. + string field_path = 1; + + // The transformation to apply on the field. + oneof transform_type { + // Sets the field to the given server value. + ServerValue set_to_server_value = 2; + + // 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. + ArrayValue append_missing_elements = 6; + + // 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. + ArrayValue remove_all_from_array = 7; + } + } + + // The name of the document to transform. + string document = 1; + + // The list of transformations to apply to the fields of the document, in + // order. + // This must not be empty. + repeated FieldTransform field_transforms = 2; +} + +// The result of applying a write. +message WriteResult { + // 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. + google.protobuf.Timestamp update_time = 1; + + // The results of applying each [DocumentTransform.FieldTransform][google.firestore.v1beta1.DocumentTransform.FieldTransform], in the + // same order. + repeated Value transform_results = 2; +} + +// A [Document][google.firestore.v1beta1.Document] has changed. +// +// May be the result of multiple [writes][google.firestore.v1beta1.Write], including deletes, that +// ultimately resulted in a new value for the [Document][google.firestore.v1beta1.Document]. +// +// Multiple [DocumentChange][google.firestore.v1beta1.DocumentChange] messages may be returned for the same logical +// change, if multiple targets are affected. +message DocumentChange { + // The new state of the [Document][google.firestore.v1beta1.Document]. + // + // If `mask` is set, contains only fields that were updated or added. + Document document = 1; + + // A set of target IDs of targets that match this document. + repeated int32 target_ids = 5; + + // A set of target IDs for targets that no longer match this document. + repeated int32 removed_target_ids = 6; +} + +// A [Document][google.firestore.v1beta1.Document] has been deleted. +// +// May be the result of multiple [writes][google.firestore.v1beta1.Write], including updates, the +// last of which deleted the [Document][google.firestore.v1beta1.Document]. +// +// Multiple [DocumentDelete][google.firestore.v1beta1.DocumentDelete] messages may be returned for the same logical +// delete, if multiple targets are affected. +message DocumentDelete { + // The resource name of the [Document][google.firestore.v1beta1.Document] that was deleted. + string document = 1; + + // A set of target IDs for targets that previously matched this entity. + repeated int32 removed_target_ids = 6; + + // The read timestamp at which the delete was observed. + // + // Greater or equal to the `commit_time` of the delete. + google.protobuf.Timestamp read_time = 4; +} + +// A [Document][google.firestore.v1beta1.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][google.firestore.v1beta1.DocumentRemove] messages may be returned for the same logical +// write or delete, if multiple targets are affected. +message DocumentRemove { + // The resource name of the [Document][google.firestore.v1beta1.Document] that has gone out of view. + string document = 1; + + // A set of target IDs for targets that previously matched this document. + repeated int32 removed_target_ids = 2; + + // The read timestamp at which the remove was observed. + // + // Greater or equal to the `commit_time` of the change/delete/remove. + google.protobuf.Timestamp read_time = 4; +} + +// A digest of all the documents that match a given target. +message ExistenceFilter { + // The target ID to which this filter applies. + int32 target_id = 1; + + // The total count of documents that match [target_id][google.firestore.v1beta1.ExistenceFilter.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. + int32 count = 2; +} diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/backoff.js b/website/functions/node_modules/@google-cloud/firestore/build/src/backoff.js new file mode 100644 index 00000000..6045861c --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/backoff.js @@ -0,0 +1,197 @@ +/*! + * Copyright 2017 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. + */ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +const logger_1 = require("./logger"); +/* + * @module firestore/backoff + * @private + * + * Contains backoff logic to facilitate RPC error handling. This class derives + * its implementation from the Firestore Mobile Web Client. + * + * @see https://github.com/firebase/firebase-js-sdk/blob/master/packages/firestore/src/remote/backoff.ts + */ +/*! + * 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; +/*! + * The default maximum backoff time in milliseconds. + */ +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; +/*! + * The default jitter to distribute the backoff attempts by (0 means no + * randomization, 1.0 means +/-50% randomization). + */ +const DEFAULT_JITTER_FACTOR = 1.0; +/*! + * The timeout handler used by `ExponentialBackoff`. + */ +let delayExecution = setTimeout; +/** + * Allows overriding of the timeout handler used by the exponential backoff + * implementation. If not invoked, we default to `setTimeout()`. + * + * Used only in testing. + * + * @private + * @param {function} handler A handler than matches the API of `setTimeout()`. + */ +function setTimeoutHandler(handler) { + delayExecution = handler; +} +exports.setTimeoutHandler = setTimeoutHandler; +/** + * A helper for running delayed tasks following an exponential backoff curve + * between attempts. + * + * Each delay is made up of a "base" delay which follows the exponential + * backoff curve, and a "jitter" (+/- 50% by default) that is calculated and + * added to the base delay. This prevents clients from accidentally + * synchronizing their delays causing spikes of load to the backend. + * + * @private + */ +class ExponentialBackoff { + /** + * @param {number=} options.initialDelayMs Optional override for the initial + * retry delay. + * @param {number=} options.backoffFactor Optional override for the + * exponential backoff factor. + * @param {number=} options.maxDelayMs Optional override for the maximum + * retry delay. + * @param {number=} options.jitterFactor Optional override to control the + * jitter factor by which to randomize attempts (0 means no randomization, + * 1.0 means +/-50% randomization). It is suggested not to exceed this range. + */ + constructor(options) { + options = options || {}; + /** + * The initial delay (used as the base delay on the first retry attempt). + * Note that jitter will still be applied, so the actual delay could be as + * little as 0.5*initialDelayMs (based on a jitter factor of 1.0). + * + * @type {number} + * @private + */ + this._initialDelayMs = options.initialDelayMs !== undefined ? + options.initialDelayMs : + DEFAULT_BACKOFF_INITIAL_DELAY_MS; + /** + * The multiplier to use to determine the extended base delay after each + * attempt. + * @type {number} + * @private + */ + this._backoffFactor = options.backoffFactor !== undefined ? + options.backoffFactor : + DEFAULT_BACKOFF_FACTOR; + /** + * The maximum base delay after which no further backoff is performed. + * Note that jitter will still be applied, so the actual delay could be as + * much as 1.5*maxDelayMs (based on a jitter factor of 1.0). + * + * @type {number} + * @private + */ + this._maxDelayMs = options.maxDelayMs !== undefined ? + options.maxDelayMs : + DEFAULT_BACKOFF_MAX_DELAY_MS; + /** + * The jitter factor that controls the random distribution of the backoff + * points. + * + * @type {number} + * @private + */ + this._jitterFactor = options.jitterFactor !== undefined ? + options.jitterFactor : + DEFAULT_JITTER_FACTOR; + /** + * The backoff delay of the current attempt. + * @type {number} + * @private + */ + this._currentBaseMs = 0; + } + /** + * Resets the backoff delay. + * + * The very next backoffAndWait() will have no delay. If it is called again + * (i.e. due to an error), initialDelayMs (plus jitter) will be used, and + * subsequent ones will increase according to the backoffFactor. + * + * @private + */ + reset() { + this._currentBaseMs = 0; + } + /** + * Resets the backoff delay to the maximum delay (e.g. for use after a + * RESOURCE_EXHAUSTED error). + * + * @private + */ + resetToMax() { + this._currentBaseMs = this._maxDelayMs; + } + /** + * Returns a promise that resolves after currentDelayMs, and increases the + * delay for any subsequent attempts. + * + * @private + * @return {Promise.} A Promise that resolves when the current delay + * elapsed. + */ + backoffAndWait() { + // First schedule using the current base (which may be 0 and should be + // honored as such). + const delayWithJitterMs = this._currentBaseMs + this._jitterDelayMs(); + if (this._currentBaseMs > 0) { + logger_1.logger('ExponentialBackoff.backoffAndWait', `Backing off for ${delayWithJitterMs} ms ` + + `(base delay: ${this._currentBaseMs} ms)`); + } + // Apply backoff factor to determine next delay and ensure it is within + // bounds. + this._currentBaseMs *= this._backoffFactor; + if (this._currentBaseMs < this._initialDelayMs) { + this._currentBaseMs = this._initialDelayMs; + } + if (this._currentBaseMs > this._maxDelayMs) { + this._currentBaseMs = this._maxDelayMs; + } + return new Promise(resolve => { + delayExecution(resolve, delayWithJitterMs); + }); + } + /** + * Returns a randomized "jitter" delay based on the current base and jitter + * factor. + * + * @private + * @returns {number} The jitter to apply based on the current delay. + */ + _jitterDelayMs() { + return (Math.random() - 0.5) * this._jitterFactor * this._currentBaseMs; + } +} +exports.ExponentialBackoff = ExponentialBackoff; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/convert.js b/website/functions/node_modules/@google-cloud/firestore/build/src/convert.js new file mode 100644 index 00000000..8cf32c74 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/convert.js @@ -0,0 +1,213 @@ +/*! + * Copyright 2017 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. + */ +'use strict'; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const is_1 = __importDefault(require("is")); +const validate_1 = require("./validate"); +const validate = validate_1.createValidator(); +/*! + * @module firestore/convert + * @private + * + * This module contains utility functions to convert + * `firestore.v1beta1.Documents` from Proto3 JSON to their equivalent + * representation in Protobuf JS. Protobuf JS is the only encoding supported by + * this client, and dependencies that use Proto3 JSON (such as the Google Cloud + * Functions SDK) are supported through this conversion and its usage in + * {@see Firestore#snapshot_}. + */ +/** + * Converts an ISO 8601 or google.protobuf.Timestamp proto into Protobuf JS. + * + * @private + * @param {*=} timestampValue - The value to convert. + * @param {string=} argumentName - The argument name to use in the error message + * if the conversion fails. If omitted, 'timestampValue' is used. + * @return {{nanos,seconds}|undefined} The value as expected by Protobuf JS or + * undefined if no input was provided. + */ +function convertTimestamp(timestampValue, argumentName) { + let timestampProto = undefined; + if (is_1.default.string(timestampValue)) { + let date = new Date(timestampValue); + let seconds = Math.floor(date.getTime() / 1000); + let nanos = 0; + if (timestampValue.length > 20) { + const nanoString = timestampValue.substring(20, timestampValue.length - 1); + const trailingZeroes = 9 - nanoString.length; + nanos = parseInt(nanoString, 10) * Math.pow(10, trailingZeroes); + } + if (isNaN(seconds) || isNaN(nanos)) { + argumentName = argumentName || 'timestampValue'; + throw new Error(`Specify a valid ISO 8601 timestamp for "${argumentName}".`); + } + timestampProto = { + seconds: seconds || undefined, + nanos: nanos || undefined, + }; + } + else if (is_1.default.defined(timestampValue)) { + validate.isObject('timestampValue', timestampValue); + timestampProto = { + seconds: timestampValue.seconds || undefined, + nanos: timestampValue.nanos || undefined, + }; + } + return timestampProto; +} +/** + * Converts a Proto3 JSON 'bytesValue' field into Protobuf JS. + * + * @private + * @param {*} bytesValue - The value to convert. + * @return {Buffer} The value as expected by Protobuf JS. + */ +function convertBytes(bytesValue) { + if (typeof bytesValue === 'string') { + return Buffer.from(bytesValue, 'base64'); + } + else { + return bytesValue; + } +} +/** + * Detects 'valueType' from a Proto3 JSON `firestore.v1beta1.Value` proto. + * + * @private + * @param {object} proto - The `firestore.v1beta1.Value` proto. + * @return {string} - The string value for 'valueType'. + */ +function detectValueType(proto) { + if (proto.valueType) { + return proto.valueType; + } + let detectedValues = []; + if (is_1.default.defined(proto.stringValue)) { + detectedValues.push('stringValue'); + } + if (is_1.default.defined(proto.booleanValue)) { + detectedValues.push('booleanValue'); + } + if (is_1.default.defined(proto.integerValue)) { + detectedValues.push('integerValue'); + } + if (is_1.default.defined(proto.doubleValue)) { + detectedValues.push('doubleValue'); + } + if (is_1.default.defined(proto.timestampValue)) { + detectedValues.push('timestampValue'); + } + if (is_1.default.defined(proto.referenceValue)) { + detectedValues.push('referenceValue'); + } + if (is_1.default.defined(proto.arrayValue)) { + detectedValues.push('arrayValue'); + } + if (is_1.default.defined(proto.nullValue)) { + detectedValues.push('nullValue'); + } + if (is_1.default.defined(proto.mapValue)) { + detectedValues.push('mapValue'); + } + if (is_1.default.defined(proto.geoPointValue)) { + detectedValues.push('geoPointValue'); + } + if (is_1.default.defined(proto.bytesValue)) { + detectedValues.push('bytesValue'); + } + if (detectedValues.length !== 1) { + throw new Error(`Unable to infer type value fom '${JSON.stringify(proto)}'.`); + } + return detectedValues[0]; +} +/** + * Converts a `firestore.v1beta1.Value` in Proto3 JSON encoding into the + * Protobuf JS format expected by this client. + * + * @private + * @param {object} fieldValue - The `firestore.v1beta1.Value` in Proto3 JSON + * format. + * @return {object} The `firestore.v1beta1.Value` in Protobuf JS format. + */ +function convertValue(fieldValue) { + let valueType = detectValueType(fieldValue); + switch (valueType) { + case 'timestampValue': + return { + timestampValue: convertTimestamp(fieldValue.timestampValue), + }; + case 'bytesValue': + return { + bytesValue: convertBytes(fieldValue.bytesValue), + }; + case 'arrayValue': { + let arrayValue = []; + if (is_1.default.array(fieldValue.arrayValue.values)) { + for (let value of fieldValue.arrayValue.values) { + arrayValue.push(convertValue(value)); + } + } + return { + arrayValue: { + values: arrayValue, + }, + }; + } + case 'mapValue': { + let mapValue = {}; + for (let prop in fieldValue.mapValue.fields) { + if (fieldValue.mapValue.fields.hasOwnProperty(prop)) { + mapValue[prop] = convertValue(fieldValue.mapValue.fields[prop]); + } + } + return { + mapValue: { + fields: mapValue, + }, + }; + } + default: + return fieldValue; + } +} +/** + * Converts a `firestore.v1beta1.Document` in Proto3 JSON encoding into the + * Protobuf JS format expected by this client. This conversion creates a copy of + * the underlying document. + * + * @private + * @param {object} document - The `firestore.v1beta1.Document` in Proto3 JSON + * format. + * @return {object} The `firestore.v1beta1.Document` in Protobuf JS format. + */ +function convertDocument(document) { + let result = {}; + for (let prop in document) { + if (document.hasOwnProperty(prop)) { + result[prop] = convertValue(document[prop]); + } + } + return result; +} +module.exports = { + documentFromJson: convertDocument, + timestampFromJson: convertTimestamp, + valueFromJson: convertValue, + detectValueType: detectValueType, +}; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/document-change.js b/website/functions/node_modules/@google-cloud/firestore/build/src/document-change.js new file mode 100644 index 00000000..e10ebbaf --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/document-change.js @@ -0,0 +1,173 @@ +/*! + * Copyright 2018 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. + */ +'use strict'; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const is = __importStar(require("is")); +/** + * 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 { + /** + * @private + * @hideconstructor + * + * @param {string} type - 'added' | 'removed' | 'modified'. + * @param {QueryDocumentSnapshot} document - The document. + * @param {number} oldIndex - The index in the documents array prior to this + * change. + * @param {number} newIndex - The index in the documents array after this + * change. + */ + constructor(type, document, oldIndex, newIndex) { + this._type = type; + this._document = document; + this._oldIndex = oldIndex; + this._newIndex = newIndex; + } + /** + * The type of change ('added', 'modified', or 'removed'). + * + * @type {string} + * @name DocumentChange#type + * @readonly + * + * @example + * let query = firestore.collection('col').where('foo', '==', 'bar'); + * let docsArray = []; + * + * let unsubscribe = query.onSnapshot(querySnapshot => { + * for (let change of querySnapshot.docChanges) { + * console.log(`Type of change is ${change.type}`); + * } + * }); + * + * // Remove this listener. + * unsubscribe(); + */ + get type() { + return this._type; + } + /** + * The document affected by this change. + * + * @type {QueryDocumentSnapshot} + * @name DocumentChange#doc + * @readonly + * + * @example + * let query = firestore.collection('col').where('foo', '==', 'bar'); + * + * let unsubscribe = query.onSnapshot(querySnapshot => { + * for (let change of querySnapshot.docChanges) { + * console.log(change.doc.data()); + * } + * }); + * + * // Remove this listener. + * unsubscribe(); + */ + get doc() { + return this._document; + } + /** + * The index of the changed document in the result set immediately prior to + * this DocumentChange (i.e. supposing that all prior DocumentChange objects + * have been applied). Is -1 for 'added' events. + * + * @type {number} + * @name DocumentChange#oldIndex + * @readonly + * + * @example + * let query = firestore.collection('col').where('foo', '==', 'bar'); + * let docsArray = []; + * + * let unsubscribe = query.onSnapshot(querySnapshot => { + * for (let change of querySnapshot.docChanges) { + * if (change.oldIndex !== -1) { + * docsArray.splice(change.oldIndex, 1); + * } + * if (change.newIndex !== -1) { + * docsArray.splice(change.newIndex, 0, change.doc); + * } + * } + * }); + * + * // Remove this listener. + * unsubscribe(); + */ + get oldIndex() { + return this._oldIndex; + } + /** + * The index of the changed document in the result set immediately after + * this DocumentChange (i.e. supposing that all prior DocumentChange + * objects and the current DocumentChange object have been applied). + * Is -1 for 'removed' events. + * + * @type {number} + * @name DocumentChange#newIndex + * @readonly + * + * @example + * let query = firestore.collection('col').where('foo', '==', 'bar'); + * let docsArray = []; + * + * let unsubscribe = query.onSnapshot(querySnapshot => { + * for (let change of querySnapshot.docChanges) { + * if (change.oldIndex !== -1) { + * docsArray.splice(change.oldIndex, 1); + * } + * if (change.newIndex !== -1) { + * docsArray.splice(change.newIndex, 0, change.doc); + * } + * } + * }); + * + * // Remove this listener. + * unsubscribe(); + */ + get newIndex() { + return this._newIndex; + } + /** + * Returns true if the data in this `DocumentChange` is equal to the provided + * value. + * + * @param {*} other The value to compare against. + * @return true if this `DocumentChange` is equal to the provided value. + */ + isEqual(other) { + if (this === other) { + return true; + } + return (is.instanceof(other, DocumentChange) && this._type === other._type && + this._oldIndex === other._oldIndex && + this._newIndex === other._newIndex && + this._document.isEqual(other._document)); + } +} +exports.DocumentChange = DocumentChange; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/document.js b/website/functions/node_modules/@google-cloud/firestore/build/src/document.js new file mode 100644 index 00000000..7eecf1d5 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/document.js @@ -0,0 +1,1025 @@ +/*! + * Copyright 2017 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. + */ +'use strict'; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const assert_1 = __importDefault(require("assert")); +const deep_equal_1 = __importDefault(require("deep-equal")); +const is_1 = __importDefault(require("is")); +const path_1 = require("./path"); +const field_value_1 = require("./field-value"); +const timestamp_1 = require("./timestamp"); +const serializer_1 = require("./serializer"); +/** + * A DocumentSnapshot is an immutable representation for a document in a + * Firestore database. The data can be extracted with + * [data()]{@link DocumentSnapshot#data} or + * [get(fieldPath)]{@link DocumentSnapshot#get} to get a + * specific field. + * + *

For a DocumentSnapshot that points to a non-existing document, any data + * access will return 'undefined'. You can use the + * [exists]{@link DocumentSnapshot#exists} property to explicitly verify a + * document's existence. + * + * @class + */ +class DocumentSnapshot { + /** + * @private + * @hideconstructor + * + * @param {firestore/DocumentReference} ref - The reference to the + * document. + * @param {object=} fieldsProto - The fields of the Firestore `Document` + * Protobuf backing this document (or undefined if the document does not + * exist). + * @param {Timestamp} readTime - The time when this snapshot was read. + * @param {Timestamp=} createTime - The time when the document was created + * (or undefined if the document does not exist). + * @param {Timestamp=} updateTime - The time when the document was last + * updated (or undefined if the document does not exist). + */ + constructor(ref, fieldsProto, readTime, createTime, updateTime) { + this._ref = ref; + this._fieldsProto = fieldsProto; + this._serializer = ref.firestore._serializer; + this._validator = ref.firestore._validator; + this._readTime = readTime; + this._createTime = createTime; + this._updateTime = updateTime; + } + /** + * Creates a DocumentSnapshot from an object. + * + * @private + * @param {firestore/DocumentReference} ref - The reference to the document. + * @param {Object} obj - The object to store in the DocumentSnapshot. + * @return {firestore.DocumentSnapshot} The created DocumentSnapshot. + */ + static fromObject(ref, obj) { + const serializer = ref.firestore._serializer; + return new DocumentSnapshot(ref, serializer.encodeFields(obj)); + } + /** + * Creates a DocumentSnapshot from an UpdateMap. + * + * This methods expands the top-level field paths in a JavaScript map and + * turns { foo.bar : foobar } into { foo { bar : foobar }} + * + * @private + * @param {firestore/DocumentReference} ref - The reference to the document. + * @param {Map.} data - The field/value map to expand. + * @return {firestore.DocumentSnapshot} The created DocumentSnapshot. + */ + static fromUpdateMap(ref, data) { + const serializer = ref.firestore._serializer; + /** + * Merges 'value' at the field path specified by the path array into + * 'target'. + */ + function merge(target, value, path, pos) { + let key = path[pos]; + let isLast = pos === path.length - 1; + if (!is_1.default.defined(target[key])) { + if (isLast) { + if (value instanceof field_value_1.FieldTransform) { + // If there is already data at this path, we need to retain it. + // Otherwise, we don't include it in the DocumentSnapshot. + return !is_1.default.empty(target) ? target : null; + } + // The merge is done. + const leafNode = serializer.encodeValue(value); + if (leafNode) { + target[key] = leafNode; + } + return target; + } + else { + // We need to expand the target object. + const childNode = { + mapValue: { + fields: {}, + }, + }; + const nestedValue = merge(childNode.mapValue.fields, value, path, pos + 1); + if (nestedValue) { + childNode.mapValue.fields = nestedValue; + target[key] = childNode; + return target; + } + else { + return !is_1.default.empty(target) ? target : null; + } + } + } + else { + assert_1.default(!isLast, 'Can\'t merge current value into a nested object'); + target[key].mapValue.fields = + merge(target[key].mapValue.fields, value, path, pos + 1); + return target; + } + } + let res = {}; + data.forEach((value, key) => { + let components = key.toArray(); + merge(res, value, components, 0); + }); + return new DocumentSnapshot(ref, res); + } + /** + * True if the document exists. + * + * @type {boolean} + * @name DocumentSnapshot#exists + * @readonly + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * documentRef.get().then((documentSnapshot) => { + * if (documentSnapshot.exists) { + * console.log(`Data: ${JSON.stringify(documentSnapshot.data())}`); + * } + * }); + */ + get exists() { + return this._fieldsProto !== undefined; + } + /** + * A [DocumentReference]{@link DocumentReference} for the document + * stored in this snapshot. + * + * @type {DocumentReference} + * @name DocumentSnapshot#ref + * @readonly + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * documentRef.get().then((documentSnapshot) => { + * if (documentSnapshot.exists) { + * console.log(`Found document at '${documentSnapshot.ref.path}'`); + * } + * }); + */ + get ref() { + return this._ref; + } + /** + * The ID of the document for which this DocumentSnapshot contains data. + * + * @type {string} + * @name DocumentSnapshot#id + * @readonly + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * documentRef.get().then((documentSnapshot) => { + * if (documentSnapshot.exists) { + * console.log(`Document found with name '${documentSnapshot.id}'`); + * } + * }); + */ + get id() { + return this._ref.id; + } + /** + * The time the document was created. Undefined for documents that don't + * exist. + * + * @type {Timestamp|undefined} + * @name DocumentSnapshot#createTime + * @readonly + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * documentRef.get().then(documentSnapshot => { + * if (documentSnapshot.exists) { + * let createTime = documentSnapshot.createTime; + * console.log(`Document created at '${createTime.toDate()}'`); + * } + * }); + */ + get createTime() { + return this._createTime; + } + /** + * The time the document was last updated (at the time the snapshot was + * generated). Undefined for documents that don't exist. + * + * @type {Timestamp|undefined} + * @name DocumentSnapshot#updateTime + * @readonly + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * documentRef.get().then(documentSnapshot => { + * if (documentSnapshot.exists) { + * let updateTime = documentSnapshot.updateTime; + * console.log(`Document updated at '${updateTime.toDate()}'`); + * } + * }); + */ + get updateTime() { + return this._updateTime; + } + /** + * The time this snapshot was read. + * + * @type {Timestamp} + * @name DocumentSnapshot#readTime + * @readonly + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * documentRef.get().then(documentSnapshot => { + * let readTime = documentSnapshot.readTime; + * console.log(`Document read at '${readTime.toDate()}'`); + * }); + */ + get readTime() { + return this._readTime; + } + /** + * 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. + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * documentRef.get().then(documentSnapshot => { + * let data = documentSnapshot.data(); + * console.log(`Retrieved data: ${JSON.stringify(data)}`); + * }); + */ + data() { + let fields = this.protoFields(); + if (is_1.default.undefined(fields)) { + return undefined; + } + let obj = {}; + for (let prop in fields) { + if (fields.hasOwnProperty(prop)) { + obj[prop] = this._serializer.decodeValue(fields[prop]); + } + } + return obj; + } + /** + * Returns the underlying Firestore 'Fields' Protobuf in Protobuf JS format. + * + * @private + * @returns {Object} The Protobuf encoded document. + */ + protoFields() { + return this._fieldsProto; + } + /** + * Retrieves the field specified by `field`. + * + * @param {string|FieldPath} field - The field path + * (e.g. 'foo' or 'foo.bar') to a specific field. + * @returns {*} The data at the specified field location or undefined if no + * such field exists. + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * documentRef.set({ a: { b: 'c' }}).then(() => { + * return documentRef.get(); + * }).then(documentSnapshot => { + * let field = documentSnapshot.get('a.b'); + * console.log(`Retrieved field value: ${field}`); + * }); + */ + get(field) { + this._validator.isFieldPath('field', field); + let protoField = this.protoField(field); + if (protoField === undefined) { + return undefined; + } + return this._serializer.decodeValue(protoField); + } + /** + * Retrieves the field specified by 'fieldPath' in its Protobuf JS + * representation. + * + * @private + * @param {string|FieldPath} 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. + */ + protoField(field) { + let fields = this.protoFields(); + if (is_1.default.undefined(fields)) { + return undefined; + } + let components = path_1.FieldPath.fromArgument(field).toArray(); + while (components.length > 1) { + fields = fields[components.shift()]; + if (!fields || !fields.mapValue) { + return undefined; + } + fields = fields.mapValue.fields; + } + return fields[components[0]]; + } + /** + * Checks whether this DocumentSnapshot contains any fields. + * + * @private + * @return {boolean} + */ + get isEmpty() { + return is_1.default.undefined(this._fieldsProto) || is_1.default.empty(this._fieldsProto); + } + /** + * Convert a document snapshot to the Firestore 'Document' Protobuf. + * + * @private + * @returns {Object} - The document in the format the API expects. + */ + toProto() { + return { + update: { + name: this._ref.formattedName, + fields: this._fieldsProto, + }, + }; + } + /** + * Returns true if the document's data and path in this `DocumentSnapshot` is + * equal to the provided value. + * + * @param {*} other The value to compare against. + * @return {boolean} true if this `DocumentSnapshot` is equal to the provided + * value. + */ + isEqual(other) { + // Since the read time is different on every document read, we explicitly + // ignore all document metadata in this comparison. + return (this === other || + (is_1.default.instance(other, DocumentSnapshot) && + this._ref.isEqual(other._ref) && + deep_equal_1.default(this._fieldsProto, other._fieldsProto, { strict: true }))); + } +} +exports.DocumentSnapshot = DocumentSnapshot; +/** + * A QueryDocumentSnapshot contains data read from a document in your + * Firestore database as part of a query. The document is guaranteed to exist + * and its data can be extracted with [data()]{@link QueryDocumentSnapshot#data} + * or [get()]{@link DocumentSnapshot#get} to get a specific field. + * + * A QueryDocumentSnapshot offers the same API surface as a + * {@link DocumentSnapshot}. Since query results contain only existing + * documents, the [exists]{@link DocumentSnapshot#exists} property will + * always be true and [data()]{@link QueryDocumentSnapshot#data} will never + * return 'undefined'. + * + * @class + * @extends DocumentSnapshot + */ +class QueryDocumentSnapshot extends DocumentSnapshot { + /** + * @private + * @hideconstructor + * + * @param {firestore/DocumentReference} ref - The reference to the document. + * @param {object} fieldsProto - The fields of the Firestore `Document` + * Protobuf backing this document. + * @param {Timestamp} readTime - The time when this snapshot was read. + * @param {Timestamp} createTime - The time when the document was created. + * @param {Timestamp} updateTime - The time when the document was last + * updated. + */ + constructor(ref, fieldsProto, readTime, createTime, updateTime) { + super(ref, fieldsProto, readTime, createTime, updateTime); + } + /** + * The time the document was created. + * + * @type {Timestamp} + * @name QueryDocumentSnapshot#createTime + * @readonly + * @override + * + * @example + * let query = firestore.collection('col'); + * + * query.get().forEach(snapshot => { + * console.log(`Document created at '${snapshot.createTime.toDate()}'`); + * }); + */ + get createTime() { + return super.createTime; + } + /** + * The time the document was last updated (at the time the snapshot was + * generated). + * + * @type {Timestamp} + * @name QueryDocumentSnapshot#updateTime + * @readonly + * @override + * + * @example + * let query = firestore.collection('col'); + * + * query.get().forEach(snapshot => { + * console.log(`Document updated at '${snapshot.updateTime.toDate()}'`); + * }); + */ + get updateTime() { + return super.updateTime; + } + /** + * Retrieves all fields in the document as an object. + * + * @override + * + * @returns {DocumentData} An object containing all fields in the document. + * + * @example + * let query = firestore.collection('col'); + * + * query.get().forEach(documentSnapshot => { + * let data = documentSnapshot.data(); + * console.log(`Retrieved data: ${JSON.stringify(data)}`); + * }); + */ + data() { + let data = super.data(); + assert_1.default(is_1.default.defined(data), 'The data in a QueryDocumentSnapshot should always exist.'); + return data; + } +} +exports.QueryDocumentSnapshot = QueryDocumentSnapshot; +/** + * Returns a builder for DocumentSnapshot and QueryDocumentSnapshot instances. + * Invoke `.build()' to assemble the final snapshot. + * + * @private + * @class + */ +class DocumentSnapshotBuilder { + /** + * @private + * @hideconstructor + * + * @param {DocumentSnapshot=} snapshot An optional snapshot to base this + * builder on. + */ + constructor(snapshot) { + snapshot = snapshot || {}; + /** + * The reference to the document. + * + * @type {DocumentReference} + */ + this.ref = snapshot._ref; + /** + * The fields of the Firestore `Document` Protobuf backing this document. + * + * @type {object} + */ + this.fieldsProto = snapshot._fieldsProto; + /** + * The time when this document was read. + * + * @type {Timestamp} + */ + this.readTime = snapshot._readTime; + /** + * The time when this document was created. + * + * @type {Timestamp} + */ + this.createTime = snapshot._createTime; + /** + * The time when this document was last updated. + * + * @type {Timestamp} + */ + this.updateTime = snapshot._updateTime; + } + /** + * Builds the DocumentSnapshot. + * + * @private + * @returns {QueryDocumentSnapshot|DocumentSnapshot} Returns either a + * QueryDocumentSnapshot (if `fieldsProto` was provided) or a + * DocumentSnapshot. + */ + build() { + assert_1.default(is_1.default.defined(this.fieldsProto) === is_1.default.defined(this.createTime), 'Create time should be set iff document exists.'); + assert_1.default(is_1.default.defined(this.fieldsProto) === is_1.default.defined(this.updateTime), 'Update time should be set iff document exists.'); + return this.fieldsProto ? + new QueryDocumentSnapshot(this.ref, this.fieldsProto, this.readTime, this.createTime, this.updateTime) : + new DocumentSnapshot(this.ref, undefined, this.readTime); + } +} +/** + * @private + * @name DocumentSnapshot.DocumentSnapshotBuilder + * @see DocumentSnapshotBuilder + */ +DocumentSnapshot.Builder = DocumentSnapshotBuilder; +/** + * A Firestore Document Mask contains the field paths affected by an update. + * + * @class + * @private + */ +class DocumentMask { + /** + * @private + * @hideconstructor + * + * @param {Array.} fieldPaths - The field paths in this mask. + */ + constructor(fieldPaths) { + this._sortedPaths = fieldPaths; + this._sortedPaths.sort((a, b) => a.compareTo(b)); + } + /** + * Creates a document mask with the field paths of a document. + * + * @private + * @param {Map.} data A map with + * fields to modify. Only the keys are used to extract the document mask. + * @returns {DocumentMask} + */ + static fromUpdateMap(data) { + let fieldPaths = []; + data.forEach((value, key) => { + if (!(value instanceof field_value_1.FieldTransform) || value.includeInDocumentMask) { + fieldPaths.push(path_1.FieldPath.fromArgument(key)); + } + }); + return new DocumentMask(fieldPaths); + } + /** + * Creates a document mask from an array of field paths. + * + * @private + * @param {Array.} fieldMask A list of field paths. + * @returns {DocumentMask} + */ + static fromFieldMask(fieldMask) { + let fieldPaths = []; + for (const fieldPath of fieldMask) { + fieldPaths.push(path_1.FieldPath.fromArgument(fieldPath)); + } + return new DocumentMask(fieldPaths); + } + /** + * Creates a document mask with the field names of a document. + * + * @private + * @param {DocumentData} data An object with fields to modify. Only the keys + * are used to extract the document mask. + * @returns {DocumentMask} + */ + static fromObject(data) { + let fieldPaths = []; + const extractFieldPaths = function (currentData, currentPath) { + let isEmpty = true; + for (let key in currentData) { + if (currentData.hasOwnProperty(key)) { + isEmpty = false; + // We don't split on dots since fromObject is called with + // DocumentData. + const childSegment = new path_1.FieldPath(key); + const childPath = currentPath ? currentPath.append(childSegment) : childSegment; + const value = currentData[key]; + if (value instanceof field_value_1.FieldTransform) { + if (value.includeInDocumentMask) { + fieldPaths.push(childPath); + } + } + else if (serializer_1.isPlainObject(value)) { + extractFieldPaths(value, childPath); + } + else { + fieldPaths.push(childPath); + } + } + } + // Add a field path for an explicitly updated empty map. + if (currentPath && isEmpty) { + fieldPaths.push(currentPath); + } + }; + extractFieldPaths(data); + return new DocumentMask(fieldPaths); + } + /** + * Returns true if this document mask contains no fields. + * + * @private + * @return {boolean} Whether this document mask is empty. + */ + get isEmpty() { + return this._sortedPaths.length === 0; + } + /** + * Removes the specified values from a sorted field path array. + * + * @private + * @param {Array.} input - A sorted array of FieldPaths. + * @param {Array.} values - An array of FieldPaths to remove. + */ + static removeFromSortedArray(input, values) { + for (let i = 0; i < input.length;) { + let removed = false; + for (const fieldPath of values) { + if (input[i].isEqual(fieldPath)) { + input.splice(i, 1); + removed = true; + break; + } + } + if (!removed) { + ++i; + } + } + } + /** + * Removes the field path specified in 'fieldPaths' from this document mask. + * + * @private + * @param {Array.} fieldPaths An array of FieldPaths. + */ + removeFields(fieldPaths) { + DocumentMask.removeFromSortedArray(this._sortedPaths, fieldPaths); + } + /** + * Returns whether this document mask contains 'fieldPath'. + * + * @private + * @param {FieldPath} fieldPath The field path to test. + * @return {boolean} Whether this document mask contains 'fieldPath'. + */ + contains(fieldPath) { + for (const sortedPath of this._sortedPaths) { + const cmp = sortedPath.compareTo(fieldPath); + if (cmp === 0) { + return true; + } + else if (cmp > 0) { + return false; + } + } + return false; + } + /** + * Removes all properties from 'data' that are not contained in this document + * mask. + * + * @private + * @param {Object} data - An object to filter. + * @return {Object} A shallow copy of the object filtered by this document + * mask. + */ + applyTo(data) { + /*! + * 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 => { + const remainingPaths = this._sortedPaths.slice(0); + const processObject = (currentData, currentPath) => { + let result = null; + Object.keys(currentData).forEach(key => { + const childPath = currentPath ? currentPath.append(key) : new path_1.FieldPath(key); + if (this.contains(childPath)) { + DocumentMask.removeFromSortedArray(remainingPaths, [childPath]); + result = result || {}; + result[key] = currentData[key]; + } + else if (is_1.default.object(currentData[key])) { + const childObject = processObject(currentData[key], childPath); + if (childObject) { + result = result || {}; + result[key] = childObject; + } + } + }); + return result; + }; + // processObject() returns 'null' if the DocumentMask is empty. + const filteredData = processObject(data) || {}; + return { + filteredData: filteredData, + remainingPaths: remainingPaths, + }; + }; + const result = applyDocumentMask(data); + if (result.remainingPaths.length !== 0) { + throw new Error(`Input data is missing for field '${result.remainingPaths[0].toString()}'.`); + } + return result.filteredData; + } + /** + * Converts a document mask to the Firestore 'DocumentMask' Proto. + * + * @private + * @returns {Object} A Firestore 'DocumentMask' Proto. + */ + toProto() { + if (this.isEmpty) { + return {}; + } + let encodedPaths = []; + for (const fieldPath of this._sortedPaths) { + encodedPaths.push(fieldPath.formattedName); + } + return { + fieldPaths: encodedPaths, + }; + } +} +exports.DocumentMask = DocumentMask; +/** + * A Firestore Document Transform. + * + * A DocumentTransform contains pending server-side transforms and their + * corresponding field paths. + * + * @private + * @class + */ +class DocumentTransform { + /** + * @private + * @hideconstructor + * + * @param {DocumentReference} ref The DocumentReference for this + * transform. + * @param {Map.} transforms A Map of FieldPaths to + * FieldTransforms. + */ + constructor(ref, transforms) { + this._ref = ref; + this._validator = ref.firestore._validator; + this._transforms = transforms; + } + /** + * Generates a DocumentTransform from a JavaScript object. + * + * @private + * @param {firestore/DocumentReference} ref The `DocumentReference` to + * use for the DocumentTransform. + * @param {Object} obj The object to extract the transformations from. + * @returns {firestore.DocumentTransform} The Document Transform. + */ + static fromObject(ref, obj) { + let updateMap = new Map(); + for (let prop in obj) { + if (obj.hasOwnProperty(prop)) { + updateMap.set(new path_1.FieldPath(prop), obj[prop]); + } + } + return DocumentTransform.fromUpdateMap(ref, updateMap); + } + /** + * Generates a DocumentTransform from an Update Map. + * + * @private + * @param {firestore/DocumentReference} ref The `DocumentReference` to + * use for the DocumentTransform. + * @param {Map} data The map to extract the transformations from. + * @returns {firestore.DocumentTransform}} The Document Transform. + */ + static fromUpdateMap(ref, data) { + let transforms = new Map(); + function encode_(val, path, allowTransforms) { + if (val instanceof field_value_1.FieldTransform && val.includeInDocumentTransform) { + if (allowTransforms) { + transforms.set(path, val); + } + else { + throw new Error(`${val.methodName}() is not supported inside of array values.`); + } + } + else if (is_1.default.array(val)) { + for (let i = 0; i < val.length; ++i) { + // We need to verify that no array value contains a document transform + encode_(val[i], path.append(String(i)), false); + } + } + else if (serializer_1.isPlainObject(val)) { + for (let prop in val) { + if (val.hasOwnProperty(prop)) { + encode_(val[prop], path.append(new path_1.FieldPath(prop)), allowTransforms); + } + } + } + } + data.forEach((value, key) => { + encode_(value, path_1.FieldPath.fromArgument(key), true); + }); + return new DocumentTransform(ref, transforms); + } + /** + * Whether this DocumentTransform contains any actionable transformations. + * + * @private + * @type {boolean} + * @readonly + */ + get isEmpty() { + return this._transforms.size === 0; + } + /** + * Returns the array of fields in this DocumentTransform. + * + * @private + * @type {Array.} + * @readonly + */ + get fields() { + return Array.from(this._transforms.keys()); + } + /** Validates the user provided field values in this document transform. */ + validate() { + this._transforms.forEach(transform => transform.validate(this._validator)); + } + /** + * Converts a document transform to the Firestore 'DocumentTransform' Proto. + * + * @private + * @param {Serializer} serializer - The Firestore serializer + * @returns {Object|null} A Firestore 'DocumentTransform' Proto or 'null' if + * this transform is empty. + */ + toProto(serializer) { + if (this.isEmpty) { + return null; + } + const protoTransforms = []; + this._transforms.forEach((transform, path) => { + protoTransforms.push(transform.toProto(serializer, path)); + }); + return { + transform: { + document: this._ref.formattedName, + fieldTransforms: protoTransforms, + }, + }; + } +} +exports.DocumentTransform = DocumentTransform; +/*! + * A Firestore Precondition encapsulates options for database writes. + * + * @private + * @class + */ +class Precondition { + /** + * @private + * @hideconstructor + * + * @param {boolean=} options.exists - Whether the referenced document should + * exist in Firestore, + * @param {Timestamp=} options.lastUpdateTime - The last update time of the + * referenced document in Firestore. + * @param options + */ + constructor(options) { + if (is_1.default.object(options)) { + this._exists = options.exists; + this._lastUpdateTime = options.lastUpdateTime; + } + } + /** + * Generates the Protobuf `Preconditon` object for this precondition. + * + * @private + * @returns {Object|null} The `Preconditon` Protobuf object or 'null' if there + * are no preconditions. + */ + toProto() { + if (this.isEmpty) { + return null; + } + let proto = {}; + if (is_1.default.defined(this._lastUpdateTime)) { + proto.updateTime = this._lastUpdateTime.toProto().timestampValue; + } + else { + proto.exists = this._exists; + } + return proto; + } + /** + * Whether this DocumentTransform contains any enforcement. + * + * @private + * @type {boolean} + * @readonly + */ + get isEmpty() { + return this._exists === undefined && !this._lastUpdateTime; + } +} +exports.Precondition = Precondition; +/*! + * Validates the use of 'options' as a Precondition and enforces that 'exists' + * and 'lastUpdateTime' use valid types. + * + * @param {boolean=} options.exists - Whether the referenced document + * should exist. + * @param {Timestamp=} options.lastUpdateTime - The last update time + * of the referenced document in Firestore. + * @param {boolean} allowExist Whether to allow the 'exists' preconditions. + * @returns {boolean} 'true' if the input is a valid Precondition. + */ +function validatePrecondition(precondition, allowExist) { + if (!is_1.default.object(precondition)) { + throw new Error('Input is not an object.'); + } + let conditions = 0; + if (is_1.default.defined(precondition.exists)) { + ++conditions; + if (!allowExist) { + throw new Error('"exists" is not an allowed condition.'); + } + if (!is_1.default.boolean(precondition.exists)) { + throw new Error('"exists" is not a boolean.'); + } + } + if (is_1.default.defined(precondition.lastUpdateTime)) { + ++conditions; + if (!is_1.default.instance(precondition.lastUpdateTime, timestamp_1.Timestamp)) { + throw new Error('"lastUpdateTime" is not a Firestore Timestamp.'); + } + } + if (conditions > 1) { + throw new Error('Input contains more than one condition.'); + } + return true; +} +exports.validatePrecondition = validatePrecondition; +/*! + * Validates the use of 'options' as SetOptions and enforces that 'merge' is a + * boolean. + * + * @param {boolean=} options.merge - Whether set() should merge the provided + * data into an existing document. + * @param {boolean=} options.mergeFields - Whether set() should only merge the + * specified set of fields. + * @returns {boolean} 'true' if the input is a valid SetOptions object. + */ +function validateSetOptions(options) { + if (!is_1.default.object(options)) { + throw new Error('Input is not an object.'); + } + if (is_1.default.defined(options.merge) && !is_1.default.boolean(options.merge)) { + throw new Error('"merge" is not a boolean.'); + } + if (is_1.default.defined(options.mergeFields)) { + if (!is_1.default.array(options.mergeFields)) { + throw new Error('"mergeFields" is not an array.'); + } + for (let i = 0; i < options.mergeFields.length; ++i) { + try { + path_1.FieldPath.validateFieldPath(options.mergeFields[i]); + } + catch (err) { + throw new Error(`Argument at index ${i} is not a valid FieldPath. ${err.message}`); + } + } + } + if (is_1.default.defined(options.merge) && is_1.default.defined(options.mergeFields)) { + throw new Error('You cannot specify both "merge" and "mergeFields".'); + } + return true; +} +exports.validateSetOptions = validateSetOptions; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/field-value.js b/website/functions/node_modules/@google-cloud/firestore/build/src/field-value.js new file mode 100644 index 00000000..18d459b2 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/field-value.js @@ -0,0 +1,324 @@ +/*! + * Copyright 2018 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. + */ +'use strict'; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const deep_equal_1 = __importDefault(require("deep-equal")); +const validate_1 = require("./validate"); +const firestore_proto_api_1 = require("../protos/firestore_proto_api"); +var api = firestore_proto_api_1.google.firestore.v1beta1; +const validate = validate_1.createValidator(); +/** + * Sentinel values that can be used when writing documents with set(), create() + * or update(). + * + * @class + */ +class FieldValue { + /** + * @private + * @hideconstructor + */ + constructor() { } + /** + * Returns a sentinel for use with update() or set() with {merge:true} to mark + * a field for deletion. + * + * @returns {FieldValue} The sentinel value to use in your objects. + * + * @example + * let documentRef = firestore.doc('col/doc'); + * let data = { a: 'b', c: 'd' }; + * + * documentRef.set(data).then(() => { + * return documentRef.update({a: Firestore.FieldValue.delete()}); + * }).then(() => { + * // Document now only contains { c: 'd' } + * }); + */ + static delete() { + return DeleteTransform.DELETE_SENTINEL; + } + /** + * Returns a sentinel used with set(), create() or update() to include a + * server-generated timestamp in the written data. + * + * @return {FieldValue} The FieldValue sentinel for use in a call to set(), + * create() or update(). + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * documentRef.set({ + * time: Firestore.FieldValue.serverTimestamp() + * }).then(() => { + * return documentRef.get(); + * }).then(doc => { + * console.log(`Server time set to ${doc.get('time')}`); + * }); + */ + static serverTimestamp() { + return ServerTimestampTransform.SERVER_TIMESTAMP_SENTINEL; + } + /** + * Returns a special value that can be used with set(), create() or update() + * that tells the server to union the given elements with any array value that + * already exists on the server. Each specified element that doesn't already + * exist in the array will be added to the end. If the field being modified is + * not already an array it will be overwritten with an array containing + * exactly the specified elements. + * + * @param {...*} elements The elements to union into the array. + * @return {FieldValue} The FieldValue sentinel for use in a call to set(), + * create() or update(). + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * documentRef.update( + * 'array', Firestore.FieldValue.arrayUnion('foo') + * ).then(() => { + * return documentRef.get(); + * }).then(doc => { + * // doc.get('array') contains field 'foo' + * }); + */ + static arrayUnion(...elements) { + validate.minNumberOfArguments('FieldValue.arrayUnion', arguments, 1); + return new ArrayUnionTransform(elements); + } + /** + * Returns a special value that can be used with set(), create() or update() + * that tells the server to remove the given elements from any array value + * that already exists on the server. All instances of each element specified + * will be removed from the array. If the field being modified is not already + * an array it will be overwritten with an empty array. + * + * @param {...*} elements The elements to remove from the array. + * @return {FieldValue} The FieldValue sentinel for use in a call to set(), + * create() or update(). + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * documentRef.update( + * 'array', Firestore.FieldValue.arrayRemove('foo') + * ).then(() => { + * return documentRef.get(); + * }).then(doc => { + * // doc.get('array') no longer contains field 'foo' + * }); + */ + static arrayRemove(...elements) { + validate.minNumberOfArguments('FieldValue.arrayRemove', arguments, 1); + return new ArrayRemoveTransform(elements); + } + /** + * Returns true if this `FieldValue` is equal to the provided value. + * + * @param {*} other The value to compare against. + * @return {boolean} true if this `FieldValue` is equal to the provided value. + */ + isEqual(other) { + return this === other; + } +} +exports.FieldValue = FieldValue; +/** + * An internal interface shared by all field transforms. + * + * A 'FieldTransform` subclass should implement '.includeInDocumentMask', + * '.includeInDocumentTransform' and 'toProto' (if '.includeInDocumentTransform' + * is 'true'). + * + * @private + * @abstract + */ +class FieldTransform extends FieldValue { +} +exports.FieldTransform = FieldTransform; +/** + * A transform that deletes a field from a Firestore document. + * + * @private + */ +class DeleteTransform extends FieldTransform { + constructor() { + super(); + } + /** + * Deletes are included in document masks. + */ + get includeInDocumentMask() { + return true; + } + /** + * Deletes are are omitted from document transforms. + */ + get includeInDocumentTransform() { + return false; + } + get methodName() { + return 'FieldValue.delete'; + } + validate() { + return true; + } + toProto(serializer, fieldPath) { + throw new Error('FieldValue.delete() should not be included in a FieldTransform'); + } +} +/** + * Sentinel value for a field delete. + */ +DeleteTransform.DELETE_SENTINEL = new DeleteTransform(); +exports.DeleteTransform = DeleteTransform; +/** + * A transform that sets a field to the Firestore server time. + * + * @private + */ +class ServerTimestampTransform extends FieldTransform { + constructor() { + super(); + } + /** + * Server timestamps are omitted from document masks. + * + * @private + */ + get includeInDocumentMask() { + return false; + } + /** + * Server timestamps are included in document transforms. + * + * @private + */ + get includeInDocumentTransform() { + return true; + } + get methodName() { + return 'FieldValue.serverTimestamp'; + } + validate() { + return true; + } + toProto(serializer, fieldPath) { + return { + fieldPath: fieldPath.formattedName, + setToServerValue: api.DocumentTransform.FieldTransform.ServerValue.REQUEST_TIME, + }; + } +} +/** + * Sentinel value for a server timestamp. + * + * @private + */ +ServerTimestampTransform.SERVER_TIMESTAMP_SENTINEL = new ServerTimestampTransform(); +/** + * Transforms an array value via a union operation. + * + * @private + */ +class ArrayUnionTransform extends FieldTransform { + constructor(elements) { + super(); + this.elements = elements; + } + /** + * Array transforms are omitted from document masks. + */ + get includeInDocumentMask() { + return false; + } + /** + * Array transforms are included in document transforms. + */ + get includeInDocumentTransform() { + return true; + } + get methodName() { + return 'FieldValue.arrayUnion'; + } + validate(validator) { + let valid = true; + for (let i = 0; valid && i < this.elements.length; ++i) { + valid = validator.isArrayElement(i, this.elements[i], { allowDeletes: 'none', allowTransforms: false }); + } + return valid; + } + toProto(serializer, fieldPath) { + const encodedElements = serializer.encodeValue(this.elements).arrayValue; + return { + fieldPath: fieldPath.formattedName, + appendMissingElements: encodedElements + }; + } + isEqual(other) { + return (this === other || + (other instanceof ArrayUnionTransform && + deep_equal_1.default(this.elements, other.elements, { strict: true }))); + } +} +/** + * Transforms an array value via a remove operation. + * + * @private + */ +class ArrayRemoveTransform extends FieldTransform { + constructor(elements) { + super(); + this.elements = elements; + } + /** + * Array transforms are omitted from document masks. + */ + get includeInDocumentMask() { + return false; + } + /** + * Array transforms are included in document transforms. + */ + get includeInDocumentTransform() { + return true; + } + get methodName() { + return 'FieldValue.arrayRemove'; + } + validate(validator) { + let valid = true; + for (let i = 0; valid && i < this.elements.length; ++i) { + valid = validator.isArrayElement(i, this.elements[i], { allowDeletes: 'none', allowTransforms: false }); + } + return valid; + } + toProto(serializer, fieldPath) { + const encodedElements = serializer.encodeValue(this.elements).arrayValue; + return { + fieldPath: fieldPath.formattedName, + removeAllFromArray: encodedElements + }; + } + isEqual(other) { + return (this === other || + (other instanceof ArrayRemoveTransform && + deep_equal_1.default(this.elements, other.elements, { strict: true }))); + } +} diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/geo-point.js b/website/functions/node_modules/@google-cloud/firestore/build/src/geo-point.js new file mode 100644 index 00000000..d4c06c6b --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/geo-point.js @@ -0,0 +1,108 @@ +/*! + * Copyright 2018 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. + */ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +const validate_1 = require("./validate"); +const validate = validate_1.createValidator(); +/** + * An immutable object representing a geographic location in Firestore. The + * location is represented as a latitude/longitude pair. + * + * @class + */ +class GeoPoint { + /** + * Creates a [GeoPoint]{@link GeoPoint}. + * + * @param {number} latitude The latitude as a number between -90 and 90. + * @param {number} longitude The longitude as a number between -180 and 180. + * + * @example + * let data = { + * google: new Firestore.GeoPoint(37.422, 122.084) + * }; + * + * firestore.doc('col/doc').set(data).then(() => { + * console.log(`Location is ${data.google.latitude}, ` + + * `${data.google.longitude}`); + * }); + */ + constructor(latitude, longitude) { + validate.isNumber('latitude', latitude, -90, 90); + validate.isNumber('longitude', longitude, -180, 180); + this._latitude = latitude; + this._longitude = longitude; + } + /** + * The latitude as a number between -90 and 90. + * + * @type {number} + * @name GeoPoint#latitude + * @readonly + */ + get latitude() { + return this._latitude; + } + /** + * The longitude as a number between -180 and 180. + * + * @type {number} + * @name GeoPoint#longitude + * @readonly + */ + get longitude() { + return this._longitude; + } + /** + * Returns a string representation for this GeoPoint. + * + * @return {string} The string representation. + */ + toString() { + return `GeoPoint { latitude: ${this.latitude}, longitude: ${this.longitude} }`; + } + /** + * Returns true if this `GeoPoint` is equal to the provided value. + * + * @param {*} other The value to compare against. + * @return {boolean} true if this `GeoPoint` is equal to the provided value. + */ + isEqual(other) { + return (this === other || + (other instanceof GeoPoint && this.latitude === other.latitude && + this.longitude === other.longitude)); + } + /** + * Converts the GeoPoint to a google.type.LatLng proto. + * @private + */ + toProto() { + return { + geoPointValue: { + latitude: this.latitude, + longitude: this.longitude, + } + }; + } + /** + * Converts a google.type.LatLng proto to its GeoPoint representation. + * @private + */ + static fromProto(proto) { + return new GeoPoint(proto.latitude || 0, proto.longitude || 0); + } +} +exports.GeoPoint = GeoPoint; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/index.js b/website/functions/node_modules/@google-cloud/firestore/build/src/index.js new file mode 100644 index 00000000..0fc22e61 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/index.js @@ -0,0 +1,1275 @@ +/*! + * Copyright 2017 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. + */ +'use strict'; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const assert_1 = __importDefault(require("assert")); +const bun_1 = __importDefault(require("bun")); +const extend_1 = __importDefault(require("extend")); +const is_1 = __importDefault(require("is")); +const through2_1 = __importDefault(require("through2")); +const projectify_1 = require("@google-cloud/projectify"); +const reference_1 = require("./reference"); +const document_1 = require("./document"); +const field_value_1 = require("./field-value"); +const validate_1 = require("./validate"); +const write_batch_1 = require("./write-batch"); +const transaction_1 = require("./transaction"); +const timestamp_1 = require("./timestamp"); +const path_1 = require("./path"); +const pool_1 = require("./pool"); +const document_change_1 = require("./document-change"); +const serializer_1 = require("./serializer"); +const geo_point_1 = require("./geo-point"); +const logger_1 = require("./logger"); +const util_1 = require("./util"); +const convert = __importStar(require("./convert")); +const libVersion = require('../../package.json').version; +logger_1.setLibVersion(libVersion); +/*! + * DO NOT REMOVE THE FOLLOWING NAMESPACE DEFINITIONS + */ +/** + * @namespace google.protobuf + */ +/** + * @namespace google.rpc + */ +/** + * @namespace google.firestore.v1beta1 + */ +/*! + * @see v1beta1 + */ +let v1beta1; // Lazy-loaded in `_runRequest()` +/*! + * HTTP header for the resource prefix to improve routing and project isolation + * by the backend. + * @type {string} + */ +const CLOUD_RESOURCE_HEADER = 'google-cloud-resource-prefix'; +/*! + * The maximum number of times to retry idempotent requests. + * @type {number} + */ +const MAX_REQUEST_RETRIES = 5; +/*! + * 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 + * operations, we need to use more than one GAPIC client since these clients + * multiplex all requests over a single channel. + * + * @type {number} + */ +const MAX_CONCURRENT_REQUESTS_PER_CLIENT = 100; +/*! + * GRPC Error code for 'UNAVAILABLE'. + * @type {number} + */ +const GRPC_UNAVAILABLE = 14; +/*! + * The maximum depth of a Firestore object. + * + * @type {number} + */ +const MAX_DEPTH = 20; +/** + * Document data (e.g. for use with + * [set()]{@link DocumentReference#set}) consisting of fields mapped + * to values. + * + * @typedef {Object.} DocumentData + */ +/** + * 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. + * + * @typedef {Object.} UpdateData + */ +/** + * An options object that configures conditional behavior of + * [update()]{@link DocumentReference#update} and + * [delete()]{@link DocumentReference#delete} calls in + * [DocumentReference]{@link DocumentReference}, + * [WriteBatch]{@link WriteBatch}, and + * [Transaction]{@link Transaction}. Using Preconditions, these calls + * can be restricted to only apply to documents that match the specified + * conditions. + * + * @property {string} lastUpdateTime - The update time to enforce (specified as + * an ISO 8601 string). + * @typedef {Object} Precondition + */ +/** + * An options object that configures the behavior of + * [set()]{@link DocumentReference#set} calls in + * [DocumentReference]{@link DocumentReference}, + * [WriteBatch]{@link WriteBatch}, and + * [Transaction]{@link Transaction}. These calls can be + * configured to perform granular merges instead of overwriting the target + * documents in their entirety by providing a SetOptions object with + * { merge : true }. + * + * @property {boolean} merge - 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. + * @typedef {Object} SetOptions + */ +/** + * The Firestore client represents a Firestore Database and is the entry point + * for all Firestore operations. + * + * @see [Firestore Documentation]{@link https://firebase.google.com/docs/firestore/} + * + * @class + * + * @example Install the client library with npm: npm install --save + * @google-cloud/firestore + * + * @example Import the client library + * var Firestore = require('@google-cloud/firestore'); + * + * @example Create a client that uses Application + * Default Credentials (ADC): var firestore = new Firestore(); + * + * @example Create a client with explicit + * credentials: var firestore = new Firestore({ projectId: + * 'your-project-id', keyFilename: '/path/to/keyfile.json' + * }); + * + * @example include:samples/quickstart.js + * region_tag:firestore_quickstart + * Full quickstart example: + */ +class Firestore { + /** + * @param {Object=} settings - [Configuration object](#/docs). + * @param {string=} settings.projectId The Firestore Project ID. Can be + * omitted in environments that support `Application Default Credentials` + * {@see https://cloud.google.com/docs/authentication} + * @param {string=} settings.keyFilename Local file containing the Service + * Account credentials. Can be omitted in environments that support + * `Application Default Credentials` + * {@see https://cloud.google.com/docs/authentication} + * @param {boolean=} settings.timestampsInSnapshots Enables the use of + * `Timestamp`s for timestamp fields in `DocumentSnapshots`.
+ * Currently, Firestore returns 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. + *
Setting `timestampsInSnapshots` to true will cause Firestore to return + * `Timestamp` values instead of `Date` avoiding this kind of problem. To + * make this work you must also change any code that uses `Date` to use + * `Timestamp` instead. + *
NOTE: in the future `timestampsInSnapshots: true` will become the + * default and this option will be removed so you should change your code to + * use `Timestamp` now and opt-in to this new behavior as soon as you can. + */ + constructor(settings) { + settings = extend_1.default({}, settings, { + libName: 'gccl', + libVersion: libVersion, + }); + this._validator = new validate_1.Validator({ + ArrayElement: (name, value) => validateFieldValue(name, value, /* depth */ 0, /*inArray=*/ true), + DeletePrecondition: precondition => document_1.validatePrecondition(precondition, /* allowExists= */ true), + Document: validateDocumentData, + DocumentReference: reference_1.validateDocumentReference, + FieldPath: path_1.FieldPath.validateFieldPath, + FieldValue: validateFieldValue, + FieldOrder: reference_1.validateFieldOrder, + QueryComparison: reference_1.validateComparisonOperator, + QueryValue: validateFieldValue, + ResourcePath: path_1.ResourcePath.validateResourcePath, + SetOptions: document_1.validateSetOptions, + UpdateMap: write_batch_1.validateUpdateMap, + UpdatePrecondition: precondition => document_1.validatePrecondition(precondition, /* allowExists= */ false), + }); + /** + * 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 + * @type {ClientPool|null} + */ + this._clientPool = null; + /** + * Whether the initialization settings can still be changed by invoking + * `settings()`. + * @private + * @type {boolean} + */ + this._settingsFrozen = false; + /** + * A Promise that resolves when client initialization completes. Can be + * 'null' if initialization hasn't started yet. + * @private + * @type {Promise|null} + */ + this._clientInitialized = null; + /** + * The configuration options for the GAPIC client. + * @private + * @type {Object} + */ + this._initalizationSettings = null; + /** + * The serializer to use for the Protobuf transformation. + * @private + * @type {Serializer} + */ + this._serializer = null; + this.validateAndApplySettings(settings); + // 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 = is_1.default.defined(process.env.FUNCTION_TRIGGER_TYPE); + this._lastSuccessfulRequest = null; + if (this._preferTransactions) { + logger_1.logger('Firestore', null, 'Detected GCF environment'); + } + logger_1.logger('Firestore', null, 'Initialized Firestore'); + } + /** + * Specifies custom settings to be used to configure the `Firestore` + * instance. Can only be invoked once and before any other Firestore method. + * + * If settings are provided via both `settings()` and the `Firestore` + * constructor, both settings objects are merged and any settings provided via + * `settings()` take precedence. + * + * @param {object} settings The settings to use for all Firestore operations. + */ + settings(settings) { + this._validator.isObject('settings', settings); + this._validator.isOptionalString('settings.projectId', settings.projectId); + this._validator.isOptionalBoolean('settings.timestampsInSnapshots', settings.timestampsInSnapshots); + if (this._clientInitialized) { + throw new Error('Firestore has already been started and its settings can no longer ' + + 'be changed. You can only call settings() before calling any other ' + + 'methods on a Firestore object.'); + } + if (this._settingsFrozen) { + throw new Error('Firestore.settings() has already be called. You can only call ' + + 'settings() once, and only before calling any other methods on a ' + + 'Firestore object.'); + } + const mergedSettings = extend_1.default({}, this._initalizationSettings, settings); + this.validateAndApplySettings(mergedSettings); + this._settingsFrozen = true; + } + validateAndApplySettings(settings) { + this._validator.isOptionalBoolean('settings.timestampsInSnapshots', settings.timestampsInSnapshots); + this._timestampsInSnapshotsEnabled = !!settings.timestampsInSnapshots; + if (settings && settings.projectId) { + this._validator.isString('settings.projectId', settings.projectId); + this._referencePath = new path_1.ResourcePath(settings.projectId, '(default)'); + } + else { + // Initialize a temporary reference path that will be overwritten during + // project ID detection. + this._referencePath = new path_1.ResourcePath('{{projectId}}', '(default)'); + } + this._initalizationSettings = settings; + this._serializer = new serializer_1.Serializer(this, this._timestampsInSnapshotsEnabled); + } + /** + * The root path to the database. + * + * @private + * @type {string} + */ + get formattedName() { + return this._referencePath.formattedName; + } + /** + * Gets a [DocumentReference]{@link DocumentReference} instance that + * refers to the document at the specified path. + * + * @param {string} documentPath - A slash-separated path to a document. + * @returns {DocumentReference} The + * [DocumentReference]{@link DocumentReference} instance. + * + * @example + * let documentRef = firestore.doc('collection/document'); + * console.log(`Path of document is ${documentRef.path}`); + */ + doc(documentPath) { + this._validator.isResourcePath('documentPath', documentPath); + let path = this._referencePath.append(documentPath); + if (!path.isDocument) { + throw new Error(`Argument "documentPath" must point to a document, but was "${documentPath}". Your path does not contain an even number of components.`); + } + return new reference_1.DocumentReference(this, path); + } + /** + * Gets a [CollectionReference]{@link CollectionReference} instance + * that refers to the collection at the specified path. + * + * @param {string} collectionPath - A slash-separated path to a collection. + * @returns {CollectionReference} The + * [CollectionReference]{@link CollectionReference} instance. + * + * @example + * let collectionRef = firestore.collection('collection'); + * + * // Add a document with an auto-generated ID. + * collectionRef.add({foo: 'bar'}).then((documentRef) => { + * console.log(`Added document at ${documentRef.path})`); + * }); + */ + collection(collectionPath) { + this._validator.isResourcePath('collectionPath', collectionPath); + let path = this._referencePath.append(collectionPath); + if (!path.isCollection) { + throw new Error(`Argument "collectionPath" must point to a collection, but was "${collectionPath}". Your path does not contain an odd number of components.`); + } + return new reference_1.CollectionReference(this, path); + } + /** + * Creates a [WriteBatch]{@link WriteBatch}, used for performing + * multiple writes as a single atomic operation. + * + * @returns {WriteBatch} A WriteBatch that operates on this Firestore + * client. + * + * @example + * let writeBatch = firestore.batch(); + * + * // Add two documents in an atomic batch. + * let data = { foo: 'bar' }; + * writeBatch.set(firestore.doc('col/doc1'), data); + * writeBatch.set(firestore.doc('col/doc2'), data); + * + * writeBatch.commit().then(res => { + * console.log(`Added document at ${res.writeResults[0].updateTime}`); + * }); + */ + batch() { + return new write_batch_1.WriteBatch(this); + } + /** + * Creates a [DocumentSnapshot]{@link DocumentSnapshot} or a + * [QueryDocumentSnapshot]{@link QueryDocumentSnapshot} from a + * `firestore.v1beta1.Document` proto (or from a resource name for missing + * documents). + * + * This API is used by Google Cloud Functions and can be called with both + * 'Proto3 JSON' and 'Protobuf JS' encoded data. + * + * @private + * @param {object|string} documentOrName - The Firestore 'Document' proto or + * the resource name of a missing document. + * @param {object=} readTime - A 'Timestamp' proto indicating the time this + * document was read. + * @param {string=} encoding - One of 'json' or 'protobufJS'. Applies to both + * the 'document' Proto and 'readTime'. Defaults to 'protobufJS'. + * @returns {DocumentSnapshot|QueryDocumentSnapshot} - A QueryDocumentSnapshot + * for existing documents, otherwise a DocumentSnapshot. + */ + snapshot_(documentOrName, readTime, encoding) { + // TODO: Assert that Firestore Project ID is valid. + let convertTimestamp; + let convertDocument; + if (!is_1.default.defined(encoding) || encoding === 'protobufJS') { + convertTimestamp = data => data; + convertDocument = data => data; + } + else if (encoding === 'json') { + // Google Cloud Functions calls us with Proto3 JSON format data, which we + // must convert to Protobuf JS. + convertTimestamp = convert.timestampFromJson; + convertDocument = convert.documentFromJson; + } + else { + throw new Error(`Unsupported encoding format. Expected 'json' or 'protobufJS', ` + + `but was '${encoding}'.`); + } + const document = new document_1.DocumentSnapshot.Builder(); + if (is_1.default.string(documentOrName)) { + document.ref = new reference_1.DocumentReference(this, path_1.ResourcePath.fromSlashSeparatedString(documentOrName)); + } + else { + document.ref = new reference_1.DocumentReference(this, path_1.ResourcePath.fromSlashSeparatedString(documentOrName.name)); + document.fieldsProto = + documentOrName.fields ? convertDocument(documentOrName.fields) : {}; + document.createTime = timestamp_1.Timestamp.fromProto(convertTimestamp(documentOrName.createTime, 'documentOrName.createTime')); + document.updateTime = timestamp_1.Timestamp.fromProto(convertTimestamp(documentOrName.updateTime, 'documentOrName.updateTime')); + } + if (readTime) { + document.readTime = + timestamp_1.Timestamp.fromProto(convertTimestamp(readTime, 'readTime')); + } + return document.build(); + } + /** + * Executes the given updateFunction and commits the changes applied within + * 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. + * + * @param {function(Transaction)} 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. + * @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 + * error will be returned. + * + * @example + * let counterTransaction = firestore.runTransaction(transaction => { + * let documentRef = firestore.doc('col/doc'); + * return transaction.get(documentRef).then(doc => { + * if (doc.exists) { + * let count = doc.get('count') || 0; + * if (count > 10) { + * return Promise.reject('Reached maximum count'); + * } + * transaction.update(documentRef, { count: ++count }); + * return Promise.resolve(count); + * } + * + * transaction.create(documentRef, { count: 1 }); + * return Promise.resolve(1); + * }); + * }); + * + * counterTransaction.then(res => { + * console.log(`Count updated to ${res}`); + * }); + */ + runTransaction(updateFunction, transactionOptions) { + this._validator.isFunction('updateFunction', updateFunction); + const defaultAttempts = 5; + let attemptsRemaining = defaultAttempts; + let previousTransaction; + if (is_1.default.defined(transactionOptions)) { + this._validator.isObject('transactionOptions', transactionOptions); + this._validator.isOptionalInteger('transactionOptions.maxAttempts', transactionOptions.maxAttempts, 1); + attemptsRemaining = transactionOptions.maxAttempts || attemptsRemaining; + previousTransaction = transactionOptions.previousTransaction; + } + const transaction = new transaction_1.Transaction(this, previousTransaction); + const requestTag = transaction.requestTag; + let result; + --attemptsRemaining; + return transaction.begin() + .then(() => { + let promise = updateFunction(transaction); + result = is_1.default.instanceof(promise, Promise) ? + promise : + Promise.reject(new Error('You must return a Promise in your transaction()-callback.')); + return result.catch(err => { + logger_1.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 > 0) { + logger_1.logger('Firestore.runTransaction', requestTag, `Retrying transaction after error: ${JSON.stringify(err)}.`); + return this.runTransaction(updateFunction, { + previousTransaction: transaction, + maxAttempts: attemptsRemaining, + }); + } + logger_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. + * + * @returns {Promise.>} A Promise that resolves + * with an array of CollectionReferences. + * + * @example + * firestore.getCollections().then(collections => { + * for (let collection of collections) { + * console.log(`Found collection with id: ${collection.id}`); + * } + * }); + */ + getCollections() { + let rootDocument = new reference_1.DocumentReference(this, this._referencePath); + return rootDocument.getCollections(); + } + /** + * Retrieves multiple documents from Firestore. + * + * @param {...DocumentReference} documents - The document references + * to receive. + * @returns {Promise>} A Promise that + * contains an array with the resulting document snapshots. + * + * @example + * let documentRef1 = firestore.doc('col/doc1'); + * let documentRef2 = firestore.doc('col/doc2'); + * + * firestore.getAll(documentRef1, documentRef2).then(docs => { + * console.log(`First document: ${JSON.stringify(docs[0])}`); + * console.log(`Second document: ${JSON.stringify(docs[1])}`); + * }); + */ + getAll(documents) { + documents = is_1.default.array(arguments[0]) ? arguments[0].slice() : + Array.prototype.slice.call(arguments); + for (let i = 0; i < documents.length; ++i) { + this._validator.isDocumentReference(i, documents[i]); + } + return this.getAll_(documents, util_1.requestTag()); + } + /** + * Internal method to retrieve multiple documents from Firestore, optionally + * as part of a transaction. + * + * @private + * @param {Array.} docRefs - The documents + * to receive. + * @param {string} requestTag A unique client-assigned identifier for this + * request. + * @param {bytes=} transactionId - transactionId - The transaction ID to use + * for this read. + * @returns {Promise>} A Promise that contains an array with + * the resulting documents. + */ + getAll_(docRefs, requestTag, transactionId) { + const requestedDocuments = new Set(); + const retrievedDocuments = new Map(); + let request = { + database: this.formattedName, + transaction: transactionId, + }; + for (let docRef of docRefs) { + requestedDocuments.add(docRef.formattedName); + } + request.documents = Array.from(requestedDocuments); + const self = this; + return self.readStream('batchGetDocuments', request, requestTag, true) + .then(stream => { + return new Promise((resolve, reject) => { + stream + .on('error', err => { + logger_1.logger('Firestore.getAll_', requestTag, 'GetAll failed with error:', err); + reject(err); + }) + .on('data', response => { + try { + let document; + if (response.found) { + logger_1.logger('Firestore.getAll_', requestTag, 'Received document: %s', response.found.name); + document = + self.snapshot_(response.found, response.readTime); + } + else { + logger_1.logger('Firestore.getAll_', requestTag, 'Document missing: %s', response.missing); + document = self.snapshot_(response.missing, response.readTime); + } + let path = document.ref.path; + retrievedDocuments.set(path, document); + } + catch (err) { + logger_1.logger('Firestore.getAll_', requestTag, 'GetAll failed with exception:', err); + reject(err); + } + }) + .on('end', () => { + logger_1.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 = []; + for (let docRef of docRefs) { + let document = retrievedDocuments.get(docRef.path); + if (!is_1.default.defined(document)) { + reject(new Error(`Did not receive document for "${docRef.path}".`)); + } + orderedDocuments.push(document); + } + resolve(orderedDocuments); + }); + stream.resume(); + }); + }); + } + /** + * Executes a new request using the first available GAPIC client. + * + * @private + */ + _runRequest(op) { + // Initialize the client pool if this is the first request. + if (!this._clientInitialized) { + if (!this._timestampsInSnapshotsEnabled) { + console.error(` +The behavior for Date objects stored in Firestore is going to change +AND YOUR APP MAY BREAK. +To hide this warning and ensure your app does not break, you need to add the +following code to your app before calling any other Cloud Firestore methods: + + const firestore = new Firestore(); + const settings = {/* your settings... */ timestampsInSnapshots: true}; + firestore.settings(settings); + +With this change, 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. In a +future release, the behavior will change to the new behavior, so if you do not +follow these steps, YOUR APP MAY BREAK.`); + } + this._clientInitialized = this._initClientPool().then(clientPool => { + this._clientPool = clientPool; + }); + } + return this._clientInitialized.then(() => this._clientPool.run(op)); + } + /** + * Initializes the client pool and invokes Project ID detection. Returns a + * Promise on completion. + * + * @private + * @return {Promise} + */ + _initClientPool() { + assert_1.default(!this._clientInitialized, 'Client pool already initialized'); + const clientPool = new pool_1.ClientPool(MAX_CONCURRENT_REQUESTS_PER_CLIENT, () => { + const gapicClient = module.exports.v1beta1(this._initalizationSettings); + logger_1.logger('Firestore', null, 'Initialized Firestore GAPIC Client'); + return gapicClient; + }); + const projectIdProvided = this._referencePath.projectId !== '{{projectId}}'; + if (projectIdProvided) { + return Promise.resolve(clientPool); + } + else { + return clientPool.run(client => this._detectProjectId(client)) + .then(projectId => { + this._referencePath = + new path_1.ResourcePath(projectId, this._referencePath.databaseId); + return clientPool; + }); + } + } + /** + * Auto-detects the Firestore Project ID. + * + * @private + * @param {object} gapicClient - The Firestore GAPIC client. + * @return {Promise} A Promise that resolves with the Project ID. + */ + _detectProjectId(gapicClient) { + return new Promise((resolve, reject) => { + gapicClient.getProjectId((err, projectId) => { + if (err) { + logger_1.logger('Firestore._detectProjectId', null, 'Failed to detect project ID: %s', err); + reject(err); + } + else { + logger_1.logger('Firestore._detectProjectId', null, 'Detected project ID: %s', projectId); + resolve(projectId); + } + }); + }); + } + /** + * Decorate the request options of an API request. This is used to replace + * any `{{projectId}}` placeholders with the value detected from the user's + * environment, if one wasn't provided manually. + * + * @private + */ + _decorateRequest(request) { + let decoratedRequest = extend_1.default(true, {}, request); + decoratedRequest = + projectify_1.replaceProjectIdToken(decoratedRequest, this._referencePath.projectId); + let decoratedGax = { otherArgs: { headers: {} } }; + decoratedGax.otherArgs.headers[CLOUD_RESOURCE_HEADER] = this.formattedName; + return { request: decoratedRequest, gax: decoratedGax }; + } + /** + * A function returning a Promise that can be retried. + * + * @private + * @callback retryFunction + * @returns {Promise} A Promise indicating the function's success. + */ + /** + * Helper method that retries failed Promises. + * + * If 'delayMs' is specified, waits 'delayMs' between invocations. Otherwise, + * schedules the first attempt immediately, and then waits 100 milliseconds + * for further attempts. + * + * @private + * @param {number} attemptsRemaining - The number of available attempts. + * @param {string} requestTag - A unique client-assigned identifier for this + * request. + * @param {retryFunction} func - Method returning a Promise than can be + * retried. + * @param {number=} delayMs - How long to wait before issuing a this retry. + * Defaults to zero. + * @returns {Promise} - A Promise with the function's result if successful + * within `attemptsRemaining`. Otherwise, returns the last rejected Promise. + */ + _retry(attemptsRemaining, requestTag, func, delayMs) { + let self = this; + let currentDelay = delayMs || 0; + let nextDelay = delayMs || 100; + --attemptsRemaining; + return new Promise(resolve => { + setTimeout(resolve, currentDelay); + }) + .then(func) + .then(result => { + self._lastSuccessfulRequest = new Date().getTime(); + return result; + }) + .catch(err => { + if (is_1.default.defined(err.code) && err.code !== GRPC_UNAVAILABLE) { + logger_1.logger('Firestore._retry', requestTag, 'Request failed with unrecoverable error:', err); + return Promise.reject(err); + } + if (attemptsRemaining === 0) { + logger_1.logger('Firestore._retry', requestTag, 'Request failed with error:', err); + return Promise.reject(err); + } + logger_1.logger('Firestore._retry', requestTag, 'Retrying request that failed with error:', err); + return self._retry(attemptsRemaining, requestTag, func, nextDelay); + }); + } + /** + * 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. + * + * @private + * @param {Stream} resultStream - The Node stream to monitor. + * @param {string} requestTag A unique client-assigned identifier for this + * request. + * @param {Object=} request - If specified, the request that should be written + * to the stream after it opened. + * @returns {Promise.} The given Stream once it is considered healthy. + */ + _initializeStream(resultStream, requestTag, request) { + /** The last error we received and have not forwarded yet. */ + let errorReceived = null; + /** + * Whether we have resolved the Promise and returned the stream to the + * caller. + */ + let streamReleased = 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 releaseStream = () => { + if (errorReceived) { + logger_1.logger('Firestore._initializeStream', requestTag, 'Emit error:', errorReceived); + resultStream.emit('error', errorReceived); + errorReceived = null; + } + else if (!streamReleased) { + logger_1.logger('Firestore._initializeStream', requestTag, 'Releasing stream'); + streamReleased = 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(resultStream); + // 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_1.logger('Firestore._initializeStream', requestTag, 'Forwarding stream close'); + resultStream.emit('end'); + } + }, 0); + } + }; + // 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', () => { + releaseStream(); + }); + resultStream.on('end', () => { + logger_1.logger('Firestore._initializeStream', requestTag, 'Received stream end'); + endCalled = true; + releaseStream(); + }); + resultStream.on('error', err => { + logger_1.logger('Firestore._initializeStream', requestTag, 'Received stream error:', err); + // If we receive an error before we were able to receive any data, + // reject this stream. + if (!streamReleased) { + logger_1.logger('Firestore._initializeStream', requestTag, 'Received initial error:', err); + streamReleased = true; + reject(err); + } + else { + errorReceived = err; + } + }); + if (is_1.default.defined(request)) { + logger_1.logger('Firestore._initializeStream', requestTag, 'Sending request: %j', request); + resultStream.write(request, 'utf-8', () => { + logger_1.logger('Firestore._initializeStream', requestTag, 'Marking stream as healthy'); + releaseStream(); + }); + } + }); + } + /** + * A funnel for all non-streaming API requests, assigning a project ID where + * necessary within the request options. + * + * @private + * @param {function} methodName - Name of the veneer API endpoint that takes a + * request and GAX options. + * @param {Object} request - The Protobuf request to send. + * @param {string} requestTag A unique client-assigned identifier for this + * request. + * @param {boolean} allowRetries - Whether this is an idempotent request that + * can be retried. + * @returns {Promise.} A Promise with the request result. + */ + request(methodName, request, requestTag, allowRetries) { + let attempts = allowRetries ? MAX_REQUEST_RETRIES : 1; + return this._runRequest(gapicClient => { + const decorated = this._decorateRequest(request); + return this._retry(attempts, requestTag, () => { + return new Promise((resolve, reject) => { + logger_1.logger('Firestore.request', requestTag, 'Sending request: %j', decorated.request); + gapicClient[methodName](decorated.request, decorated.gax, (err, result) => { + if (err) { + logger_1.logger('Firestore.request', requestTag, 'Received error:', err); + reject(err); + } + else { + logger_1.logger('Firestore.request', requestTag, 'Received response: %j', result); + resolve(result); + } + }); + }); + }); + }); + } + /** + * A funnel for read-only 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. + * + * @private + * @param {string} methodName - Name of the streaming Veneer API endpoint that + * takes a request and GAX options. + * @param {Object} request - The Protobuf request to send. + * @param {string} requestTag A unique client-assigned identifier for this + * request. + * @param {boolean} allowRetries - Whether this is an idempotent request that + * can be retried. + * @returns {Promise.} A Promise with the resulting read-only stream. + */ + readStream(methodName, request, requestTag, allowRetries) { + let attempts = allowRetries ? MAX_REQUEST_RETRIES : 1; + return this._runRequest(gapicClient => { + const decorated = this._decorateRequest(request); + return this._retry(attempts, requestTag, () => { + return new Promise((resolve, reject) => { + try { + logger_1.logger('Firestore.readStream', requestTag, 'Sending request: %j', decorated.request); + let stream = gapicClient[methodName](decorated.request, decorated.gax); + let logStream = through2_1.default.obj(function (chunk, enc, callback) { + logger_1.logger('Firestore.readStream', requestTag, 'Received response: %j', chunk); + this.push(chunk); + callback(); + }); + resolve(bun_1.default([stream, logStream])); + } + catch (err) { + logger_1.logger('Firestore.readStream', requestTag, 'Received error:', err); + reject(err); + } + }) + .then(stream => this._initializeStream(stream, requestTag)); + }); + }); + } + /** + * 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 {string} methodName - Name of the streaming Veneer API endpoint that + * takes GAX options. + * @param {Object} request - The Protobuf request to send as the first stream + * message. + * @param {string} requestTag A unique client-assigned identifier for this + * request. + * @param {boolean} allowRetries - Whether this is an idempotent request that + * can be retried. + * @returns {Promise.} A Promise with the resulting read/write stream. + */ + readWriteStream(methodName, request, requestTag, allowRetries) { + let self = this; + let attempts = allowRetries ? MAX_REQUEST_RETRIES : 1; + return this._runRequest(gapicClient => { + const decorated = this._decorateRequest(request); + return this._retry(attempts, requestTag, () => { + return Promise.resolve().then(() => { + logger_1.logger('Firestore.readWriteStream', requestTag, 'Opening stream'); + // The generated bi-directional streaming API takes the list of GAX + // headers as its second argument. + let requestStream = gapicClient[methodName]({}, decorated.gax); + // The transform stream to assign the project ID. + let transform = through2_1.default.obj(function (chunk, encoding, callback) { + let decoratedChunk = extend_1.default(true, {}, chunk); + projectify_1.replaceProjectIdToken(decoratedChunk, self._referencePath.projectId); + logger_1.logger('Firestore.readWriteStream', requestTag, 'Streaming request: %j', decoratedChunk); + requestStream.write(decoratedChunk, encoding, callback); + }); + let logStream = through2_1.default.obj(function (chunk, enc, callback) { + logger_1.logger('Firestore.readWriteStream', requestTag, 'Received response: %j', chunk); + this.push(chunk); + callback(); + }); + let resultStream = bun_1.default([transform, requestStream, logStream]); + return this._initializeStream(resultStream, requestTag, request); + }); + }); + }); + } +} +/** + * Validates a JavaScript value for usage as a Firestore value. + * + * @private + * @param {Object} val JavaScript value to validate. + * @param {string} options.allowDeletes At what level field deletes are + * supported (acceptable values are 'none', 'root' or 'all'). + * @param {boolean} options.allowServerTimestamps Whether server timestamps + * are supported. + * @param {number=} depth The current depth of the traversal. + * @param {number=} inArray Whether we are inside an array. + * @returns {boolean} 'true' when the object is valid. + * @throws {Error} when the object is invalid. + */ +function validateFieldValue(val, options, depth, inArray) { + assert_1.default(['none', 'root', 'all'].indexOf(options.allowDeletes) !== -1, 'Expected \'none\', \'root\', or \'all\' for \'options.allowDeletes\''); + assert_1.default(typeof options.allowTransforms === 'boolean', 'Expected boolean for \'options.allowTransforms\''); + if (!depth) { + depth = 1; + } + else if (depth > MAX_DEPTH) { + throw new Error(`Input object is deeper than ${MAX_DEPTH} levels or contains a cycle.`); + } + inArray = inArray || false; + if (is_1.default.array(val)) { + for (let prop of val) { + validateFieldValue(val[prop], options, depth + 1, /* inArray= */ true); + } + } + else if (serializer_1.isPlainObject(val)) { + for (let prop in val) { + if (val.hasOwnProperty(prop)) { + validateFieldValue(val[prop], options, depth + 1, inArray); + } + } + } + else if (val instanceof field_value_1.DeleteTransform) { + if (inArray) { + throw new Error(`${val.methodName}() cannot be used inside of an array.`); + } + else if ((options.allowDeletes === 'root' && depth > 1) || + options.allowDeletes === 'none') { + throw new Error(`${val.methodName}() must appear at the top-level and can only be used in update() or set() with {merge:true}.`); + } + } + else if (val instanceof field_value_1.FieldTransform) { + if (inArray) { + throw new Error(`${val.methodName}() cannot be used inside of an array.`); + } + else if (!options.allowTransforms) { + throw new Error(`${val.methodName}() can only be used in set(), create() or update().`); + } + } + else if (is_1.default.instanceof(val, reference_1.DocumentReference)) { + return true; + } + else if (is_1.default.instanceof(val, geo_point_1.GeoPoint)) { + return true; + } + else if (is_1.default.instanceof(val, timestamp_1.Timestamp)) { + return true; + } + else if (is_1.default.instanceof(val, path_1.FieldPath)) { + throw new Error('Cannot use object of type "FieldPath" as a Firestore value.'); + } + else if (is_1.default.object(val)) { + throw validate_1.customObjectError(val); + } + return true; +} +/** + * Validates a JavaScript object for usage as a Firestore document. + * + * @private + * @param {Object} obj JavaScript object to validate. + * @param {string} options.allowDeletes At what level field deletes are + * supported (acceptable values are 'none', 'root' or 'all'). + * @param {boolean} options.allowServerTimestamps Whether server timestamps + * are supported. + * @param {boolean} options.allowEmpty Whether empty documents are supported. + * @returns {boolean} 'true' when the object is valid. + * @throws {Error} when the object is invalid. + */ +function validateDocumentData(obj, options) { + assert_1.default(typeof options.allowEmpty === 'boolean', 'Expected boolean for \'options.allowEmpty\''); + if (!serializer_1.isPlainObject(obj)) { + throw new Error('Input is not a plain JavaScript object.'); + } + options = options || {}; + let isEmpty = true; + for (let prop in obj) { + if (obj.hasOwnProperty(prop)) { + isEmpty = false; + validateFieldValue(obj[prop], options, /* depth= */ 1); + } + } + if (options.allowEmpty === false && isEmpty) { + throw new Error('At least one field must be updated.'); + } + return true; +} +/** + * A logging function that takes a single string. + * + * @callback Firestore~logFunction + * @param {string} Log message + */ +/** + * Sets the log function for all active Firestore instances. + * + * @method Firestore.setLogFunction + * @param {Firestore~logFunction} logger - A log function that takes a single + * string. + */ +Firestore.setLogFunction = logger_1.setLogFunction; +/** + * The default export of the `@google-cloud/firestore` package is the + * {@link Firestore} class. + * + * See {@link Firestore} and {@link ClientConfig} for client methods and + * configuration options. + * + * @module {Firestore} @google-cloud/firestore + * @alias nodejs-firestore + * + * @example Install the client library with npm: npm install --save + * @google-cloud/firestore + * + * @example Import the client library + * var Firestore = require('@google-cloud/firestore'); + * + * @example Create a client that uses Application + * Default Credentials (ADC): var firestore = new Firestore(); + * + * @example Create a client with explicit + * credentials: var firestore = new Firestore({ projectId: + * 'your-project-id', keyFilename: '/path/to/keyfile.json' + * }); + * + * @example include:samples/quickstart.js + * region_tag:firestore_quickstart + * Full quickstart example: + */ +module.exports = Firestore; +module.exports.default = Firestore; +module.exports.Firestore = Firestore; +/** + * {@link v1beta1} factory function. + * + * @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; + }, +}); +/** + * {@link GeoPoint} class. + * + * @name Firestore.GeoPoint + * @see GeoPoint + * @type {Constructor} + */ +module.exports.GeoPoint = geo_point_1.GeoPoint; +/** + * {@link Transaction} class. + * + * @name Firestore.Transaction + * @see Transaction + * @type Transaction + */ +module.exports.Transaction = transaction_1.Transaction; +/** + * {@link WriteBatch} class. + * + * @name Firestore.WriteBatch + * @see WriteBatch + * @type WriteBatch + */ +module.exports.WriteBatch = write_batch_1.WriteBatch; +/** + * {@link DocumentReference} class. + * + * @name Firestore.DocumentReference + * @see DocumentReference + * @type DocumentReference + */ +module.exports.DocumentReference = reference_1.DocumentReference; +/** + * {@link WriteResult} class. + * + * @name Firestore.WriteResult + * @see WriteResult + * @type WriteResult + */ +module.exports.WriteResult = write_batch_1.WriteResult; +/** + * {@link DocumentSnapshot} DocumentSnapshot. + * + * @name Firestore.DocumentSnapshot + * @see DocumentSnapshot + * @type DocumentSnapshot + */ +module.exports.DocumentSnapshot = document_1.DocumentSnapshot; +/** + * {@link QueryDocumentSnapshot} class. + * + * @name Firestore.QueryDocumentSnapshot + * @see QueryDocumentSnapshot + * @type QueryDocumentSnapshot + */ +module.exports.QueryDocumentSnapshot = document_1.QueryDocumentSnapshot; +/** + * {@link CollectionReference} class. + * + * @name Firestore.CollectionReference + * @see CollectionReference + * @type CollectionReference + */ +module.exports.CollectionReference = reference_1.CollectionReference; +/** + * {@link QuerySnapshot} class. + * + * @name Firestore.QuerySnapshot + * @see QuerySnapshot + * @type QuerySnapshot + */ +module.exports.QuerySnapshot = reference_1.QuerySnapshot; +/** + * {@link DocumentChange} class. + * + * @name Firestore.DocumentChange + * @see DocumentChange + * @type DocumentChange + */ +module.exports.DocumentChange = document_change_1.DocumentChange; +/** + * {@link Query} class. + * + * @name Firestore.Query + * @see Query + * @type Query + */ +module.exports.Query = reference_1.Query; +/** + * {@link FieldValue} class. + * + * @name Firestore.FieldValue + * @see FieldValue + */ +module.exports.FieldValue = field_value_1.FieldValue; +/** + * {@link FieldPath} class. + * + * @name Firestore.FieldPath + * @see FieldPath + * @type {Constructor} + */ +module.exports.FieldPath = path_1.FieldPath; +/** + * {@link Timestamp} class. + * + * @name Firestore.Timestamp + * @see Timestamp + * @type Timestamp + */ +module.exports.Timestamp = timestamp_1.Timestamp; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/logger.js b/website/functions/node_modules/@google-cloud/firestore/build/src/logger.js new file mode 100644 index 00000000..d2b6288c --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/logger.js @@ -0,0 +1,60 @@ +/*! + * Copyright 2018 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. + */ +'use strict'; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const util_1 = __importDefault(require("util")); +const validate_1 = require("./validate"); +const validate = validate_1.createValidator(); +/*! The Firestore library version */ +let libVersion; +/*! The external function used to emit logs. */ +let logFunction = (msg) => { }; +/** + * Log function to use for debug output. By default, we don't perform any + * logging. + * + * @private + */ +function logger(methodName, requestTag, logMessage, ...additionalArgs) { + requestTag = requestTag || '#####'; + const formattedMessage = util_1.default.format(logMessage, ...additionalArgs); + const time = new Date().toISOString(); + logFunction(`Firestore (${libVersion}) ${time} ${requestTag} [${methodName}]: ` + + formattedMessage); +} +exports.logger = logger; +/** + * Sets the log function for all active Firestore instances. + * + * @private + */ +function setLogFunction(logger) { + validate.isFunction('logger', logger); + logFunction = logger; +} +exports.setLogFunction = setLogFunction; +/** + * Sets the log function for all active Firestore instances. + * + * @private + */ +function setLibVersion(version) { + libVersion = version; +} +exports.setLibVersion = setLibVersion; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/order.js b/website/functions/node_modules/@google-cloud/firestore/build/src/order.js new file mode 100644 index 00000000..cd9e60ad --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/order.js @@ -0,0 +1,238 @@ +/*! + * Copyright 2017 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. + */ +'use strict'; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const is = __importStar(require("is")); +const convert_1 = require("./convert"); +const path_1 = require("./path"); +const validate_1 = require("./validate"); +/*! + * The type order as defined by the backend. + */ +var TypeOrder; +(function (TypeOrder) { + TypeOrder[TypeOrder["NULL"] = 0] = "NULL"; + TypeOrder[TypeOrder["BOOLEAN"] = 1] = "BOOLEAN"; + TypeOrder[TypeOrder["NUMBER"] = 2] = "NUMBER"; + TypeOrder[TypeOrder["TIMESTAMP"] = 3] = "TIMESTAMP"; + TypeOrder[TypeOrder["STRING"] = 4] = "STRING"; + TypeOrder[TypeOrder["BLOB"] = 5] = "BLOB"; + TypeOrder[TypeOrder["REF"] = 6] = "REF"; + TypeOrder[TypeOrder["GEO_POINT"] = 7] = "GEO_POINT"; + TypeOrder[TypeOrder["ARRAY"] = 8] = "ARRAY"; + TypeOrder[TypeOrder["OBJECT"] = 9] = "OBJECT"; +})(TypeOrder || (TypeOrder = {})); +/*! + * @private + */ +function typeOrder(val) { + const valueType = convert_1.detectValueType(val); + switch (valueType) { + case 'nullValue': + return TypeOrder.NULL; + case 'integerValue': + return TypeOrder.NUMBER; + case 'doubleValue': + return TypeOrder.NUMBER; + case 'stringValue': + return TypeOrder.STRING; + case 'booleanValue': + return TypeOrder.BOOLEAN; + case 'arrayValue': + return TypeOrder.ARRAY; + case 'timestampValue': + return TypeOrder.TIMESTAMP; + case 'geoPointValue': + return TypeOrder.GEO_POINT; + case 'bytesValue': + return TypeOrder.BLOB; + case 'referenceValue': + return TypeOrder.REF; + case 'mapValue': + return TypeOrder.OBJECT; + default: + throw validate_1.customObjectError(val); + } +} +/*! + * @private + */ +function primitiveComparator(left, right) { + if (left < right) { + return -1; + } + if (left > right) { + return 1; + } + return 0; +} +exports.primitiveComparator = primitiveComparator; +/*! + * Utility function to compare doubles (using Firestore semantics for NaN). + * @private + */ +function compareNumbers(left, right) { + if (left < right) { + return -1; + } + if (left > right) { + return 1; + } + if (left === right) { + return 0; + } + // one or both are NaN. + if (isNaN(left)) { + return isNaN(right) ? 0 : -1; + } + return 1; +} +/*! + * @private + */ +function compareNumberProtos(left, right) { + let leftValue, rightValue; + if (left.integerValue !== undefined) { + leftValue = Number(left.integerValue); + } + else { + leftValue = Number(left.doubleValue); + } + if (right.integerValue !== undefined) { + rightValue = Number(right.integerValue); + } + else { + rightValue = Number(right.doubleValue); + } + return compareNumbers(leftValue, rightValue); +} +/*! + * @private + */ +function compareTimestamps(left, right) { + const seconds = primitiveComparator(left.seconds || 0, right.seconds || 0); + if (seconds !== 0) { + return seconds; + } + return primitiveComparator(left.nanos || 0, right.nanos || 0); +} +/*! + * @private + */ +function compareBlobs(left, right) { + if (!is.instanceof(left, Buffer) || !is.instanceof(right, Buffer)) { + throw new Error('Blobs can only be compared if they are Buffers.'); + } + return Buffer.compare(left, right); +} +/*! + * @private + */ +function compareReferenceProtos(left, right) { + const leftPath = path_1.ResourcePath.fromSlashSeparatedString(left.referenceValue); + const rightPath = path_1.ResourcePath.fromSlashSeparatedString(right.referenceValue); + return leftPath.compareTo(rightPath); +} +/*! + * @private + */ +function compareGeoPoints(left, right) { + return (primitiveComparator(left.latitude || 0, right.latitude || 0) || + primitiveComparator(left.longitude || 0, right.longitude || 0)); +} +/*! + * @private + */ +function compareArrays(left, right) { + for (let i = 0; i < left.length && i < right.length; i++) { + const valueComparison = compare(left[i], right[i]); + if (valueComparison !== 0) { + return valueComparison; + } + } + // If all the values matched so far, just check the length. + return primitiveComparator(left.length, right.length); +} +/*! + * @private + */ +function compareObjects(left, right) { + // This requires iterating over the keys in the object in order and doing a + // deep comparison. + const leftKeys = Object.keys(left); + const rightKeys = Object.keys(right); + leftKeys.sort(); + rightKeys.sort(); + for (let i = 0; i < leftKeys.length && i < rightKeys.length; i++) { + const keyComparison = primitiveComparator(leftKeys[i], rightKeys[i]); + if (keyComparison !== 0) { + return keyComparison; + } + const key = leftKeys[i]; + const valueComparison = compare(left[key], right[key]); + if (valueComparison !== 0) { + return valueComparison; + } + } + // If all the keys matched so far, just check the length. + return primitiveComparator(leftKeys.length, rightKeys.length); +} +/*! + * @private + */ +function compare(left, right) { + // First compare the types. + const leftType = typeOrder(left); + const rightType = typeOrder(right); + const typeComparison = primitiveComparator(leftType, rightType); + if (typeComparison !== 0) { + return typeComparison; + } + // So they are the same type. + switch (leftType) { + case TypeOrder.NULL: + // Nulls are all equal. + return 0; + case TypeOrder.BOOLEAN: + return primitiveComparator(left.booleanValue, right.booleanValue); + case TypeOrder.STRING: + return primitiveComparator(left.stringValue, right.stringValue); + case TypeOrder.NUMBER: + return compareNumberProtos(left, right); + case TypeOrder.TIMESTAMP: + return compareTimestamps(left.timestampValue, right.timestampValue); + case TypeOrder.BLOB: + return compareBlobs(left.bytesValue, right.bytesValue); + case TypeOrder.REF: + return compareReferenceProtos(left, right); + case TypeOrder.GEO_POINT: + return compareGeoPoints(left.geoPointValue, right.geoPointValue); + case TypeOrder.ARRAY: + return compareArrays(left.arrayValue.values || [], right.arrayValue.values || []); + case TypeOrder.OBJECT: + return compareObjects(left.mapValue.fields || {}, right.mapValue.fields || {}); + default: + throw new Error(`Encountered unknown type order: ${leftType}`); + } +} +exports.compare = compare; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/path.js b/website/functions/node_modules/@google-cloud/firestore/build/src/path.js new file mode 100644 index 00000000..23b07c5e --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/path.js @@ -0,0 +1,510 @@ +/*! + * Copyright 2017 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. + */ +'use strict'; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const is_1 = __importDefault(require("is")); +const validate_1 = require("./validate"); +const validate = validate_1.createValidator(); +/*! + * A regular expression to verify an absolute Resource Path in Firestore. It + * extracts the project ID, the database name and the relative resource path + * if available. + * + * @type {RegExp} + */ +const RESOURCE_PATH_RE = +// Note: [\s\S] matches all characters including newlines. +/^projects\/([^/]*)\/databases\/([^/]*)(?:\/documents\/)?([\s\S]*)$/; +/*! + * A regular expression to verify whether a field name can be passed to the + * backend without escaping. + * + * @type {RegExp} + */ +const UNESCAPED_FIELD_NAME_RE = /^[_a-zA-Z][_a-zA-Z0-9]*$/; +/*! + * A regular expression to verify field paths that are passed to the API as + * strings. Field paths that do not match this expression have to be provided + * as a [FieldPath]{@link FieldPath} object. + * + * @type {RegExp} + */ +const FIELD_PATH_RE = /^[^*~/[\]]+$/; +/** + * An abstract class representing a Firestore path. + * + * Subclasses have to implement `split()` and `canonicalString()`. + * + * @private + * @class + */ +class Path { + /** + * Creates a new Path with the given segments. + * + * @private + * @hideconstructor + * @param {string[]} segments - Sequence of parts of a path. + */ + constructor(segments) { + this.segments = segments; + } + /** + * String representation as expected by the proto API. + * + * @private + * @type {string} + */ + get formattedName() { + return this.canonicalString(); + } + /** + * Create a child path beneath the current level. + * + * @private + * @param {string|T} relativePath - Relative path to append to the current + * path. + * @returns {T} The new path. + * @template T + */ + append(relativePath) { + if (relativePath instanceof Path) { + return this.construct(this.segments.concat(relativePath.segments)); + } + return this.construct(this.segments.concat(this.split(relativePath))); + } + /** + * Returns the path of the parent node. + * + * @private + * @returns {T|null} The new path or null if we are already at the root. + * @returns {T} The new path. + * @template T + */ + parent() { + if (this.segments.length === 0) { + return null; + } + return this.construct(this.segments.slice(0, this.segments.length - 1)); + } + /** + * Checks whether the current path is a prefix of the specified path. + * + * @private + * @param {Path} other - The path to check against. + * @returns {boolean} 'true' iff the current path is a prefix match with + * 'other'. + */ + isPrefixOf(other) { + if (other.segments.length < this.segments.length) { + return false; + } + for (let i = 0; i < this.segments.length; i++) { + if (this.segments[i] !== other.segments[i]) { + return false; + } + } + return true; + } + /** + * Returns a string representation of this path. + * + * @private + * @returns {string} A string representing this path. + */ + toString() { + return this.formattedName; + } + /** + * Compare the current path against another Path object. + * + * @private + * @param {Path} other - The path to compare to. + * @returns {number} -1 if current < other, 1 if current > other, 0 if equal + */ + compareTo(other) { + const len = Math.min(this.segments.length, other.segments.length); + for (let i = 0; i < len; i++) { + if (this.segments[i] < other.segments[i]) { + return -1; + } + if (this.segments[i] > other.segments[i]) { + return 1; + } + } + if (this.segments.length < other.segments.length) { + return -1; + } + if (this.segments.length > other.segments.length) { + return 1; + } + return 0; + } + /** + * Returns a copy of the underlying segments. + * + * @private + * @returns {Array.} A copy of the segments that make up this path. + */ + toArray() { + return this.segments.slice(); + } + /** + * Returns true if this `Path` is equal to the provided value. + * + * @private + * @param {*} other The value to compare against. + * @return {boolean} true if this `Path` is equal to the provided value. + */ + isEqual(other) { + return (this === other || + (is_1.default.instanceof(other, this.constructor) && + this.compareTo(other) === 0)); + } +} +/** + * A slash-separated path for navigating resources (documents and collections) + * within Firestore. + * + * @private + * @class + */ +class ResourcePath extends Path { + /** + * Constructs a Firestore Resource Path. + * + * @private + * @hideconstructor + * + * @param {string} projectId - The Firestore project id. + * @param {string} databaseId - The Firestore database id. + * @param {string[]?} segments - Sequence of names of the parts of + * the path. + */ + constructor(projectId, databaseId, segments) { + const elements = segments instanceof Array ? + segments : + Array.prototype.slice.call(arguments, 2); + super(elements); + this.projectId = projectId; + this.databaseId = databaseId; + } + /** + * String representation of the path relative to the database root. + * + * @private + * @type {string} + */ + get relativeName() { + return this.segments.join('/'); + } + /** + * Indicates whether this ResourcePath points to a document. + * + * @private + * @type {boolean} + */ + get isDocument() { + return this.segments.length > 0 && this.segments.length % 2 === 0; + } + /** + * Indicates whether this ResourcePath points to a collection. + * + * @private + * @type {boolean} + */ + get isCollection() { + return this.segments.length % 2 === 1; + } + /** + * The last component of the path. + * + * @private + * @type {string|null} + */ + get id() { + if (this.segments.length > 0) { + return this.segments[this.segments.length - 1]; + } + return null; + } + /** + * Returns true if the given string can be used as a relative or absolute + * resource path. + * + * @private + * @param {string} resourcePath - The path to validate. + * @throws if the string can't be used as a resource path. + * @returns {boolean} 'true' when the path is valid. + */ + static validateResourcePath(resourcePath) { + if (!is_1.default.string(resourcePath) || resourcePath === '') { + throw new Error(`Path must be a non-empty string.`); + } + if (resourcePath.indexOf('//') >= 0) { + throw new Error('Paths must not contain //.'); + } + return true; + } + /** + * Creates a resource path from an absolute Firestore path. + * + * @private + * @param {string} absolutePath - A string representation of a Resource Path. + * @returns {ResourcePath} The new ResourcePath. + */ + static fromSlashSeparatedString(absolutePath) { + const elements = RESOURCE_PATH_RE.exec(absolutePath); + if (elements) { + const project = elements[1]; + const database = elements[2]; + const path = elements[3]; + return new ResourcePath(project, database).append(path); + } + throw new Error(`Resource name '${absolutePath}' is not valid.`); + } + /** + * Splits a string into path segments, using slashes as separators. + * + * @private + * @override + * @param {string} relativePath - The path to split. + * @returns {Array.} - The split path segments. + */ + split(relativePath) { + // We may have an empty segment at the beginning or end if they had a + // leading or trailing slash (which we allow). + return relativePath.split('/').filter(segment => segment.length > 0); + } + /** + * String representation of a ResourcePath as expected by the API. + * + * @private + * @override + * @returns {string} The representation as expected by the API. + */ + canonicalString() { + let components = [ + 'projects', + this.projectId, + 'databases', + this.databaseId, + ]; + if (this.segments.length > 0) { + components = components.concat('documents', this.segments); + } + return components.join('/'); + } + /** + * Constructs a new instance of ResourcePath. We need this instead of using + * the normal constructor because polymorphic 'this' doesn't work on static + * methods. + * + * @private + * @override + * @param {Array.} segments - Sequence of names of the parts of the + * path. + * @returns {ResourcePath} The newly created ResourcePath. + */ + construct(segments) { + return new ResourcePath(this.projectId, this.databaseId, segments); + } + /** + * Compare the current path against another ResourcePath object. + * + * @private + * @override + * @param {ResourcePath} other - The path to compare to. + * @returns {number} -1 if current < other, 1 if current > other, 0 if equal + */ + compareTo(other) { + // Ignore DocumentReference with {{projectId}} placeholders and assume that + // the resolved IDs match the provided ResourcePath. We could alternatively + // try to resolve the Project ID here, but this is asynchronous as it + // requires Disk I/O. + if (this.projectId !== '{{projectId}}' && + other.projectId !== '{{projectId}}') { + if (this.projectId < other.projectId) { + return -1; + } + if (this.projectId > other.projectId) { + return 1; + } + } + if (this.databaseId < other.databaseId) { + return -1; + } + if (this.databaseId > other.databaseId) { + return 1; + } + return super.compareTo(other); + } + /** + * Converts this ResourcePath to the Firestore Proto representation. + * + * @private + */ + toProto() { + return { + referenceValue: this.formattedName, + }; + } +} +exports.ResourcePath = ResourcePath; +/** + * A dot-separated path for navigating sub-objects within a document. + * + * @class + */ +class FieldPath extends Path { + /** + * Constructs a Firestore Field Path. + * + * @param {...string|string[]} segments - Sequence of field names that form + * this path. + * + * @example + * let query = firestore.collection('col'); + * let fieldPath = new FieldPath('f.o.o', 'bar'); + * + * query.where(fieldPath, '==', 42).get().then(snapshot => { + * snapshot.forEach(document => { + * console.log(`Document contains {'f.o.o' : {'bar' : 42}}`); + * }); + * }); + */ + constructor(segments) { + validate.minNumberOfArguments('FieldPath', arguments, 1); + const elements = segments instanceof Array ? + segments : + Array.prototype.slice.call(arguments); + for (let i = 0; i < elements.length; ++i) { + validate.isString(i, elements[i]); + if (elements[i].length === 0) { + throw new Error(`Argument at index ${i} should not be empty.`); + } + } + super(elements); + } + /** + * A special FieldPath value to refer to the ID of a document. It can be used + * in queries to sort or filter by the document ID. + * + * @returns {FieldPath} + */ + static documentId() { + return FieldPath._DOCUMENT_ID; + } + /** + * Returns true if the provided value can be used as a field path argument. + * + * @private + * @param {string|FieldPath} fieldPath - The value to verify. + * @throws if the string can't be used as a field path. + * @returns {boolean} 'true' when the path is valid. + */ + static validateFieldPath(fieldPath) { + if (!(fieldPath instanceof FieldPath)) { + if (!is_1.default.string(fieldPath)) { + throw validate_1.customObjectError(fieldPath); + } + if (fieldPath.indexOf('..') >= 0) { + throw new Error(`Paths must not contain '..' in them.`); + } + if (fieldPath.startsWith('.') || fieldPath.endsWith('.')) { + throw new Error(`Paths must not start or end with '.'.`); + } + if (!FIELD_PATH_RE.test(fieldPath)) { + throw new Error(`Paths can't be empty and must not contain '*~/[]'.`); + } + } + return true; + } + /** + * Turns a field path argument into a [FieldPath]{@link FieldPath}. + * Supports FieldPaths as input (which are passed through) and dot-separated + * strings. + * + * @private + * @param {string|FieldPath} fieldPath - The FieldPath to create. + * @returns {FieldPath} A field path representation. + */ + static fromArgument(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('.')); + } + /** + * String representation of a FieldPath as expected by the API. + * + * @private + * @override + * @returns {string} The representation as expected by the API. + */ + canonicalString() { + return this.segments + .map(str => { + return UNESCAPED_FIELD_NAME_RE.test(str) ? + str : + '`' + str.replace('\\', '\\\\').replace('`', '\\`') + '`'; + }) + .join('.'); + } + /** + * Splits a string into path segments, using dots as separators. + * + * @private + * @override + * @param {string} fieldPath - The path to split. + * @returns {Array.} - The split path segments. + */ + split(fieldPath) { + return fieldPath.split('.'); + } + /** + * Constructs a new instance of FieldPath. We need this instead of using + * the normal constructor because polymorphic 'this' doesn't work on static + * methods. + * + * @private + * @override + * @param {Array.} segments - Sequence of field names. + * @returns {ResourcePath} The newly created FieldPath. + */ + construct(segments) { + return new FieldPath(segments); + } + /** + * Returns true if this `FieldPath` is equal to the provided value. + * + * @param {*} other The value to compare against. + * @return {boolean} true if this `FieldPath` is equal to the provided value. + */ + isEqual(other) { + return super.isEqual(other); + } +} +/** + * A special sentinel value to refer to the ID of a document. + * + * @private + */ +FieldPath._DOCUMENT_ID = new FieldPath('__name__'); +exports.FieldPath = FieldPath; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/pool.js b/website/functions/node_modules/@google-cloud/firestore/build/src/pool.js new file mode 100644 index 00000000..2ad0ecf6 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/pool.js @@ -0,0 +1,124 @@ +/*! + * Copyright 2018 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. + */ +'use strict'; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const assert_1 = __importDefault(require("assert")); +/** + * An auto-resizing pool that distributes concurrent operations over multiple + * clients of type `T`. + * + * ClientPool is used within Firestore to manage a pool of GAPIC clients and + * automatically initializes multiple clients if we issue more than 100 + * concurrent operations. + * + * @private + */ +class ClientPool { + /** + * @param concurrentOperationLimit - The number of operations that each client + * can handle. + * @param clientFactory - A factory function called as needed when new clients + * are required. + */ + constructor(concurrentOperationLimit, clientFactory) { + this.concurrentOperationLimit = concurrentOperationLimit; + this.clientFactory = clientFactory; + /** Stores each active clients and how many operations it has outstanding. */ + this.activeClients = new Map(); + } + /** + * Returns an already existing client if it has less than the maximum number + * of concurrent operations or initializes and returns a new client. + */ + acquire() { + let selectedClient = null; + let selectedRequestCount = 0; + this.activeClients.forEach((requestCount, client) => { + if (!selectedClient && requestCount < this.concurrentOperationLimit) { + selectedClient = client; + selectedRequestCount = requestCount; + } + }); + if (!selectedClient) { + selectedClient = this.clientFactory(); + assert_1.default(!this.activeClients.has(selectedClient), 'The provided client factory returned an existing instance'); + } + this.activeClients.set(selectedClient, selectedRequestCount + 1); + return selectedClient; + } + /** + * Reduces the number of operations for the provided client, potentially + * removing it from the pool of active clients. + */ + release(client) { + let requestCount = this.activeClients.get(client) || 0; + assert_1.default(requestCount > 0, 'No active request'); + requestCount = requestCount - 1; + this.activeClients.set(client, requestCount); + if (requestCount === 0) { + this.garbageCollect(); + } + } + /** + * The number of currently registered clients. + * + * @return Number of currently registered clients. + */ + // Visible for testing. + get size() { + return this.activeClients.size; + } + /** + * Runs the provided operation in this pool. This function may create an + * additional client if all existing clients already operate at the concurrent + * operation limit. + * + * @param op - A callback function that returns a Promise. The client T will + * be returned to the pool when callback finishes. + * @return A Promise that resolves with the result of `op`. + */ + run(op) { + const client = this.acquire(); + return op(client) + .catch(err => { + this.release(client); + return Promise.reject(err); + }) + .then(res => { + this.release(client); + return res; + }); + } + /** + * Deletes clients that are no longer executing operations. Keeps up to one + * idle client to reduce future initialization costs. + */ + garbageCollect() { + let idleClients = 0; + this.activeClients.forEach((requestCount, client) => { + if (requestCount === 0) { + ++idleClients; + if (idleClients > 1) { + this.activeClients.delete(client); + } + } + }); + } +} +exports.ClientPool = ClientPool; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/reference.js b/website/functions/node_modules/@google-cloud/firestore/build/src/reference.js new file mode 100644 index 00000000..87bb667d --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/reference.js @@ -0,0 +1,1782 @@ +/*! + * Copyright 2017 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. + */ +'use strict'; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const bun_1 = __importDefault(require("bun")); +const deep_equal_1 = __importDefault(require("deep-equal")); +const extend_1 = __importDefault(require("extend")); +const is_1 = __importDefault(require("is")); +const through2_1 = __importDefault(require("through2")); +const order_1 = require("./order"); +const logger_1 = require("./logger"); +const document_1 = require("./document"); +const document_change_1 = require("./document-change"); +const watch_1 = require("./watch"); +const write_batch_1 = require("./write-batch"); +const timestamp_1 = require("./timestamp"); +const path_1 = require("./path"); +const util_1 = require("./util"); +const validate_1 = require("./validate"); +/*! + * The direction of a `Query.orderBy()` clause is specified as 'desc' or 'asc' + * (descending or ascending). + * + * @private + */ +const directionOperators = { + asc: 'ASCENDING', + ASC: 'ASCENDING', + desc: 'DESCENDING', + DESC: 'DESCENDING', +}; +/*! + * Filter conditions in a `Query.where()` clause are specified using the + * strings '<', '<=', '==', '>=', and '>'. + * + * @private + */ +const comparisonOperators = { + '<': 'LESS_THAN', + '<=': 'LESS_THAN_OR_EQUAL', + '=': 'EQUAL', + '==': 'EQUAL', + '>': 'GREATER_THAN', + '>=': 'GREATER_THAN_OR_EQUAL', + 'array-contains': 'ARRAY_CONTAINS' +}; +/** + * onSnapshot() callback that receives a QuerySnapshot. + * + * @callback querySnapshotCallback + * @param {QuerySnapshot} snapshot - A query snapshot. + */ +/** + * onSnapshot() callback that receives a DocumentSnapshot. + * + * @callback documentSnapshotCallback + * @param {DocumentSnapshot} snapshot - A document snapshot. + */ +/** + * onSnapshot() callback that receives an error. + * + * @callback errorCallback + * @param {Error} err - An error from a listen. + */ +/** + * A DocumentReference refers to a document location in a Firestore database + * and can be used to write, read, or listen to the location. The document at + * the referenced location may or may not exist. A DocumentReference can + * also be used to create a + * [CollectionReference]{@link CollectionReference} to a + * subcollection. + * + * @class + */ +class DocumentReference { + /** + * @private + * @hideconstructor + * + * @param {Firestore} firestore - The Firestore Database client. + * @param {ResourcePath} path - The Path of this reference. + */ + constructor(firestore, path) { + this._firestore = firestore; + this._validator = firestore._validator; + this._referencePath = path; + } + /** + * The string representation of the DocumentReference's location. + * @private + * @type {string} + * @name DocumentReference#formattedName + */ + get formattedName() { + return this._referencePath.formattedName; + } + /** + * The [Firestore]{@link Firestore} instance for the Firestore + * database (useful for performing transactions, etc.). + * + * @type {Firestore} + * @name DocumentReference#firestore + * @readonly + * + * @example + * let collectionRef = firestore.collection('col'); + * + * collectionRef.add({foo: 'bar'}).then(documentReference => { + * let firestore = documentReference.firestore; + * console.log(`Root location for document is ${firestore.formattedName}`); + * }); + */ + get firestore() { + return this._firestore; + } + /** + * A string representing the path of the referenced document (relative + * to the root of the database). + * + * @type {string} + * @name DocumentReference#path + * @readonly + * + * @example + * let collectionRef = firestore.collection('col'); + * + * collectionRef.add({foo: 'bar'}).then(documentReference => { + * console.log(`Added document at '${documentReference.path}'`); + * }); + */ + get path() { + return this._referencePath.relativeName; + } + /** + * The last path element of the referenced document. + * + * @type {string} + * @name DocumentReference#id + * @readonly + * + * @example + * let collectionRef = firestore.collection('col'); + * + * collectionRef.add({foo: 'bar'}).then(documentReference => { + * console.log(`Added document with name '${documentReference.id}'`); + * }); + */ + get id() { + return this._referencePath.id; + } + /** + * A reference to the collection to which this DocumentReference belongs. + * + * @name DocumentReference#parent + * @type {CollectionReference} + * @readonly + * + * @example + * let documentRef = firestore.doc('col/doc'); + * let collectionRef = documentRef.parent; + * + * collectionRef.where('foo', '==', 'bar').get().then(results => { + * console.log(`Found ${results.size} matches in parent collection`); + * }): + */ + get parent() { + return createCollectionReference(this._firestore, this._referencePath.parent()); + } + /** + * Returns the [ResourcePath]{@link ResourcePath} for this + * DocumentReference. + * + * @private + * @type {ResourcePath} + * @readonly + */ + get ref() { + return this._referencePath; + } + /** + * Retrieve a document from the database. Fails the Promise if the document is + * not found. + * + * @returns {Promise.} A Promise resolved with a + * DocumentSnapshot for the retrieved document on success. For missing + * documents, DocumentSnapshot.exists will be false. If the get() fails for + * other reasons, the Promise will be rejected. + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * documentRef.get().then(documentSnapshot => { + * if (documentSnapshot.exists) { + * console.log('Document retrieved successfully.'); + * } + * }); + */ + get() { + return this._firestore.getAll([this]).then(result => { + return result[0]; + }); + } + /** + * Gets a [CollectionReference]{@link CollectionReference} instance + * that refers to the collection at the specified path. + * + * @param {string} collectionPath - A slash-separated path to a collection. + * @returns {CollectionReference} A reference to the new + * subcollection. + * + * @example + * let documentRef = firestore.doc('col/doc'); + * let subcollection = documentRef.collection('subcollection'); + * console.log(`Path to subcollection: ${subcollection.path}`); + */ + collection(collectionPath) { + this._validator.isResourcePath('collectionPath', collectionPath); + let path = this._referencePath.append(collectionPath); + if (!path.isCollection) { + throw new Error(`Argument "collectionPath" must point to a collection, but was "${collectionPath}". Your path does not contain an odd number of components.`); + } + return createCollectionReference(this._firestore, path); + } + /** + * Fetches the subcollections that are direct children of this document. + * + * @returns {Promise.>} A Promise that resolves + * with an array of CollectionReferences. + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * documentRef.getCollections().then(collections => { + * for (let collection of collections) { + * console.log(`Found subcollection with id: ${collection.id}`); + * } + * }); + */ + getCollections() { + const request = { + parent: this._referencePath.formattedName, + }; + return this._firestore.request('listCollectionIds', request, util_1.requestTag()) + .then(collectionIds => { + let collections = []; + // We can just sort this list using the default comparator since it + // will only contain collection ids. + collectionIds.sort(); + for (let collectionId of collectionIds) { + collections.push(this.collection(collectionId)); + } + return collections; + }); + } + /** + * Create a document with the provided object values. This will fail the write + * if a document exists at its location. + * + * @param {DocumentData} data - An object that contains the fields and data to + * serialize as the document. + * @returns {Promise.} A Promise that resolves with the + * write time of this create. + * + * @example + * let documentRef = firestore.collection('col').doc(); + * + * documentRef.create({foo: 'bar'}).then((res) => { + * console.log(`Document created at ${res.updateTime}`); + * }).catch((err) => { + * console.log(`Failed to create document: ${err}`); + * }); + */ + create(data) { + let writeBatch = new write_batch_1.WriteBatch(this._firestore); + return writeBatch.create(this, data).commit().then(writeResults => { + return Promise.resolve(writeResults[0]); + }); + } + /** + * Deletes the document referred to by this `DocumentReference`. + * + * A delete for a non-existing document is treated as a success (unless + * lastUptimeTime is provided). + * + * @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 delete if the + * document was last updated at a different time. + * @returns {Promise.} A Promise that resolves with the + * delete time. + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * documentRef.delete().then(() => { + * console.log('Document successfully deleted.'); + * }); + */ + delete(precondition) { + let writeBatch = new write_batch_1.WriteBatch(this._firestore); + return writeBatch.delete(this, precondition).commit().then(writeResults => { + return Promise.resolve(writeResults[0]); + }); + } + /** + * 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 {DocumentData} data - A map of the fields and values for the + * document. + * @param {SetOptions=} options - An object to configure the set behavior. + * @param {boolean=} options.merge - If true, set() merges the values + * specified in its data argument. Fields omitted from this set() call + * remain untouched. + * @param {Array.=} 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 + * write time of this set. + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * documentRef.set({foo: 'bar'}).then(res => { + * console.log(`Document written at ${res.updateTime}`); + * }); + */ + set(data, options) { + let writeBatch = new write_batch_1.WriteBatch(this._firestore); + return writeBatch.set(this, data, options).commit().then(writeResults => { + return Promise.resolve(writeResults[0]); + }); + } + /** + * Updates fields in the document referred to by this DocumentReference. + * If the document doesn't yet exist, the update fails and the returned + * Promise 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. + * + * A Precondition restricting this update can be specified as the last + * argument. + * + * @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 { + * ...(*|string|FieldPath|Precondition)} preconditionOrValues - + * An alternating list of field paths and values to update or a Precondition + * to restrict this update. + * @returns Promise. A Promise that resolves once the + * data has been successfully written to the backend. + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * documentRef.update({foo: 'bar'}).then(res => { + * console.log(`Document updated at ${res.updateTime}`); + * }); + */ + update(dataOrField, preconditionOrValues) { + this._validator.minNumberOfArguments('update', arguments, 1); + let writeBatch = new write_batch_1.WriteBatch(this._firestore); + preconditionOrValues = Array.prototype.slice.call(arguments, 1); + return writeBatch.update + .apply(writeBatch, [this, dataOrField].concat(preconditionOrValues)) + .commit() + .then(writeResults => { + return Promise.resolve(writeResults[0]); + }); + } + /** + * Attaches a listener for DocumentSnapshot events. + * + * @param {documentSnapshotCallback} onNext - A callback to be called every + * time a new `DocumentSnapshot` is available. + * @param {errorCallback=} onError - A callback to be called if the listen + * fails or is cancelled. No further callbacks will occur. If unset, errors + * will be logged to the console. + * + * @returns {function()} An unsubscribe function that can be called to cancel + * the snapshot listener. + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * let unsubscribe = documentRef.onSnapshot(documentSnapshot => { + * if (documentSnapshot.exists) { + * console.log(documentSnapshot.data()); + * } + * }, err => { + * console.log(`Encountered error: ${err}`); + * }); + * + * // Remove this listener. + * unsubscribe(); + */ + onSnapshot(onNext, onError) { + this._validator.isFunction('onNext', onNext); + this._validator.isOptionalFunction('onError', onError); + if (!is_1.default.defined(onError)) { + onError = console.error; + } + let watch = watch_1.Watch.forDocument(this); + return watch.onSnapshot((readTime, size, docs) => { + for (let document of docs()) { + if (document.ref.path === this.path) { + onNext(document); + return; + } + } + // The document is missing. + let document = new document_1.DocumentSnapshot.Builder(); + document.ref = + new DocumentReference(this._firestore, this._referencePath); + document.readTime = readTime; + onNext(document.build()); + }, onError); + } + /** + * Returns true if this `DocumentReference` is equal to the provided value. + * + * @param {*} other The value to compare against. + * @return {boolean} true if this `DocumentReference` is equal to the provided + * value. + */ + isEqual(other) { + return (this === other || + (is_1.default.instanceof(other, DocumentReference) && + this._firestore === other._firestore && + this._referencePath.isEqual(other._referencePath))); + } + /** + * Converts this DocumentReference to the Firestore Proto representation. + * + * @private + */ + toProto() { + return { + referenceValue: this.formattedName + }; + } +} +exports.DocumentReference = DocumentReference; +/** + * A Query order-by field. + * + * @private + * @class + */ +class FieldOrder { + /** + * @private + * @hideconstructor + * + * @param {FieldPath} field - The name of a document field (member) + * on which to order query results. + * @param {string=} direction One of 'ASCENDING' (default) or 'DESCENDING' to + * set the ordering direction to ascending or descending, respectively. + */ + constructor(field, direction) { + this._field = field; + this._direction = direction || directionOperators.ASC; + } + /** + * The path of the field on which to order query results. + * + * @private + * @type {FieldPath} + */ + get field() { + return this._field; + } + /** + * One of 'ASCENDING' (default) or 'DESCENDING'. + * + * @private + * @type {string} + */ + get direction() { + return this._direction; + } + /** + * Generates the proto representation for this field order. + * + * @private + * @returns {Object} + */ + toProto() { + return { + field: { + fieldPath: this._field.formattedName, + }, + direction: this._direction, + }; + } +} +/*! + * A field constraint for a Query where clause. + * + * @private + * @class + */ +class FieldFilter { + /** + * @private + * @hideconstructor + * + * @param {FieldPath} field - The path of the property value to + * compare. + * @param {string} opString - A comparison operation. + * @param {*} value The value to which to compare the + * field for inclusion in a query. + */ + constructor(serializer, field, opString, value) { + this._serializer = serializer; + this._field = field; + this._opString = opString; + this._value = value; + } + /** + * Returns the field path of this filter. + * + * @private + * @return {FieldPath} + */ + get field() { + return this._field; + } + /** + * Returns whether this FieldFilter uses an equals comparison. + * + * @private + * @return {boolean} + */ + isInequalityFilter() { + return this._opString === 'GREATER_THAN' || + this._opString === 'GREATER_THAN_OR_EQUAL' || + this._opString === 'LESS_THAN' || + this._opString === 'LESS_THAN_OR_EQUAL'; + } + /** + * Generates the proto representation for this field filter. + * + * @private + * @returns {Object} + */ + toProto() { + if (typeof this._value === 'number' && isNaN(this._value)) { + return { + unaryFilter: { + field: { + fieldPath: this._field.formattedName, + }, + op: 'IS_NAN', + }, + }; + } + if (this._value === null) { + return { + unaryFilter: { + field: { + fieldPath: this._field.formattedName, + }, + op: 'IS_NULL', + }, + }; + } + return { + fieldFilter: { + field: { + fieldPath: this._field.formattedName, + }, + op: this._opString, + value: this._serializer.encodeValue(this._value), + }, + }; + } +} +/** + * A QuerySnapshot contains zero or more + * [QueryDocumentSnapshot]{@link QueryDocumentSnapshot} objects + * representing the results of a query. The documents can be accessed as an + * array via the [documents]{@link QuerySnapshot#documents} property + * or enumerated using the [forEach]{@link QuerySnapshot#forEach} + * method. The number of documents can be determined via the + * [empty]{@link QuerySnapshot#empty} and + * [size]{@link QuerySnapshot#size} properties. + * + * @class QuerySnapshot + */ +class QuerySnapshot { + /** + * @private + * @hideconstructor + * + * @param {Query} query - The originating query. + * @param {Timestamp} readTime - The time when this query snapshot was + * obtained. + * @param {number} size - The number of documents in the result set. + * @param {function} docs - A callback returning a sorted array of documents + * matching this query + * @param {function} changes - A callback returning a sorted array of + * document change events for this snapshot. + */ + constructor(query, readTime, size, docs, changes) { + this._query = query; + this._validator = query.firestore._validator; + this._readTime = readTime; + this._size = size; + this._docs = docs; + this._materializedDocs = null; + this._changes = changes; + this._materializedChanges = null; + } + /** + * The query on which you called get() or onSnapshot() in order to get this + * QuerySnapshot. + * + * @type {Query} + * @name QuerySnapshot#query + * @readonly + * + * @example + * let query = firestore.collection('col').where('foo', '==', 'bar'); + * + * query.limit(10).get().then(querySnapshot => { + * console.log(`Returned first batch of results`); + * let query = querySnapshot.query; + * return query.offset(10).get(); + * }).then(() => { + * console.log(`Returned second batch of results`); + * }); + */ + get query() { + return this._query; + } + /** + * An array of all the documents in this QuerySnapshot. + * + * @type {Array.} + * @name QuerySnapshot#docs + * @readonly + * + * @example + * let query = firestore.collection('col').where('foo', '==', 'bar'); + * + * query.get().then(querySnapshot => { + * let docs = querySnapshot.docs; + * for (let doc of docs) { + * console.log(`Document found at path: ${doc.ref.path}`); + * } + * }); + */ + get docs() { + if (this._materializedDocs) { + return this._materializedDocs; + } + this._materializedDocs = this._docs(); + this._docs = null; + return this._materializedDocs; + } + /** + * An array of all changes in this QuerySnapshot. + * + * @type {Array.} + * @name QuerySnapshot#docChanges + * @readonly + */ + get docChanges() { + if (this._materializedChanges) { + return this._materializedChanges; + } + this._materializedChanges = this._changes(); + this._changes = null; + return this._materializedChanges; + } + /** + * True if there are no documents in the QuerySnapshot. + * + * @type {boolean} + * @name QuerySnapshot#empty + * @readonly + * + * @example + * let query = firestore.collection('col').where('foo', '==', 'bar'); + * + * query.get().then(querySnapshot => { + * if (querySnapshot.empty) { + * console.log('No documents found.'); + * } + * }); + */ + get empty() { + return this._size === 0; + } + /** + * The number of documents in the QuerySnapshot. + * + * @type {number} + * @name QuerySnapshot#size + * @readonly + * + * @example + * let query = firestore.collection('col').where('foo', '==', 'bar'); + * + * query.get().then(querySnapshot => { + * console.log(`Found ${querySnapshot.size} documents.`); + * }); + */ + get size() { + return this._size; + } + /** + * The time this query snapshot was obtained. + * + * @type {Timestamp} + * @name QuerySnapshot#readTime + * + * @example + * let query = firestore.collection('col').where('foo', '==', 'bar'); + * + * query.get().then((querySnapshot) => { + * let readTime = querySnapshot.readTime; + * console.log(`Query results returned at '${readTime.toDate()}'`); + * }); + */ + get readTime() { + return this._readTime; + } + /** + * Enumerates all of the documents in the QuerySnapshot. + * + * @param {function} callback - A callback to be called with a + * [QueryDocumentSnapshot]{@link QueryDocumentSnapshot} for each document in + * the snapshot. + * @param {*=} thisArg The `this` binding for the callback.. + * + * @example + * let query = firestore.collection('col').where('foo', '==', 'bar'); + * + * query.get().then(querySnapshot => { + * querySnapshot.forEach(documentSnapshot => { + * console.log(`Document found at path: ${documentSnapshot.ref.path}`); + * }); + * }); + */ + forEach(callback, thisArg) { + this._validator.isFunction('callback', callback); + for (let doc of this.docs) { + callback.call(thisArg, doc); + } + } + /** + * Returns true if the document data in this `QuerySnapshot` is equal to the + * provided value. + * + * @param {*} other The value to compare against. + * @return {boolean} true if this `QuerySnapshot` is equal to the provided + * value. + */ + isEqual(other) { + // Since the read time is different on every query read, we explicitly + // ignore all metadata in this comparison. + if (this === other) { + return true; + } + if (!is_1.default.instanceof(other, QuerySnapshot)) { + return false; + } + if (this._size !== other._size) { + return false; + } + if (!this._query.isEqual(other._query)) { + return false; + } + if (this._materializedDocs && !this._materializedChanges) { + // If we have only materialized the documents, we compare them first. + return (isArrayEqual(this.docs, other.docs) && + isArrayEqual(this.docChanges, other.docChanges)); + } + // Otherwise, we compare the changes first as we expect there to be fewer. + return (isArrayEqual(this.docChanges, other.docChanges) && + isArrayEqual(this.docs, other.docs)); + } +} +exports.QuerySnapshot = QuerySnapshot; +/** + * A Query refers to a query which you can read or stream from. You can also + * construct refined Query objects by adding filters and ordering. + * + * @class Query + */ +class Query { + /** + * @private + * @hideconstructor + * + * @param {Firestore} firestore - The Firestore Database client. + * @param {ResourcePath} path Path of the collection to be queried. + * @param {Array.=} fieldOrders - Sequence of fields to + * control the order of results. + * @param {Array.=} fieldFilters - Sequence of fields + * constraining the results of the query. + * @param {object=} queryOptions Additional query options. + */ + constructor(firestore, path, fieldFilters, fieldOrders, queryOptions) { + this._firestore = firestore; + this._serializer = firestore._serializer; + this._validator = firestore._validator; + this._referencePath = path; + this._fieldFilters = fieldFilters || []; + this._fieldOrders = fieldOrders || []; + this._queryOptions = queryOptions || {}; + } + /** + * Detects the argument type for Firestore cursors. + * + * @private + * @param {Array.} fieldValuesOrDocumentSnapshot - A + * snapshot of the document or a set of field values. + * @returns {boolean} 'true' if the input is a single DocumentSnapshot.. + */ + static _isDocumentSnapshot(fieldValuesOrDocumentSnapshot) { + return (fieldValuesOrDocumentSnapshot.length === 1 && + is_1.default.instance(fieldValuesOrDocumentSnapshot[0], document_1.DocumentSnapshot)); + } + /** + * Extracts field values from the DocumentSnapshot based on the provided + * field order. + * + * @private + * @param {DocumentSnapshot} documentSnapshot - The document to extract the + * fields from. + * @param {Array.} fieldOrders - The field order that defines what + * fields we should extract. + * @return {Array.<*>} The field values to use. + * @private + */ + static _extractFieldValues(documentSnapshot, fieldOrders) { + let fieldValues = []; + for (let fieldOrder of fieldOrders) { + if (path_1.FieldPath._DOCUMENT_ID.isEqual(fieldOrder.field)) { + fieldValues.push(documentSnapshot.ref); + } + else { + let fieldValue = documentSnapshot.get(fieldOrder.field); + if (is_1.default.undefined(fieldValue)) { + throw new Error(`Field '${fieldOrder + .field}' is missing in the provided DocumentSnapshot. Please provide a ` + + 'document that contains values for all specified orderBy() and ' + + 'where() constraints.'); + } + else { + fieldValues.push(fieldValue); + } + } + } + return fieldValues; + } + /** + * The string representation of the Query's location. + * @private + * @type {string} + * @name Query#formattedName + */ + get formattedName() { + return this._referencePath.formattedName; + } + /** + * The [Firestore]{@link Firestore} instance for the Firestore + * database (useful for performing transactions, etc.). + * + * @type {Firestore} + * @name Query#firestore + * @readonly + * + * @example + * let collectionRef = firestore.collection('col'); + * + * collectionRef.add({foo: 'bar'}).then(documentReference => { + * let firestore = documentReference.firestore; + * console.log(`Root location for document is ${firestore.formattedName}`); + * }); + */ + get firestore() { + return this._firestore; + } + /** + * Creates and returns a new [Query]{@link Query} with the additional filter + * that documents must contain the specified field and that its value should + * satisfy the relation constraint provided. + * + * Returns a new Query that constrains the value of a Document property. + * + * This function returns a new (immutable) instance of the Query (rather than + * modify the existing instance) to impose the filter. + * + * @param {string|FieldPath} fieldPath - The name of a property + * value to compare. + * @param {string} opStr - A comparison operation in the form of a string + * (e.g., "<"). + * @param {*} value - The value to which to compare the field for inclusion in + * a query. + * @returns {Query} The created Query. + * + * @example + * let collectionRef = firestore.collection('col'); + * + * collectionRef.where('foo', '==', 'bar').get().then(querySnapshot => { + * querySnapshot.forEach(documentSnapshot => { + * console.log(`Found document at ${documentSnapshot.ref.path}`); + * }); + * }); + */ + where(fieldPath, opStr, value) { + this._validator.isFieldPath('fieldPath', fieldPath); + this._validator.isQueryComparison('opStr', opStr, value); + this._validator.isQueryValue('value', value, { + allowDeletes: 'none', + allowTransforms: false, + }); + if (this._queryOptions.startAt || this._queryOptions.endAt) { + throw new Error('Cannot specify a where() filter after calling startAt(), ' + + 'startAfter(), endBefore() or endAt().'); + } + fieldPath = path_1.FieldPath.fromArgument(fieldPath); + if (path_1.FieldPath._DOCUMENT_ID.isEqual(fieldPath)) { + value = this._convertReference(value); + } + let combinedFilters = this._fieldFilters.concat(new FieldFilter(this._serializer, fieldPath, comparisonOperators[opStr], value)); + return new Query(this._firestore, this._referencePath, combinedFilters, this._fieldOrders, this._queryOptions); + } + /** + * Creates and returns a new [Query]{@link Query} instance that applies a + * field mask to the result and returns only the specified subset of fields. + * You can specify a list of field paths to return, or use an empty list to + * only return the references of matching documents. + * + * This function returns a new (immutable) instance of the Query (rather than + * modify the existing instance) to impose the field mask. + * + * @param {...(string|FieldPath)} fieldPaths - The field paths to + * return. + * @returns {Query} The created Query. + * + * @example + * let collectionRef = firestore.collection('col'); + * let documentRef = collectionRef.doc('doc'); + * + * return documentRef.set({x:10, y:5}).then(() => { + * return collectionRef.where('x', '>', 5).select('y').get(); + * }).then((res) => { + * console.log(`y is ${res.docs[0].get('y')}.`); + * }); + */ + select(fieldPaths) { + fieldPaths = [].slice.call(arguments); + let result = []; + if (fieldPaths.length === 0) { + result.push({ fieldPath: path_1.FieldPath._DOCUMENT_ID.formattedName }); + } + else { + for (let i = 0; i < fieldPaths.length; ++i) { + this._validator.isFieldPath(i, fieldPaths[i]); + result.push({ + fieldPath: path_1.FieldPath.fromArgument(fieldPaths[i]).formattedName, + }); + } + } + let options = extend_1.default(true, {}, this._queryOptions); + options.selectFields = { fields: result }; + return new Query(this._firestore, this._referencePath, this._fieldFilters, this._fieldOrders, options); + } + /** + * Creates and returns a new [Query]{@link Query} that's additionally sorted + * by the specified field, optionally in descending order instead of + * ascending. + * + * This function returns a new (immutable) instance of the Query (rather than + * modify the existing instance) to impose the field mask. + * + * @param {string|FieldPath} fieldPath - The field to sort by. + * @param {string=} directionStr - Optional direction to sort by ('asc' or + * 'desc'). If not specified, order will be ascending. + * @returns {Query} The created Query. + * + * @example + * let query = firestore.collection('col').where('foo', '>', 42); + * + * query.orderBy('foo', 'desc').get().then(querySnapshot => { + * querySnapshot.forEach(documentSnapshot => { + * console.log(`Found document at ${documentSnapshot.ref.path}`); + * }); + * }); + */ + orderBy(fieldPath, directionStr) { + this._validator.isFieldPath('fieldPath', fieldPath); + this._validator.isOptionalFieldOrder('directionStr', directionStr); + if (this._queryOptions.startAt || this._queryOptions.endAt) { + throw new Error('Cannot specify an orderBy() constraint after calling ' + + 'startAt(), startAfter(), endBefore() or endAt().'); + } + let newOrder = new FieldOrder(path_1.FieldPath.fromArgument(fieldPath), directionOperators[directionStr]); + let combinedOrders = this._fieldOrders.concat(newOrder); + return new Query(this._firestore, this._referencePath, this._fieldFilters, combinedOrders, this._queryOptions); + } + /** + * Creates and returns a new [Query]{@link Query} that's additionally limited + * to only return up to the specified number of documents. + * + * This function returns a new (immutable) instance of the Query (rather than + * modify the existing instance) to impose the limit. + * + * @param {number} limit - The maximum number of items to return. + * @returns {Query} The created Query. + * + * @example + * let query = firestore.collection('col').where('foo', '>', 42); + * + * query.limit(1).get().then(querySnapshot => { + * querySnapshot.forEach(documentSnapshot => { + * console.log(`Found document at ${documentSnapshot.ref.path}`); + * }); + * }); + */ + limit(limit) { + this._validator.isInteger('limit', limit); + let options = extend_1.default(true, {}, this._queryOptions); + options.limit = limit; + return new Query(this._firestore, this._referencePath, this._fieldFilters, this._fieldOrders, options); + } + /** + * Specifies the offset of the returned results. + * + * This function returns a new (immutable) instance of the + * [Query]{@link Query} (rather than modify the existing instance) + * to impose the offset. + * + * @param {number} offset - The offset to apply to the Query results + * @returns {Query} The created Query. + * + * @example + * let query = firestore.collection('col').where('foo', '>', 42); + * + * query.limit(10).offset(20).get().then(querySnapshot => { + * querySnapshot.forEach(documentSnapshot => { + * console.log(`Found document at ${documentSnapshot.ref.path}`); + * }); + * }); + */ + offset(offset) { + this._validator.isInteger('offset', offset); + let options = extend_1.default(true, {}, this._queryOptions); + options.offset = offset; + return new Query(this._firestore, this._referencePath, this._fieldFilters, this._fieldOrders, options); + } + /** + * Returns true if this `Query` is equal to the provided value. + * + * @param {*} other The value to compare against. + * @return {boolean} true if this `Query` is equal to the provided value. + */ + isEqual(other) { + if (this === other) { + return true; + } + return (is_1.default.instanceof(other, Query) && + this._referencePath.isEqual(other._referencePath) && + deep_equal_1.default(this._fieldFilters, other._fieldFilters, { strict: true }) && + deep_equal_1.default(this._fieldOrders, other._fieldOrders, { strict: true }) && + deep_equal_1.default(this._queryOptions, other._queryOptions, { strict: true })); + } + /** + * Computes the backend ordering semantics for DocumentSnapshot cursors. + * + * @private + * @param {Array.} cursorValuesOrDocumentSnapshot - The + * snapshot of the document or the set of field values to use as the boundary. + * @returns {Array.} The implicit ordering semantics. + */ + _createImplicitOrderBy(cursorValuesOrDocumentSnapshot) { + if (!Query._isDocumentSnapshot(cursorValuesOrDocumentSnapshot)) { + return this._fieldOrders; + } + let fieldOrders = this._fieldOrders.slice(); + let hasDocumentId = false; + if (fieldOrders.length === 0) { + // If no explicit ordering is specified, use the first inequality to + // define an implicit order. + for (let fieldFilter of this._fieldFilters) { + if (fieldFilter.isInequalityFilter()) { + fieldOrders.push(new FieldOrder(fieldFilter.field, 'ASCENDING')); + break; + } + } + } + else { + for (let fieldOrder of fieldOrders) { + if (path_1.FieldPath._DOCUMENT_ID.isEqual(fieldOrder.field)) { + hasDocumentId = true; + } + } + } + if (!hasDocumentId) { + // Add implicit sorting by name, using the last specified direction. + let lastDirection = fieldOrders.length === 0 ? + directionOperators.ASC : + fieldOrders[fieldOrders.length - 1].direction; + fieldOrders.push(new FieldOrder(path_1.FieldPath.documentId(), lastDirection)); + } + return fieldOrders; + } + /** + * Builds a Firestore 'Position' proto message. + * + * @private + * @param {Array.} fieldOrders - The field orders to use for this + * cursor. + * @param {Array.} cursorValuesOrDocumentSnapshot - The + * snapshot of the document or the set of field values to use as the + * boundary. + * @param before - Whether the query boundary lies just before or after the + * provided data. + * @returns {Object} The proto message. + */ + _createCursor(fieldOrders, cursorValuesOrDocumentSnapshot, before) { + let fieldValues; + if (Query._isDocumentSnapshot(cursorValuesOrDocumentSnapshot)) { + fieldValues = Query._extractFieldValues(cursorValuesOrDocumentSnapshot[0], fieldOrders); + } + else { + fieldValues = cursorValuesOrDocumentSnapshot; + } + if (fieldValues.length > fieldOrders.length) { + throw new Error('Too many cursor values specified. The specified ' + + 'values must match the orderBy() constraints of the query.'); + } + let options = { + values: [], + }; + if (before) { + options.before = true; + } + for (let i = 0; i < fieldValues.length; ++i) { + let fieldValue = fieldValues[i]; + if (path_1.FieldPath._DOCUMENT_ID.isEqual(fieldOrders[i].field)) { + fieldValue = this._convertReference(fieldValue); + } + this._validator.isQueryValue(i, fieldValue, { + allowDeletes: 'none', + allowTransforms: false, + }); + options.values.push(this._serializer.encodeValue(fieldValue)); + } + return options; + } + /** + * Validates that a value used with FieldValue.documentId() is either a + * string or a DocumentReference that is part of the query`s result set. + * Throws a validation error or returns a DocumentReference that can + * directly be used in the Query. + * + * @param {*} reference - The value to validate. + * @throws If the value cannot be used for this query. + * @return {DocumentReference} If valid, returns a DocumentReference that + * can be used with the query. + * @private + */ + _convertReference(reference) { + if (is_1.default.string(reference)) { + reference = new DocumentReference(this._firestore, this._referencePath.append(reference)); + } + else if (is_1.default.instance(reference, DocumentReference)) { + if (!this._referencePath.isPrefixOf(reference.ref)) { + throw new Error(`'${reference.path}' is not part of the query result set and ` + + 'cannot be used as a query boundary.'); + } + } + else { + throw new Error('The corresponding value for FieldPath.documentId() must be a ' + + 'string or a DocumentReference.'); + } + if (reference.ref.parent().compareTo(this._referencePath) !== 0) { + throw new Error('Only a direct child can be used as a query boundary. ' + + `Found: '${reference.path}'.`); + } + return reference; + } + /** + * Creates and returns a new [Query]{@link Query} that starts at the provided + * set of field values relative to the order of the query. The order of the + * provided values must match the order of the order by clauses of the query. + * + * @param {...*|DocumentSnapshot} fieldValuesOrDocumentSnapshot - The snapshot + * of the document the query results should start at or the field values to + * start this query at, in order of the query's order by. + * @returns {Query} A query with the new starting point. + * + * @example + * let query = firestore.collection('col'); + * + * query.orderBy('foo').startAt(42).get().then(querySnapshot => { + * querySnapshot.forEach(documentSnapshot => { + * console.log(`Found document at ${documentSnapshot.ref.path}`); + * }); + * }); + */ + startAt(fieldValuesOrDocumentSnapshot) { + let options = extend_1.default(true, {}, this._queryOptions); + fieldValuesOrDocumentSnapshot = [].slice.call(arguments); + let fieldOrders = this._createImplicitOrderBy(fieldValuesOrDocumentSnapshot); + options.startAt = + this._createCursor(fieldOrders, fieldValuesOrDocumentSnapshot, true); + return new Query(this._firestore, this._referencePath, this._fieldFilters, fieldOrders, options); + } + /** + * Creates and returns a new [Query]{@link Query} that starts after the + * provided set of field values relative to the order of the query. The order + * of the provided values must match the order of the order by clauses of the + * query. + * + * @param {...*|DocumentSnapshot} fieldValuesOrDocumentSnapshot - The snapshot + * of the document the query results should start after or the field values to + * start this query after, in order of the query's order by. + * @returns {Query} A query with the new starting point. + * + * @example + * let query = firestore.collection('col'); + * + * query.orderBy('foo').startAfter(42).get().then(querySnapshot => { + * querySnapshot.forEach(documentSnapshot => { + * console.log(`Found document at ${documentSnapshot.ref.path}`); + * }); + * }); + */ + startAfter(fieldValuesOrDocumentSnapshot) { + let options = extend_1.default(true, {}, this._queryOptions); + fieldValuesOrDocumentSnapshot = [].slice.call(arguments); + let fieldOrders = this._createImplicitOrderBy(fieldValuesOrDocumentSnapshot); + options.startAt = + this._createCursor(fieldOrders, fieldValuesOrDocumentSnapshot, false); + return new Query(this._firestore, this._referencePath, this._fieldFilters, fieldOrders, options); + } + /** + * Creates and returns a new [Query]{@link Query} that ends before the set of + * field values relative to the order of the query. The order of the provided + * values must match the order of the order by clauses of the query. + * + * @param {...*|DocumentSnapshot} fieldValuesOrDocumentSnapshot - The snapshot + * of the document the query results should end before or the field values to + * end this query before, in order of the query's order by. + * @returns {Query} A query with the new ending point. + * + * @example + * let query = firestore.collection('col'); + * + * query.orderBy('foo').endBefore(42).get().then(querySnapshot => { + * querySnapshot.forEach(documentSnapshot => { + * console.log(`Found document at ${documentSnapshot.ref.path}`); + * }); + * }); + */ + endBefore(fieldValuesOrDocumentSnapshot) { + let options = extend_1.default(true, {}, this._queryOptions); + fieldValuesOrDocumentSnapshot = [].slice.call(arguments); + let fieldOrders = this._createImplicitOrderBy(fieldValuesOrDocumentSnapshot); + options.endAt = + this._createCursor(fieldOrders, fieldValuesOrDocumentSnapshot, true); + return new Query(this._firestore, this._referencePath, this._fieldFilters, fieldOrders, options); + } + /** + * Creates and returns a new [Query]{@link Query} that ends at the provided + * set of field values relative to the order of the query. The order of the + * provided values must match the order of the order by clauses of the query. + * + * @param {...*|DocumentSnapshot} fieldValuesOrDocumentSnapshot - The snapshot + * of the document the query results should end at or the field values to end + * this query at, in order of the query's order by. + * @returns {Query} A query with the new ending point. + * + * @example + * let query = firestore.collection('col'); + * + * query.orderBy('foo').endAt(42).get().then(querySnapshot => { + * querySnapshot.forEach(documentSnapshot => { + * console.log(`Found document at ${documentSnapshot.ref.path}`); + * }); + * }); + */ + endAt(fieldValuesOrDocumentSnapshot) { + let options = extend_1.default(true, {}, this._queryOptions); + fieldValuesOrDocumentSnapshot = [].slice.call(arguments); + let fieldOrders = this._createImplicitOrderBy(fieldValuesOrDocumentSnapshot); + options.endAt = + this._createCursor(fieldOrders, fieldValuesOrDocumentSnapshot, false); + return new Query(this._firestore, this._referencePath, this._fieldFilters, fieldOrders, options); + } + /** + * Executes the query and returns the results as a + * [QuerySnapshot]{@link QuerySnapshot}. + * + * @returns {Promise.} A Promise that resolves with the results + * of the Query. + * + * @example + * let query = firestore.collection('col').where('foo', '==', 'bar'); + * + * query.get().then(querySnapshot => { + * querySnapshot.forEach(documentSnapshot => { + * console.log(`Found document at ${documentSnapshot.ref.path}`); + * }); + * }); + */ + get() { + return this._get(); + } + /** + * Internal get() method that accepts an optional transaction id. + * + * @private + * @param {bytes=} queryOptions.transactionId - A transaction ID. + */ + _get(queryOptions) { + let self = this; + let docs = []; + return new Promise((resolve, reject) => { + let readTime; + self._stream(queryOptions) + .on('error', err => { + reject(err); + }) + .on('data', result => { + readTime = result.readTime; + if (result.document) { + let document = result.document; + docs.push(document); + } + }) + .on('end', () => { + resolve(new QuerySnapshot(this, readTime, docs.length, () => docs, () => { + let changes = []; + for (let i = 0; i < docs.length; ++i) { + changes.push(new document_change_1.DocumentChange(document_change_1.DocumentChange.ADDED, docs[i], -1, i)); + } + return changes; + })); + }); + }); + } + /** + * Executes the query and streams the results as + * [QueryDocumentSnapshots]{@link QueryDocumentSnapshot}. + * + * @returns {Stream.} A stream of + * QueryDocumentSnapshots. + * + * @example + * let query = firestore.collection('col').where('foo', '==', 'bar'); + * + * let count = 0; + * + * query.stream().on('data', (documentSnapshot) => { + * console.log(`Found document with name '${documentSnapshot.id}'`); + * ++count; + * }).on('end', () => { + * console.log(`Total count is ${count}`); + * }); + */ + stream() { + let responseStream = this._stream(); + let transform = through2_1.default.obj(function (chunk, encoding, callback) { + // Only send chunks with documents. + if (chunk.document) { + this.push(chunk.document); + } + callback(); + }); + return bun_1.default([responseStream, transform]); + } + /** + * Internal method for serializing a query to its RunQuery proto + * representation with an optional transaction id. + * + * @param {bytes=} queryOptions.transactionId - A transaction ID. + * @private + * @returns Serialized JSON for the query. + */ + toProto(queryOptions) { + let reqOpts = { + parent: this._referencePath.parent().formattedName, + structuredQuery: { + from: [ + { + collectionId: this._referencePath.id, + }, + ], + }, + }; + let structuredQuery = reqOpts.structuredQuery; + if (this._fieldFilters.length === 1) { + structuredQuery.where = this._fieldFilters[0].toProto(); + } + else if (this._fieldFilters.length > 1) { + let filters = []; + for (let fieldFilter of this._fieldFilters) { + filters.push(fieldFilter.toProto()); + } + structuredQuery.where = { + compositeFilter: { + op: 'AND', + filters: filters, + }, + }; + } + if (this._fieldOrders.length) { + let orderBy = []; + for (let fieldOrder of this._fieldOrders) { + orderBy.push(fieldOrder.toProto()); + } + structuredQuery.orderBy = orderBy; + } + if (this._queryOptions.limit) { + structuredQuery.limit = { value: this._queryOptions.limit }; + } + if (this._queryOptions.offset) { + structuredQuery.offset = this._queryOptions.offset; + } + if (this._queryOptions.startAt) { + structuredQuery.startAt = this._queryOptions.startAt; + } + if (this._queryOptions.endAt) { + structuredQuery.endAt = this._queryOptions.endAt; + } + if (this._queryOptions.selectFields) { + structuredQuery.select = this._queryOptions.selectFields; + } + if (queryOptions && queryOptions.transactionId) { + reqOpts.transaction = queryOptions.transactionId; + } + return reqOpts; + } + /** + * Internal streaming method that accepts an optional transaction id. + * + * @param {bytes=} queryOptions.transactionId - A transaction ID. + * @private + * @returns {stream} A stream of document results. + */ + _stream(queryOptions) { + const request = this.toProto(queryOptions); + const tag = util_1.requestTag(); + const self = this; + const stream = through2_1.default.obj(function (proto, enc, callback) { + const readTime = timestamp_1.Timestamp.fromProto(proto.readTime); + if (proto.document) { + let document = self.firestore.snapshot_(proto.document, proto.readTime); + this.push({ document, readTime }); + } + else { + this.push({ readTime }); + } + callback(); + }); + this._firestore.readStream('runQuery', request, tag, true) + .then(backendStream => { + backendStream.on('error', err => { + logger_1.logger('Query._stream', tag, 'Query failed with stream error:', err); + stream.destroy(err); + }); + backendStream.resume(); + backendStream.pipe(stream); + }) + .catch(err => { + stream.destroy(err); + }); + return stream; + } + /** + * Attaches a listener for QuerySnapshot events. + * + * @param {querySnapshotCallback} onNext - A callback to be called every time + * a new [QuerySnapshot]{@link QuerySnapshot} is available. + * @param {errorCallback=} onError - A callback to be called if the listen + * fails or is cancelled. No further callbacks will occur. + * + * @returns {function()} An unsubscribe function that can be called to cancel + * the snapshot listener. + * + * @example + * let query = firestore.collection('col').where('foo', '==', 'bar'); + * + * let unsubscribe = query.onSnapshot(querySnapshot => { + * console.log(`Received query snapshot of size ${querySnapshot.size}`); + * }, err => { + * console.log(`Encountered error: ${err}`); + * }); + * + * // Remove this listener. + * unsubscribe(); + */ + onSnapshot(onNext, onError) { + this._validator.isFunction('onNext', onNext); + this._validator.isOptionalFunction('onError', onError); + if (!is_1.default.defined(onError)) { + onError = console.error; + } + let watch = watch_1.Watch.forQuery(this); + return watch.onSnapshot((readTime, size, docs, changes) => { + onNext(new QuerySnapshot(this, readTime, size, docs, changes)); + }, onError); + } + /** + * Returns a function that can be used to sort QueryDocumentSnapshots + * according to the sort criteria of this query. + * + * @private + */ + comparator() { + return (doc1, doc2) => { + // Add implicit sorting by name, using the last specified direction. + let lastDirection = this._fieldOrders.length === 0 ? + directionOperators.ASC : + this._fieldOrders[this._fieldOrders.length - 1].direction; + let orderBys = this._fieldOrders.concat(new FieldOrder(path_1.FieldPath._DOCUMENT_ID, lastDirection)); + for (let orderBy of orderBys) { + let comp; + if (path_1.FieldPath._DOCUMENT_ID.isEqual(orderBy.field)) { + comp = doc1.ref._referencePath.compareTo(doc2.ref._referencePath); + } + else { + const v1 = doc1.protoField(orderBy.field); + const v2 = doc2.protoField(orderBy.field); + if (!is_1.default.defined(v1) || !is_1.default.defined(v2)) { + throw new Error('Trying to compare documents on fields that ' + + 'don\'t exist. Please include the fields you are ordering on ' + + 'in your select() call.'); + } + comp = order_1.compare(v1, v2); + } + if (comp !== 0) { + const direction = orderBy.direction === directionOperators.ASC ? 1 : -1; + return direction * comp; + } + } + return 0; + }; + } +} +exports.Query = Query; +/** + * A CollectionReference object can be used for adding documents, getting + * document references, and querying for documents (using the methods + * inherited from [Query]{@link Query}). + * + * @class + * @extends Query + */ +class CollectionReference extends Query { + /** + * @private + * @hideconstructor + * + * @param {Firestore} firestore - The Firestore Database client. + * @param {ResourcePath} path - The Path of this collection. + */ + constructor(firestore, path) { + super(firestore, path); + } + /** + * The last path element of the referenced collection. + * + * @type {string} + * @name CollectionReference#id + * @readonly + * + * @example + * let collectionRef = firestore.collection('col/doc/subcollection'); + * console.log(`ID of the subcollection: ${collectionRef.id}`); + */ + get id() { + return this._referencePath.id; + } + /** + * A reference to the containing Document if this is a subcollection, else + * null. + * + * @type {DocumentReference} + * @name CollectionReference#parent + * @readonly + * + * @example + * let collectionRef = firestore.collection('col/doc/subcollection'); + * let documentRef = collectionRef.parent; + * console.log(`Parent name: ${documentRef.path}`); + */ + get parent() { + return new DocumentReference(this._firestore, this._referencePath.parent()); + } + /** + * A string representing the path of the referenced collection (relative + * to the root of the database). + * + * @type {string} + * @name CollectionReference#path + * @readonly + * + * @example + * let collectionRef = firestore.collection('col/doc/subcollection'); + * console.log(`Path of the subcollection: ${collectionRef.path}`); + */ + get path() { + return this._referencePath.relativeName; + } + /** + * Gets a [DocumentReference]{@link DocumentReference} instance that + * refers to the document at the specified path. If no path is specified, an + * automatically-generated unique ID will be used for the returned + * DocumentReference. + * + * @param {string=} documentPath - A slash-separated path to a document. + * @returns {DocumentReference} The `DocumentReference` + * instance. + * + * @example + * let collectionRef = firestore.collection('col'); + * let documentRefWithName = collectionRef.doc('doc'); + * let documentRefWithAutoId = collectionRef.doc(); + * console.log(`Reference with name: ${documentRefWithName.path}`); + * console.log(`Reference with auto-id: ${documentRefWithAutoId.path}`); + */ + doc(documentPath) { + if (arguments.length === 0) { + documentPath = util_1.autoId(); + } + else { + this._validator.isResourcePath('documentPath', documentPath); + } + let path = this._referencePath.append(documentPath); + if (!path.isDocument) { + throw new Error(`Argument "documentPath" must point to a document, but was "${documentPath}". Your path does not contain an even number of components.`); + } + return new DocumentReference(this._firestore, path); + } + /** + * Add a new document to this collection with the specified data, assigning + * it a document ID automatically. + * + * @param {DocumentData} data - An Object containing the data for the new + * document. + * @returns {Promise.} A Promise resolved with a + * [DocumentReference]{@link DocumentReference} pointing to the + * newly created document. + * + * @example + * let collectionRef = firestore.collection('col'); + * collectionRef.add({foo: 'bar'}).then(documentReference => { + * console.log(`Added document with name: ${documentReference.id}`); + * }); + */ + add(data) { + this._validator.isDocument('data', data, { + allowEmpty: true, + allowDeletes: 'none', + allowTransforms: true, + }); + let documentRef = this.doc(); + return documentRef.create(data).then(() => { + return Promise.resolve(documentRef); + }); + } + /** + * Returns true if this `CollectionReference` is equal to the provided value. + * + * @param {*} other The value to compare against. + * @return {boolean} true if this `CollectionReference` is equal to the + * provided value. + */ + isEqual(other) { + return (this === other || + (is_1.default.instanceof(other, CollectionReference) && super.isEqual(other))); + } +} +exports.CollectionReference = CollectionReference; +/*! + * Creates a new CollectionReference. Invoked by DocumentReference to avoid + * invalid declaration order. + * + * @param {Firestore} firestore - The Firestore Database client. + * @param {ResourcePath} path - The path of this collection. + * @returns {CollectionReference} + */ +function createCollectionReference(firestore, path) { + return new CollectionReference(firestore, path); +} +/*! + * Validates the input string as a field order direction. + * + * @param {string=} str Order direction to validate. + * @throws {Error} when the direction is invalid + */ +function validateFieldOrder(str) { + if (!is_1.default.string(str) || !is_1.default.defined(directionOperators[str])) { + throw new Error('Order must be one of "asc" or "desc".'); + } + return true; +} +exports.validateFieldOrder = validateFieldOrder; +/*! + * Validates the input string as a field comparison operator. + * + * @param {string} str Field comparison operator to validate. + * @param {*} val Value that is used in the filter. + * @throws {Error} when the comparison operation is invalid + */ +function validateComparisonOperator(str, val) { + if (is_1.default.string(str) && comparisonOperators[str]) { + let op = comparisonOperators[str]; + if (typeof val === 'number' && isNaN(val) && op !== 'EQUAL') { + throw new Error('Invalid query. You can only perform equals comparisons on NaN.'); + } + if (val === null && op !== 'EQUAL') { + throw new Error('Invalid query. You can only perform equals comparisons on Null.'); + } + return true; + } + throw new Error('Operator must be one of "<", "<=", "==", ">", or ">=".'); +} +exports.validateComparisonOperator = validateComparisonOperator; +/*! + * Validates that 'value' is a DocumentReference. + * + * @param {*} value The argument to validate. + * @returns 'true' is value is an instance of DocumentReference. + */ +function validateDocumentReference(value) { + if (is_1.default.instanceof(value, DocumentReference)) { + return true; + } + throw validate_1.customObjectError(value); +} +exports.validateDocumentReference = validateDocumentReference; +/** + * Verifies euqality for an array of objects using the `isEqual` interface. + * + * @private + * @param {Array.} left Array of objects supporting `isEqual`. + * @param {Array.} right Array of objects supporting `isEqual`. + * @return {boolean} True if arrays are equal. + */ +function isArrayEqual(left, right) { + if (left.length !== right.length) { + return false; + } + for (let i = 0; i < left.length; ++i) { + if (!left[i].isEqual(right[i])) { + return false; + } + } + return true; +} diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/serializer.js b/website/functions/node_modules/@google-cloud/firestore/build/src/serializer.js new file mode 100644 index 00000000..d4942477 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/serializer.js @@ -0,0 +1,228 @@ +/*! + * Copyright 2018 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. + */ +'use strict'; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const is_1 = __importDefault(require("is")); +const firestore_proto_api_1 = require("../protos/firestore_proto_api"); +const timestamp_1 = require("./timestamp"); +const field_value_1 = require("./field-value"); +const validate_1 = require("./validate"); +const path_1 = require("./path"); +const convert_1 = require("./convert"); +const geo_point_1 = require("./geo-point"); +/** + * Serializer that is used to convert between JavaScripts types and their + * Firestore Protobuf representation. + * + * @private + */ +class Serializer { + constructor(firestore, timestampsInSnapshotsEnabled) { + this.timestampsInSnapshotsEnabled = timestampsInSnapshotsEnabled; + // 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); + } + /** + * Encodes a JavaScrip object into the Firestore 'Fields' representation. + * + * @private + * @param obj The object to encode. + * @returns The Firestore 'Fields' representation + */ + encodeFields(obj) { + const fields = {}; + for (const prop in obj) { + if (obj.hasOwnProperty(prop)) { + const val = this.encodeValue(obj[prop]); + if (val) { + fields[prop] = val; + } + } + } + return fields; + } + /** + * Encodes a JavaScript value into the Firestore 'Value' representation. + * + * @private + * @param val The object to encode + * @returns The Firestore Proto or null if we are deleting a field. + */ + encodeValue(val) { + if (val instanceof field_value_1.FieldTransform) { + return null; + } + if (is_1.default.string(val)) { + return { + stringValue: val, + }; + } + if (is_1.default.bool(val)) { + return { + booleanValue: val, + }; + } + if (is_1.default.integer(val)) { + return { + integerValue: val, + }; + } + // Integers are handled above, the remaining numbers are treated as doubles + if (is_1.default.number(val)) { + return { + doubleValue: val, + }; + } + if (is_1.default.date(val)) { + const timestamp = timestamp_1.Timestamp.fromDate(val); + return { + timestampValue: { + seconds: timestamp.seconds, + nanos: timestamp.nanoseconds, + }, + }; + } + if (val === null) { + return { + nullValue: firestore_proto_api_1.google.protobuf.NullValue.NULL_VALUE, + }; + } + if (val instanceof Buffer || val instanceof Uint8Array) { + return { + bytesValue: val, + }; + } + if (typeof val === 'object' && 'toProto' in val && + typeof val.toProto === 'function') { + return val.toProto(); + } + if (val instanceof Array) { + const array = { + arrayValue: {}, + }; + if (val.length > 0) { + array.arrayValue.values = []; + for (let i = 0; i < val.length; ++i) { + const enc = this.encodeValue(val[i]); + if (enc) { + array.arrayValue.values.push(enc); + } + } + } + return array; + } + if (typeof val === 'object' && isPlainObject(val)) { + const map = { + mapValue: {}, + }; + // If we encounter an empty object, we always need to send it to make sure + // the server creates a map entry. + if (!is_1.default.empty(val)) { + map.mapValue.fields = this.encodeFields(val); + if (is_1.default.empty(map.mapValue.fields)) { + return null; + } + } + return map; + } + throw validate_1.customObjectError(val); + } + /** + * Decodes a single Firestore 'Value' Protobuf. + * + * @private + * @param proto - A Firestore 'Value' Protobuf. + * @returns The converted JS type. + */ + decodeValue(proto) { + const valueType = convert_1.detectValueType(proto); + switch (valueType) { + case 'stringValue': { + return proto.stringValue; + } + case 'booleanValue': { + return proto.booleanValue; + } + case 'integerValue': { + return Number(proto.integerValue); + } + case 'doubleValue': { + return Number(proto.doubleValue); + } + case 'timestampValue': { + const timestamp = timestamp_1.Timestamp.fromProto(proto.timestampValue); + return this.timestampsInSnapshotsEnabled ? timestamp : + timestamp.toDate(); + } + case 'referenceValue': { + const resourcePath = path_1.ResourcePath.fromSlashSeparatedString(proto.referenceValue); + return this.createReference(resourcePath.relativeName); + } + case 'arrayValue': { + const array = []; + if (is_1.default.array(proto.arrayValue.values)) { + for (const value of proto.arrayValue.values) { + array.push(this.decodeValue(value)); + } + } + return array; + } + case 'nullValue': { + return null; + } + case 'mapValue': { + const obj = {}; + const fields = proto.mapValue.fields; + for (const prop in fields) { + if (fields.hasOwnProperty(prop)) { + obj[prop] = this.decodeValue(fields[prop]); + } + } + return obj; + } + case 'geoPointValue': { + return geo_point_1.GeoPoint.fromProto(proto.geoPointValue); + } + case 'bytesValue': { + return proto.bytesValue; + } + default: { + throw new Error('Cannot decode type from Firestore Value: ' + + JSON.stringify(proto)); + } + } + } +} +exports.Serializer = 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. + */ +function isPlainObject(input) { + return (typeof input === 'object' && input !== null && + (Object.getPrototypeOf(input) === Object.prototype || + Object.getPrototypeOf(input) === null)); +} +exports.isPlainObject = isPlainObject; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/timestamp.js b/website/functions/node_modules/@google-cloud/firestore/build/src/timestamp.js new file mode 100644 index 00000000..32cd7ab3 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/timestamp.js @@ -0,0 +1,225 @@ +/*! + * Copyright 2018 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. + */ +'use strict'; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const is_1 = __importDefault(require("is")); +const validate_1 = require("./validate"); +const validate = validate_1.createValidator(); +/*! + * Number of nanoseconds in a millisecond. + * + * @type {number} + */ +const MS_TO_NANOS = 1000000; +/** + * A Timestamp represents a point in time independent of any time zone or + * calendar, represented as seconds and fractions of seconds at nanosecond + * resolution in UTC Epoch time. It is encoded using the Proleptic Gregorian + * Calendar which extends the Gregorian calendar backwards to year one. It is + * encoded assuming all minutes are 60 seconds long, i.e. leap seconds are + * "smeared" so that no leap second table is needed for interpretation. Range is + * from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. + * + * @see https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto + */ +class Timestamp { + /** + * Creates a new timestamp with the current date, with millisecond precision. + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * documentRef.set({ updateTime:Firestore.Timestamp.now() }); + * + * @return {Timestamp} A new `Timestamp` representing the current date. + */ + static now() { + return Timestamp.fromMillis(Date.now()); + } + /** + * Creates a new timestamp from the given date. + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * let date = Date.parse('01 Jan 2000 00:00:00 GMT'); + * documentRef.set({ startTime:Firestore.Timestamp.fromDate(date) }); + * + * @param {Date} date The date to initialize the `Timestamp` from. + * @return {Timestamp} A new `Timestamp` representing the same point in time + * as the given date. + */ + static fromDate(date) { + return Timestamp.fromMillis(date.getTime()); + } + /** + * Creates a new timestamp from the given number of milliseconds. + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * documentRef.set({ startTime:Firestore.Timestamp.fromMillis(42) }); + * + * @param {number} milliseconds Number of milliseconds since Unix epoch + * 1970-01-01T00:00:00Z. + * @return {Timestamp} A new `Timestamp` representing the same point in time + * as the given number of milliseconds. + */ + static fromMillis(milliseconds) { + const seconds = Math.floor(milliseconds / 1000); + const nanos = (milliseconds - seconds * 1000) * MS_TO_NANOS; + return new Timestamp(seconds, nanos); + } + /** + * Generates a `Timestamp` object from a Timestamp proto. + * + * @private + * @param {Object} timestamp The `Timestamp` Protobuf object. + */ + static fromProto(timestamp) { + return new Timestamp(Number(timestamp.seconds || 0), Number(timestamp.nanos || 0)); + } + /** + * Creates a new timestamp. + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * documentRef.set({ startTime:new Firestore.Timestamp(42, 0) }); + * + * @param {number} seconds The number of 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. + * @param {number} nanoseconds The non-negative fractions of a second at + * nanosecond resolution. Negative second values with fractions must still + * have non-negative nanoseconds values that count forward in time. Must be + * from 0 to 999,999,999 inclusive. + */ + constructor(seconds, nanoseconds) { + validate.isInteger('seconds', seconds); + validate.isInteger('nanoseconds', nanoseconds, 0, 999999999); + this._seconds = seconds; + this._nanoseconds = nanoseconds; + } + /** + * The number of seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * documentRef.get().then(snap => { + * let updatedAt = snap.updateTime; + * console.log(`Updated at ${updated.seconds}s ${updated.nanoseconds}ns`); + * }); + * + * @type {number} + */ + get seconds() { + return this._seconds; + } + /** + * The non-negative fractions of a second at nanosecond resolution. + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * documentRef.get().then(snap => { + * let updated = snap.updateTime; + * console.log(`Updated at ${updated.seconds}s ${updated.nanoseconds}ns`); + * }); + * + * @type {number} + */ + get nanoseconds() { + return this._nanoseconds; + } + /** + * Returns a new `Date` corresponding to this timestamp. This may lose + * precision. + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * documentRef.get().then(snap => { + * console.log(`Document updated at: ${snap.updateTime.toDate()}`); + * }); + * + * @return {Date} JavaScript `Date` object representing the same point in time + * as this `Timestamp`, with millisecond precision. + */ + toDate() { + return new Date(this._seconds * 1000 + Math.round(this._nanoseconds / MS_TO_NANOS)); + } + /** + * Returns the number of milliseconds since Unix epoch 1970-01-01T00:00:00Z. + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * documentRef.get().then(snap => { + * let startTime = snap.get('startTime'); + * let endTime = snap.get('endTime'); + * console.log(`Duration: ${endTime - startTime}`); + * }); + * + * @return {number} The point in time corresponding to this timestamp, + * represented as the number of milliseconds since Unix epoch + * 1970-01-01T00:00:00Z. + */ + toMillis() { + return this._seconds * 1000 + Math.floor(this._nanoseconds / MS_TO_NANOS); + } + /** + * Returns 'true' if this `Timestamp` is equal to the provided one. + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * documentRef.get().then(snap => { + * if (snap.createTime.isEqual(snap.updateTime)) { + * console.log('Document is in its initial state.'); + * } + * }); + * + * @param {any} other The `Timestamp` to compare against. + * @return {boolean} 'true' if this `Timestamp` is equal to the provided one. + */ + isEqual(other) { + return (this === other || + (is_1.default.instanceof(other, Timestamp) && this._seconds === other.seconds && + this._nanoseconds === other.nanoseconds)); + } + /** + * Generates the Protobuf `Timestamp` object for this timestamp. + * + * @private + * @returns {Object} The `Timestamp` Protobuf object. + */ + toProto() { + const timestamp = {}; + if (this.seconds) { + timestamp.seconds = this.seconds; + } + if (this.nanoseconds) { + timestamp.nanos = this.nanoseconds; + } + return { timestampValue: timestamp }; + } +} +exports.Timestamp = Timestamp; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/transaction.js b/website/functions/node_modules/@google-cloud/firestore/build/src/transaction.js new file mode 100644 index 00000000..6e5cd8f9 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/transaction.js @@ -0,0 +1,311 @@ +/*! + * Copyright 2017 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. + */ +'use strict'; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const is_1 = __importDefault(require("is")); +const reference_1 = require("./reference"); +const util_1 = require("./util"); +/*! + * Error message for transactional reads that were executed after performing + * writes. + */ +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. + * + * The Transaction object passed to a transaction's updateFunction provides + * the methods to read and write data within the transaction context. See + * [runTransaction()]{@link Firestore#runTransaction}. + * + * @class + */ +class Transaction { + /** + * @private + * @hideconstructor + * + * @param {Firestore} firestore - The Firestore Database client. + * @param {Transaction=} previousTransaction - If + * available, the failed transaction that is being retried. + */ + constructor(firestore, previousTransaction) { + this._firestore = firestore; + this._validator = firestore._validator; + this._previousTransaction = previousTransaction; + this._writeBatch = firestore.batch(); + this._requestTag = + previousTransaction ? previousTransaction.requestTag : util_1.requestTag(); + } + /** + * Retrieve a document or a query result from the database. Holds a + * pessimistic lock on all returned documents. + * + * @param {DocumentReference|Query} refOrQuery - The + * document or query to return. + * @returns {Promise} A Promise that resolves with a DocumentSnapshot or + * QuerySnapshot for the returned documents. + * + * @example + * firestore.runTransaction(transaction => { + * let documentRef = firestore.doc('col/doc'); + * return transaction.get(documentRef).then(doc => { + * if (doc.exists) { + * transaction.update(documentRef, { count: doc.get('count') + 1 }); + * } else { + * transaction.create(documentRef, { count: 1 }); + * } + * }); + * }); + */ + get(refOrQuery) { + if (!this._writeBatch.isEmpty) { + throw new Error(READ_AFTER_WRITE_ERROR_MSG); + } + if (is_1.default.instance(refOrQuery, reference_1.DocumentReference)) { + return this._firestore + .getAll_([refOrQuery], this._requestTag, this._transactionId) + .then(res => { + return Promise.resolve(res[0]); + }); + } + if (is_1.default.instance(refOrQuery, reference_1.Query)) { + return refOrQuery._get({ transactionId: this._transactionId }); + } + throw new Error('Argument "refOrQuery" must be a DocumentRef or a Query.'); + } + /** + * Retrieves multiple documents from Firestore. Holds a pessimistic lock on + * all returned documents. + * + * @param {...DocumentReference} documents - The document references + * to receive. + * @returns {Promise>} A Promise that + * contains an array with the resulting document snapshots. + * + * @example + * let firstDoc = firestore.doc('col/doc1'); + * let secondDoc = firestore.doc('col/doc2'); + * let resultDoc = firestore.doc('col/doc3'); + * + * firestore.runTransaction(transaction => { + * return transaction.getAll(firstDoc, secondDoc).then(docs => { + * transaction.set(resultDoc, { + * sum: docs[1].get('count') + docs[2].get('count') + * }); + * }); + * }); + */ + getAll(documents) { + if (!this._writeBatch.isEmpty) { + throw new Error(READ_AFTER_WRITE_ERROR_MSG); + } + documents = is_1.default.array(arguments[0]) ? arguments[0].slice() : + Array.prototype.slice.call(arguments); + for (let i = 0; i < documents.length; ++i) { + this._validator.isDocumentReference(i, documents[i]); + } + return this._firestore.getAll_(documents, this._requestTag, this._transactionId); + } + /** + * Create the document referred to by the provided + * [DocumentReference]{@link DocumentReference}. The operation will + * fail the transaction if a document exists at the specified location. + * + * @param {DocumentReference} documentRef - A reference to the + * document to be created. + * @param {DocumentData} data - The object data to serialize as the document. + * @returns {Transaction} This Transaction instance. Used for + * chaining method calls. + * + * @example + * firestore.runTransaction(transaction => { + * let documentRef = firestore.doc('col/doc'); + * return transaction.get(documentRef).then(doc => { + * if (!doc.exists) { + * transaction.create(documentRef, { foo: 'bar' }); + * } + * }); + * }); + */ + create(documentRef, data) { + this._writeBatch.create(documentRef, data); + return this; + } + /** + * Writes to the document referred to by the provided + * [DocumentReference]{@link DocumentReference}. If the document + * does not exist yet, it will be created. If you pass + * [SetOptions]{@link SetOptions}, the provided data can be merged into the + * existing document. + * + * @param {DocumentReference} documentRef - A reference to the + * document to be set. + * @param {DocumentData} 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 {Transaction} This Transaction instance. Used for + * chaining method calls. + * + * @example + * firestore.runTransaction(transaction => { + * let documentRef = firestore.doc('col/doc'); + * transaction.set(documentRef, { foo: 'bar' }); + * return Promise.resolve(); + * }); + */ + set(documentRef, data, options) { + this._writeBatch.set(documentRef, data, options); + return this; + } + /** + * Updates fields in the document referred to by the provided + * [DocumentReference]{@link DocumentReference}. The update will + * fail if applied to a document that does not exist. + * + * 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 to enforce on this update. + * @returns {Transaction} This Transaction instance. Used for + * chaining method calls. + * + * @example + * firestore.runTransaction(transaction => { + * let documentRef = firestore.doc('col/doc'); + * return transaction.get(documentRef).then(doc => { + * if (doc.exists) { + * transaction.update(documentRef, { count: doc.get('count') + 1 }); + * } else { + * transaction.create(documentRef, { count: 1 }); + * } + * }); + * }); + */ + update(documentRef, dataOrField, preconditionOrValues) { + this._validator.minNumberOfArguments('update', arguments, 2); + preconditionOrValues = Array.prototype.slice.call(arguments, 2); + this._writeBatch.update.apply(this._writeBatch, [documentRef, dataOrField].concat(preconditionOrValues)); + return this; + } + /** + * Deletes the document referred to by the provided [DocumentReference] + * {@link DocumentReference}. + * + * @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 transaction if the + * document doesn't exist or was last updated at a different time. + * @returns {Transaction} This Transaction instance. Used for + * chaining method calls. + * + * @example + * firestore.runTransaction(transaction => { + * let documentRef = firestore.doc('col/doc'); + * transaction.delete(documentRef); + * return Promise.resolve(); + * }); + */ + delete(documentRef, precondition) { + this._writeBatch.delete(documentRef, precondition); + return this; + } + /** + * Starts a transaction and obtains the transaction id from the server. + * + * @private + * @returns {Promise} An empty Promise. + */ + begin() { + let request = { + database: this._firestore.formattedName, + }; + if (this._previousTransaction) { + request.options = { + readWrite: { + retryTransaction: this._previousTransaction._transactionId, + }, + }; + } + return this._firestore + .request('beginTransaction', request, this._requestTag, ALLOW_RETRIES) + .then(resp => { + this._transactionId = resp.transaction; + }); + } + /** + * Commits all queued-up changes in this transaction and releases all locks. + * + * @private + * @returns {Promise} An empty Promise. + */ + commit() { + return this._writeBatch.commit_({ + transactionId: this._transactionId, + requestTag: this._requestTag, + }); + } + /** + * Releases all locks and rolls back this transaction. + * + * @private + * @returns {Promise} An empty Promise. + */ + rollback() { + let request = { + database: this._firestore.formattedName, + transaction: this._transactionId, + }; + return this._firestore.request('rollback', request, this._requestTag); + } + /** + * Returns the tag to use with with all request for this Transaction. + * @private + * @return {string} A unique client-generated identifier for this transaction. + */ + get requestTag() { + return this._requestTag; + } +} +exports.Transaction = Transaction; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/types.js b/website/functions/node_modules/@google-cloud/firestore/build/src/types.js new file mode 100644 index 00000000..2e63de2a --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/types.js @@ -0,0 +1,17 @@ +/*! + * Copyright 2018 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. + */ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/util.js b/website/functions/node_modules/@google-cloud/firestore/build/src/util.js new file mode 100644 index 00000000..e4b5052c --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/util.js @@ -0,0 +1,46 @@ +/*! + * Copyright 2018 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. + */ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Generate a unique client-side identifier. + * + * Used for the creation of new documents. + * + * @private + * @returns {string} A unique 20-character wide identifier. + */ +function autoId() { + const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + let autoId = ''; + for (let i = 0; i < 20; i++) { + autoId += chars.charAt(Math.floor(Math.random() * chars.length)); + } + return autoId; +} +exports.autoId = autoId; +/** + * Generate a short and semi-random client-side identifier. + * + * Used for the creation of request tags. + * + * @private + * @returns {string} A random 5-character wide identifier. + */ +function requestTag() { + return autoId().substr(0, 5); +} +exports.requestTag = requestTag; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/firestore/v1beta1/doc_common.js b/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/firestore/v1beta1/doc_common.js new file mode 100644 index 00000000..2d2d760e --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/firestore/v1beta1/doc_common.js @@ -0,0 +1,107 @@ +"use strict"; +// 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. +// 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} + */ +var 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} + */ +var 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} + */ +var 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 {string} 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/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/firestore/v1beta1/doc_document.js b/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/firestore/v1beta1/doc_document.js new file mode 100644 index 00000000..2a9cde76 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/firestore/v1beta1/doc_document.js @@ -0,0 +1,183 @@ +"use strict"; +// 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. +// 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` or `_`. 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 initally 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} + */ +var 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 {string} 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 contain another array value. + * + * 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} + */ +var 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} + */ +var 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} + */ +var MapValue = { +// This is for documentation. Actual contents will be loaded by gRPC. +}; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/firestore/v1beta1/doc_firestore.js b/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/firestore/v1beta1/doc_firestore.js new file mode 100644 index 00000000..6e8a5010 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/firestore/v1beta1/doc_firestore.js @@ -0,0 +1,881 @@ +"use strict"; +// 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. +// 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 {string} 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} + */ +var 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 {string} 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} + */ +var 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} + */ +var 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} + */ +var 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} + */ +var 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} + */ +var 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 {string} 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} + */ +var 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 {string} 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} + */ +var 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} + */ +var BeginTransactionRequest = { +// This is for documentation. Actual contents will be loaded by gRPC. +}; +/** + * The response for Firestore.BeginTransaction. + * + * @property {string} 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} + */ +var 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 {string} 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} + */ +var 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} + */ +var 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 {string} 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} + */ +var 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 {string} 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} + */ +var RunQueryRequest = { +// This is for documentation. Actual contents will be loaded by gRPC. +}; +/** + * The response for Firestore.RunQuery. + * + * @property {string} 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} + */ +var 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 {string} 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} + */ +var 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 {string} 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} + */ +var 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} + */ +var 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} + */ +var 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 {string} 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 + * A client provided target ID. + * + * If not set, the server will assign an ID for the target. + * + * Used for resuming a target without changing IDs. The IDs can either be + * client-assigned or be server-assigned in a previous stream. All targets + * with client provided IDs must be added before adding a target that needs + * a server-assigned id. + * + * @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} + */ +var 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. + * + * For `target_change_type=ADD`, the order of the target IDs matches the order + * of the requests to add the targets. This allows clients to unambiguously + * associate server-assigned target IDs with added targets. + * + * For other states, 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 {string} 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} + */ +var 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} + */ +var 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} + */ +var ListCollectionIdsResponse = { +// This is for documentation. Actual contents will be loaded by gRPC. +}; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/firestore/v1beta1/doc_query.js b/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/firestore/v1beta1/doc_query.js new file mode 100644 index 00000000..881adcad --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/firestore/v1beta1/doc_query.js @@ -0,0 +1,379 @@ +"use strict"; +// 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. +// 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} + */ +var 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 + } + }, + /** + * 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 exprestion 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. + }, + /** + * 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. + }, + /** + * 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 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} + */ +var Cursor = { +// This is for documentation. Actual contents will be loaded by gRPC. +}; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/firestore/v1beta1/doc_write.js b/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/firestore/v1beta1/doc_write.js new file mode 100644 index 00000000..a7c85a1e --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/firestore/v1beta1/doc_write.js @@ -0,0 +1,262 @@ +"use strict"; +// 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. +// 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 tranformation 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`. + * 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. + * 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} + */ +var 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} + */ +var 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} + * + * @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} + */ +var 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} + */ +var 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} + */ +var 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} + */ +var 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} + */ +var ExistenceFilter = { +// This is for documentation. Actual contents will be loaded by gRPC. +}; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/protobuf/doc_any.js b/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/protobuf/doc_any.js new file mode 100644 index 00000000..6c1af084 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/protobuf/doc_any.js @@ -0,0 +1,130 @@ +"use strict"; +// 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. +// 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 whose content describes the type of the + * serialized protocol buffer message. + * + * For URLs which use the scheme `http`, `https`, or no scheme, the + * following restrictions and interpretations apply: + * + * * If no scheme is provided, `https` is assumed. + * * 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). + * * 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.) + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + * + * @property {string} 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} + */ +var Any = { +// This is for documentation. Actual contents will be loaded by gRPC. +}; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/protobuf/doc_empty.js b/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/protobuf/doc_empty.js new file mode 100644 index 00000000..0e293775 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/protobuf/doc_empty.js @@ -0,0 +1,33 @@ +"use strict"; +// 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. +// 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} + */ +var Empty = { +// This is for documentation. Actual contents will be loaded by gRPC. +}; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/protobuf/doc_timestamp.js b/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/protobuf/doc_timestamp.js new file mode 100644 index 00000000..ec7a9559 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/protobuf/doc_timestamp.js @@ -0,0 +1,115 @@ +"use strict"; +// 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. +// 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 calendar, represented as seconds and fractions of seconds at + * nanosecond resolution in UTC Epoch time. It is encoded using the + * Proleptic Gregorian Calendar which extends the Gregorian calendar + * backwards to year one. It is encoded assuming all minutes are 60 + * seconds long, i.e. leap seconds are "smeared" so that no leap second + * table is needed for interpretation. 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 date strings. + * See + * [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt). + * + * # 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, though only UTC (as indicated by "Z") is presently supported. + * + * 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://cloud.google.com + * http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()) + * 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} + */ +var Timestamp = { +// This is for documentation. Actual contents will be loaded by gRPC. +}; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/protobuf/doc_wrappers.js b/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/protobuf/doc_wrappers.js new file mode 100644 index 00000000..a9125aa7 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/protobuf/doc_wrappers.js @@ -0,0 +1,151 @@ +"use strict"; +// 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. +// Note: this file is purely for documentation. Any contents are not expected +// to be loaded as the JS file. +/** + * Wrapper message for `double`. + * + * The JSON representation for `DoubleValue` is JSON number. + * + * @property {number} value + * The double value. + * + * @typedef DoubleValue + * @memberof google.protobuf + * @see [google.protobuf.DoubleValue definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/wrappers.proto} + */ +var DoubleValue = { +// This is for documentation. Actual contents will be loaded by gRPC. +}; +/** + * Wrapper message for `float`. + * + * The JSON representation for `FloatValue` is JSON number. + * + * @property {number} value + * The float value. + * + * @typedef FloatValue + * @memberof google.protobuf + * @see [google.protobuf.FloatValue definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/wrappers.proto} + */ +var FloatValue = { +// This is for documentation. Actual contents will be loaded by gRPC. +}; +/** + * Wrapper message for `int64`. + * + * The JSON representation for `Int64Value` is JSON string. + * + * @property {number} value + * The int64 value. + * + * @typedef Int64Value + * @memberof google.protobuf + * @see [google.protobuf.Int64Value definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/wrappers.proto} + */ +var Int64Value = { +// This is for documentation. Actual contents will be loaded by gRPC. +}; +/** + * Wrapper message for `uint64`. + * + * The JSON representation for `UInt64Value` is JSON string. + * + * @property {number} value + * The uint64 value. + * + * @typedef UInt64Value + * @memberof google.protobuf + * @see [google.protobuf.UInt64Value definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/wrappers.proto} + */ +var UInt64Value = { +// This is for documentation. Actual contents will be loaded by gRPC. +}; +/** + * 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} + */ +var Int32Value = { +// This is for documentation. Actual contents will be loaded by gRPC. +}; +/** + * Wrapper message for `uint32`. + * + * The JSON representation for `UInt32Value` is JSON number. + * + * @property {number} value + * The uint32 value. + * + * @typedef UInt32Value + * @memberof google.protobuf + * @see [google.protobuf.UInt32Value definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/wrappers.proto} + */ +var UInt32Value = { +// This is for documentation. Actual contents will be loaded by gRPC. +}; +/** + * Wrapper message for `bool`. + * + * The JSON representation for `BoolValue` is JSON `true` and `false`. + * + * @property {boolean} value + * The bool value. + * + * @typedef BoolValue + * @memberof google.protobuf + * @see [google.protobuf.BoolValue definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/wrappers.proto} + */ +var BoolValue = { +// This is for documentation. Actual contents will be loaded by gRPC. +}; +/** + * Wrapper message for `string`. + * + * The JSON representation for `StringValue` is JSON string. + * + * @property {string} value + * The string value. + * + * @typedef StringValue + * @memberof google.protobuf + * @see [google.protobuf.StringValue definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/wrappers.proto} + */ +var StringValue = { +// This is for documentation. Actual contents will be loaded by gRPC. +}; +/** + * Wrapper message for `bytes`. + * + * The JSON representation for `BytesValue` is JSON string. + * + * @property {string} value + * The bytes value. + * + * @typedef BytesValue + * @memberof google.protobuf + * @see [google.protobuf.BytesValue definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/wrappers.proto} + */ +var BytesValue = { +// This is for documentation. Actual contents will be loaded by gRPC. +}; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/rpc/doc_status.js b/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/rpc/doc_status.js new file mode 100644 index 00000000..239d7b77 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/doc/google/rpc/doc_status.js @@ -0,0 +1,92 @@ +"use strict"; +// 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. +// 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} + */ +var Status = { +// This is for documentation. Actual contents will be loaded by gRPC. +}; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/firestore_client.js b/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/firestore_client.js new file mode 100644 index 00000000..8d869406 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/firestore_client.js @@ -0,0 +1,1398 @@ +// 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. +'use strict'; +const gapicConfig = require('./firestore_client_config'); +const gax = require('google-gax'); +const merge = require('lodash.merge'); +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.servicePath] - The domain name of the + * API remote host. + */ + constructor(opts) { + this._descriptors = {}; + // Ensure that options include the service address and port. + opts = Object.assign({ + clientConfig: {}, + port: this.constructor.port, + servicePath: this.constructor.servicePath, + }, opts); + // Create a `gaxGrpc` object, with any grpc-specific options + // sent to the client. + opts.scopes = this.constructor.scopes; + var gaxGrpc = new gax.GrpcClient(opts); + // Save the auth object to the client, for use by other methods. + this.auth = gaxGrpc.auth; + // Determine the client header string. + var clientHeader = [ + `gl-node/${process.version}`, + `grpc/${gaxGrpc.grpcVersion}`, + `gax/${gax.version}`, + `gapic/${VERSION}`, + ]; + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + var protos = merge({}, gaxGrpc.loadProto(path.join(__dirname, '..', '..', 'protos'), 'google/firestore/v1beta1/firestore.proto')); + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this._pathTemplates = { + databaseRootPathTemplate: new gax.PathTemplate('projects/{project}/databases/{database}'), + documentRootPathTemplate: new gax.PathTemplate('projects/{project}/databases/{database}/documents'), + documentPathPathTemplate: new gax.PathTemplate('projects/{project}/databases/{database}/documents/{document_path=**}'), + anyPathPathTemplate: new gax.PathTemplate('projects/{project}/databases/{database}/documents/{document}/{any_path=**}'), + }; + // 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 gax.PageDescriptor('pageToken', 'nextPageToken', 'documents'), + listCollectionIds: new gax.PageDescriptor('pageToken', 'nextPageToken', 'collectionIds'), + }; + // Some of the methods on this service provide streaming responses. + // Provide descriptors for these. + this._descriptors.stream = { + batchGetDocuments: new gax.StreamDescriptor(gax.StreamType.SERVER_STREAMING), + runQuery: new gax.StreamDescriptor(gax.StreamType.SERVER_STREAMING), + write: new gax.StreamDescriptor(gax.StreamType.BIDI_STREAMING), + listen: new gax.StreamDescriptor(gax.StreamType.BIDI_STREAMING), + }; + // Put together the default options sent with requests. + var 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. + var firestoreStub = gaxGrpc.createStub(protos.google.firestore.v1beta1.Firestore, opts); + // Iterate over each of the methods that the service provides + // and create an API call method for each. + var firestoreStubMethods = [ + 'getDocument', + 'listDocuments', + 'createDocument', + 'updateDocument', + 'deleteDocument', + 'batchGetDocuments', + 'beginTransaction', + 'commit', + 'rollback', + 'runQuery', + 'write', + 'listen', + 'listCollectionIds', + ]; + for (let methodName of firestoreStubMethods) { + this._innerApiCalls[methodName] = gax.createApiCall(firestoreStub.then(stub => function () { + var args = Array.prototype.slice.call(arguments, 0); + return stub[methodName].apply(stub, args); + }), 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 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 {string} [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/global.html#CallOptions} 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('firestore.v1beta1'); + * + * var client = new firestore.v1beta1.FirestoreClient({ + * // optional auth parameters. + * }); + * + * var formattedName = client.anyPathPath('[PROJECT]', '[DATABASE]', + * '[DOCUMENT]', '[ANY_PATH]'); client.getDocument({name: formattedName}) + * .then(responses => { + * var response = responses[0]; + * // doThingsWith(response) + * }) + * .catch(err => { + * console.error(err); + * }); + */ + getDocument(request, options, callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + options = options || {}; + 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 {string} [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/global.html#CallOptions} 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('firestore.v1beta1'); + * + * var client = new firestore.v1beta1.FirestoreClient({ + * // optional auth parameters. + * }); + * + * // Iterate over all elements. + * var formattedParent = client.anyPathPath('[PROJECT]', '[DATABASE]', + * '[DOCUMENT]', '[ANY_PATH]'); var collectionId = ''; var request = { parent: + * formattedParent, collectionId: collectionId, + * }; + * + * client.listDocuments(request) + * .then(responses => { + * var resources = responses[0]; + * for (let i = 0; i < resources.length; i += 1) { + * // doThingsWith(resources[i]) + * } + * }) + * .catch(err => { + * console.error(err); + * }); + * + * // Or obtain the paged response. + * var formattedParent = client.anyPathPath('[PROJECT]', '[DATABASE]', + * '[DOCUMENT]', '[ANY_PATH]'); var collectionId = ''; var request = { parent: + * formattedParent, collectionId: collectionId, + * }; + * + * + * var options = {autoPaginate: false}; + * var callback = responses => { + * // The actual resources in a response. + * var resources = responses[0]; + * // The next request if the response shows that there are more responses. + * var nextRequest = responses[1]; + * // The actual response object, if necessary. + * // var rawResponse = responses[2]; + * for (let i = 0; i < resources.length; i += 1) { + * // doThingsWith(resources[i]); + * } + * 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 = {}; + } + 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 {string} [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/global.html#CallOptions} 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('firestore.v1beta1'); + * + * var client = new firestore.v1beta1.FirestoreClient({ + * // optional auth parameters. + * }); + * + * var formattedParent = client.anyPathPath('[PROJECT]', '[DATABASE]', + * '[DOCUMENT]', '[ANY_PATH]'); var collectionId = ''; var 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/global.html#CallOptions} 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('firestore.v1beta1'); + * + * var client = new firestore.v1beta1.FirestoreClient({ + * // optional auth parameters. + * }); + * + * var formattedParent = client.anyPathPath('[PROJECT]', '[DATABASE]', + * '[DOCUMENT]', '[ANY_PATH]'); var collectionId = ''; var documentId = ''; + * var document = {}; + * var request = { + * parent: formattedParent, + * collectionId: collectionId, + * documentId: documentId, + * document: document, + * }; + * client.createDocument(request) + * .then(responses => { + * var response = responses[0]; + * // doThingsWith(response) + * }) + * .catch(err => { + * console.error(err); + * }); + */ + createDocument(request, options, callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + 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/global.html#CallOptions} 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('firestore.v1beta1'); + * + * var client = new firestore.v1beta1.FirestoreClient({ + * // optional auth parameters. + * }); + * + * var document = {}; + * var updateMask = {}; + * var request = { + * document: document, + * updateMask: updateMask, + * }; + * client.updateDocument(request) + * .then(responses => { + * var response = responses[0]; + * // doThingsWith(response) + * }) + * .catch(err => { + * console.error(err); + * }); + */ + updateDocument(request, options, callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + options = options || {}; + 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/global.html#CallOptions} 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('firestore.v1beta1'); + * + * var client = new firestore.v1beta1.FirestoreClient({ + * // optional auth parameters. + * }); + * + * var 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 = {}; + } + options = options || {}; + 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 {string} [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/global.html#CallOptions} for the + * details. + * @returns {Stream} + * An object stream which emits [BatchGetDocumentsResponse]{@link + * google.firestore.v1beta1.BatchGetDocumentsResponse} on 'data' event. + * + * @example + * + * const firestore = require('firestore.v1beta1'); + * + * var client = new firestore.v1beta1.FirestoreClient({ + * // optional auth parameters. + * }); + * + * var formattedDatabase = client.databaseRootPath('[PROJECT]', '[DATABASE]'); + * var documents = []; + * var request = { + * database: formattedDatabase, + * documents: documents, + * }; + * client.batchGetDocuments(request).on('data', response => { + * // doThingsWith(response) + * }); + */ + batchGetDocuments(request, options) { + options = options || {}; + 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/global.html#CallOptions} 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('firestore.v1beta1'); + * + * var client = new firestore.v1beta1.FirestoreClient({ + * // optional auth parameters. + * }); + * + * var formattedDatabase = client.databaseRootPath('[PROJECT]', '[DATABASE]'); + * client.beginTransaction({database: formattedDatabase}) + * .then(responses => { + * var response = responses[0]; + * // doThingsWith(response) + * }) + * .catch(err => { + * console.error(err); + * }); + */ + beginTransaction(request, options, callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + options = options || {}; + 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 {string} [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/global.html#CallOptions} 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('firestore.v1beta1'); + * + * var client = new firestore.v1beta1.FirestoreClient({ + * // optional auth parameters. + * }); + * + * var formattedDatabase = client.databaseRootPath('[PROJECT]', '[DATABASE]'); + * var writes = []; + * var request = { + * database: formattedDatabase, + * writes: writes, + * }; + * client.commit(request) + * .then(responses => { + * var response = responses[0]; + * // doThingsWith(response) + * }) + * .catch(err => { + * console.error(err); + * }); + */ + commit(request, options, callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + options = options || {}; + 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 {string} 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/global.html#CallOptions} 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('firestore.v1beta1'); + * + * var client = new firestore.v1beta1.FirestoreClient({ + * // optional auth parameters. + * }); + * + * var formattedDatabase = client.databaseRootPath('[PROJECT]', '[DATABASE]'); + * var transaction = ''; + * var 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 = {}; + } + options = options || {}; + 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 {string} [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/global.html#CallOptions} for the + * details. + * @returns {Stream} + * An object stream which emits [RunQueryResponse]{@link + * google.firestore.v1beta1.RunQueryResponse} on 'data' event. + * + * @example + * + * const firestore = require('firestore.v1beta1'); + * + * var client = new firestore.v1beta1.FirestoreClient({ + * // optional auth parameters. + * }); + * + * var formattedParent = client.anyPathPath('[PROJECT]', '[DATABASE]', + * '[DOCUMENT]', '[ANY_PATH]'); client.runQuery({parent: + * formattedParent}).on('data', response => { + * // doThingsWith(response) + * }); + */ + runQuery(request, options) { + options = options || {}; + 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/global.html#CallOptions} 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('firestore.v1beta1'); + * + * var client = new firestore.v1beta1.FirestoreClient({ + * // optional auth parameters. + * }); + * + * var stream = client.write().on('data', response => { + * // doThingsWith(response) + * }); + * var formattedDatabase = client.databaseRootPath('[PROJECT]', '[DATABASE]'); + * var 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/global.html#CallOptions} 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('firestore.v1beta1'); + * + * var client = new firestore.v1beta1.FirestoreClient({ + * // optional auth parameters. + * }); + * + * var stream = client.listen().on('data', response => { + * // doThingsWith(response) + * }); + * var formattedDatabase = client.databaseRootPath('[PROJECT]', '[DATABASE]'); + * var 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/global.html#CallOptions} 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('firestore.v1beta1'); + * + * var client = new firestore.v1beta1.FirestoreClient({ + * // optional auth parameters. + * }); + * + * // Iterate over all elements. + * var formattedParent = client.anyPathPath('[PROJECT]', '[DATABASE]', + * '[DOCUMENT]', '[ANY_PATH]'); + * + * client.listCollectionIds({parent: formattedParent}) + * .then(responses => { + * var resources = responses[0]; + * for (let i = 0; i < resources.length; i += 1) { + * // doThingsWith(resources[i]) + * } + * }) + * .catch(err => { + * console.error(err); + * }); + * + * // Or obtain the paged response. + * var formattedParent = client.anyPathPath('[PROJECT]', '[DATABASE]', + * '[DOCUMENT]', '[ANY_PATH]'); + * + * + * var options = {autoPaginate: false}; + * var callback = responses => { + * // The actual resources in a response. + * var resources = responses[0]; + * // The next request if the response shows that there are more responses. + * var nextRequest = responses[1]; + * // The actual response object, if necessary. + * // var rawResponse = responses[2]; + * for (let i = 0; i < resources.length; i += 1) { + * // doThingsWith(resources[i]); + * } + * 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 = {}; + } + options = options || {}; + 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/global.html#CallOptions} for the + * details. + * @returns {Stream} + * An object stream which emits a string on 'data' event. + * + * @example + * + * const firestore = require('firestore.v1beta1'); + * + * var client = new firestore.v1beta1.FirestoreClient({ + * // optional auth parameters. + * }); + * + * var 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 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_root resource name string. + * + * @param {String} project + * @param {String} database + * @returns {String} + */ + documentRootPath(project, database) { + return this._pathTemplates.documentRootPathTemplate.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 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, + }); + } + /** + * 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 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; + } + /** + * 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 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; + } +} +module.exports = FirestoreClient; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/firestore_client_config.json b/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/firestore_client_config.json new file mode 100644 index 00000000..53a379c2 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/firestore_client_config.json @@ -0,0 +1,100 @@ +{ + "interfaces": { + "google.firestore.v1beta1.Firestore": { + "retry_codes": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "non_idempotent": [] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 20000, + "rpc_timeout_multiplier": 1.0, + "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": 86400000, + "total_timeout_millis": 86400000 + } + }, + "methods": { + "GetDocument": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListDocuments": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "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", + "retry_params_name": "default" + }, + "DeleteDocument": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "BatchGetDocuments": { + "timeout_millis": 86400000, + "retry_codes_name": "idempotent", + "retry_params_name": "streaming" + }, + "BeginTransaction": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "Commit": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Rollback": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "RunQuery": { + "timeout_millis": 86400000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "Write": { + "timeout_millis": 300000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "streaming" + }, + "Listen": { + "timeout_millis": 86400000, + "retry_codes_name": "idempotent", + "retry_params_name": "streaming" + }, + "ListCollectionIds": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/index.js b/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/index.js new file mode 100644 index 00000000..b79e5885 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/v1beta1/index.js @@ -0,0 +1,29 @@ +/* + * Copyright 2017, 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. + */ +'use strict'; +var firestoreClient = require('./firestore_client'); +var gax = require('google-gax'); +var extend = require('extend'); +function v1beta1(options) { + options = extend({ + scopes: v1beta1.ALL_SCOPES, + }, options); + var gaxGrpc = new gax.GrpcClient(options); + return new firestoreClient(gaxGrpc); +} +v1beta1.SERVICE_ADDRESS = firestoreClient.SERVICE_ADDRESS; +v1beta1.ALL_SCOPES = firestoreClient.ALL_SCOPES; +module.exports = v1beta1; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/validate.js b/website/functions/node_modules/@google-cloud/firestore/build/src/validate.js new file mode 100644 index 00000000..97af36ee --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/validate.js @@ -0,0 +1,184 @@ +/*! + * Copyright 2017 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. + */ +'use strict'; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const is = __importStar(require("is")); +/** + * Formats the given word as plural conditionally given the preceding number. + * + * @private + */ +function formatPlural(num, str) { + return `${num} ${str}` + (num === 1 ? '' : 's'); +} +/** + * Provides argument validation for the Firestore Public API. Exposes validators + * for strings, integers, numbers, objects and functions by default and can be + * extended to provide custom validators. + * + * The exported validation functions follow the naming convention is{Type} and + * isOptional{Type}, such as "isString" and "isOptionalString". + * + * To register custom validators, invoke the constructor with with a mapping + * from type names to validation functions. Validation functions return 'true' + * for valid inputs and may throw errors with custom validation messages for + * easier diagnosis. + * + * @private + */ +class Validator { + /** + * Create a new Validator, optionally registering the custom validators as + * provided. + * + * @param customValidators A list of custom validators to register. + */ + constructor(customValidators) { + const validators = Object.assign({ + function: is.function, + integer: (value, min, max) => { + min = is.defined(min) ? min : -Infinity; + max = is.defined(max) ? max : Infinity; + if (!is.integer(value)) { + return false; + } + if (value < min || value > max) { + throw new Error(`Value must be within [${min}, ${max}] inclusive, but was: ${value}`); + } + return true; + }, + number: (value, min, max) => { + min = is.defined(min) ? min : -Infinity; + max = is.defined(max) ? max : Infinity; + if (!is.number(value) || is.nan(value)) { + return false; + } + if (value < min || value > max) { + throw new Error(`Value must be within [${min}, ${max}] inclusive, but was: ${value}`); + } + return true; + }, + object: is.object, + string: is.string, + boolean: is.boolean + }, customValidators); + const register = type => { + const camelCase = type.substring(0, 1).toUpperCase() + type.substring(1); + this[`is${camelCase}`] = (argumentName, ...values) => { + let valid = false; + let message = is.number(argumentName) ? + `Argument at index ${argumentName} is not a valid ${type}.` : + `Argument "${argumentName}" is not a valid ${type}.`; + try { + valid = validators[type].call(null, ...values); + } + catch (err) { + message += ` ${err.message}`; + } + if (valid !== true) { + throw new Error(message); + } + }; + this[`isOptional${camelCase}`] = function (argumentName, value) { + if (is.defined(value)) { + this[`is${camelCase}`].apply(null, arguments); + } + }; + }; + for (const type in validators) { + if (validators.hasOwnProperty(type)) { + register(type); + } + } + } + /** + * Verifies that 'args' has at least 'minSize' elements. + * + * @param {string} funcName - The function name to use in the error message. + * @param {Array.<*>} args - The array (or array-like structure) to verify. + * @param {number} minSize - The minimum number of elements to enforce. + * @throws if the expectation is not met. + * @returns {boolean} 'true' when the minimum number of elements is available. + */ + minNumberOfArguments(funcName, args, minSize) { + if (args.length < minSize) { + throw new Error(`Function '${funcName}()' requires at least ` + + `${formatPlural(minSize, 'argument')}.`); + } + return true; + } + /** + * Verifies that 'args' has at most 'maxSize' elements. + * + * @param {string} funcName - The function name to use in the error message. + * @param {Array.<*>} args - The array (or array-like structure) to verify. + * @param {number} maxSize - The maximum number of elements to enforce. + * @throws if the expectation is not met. + * @returns {boolean} 'true' when only the maximum number of elements is + * specified. + */ + maxNumberOfArguments(funcName, args, maxSize) { + if (args.length > maxSize) { + throw new Error(`Function '${funcName}()' accepts at most ` + + `${formatPlural(maxSize, 'argument')}.`); + } + return true; + } +} +exports.Validator = Validator; +function customObjectError(val) { + if (is.object(val) && val.constructor.name !== 'Object') { + const typeName = val.constructor.name; + switch (typeName) { + case 'DocumentReference': + case 'FieldPath': + case 'FieldValue': + case 'GeoPoint': + case 'Timestamp': + return new Error(`Detected an object of type "${typeName}" that doesn't match the ` + + 'expected instance. Please ensure that the Firestore types you ' + + 'are using are from the same NPM package.'); + default: + return new Error(`Couldn't serialize object of type "${typeName}". Firestore ` + + 'doesn\'t support JavaScript objects with custom prototypes ' + + '(i.e. objects that were created via the \'new\' operator).'); + } + } + else { + return new Error(`Invalid use of type "${typeof val}" as a Firestore argument.`); + } +} +exports.customObjectError = customObjectError; +/** + * Create a new Validator, optionally registering the custom validators as + * provided. + * + * @private + * @param customValidators A list of custom validators to register. + */ +function createValidator(customValidators) { + // This function exists to change the type of `Validator` to `any` so that + // consumers can call the custom validator functions. + return new Validator(customValidators); +} +exports.createValidator = createValidator; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/watch.js b/website/functions/node_modules/@google-cloud/firestore/build/src/watch.js new file mode 100644 index 00000000..df243861 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/watch.js @@ -0,0 +1,664 @@ +/*! + * Copyright 2017 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. + */ +'use strict'; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const assert_1 = __importDefault(require("assert")); +const functional_red_black_tree_1 = __importDefault(require("functional-red-black-tree")); +const through2_1 = __importDefault(require("through2")); +const logger_1 = require("./logger"); +const backoff_1 = require("./backoff"); +const timestamp_1 = require("./timestamp"); +const path_1 = require("./path"); +const util_1 = require("./util"); +const document_1 = require("./document"); +const document_change_1 = require("./document-change"); +/*! + * Target ID used by watch. Watch uses a fixed target id since we only support + * one target per stream. + * + * @private + * @type {number} + */ +const WATCH_TARGET_ID = 0x1; +/*! + * The change type for document change events. + */ +const ChangeType = { + added: 'added', + modified: 'modified', + 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 = { + // 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). + */ +const DOCUMENT_WATCH_COMPARATOR = (doc1, doc2) => { + assert_1.default(doc1 === doc2, 'Document watches only support one document.'); + return 0; +}; +/** + * @private + * @callback docsCallback + * @returns {Array.} An ordered list of documents. + */ +/** + * @private + * @callback changeCallback + * @returns {Array.} An ordered list of document + * changes. + */ +/** + * onSnapshot() callback that receives the updated query state. + * + * @private + * @callback watchSnapshotCallback + * + * @param {Timestamp} readTime - The time at which this snapshot was obtained. + * @param {number} size - The number of documents in the result set. + * @param {docsCallback} docs - A callback that returns the ordered list of + * documents stored in this snapshot. + * @param {changeCallback} changes - A callback that returns the list of + * changed documents since the last snapshot delivered for this watch. + */ +/** + * Watch provides listen functionality and exposes the 'onSnapshot' observer. It + * can be used with a valid Firestore Listen target. + * + * @class + * @private + */ +class Watch { + /** + * @private + * @hideconstructor + * + * @param {Firestore} firestore The Firestore Database client. + * @param {Object} target - A Firestore 'Target' proto denoting the target to + * listen on. + * @param {function} comparator - A comparator for QueryDocumentSnapshots that + * is used to order the document snapshots returned by this watch. + */ + constructor(firestore, target, comparator) { + this._firestore = firestore; + this._targets = target; + this._comparator = comparator; + this._backoff = new backoff_1.ExponentialBackoff(); + this._requestTag = util_1.requestTag(); + } + /** + * Creates a new Watch instance to listen on DocumentReferences. + * + * @private + * @param {DocumentReference} documentRef - The document + * reference for this watch. + * @returns {Watch} A newly created Watch instance. + */ + static forDocument(documentRef) { + return new Watch(documentRef.firestore, { + documents: { + documents: [documentRef.formattedName], + }, + targetId: WATCH_TARGET_ID, + }, DOCUMENT_WATCH_COMPARATOR); + } + /** + * Creates a new Watch instance to listen on Queries. + * + * @private + * @param {Query} query - The query used for this watch. + * @returns {Watch} A newly created Watch instance. + */ + static forQuery(query) { + return new Watch(query.firestore, { + query: query.toProto(), + targetId: WATCH_TARGET_ID, + }, query.comparator()); + } + /** + * Determines whether an 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. + * + * @private + * @param {Error} error An error object. + * @return {boolean} Whether the error is permanent. + */ + isPermanentError(error) { + if (error.code === undefined) { + logger_1.logger('Watch.onSnapshot', this._requestTag, 'Unable to determine error code: ', error); + return false; + } + switch (error.code) { + 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: + return false; + default: + return true; + } + } + /** + * Determines whether we need to initiate a longer backoff due to system + * overload. + * + * @private + * @param {Error} error A GRPC Error object that exposes an error code. + * @return {boolean} Whether we need to back off our retries. + */ + isResourceExhaustedError(error) { + return error.code === GRPC_STATUS_CODE.RESOURCE_EXHAUSTED; + } + /** + * Starts a watch and attaches a listener for document change events. + * + * @private + * @param {watchSnapshotCallback} onNext - A callback to be called every time + * a new snapshot is available. + * @param {function(Error)} onError - A callback to be called if the listen + * fails or is cancelled. No further callbacks will occur. + * + * @returns {function()} An unsubscribe function that can be called to cancel + * the snapshot listener. + */ + onSnapshot(onNext, onError) { + let self = this; + // The sorted tree of QueryDocumentSnapshots as sent in the last snapshot. + // We only look at the keys. + let docTree = functional_red_black_tree_1.default(this._comparator); + // A map of document names to QueryDocumentSnapshots for the last sent + // snapshot. + let docMap = new Map(); + // The accumulates map of document changes (keyed by document name) for the + // current snapshot. + let changeMap = new Map(); + // The current state of the query results. + let current = false; + // We need this to track whether we've pushed an initial set of changes, + // since we should push those even when there are no changes, if there \ + // aren't docs. + let hasPushed = false; + // The server assigns and updates the resume token. + let resumeToken = undefined; + // Indicates whether we are interested in data from the stream. Set to false + // in the 'unsubscribe()' callback. + let isActive = true; + // Sentinel value for a document remove. + const REMOVED = {}; + const request = { + database: this._firestore.formattedName, + addTarget: this._targets, + }; + // We may need to replace the underlying stream on reset events. + // This is the one that will be returned and proxy the current one. + const stream = through2_1.default.obj(); + // The current stream to the backend. + let currentStream = null; + /** Helper to clear the docs on RESET or filter mismatch. */ + const resetDocs = function () { + logger_1.logger('Watch.onSnapshot', self._requestTag, 'Resetting documents'); + changeMap.clear(); + resumeToken = undefined; + docTree.forEach(snapshot => { + // Mark each document as deleted. If documents are not deleted, they + // will be send again by the server. + changeMap.set(snapshot.ref.formattedName, REMOVED); + }); + current = false; + }; + /** Closes the stream and calls onError() if the stream is still active. */ + const closeStream = function (err) { + if (currentStream) { + currentStream.unpipe(stream); + currentStream.end(); + currentStream = null; + } + stream.end(); + if (isActive) { + isActive = false; + logger_1.logger('Watch.onSnapshot', self._requestTag, 'Invoking onError: ', err); + onError(err); + } + }; + /** + * Re-opens the stream unless the specified error is considered permanent. + * Clears the change map. + */ + const maybeReopenStream = function (err) { + if (isActive && !self.isPermanentError(err)) { + logger_1.logger('Watch.onSnapshot', self._requestTag, 'Stream ended, re-opening after retryable error: ', err); + request.addTarget.resumeToken = resumeToken; + changeMap.clear(); + if (self.isResourceExhaustedError(err)) { + self._backoff.resetToMax(); + } + resetStream(); + } + else { + closeStream(err); + } + }; + /** Helper to restart the outgoing stream to the backend. */ + const resetStream = function () { + logger_1.logger('Watch.onSnapshot', self._requestTag, 'Opening new stream'); + if (currentStream) { + currentStream.unpipe(stream); + currentStream.end(); + currentStream = null; + initStream(); + } + }; + /** + * Initializes a new stream to the backend with backoff. + */ + const initStream = function () { + self._backoff.backoffAndWait().then(() => { + if (!isActive) { + logger_1.logger('Watch.onSnapshot', self._requestTag, 'Not initializing inactive stream'); + return; + } + // Note that we need to call the internal _listen API to pass additional + // header values in readWriteStream. + self._firestore + .readWriteStream('listen', request, self._requestTag, true) + .then(backendStream => { + if (!isActive) { + logger_1.logger('Watch.onSnapshot', self._requestTag, 'Closing inactive stream'); + backendStream.end(); + return; + } + logger_1.logger('Watch.onSnapshot', self._requestTag, 'Opened new stream'); + currentStream = backendStream; + currentStream.on('error', err => { + maybeReopenStream(err); + }); + currentStream.on('end', () => { + const err = new Error('Stream ended unexpectedly'); + err.code = GRPC_STATUS_CODE.UNKNOWN; + maybeReopenStream(err); + }); + currentStream.pipe(stream); + currentStream.resume(); + }) + .catch(closeStream); + }); + }; + /** + * Checks if the current target id is included in the list of target ids. + * If no targetIds are provided, returns true. + */ + const affectsTarget = function (targetIds, currentId) { + if (targetIds === undefined || targetIds.length === 0) { + return true; + } + for (let targetId of targetIds) { + if (targetId === currentId) { + return true; + } + } + return false; + }; + /** Splits up document changes into removals, additions, and updates. */ + const extractChanges = function (docMap, changes, readTime) { + let deletes = []; + let adds = []; + let updates = []; + changes.forEach((value, name) => { + if (value === REMOVED) { + if (docMap.has(name)) { + deletes.push(name); + } + } + else if (docMap.has(name)) { + value.readTime = readTime; + updates.push(value.build()); + } + else { + value.readTime = readTime; + adds.push(value.build()); + } + }); + return { deletes, adds, updates }; + }; + /** + * Applies the mutations in changeMap to both the document tree and the + * document lookup map. Modified docMap in-place and returns the updated + * state. + */ + const computeSnapshot = function (docTree, docMap, changes) { + let updatedTree = docTree; + let updatedMap = docMap; + assert_1.default(docTree.length === docMap.size, 'The document tree and document ' + + 'map should have the same number of entries.'); + /** + * Applies a document delete to the document tree and the document map. + * Returns the corresponding DocumentChange event. + */ + const deleteDoc = function (name) { + assert_1.default(updatedMap.has(name), 'Document to delete does not exist'); + let oldDocument = updatedMap.get(name); + let existing = updatedTree.find(oldDocument); + let oldIndex = existing.index; + updatedTree = existing.remove(); + updatedMap.delete(name); + return new document_change_1.DocumentChange(ChangeType.removed, oldDocument, oldIndex, -1); + }; + /** + * Applies a document add to the document tree and the document map. + * Returns the corresponding DocumentChange event. + */ + const addDoc = function (newDocument) { + let name = newDocument.ref.formattedName; + assert_1.default(!updatedMap.has(name), 'Document to add already exists'); + updatedTree = updatedTree.insert(newDocument, null); + let newIndex = updatedTree.find(newDocument).index; + updatedMap.set(name, newDocument); + return new document_change_1.DocumentChange(ChangeType.added, newDocument, -1, newIndex); + }; + /** + * Applies a document modification to the document tree and the document + * map. Returns the DocumentChange event for successful modifications. + */ + const modifyDoc = function (newDocument) { + let name = newDocument.ref.formattedName; + assert_1.default(updatedMap.has(name), 'Document to modify does not exist'); + let oldDocument = updatedMap.get(name); + if (!oldDocument.updateTime.isEqual(newDocument.updateTime)) { + let removeChange = deleteDoc(name); + let addChange = addDoc(newDocument); + return new document_change_1.DocumentChange(ChangeType.modified, newDocument, removeChange.oldIndex, addChange.newIndex); + } + return null; + }; + // Process the sorted changes in the order that is expected by our + // clients (removals, additions, and then modifications). We also need to + // sort the individual changes to assure that oldIndex/newIndex keep + // incrementing. + let appliedChanges = []; + changes.deletes.sort((name1, name2) => { + // Deletes are sorted based on the order of the existing document. + return self._comparator(updatedMap.get(name1), updatedMap.get(name2)); + }); + changes.deletes.forEach(name => { + let change = deleteDoc(name); + if (change) { + appliedChanges.push(change); + } + }); + changes.adds.sort(self._comparator); + changes.adds.forEach(snapshot => { + let change = addDoc(snapshot); + if (change) { + appliedChanges.push(change); + } + }); + changes.updates.sort(self._comparator); + changes.updates.forEach(snapshot => { + let change = modifyDoc(snapshot); + if (change) { + appliedChanges.push(change); + } + }); + assert_1.default(updatedTree.length === updatedMap.size, 'The update document ' + + 'tree and document map should have the same number of entries.'); + return { updatedTree, updatedMap, appliedChanges }; + }; + /** + * Assembles a new snapshot from the current set of changes and invokes the + * user's callback. Clears the current changes on completion. + */ + const push = function (readTime, nextResumeToken) { + let changes = extractChanges(docMap, changeMap, readTime); + let diff = computeSnapshot(docTree, docMap, changes); + if (!hasPushed || diff.appliedChanges.length > 0) { + logger_1.logger('Watch.onSnapshot', self._requestTag, 'Sending snapshot with %d changes and %d documents', diff.appliedChanges.length, diff.updatedTree.length); + onNext(readTime, diff.updatedTree.length, () => diff.updatedTree.keys, () => diff.appliedChanges); + hasPushed = true; + } + docTree = diff.updatedTree; + docMap = diff.updatedMap; + changeMap.clear(); + resumeToken = nextResumeToken; + }; + /** + * Returns the current count of all documents, including the changes from + * the current changeMap. + */ + const currentSize = function () { + let changes = extractChanges(docMap, changeMap); + return docMap.size + changes.adds.length - changes.deletes.length; + }; + initStream(); + stream + .on('data', proto => { + if (proto.targetChange) { + logger_1.logger('Watch.onSnapshot', self._requestTag, 'Processing target change'); + const change = proto.targetChange; + const noTargetIds = !change.targetIds || change.targetIds.length === 0; + if (change.targetChangeType === 'NO_CHANGE') { + if (noTargetIds && change.readTime && current) { + // This means everything is up-to-date, so emit the current + // set of docs as a snapshot, if there were changes. + push(timestamp_1.Timestamp.fromProto(change.readTime), change.resumeToken); + } + } + else if (change.targetChangeType === 'ADD') { + if (WATCH_TARGET_ID !== change.targetIds[0]) { + closeStream(Error('Unexpected target ID sent by server')); + } + } + else if (change.targetChangeType === 'REMOVE') { + let code = 13; + let message = 'internal error'; + if (change.cause) { + code = change.cause.code; + message = change.cause.message; + } + // @todo: Surface a .code property on the exception. + closeStream(new Error('Error ' + code + ': ' + message)); + } + else if (change.targetChangeType === 'RESET') { + // Whatever changes have happened so far no longer matter. + resetDocs(); + } + else if (change.targetChangeType === 'CURRENT') { + current = true; + } + else { + closeStream(new Error('Unknown target change type: ' + JSON.stringify(change))); + } + if (change.resumeToken && + affectsTarget(change.targetIds, WATCH_TARGET_ID)) { + this._backoff.reset(); + } + } + else if (proto.documentChange) { + logger_1.logger('Watch.onSnapshot', self._requestTag, 'Processing change event'); + // No other targetIds can show up here, but we still need to see + // if the targetId was in the added list or removed list. + const targetIds = proto.documentChange.targetIds || []; + const removedTargetIds = proto.documentChange.removedTargetIds || []; + let changed = false; + let removed = false; + for (let i = 0; i < targetIds.length; i++) { + if (targetIds[i] === WATCH_TARGET_ID) { + changed = true; + } + } + for (let i = 0; i < removedTargetIds.length; i++) { + if (removedTargetIds[i] === WATCH_TARGET_ID) { + removed = true; + } + } + const document = proto.documentChange.document; + const name = document.name; + if (changed) { + logger_1.logger('Watch.onSnapshot', self._requestTag, 'Received document change'); + const snapshot = new document_1.DocumentSnapshot.Builder(); + snapshot.ref = self._firestore.doc(path_1.ResourcePath.fromSlashSeparatedString(name).relativeName); + snapshot.fieldsProto = document.fields || {}; + snapshot.createTime = + timestamp_1.Timestamp.fromProto(document.createTime); + snapshot.updateTime = + timestamp_1.Timestamp.fromProto(document.updateTime); + changeMap.set(name, snapshot); + } + else if (removed) { + logger_1.logger('Watch.onSnapshot', self._requestTag, 'Received document remove'); + changeMap.set(name, REMOVED); + } + } + else if (proto.documentDelete || proto.documentRemove) { + logger_1.logger('Watch.onSnapshot', self._requestTag, 'Processing remove event'); + const name = (proto.documentDelete || proto.documentRemove).document; + changeMap.set(name, REMOVED); + } + else if (proto.filter) { + logger_1.logger('Watch.onSnapshot', self._requestTag, 'Processing filter update'); + if (proto.filter.count !== currentSize()) { + // We need to remove all the current results. + resetDocs(); + // The filter didn't match, so re-issue the query. + resetStream(); + } + } + else { + closeStream(new Error('Unknown listen response type: ' + JSON.stringify(proto))); + } + }) + .on('end', () => { + logger_1.logger('Watch.onSnapshot', self._requestTag, 'Processing stream end'); + if (currentStream) { + // Pass the event on to the underlying stream. + currentStream.end(); + } + }); + return () => { + logger_1.logger('Watch.onSnapshot', self._requestTag, 'Ending stream'); + // Prevent further callbacks. + isActive = false; + onNext = () => { }; + onError = () => { }; + stream.end(); + }; + } +} +exports.Watch = Watch; diff --git a/website/functions/node_modules/@google-cloud/firestore/build/src/write-batch.js b/website/functions/node_modules/@google-cloud/firestore/build/src/write-batch.js new file mode 100644 index 00000000..f738e718 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/build/src/write-batch.js @@ -0,0 +1,510 @@ +/*! + * Copyright 2017 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. + */ +'use strict'; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const assert_1 = __importDefault(require("assert")); +const is_1 = __importDefault(require("is")); +const logger_1 = require("./logger"); +const document_1 = require("./document"); +const path_1 = require("./path"); +const timestamp_1 = require("./timestamp"); +const util_1 = require("./util"); +/*! + * Google Cloud Functions terminates idle connections after two minutes. After + * longer periods of idleness, we issue transactional commits to allow for + * retries. + * + * @type {number} + */ +const GCF_IDLE_TIMEOUT_MS = 110 * 1000; +/** + * A WriteResult wraps the write time set by the Firestore servers on sets(), + * updates(), and creates(). + * + * @class + */ +class WriteResult { + /** + * @private + * @hideconstructor + * + * @param {Timestamp} writeTime - The time of the corresponding document + * write. + */ + constructor(writeTime) { + this._writeTime = writeTime; + } + /** + * The write time as set by the Firestore servers. + * + * @type {Timestamp} + * @name WriteResult#writeTime + * @readonly + * + * @example + * let documentRef = firestore.doc('col/doc'); + * + * documentRef.set({foo: 'bar'}).then(writeResult => { + * console.log(`Document written at: ${writeResult.toDate()}`); + * }); + */ + get writeTime() { + return this._writeTime; + } + /** + * Returns true if this `WriteResult` is equal to the provided value. + * + * @param {*} other The value to compare against. + * @return true if this `WriteResult` is equal to the provided value. + */ + isEqual(other) { + return (this === other || + (is_1.default.instanceof(other, WriteResult) && + this._writeTime.isEqual(other._writeTime))); + } +} +exports.WriteResult = WriteResult; +/** + * A Firestore WriteBatch that can be used to atomically commit multiple write + * operations at once. + * + * @class + */ +class WriteBatch { + /** + * @private + * @hideconstructor + * + * @param {Firestore} firestore - The Firestore Database client. + */ + constructor(firestore) { + this._firestore = firestore; + this._validator = firestore._validator; + this._serializer = firestore._serializer; + this._writes = []; + this._committed = false; + } + /** + * Checks if this write batch has any pending operations. + * + * @private + * @returns {boolean} + */ + get isEmpty() { + return this._writes.length === 0; + } + /** + * Throws an error if this batch has already been committed. + * + * @private + */ + verifyNotCommitted() { + if (this._committed) { + throw new Error('Cannot modify a WriteBatch that has been committed.'); + } + } + /** + * Create a document with the provided object values. This will fail the batch + * if a document exists at its location. + * + * @param {DocumentReference} documentRef - A reference to the + * document to be created. + * @param {DocumentData} data - The object to serialize as the document. + * @returns {WriteBatch} This WriteBatch instance. Used for chaining + * method calls. + * + * @example + * let writeBatch = firestore.batch(); + * let documentRef = firestore.collection('col').doc(); + * + * writeBatch.create(documentRef, {foo: 'bar'}); + * + * writeBatch.commit().then(() => { + * console.log('Successfully executed batch.'); + * }); + */ + create(documentRef, data) { + this._validator.isDocumentReference('documentRef', documentRef); + this._validator.isDocument('data', data, { + allowEmpty: true, + allowDeletes: 'none', + allowTransforms: true, + }); + this.verifyNotCommitted(); + const document = document_1.DocumentSnapshot.fromObject(documentRef, data); + const precondition = new document_1.Precondition({ exists: false }); + const transform = document_1.DocumentTransform.fromObject(documentRef, data); + transform.validate(); + this._writes.push({ + write: !document.isEmpty || transform.isEmpty ? document.toProto() : null, + transform: transform.toProto(this._serializer), + precondition: precondition.toProto(), + }); + return this; + } + /** + * Deletes 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 {WriteBatch} This WriteBatch instance. Used for chaining + * method calls. + * + * @example + * let writeBatch = firestore.batch(); + * let documentRef = firestore.doc('col/doc'); + * + * writeBatch.delete(documentRef); + * + * writeBatch.commit().then(() => { + * console.log('Successfully executed batch.'); + * }); + */ + delete(documentRef, precondition) { + this._validator.isDocumentReference('documentRef', documentRef); + this._validator.isOptionalDeletePrecondition('precondition', precondition); + this.verifyNotCommitted(); + const conditions = new document_1.Precondition(precondition); + this._writes.push({ + write: { + delete: documentRef.formattedName, + }, + precondition: conditions.toProto(), + }); + return this; + } + /** + * 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 {DocumentData} 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 {WriteBatch} This WriteBatch instance. Used for chaining + * method calls. + * + * @example + * let writeBatch = firestore.batch(); + * let documentRef = firestore.doc('col/doc'); + * + * writeBatch.set(documentRef, {foo: 'bar'}); + * + * writeBatch.commit().then(() => { + * console.log('Successfully executed batch.'); + * }); + */ + set(documentRef, data, options) { + this._validator.isOptionalSetOptions('options', options); + const mergeLeaves = options && options.merge === true; + const mergePaths = options && options.mergeFields; + this._validator.isDocumentReference('documentRef', documentRef); + this._validator.isDocument('data', data, { + allowEmpty: true, + allowDeletes: mergePaths || mergeLeaves ? 'all' : 'none', + allowTransforms: true, + }); + this.verifyNotCommitted(); + let documentMask; + if (mergePaths) { + documentMask = document_1.DocumentMask.fromFieldMask(options.mergeFields); + data = documentMask.applyTo(data); + } + const transform = document_1.DocumentTransform.fromObject(documentRef, data); + transform.validate(); + const document = document_1.DocumentSnapshot.fromObject(documentRef, data); + if (mergePaths) { + documentMask.removeFields(transform.fields); + } + else { + documentMask = document_1.DocumentMask.fromObject(data); + } + const hasDocumentData = !document.isEmpty || !documentMask.isEmpty; + let write; + if (!mergePaths && !mergeLeaves) { + write = document.toProto(); + } + else if (hasDocumentData || transform.isEmpty) { + write = document.toProto(); + write.updateMask = documentMask.toProto(this._serializer); + } + this._writes.push({ + write, + transform: transform.toProto(this._serializer), + }); + return this; + } + /** + * 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 {WriteBatch} This WriteBatch instance. Used for chaining + * method calls. + * + * @example + * let writeBatch = firestore.batch(); + * let documentRef = firestore.doc('col/doc'); + * + * writeBatch.update(documentRef, {foo: 'bar'}); + * + * writeBatch.commit().then(() => { + * console.log('Successfully executed batch.'); + * }); + */ + update(documentRef, dataOrField, preconditionOrValues) { + this._validator.minNumberOfArguments('update', arguments, 2); + this._validator.isDocumentReference('documentRef', documentRef); + this.verifyNotCommitted(); + const updateMap = new Map(); + let precondition = new document_1.Precondition({ exists: true }); + const argumentError = 'Update() requires either a single JavaScript ' + + 'object or an alternating list of field/value pairs that can be ' + + 'followed by an optional precondition.'; + let usesVarargs = is_1.default.string(dataOrField) || is_1.default.instance(dataOrField, path_1.FieldPath); + if (usesVarargs) { + try { + for (let i = 1; i < arguments.length; i += 2) { + if (i === arguments.length - 1) { + this._validator.isUpdatePrecondition(i, arguments[i]); + precondition = new document_1.Precondition(arguments[i]); + } + else { + this._validator.isFieldPath(i, arguments[i]); + this._validator.minNumberOfArguments('update', arguments, i + 1); + this._validator.isFieldValue(i, arguments[i + 1], { + allowDeletes: 'root', + allowTransforms: true, + }); + updateMap.set(path_1.FieldPath.fromArgument(arguments[i]), arguments[i + 1]); + } + } + } + catch (err) { + logger_1.logger('WriteBatch.update', null, 'Varargs validation failed:', err); + // We catch the validation error here and re-throw to provide a better + // error message. + throw new Error(`${argumentError} ${err.message}`); + } + } + else { + try { + this._validator.isDocument('dataOrField', dataOrField, { + allowEmpty: false, + allowDeletes: 'root', + allowTransforms: true, + }); + this._validator.maxNumberOfArguments('update', arguments, 3); + Object.keys(dataOrField).forEach(key => { + this._validator.isFieldPath(key, key); + updateMap.set(path_1.FieldPath.fromArgument(key), dataOrField[key]); + }); + if (is_1.default.defined(preconditionOrValues)) { + this._validator.isUpdatePrecondition('preconditionOrValues', preconditionOrValues); + precondition = new document_1.Precondition(preconditionOrValues); + } + } + catch (err) { + logger_1.logger('WriteBatch.update', null, 'Non-varargs validation failed:', err); + // We catch the validation error here and prefix the error with a custom + // message to describe the usage of update() better. + throw new Error(`${argumentError} ${err.message}`); + } + } + this._validator.isUpdateMap('dataOrField', updateMap); + let document = document_1.DocumentSnapshot.fromUpdateMap(documentRef, updateMap); + let documentMask = document_1.DocumentMask.fromUpdateMap(updateMap); + let write = null; + if (!document.isEmpty || !documentMask.isEmpty) { + write = document.toProto(); + write.updateMask = documentMask.toProto(); + } + let transform = document_1.DocumentTransform.fromUpdateMap(documentRef, updateMap); + transform.validate(); + this._writes.push({ + write: write, + transform: transform.toProto(this._serializer), + precondition: precondition.toProto(), + }); + return this; + } + /** + * Atomically commits all pending operations to the database and verifies all + * preconditions. Fails the entire write if any precondition is not met. + * + * @returns {Promise.>} A Promise that resolves + * when this batch completes. + * + * @example + * let writeBatch = firestore.batch(); + * let documentRef = firestore.doc('col/doc'); + * + * writeBatch.set(documentRef, {foo: 'bar'}); + * + * writeBatch.commit().then(() => { + * console.log('Successfully executed batch.'); + * }); + */ + commit() { + return this.commit_(); + } + /** + * Commit method that takes an optional transaction ID. + * + * @private + * @param {object=} commitOptions Options to use for this commit. + * @param {bytes=} commitOptions.transactionId The transaction ID of this + * commit. + * @param {string=} commitOptions.requestTag A unique client-assigned + * identifier for this request. + * @returns {Promise.>} A Promise that resolves + * when this batch completes. + */ + commit_(commitOptions) { + // Note: We don't call `verifyNotCommitted()` to allow for retries. + let explicitTransaction = commitOptions && commitOptions.transactionId; + let tag = (commitOptions && commitOptions.requestTag) || util_1.requestTag(); + let request = { + database: this._firestore.formattedName, + }; + // On GCF, we periodically force transactional commits to allow for + // request retries in case GCF closes our backend connection. + if (!explicitTransaction && this._shouldCreateTransaction()) { + logger_1.logger('WriteBatch.commit', tag, 'Using transaction for commit'); + return this._firestore.request('beginTransaction', request, tag, true) + .then(resp => { + return this.commit_({ transactionId: resp.transaction }); + }); + } + request.writes = []; + for (let req of this._writes) { + assert_1.default(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); + } + if (req.transform) { + request.writes.push(req.transform); + } + } + logger_1.logger('WriteBatch.commit', tag, 'Sending %d writes', request.writes.length); + if (explicitTransaction) { + request.transaction = explicitTransaction; + } + this._committed = true; + return this._firestore.request('commit', request, tag).then(resp => { + const writeResults = []; + if (request.writes.length > 0) { + assert_1.default(resp.writeResults instanceof Array && + 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_1.Timestamp.fromProto(resp.commitTime); + let offset = 0; + for (let i = 0; i < this._writes.length; ++i) { + let writeRequest = this._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; + } + let writeResult = resp.writeResults[i + offset]; + writeResults.push(new WriteResult(writeResult.updateTime ? + timestamp_1.Timestamp.fromProto(writeResult.updateTime) : + commitTime)); + } + } + return writeResults; + }); + } + /** + * Determines whether we should issue a transactional commit. On GCF, this + * happens after two minutes of idleness. + * + * @private + * @returns {boolean} Whether to use a transaction. + */ + _shouldCreateTransaction() { + if (!this._firestore._preferTransactions) { + return false; + } + if (this._firestore._lastSuccessfulRequest) { + let now = new Date().getTime(); + return now - this._firestore._lastSuccessfulRequest > GCF_IDLE_TIMEOUT_MS; + } + return true; + } +} +exports.WriteBatch = WriteBatch; +/*! + * Validates that the update data does not contain any ambiguous field + * definitions (such as 'a.b' and 'a'). + * + * @param {Map.} data - An update map with field/value pairs. + * @returns {boolean} 'true' if the input is a valid update map. + */ +function validateUpdateMap(data) { + const fields = []; + data.forEach((value, key) => { + fields.push(key); + }); + fields.sort((left, right) => left.compareTo(right)); + for (let i = 1; i < fields.length; ++i) { + if (fields[i - 1].isPrefixOf(fields[i])) { + throw new Error(`Field "${fields[i - 1]}" was specified multiple times.`); + } + } + return true; +} +exports.validateUpdateMap = validateUpdateMap; diff --git a/website/functions/node_modules/@google-cloud/firestore/package.json b/website/functions/node_modules/@google-cloud/firestore/package.json new file mode 100644 index 00000000..6e495d55 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/package.json @@ -0,0 +1,145 @@ +{ + "_from": "@google-cloud/firestore@^0.16.0", + "_id": "@google-cloud/firestore@0.16.1", + "_inBundle": false, + "_integrity": "sha512-xHb4OdRb0OP0x/8w58WJERtCi9Pr+CsloiUlVAq6fFjSyEcmxgL0V+swE8A/2rI5NGQGwtrN57xwDcis5UM/cQ==", + "_location": "/@google-cloud/firestore", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "@google-cloud/firestore@^0.16.0", + "name": "@google-cloud/firestore", + "escapedName": "@google-cloud%2ffirestore", + "scope": "@google-cloud", + "rawSpec": "^0.16.0", + "saveSpec": null, + "fetchSpec": "^0.16.0" + }, + "_requiredBy": [ + "/firebase-admin" + ], + "_resolved": "https://registry.npmjs.org/@google-cloud/firestore/-/firestore-0.16.1.tgz", + "_shasum": "aedba92d428cc78f8a6e3eb6ab59e3c8d906f814", + "_spec": "@google-cloud/firestore@^0.16.0", + "_where": "C:\\Users\\jlevi\\Downloads\\tr2022-strategy-master\\tr2022-strategy-master\\data analysis\\functions\\node_modules\\firebase-admin", + "author": { + "name": "Google Inc." + }, + "bugs": { + "url": "https://github.com/googleapis/nodejs-firestore/issues" + }, + "bundleDependencies": false, + "contributors": [ + { + "name": "Alexander Fenster", + "email": "github@fenster.name" + }, + { + "name": "Bond", + "email": "bondz@users.noreply.github.com" + }, + { + "name": "Jason Dobry", + "email": "jdobry@google.com" + }, + { + "name": "Luke Sneeringer", + "email": "lukesneeringer@google.com" + }, + { + "name": "Sebastian Schmidt", + "email": "mrschmidt@google.com" + }, + { + "name": "Stephen Sawchuk", + "email": "sawchuk@gmail.com" + }, + { + "name": "greenkeeper[bot]", + "email": "greenkeeper[bot]@users.noreply.github.com" + } + ], + "dependencies": { + "@google-cloud/projectify": "^0.3.0", + "bun": "^0.0.12", + "deep-equal": "^1.0.1", + "extend": "^3.0.1", + "functional-red-black-tree": "^1.0.1", + "google-gax": "^0.18.0", + "google-proto-files": "^0.16.1", + "is": "^3.2.1", + "lodash.merge": "^4.6.1", + "protobufjs": "^6.8.6", + "through2": "^2.0.3" + }, + "deprecated": false, + "description": "Firestore Client Library for Node.js", + "devDependencies": { + "@google-cloud/nodejs-repo-tools": "^2.3.0", + "@types/mocha": "^5.2.3", + "@types/node": "^10.3.5", + "chai": "^4.1.2", + "chai-as-promised": "^7.1.1", + "codecov": "^3.0.2", + "duplexify": "^3.6.0", + "gts": "^0.7.1", + "hard-rejection": "^1.0.0", + "ink-docstrap": "git+https://github.com/docstrap/docstrap.git", + "intelli-espower-loader": "^1.0.1", + "jsdoc": "^3.5.5", + "mocha": "^5.2.0", + "nyc": "^12.0.2", + "power-assert": "^1.6.0", + "proxyquire": "^2.0.1", + "source-map-support": "^0.5.6", + "ts-node": "^7.0.0", + "typescript": "^2.9.2" + }, + "engines": { + "node": ">=6.0.0" + }, + "files": [ + "build/protos", + "build/src", + "types" + ], + "homepage": "https://github.com/googleapis/nodejs-firestore#readme", + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "firestore" + ], + "license": "Apache-2.0", + "main": "./build/src/index.js", + "name": "@google-cloud/firestore", + "repository": { + "type": "git", + "url": "git+https://github.com/googleapis/nodejs-firestore.git" + }, + "scripts": { + "check": "gts check", + "clean": "gts clean", + "codecov": "nyc report --reporter=json && codecov -f .coverage/*.json", + "compile": "tsc -p . && cp -r dev/protos build && cp -r dev/test/fake-certificate.json build/test/fake-certificate.json && cp dev/src/v1beta1/firestore_client_config.json build/src/v1beta1/ && cp dev/conformance/test-definition.proto build/conformance && cp dev/conformance/test-suite.binproto build/conformance", + "conformance": "mocha build/conformance", + "docs": "jsdoc -c .jsdoc.js", + "fix": "gts fix", + "generate-scaffolding": "repo-tools generate all", + "posttest": "npm run check", + "predocs": "npm run compile", + "prepare": "npm run compile", + "pretest-only": "npm run compile", + "system-test": "mocha build/system-test --timeout 600000", + "test": "npm run test-only", + "test-only": "nyc mocha build/test" + }, + "types": "./types/firestore.d.ts", + "version": "0.16.1" +} diff --git a/website/functions/node_modules/@google-cloud/firestore/types/firestore.d.ts b/website/functions/node_modules/@google-cloud/firestore/types/firestore.d.ts new file mode 100644 index 00000000..a63baf09 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/firestore/types/firestore.d.ts @@ -0,0 +1,1244 @@ +/** + * @fileoverview Firestore Server API. + * + * Copyright 2017 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. + */ + +// tslint:disable + +// Declare a global (ambient) namespace +// (used when not using import statement, but just script include). +declare namespace FirebaseFirestore { + /** + * Document data (for use with `DocumentReference.set()`) consists of fields + * mapped to values. + */ + 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. + */ + export type UpdateData = {[fieldPath: string]: any}; + + /** + * Sets the log function for all active Firestore instances. + */ + function setLogFunction(logger: (msg:string) => void): void; + + /** + * 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; + + /** + * 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; + + /** + * Enables the use of `Timestamp`s for timestamp fields in + * `DocumentSnapshot`s. + * + * Currently, Firestore returns 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. + * + * Setting `timestampsInSnapshots` to true will cause Firestore to return + * `Timestamp` values instead of `Date` avoiding this kind of problem. To + * make this work you must also change any code that uses `Date` to use + * `Timestamp` instead. + * + * NOTE: in the future `timestampsInSnapshots: true` will become the + * default and this option will be removed so you should change your code to + * use `Timestamp` now and opt-in to this new behavior as soon as you can. + */ + timestampsInSnapshots?: boolean; + + [key: string]: any; // Accept other properties, such as GRPC settings. + } + + /** + * `Firestore` represents a Firestore Database and is the entry point for all + * Firestore operations. + */ + export class Firestore { + /** + * @param settings - Configuration object. See [Firestore Documentation] + * {@link https://firebase.google.com/docs/firestore/} + */ + public constructor(settings?: Settings); + + /** + * Specifies custom settings to be used to configure the `Firestore` + * instance. Can only be invoked once and before any other Firestore + * method. + * + * If settings are provided via both `settings()` and the `Firestore` + * constructor, both settings objects are merged and any settings provided + * via `settings()` take precedence. + * + * @param {object} settings The settings to use for all Firestore + * operations. + */ + settings(settings: Settings): void; + + /** + * Gets a `CollectionReference` instance that refers to the collection at + * the specified path. + * + * @param collectionPath A slash-separated path to a collection. + * @return The `CollectionReference` instance. + */ + collection(collectionPath: string): CollectionReference; + + /** + * Gets a `DocumentReference` instance that refers to the document at the + * specified path. + * + * @param documentPath A slash-separated path to a document. + * @return The `DocumentReference` instance. + */ + doc(documentPath: string): DocumentReference; + + /** + * Retrieves multiple documents from Firestore. + * + * @param documentRef The `DocumentReferences` to receive. + * @return A Promise that resolves with an array of resulting document + * snapshots. + */ + getAll(...documentRef: DocumentReference[]): Promise; + + /** + * Fetches the root collections that are associated with this Firestore + * database. + * + * @returns A Promise that resolves with an array of CollectionReferences. + */ + getCollections() : Promise; + + /** + * Executes the given updateFunction and commits the changes applied within + * 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. + * + * @param updateFunction The function to execute within the transaction + * context. + * @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 + * transaction failed, a rejected Promise with the corresponding failure + * error will be returned. + */ + runTransaction( + updateFunction: (transaction: Transaction) => Promise + ): Promise; + + /** + * Creates a write batch, used for performing multiple writes as a single + * atomic operation. + */ + batch(): WriteBatch; + } + + /** + * An immutable object representing a geo point in Firestore. The geo point + * is represented as latitude/longitude pair. + * + * Latitude values are in the range of [-90, 90]. + * Longitude values are in the range of [-180, 180]. + */ + export class GeoPoint { + /** + * Creates a new immutable GeoPoint object with the provided latitude and + * longitude values. + * @param latitude The latitude as number between -90 and 90. + * @param longitude The longitude as number between -180 and 180. + */ + constructor(latitude: number, longitude: number); + + readonly latitude: number; + readonly longitude: number; + + /** + * Returns true if this `GeoPoint` is equal to the provided one. + * + * @param other The `GeoPoint` to compare against. + * @return true if this `GeoPoint` is equal to the provided one. + */ + isEqual(other: GeoPoint): boolean; + } + + /** + * A reference to a transaction. + * The `Transaction` object passed to a transaction's updateFunction provides + * the methods to read and write data within the transaction context. See + * `Firestore.runTransaction()`. + */ + export class Transaction { + private constructor(); + + + /** + * Retrieves a query result. Holds a pessimistic lock on all returned + * documents. + * + * @param query A query to execute. + * @return A QuerySnapshot for the retrieved data. + */ + get(query: Query): Promise; + + /** + * Reads the document referenced by the provided `DocumentReference.` + * Holds a pessimistic lock on the returned document. + * + * @param documentRef A reference to the document to be read. + * @return A DocumentSnapshot for the read data. + */ + get(documentRef: DocumentReference): Promise; + + /** + * Retrieves multiple documents from Firestore. Holds a pessimistic lock on + * all returned documents. + * + * @param documentRef The `DocumentReferences` to receive. + * @return A Promise that resolves with an array of resulting document + * snapshots. + */ + getAll(...documentRef: DocumentReference[]): Promise; + + /** + * Create the document referred to by the provided `DocumentReference`. + * The operation will fail the transaction if a document exists at the + * specified location. + * + * @param documentRef A reference to the document to be create. + * @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; + + /** + * Writes to the document referred to by the provided `DocumentReference`. + * If the document does not exist yet, it will be created. If you pass + * `SetOptions`, the provided data can be merged into the existing document. + * + * @param documentRef A reference to the document to be set. + * @param data An object of the fields and values for the document. + * @param options An object to configure the set behavior. + * @return This `Transaction` instance. Used for chaining method calls. + */ + set(documentRef: DocumentReference, data: DocumentData, + options?: SetOptions): Transaction; + + /** + * Updates fields in the document referred to by the provided + * `DocumentReference`. The update will fail if applied to a document that + * does not exist. + * + * Nested fields can be updated by providing dot-separated field path + * strings. + * + * @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. + * @return This `Transaction` instance. Used for chaining method calls. + */ + update(documentRef: DocumentReference, data: UpdateData, + precondition?: Precondition): Transaction; + + /** + * Updates fields in the document referred to by the provided + * `DocumentReference`. The update will fail if applied to a document that + * does not exist. + * + * 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 by a `Precondition` to enforce on this + * update. + * @return This `Transaction` instance. Used for chaining method calls. + */ + update(documentRef: DocumentReference, field: string|FieldPath, value:any, + ...fieldsOrPrecondition: any[]): Transaction; + + /** + * Deletes the document referred to by the provided `DocumentReference`. + * + * @param documentRef A reference to the document to be deleted. + * @param precondition A Precondition to enforce for this delete. + * @return This `Transaction` instance. Used for chaining method calls. + */ + delete(documentRef: DocumentReference, + precondition?: Precondition): Transaction; + } + + /** + * A write batch, used to perform multiple writes as a single atomic unit. + * + * A `WriteBatch` object can be acquired by calling `Firestore.batch()`. It + * provides methods for adding writes to the write batch. None of the + * writes will be committed (or visible locally) until `WriteBatch.commit()` + * is called. + * + * Unlike transactions, write batches are persisted offline and therefore are + * preferable when you don't need to condition your writes on read data. + */ + export class WriteBatch { + private constructor(); + + /** + * Create the document referred to by the provided `DocumentReference`. The + * operation will fail the batch if a document exists at the specified + * location. + * + * @param documentRef A reference to the document to be created. + * @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; + + /** + * Write to the document referred to by the provided `DocumentReference`. + * If the document does not exist yet, it will be created. If you pass + * `SetOptions`, the provided data can be merged into the existing document. + * + * @param documentRef A reference to the document to be set. + * @param data An object of the fields and values for the document. + * @param options An object to configure the set behavior. + * @return This `WriteBatch` instance. Used for chaining method calls. + */ + set(documentRef: DocumentReference, data: DocumentData, + options?: SetOptions): WriteBatch; + + /** + * Update fields of the document referred to by the provided + * `DocumentReference`. If the document doesn't yet exist, the update fails + * and the entire batch will be rejected. + * + * Nested fields can be updated by providing dot-separated field path + * strings. + * + * @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. + * @return This `WriteBatch` instance. Used for chaining method calls. + */ + update(documentRef: DocumentReference, data: UpdateData, + precondition?: Precondition): WriteBatch; + + /** + * Updates fields in the document referred to by the provided + * `DocumentReference`. The update will fail if applied to a document that + * does not exist. + * + * 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. + * @return This `WriteBatch` instance. Used for chaining method calls. + */ + update(documentRef: DocumentReference, field: string|FieldPath, value:any, + ...fieldsOrPrecondition: any[]): WriteBatch; + + /** + * Deletes the document referred to by the provided `DocumentReference`. + * + * @param documentRef A reference to the document to be deleted. + * @param precondition A Precondition to enforce for this delete. + * @return This `WriteBatch` instance. Used for chaining method calls. + */ + delete(documentRef: DocumentReference, + precondition?: Precondition): WriteBatch; + + /** + * Commits all of the writes in this write batch as a single atomic unit. + * + * @return A Promise resolved once all of the writes in the batch have been + * successfully written to the backend as an atomic unit. + */ + commit(): Promise; + } + + /** + * 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?: (string|FieldPath)[]; + } + + /** + * A WriteResult wraps the write time set by the Firestore servers on `sets()`, + * `updates()`, and `creates()`. + */ + export class WriteResult { + private constructor(); + + /** + * The write time as set by the Firestore servers. + */ + readonly writeTime: Timestamp; + + /** + * Returns true if this `WriteResult` is equal to the provided one. + * + * @param other The `WriteResult` to compare against. + * @return true if this `WriteResult` is equal to the provided one. + */ + isEqual(other: WriteResult): boolean; + } + + /** + * A `DocumentReference` refers to a document location in a Firestore database + * and can be used to write, read, or listen to the location. The document at + * the referenced location may or may not exist. A `DocumentReference` can + * also be used to create a `CollectionReference` to a subcollection. + */ + export class DocumentReference { + private constructor(); + + /** The identifier of the document within its collection. */ + readonly id: string; + + /** + * The `Firestore` for the Firestore database (useful for performing + * transactions, etc.). + */ + readonly firestore: Firestore; + + /** + * A reference to the Collection to which this DocumentReference belongs. + */ + readonly parent: CollectionReference; + + /** + * A string representing the path of the referenced document (relative + * to the root of the database). + */ + readonly path: string; + + /** + * Gets a `CollectionReference` instance that refers to the collection at + * the specified path. + * + * @param collectionPath A slash-separated path to a collection. + * @return The `CollectionReference` instance. + */ + collection(collectionPath: string): CollectionReference; + + /** + * Fetches the subcollections that are direct children of this document. + * + * @returns A Promise that resolves with an array of CollectionReferences. + */ + getCollections() : Promise; + + /** + * Creates a document referred to by this `DocumentReference` with the + * provided object values. The write fails if the document already exists + * + * @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; + + /** + * Writes to the document referred to by this `DocumentReference`. If the + * document does not yet exist, it will be created. If you pass + * `SetOptions`, the provided data can be merged into an existing document. + * + * @param data A map of the fields and values for the document. + * @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; + + /** + * Updates fields in the document referred to by this `DocumentReference`. + * The update will fail if applied to a document that does not exist. + * + * Nested fields can be updated by providing dot-separated field path + * strings. + * + * @param data An object containing the fields and values with which to + * update the document. + * @param precondition A Precondition to enforce on this update. + * @return A Promise resolved with the write time of this update. + */ + update(data: UpdateData, precondition?: Precondition): Promise; + + /** + * Updates fields in the document referred to by this `DocumentReference`. + * The update will fail if applied to a document that does not exist. + * + * 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 field The first field to update. + * @param value The first value. + * @param moreFieldsOrPrecondition An alternating list of field paths and + * values to update, optionally followed by a `Precondition` to enforce on + * this update. + * @return A Promise resolved with the write time of this update. + */ + update(field: string|FieldPath, value:any, + ...moreFieldsOrPrecondition: any[]): Promise; + + /** + * Deletes the document referred to by this `DocumentReference`. + * + * @param precondition A Precondition to enforce for this delete. + * @return A Promise resolved with the write time of this delete. + */ + delete(precondition?:Precondition): Promise; + + /** + * Reads the document referred to by this `DocumentReference`. + * + * @return A Promise resolved with a DocumentSnapshot containing the + * current document contents. + */ + get(): Promise; + + /** + * Attaches a listener for DocumentSnapshot events. + * + * @param onNext A callback to be called every time a new `DocumentSnapshot` + * is available. + * @param onError A callback to be called if the listen fails or is + * cancelled. No further callbacks will occur. + * @return An unsubscribe function that can be called to cancel + * the snapshot listener. + */ + onSnapshot(onNext: (snapshot: DocumentSnapshot) => void, + onError?: (error: Error) => void): () => void; + + /** + * Returns true if this `DocumentReference` is equal to the provided one. + * + * @param other The `DocumentReference` to compare against. + * @return true if this `DocumentReference` is equal to the provided one. + */ + isEqual(other: DocumentReference): boolean; + } + + /** + * A `DocumentSnapshot` contains data read from a document in your Firestore + * database. The data can be extracted with `.data()` or `.get()` to + * get a specific field. + * + * For a `DocumentSnapshot` that points to a non-existing document, any data + * access will return 'undefined'. You can use the `exists` property to + * explicitly verify a document's existence. + */ + export class DocumentSnapshot { + protected constructor(); + + /** True if the document exists. */ + readonly exists: boolean; + + /** A `DocumentReference` to the document location. */ + readonly ref: DocumentReference; + + /** + * The ID of the document for which this `DocumentSnapshot` contains data. + */ + readonly id: string; + + /** + * The time the document was created. Not set for documents that don't + * exist. + */ + readonly createTime?: Timestamp; + + /** + * The time the document was last updated (at the time the snapshot was + * generated). Not set for documents that don't exist. + */ + readonly updateTime?: Timestamp; + + /** + * The time this snapshot was read. + */ + readonly readTime: Timestamp; + + /** + * Retrieves all fields in the document as an Object. Returns 'undefined' if + * the document doesn't exist. + * + * @return An Object containing all fields in the document. + */ + data(): DocumentData | undefined; + + /** + * Retrieves the field specified by `fieldPath`. + * + * @param fieldPath The path (e.g. 'foo' or 'foo.bar') to a specific field. + * @return The data at the specified field location or undefined if no such + * field exists in the document. + */ + get(fieldPath: string|FieldPath): any; + + /** + * Returns true if the document's data and path in this `DocumentSnapshot` + * is equal to the provided one. + * + * @param other The `DocumentSnapshot` to compare against. + * @return true if this `DocumentSnapshot` is equal to the provided one. + */ + isEqual(other: DocumentSnapshot): boolean; + } + + /** + * A `QueryDocumentSnapshot` contains data read from a document in your + * Firestore database as part of a query. The document is guaranteed to exist + * and its data can be extracted with `.data()` or `.get()` to get a + * specific field. + * + * A `QueryDocumentSnapshot` offers the same API surface as a + * `DocumentSnapshot`. Since query results contain only existing documents, the + * `exists` property will always be true and `data()` will never return + * 'undefined'. + */ + export class QueryDocumentSnapshot extends DocumentSnapshot { + private constructor(); + + /** + * The time the document was created. + */ + readonly createTime: Timestamp; + + /** + * The time the document was last updated (at the time the snapshot was + * generated). + */ + readonly updateTime: Timestamp; + + /** + * Retrieves all fields in the document as an Object. + * + * @override + * @return An Object containing all fields in the document. + */ + data(): DocumentData; + } + + /** + * 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 '<', '<=', '==', '>=', '>', and 'array-contains'. + */ + export type WhereFilterOp = '<' | '<=' | '==' | '>=' | '>' | 'array-contains'; + + /** + * 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 { + protected constructor(); + + /** + * The `Firestore` for the Firestore database (useful for performing + * transactions, etc.). + */ + readonly firestore: Firestore; + + /** + * Creates and returns a new Query with the additional filter that documents + * must contain the specified field and that its value should satisfy the + * relation constraint provided. + * + * This function returns a new (immutable) instance of the Query (rather + * than modify the existing instance) to impose the filter. + * + * @param fieldPath The path to compare + * @param opStr The operation string (e.g "<", "<=", "==", ">", ">="). + * @param value The value for comparison + * @return The created Query. + */ + where(fieldPath: string|FieldPath, opStr: WhereFilterOp, value: any): Query; + + /** + * Creates and returns a new Query that's additionally sorted by the + * specified field, optionally in descending order instead of ascending. + * + * This function returns a new (immutable) instance of the Query (rather + * than modify the existing instance) to impose the order. + * + * @param fieldPath The field to sort by. + * @param directionStr Optional direction to sort by ('asc' or 'desc'). If + * not specified, order will be ascending. + * @return The created Query. + */ + orderBy( + fieldPath: string|FieldPath, directionStr?: OrderByDirection + ): Query; + + /** + * Creates and returns a new Query that's additionally limited to only + * return up to the specified number of documents. + * + * This function returns a new (immutable) instance of the Query (rather + * than modify the existing instance) to impose the limit. + * + * @param limit The maximum number of items to return. + * @return The created Query. + */ + limit(limit: number): Query; + + /** + * Specifies the offset of the returned results. + * + * This function returns a new (immutable) instance of the Query (rather + * than modify the existing instance) to impose the offset. + * + * @param offset The offset to apply to the Query results. + * @return The created Query. + */ + offset(offset: number): Query; + + /** + * Creates and returns a new Query instance that applies a field mask to + * the result and returns only the specified subset of fields. You can + * specify a list of field paths to return, or use an empty list to only + * return the references of matching documents. + * + * This function returns a new (immutable) instance of the Query (rather + * than modify the existing instance) to impose the field mask. + * + * @param field The field paths to return. + * @return The created Query. + */ + select(...field: (string | FieldPath)[]): Query; + + /** + * Creates and returns a new Query that starts at the provided document + * (inclusive). The starting position is relative to the order of the query. + * The document must contain all of the fields provided in the orderBy of + * this query. + * + * @param snapshot The snapshot of the document to start after. + * @return The created Query. + */ + startAt(snapshot: DocumentSnapshot): Query; + + /** + * Creates and returns a new Query that starts at the provided fields + * relative to the order of the query. The order of the field values + * must match the order of the order by clauses of the query. + * + * @param fieldValues The field values to start this query at, in order + * of the query's order by. + * @return The created Query. + */ + startAt(...fieldValues: any[]): Query; + + /** + * Creates and returns a new Query that starts after the provided document + * (exclusive). The starting position is relative to the order of the query. + * The document must contain all of the fields provided in the orderBy of + * this query. + * + * @param snapshot The snapshot of the document to start after. + * @return The created Query. + */ + startAfter(snapshot: DocumentSnapshot): Query; + + /** + * Creates and returns a new Query that starts after the provided fields + * relative to the order of the query. The order of the field values + * must match the order of the order by clauses of the query. + * + * @param fieldValues The field values to start this query after, in order + * of the query's order by. + * @return The created Query. + */ + startAfter(...fieldValues: any[]): Query; + + /** + * Creates and returns a new Query that ends before the provided document + * (exclusive). The end position is relative to the order of the query. The + * document must contain all of the fields provided in the orderBy of this + * query. + * + * @param snapshot The snapshot of the document to end before. + * @return The created Query. + */ + endBefore(snapshot: DocumentSnapshot): Query; + + /** + * Creates and returns a new Query that ends before the provided fields + * relative to the order of the query. The order of the field values + * must match the order of the order by clauses of the query. + * + * @param fieldValues The field values to end this query before, in order + * of the query's order by. + * @return The created Query. + */ + endBefore(...fieldValues: any[]): Query; + + /** + * Creates and returns a new Query that ends at the provided document + * (inclusive). The end position is relative to the order of the query. The + * document must contain all of the fields provided in the orderBy of this + * query. + * + * @param snapshot The snapshot of the document to end at. + * @return The created Query. + */ + endAt(snapshot: DocumentSnapshot): Query; + + /** + * Creates and returns a new Query that ends at the provided fields + * relative to the order of the query. The order of the field values + * must match the order of the order by clauses of the query. + * + * @param fieldValues The field values to end this query at, in order + * of the query's order by. + * @return The created Query. + */ + endAt(...fieldValues: any[]): Query; + + /** + * Executes the query and returns the results as a `QuerySnapshot`. + * + * @return A Promise that will be resolved with the results of the Query. + */ + get(): Promise; + + /* + * Executes the query and returns the results as Node Stream. + * + * @return A stream of QueryDocumentSnapshot. + */ + stream(): NodeJS.ReadableStream; + + /** + * Attaches a listener for `QuerySnapshot `events. + * + * @param onNext A callback to be called every time a new `QuerySnapshot` + * is available. + * @param onError A callback to be called if the listen fails or is + * cancelled. No further callbacks will occur. + * @return An unsubscribe function that can be called to cancel + * the snapshot listener. + */ + onSnapshot(onNext: (snapshot: QuerySnapshot) => void, + onError?: (error: Error) => void) : () => void; + + /** + * Returns true if this `Query` is equal to the provided one. + * + * @param other The `Query` to compare against. + * @return true if this `Query` is equal to the provided one. + */ + isEqual(other: Query): boolean; + } + + /** + * A `QuerySnapshot` contains zero or more `QueryDocumentSnapshot` objects + * representing the results of a query. The documents can be accessed as an + * array via the `docs` property or enumerated using the `forEach` method. The + * number of documents can be determined via the `empty` and `size` + * properties. + */ + export class QuerySnapshot { + private constructor(); + + /** + * The query on which you called `get` or `onSnapshot` in order to get this + * `QuerySnapshot`. + */ + readonly query: Query; + + /** + * An array of the documents that changed since the last snapshot. If this + * is the first snapshot, all documents will be in the list as added + * changes. + */ + readonly docChanges: DocumentChange[]; + + /** An array of all the documents in the QuerySnapshot. */ + readonly docs: QueryDocumentSnapshot[]; + + /** The number of documents in the QuerySnapshot. */ + readonly size: number; + + /** True if there are no documents in the QuerySnapshot. */ + readonly empty: boolean; + + /** The time this query snapshot was obtained. */ + readonly readTime: Timestamp; + + /** + * Enumerates all of the documents in the QuerySnapshot. + * + * @param callback A callback to be called with a `DocumentSnapshot` for + * each document in the snapshot. + * @param thisArg The `this` binding for the callback. + */ + forEach( + callback: (result: QueryDocumentSnapshot) => void, thisArg?: any + ): void; + + /** + * Returns true if the document data in this `QuerySnapshot` is equal to the + * provided one. + * + * @param other The `QuerySnapshot` to compare against. + * @return true if this `QuerySnapshot` is equal to the provided one. + */ + isEqual(other: QuerySnapshot): boolean; + } + + /** + * The type of of a `DocumentChange` may be 'added', 'removed', or 'modified'. + */ + 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. + */ + export interface DocumentChange { + /** The type of change ('added', 'modified', or 'removed'). */ + readonly type: DocumentChangeType; + + /** The document affected by this change. */ + readonly doc: QueryDocumentSnapshot; + + /** + * The index of the changed document in the result set immediately prior to + * this DocumentChange (i.e. supposing that all prior DocumentChange objects + * have been applied). Is -1 for 'added' events. + */ + readonly oldIndex: number; + + /** + * The index of the changed document in the result set immediately after + * this DocumentChange (i.e. supposing that all prior DocumentChange + * objects and the current DocumentChange object have been applied). + * Is -1 for 'removed' events. + */ + readonly newIndex: number; + + /** + * Returns true if the data in this `DocumentChange` is equal to the + * provided one. + * + * @param other The `DocumentChange` to compare against. + * @return true if this `DocumentChange` is equal to the provided one. + */ + isEqual(other: DocumentChange): boolean; + } + + /** + * A `CollectionReference` object can be used for adding documents, getting + * document references, and querying for documents (using the methods + * inherited from `Query`). + */ + export class CollectionReference extends Query { + private constructor(); + + /** The identifier of the collection. */ + readonly id: string; + + /** + * A reference to the containing Document if this is a subcollection, else + * null. + */ + readonly parent: DocumentReference|null; + + /** + * A string representing the path of the referenced collection (relative + * to the root of the database). + */ + readonly path: string; + + /** + * Get a `DocumentReference` for the document within the collection at the + * specified path. If no path is specified, an automatically-generated + * unique ID will be used for the returned DocumentReference. + * + * @param documentPath A slash-separated path to a document. + * @return The `DocumentReference` instance. + */ + doc(documentPath?: string): DocumentReference; + + /** + * Add a new document to this collection with the specified data, assigning + * it a document ID automatically. + * + * @param data An Object containing the data for the new document. + * @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; + + /** + * Returns true if this `CollectionReference` is equal to the provided one. + * + * @param other The `CollectionReference` to compare against. + * @return true if this `CollectionReference` is equal to the provided one. + */ + isEqual(other: CollectionReference): boolean; + } + + /** + * Sentinel values that can be used when writing document fields with set(), + * create() or update(). + */ + export class FieldValue { + private constructor(); + + /** + * Returns a sentinel used with set(), create() or update() to include a + * server-generated timestamp in the written data. + * + * @return The FieldValue sentinel for use in a call to set(), create() or + * update(). + */ + static serverTimestamp(): FieldValue; + + /** + * Returns a sentinel for use with update() or set() with {merge:true} to + * mark a field for deletion. + * + * @return The FieldValue sentinel for use in a call to set() or update(). + */ + static delete(): FieldValue; + + /** + * Returns a special value that can be used with set(), create() or update() + * that tells the server to union the given elements with any array value + * that already exists on the server. Each specified element that doesn't + * already exist in the array will be added to the end. If the field being + * modified is not already an array it will be overwritten with an array + * containing exactly the specified elements. + * + * @param elements The elements to union into the array. + * @return The FieldValue sentinel for use in a call to set(), create() or + * update(). + */ + static arrayUnion(...elements: any[]): FieldValue; + + /** + * Returns a special value that can be used with set(), create() or update() + * that tells the server to remove the given elements from any array value + * that already exists on the server. All instances of each element + * specified will be removed from the array. If the field being modified is + * not already an array it will be overwritten with an empty array. + * + * @param elements The elements to remove from the array. + * @return The FieldValue sentinel for use in a call to set(), create() or + * update(). + */ + static arrayRemove(...elements: any[]): FieldValue; + + /** + * Returns true if this `FieldValue` is equal to the provided one. + * + * @param other The `FieldValue` to compare against. + * @return true if this `FieldValue` is equal to the provided one. + */ + isEqual(other: FieldValue): boolean; + } + + /** + * A FieldPath refers to a field in a document. The path may consist of a + * single field name (referring to a top-level field in the document), or a + * list of field names (referring to a nested field in the document). + */ + export class FieldPath { + /** + * Creates a FieldPath from the provided field names. If more than one field + * name is provided, the path will point to a nested field in a document. + * + * @param fieldNames A list of field names. + */ + constructor(...fieldNames: string[]); + + /** + * Returns a special sentinel FieldPath to refer to the ID of a document. + * It can be used in queries to sort or filter by the document ID. + */ + static documentId(): FieldPath; + + /** + * Returns true if this `FieldPath` is equal to the provided one. + * + * @param other The `FieldPath` to compare against. + * @return true if this `FieldPath` is equal to the provided one. + */ + isEqual(other: FieldPath): boolean; + } + + /** + * A Timestamp represents a point in time independent of any time zone or + * calendar, represented as seconds and fractions of seconds at nanosecond + * resolution in UTC Epoch time. It is encoded using the Proleptic Gregorian + * Calendar which extends the Gregorian calendar backwards to year one. It is + * encoded assuming all minutes are 60 seconds long, i.e. leap seconds are + * "smeared" so that no leap second table is needed for interpretation. Range + * is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. + * + * @see https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto + */ + export class Timestamp { + /** + * Creates a new timestamp with the current date, with millisecond precision. + * + * @return A new `Timestamp` representing the current date. + */ + static now(): Timestamp; + + /** + * Creates a new timestamp from the given date. + * + * @param date The date to initialize the `Timestamp` from. + * @return A new `Timestamp` representing the same point in time as the + * given date. + */ + static fromDate(date: Date): Timestamp; + + /** + * Creates a new timestamp from the given number of milliseconds. + * + * @param milliseconds Number of milliseconds since Unix epoch + * 1970-01-01T00:00:00Z. + * @return A new `Timestamp` representing the same point in time as the + * given number of milliseconds. + */ + static fromMillis(milliseconds: number): Timestamp; + + /** + * Creates a new timestamp. + * + * @param seconds The number of 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. + * @param nanoseconds The non-negative fractions of a second at nanosecond + * resolution. Negative second values with fractions must still have + * non-negative nanoseconds values that count forward in time. Must be from + * 0 to 999,999,999 inclusive. + */ + constructor(seconds: number, nanoseconds: number); + + /** + * The number of seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. + */ + readonly seconds: number; + + /** The non-negative fractions of a second at nanosecond resolution. */ + readonly nanoseconds: number; + + /** + * Returns a new `Date` corresponding to this timestamp. This may lose + * precision. + * + * @return JavaScript `Date` object representing the same point in time as + * this `Timestamp`, with millisecond precision. + */ + toDate(): Date; + + /** + * Returns the number of milliseconds since Unix epoch 1970-01-01T00:00:00Z. + * + * @return The point in time corresponding to this timestamp, represented as + * the number of milliseconds since Unix epoch 1970-01-01T00:00:00Z. + */ + toMillis(): number; + + /** + * Returns true if this `Timestamp` is equal to the provided one. + * + * @param other The `Timestamp` to compare against. + * @return 'true' if this `Timestamp` is equal to the provided one. + */ + isEqual(other: Timestamp): boolean; + } +} + +declare module '@google-cloud/firestore' { + export = FirebaseFirestore; +} diff --git a/website/functions/node_modules/@google-cloud/projectify/CHANGELOG.md b/website/functions/node_modules/@google-cloud/projectify/CHANGELOG.md new file mode 100644 index 00000000..e2d389f5 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/projectify/CHANGELOG.md @@ -0,0 +1,58 @@ +# Changelog + +[npm history][1] + +[1]: https://www.npmjs.com/package/@google-cloud/projectify?activeTab=versions +## v0.3.2 + +### Bug fixes +- fix: do not replace projectId on stream objects ([#53](https://github.com/googleapis/nodejs-projectify/pull/53)) + +### Dependencies +- chore(deps): update dependency gts to ^0.9.0 ([#52](https://github.com/googleapis/nodejs-projectify/pull/52)) + +### Internal / Testing Changes +- chore: update eslintignore config ([#51](https://github.com/googleapis/nodejs-projectify/pull/51)) +- chore: use latest npm on Windows ([#50](https://github.com/googleapis/nodejs-projectify/pull/50)) +- chore: update CircleCI config ([#49](https://github.com/googleapis/nodejs-projectify/pull/49)) +- chore: include build in eslintignore ([#46](https://github.com/googleapis/nodejs-projectify/pull/46)) + +## v0.3.1 + +### Implementation Changes +- fix: replaceProjectId should not fail when passed a Buffer ([#43](https://github.com/googleapis/nodejs-projectify/pull/43)) + +### Dependencies +- chore(deps): update dependency nyc to v13 ([#13](https://github.com/googleapis/nodejs-projectify/pull/13)) +- chore(deps): lock file maintenance ([#11](https://github.com/googleapis/nodejs-projectify/pull/11)) +- chore(deps): lock file maintenance ([#8](https://github.com/googleapis/nodejs-projectify/pull/8)) +- chore(deps): update dependency typescript to v3 ([#7](https://github.com/googleapis/nodejs-projectify/pull/7)) +- chore(deps): update dependency gts to ^0.8.0 ([#2](https://github.com/googleapis/nodejs-projectify/pull/2)) +- chore(deps): lock file maintenance ([#4](https://github.com/googleapis/nodejs-projectify/pull/4)) +- chore(deps): lock file maintenance ([#3](https://github.com/googleapis/nodejs-projectify/pull/3)) + +### Internal / Testing Changes +- chore: update issue templates ([#40](https://github.com/googleapis/nodejs-projectify/pull/40)) +- chore: remove old issue template ([#38](https://github.com/googleapis/nodejs-projectify/pull/38)) +- build: run tests on node11 ([#37](https://github.com/googleapis/nodejs-projectify/pull/37)) +- chores(build): run codecov on continuous builds ([#34](https://github.com/googleapis/nodejs-projectify/pull/34)) +- chores(build): do not collect sponge.xml from windows builds ([#35](https://github.com/googleapis/nodejs-projectify/pull/35)) +- chore: update new issue template ([#33](https://github.com/googleapis/nodejs-projectify/pull/33)) +- build: fix codecov uploading on Kokoro ([#30](https://github.com/googleapis/nodejs-projectify/pull/30)) +- Update kokoro config ([#28](https://github.com/googleapis/nodejs-projectify/pull/28)) +- Update CI config ([#26](https://github.com/googleapis/nodejs-projectify/pull/26)) +- Don't publish sourcemaps ([#24](https://github.com/googleapis/nodejs-projectify/pull/24)) +- build: prevent system/sample-test from leaking credentials +- Update kokoro config ([#22](https://github.com/googleapis/nodejs-projectify/pull/22)) +- test: remove appveyor config ([#21](https://github.com/googleapis/nodejs-projectify/pull/21)) +- Update CI config ([#20](https://github.com/googleapis/nodejs-projectify/pull/20)) +- Enable prefer-const in the eslint config ([#19](https://github.com/googleapis/nodejs-projectify/pull/19)) +- Enable no-var in eslint ([#18](https://github.com/googleapis/nodejs-projectify/pull/18)) +- Update CI config ([#17](https://github.com/googleapis/nodejs-projectify/pull/17)) +- Add synth and update CI config ([#15](https://github.com/googleapis/nodejs-projectify/pull/15)) +- chore: ignore package-lock.json ([#12](https://github.com/googleapis/nodejs-projectify/pull/12)) +- chore: update renovate config ([#10](https://github.com/googleapis/nodejs-projectify/pull/10)) +- remove that whitespace ([#9](https://github.com/googleapis/nodejs-projectify/pull/9)) +- chore: assert.deelEqual => assert.deepStrictEqual ([#6](https://github.com/googleapis/nodejs-projectify/pull/6)) +- chore: move mocha options to mocha.opts ([#5](https://github.com/googleapis/nodejs-projectify/pull/5)) + diff --git a/website/functions/node_modules/@google-cloud/projectify/LICENSE b/website/functions/node_modules/@google-cloud/projectify/LICENSE new file mode 100644 index 00000000..7a4a3ea2 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/projectify/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. \ No newline at end of file diff --git a/website/functions/node_modules/@google-cloud/projectify/README.md b/website/functions/node_modules/@google-cloud/projectify/README.md new file mode 100644 index 00000000..d87089ea --- /dev/null +++ b/website/functions/node_modules/@google-cloud/projectify/README.md @@ -0,0 +1,15 @@ +Google Cloud Platform logo + +# @google-cloud/projectify +> A simple utility for replacing the projectid token in objects. + +## Contributing + +Contributions welcome! See the [Contributing Guide](https://github.com/googlecloudplatform/google-cloud-node/blob/master/.github/CONTRIBUTING.md). + +## License + +Apache Version 2.0 + +See [LICENSE](https://github.com/googlecloudplatform/google-cloud-node/blob/master/LICENSE) + diff --git a/website/functions/node_modules/@google-cloud/projectify/build/src/index.d.ts b/website/functions/node_modules/@google-cloud/projectify/build/src/index.d.ts new file mode 100644 index 00000000..a08837b2 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/projectify/build/src/index.d.ts @@ -0,0 +1,31 @@ +/** + * Copyright 2014 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. + */ +/** + * Populate the `{{projectId}}` placeholder. + * + * @throws {Error} If a projectId is required, but one is not provided. + * + * @param {*} - Any input value that may contain a placeholder. Arrays and objects will be looped. + * @param {string} projectId - A projectId. If not provided + * @return {*} - The original argument with all placeholders populated. + */ +export declare function replaceProjectIdToken(value: any, projectId: string): any; +/** + * Custom error type for missing project ID errors. + */ +export declare class MissingProjectIdError extends Error { + message: string; +} diff --git a/website/functions/node_modules/@google-cloud/projectify/build/src/index.js b/website/functions/node_modules/@google-cloud/projectify/build/src/index.js new file mode 100644 index 00000000..96aa4173 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/projectify/build/src/index.js @@ -0,0 +1,64 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const stream_1 = require("stream"); +/** + * Copyright 2014 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. + */ +/** + * Populate the `{{projectId}}` placeholder. + * + * @throws {Error} If a projectId is required, but one is not provided. + * + * @param {*} - Any input value that may contain a placeholder. Arrays and objects will be looped. + * @param {string} projectId - A projectId. If not provided + * @return {*} - The original argument with all placeholders populated. + */ +// tslint:disable-next-line:no-any +function replaceProjectIdToken(value, projectId) { + if (Array.isArray(value)) { + value = value.map(v => replaceProjectIdToken(v, projectId)); + } + if (value !== null && typeof value === 'object' && + !(value instanceof Buffer) && !(value instanceof stream_1.Stream) && + typeof value.hasOwnProperty === 'function') { + for (const opt in value) { + if (value.hasOwnProperty(opt)) { + value[opt] = replaceProjectIdToken(value[opt], projectId); + } + } + } + if (typeof value === 'string' && + value.indexOf('{{projectId}}') > -1) { + if (!projectId || projectId === '{{projectId}}') { + throw new MissingProjectIdError(); + } + value = value.replace(/{{projectId}}/g, projectId); + } + return value; +} +exports.replaceProjectIdToken = replaceProjectIdToken; +/** + * Custom error type for missing project ID errors. + */ +class MissingProjectIdError extends Error { + constructor() { + super(...arguments); + this.message = `Sorry, we cannot connect to Cloud Services without a project + ID. You may specify one with an environment variable named + "GOOGLE_CLOUD_PROJECT".`.replace(/ +/g, ' '); + } +} +exports.MissingProjectIdError = MissingProjectIdError; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/website/functions/node_modules/@google-cloud/projectify/package.json b/website/functions/node_modules/@google-cloud/projectify/package.json new file mode 100644 index 00000000..4294998d --- /dev/null +++ b/website/functions/node_modules/@google-cloud/projectify/package.json @@ -0,0 +1,86 @@ +{ + "_from": "@google-cloud/projectify@^0.3.0", + "_id": "@google-cloud/projectify@0.3.2", + "_inBundle": false, + "_integrity": "sha512-t1bs5gE105IpgikX7zPCJZzVyXM5xZ/1kJomUPim2E2pNp4OUUFNyvKm/T2aM6GBP2F30o8abCD+/wbOhHWYYA==", + "_location": "/@google-cloud/projectify", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "@google-cloud/projectify@^0.3.0", + "name": "@google-cloud/projectify", + "escapedName": "@google-cloud%2fprojectify", + "scope": "@google-cloud", + "rawSpec": "^0.3.0", + "saveSpec": null, + "fetchSpec": "^0.3.0" + }, + "_requiredBy": [ + "/@google-cloud/firestore" + ], + "_resolved": "https://registry.npmjs.org/@google-cloud/projectify/-/projectify-0.3.2.tgz", + "_shasum": "ed54c98cae646dc03a742eac288184a13d33a4c2", + "_spec": "@google-cloud/projectify@^0.3.0", + "_where": "C:\\Users\\jlevi\\Downloads\\tr2022-strategy-master\\tr2022-strategy-master\\data analysis\\functions\\node_modules\\@google-cloud\\firestore", + "author": { + "name": "Google Inc." + }, + "bugs": { + "url": "https://github.com/googleapis/nodejs-projectify/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "A simple utility for replacing the projectid token in objects.", + "devDependencies": { + "@types/mocha": "^5.2.4", + "@types/node": "^10.5.2", + "codecov": "^3.0.4", + "gts": "^0.9.0", + "hard-rejection": "^1.0.0", + "intelli-espower-loader": "^1.0.1", + "mocha": "^5.2.0", + "nyc": "^13.0.0", + "source-map-support": "^0.5.6", + "typescript": "^3.0.0" + }, + "files": [ + "build/src", + "!build/src/**/*.map" + ], + "homepage": "https://github.com/googleapis/nodejs-projectify#readme", + "keywords": [], + "license": "Apache-2.0", + "main": "build/src/index.js", + "name": "@google-cloud/projectify", + "nyc": { + "exclude": [ + "build/test" + ] + }, + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/googleapis/nodejs-projectify.git" + }, + "scripts": { + "clean": "gts clean", + "codecov": "nyc report --reporter=json && codecov -f coverage/*.json", + "compile": "tsc -p .", + "docs": "echo no docs 👻", + "fix": "gts fix", + "lint": "gts check", + "posttest": "npm run lint", + "prepare": "npm run compile", + "presystem-test": "npm run compile", + "pretest": "npm run compile", + "samples-test": "cd samples/ && npm link ../ && npm test && cd ../", + "system-test": "mocha build/system-test", + "test": "npm run test-only", + "test-only": "nyc mocha build/test" + }, + "types": "build/src/index.d.ts", + "version": "0.3.2" +} diff --git a/website/functions/node_modules/@google-cloud/storage/CONTRIBUTORS b/website/functions/node_modules/@google-cloud/storage/CONTRIBUTORS new file mode 100644 index 00000000..883c5b4a --- /dev/null +++ b/website/functions/node_modules/@google-cloud/storage/CONTRIBUTORS @@ -0,0 +1,26 @@ +# The names of individuals who have contributed to this project. +# +# Names are formatted as: +# name +# +Ace Nassri +Alexander Borovykh +Alexander Fenster +Calvin Metcalf +Colin Ihrig +Cristian Almstrand +Dave Gramlich +Dominic Valenciana +Eric Uldall +Ernest Landrito +Frank Natividad +Jason Dobry +Jason Dobry +Justin Sprigg +Luke Sneeringer +Stephen +Stephen Sawchuk +Stephen Sawchuk +Tyler Johnson +Zach Bjornson +greenkeeper[bot] diff --git a/website/functions/node_modules/@google-cloud/storage/LICENSE b/website/functions/node_modules/@google-cloud/storage/LICENSE new file mode 100644 index 00000000..7a4a3ea2 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/storage/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. \ No newline at end of file diff --git a/website/functions/node_modules/@google-cloud/storage/README.md b/website/functions/node_modules/@google-cloud/storage/README.md new file mode 100644 index 00000000..5728fc6d --- /dev/null +++ b/website/functions/node_modules/@google-cloud/storage/README.md @@ -0,0 +1,134 @@ +Google Cloud Platform logo + +# [Google Cloud Storage: Node.js Client](https://github.com/googleapis/nodejs-storage) + +[![release level](https://img.shields.io/badge/release%20level-general%20availability%20%28GA%29-brightgreen.svg?style=flat)](https://cloud.google.com/terms/launch-stages) +[![CircleCI](https://img.shields.io/circleci/project/github/googleapis/nodejs-storage.svg?style=flat)](https://circleci.com/gh/googleapis/nodejs-storage) +[![AppVeyor](https://ci.appveyor.com/api/projects/status/github/googleapis/nodejs-storage?branch=master&svg=true)](https://ci.appveyor.com/project/googleapis/nodejs-storage) +[![codecov](https://img.shields.io/codecov/c/github/googleapis/nodejs-storage/master.svg?style=flat)](https://codecov.io/gh/googleapis/nodejs-storage) + +> Node.js idiomatic client for [Cloud Storage][product-docs]. + +[Cloud Storage](https://cloud.google.com/storage/docs) allows world-wide storage and retrieval of any amount of data at any time. You can use Google Cloud Storage for a range of scenarios including serving website content, storing data for archival and disaster recovery, or distributing large data objects to users via direct download. + + +* [Cloud Storage Node.js Client API Reference][client-docs] +* [github.com/googleapis/nodejs-storage](https://github.com/googleapis/nodejs-storage) +* [Cloud Storage Documentation][product-docs] + +Read more about the client libraries for Cloud APIs, including the older +Google APIs Client Libraries, in [Client Libraries Explained][explained]. + +[explained]: https://cloud.google.com/apis/docs/client-libraries-explained + +**Table of contents:** + +* [Quickstart](#quickstart) + * [Before you begin](#before-you-begin) + * [Installing the client library](#installing-the-client-library) + * [Using the client library](#using-the-client-library) +* [Samples](#samples) +* [Versioning](#versioning) +* [Contributing](#contributing) +* [License](#license) + +## Quickstart + +### Before you begin + +1. Select or create a Cloud Platform project. + + [Go to the projects page][projects] + +1. Enable billing for your project. + + [Enable billing][billing] + +1. Enable the Google Cloud Storage API. + + [Enable the API][enable_api] + +1. [Set up authentication with a service account][auth] so you can access the + API from your local workstation. + +[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=storage-api.googleapis.com +[auth]: https://cloud.google.com/docs/authentication/getting-started + +### Installing the client library + + npm install --save @google-cloud/storage + +### Using the client library + +```javascript +// Imports the Google Cloud client library +const Storage = require('@google-cloud/storage'); + +// Your Google Cloud Platform project ID +const projectId = 'YOUR_PROJECT_ID'; + +// Creates a client +const storage = new Storage({ + projectId: projectId, +}); + +// The name for the new bucket +const bucketName = 'my-new-bucket'; + +// Creates the new bucket +storage + .createBucket(bucketName) + .then(() => { + console.log(`Bucket ${bucketName} created.`); + }) + .catch(err => { + console.error('ERROR:', err); + }); +``` + +## Samples + +Samples are in the [`samples/`](https://github.com/googleapis/nodejs-storage/tree/master/samples) directory. The samples' `README.md` +has instructions for running the samples. + +| Sample | Source Code | Try it | +| --------------------------- | --------------------------------- | ------ | +| ACL (Access Control Lists) | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/acl.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/acl.js,samples/README.md) | +| Buckets | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/buckets.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/buckets.js,samples/README.md) | +| Encryption | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/encryption.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/encryption.js,samples/README.md) | +| Files | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/files.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/files.js,samples/README.md) | +| Notifications | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/notifications.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/notifications.js,samples/README.md) | +| Requester Pays | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/requesterPays.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/requesterPays.js,samples/README.md) | + +The [Cloud Storage Node.js Client API Reference][client-docs] documentation +also contains samples. + +## Versioning + +This library follows [Semantic Versioning](http://semver.org/). + +This library is considered to be **General Availability (GA)**. This means it +is stable; the code surface will not change in backwards-incompatible ways +unless absolutely necessary (e.g. because of critical security issues) or with +an extensive deprecation period. Issues and requests against **GA** libraries +are addressed with the highest priority. + +More Information: [Google Cloud Platform Launch Stages][launch_stages] + +[launch_stages]: https://cloud.google.com/terms/launch-stages + +## Contributing + +Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/nodejs-storage/blob/master/.github/CONTRIBUTING.md). + +## License + +Apache Version 2.0 + +See [LICENSE](https://github.com/googleapis/nodejs-storage/blob/master/LICENSE) + +[client-docs]: https://cloud.google.com/nodejs/docs/reference/storage/latest/ +[product-docs]: https://cloud.google.com/storage/docs +[shell_img]: //gstatic.com/cloudssh/images/open-btn.png diff --git a/website/functions/node_modules/@google-cloud/storage/package.json b/website/functions/node_modules/@google-cloud/storage/package.json new file mode 100644 index 00000000..6f8bae6d --- /dev/null +++ b/website/functions/node_modules/@google-cloud/storage/package.json @@ -0,0 +1,209 @@ +{ + "_from": "@google-cloud/storage@^1.6.0", + "_id": "@google-cloud/storage@1.7.0", + "_inBundle": false, + "_integrity": "sha512-QaAxzCkbhspwajoaEnT0GcnQcpjPRcBrHYuQsXtD05BtOJgVnHCLXSsfUiRdU0nVpK+Thp7+sTkQ0fvk5PanKg==", + "_location": "/@google-cloud/storage", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "@google-cloud/storage@^1.6.0", + "name": "@google-cloud/storage", + "escapedName": "@google-cloud%2fstorage", + "scope": "@google-cloud", + "rawSpec": "^1.6.0", + "saveSpec": null, + "fetchSpec": "^1.6.0" + }, + "_requiredBy": [ + "/firebase-admin" + ], + "_resolved": "https://registry.npmjs.org/@google-cloud/storage/-/storage-1.7.0.tgz", + "_shasum": "07bff573d92d5c294db6a04af246688875a8f74b", + "_spec": "@google-cloud/storage@^1.6.0", + "_where": "C:\\Users\\jlevi\\Downloads\\tr2022-strategy-master\\tr2022-strategy-master\\data analysis\\functions\\node_modules\\firebase-admin", + "author": { + "name": "Google Inc." + }, + "bugs": { + "url": "https://github.com/googleapis/nodejs-storage/issues" + }, + "bundleDependencies": false, + "contributors": [ + { + "name": "Ace Nassri", + "email": "anassri@google.com" + }, + { + "name": "Alexander Borovykh", + "email": "immaculate.pine@gmail.com" + }, + { + "name": "Alexander Fenster", + "email": "github@fenster.name" + }, + { + "name": "Calvin Metcalf", + "email": "calvin.metcalf@gmail.com" + }, + { + "name": "Colin Ihrig", + "email": "cjihrig@gmail.com" + }, + { + "name": "Cristian Almstrand", + "email": "almstrand@users.noreply.github.com" + }, + { + "name": "Dave Gramlich", + "email": "callmehiphop@gmail.com" + }, + { + "name": "Dominic Valenciana", + "email": "kiricon@live.com" + }, + { + "name": "Eric Uldall", + "email": "ericuldall@gmail.com" + }, + { + "name": "Ernest Landrito", + "email": "landrito@google.com" + }, + { + "name": "Frank Natividad", + "email": "frankyn@users.noreply.github.com" + }, + { + "name": "Jason Dobry", + "email": "jason.dobry@gmail.com" + }, + { + "name": "Jason Dobry", + "email": "jmdobry@users.noreply.github.com" + }, + { + "name": "Justin Sprigg", + "email": "justin.sprigg@gmail.com" + }, + { + "name": "Luke Sneeringer", + "email": "luke@sneeringer.com" + }, + { + "name": "Stephen", + "email": "stephenplusplus@users.noreply.github.com" + }, + { + "name": "Stephen Sawchuk", + "email": "sawchuk@gmail.com" + }, + { + "name": "Stephen Sawchuk", + "email": "stephenplusplus@users.noreply.github.com" + }, + { + "name": "Tyler Johnson", + "email": "mail@tyler-johnson.ca" + }, + { + "name": "Zach Bjornson", + "email": "bjornson@stanford.edu" + }, + { + "name": "greenkeeper[bot]", + "email": "greenkeeper[bot]@users.noreply.github.com" + } + ], + "dependencies": { + "@google-cloud/common": "^0.17.0", + "arrify": "^1.0.0", + "async": "^2.0.1", + "compressible": "^2.0.12", + "concat-stream": "^1.5.0", + "create-error-class": "^3.0.2", + "duplexify": "^3.5.0", + "extend": "^3.0.0", + "gcs-resumable-upload": "^0.10.2", + "hash-stream-validation": "^0.2.1", + "is": "^3.0.1", + "mime": "^2.2.0", + "mime-types": "^2.0.8", + "once": "^1.3.1", + "pumpify": "^1.5.1", + "request": "^2.85.0", + "safe-buffer": "^5.1.1", + "snakeize": "^0.1.0", + "stream-events": "^1.0.1", + "through2": "^2.0.0", + "xdg-basedir": "^3.0.0" + }, + "deprecated": false, + "description": "Cloud Storage Client Library for Node.js", + "devDependencies": { + "@google-cloud/nodejs-repo-tools": "^2.2.3", + "@google-cloud/pubsub": "*", + "codecov": "^3.0.0", + "eslint": "^4.7.1", + "eslint-config-prettier": "^2.5.0", + "eslint-plugin-node": "^6.0.0", + "eslint-plugin-prettier": "^2.3.1", + "ink-docstrap": "https://github.com/docstrap/docstrap/tarball/master", + "intelli-espower-loader": "^1.0.1", + "jsdoc": "^3.5.4", + "mocha": "^5.0.0", + "normalize-newline": "^3.0.0", + "nyc": "^11.1.0", + "power-assert": "^1.4.4", + "prettier": "^1.7.0", + "prop-assign": "^1.0.0", + "propprop": "^0.3.0", + "proxyquire": "^2.0.0", + "semistandard": "^12.0.0", + "tmp": "^0.0.33", + "uuid": "^3.1.0" + }, + "engines": { + "node": ">=4" + }, + "files": [ + "src", + "AUTHORS", + "CONTRIBUTORS", + "COPYING" + ], + "homepage": "https://github.com/googleapis/nodejs-storage#readme", + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google storage", + "storage" + ], + "license": "Apache-2.0", + "main": "./src/index.js", + "name": "@google-cloud/storage", + "repository": { + "type": "git", + "url": "git+https://github.com/googleapis/nodejs-storage.git" + }, + "scripts": { + "all-test": "npm test && npm run system-test && npm run samples-test", + "cover": "nyc --reporter=lcov mocha --require intelli-espower-loader test/*.js && nyc report", + "docs": "repo-tools exec -- jsdoc -c .jsdoc.js", + "generate-scaffolding": "repo-tools generate all && repo-tools generate lib_samples_readme -l samples/ --config ../.cloud-repo-tools.json", + "lint": "repo-tools lint --cmd eslint -- src/ samples/ system-test/ test/", + "prettier": "repo-tools exec -- prettier --write src/**/*.js samples/*.js samples/**/*.js system-test/**/*.js test/**/*.js", + "samples-test": "npm link && cd samples/ && npm link @google-cloud/storage && npm test && cd ../", + "system-test": "repo-tools test run --cmd mocha -- system-test/ --timeout 600000", + "test": "repo-tools test run --cmd npm -- run cover", + "test-no-cover": "repo-tools test run --cmd mocha -- test/" + }, + "version": "1.7.0" +} diff --git a/website/functions/node_modules/@google-cloud/storage/src/acl.js b/website/functions/node_modules/@google-cloud/storage/src/acl.js new file mode 100644 index 00000000..83600e04 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/storage/src/acl.js @@ -0,0 +1,766 @@ +/*! + * Copyright 2014 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. + */ + +'use strict'; + +const arrify = require('arrify'); +const common = require('@google-cloud/common'); +const extend = require('extend'); +const is = require('is'); +const util = require('util'); + +/** + * Cloud Storage uses access control lists (ACLs) to manage object and + * bucket access. ACLs are the mechanism you use to share objects with other + * users and allow other users to access your buckets and objects. + * + * An ACL consists of one or more entries, where each entry grants permissions + * to an entity. Permissions define the actions that can be performed against an + * object or bucket (for example, `READ` or `WRITE`); the entity defines who the + * permission applies to (for example, a specific user or group of users). + * + * Where an `entity` value is accepted, we follow the format the Cloud Storage + * API expects. + * + * Refer to + * https://cloud.google.com/storage/docs/json_api/v1/defaultObjectAccessControls + * for the most up-to-date values. + * + * - `user-userId` + * - `user-email` + * - `group-groupId` + * - `group-email` + * - `domain-domain` + * - `project-team-projectId` + * - `allUsers` + * - `allAuthenticatedUsers` + * + * Examples: + * + * - The user "liz@example.com" would be `user-liz@example.com`. + * - The group "example@googlegroups.com" would be + * `group-example@googlegroups.com`. + * - To refer to all members of the Google Apps for Business domain + * "example.com", the entity would be `domain-example.com`. + * + * For more detailed information, see + * [About Access Control Lists](http://goo.gl/6qBBPO). + * + * @constructor Acl + * @mixin + * @param {object} options Configuration options. + */ +function Acl(options) { + AclRoleAccessorMethods.call(this); + + this.pathPrefix = options.pathPrefix; + this.request_ = options.request; +} + +/** + * An object of convenience methods to add or delete owner ACL permissions for a + * given entity. + * + * The supported methods include: + * + * - `myFile.acl.owners.addAllAuthenticatedUsers` + * - `myFile.acl.owners.deleteAllAuthenticatedUsers` + * - `myFile.acl.owners.addAllUsers` + * - `myFile.acl.owners.deleteAllUsers` + * - `myFile.acl.owners.addDomain` + * - `myFile.acl.owners.deleteDomain` + * - `myFile.acl.owners.addGroup` + * - `myFile.acl.owners.deleteGroup` + * - `myFile.acl.owners.addProject` + * - `myFile.acl.owners.deleteProject` + * - `myFile.acl.owners.addUser` + * - `myFile.acl.owners.deleteUser` + * + * @return {object} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * const myFile = myBucket.file('my-file'); + * + * //- + * // Add a user as an owner of a file. + * //- + * const myBucket = gcs.bucket('my-bucket'); + * const myFile = myBucket.file('my-file'); + * myFile.acl.owners.addUser('email@example.com', function(err, aclObject) {}); + * + * //- + * // For reference, the above command is the same as running the following. + * //- + * myFile.acl.add({ + * entity: 'user-email@example.com', + * role: gcs.acl.OWNER_ROLE + * }, function(err, aclObject) {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * myFile.acl.owners.addUser('email@example.com').then(function(data) { + * const aclObject = data[0]; + * const apiResponse = data[1]; + * }); + */ +Acl.prototype.owners = {}; + +/** + * An object of convenience methods to add or delete reader ACL permissions for + * a given entity. + * + * The supported methods include: + * + * - `myFile.acl.readers.addAllAuthenticatedUsers` + * - `myFile.acl.readers.deleteAllAuthenticatedUsers` + * - `myFile.acl.readers.addAllUsers` + * - `myFile.acl.readers.deleteAllUsers` + * - `myFile.acl.readers.addDomain` + * - `myFile.acl.readers.deleteDomain` + * - `myFile.acl.readers.addGroup` + * - `myFile.acl.readers.deleteGroup` + * - `myFile.acl.readers.addProject` + * - `myFile.acl.readers.deleteProject` + * - `myFile.acl.readers.addUser` + * - `myFile.acl.readers.deleteUser` + * + * @return {object} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * const myFile = myBucket.file('my-file'); + * + * //- + * // Add a user as a reader of a file. + * //- + * myFile.acl.readers.addUser('email@example.com', function(err, aclObject) {}); + * + * //- + * // For reference, the above command is the same as running the following. + * //- + * myFile.acl.add({ + * entity: 'user-email@example.com', + * role: gcs.acl.READER_ROLE + * }, function(err, aclObject) {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * myFile.acl.readers.addUser('email@example.com').then(function(data) { + * const aclObject = data[0]; + * const apiResponse = data[1]; + * }); + */ +Acl.prototype.readers = {}; + +/** + * An object of convenience methods to add or delete writer ACL permissions for + * a given entity. + * + * The supported methods include: + * + * - `myFile.acl.writers.addAllAuthenticatedUsers` + * - `myFile.acl.writers.deleteAllAuthenticatedUsers` + * - `myFile.acl.writers.addAllUsers` + * - `myFile.acl.writers.deleteAllUsers` + * - `myFile.acl.writers.addDomain` + * - `myFile.acl.writers.deleteDomain` + * - `myFile.acl.writers.addGroup` + * - `myFile.acl.writers.deleteGroup` + * - `myFile.acl.writers.addProject` + * - `myFile.acl.writers.deleteProject` + * - `myFile.acl.writers.addUser` + * - `myFile.acl.writers.deleteUser` + * + * @return {object} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * const myFile = myBucket.file('my-file'); + * + * //- + * // Add a user as a writer of a file. + * //- + * myFile.acl.writers.addUser('email@example.com', function(err, aclObject) {}); + * + * //- + * // For reference, the above command is the same as running the following. + * //- + * myFile.acl.add({ + * entity: 'user-email@example.com', + * role: gcs.acl.WRITER_ROLE + * }, function(err, aclObject) {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * myFile.acl.writers.addUser('email@example.com').then(function(data) { + * const aclObject = data[0]; + * const apiResponse = data[1]; + * }); + */ +Acl.prototype.writers = {}; + +util.inherits(Acl, AclRoleAccessorMethods); + +/** + * @typedef {array} AddAclResponse + * @property {object} 0 The Acl Objects. + * @property {object} 1 The full API response. + */ +/** + * @callback AddAclCallback + * @param {?Error} err Request error, if any. + * @param {object} acl The Acl Objects. + * @param {object} apiResponse The full API response. + */ +/** + * Add access controls on a {@link Bucket} or {@link File}. + * + * @see [BucketAccessControls: insert API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/bucketAccessControls/insert} + * @see [ObjectAccessControls: insert API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/objectAccessControls/insert} + * + * @param {object} options Configuration options. + * @param {string} options.entity Whose permissions will be added. + * @param {string} options.role Permissions allowed for the defined entity. + * See {@link https://cloud.google.com/storage/docs/access-control Access Control}. + * @param {number} [options.generation] **File Objects Only** Select a specific + * revision of this file (as opposed to the latest version, the default). + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {AddAclCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * const myFile = myBucket.file('my-file'); + * + * const options = { + * entity: 'user-useremail@example.com', + * role: gcs.acl.OWNER_ROLE + * }; + * + * myBucket.acl.add(options, function(err, aclObject, apiResponse) {}); + * + * //- + * // For file ACL operations, you can also specify a `generation` property. + * // Here is how you would grant ownership permissions to a user on a specific + * // revision of a file. + * //- + * myFile.acl.add({ + * entity: 'user-useremail@example.com', + * role: gcs.acl.OWNER_ROLE, + * generation: 1 + * }, function(err, aclObject, apiResponse) {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * myBucket.acl.add(options).then(function(data) { + * const aclObject = data[0]; + * const apiResponse = data[1]; + * }); + * + * @example include:samples/acl.js + * region_tag:storage_add_file_owner + * Example of adding an owner to a file: + * + * @example include:samples/acl.js + * region_tag:storage_add_bucket_owner + * Example of adding an owner to a bucket: + * + * @example include:samples/acl.js + * region_tag:storage_add_bucket_default_owner + * Example of adding a default owner to a bucket: + */ +Acl.prototype.add = function(options, callback) { + const self = this; + + const query = {}; + + if (options.generation) { + query.generation = options.generation; + } + + if (options.userProject) { + query.userProject = options.userProject; + } + + this.request( + { + method: 'POST', + uri: '', + qs: query, + json: { + entity: options.entity, + role: options.role.toUpperCase(), + }, + }, + function(err, resp) { + if (err) { + callback(err, null, resp); + return; + } + + callback(null, self.makeAclObject_(resp), resp); + } + ); +}; + +/** + * @typedef {array} RemoveAclResponse + * @property {object} 0 The full API response. + */ +/** + * @callback RemoveAclCallback + * @param {?Error} err Request error, if any. + * @param {object} apiResponse The full API response. + */ +/** + * Delete access controls on a {@link Bucket} or {@link File}. + * + * @see [BucketAccessControls: delete API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/bucketAccessControls/delete} + * @see [ObjectAccessControls: delete API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/objectAccessControls/delete} + * + * @param {object} options Configuration object. + * @param {string} options.entity Whose permissions will be revoked. + * @param {int} [options.generation] **File Objects Only** Select a specific + * revision of this file (as opposed to the latest version, the default). + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {RemoveAclCallback} callback The callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * const myFile = myBucket.file('my-file'); + * + * myBucket.acl.delete({ + * entity: 'user-useremail@example.com' + * }, function(err, apiResponse) {}); + * + * //- + * // For file ACL operations, you can also specify a `generation` property. + * //- + * myFile.acl.delete({ + * entity: 'user-useremail@example.com', + * generation: 1 + * }, function(err, apiResponse) {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * myFile.acl.delete().then(function(data) { + * const apiResponse = data[0]; + * }); + * + * @example include:samples/acl.js + * region_tag:storage_remove_bucket_owner + * Example of removing an owner from a bucket: + * + * @example include:samples/acl.js + * region_tag:storage_remove_bucket_default_owner + * Example of removing a default owner from a bucket: + * + * @example include:samples/acl.js + * region_tag:storage_remove_file_owner + * Example of removing an owner from a bucket: + */ +Acl.prototype.delete = function(options, callback) { + const query = {}; + + if (options.generation) { + query.generation = options.generation; + } + + if (options.userProject) { + query.userProject = options.userProject; + } + + this.request( + { + method: 'DELETE', + uri: '/' + encodeURIComponent(options.entity), + qs: query, + }, + function(err, resp) { + callback(err, resp); + } + ); +}; + +/** + * @typedef {array} GetAclResponse + * @property {object|object[]} 0 Single or array of Acl Objects. + * @property {object} 1 The full API response. + */ +/** + * @callback GetAclCallback + * @param {?Error} err Request error, if any. + * @param {object|object[]} acl Single or array of Acl Objects. + * @param {object} apiResponse The full API response. + */ +/** + * Get access controls on a {@link Bucket} or {@link File}. If + * an entity is omitted, you will receive an array of all applicable access + * controls. + * + * @see [BucketAccessControls: get API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/bucketAccessControls/get} + * @see [ObjectAccessControls: get API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/objectAccessControls/get} + * + * @param {object|function} [options] Configuration options. If you want to + * receive a list of all access controls, pass the callback function as the + * only argument. + * @param {string} [options.entity] Whose permissions will be fetched. + * @param {number} [options.generation] **File Objects Only** Select a specific + * revision of this file (as opposed to the latest version, the default). + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {GetAclCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * const myFile = myBucket.file('my-file'); + * + * myBucket.acl.get({ + * entity: 'user-useremail@example.com' + * }, function(err, aclObject, apiResponse) {}); + * + * //- + * // Get all access controls. + * //- + * myBucket.acl.get(function(err, aclObjects, apiResponse) { + * // aclObjects = [ + * // { + * // entity: 'user-useremail@example.com', + * // role: 'owner' + * // } + * // ] + * }); + * + * //- + * // For file ACL operations, you can also specify a `generation` property. + * //- + * myFile.acl.get({ + * entity: 'user-useremail@example.com', + * generation: 1 + * }, function(err, aclObject, apiResponse) {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * myBucket.acl.get().then(function(data) { + * const aclObject = data[0]; + * const apiResponse = data[1]; + * }); + * + * @example include:samples/acl.js + * region_tag:storage_print_file_acl + * Example of printing a file's ACL: + * + * @example include:samples/acl.js + * region_tag:storage_print_file_acl_for_user + * Example of printing a file's ACL for a specific user: + * + * @example include:samples/acl.js + * region_tag:storage_print_bucket_acl + * Example of printing a bucket's ACL: + * + * @example include:samples/acl.js + * region_tag:storage_print_bucket_acl_for_user + * Example of printing a bucket's ACL for a specific user: + */ +Acl.prototype.get = function(options, callback) { + const self = this; + let path = ''; + const query = {}; + + if (is.fn(options)) { + callback = options; + options = null; + } else { + path = '/' + encodeURIComponent(options.entity); + + if (options.generation) { + query.generation = options.generation; + } + + if (options.userProject) { + query.userProject = options.userProject; + } + } + + this.request( + { + uri: path, + qs: query, + }, + function(err, resp) { + if (err) { + callback(err, null, resp); + return; + } + + let results; + + if (resp.items) { + results = arrify(resp.items).map(self.makeAclObject_); + } else { + results = self.makeAclObject_(resp); + } + + callback(null, results, resp); + } + ); +}; + +/** + * @typedef {array} UpdateAclResponse + * @property {object} 0 The updated Acl Objects. + * @property {object} 1 The full API response. + */ +/** + * @callback UpdateAclCallback + * @param {?Error} err Request error, if any. + * @param {object} acl The updated Acl Objects. + * @param {object} apiResponse The full API response. + */ +/** + * Update access controls on a {@link Bucket} or {@link File}. + * + * @see [BucketAccessControls: update API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/bucketAccessControls/update} + * @see [ObjectAccessControls: update API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/objectAccessControls/update} + * + * @param {object} options Configuration options. + * @param {string} options.entity Whose permissions will be updated. + * @param {string} options.role Permissions allowed for the defined entity. + * See {@link Storage.acl}. + * @param {number} [options.generation] **File Objects Only** Select a specific + * revision of this file (as opposed to the latest version, the default). + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {UpdateAclCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * const myFile = myBucket.file('my-file'); + * + * const options = { + * entity: 'user-useremail@example.com', + * role: gcs.acl.WRITER_ROLE + * }; + * + * myBucket.acl.update(options, function(err, aclObject, apiResponse) {}); + * + * //- + * // For file ACL operations, you can also specify a `generation` property. + * //- + * myFile.acl.update({ + * entity: 'user-useremail@example.com', + * role: gcs.acl.WRITER_ROLE, + * generation: 1 + * }, function(err, aclObject, apiResponse) {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * myFile.acl.update(options).then(function(data) { + * const aclObject = data[0]; + * const apiResponse = data[1]; + * }); + */ +Acl.prototype.update = function(options, callback) { + const self = this; + + const query = {}; + + if (options.generation) { + query.generation = options.generation; + } + + if (options.userProject) { + query.userProject = options.userProject; + } + + this.request( + { + method: 'PUT', + uri: '/' + encodeURIComponent(options.entity), + qs: query, + json: { + role: options.role.toUpperCase(), + }, + }, + function(err, resp) { + if (err) { + callback(err, null, resp); + return; + } + + callback(null, self.makeAclObject_(resp), resp); + } + ); +}; + +/** + * Transform API responses to a consistent object format. + * + * @private + */ +Acl.prototype.makeAclObject_ = function(accessControlObject) { + const obj = { + entity: accessControlObject.entity, + role: accessControlObject.role, + }; + + if (accessControlObject.projectTeam) { + obj.projectTeam = accessControlObject.projectTeam; + } + + return obj; +}; + +/** + * Patch requests up to the bucket's request object. + * + * @private + * + * @param {string} method Action. + * @param {string} path Request path. + * @param {*} query Request query object. + * @param {*} body Request body contents. + * @param {function} callback Callback function. + */ +Acl.prototype.request = function(reqOpts, callback) { + reqOpts.uri = this.pathPrefix + reqOpts.uri; + this.request_(reqOpts, callback); +}; + +/*! Developer Documentation + * + * All async methods (except for streams) will return a Promise in the event + * that a callback is omitted. + */ +common.util.promisifyAll(Acl); + +module.exports = Acl; + +/** + * Attach functionality to a {@link Storage.acl} instance. This will add an + * object for each role group (owners, readers, and writers), with each object + * containing methods to add or delete a type of entity. + * + * As an example, here are a few methods that are created. + * + * myBucket.acl.readers.deleteGroup('groupId', function(err) {}); + * + * myBucket.acl.owners.addUser('email@example.com', function(err, acl) {}); + * + * myBucket.acl.writers.addDomain('example.com', function(err, acl) {}); + * + * @private + */ +function AclRoleAccessorMethods() { + AclRoleAccessorMethods.roles.forEach(this._assignAccessMethods.bind(this)); +} + +AclRoleAccessorMethods.accessMethods = ['add', 'delete']; + +AclRoleAccessorMethods.entities = [ + // Special entity groups that do not require further specification. + 'allAuthenticatedUsers', + 'allUsers', + + // Entity groups that require specification, e.g. `user-email@example.com`. + 'domain-', + 'group-', + 'project-', + 'user-', +]; + +AclRoleAccessorMethods.roles = ['OWNER', 'READER', 'WRITER']; + +AclRoleAccessorMethods.prototype._assignAccessMethods = function(role) { + const self = this; + + const accessMethods = AclRoleAccessorMethods.accessMethods; + const entities = AclRoleAccessorMethods.entities; + const roleGroup = role.toLowerCase() + 's'; + + this[roleGroup] = entities.reduce(function(acc, entity) { + const isPrefix = entity.charAt(entity.length - 1) === '-'; + + accessMethods.forEach(function(accessMethod) { + let method = accessMethod + entity[0].toUpperCase() + entity.substr(1); + + if (isPrefix) { + method = method.replace('-', ''); + } + + // Wrap the parent accessor method (e.g. `add` or `delete`) to avoid the + // more complex API of specifying an `entity` and `role`. + acc[method] = function(entityId, options, callback) { + let apiEntity; + + if (is.fn(options)) { + callback = options; + options = {}; + } + + if (isPrefix) { + apiEntity = entity + entityId; + } else { + // If the entity is not a prefix, it is a special entity group that + // does not require further details. The accessor methods only accept + // a callback. + apiEntity = entity; + callback = entityId; + } + + options = extend( + { + entity: apiEntity, + role: role, + }, + options + ); + + const args = [options]; + + if (is.fn(callback)) { + args.push(callback); + } + + return self[accessMethod].apply(self, args); + }; + }); + + return acc; + }, {}); +}; + +module.exports.AclRoleAccessorMethods = AclRoleAccessorMethods; diff --git a/website/functions/node_modules/@google-cloud/storage/src/bucket.js b/website/functions/node_modules/@google-cloud/storage/src/bucket.js new file mode 100644 index 00000000..f0c84196 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/storage/src/bucket.js @@ -0,0 +1,2458 @@ +/** + * Copyright 2014-2017 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. + */ + +'use strict'; + +const arrify = require('arrify'); +const async = require('async'); +const common = require('@google-cloud/common'); +const extend = require('extend'); +const fs = require('fs'); +const is = require('is'); +const mime = require('mime-types'); +const path = require('path'); +const snakeize = require('snakeize'); +const util = require('util'); +const request = require('request'); + +const Acl = require('./acl.js'); +const File = require('./file.js'); +const Iam = require('./iam.js'); +const Notification = require('./notification.js'); + +/** + * The size of a file (in bytes) must be greater than this number to + * automatically trigger a resumable upload. + * + * @const {number} + * @private + */ +const RESUMABLE_THRESHOLD = 5000000; + +/** + * Create a Bucket object to interact with a Cloud Storage bucket. + * + * @class + * @hideconstructor + * + * @param {Storage} storage A {@link Storage} instance. + * @param {string} name The name of the bucket. + * @param {object} [options] Configuration object. + * @param {string} [options.userProject] User project. + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('albums'); + */ +function Bucket(storage, name, options) { + options = options || {}; + + name = name.replace(/^gs:\/\//, ''); + + const methods = { + /** + * Create a bucket. + * + * @method Bucket#create + * @param {CreateBucketRequest} [metadata] Metadata to set for the bucket. + * @param {CreateBucketCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('albums'); + * bucket.create(function(err, bucket, apiResponse) { + * if (!err) { + * // The bucket was created successfully. + * } + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * bucket.create().then(function(data) { + * const bucket = data[0]; + * const apiResponse = data[1]; + * }); + */ + create: true, + }; + + common.ServiceObject.call(this, { + parent: storage, + baseUrl: '/b', + id: name, + createMethod: storage.createBucket.bind(storage), + methods: methods, + }); + + /** + * The bucket's name. + * @name Bucket#name + * @type {string} + */ + this.name = name; + /** + * A reference to the {@link Storage} associated with this {@link Bucket} + * instance. + * @name Bucket#storage + * @type {string} + */ + this.storage = storage; + + /** + * A user project to apply to each request from this bucket. + * @name Bucket#userProject + * @type {string} + */ + this.userProject = options.userProject; + + /** + * Cloud Storage uses access control lists (ACLs) to manage object and + * bucket access. ACLs are the mechanism you use to share objects with other + * users and allow other users to access your buckets and objects. + * + * An ACL consists of one or more entries, where each entry grants permissions + * to an entity. Permissions define the actions that can be performed against + * an object or bucket (for example, `READ` or `WRITE`); the entity defines + * who the permission applies to (for example, a specific user or group of + * users). + * + * The `acl` object on a Bucket instance provides methods to get you a list of + * the ACLs defined on your bucket, as well as set, update, and delete them. + * + * Buckets also have + * [default ACLs](https://cloud.google.com/storage/docs/access-control/lists#default) + * for all created files. Default ACLs specify permissions that all new + * objects added to the bucket will inherit by default. You can add, delete, + * get, and update entities and permissions for these as well with + * {@link Bucket#acl.default}. + * + * @see [About Access Control Lists]{@link http://goo.gl/6qBBPO} + * @see [Default ACLs]{@link https://cloud.google.com/storage/docs/access-control/lists#default} + * + * @name Bucket#acl + * @mixes Acl + * @property {Acl} default Cloud Storage Buckets have + * [default ACLs](https://cloud.google.com/storage/docs/access-control/lists#default) + * for all created files. You can add, delete, get, and update entities and + * permissions for these as well. The method signatures and examples are all + * the same, after only prefixing the method call with `default`. + * + * @example + * const storage = require('@google-cloud/storage')(); + * + * //- + * // Make a bucket's contents publicly readable. + * //- + * const myBucket = storage.bucket('my-bucket'); + * + * const options = { + * entity: 'allUsers', + * role: storage.acl.READER_ROLE + * }; + * + * myBucket.acl.add(options, function(err, aclObject) {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * myBucket.acl.add(options).then(function(data) { + * const aclObject = data[0]; + * const apiResponse = data[1]; + * }); + * + * @example include:samples/acl.js + * region_tag:storage_print_bucket_acl + * Example of printing a bucket's ACL: + * + * @example include:samples/acl.js + * region_tag:storage_print_bucket_acl_for_user + * Example of printing a bucket's ACL for a specific user: + * + * @example include:samples/acl.js + * region_tag:storage_add_bucket_owner + * Example of adding an owner to a bucket: + * + * @example include:samples/acl.js + * region_tag:storage_remove_bucket_owner + * Example of removing an owner from a bucket: + * + * @example include:samples/acl.js + * region_tag:storage_add_bucket_default_owner + * Example of adding a default owner to a bucket: + * + * @example include:samples/acl.js + * region_tag:storage_remove_bucket_default_owner + * Example of removing a default owner from a bucket: + */ + this.acl = new Acl({ + request: this.request.bind(this), + pathPrefix: '/acl', + }); + + this.acl.default = new Acl({ + request: this.request.bind(this), + pathPrefix: '/defaultObjectAcl', + }); + + /** + * Get and set IAM policies for your bucket. + * + * @name Bucket#iam + * @mixes Iam + * + * @see [Cloud Storage IAM Management](https://cloud.google.com/storage/docs/access-control/iam#short_title_iam_management) + * @see [Granting, Changing, and Revoking Access](https://cloud.google.com/iam/docs/granting-changing-revoking-access) + * @see [IAM Roles](https://cloud.google.com/iam/docs/understanding-roles) + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('albums'); + * + * //- + * // Get the IAM policy for your bucket. + * //- + * bucket.iam.getPolicy(function(err, policy) { + * console.log(policy); + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * bucket.iam.getPolicy().then(function(data) { + * const policy = data[0]; + * const apiResponse = data[1]; + * }); + * + * @example include:samples/iam.js + * region_tag:storage_view_bucket_iam_members + * Example of retrieving a bucket's IAM policy: + * + * @example include:samples/iam.js + * region_tag:storage_add_bucket_iam_member + * Example of adding to a bucket's IAM policy: + * + * @example include:samples/iam.js + * region_tag:storage_remove_bucket_iam_member + * Example of removing from a bucket's IAM policy: + */ + this.iam = new Iam(this); +} + +util.inherits(Bucket, common.ServiceObject); + +/** + * @typedef {array} CombineResponse + * @property {File} 0 The new {@link File}. + * @property {object} 1 The full API response. + */ +/** + * @callback CombineCallback + * @param {?Error} err Request error, if any. + * @param {File} newFile The new {@link File}. + * @param {object} apiResponse The full API response. + */ +/** + * Combine multiple files into one new file. + * + * @see [Objects: compose API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/objects/compose} + * + * @throws {Error} if a non-array is provided as sources argument. + * @throws {Error} if less than two sources are provided. + * @throws {Error} if no destination is provided. + * + * @param {string[]|File[]} sources The source files that will be + * combined. + * @param {string|File} destination The file you would like the + * source files combined into. + * @param {object} [options] Configuration options. + * @param {string} [options.kmsKeyName] Resource name of the Cloud KMS key, of + * the form + * `projects/my-project/locations/location/keyRings/my-kr/cryptoKeys/my-key`, + * that will be used to encrypt the object. Overwrites the object metadata's + * `kms_key_name` value, if any. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {CombineCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const logBucket = storage.bucket('log-bucket'); + * + * const sources = [ + * logBucket.file('2013-logs.txt'), + * logBucket.file('2014-logs.txt') + * ]; + * + * const allLogs = logBucket.file('all-logs.txt'); + * + * logBucket.combine(sources, allLogs, function(err, newFile, apiResponse) { + * // newFile === allLogs + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * logBucket.combine(sources, allLogs).then(function(data) { + * const newFile = data[0]; + * const apiResponse = data[1]; + * }); + */ +Bucket.prototype.combine = function(sources, destination, options, callback) { + if (!is.array(sources) || sources.length < 2) { + throw new Error('You must provide at least two source files.'); + } + + if (!destination) { + throw new Error('A destination file must be specified.'); + } + + const self = this; + + if (is.fn(options)) { + callback = options; + options = {}; + } + + sources = sources.map(convertToFile); + destination = convertToFile(destination); + callback = callback || common.util.noop; + + if (!destination.metadata.contentType) { + const destinationContentType = mime.contentType(destination.name); + + if (destinationContentType) { + destination.metadata.contentType = destinationContentType; + } + } + + // Make the request from the destination File object. + destination.request( + { + method: 'POST', + uri: '/compose', + json: { + destination: { + contentType: destination.metadata.contentType, + }, + sourceObjects: sources.map(function(source) { + const sourceObject = { + name: source.name, + }; + + if (source.metadata && source.metadata.generation) { + sourceObject.generation = source.metadata.generation; + } + + return sourceObject; + }), + }, + qs: options, + }, + function(err, resp) { + if (err) { + callback(err, null, resp); + return; + } + + callback(null, destination, resp); + } + ); + + function convertToFile(file) { + if (file instanceof File) { + return file; + } + + return self.file(file); + } +}; + +/** + * @typedef {array} CreateChannelResponse + * @property {Channel} 0 The new {@link Channel}. + * @property {object} 1 The full API response. + */ +/** + * @callback CreateChannelCallback + * @param {?Error} err Request error, if any. + * @param {Channel} channel The new {@link Channel}. + * @param {object} apiResponse The full API response. + */ +/** + * Create a channel that will be notified when objects in this bucket changes. + * + * @throws {Error} If an ID is not provided. + * @throws {Error} If an address is not provided. + * + * @see [Objects: watchAll API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/objects/watchAll} + * + * @param {string} id The ID of the channel to create. + * @param {object} config See a + * [Objects: watchAll request body](https://cloud.google.com/storage/docs/json_api/v1/objects/watchAll). + * @param {string} config.address The address where notifications are + * delivered for this channel. + * @param {object} [options] Configuration options. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {CreateChannelCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('albums'); + * const id = 'new-channel-id'; + * + * const config = { + * address: 'https://...' + * }; + * + * bucket.createChannel(id, config, function(err, channel, apiResponse) { + * if (!err) { + * // Channel created successfully. + * } + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * bucket.createChannel(id, config).then(function(data) { + * const channel = data[0]; + * const apiResponse = data[1]; + * }); + */ +Bucket.prototype.createChannel = function(id, config, options, callback) { + const self = this; + + if (!is.string(id)) { + throw new Error('An ID is required to create a channel.'); + } + + if (!is.string(config.address)) { + throw new Error('An address is required to create a channel.'); + } + + if (is.fn(options)) { + callback = options; + options = {}; + } + + this.request( + { + method: 'POST', + uri: '/o/watch', + json: extend( + { + id: id, + type: 'web_hook', + }, + config + ), + qs: options, + }, + function(err, apiResponse) { + if (err) { + callback(err, null, apiResponse); + return; + } + + const resourceId = apiResponse.resourceId; + const channel = self.storage.channel(id, resourceId); + + channel.metadata = apiResponse; + + callback(null, channel, apiResponse); + } + ); +}; + +/** + * Metadata to set for the Notification. + * + * @typedef {object} CreateNotificationRequest + * @property {object} [customAttributes] An optional list of additional + * attributes to attach to each Cloud PubSub message published for this + * notification subscription. + * @property {string[]} [eventTypes] If present, only send notifications about + * listed event types. If empty, sent notifications for all event types. + * @property {string} [objectNamePrefix] If present, only apply this + * notification configuration to object names that begin with this prefix. + * @property {string} [payloadFormat] The desired content of the Payload. + * Defaults to `JSON_API_V1`. + * + * Acceptable values are: + * - `JSON_API_V1` + * + * - `NONE` + * @property {string} [options.userProject] The ID of the project which will be + * billed for the request. + */ +/** + * @typedef {array} CreateNotificationResponse + * @property {Notification} 0 The new {@link Notification}. + * @property {object} 1 The full API response. + */ +/** + * @callback CreateNotificationCallback + * @param {?Error} err Request error, if any. + * @param {Notification} notification The new {@link Notification}. + * @param {object} apiResponse The full API response. + */ +/** + * Creates a notification subscription for the bucket. + * + * @see [Notifications: insert]{@link https://cloud.google.com/storage/docs/json_api/v1/notifications/insert} + * + * @param {Topic|string} topic The Cloud PubSub topic to which this + * subscription publishes. If the project ID is omitted, the current project + * ID will be used. + * + * Acceptable formats are: + * - `projects/grape-spaceship-123/topics/my-topic` + * + * - `my-topic` + * @param {CreateNotificationRequest} [options] Metadata to set for the + * notification. + * @param {CreateNotificationCallback} [callback] Callback function. + * @returns {Promise} + * @throws {Error} If a valid topic is not provided. + * @see Notification#create + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * + * const callback = function(err, notification, apiResponse) { + * if (!err) { + * // The notification was created successfully. + * } + * }; + * + * myBucket.createNotification('my-topic', callback); + * + * //- + * // Configure the nofiication by providing Notification metadata. + * //- + * const metadata = { + * objectNamePrefix: 'prefix-' + * }; + * + * myBucket.createNotification('my-topic', metadata, callback); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * myBucket.createNotification('my-topic').then(function(data) { + * const notification = data[0]; + * const apiResponse = data[1]; + * }); + * + * @example include:samples/notifications.js + * region_tag:storage_create_notification + * Another example: + */ +Bucket.prototype.createNotification = function(topic, options, callback) { + const self = this; + + if (is.fn(options)) { + callback = options; + options = {}; + } + + if (is.object(topic) && common.util.isCustomType(topic, 'pubsub/topic')) { + topic = topic.name; + } + + if (!is.string(topic)) { + throw new Error('A valid topic name is required.'); + } + + const body = extend({topic: topic}, options); + + if (body.topic.indexOf('projects') !== 0) { + body.topic = 'projects/{{projectId}}/topics/' + body.topic; + } + + body.topic = '//pubsub.googleapis.com/' + body.topic; + + if (!body.payloadFormat) { + body.payloadFormat = 'JSON_API_V1'; + } + + const query = {}; + + if (body.userProject) { + query.userProject = body.userProject; + delete body.userProject; + } + + this.request( + { + method: 'POST', + uri: '/notificationConfigs', + json: snakeize(body), + qs: query, + }, + function(err, apiResponse) { + if (err) { + callback(err, null, apiResponse); + return; + } + + const notification = self.notification(apiResponse.id); + + notification.metadata = apiResponse; + + callback(null, notification, apiResponse); + } + ); +}; + +/** + * @typedef {array} DeleteBucketResponse + * @property {object} 0 The full API response. + */ +/** + * @callback DeleteBucketCallback + * @param {?Error} err Request error, if any. + * @param {object} apiResponse The full API response. + */ +/** + * Delete the bucket. + * + * @see [Buckets: delete API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/buckets/delete} + * + * @param {object} [options] Configuration options. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {DeleteBucketCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('albums'); + * bucket.delete(function(err, apiResponse) {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * bucket.delete().then(function(data) { + * const apiResponse = data[0]; + * }); + * + * @example include:samples/buckets.js + * region_tag:storage_delete_bucket + * Another example: + */ +Bucket.prototype.delete = function(options, callback) { + if (is.fn(options)) { + callback = options; + options = {}; + } + + this.request( + { + method: 'DELETE', + uri: '', + qs: options, + }, + callback || common.util.noop + ); +}; + +/** + * @callback DeleteFilesCallback + * @param {?Error|?Error[]} err Request error, if any, or array of errors from + * files that were not able to be deleted. + * @param {object} apiResponse The full API response. + */ +/** + * Iterate over the bucket's files, calling `file.delete()` on each. + * + * This is not an atomic request. A delete attempt will be made + * for each file individually. Any one can fail, in which case only a portion of + * the files you intended to be deleted would have. + * + * Operations are performed in parallel, up to 10 at once. The first error + * breaks the loop and will execute the provided callback with it. Specify + * `{ force: true }` to suppress the errors until all files have had a chance to + * be processed. + * + * The `query` object passed as the first argument will also be passed to + * {@link Bucket#getFiles}. + * + * @see [Objects: delete API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/objects/delete} + * + * @param {object} [query] Query object. See {@link Bucket#getFiles} + * for all of the supported properties. + * @param {boolean} [query.force] Suppress errors until all files have been + * processed. + * @param {string} [query.userProject] The ID of the project which will be + * billed for the request. + * @param {DeleteFilesCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('albums'); + * + * //- + * // Delete all of the files in the bucket. + * //- + * bucket.deleteFiles(function(err) {}); + * + * //- + * // By default, if a file cannot be deleted, this method will stop deleting + * // files from your bucket. You can override this setting with `force: true`. + * //- + * bucket.deleteFiles({ + * force: true + * }, function(errors) { + * // `errors`: + * // Array of errors if any occurred, otherwise null. + * }); + * + * //- + * // The first argument to this method acts as a query to + * // {@link Bucket#getFiles}. As an example, you can delete files + * // which match a prefix. + * //- + * bucket.deleteFiles({ + * prefix: 'images/' + * }, function(err) { + * if (!err) { + * // All files in the `images` directory have been deleted. + * } + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * bucket.deleteFiles().then(function() {}); + */ +Bucket.prototype.deleteFiles = function(query, callback) { + if (is.fn(query)) { + callback = query; + query = {}; + } + + query = query || {}; + + const MAX_PARALLEL_LIMIT = 10; + const errors = []; + + this.getFiles(query, function(err, files) { + if (err) { + callback(err); + return; + } + + function deleteFile(file, callback) { + file.delete(query, function(err) { + if (err) { + if (query.force) { + errors.push(err); + callback(); + return; + } + + callback(err); + return; + } + + callback(); + }); + } + + // Iterate through each file and attempt to delete it. + async.eachLimit(files, MAX_PARALLEL_LIMIT, deleteFile, function(err) { + if (err || errors.length > 0) { + callback(err || errors); + return; + } + + callback(); + }); + }); +}; + +/** + * @typedef {array} DeleteLabelsResponse + * @property {object} 0 The full API response. + */ +/** + * @callback DeleteLabelsCallback + * @param {?Error} err Request error, if any. + * @param {object} apiResponse The full API response. + */ +/** + * Delete one or more labels from this bucket. + * + * @param {string|string[]} labels The labels to delete. If no labels are + * provided, all of the labels are removed. + * @param {DeleteLabelsCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('albums'); + * + * //- + * // Delete all of the labels from this bucket. + * //- + * bucket.deleteLabels(function(err, apiResponse) {}); + * + * //- + * // Delete a single label. + * //- + * bucket.deleteLabels('labelone', function(err, apiResponse) {}); + * + * //- + * // Delete a specific set of labels. + * //- + * bucket.deleteLabels([ + * 'labelone', + * 'labeltwo' + * ], function(err, apiResponse) {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * bucket.deleteLabels().then(function(data) { + * const apiResponse = data[0]; + * }); + */ +Bucket.prototype.deleteLabels = function(labels, callback) { + const self = this; + + if (is.fn(labels)) { + callback = labels; + labels = []; + } + + labels = arrify(labels); + + if (labels.length === 0) { + this.getLabels(function(err, labels) { + if (err) { + callback(err); + return; + } + + deleteLabels(Object.keys(labels)); + }); + } else { + deleteLabels(labels); + } + + function deleteLabels(labels) { + const nullLabelMap = labels.reduce(function(nullLabelMap, labelKey) { + nullLabelMap[labelKey] = null; + return nullLabelMap; + }, {}); + + self.setLabels(nullLabelMap, callback); + } +}; + +/** + * @typedef {array} DisableRequesterPaysResponse + * @property {object} 0 The full API response. + */ +/** + * @callback DisableRequesterPaysCallback + * @param {?Error} err Request error, if any. + * @param {object} apiResponse The full API response. + */ +/** + *
+ * Early Access Testers Only + *

+ * This feature is not yet widely-available. + *

+ *
+ * + * Disable `requesterPays` functionality from this bucket. + * + * @param {DisableRequesterPaysCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('albums'); + * + * bucket.disableRequesterPays(function(err, apiResponse) { + * if (!err) { + * // requesterPays functionality disabled successfully. + * } + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * bucket.disableRequesterPays().then(function(data) { + * const apiResponse = data[0]; + * }); + * + * @example include:samples/requesterPays.js + * region_tag:storage_disable_requester_pays + * Example of disabling requester pays: + */ +Bucket.prototype.disableRequesterPays = function(callback) { + this.setMetadata( + { + billing: { + requesterPays: false, + }, + }, + callback || common.util.noop + ); +}; + +/** + * @typedef {array} EnableRequesterPaysResponse + * @property {object} 0 The full API response. + */ +/** + * @callback EnableRequesterPaysCallback + * @param {?Error} err Request error, if any. + * @param {object} apiResponse The full API response. + */ +/** + *
+ * Early Access Testers Only + *

+ * This feature is not yet widely-available. + *

+ *
+ * + * Enable `requesterPays` functionality for this bucket. This enables you, the + * bucket owner, to have the requesting user assume the charges for the access + * to your bucket and its contents. + * + * @param {EnableRequesterPaysCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('albums'); + * + * bucket.enableRequesterPays(function(err, apiResponse) { + * if (!err) { + * // requesterPays functionality enabled successfully. + * } + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * bucket.enableRequesterPays().then(function(data) { + * const apiResponse = data[0]; + * }); + * + * @example include:samples/requesterPays.js + * region_tag:storage_enable_requester_pays + * Example of enabling requester pays: + */ +Bucket.prototype.enableRequesterPays = function(callback) { + this.setMetadata( + { + billing: { + requesterPays: true, + }, + }, + callback || common.util.noop + ); +}; + +/** + * @typedef {array} BucketExistsResponse + * @property {boolean} 0 Whether the {@link Bucket} exists. + */ +/** + * @callback BucketExistsCallback + * @param {?Error} err Request error, if any. + * @param {boolean} exists Whether the {@link Bucket} exists. + */ +/** + * Check if the bucket exists. + * + * @param {object} [options] Configuration options. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {BucketExistsCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('albums'); + * + * bucket.exists(function(err, exists) {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * bucket.exists().then(function(data) { + * const exists = data[0]; + * }); + */ +Bucket.prototype.exists = function(options, callback) { + if (is.fn(options)) { + callback = options; + options = {}; + } + + options = options || {}; + + this.get(options, function(err) { + if (err) { + if (err.code === 404) { + callback(null, false); + } else { + callback(err); + } + + return; + } + + callback(null, true); + }); +}; + +/** + * Create a {@link File} object. See {@link File} to see how to handle + * the different use cases you may have. + * + * @param {string} name The name of the file in this bucket. + * @param {object} [options] Configuration options. + * @param {string|number} [options.generation] Only use a specific revision of + * this file. + * @param {string} [options.encryptionKey] A custom encryption key. See + * [Customer-supplied Encryption Keys](https://cloud.google.com/storage/docs/encryption#customer-supplied). + * @param {string} [options.kmsKeyName] The name of the Cloud KMS key that will + * be used to encrypt the object. Must be in the format: + * `projects/my-project/locations/location/keyRings/my-kr/cryptoKeys/my-key`. + * KMS key ring must use the same location as the bucket. + * @returns {File} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('albums'); + * const file = bucket.file('my-existing-file.png'); + */ +Bucket.prototype.file = function(name, options) { + if (!name) { + throw Error('A file name must be specified.'); + } + + return new File(this, name, options); +}; + +/** + * @typedef {array} GetBucketResponse + * @property {Bucket} 0 The {@link Bucket}. + * @property {object} 1 The full API response. + */ +/** + * @callback GetBucketCallback + * @param {?Error} err Request error, if any. + * @param {Bucket} bucket The {@link Bucket}. + * @param {object} apiResponse The full API response. + */ +/** + * Get a bucket if it exists. + * + * You may optionally use this to "get or create" an object by providing an + * object with `autoCreate` set to `true`. Any extra configuration that is + * normally required for the `create` method must be contained within this + * object as well. + * + * @param {object} [options] Configuration options. + * @param {boolean} [options.autoCreate] Automatically create the object if + * it does not exist. Default: `false` + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {GetBucketCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('albums'); + * + * bucket.get(function(err, bucket, apiResponse) { + * // `bucket.metadata` has been populated. + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * bucket.get().then(function(data) { + * const bucket = data[0]; + * const apiResponse = data[1]; + * }); + */ +Bucket.prototype.get = function(options, callback) { + const self = this; + + if (is.fn(options)) { + callback = options; + options = {}; + } + + options = options || {}; + + const autoCreate = options.autoCreate; + delete options.autoCreate; + + function onCreate(err, bucket, apiResponse) { + if (err) { + if (err.code === 409) { + self.get(options, callback); + return; + } + + callback(err, null, apiResponse); + return; + } + + callback(null, bucket, apiResponse); + } + + this.getMetadata(options, function(err, metadata) { + if (err) { + if (err.code === 404 && autoCreate) { + const args = []; + + if (!is.empty(options)) { + args.push(options); + } + + args.push(onCreate); + + self.create.apply(self, args); + return; + } + + callback(err, null, metadata); + return; + } + + callback(null, self, metadata); + }); +}; + +/** + * Query object for listing files. + * + * @typedef {object} GetFilesRequest + * @property {boolean} [autoPaginate=true] Have pagination handled + * automatically. + * @property {string} [delimiter] Results will contain only objects whose + * names, aside from the prefix, do not contain delimiter. Objects whose + * names, aside from the prefix, contain delimiter will have their name + * truncated after the delimiter, returned in `apiResponse.prefixes`. + * Duplicate prefixes are omitted. + * @property {string} [directory] Filter results based on a directory name, or + * more technically, a "prefix". + * @property {string} [prefix] Filter results to objects whose names begin + * with this prefix. + * @property {number} [maxApiCalls] Maximum number of API calls to make. + * @property {number} [maxResults] Maximum number of items plus prefixes to + * return. + * @property {string} [pageToken] A previously-returned page token + * representing part of the larger set of results to view. + * @property {string} [userProject] The ID of the project which will be + * billed for the request. + * @property {boolean} [versions] If true, returns File objects scoped to + * their versions. + */ +/** + * @typedef {array} GetFilesResponse + * @property {File[]} 0 Array of {@link File} instances. + */ +/** + * @callback GetFilesCallback + * @param {?Error} err Request error, if any. + * @param {File[]} files Array of {@link File} instances. + */ +/** + * Get {@link File} objects for the files currently in the bucket. + * + * @see [Objects: list API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/objects/list} + * + * @param {GetFilesRequest} [query] Query object for listing files. + * @param {GetFilesCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('albums'); + * + * bucket.getFiles(function(err, files) { + * if (!err) { + * // files is an array of File objects. + * } + * }); + * + * //- + * // If your bucket has versioning enabled, you can get all of your files + * // scoped to their generation. + * //- + * bucket.getFiles({ + * versions: true + * }, function(err, files) { + * // Each file is scoped to its generation. + * }); + * + * //- + * // To control how many API requests are made and page through the results + * // manually, set `autoPaginate` to `false`. + * //- + * const callback = function(err, files, nextQuery, apiResponse) { + * if (nextQuery) { + * // More results exist. + * bucket.getFiles(nextQuery, callback); + * } + * + * // The `metadata` property is populated for you with the metadata at the + * // time of fetching. + * files[0].metadata; + * + * // However, in cases where you are concerned the metadata could have + * // changed, use the `getMetadata` method. + * files[0].getMetadata(function(err, metadata) {}); + * }; + * + * bucket.getFiles({ + * autoPaginate: false + * }, callback); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * bucket.getFiles().then(function(data) { + * const files = data[0]; + * }); + * + * @example include:samples/files.js + * region_tag:storage_list_files + * Another example: + * + * @example include:samples/files.js + * region_tag:storage_list_files_with_prefix + * Example of listing files, filtered by a prefix: + */ +Bucket.prototype.getFiles = function(query, callback) { + const self = this; + + if (!callback) { + callback = query; + query = {}; + } + + query = extend({}, query); + + if (query.directory) { + query.prefix = `${query.directory}/`.replace(/\/*$/, '/'); + delete query.directory; + } + + this.request( + { + uri: '/o', + qs: query, + }, + function(err, resp) { + if (err) { + callback(err, null, null, resp); + return; + } + + const files = arrify(resp.items).map(function(file) { + const options = {}; + + if (query.versions) { + options.generation = file.generation; + } + + if (file.kmsKeyName) { + options.kmsKeyName = file.kmsKeyName; + } + + const fileInstance = self.file(file.name, options); + fileInstance.metadata = file; + + return fileInstance; + }); + + let nextQuery = null; + if (resp.nextPageToken) { + nextQuery = extend({}, query, { + pageToken: resp.nextPageToken, + }); + } + + callback(null, files, nextQuery, resp); + } + ); +}; + +/** + * Get {@link File} objects for the files currently in the bucket as a + * readable object stream. + * + * @method Bucket#getFilesStream + * @param {GetFilesRequest} [query] Query object for listing files. + * @returns {ReadableStream} A readable stream that emits {@link File} instances. + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('albums'); + * + * bucket.getFilesStream() + * .on('error', console.error) + * .on('data', function(file) { + * // file is a File object. + * }) + * .on('end', function() { + * // All files retrieved. + * }); + * + * //- + * // If you anticipate many results, you can end a stream early to prevent + * // unnecessary processing and API requests. + * //- + * bucket.getFilesStream() + * .on('data', function(file) { + * this.end(); + * }); + */ +Bucket.prototype.getFilesStream = common.paginator.streamify('getFiles'); + +/** + * @typedef {array} GetLabelsResponse + * @property {object} 0 Object of labels currently set on this bucket. + */ +/** + * @callback GetLabelsCallback + * @param {?Error} err Request error, if any. + * @param {object} labels Object of labels currently set on this bucket. + */ +/** + * Get the labels currently set on this bucket. + * + * @param {object} [options] Configuration options. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {GetLabelsCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('albums'); + * + * bucket.getLabels(function(err, labels) { + * if (err) { + * // Error handling omitted. + * } + * + * // labels = { + * // label: 'labelValue', + * // ... + * // } + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * bucket.getLabels().then(function(data) { + * const labels = data[0]; + * }); + */ +Bucket.prototype.getLabels = function(options, callback) { + if (is.fn(options)) { + callback = options; + options = {}; + } + + this.getMetadata(options, function(err, metadata) { + if (err) { + callback(err); + return; + } + + callback(null, metadata.labels || {}); + }); +}; + +/** + * @typedef {array} GetBucketMetadataResponse + * @property {object} 0 The bucket metadata. + * @property {object} 1 The full API response. + */ +/** + * @callback GetBucketMetadataCallback + * @param {?Error} err Request error, if any. + * @param {object} files The bucket metadata. + * @param {object} apiResponse The full API response. + */ +/** + * Get the bucket's metadata. + * + * To set metadata, see {@link Bucket#setMetadata}. + * + * @see [Buckets: get API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/buckets/get} + * + * @param {object} [options] Configuration options. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {GetBucketMetadataCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('albums'); + * + * bucket.getMetadata(function(err, metadata, apiResponse) {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * bucket.getMetadata().then(function(data) { + * const metadata = data[0]; + * const apiResponse = data[1]; + * }); + * + * @example include:samples/requesterPays.js + * region_tag:storage_get_requester_pays_status + * Example of retrieving the requester pays status of a bucket: + */ +Bucket.prototype.getMetadata = function(options, callback) { + const self = this; + + if (is.fn(options)) { + callback = options; + options = {}; + } + + this.request( + { + uri: '', + qs: options, + }, + function(err, resp) { + if (err) { + callback(err, null, resp); + return; + } + + self.metadata = resp; + + callback(null, self.metadata, resp); + } + ); +}; + +/** + * @typedef {array} GetNotificationsResponse + * @property {Notification[]} 0 Array of {@link Notification} instances. + * @property {object} 1 The full API response. + */ +/** + * @callback GetNotificationsCallback + * @param {?Error} err Request error, if any. + * @param {Notification[]} notifications Array of {@link Notification} + * instances. + * @param {object} apiResponse The full API response. + */ +/** + * Retrieves a list of notification subscriptions for a given bucket. + * + * @see [Notifications: list]{@link https://cloud.google.com/storage/docs/json_api/v1/notifications/list} + * + * @param {object} [options] Configuration options. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {GetNotificationsCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('my-bucket'); + * + * bucket.getNotifications(function(err, notifications, apiResponse) { + * if (!err) { + * // notifications is an array of Notification objects. + * } + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * bucket.getNotifications().then(function(data) { + * const notifications = data[0]; + * const apiResponse = data[1]; + * }); + * + * @example include:samples/notifications.js + * region_tag:storage_list_notifications + * Another example: + */ +Bucket.prototype.getNotifications = function(options, callback) { + const self = this; + + if (is.fn(options)) { + callback = options; + options = {}; + } + + this.request( + { + uri: '/notificationConfigs', + qs: options, + }, + function(err, resp) { + if (err) { + callback(err, null, resp); + return; + } + + const notifications = arrify(resp.items).map(function(notification) { + const notificationInstance = self.notification(notification.id); + notificationInstance.metadata = notification; + return notificationInstance; + }); + + callback(null, notifications, resp); + } + ); +}; + +/** + * @typedef {array} MakeBucketPrivateResponse + * @property {File[]} 0 List of files made private. + */ +/** + * @callback MakeBucketPrivateCallback + * @param {?Error} err Request error, if any. + * @param {File[]} files List of files made private. + */ +/** + * Make the bucket listing private. + * + * You may also choose to make the contents of the bucket private by specifying + * `includeFiles: true`. This will automatically run + * {@link File#makePrivate} for every file in the bucket. + * + * When specifying `includeFiles: true`, use `force: true` to delay execution of + * your callback until all files have been processed. By default, the callback + * is executed after the first error. Use `force` to queue such errors until all + * files have been processed, after which they will be returned as an array as + * the first argument to your callback. + * + * NOTE: This may cause the process to be long-running and use a high number of + * requests. Use with caution. + * + * @see [Buckets: patch API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/buckets/patch} + * + * @param {object} [options] Configuration options. + * @param {boolean} [options.includeFiles=false] Make each file in the bucket + * private. + * @param {boolean} [options.force] Queue errors occurred while making files + * private until all files have been processed. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {MakeBucketPrivateCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('albums'); + * + * //- + * // Make the bucket private. + * //- + * bucket.makePrivate(function(err) {}); + * + * //- + * // Make the bucket and its contents private. + * //- + * const opts = { + * includeFiles: true + * }; + * + * bucket.makePrivate(opts, function(err, files) { + * // `err`: + * // The first error to occur, otherwise null. + * // + * // `files`: + * // Array of files successfully made private in the bucket. + * }); + * + * //- + * // Make the bucket and its contents private, using force to suppress errors + * // until all files have been processed. + * //- + * const opts = { + * includeFiles: true, + * force: true + * }; + * + * bucket.makePrivate(opts, function(errors, files) { + * // `errors`: + * // Array of errors if any occurred, otherwise null. + * // + * // `files`: + * // Array of files successfully made private in the bucket. + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * bucket.makePrivate(opts).then(function(data) { + * const files = data[0]; + * }); + */ +Bucket.prototype.makePrivate = function(options, callback) { + const self = this; + + if (is.fn(options)) { + callback = options; + options = {}; + } + + options = options || {}; + options.private = true; + + async.series([setPredefinedAcl, makeFilesPrivate], callback); + + function setPredefinedAcl(done) { + const query = { + predefinedAcl: 'projectPrivate', + }; + + if (options.userProject) { + query.userProject = options.userProject; + } + + self.setMetadata( + { + // You aren't allowed to set both predefinedAcl & acl properties on a + // bucket so acl must explicitly be nullified. + acl: null, + }, + query, + done + ); + } + + function makeFilesPrivate(done) { + if (!options.includeFiles) { + done(); + return; + } + + self.makeAllFilesPublicPrivate_(options, done); + } +}; + +/** + * @typedef {array} MakeBucketPublicResponse + * @property {File[]} 0 List of files made public. + */ +/** + * @callback MakeBucketPublicCallback + * @param {?Error} err Request error, if any. + * @param {File[]} files List of files made public. + */ +/** + * Make the bucket publicly readable. + * + * You may also choose to make the contents of the bucket publicly readable by + * specifying `includeFiles: true`. This will automatically run + * {@link File#makePublic} for every file in the bucket. + * + * When specifying `includeFiles: true`, use `force: true` to delay execution of + * your callback until all files have been processed. By default, the callback + * is executed after the first error. Use `force` to queue such errors until all + * files have been processed, after which they will be returned as an array as + * the first argument to your callback. + * + * NOTE: This may cause the process to be long-running and use a high number of + * requests. Use with caution. + * + * @see [Buckets: patch API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/buckets/patch} + * + * @param {object} [options] Configuration options. + * @param {boolean} [options.includeFiles=false] Make each file in the bucket + * publicly readable. + * @param {boolean} [options.force] Queue errors occurred while making files + * public until all files have been processed. + * @param {MakeBucketPublicCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('albums'); + * + * //- + * // Make the bucket publicly readable. + * //- + * bucket.makePublic(function(err) {}); + * + * //- + * // Make the bucket and its contents publicly readable. + * //- + * const opts = { + * includeFiles: true + * }; + * + * bucket.makePublic(opts, function(err, files) { + * // `err`: + * // The first error to occur, otherwise null. + * // + * // `files`: + * // Array of files successfully made public in the bucket. + * }); + * + * //- + * // Make the bucket and its contents publicly readable, using force to + * // suppress errors until all files have been processed. + * //- + * const opts = { + * includeFiles: true, + * force: true + * }; + * + * bucket.makePublic(opts, function(errors, files) { + * // `errors`: + * // Array of errors if any occurred, otherwise null. + * // + * // `files`: + * // Array of files successfully made public in the bucket. + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * bucket.makePublic(opts).then(function(data) { + * const files = data[0]; + * }); + */ +Bucket.prototype.makePublic = function(options, callback) { + const self = this; + + if (is.fn(options)) { + callback = options; + options = {}; + } + + options = options || {}; + options.public = true; + + async.series( + [addAclPermissions, addDefaultAclPermissions, makeFilesPublic], + callback + ); + + function addAclPermissions(done) { + // Allow reading bucket contents while preserving original permissions. + self.acl.add( + { + entity: 'allUsers', + role: 'READER', + }, + done + ); + } + + function addDefaultAclPermissions(done) { + self.acl.default.add( + { + entity: 'allUsers', + role: 'READER', + }, + done + ); + } + + function makeFilesPublic(done) { + if (!options.includeFiles) { + done(); + return; + } + + self.makeAllFilesPublicPrivate_(options, done); + } +}; + +/** + * Get a reference to a Cloud Pub/Sub Notification. + * + * @param {string} id ID of notification. + * @returns {Notification} + * @see Notification + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('my-bucket'); + * const notification = bucket.notification('1'); + */ +Bucket.prototype.notification = function(id) { + if (!id) { + throw new Error('You must supply a notification ID.'); + } + + return new Notification(this, id); +}; + +/** + * Makes request and applies userProject query parameter if necessary. + * + * @private + * + * @param {object} reqOpts - The request options. + * @param {function} callback - The callback function. + */ +Bucket.prototype.request = function(reqOpts, callback) { + if (this.userProject && (!reqOpts.qs || !reqOpts.qs.userProject)) { + reqOpts.qs = extend(reqOpts.qs, {userProject: this.userProject}); + } + + return common.ServiceObject.prototype.request.call(this, reqOpts, callback); +}; + +/** + * @typedef {array} SetLabelsResponse + * @property {object} 0 The bucket metadata. + */ +/** + * @callback SetLabelsCallback + * @param {?Error} err Request error, if any. + * @param {object} metadata The bucket metadata. + */ +/** + * Set labels on the bucket. + * + * This makes an underlying call to {@link Bucket#setMetadata}, which + * is a PATCH request. This means an individual label can be overwritten, but + * unmentioned labels will not be touched. + * + * @param {object} labels Labels to set on the bucket. + * @param {object} [options] Configuration options. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {SetLabelsCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('albums'); + * + * const labels = { + * labelone: 'labelonevalue', + * labeltwo: 'labeltwovalue' + * }; + * + * bucket.setLabels(labels, function(err, metadata) { + * if (!err) { + * // Labels set successfully. + * } + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * bucket.setLabels(labels).then(function(data) { + * const metadata = data[0]; + * }); + */ +Bucket.prototype.setLabels = function(labels, options, callback) { + if (is.fn(options)) { + callback = options; + options = {}; + } + + callback = callback || common.util.noop; + + this.setMetadata({labels}, options, callback); +}; + +/** + * @typedef {array} SetBucketMetadataResponse + * @property {object} 0 The bucket metadata. + */ +/** + * @callback SetBucketMetadataCallback + * @param {?Error} err Request error, if any. + * @param {object} metadata The bucket metadata. + */ +/** + * Set the bucket's metadata. + * + * @see [Buckets: patch API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/buckets/patch} + * + * @param {object} metadata The metadata you wish to set. + * @param {object} [options] Configuration options. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {SetBucketMetadataCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('albums'); + * + * //- + * // Set website metadata field on the bucket. + * //- + * const metadata = { + * website: { + * mainPageSuffix: 'http://example.com', + * notFoundPage: 'http://example.com/404.html' + * } + * }; + * + * bucket.setMetadata(metadata, function(err, apiResponse) {}); + * + * //- + * // Enable versioning for your bucket. + * //- + * bucket.setMetadata({ + * versioning: { + * enabled: true + * } + * }, function(err, apiResponse) {}); + * + * //- + * // Enable KMS encryption for objects within this bucket. + * //- + * bucket.setMetadata({ + * encryption: { + * defaultKmsKeyName: 'projects/grape-spaceship-123/...' + * } + * }, function(err, apiResponse) {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * bucket.setMetadata(metadata).then(function(data) { + * const apiResponse = data[0]; + * }); + */ +Bucket.prototype.setMetadata = function(metadata, options, callback) { + const self = this; + + if (is.fn(options)) { + callback = options; + options = {}; + } + + callback = callback || common.util.noop; + + this.request( + { + method: 'PATCH', + uri: '', + json: metadata, + qs: options, + }, + function(err, resp) { + if (err) { + callback(err, resp); + return; + } + + self.metadata = resp; + + callback(null, resp); + } + ); +}; + +/** + * @callback SetStorageClassCallback + * @param {?Error} err Request error, if any. + */ +/** + * Set the default storage class for new files in this bucket. + * + * @see [Storage Classes]{@link https://cloud.google.com/storage/docs/storage-classes} + * + * @param {string} storageClass The new storage class. (`multi_regional`, + * `regional`, `standard`, `nearline`, `coldline`, or + * `durable_reduced_availability`) + * @param {object} [options] Configuration options. + * @param {string} [options.userProject] - The ID of the project which will be + * billed for the request. + * @param {SetStorageClassCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('albums'); + * + * bucket.setStorageClass('regional', function(err, apiResponse) { + * if (err) { + * // Error handling omitted. + * } + * + * // The storage class was updated successfully. + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * bucket.setStorageClass('regional').then(function() {}); + */ +Bucket.prototype.setStorageClass = function(storageClass, options, callback) { + // In case we get input like `storageClass`, convert to `storage_class`. + storageClass = storageClass + .replace(/-/g, '_') + .replace(/([a-z])([A-Z])/g, function(_, low, up) { + return low + '_' + up; + }) + .toUpperCase(); + + this.setMetadata({storageClass}, options, callback); +}; + +/** + * Set a user project to be billed for all requests made from this Bucket + * object and any files referenced from this Bucket object. + * + * @param {string} userProject The user project. + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('albums'); + * + * bucket.setUserProject('grape-spaceship-123'); + */ +Bucket.prototype.setUserProject = function(userProject) { + this.userProject = userProject; +}; + +/** + * @typedef {array} UploadResponse + * @property {object} 0 The uploaded {@link File}. + * @property {object} 1 The full API response. + */ +/** + * @callback UploadCallback + * @param {?Error} err Request error, if any. + * @param {object} metadata The uploaded {@link File}. + * @param {object} apiResponse The full API response. + */ +/** + * Upload a file to the bucket. This is a convenience method that wraps + * {@link File#createWriteStream}. + * + * You can specify whether or not an upload is resumable by setting + * `options.resumable`. *Resumable uploads are enabled by default if your input + * file is larger than 5 MB.* + * + * For faster crc32c computation, you must manually install + * [`fast-crc32c`](http://www.gitnpm.com/fast-crc32c): + * + * $ npm install --save fast-crc32c + * + * @see [Upload Options (Simple or Resumable)]{@link https://cloud.google.com/storage/docs/json_api/v1/how-tos/upload#uploads} + * @see [Objects: insert API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/objects/insert} + * + * @param {string} pathString The fully qualified path or url to the file you + * wish to upload to your bucket. + * @param {object} [options] Configuration options. + * @param {string|File} [options.destination] The place to save + * your file. If given a string, the file will be uploaded to the bucket + * using the string as a filename. When given a File object, your local file + * will be uploaded to the File object's bucket and under the File object's + * name. Lastly, when this argument is omitted, the file is uploaded to your + * bucket using the name of the local file or the path of the url relative to it's domain. + * @param {string} [options.encryptionKey] A custom encryption key. See + * [Customer-supplied Encryption Keys](https://cloud.google.com/storage/docs/encryption#customer-supplied). + * @param {boolean} [options.gzip] Automatically gzip the file. This will set + * `options.metadata.contentEncoding` to `gzip`. + * @param {string} [options.kmsKeyName] The name of the Cloud KMS key that will + * be used to encrypt the object. Must be in the format: + * `projects/my-project/locations/location/keyRings/my-kr/cryptoKeys/my-key`. + * @param {object} [options.metadata] See an + * [Objects: insert request body](https://cloud.google.com/storage/docs/json_api/v1/objects/insert#request_properties_JSON). + * @param {string} [options.offset] The starting byte of the upload stream, for + * resuming an interrupted upload. Defaults to 0. + * @param {string} [options.predefinedAcl] Apply a predefined set of access + * controls to this object. + * + * Acceptable values are: + * - **`authenticatedRead`** - Object owner gets `OWNER` access, and + * `allAuthenticatedUsers` get `READER` access. + * + * - **`bucketOwnerFullControl`** - Object owner gets `OWNER` access, and + * project team owners get `OWNER` access. + * + * - **`bucketOwnerRead`** - Object owner gets `OWNER` access, and project + * team owners get `READER` access. + * + * - **`private`** - Object owner gets `OWNER` access. + * + * - **`projectPrivate`** - Object owner gets `OWNER` access, and project + * team members get access according to their roles. + * + * - **`publicRead`** - Object owner gets `OWNER` access, and `allUsers` get + * `READER` access. + * @param {boolean} [options.private] Make the uploaded file private. (Alias for + * `options.predefinedAcl = 'private'`) + * @param {boolean} [options.public] Make the uploaded file public. (Alias for + * `options.predefinedAcl = 'publicRead'`) + * @param {boolean} [options.resumable] Force a resumable upload. (default: + * true for files larger than 5 MB). + * @param {string} [options.uri] The URI for an already-created resumable + * upload. See {@link File#createResumableUpload}. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {string|boolean} [options.validation] Possible values: `"md5"`, + * `"crc32c"`, or `false`. By default, data integrity is validated with an + * MD5 checksum for maximum reliability. CRC32c will provide better + * performance with less reliability. You may also choose to skip validation + * completely, however this is **not recommended**. + * @param {object} [options.requestOptions] When `pathString` is a URL, + * additional [options for the HTTP request](https://github.com/request/request#requestoptions-callback) + * could be provided here. + * @param {UploadCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('albums'); + * + * //- + * // Upload a file from a local path. + * //- + * bucket.upload('/local/path/image.png', function(err, file, apiResponse) { + * // Your bucket now contains: + * // - "image.png" (with the contents of `/local/path/image.png') + * + * // `file` is an instance of a File object that refers to your new file. + * }); + * + * //- + * // You can also upload a file from a URL. + * //- + * + * bucket.upload('https://example.com/images/image.png', function(err, file, apiResponse) { + * // Your bucket now contains: + * // - "image.png" + * + * // `file` is an instance of a File object that refers to your new file. + * }); + * + * //- + * // It's not always that easy. You will likely want to specify the filename + * // used when your new file lands in your bucket. + * // + * // You may also want to set metadata or customize other options. + * //- + * const options = { + * destination: 'new-image.png', + * resumable: true, + * validation: 'crc32c', + * metadata: { + * metadata: { + * event: 'Fall trip to the zoo' + * } + * } + * }; + * + * bucket.upload('local-image.png', options, function(err, file) { + * // Your bucket now contains: + * // - "new-image.png" (with the contents of `local-image.png') + * + * // `file` is an instance of a File object that refers to your new file. + * }); + * + * //- + * // You can also have a file gzip'd on the fly. + * //- + * bucket.upload('index.html', { gzip: true }, function(err, file) { + * // Your bucket now contains: + * // - "index.html" (automatically compressed with gzip) + * + * // Downloading the file with `file.download` will automatically decode the + * // file. + * }); + * + * //- + * // You may also re-use a File object, {File}, that references + * // the file you wish to create or overwrite. + * //- + * const options = { + * destination: bucket.file('existing-file.png'), + * resumable: false + * }; + * + * bucket.upload('local-img.png', options, function(err, newFile) { + * // Your bucket now contains: + * // - "existing-file.png" (with the contents of `local-img.png') + * + * // Note: + * // The `newFile` parameter is equal to `file`. + * }); + * + * //- + * // To use + * // + * // Customer-supplied Encryption Keys, provide the `encryptionKey` option. + * //- + * const crypto = require('crypto'); + * const encryptionKey = crypto.randomBytes(32); + * + * bucket.upload('img.png', { + * encryptionKey: encryptionKey + * }, function(err, newFile) { + * // `img.png` was uploaded with your custom encryption key. + * + * // `newFile` is already configured to use the encryption key when making + * // operations on the remote object. + * + * // However, to use your encryption key later, you must create a `File` + * // instance with the `key` supplied: + * const file = bucket.file('img.png', { + * encryptionKey: encryptionKey + * }); + * + * // Or with `file#setEncryptionKey`: + * const file = bucket.file('img.png'); + * file.setEncryptionKey(encryptionKey); + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * bucket.upload('local-image.png').then(function(data) { + * const file = data[0]; + * }); + * + * //- + * // Additional options for download request could be provided. + * //- + * bucket.upload('https://example.com/images/image.png', { + * requestOptions: { + * headers: { + * 'User-Agent': 'curl/7.54.0' + * } + * } + * }, function(err, newFile) { + * // Custom `User-Agent` header will be used for the download request of + * // "https://example.com/images/image.png". + * }); + * + * @example include:samples/files.js + * region_tag:storage_upload_file + * Another example: + * + * @example include:samples/encryption.js + * region_tag:storage_upload_encrypted_file + * Example of uploading an encrypted file: + */ +Bucket.prototype.upload = function(pathString, options, callback) { + if (global.GCLOUD_SANDBOX_ENV) { + return; + } + + const isURL = /^(http|https):/.test(pathString); + + if (is.fn(options)) { + callback = options; + options = {}; + } + + options = extend( + { + metadata: {}, + }, + options + ); + + const requestOptions = Object.assign( + { + url: pathString, + }, + options.requestOptions + ); + + let newFile; + if (options.destination instanceof File) { + newFile = options.destination; + } else if (is.string(options.destination)) { + // Use the string as the name of the file. + newFile = this.file(options.destination, { + encryptionKey: options.encryptionKey, + kmsKeyName: options.kmsKeyName, + }); + } else { + // Resort to using the name of the incoming file. + const destination = path.basename(pathString); + newFile = this.file(destination, { + encryptionKey: options.encryptionKey, + kmsKeyName: options.kmsKeyName, + }); + } + + const contentType = mime.contentType(path.basename(pathString)); + + if (contentType && !options.metadata.contentType) { + options.metadata.contentType = contentType; + } + + if (is.boolean(options.resumable)) { + upload(); + } else if (isURL) { + request.head(requestOptions, function(err, resp) { + if (err) { + callback(err); + return; + } + + const contentLength = resp.headers['content-length']; + + if (is.number(contentLength)) { + options.resumable = contentLength > RESUMABLE_THRESHOLD; + } + + upload(); + }); + } else { + // Determine if the upload should be resumable if it's over the threshold. + fs.stat(pathString, function(err, fd) { + if (err) { + callback(err); + return; + } + + options.resumable = fd.size > RESUMABLE_THRESHOLD; + + upload(); + }); + } + + function upload() { + let sourceStream; + + if (isURL) { + sourceStream = request.get(requestOptions); + } else { + sourceStream = fs.createReadStream(pathString); + } + + sourceStream + .on('error', callback) + .pipe(newFile.createWriteStream(options)) + .on('error', callback) + .on('finish', function() { + callback(null, newFile, newFile.metadata); + }); + } +}; + +/** + * Iterate over all of a bucket's files, calling `file.makePublic()` (public) + * or `file.makePrivate()` (private) on each. + * + * Operations are performed in parallel, up to 10 at once. The first error + * breaks the loop, and will execute the provided callback with it. Specify + * `{ force: true }` to suppress the errors. + * + * @private + * + * @param {object} options] Configuration options. + * @param {boolean} [options.force] Suppress errors until all files have been + * processed. + * @param {boolean} [options.private] Make files private. + * @param {boolean} [options.public] Make files public. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {function} callback Callback function. + */ +Bucket.prototype.makeAllFilesPublicPrivate_ = function(options, callback) { + const MAX_PARALLEL_LIMIT = 10; + const errors = []; + const updatedFiles = []; + + this.getFiles(options, function(err, files) { + if (err) { + callback(err); + return; + } + + function processFile(file, callback) { + if (options.public) { + file.makePublic(processedCallback); + } else if (options.private) { + file.makePrivate(options, processedCallback); + } + + function processedCallback(err) { + if (err) { + if (options.force) { + errors.push(err); + callback(); + return; + } + + callback(err); + return; + } + + updatedFiles.push(file); + callback(); + } + } + + // Iterate through each file and make it public or private. + async.eachLimit(files, MAX_PARALLEL_LIMIT, processFile, function(err) { + if (err || errors.length > 0) { + callback(err || errors, updatedFiles); + return; + } + + callback(null, updatedFiles); + }); + }); +}; + +/*! Developer Documentation + * + * These methods can be auto-paginated. + */ +common.paginator.extend(Bucket, 'getFiles'); + +/*! Developer Documentation + * + * All async methods (except for streams) will return a Promise in the event + * that a callback is omitted. + */ +common.util.promisifyAll(Bucket, { + exclude: ['file', 'notification'], +}); + +/** + * Reference to the {@link Bucket} class. + * @name module:@google-cloud/storage.Bucket + * @see Bucket + */ +module.exports = Bucket; diff --git a/website/functions/node_modules/@google-cloud/storage/src/channel.js b/website/functions/node_modules/@google-cloud/storage/src/channel.js new file mode 100644 index 00000000..3d7f9b0e --- /dev/null +++ b/website/functions/node_modules/@google-cloud/storage/src/channel.js @@ -0,0 +1,116 @@ +/*! + * Copyright 2015 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. + */ + +'use strict'; + +const common = require('@google-cloud/common'); +const util = require('util'); + +/** + * Create a channel object to interact with a Cloud Storage channel. + * + * @see [Object Change Notification]{@link https://cloud.google.com/storage/docs/object-change-notification} + * + * @class + * + * @param {string} id The ID of the channel. + * @param {string} resourceId The resource ID of the channel. + * + * @example + * const storage = require('@google-cloud/storage')(); + * const channel = storage.channel('id', 'resource-id'); + */ +function Channel(storage, id, resourceId) { + const config = { + parent: storage, + baseUrl: '/channels', + + // An ID shouldn't be included in the API requests. + // RE: https://github.com/GoogleCloudPlatform/google-cloud-node/issues/1145 + id: '', + + methods: { + // Only need `request`. + }, + }; + + common.ServiceObject.call(this, config); + + this.metadata.id = id; + this.metadata.resourceId = resourceId; +} + +util.inherits(Channel, common.ServiceObject); + +/** + * @typedef {array} StopResponse + * @property {object} 0 The full API response. + */ +/** + * @callback StopCallback + * @param {?Error} err Request error, if any. + * @param {object} apiResponse The full API response. + */ +/** + * Stop this channel. + * + * @param {StopCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const channel = storage.channel('id', 'resource-id'); + * channel.stop(function(err, apiResponse) { + * if (!err) { + * // Channel stopped successfully. + * } + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * channel.stop().then(function(data) { + * const apiResponse = data[0]; + * }); + */ +Channel.prototype.stop = function(callback) { + callback = callback || common.util.noop; + + this.request( + { + method: 'POST', + uri: '/stop', + json: this.metadata, + }, + function(err, apiResponse) { + callback(err, apiResponse); + } + ); +}; + +/*! Developer Documentation + * + * All async methods (except for streams) will return a Promise in the event + * that a callback is omitted. + */ +common.util.promisifyAll(Channel); + +/** + * Reference to the {@link Channel} class. + * @name module:@google-cloud/storage.Channel + * @see Channel + */ +module.exports = Channel; diff --git a/website/functions/node_modules/@google-cloud/storage/src/file.js b/website/functions/node_modules/@google-cloud/storage/src/file.js new file mode 100644 index 00000000..95899887 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/storage/src/file.js @@ -0,0 +1,2475 @@ +/*! + * Copyright 2014 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. + */ + +'use strict'; + +const Buffer = require('safe-buffer').Buffer; +const common = require('@google-cloud/common'); +const compressible = require('compressible'); +const concat = require('concat-stream'); +const createErrorClass = require('create-error-class'); +const crypto = require('crypto'); +const duplexify = require('duplexify'); +const extend = require('extend'); +const fs = require('fs'); +const hashStreamValidation = require('hash-stream-validation'); +const is = require('is'); +const mime = require('mime'); +const once = require('once'); +const os = require('os'); +const pumpify = require('pumpify'); +const resumableUpload = require('gcs-resumable-upload'); +const streamEvents = require('stream-events'); +const through = require('through2'); +const util = require('util'); +const xdgBasedir = require('xdg-basedir'); +const zlib = require('zlib'); +const url = require('url'); + +const Acl = require('./acl.js'); + +/** + * Custom error type for errors related to creating a resumable upload. + * + * @private + */ +const ResumableUploadError = createErrorClass('ResumableUploadError'); + +/** + * Custom error type for errors related to getting signed errors and policies. + * + * @private + */ +const SigningError = createErrorClass('SigningError'); + +/** + * @const {string} + * @private + */ +const STORAGE_DOWNLOAD_BASE_URL = 'https://storage.googleapis.com'; + +/** + * @const {string} + * @private + */ +const STORAGE_UPLOAD_BASE_URL = + 'https://www.googleapis.com/upload/storage/v1/b'; + +/** + * @const {RegExp} + * @private + */ +const GS_URL_REGEXP = /^gs:\/\/([a-z0-9_.-]+)\/(.+)$/; + +/** + * A File object is created from your {@link Bucket} object using + * {@link Bucket#file}. + * + * @class + * @param {Bucket} bucket The Bucket instance this file is + * attached to. + * @param {string} name The name of the remote file. + * @param {object} [options] Configuration options. + * @param {string} [options.encryptionKey] A custom encryption key. + * @param {number} [options.generation] Generation to scope the file to. + * @param {string} [options.kmsKeyName] Cloud KMS Key used to encrypt this + * object, if the object is encrypted by such a key. Limited availability; + * usable only by enabled projects. + * @param {string} [options.userProject] The ID of the project which will be + * billed for all requests made from File object. + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * + * const file = myBucket.file('my-file'); + */ +function File(bucket, name, options) { + options = options || {}; + + this.bucket = bucket; + this.storage = bucket.parent; + + this.kmsKeyName = options.kmsKeyName; + this.userProject = options.userProject || bucket.userProject; + + Object.defineProperty(this, 'name', { + enumerable: true, + value: name.replace(/^\/+/, ''), // Remove leading slashes. + }); + + const generation = parseInt(options.generation, 10); + + if (!isNaN(generation)) { + this.generation = generation; + this.requestQueryObject = { + generation: this.generation, + }; + } + + common.ServiceObject.call(this, { + parent: bucket, + baseUrl: '/o', + id: encodeURIComponent(this.name), + }); + + if (options.encryptionKey) { + this.setEncryptionKey(options.encryptionKey); + } + + /** + * Cloud Storage uses access control lists (ACLs) to manage object and + * bucket access. ACLs are the mechanism you use to share objects with other + * users and allow other users to access your buckets and objects. + * + * An ACL consists of one or more entries, where each entry grants permissions + * to an entity. Permissions define the actions that can be performed against + * an object or bucket (for example, `READ` or `WRITE`); the entity defines + * who the permission applies to (for example, a specific user or group of + * users). + * + * The `acl` object on a File instance provides methods to get you a list of + * the ACLs defined on your bucket, as well as set, update, and delete them. + * + * @see [About Access Control lists]{@link http://goo.gl/6qBBPO} + * + * @name File#acl + * @mixes Acl + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * + * const file = myBucket.file('my-file'); + * //- + * // Make a file publicly readable. + * //- + * const options = { + * entity: 'allUsers', + * role: storage.acl.READER_ROLE + * }; + * + * file.acl.add(options, function(err, aclObject) {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * file.acl.add(options).then(function(data) { + * const aclObject = data[0]; + * const apiResponse = data[1]; + * }); + */ + this.acl = new Acl({ + request: this.request.bind(this), + pathPrefix: '/acl', + }); +} + +util.inherits(File, common.ServiceObject); + +/** + * @typedef {array} CopyResponse + * @property {File} 0 The copied {@link File}. + * @property {object} 1 The full API response. + */ +/** + * @callback CopyCallback + * @param {?Error} err Request error, if any. + * @param {File} copiedFile The copied {@link File}. + * @param {object} apiResponse The full API response. + */ +/** + * Copy this file to another file. By default, this will copy the file to the + * same bucket, but you can choose to copy it to another Bucket by providing + * a Bucket or File object or a URL starting with "gs://". + * + * @see [Objects: rewrite API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/objects/rewrite} + * + * @throws {Error} If the destination file is not provided. + * + * @param {string|Bucket|File} destination Destination file. + * @param {object} [options] Configuration options. See an + * [Object resource](https://cloud.google.com/storage/docs/json_api/v1/objects#resource). + * @param {string} [options.destinationKmsKeyName] Resource name of the Cloud + * KMS key, of the form + * `projects/my-project/locations/location/keyRings/my-kr/cryptoKeys/my-key`, + * that will be used to encrypt the object. Overwrites the object metadata's + * `kms_key_name` value, if any. + * @param {string} [options.keepAcl] Retain the ACL for the new file. + * @param {string} [options.predefinedAcl] Set the ACL for the new file. + * @param {string} [options.token] A previously-returned `rewriteToken` from an + * unfinished rewrite request. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {CopyCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * + * //- + * // You can pass in a variety of types for the destination. + * // + * // For all of the below examples, assume we are working with the following + * // Bucket and File objects. + * //- + * const bucket = storage.bucket('my-bucket'); + * const file = bucket.file('my-image.png'); + * + * //- + * // If you pass in a string for the destination, the file is copied to its + * // current bucket, under the new name provided. + * //- + * file.copy('my-image-copy.png', function(err, copiedFile, apiResponse) { + * // `my-bucket` now contains: + * // - "my-image.png" + * // - "my-image-copy.png" + * + * // `copiedFile` is an instance of a File object that refers to your new + * // file. + * }); + * + * //- + * // If you pass in a string starting with "gs://" for the destination, the + * // file is copied to the other bucket and under the new name provided. + * //- + * const newLocation = 'gs://another-bucket/my-image-copy.png'; + * file.copy(newLocation, function(err, copiedFile, apiResponse) { + * // `my-bucket` still contains: + * // - "my-image.png" + * // + * // `another-bucket` now contains: + * // - "my-image-copy.png" + * + * // `copiedFile` is an instance of a File object that refers to your new + * // file. + * }); + * + * //- + * // If you pass in a Bucket object, the file will be copied to that bucket + * // using the same name. + * //- + * const anotherBucket = storage.bucket('another-bucket'); + * file.copy(anotherBucket, function(err, copiedFile, apiResponse) { + * // `my-bucket` still contains: + * // - "my-image.png" + * // + * // `another-bucket` now contains: + * // - "my-image.png" + * + * // `copiedFile` is an instance of a File object that refers to your new + * // file. + * }); + * + * //- + * // If you pass in a File object, you have complete control over the new + * // bucket and filename. + * //- + * const anotherFile = anotherBucket.file('my-awesome-image.png'); + * file.copy(anotherFile, function(err, copiedFile, apiResponse) { + * // `my-bucket` still contains: + * // - "my-image.png" + * // + * // `another-bucket` now contains: + * // - "my-awesome-image.png" + * + * // Note: + * // The `copiedFile` parameter is equal to `anotherFile`. + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * file.copy(newLocation).then(function(data) { + * const newFile = data[0]; + * const apiResponse = data[1]; + * }); + * + * @example include:samples/files.js + * region_tag:storage_copy_file + * Another example: + */ +File.prototype.copy = function(destination, options, callback) { + const self = this; + + const noDestinationError = new Error('Destination file should have a name.'); + + if (!destination) { + throw noDestinationError; + } + + if (is.fn(options)) { + callback = options; + options = {}; + } + + options = extend(true, {}, options); + callback = callback || common.util.noop; + + let destBucket; + let destName; + let newFile; + + if (is.string(destination)) { + const parsedDestination = GS_URL_REGEXP.exec(destination); + if (parsedDestination !== null && parsedDestination.length === 3) { + destBucket = this.storage.bucket(parsedDestination[1]); + destName = parsedDestination[2]; + } else { + destBucket = this.bucket; + destName = destination; + } + } else if ( + destination.constructor && + destination.constructor.name === 'Bucket' + ) { + destBucket = destination; + destName = this.name; + } else if (destination instanceof File) { + destBucket = destination.bucket; + destName = destination.name; + newFile = destination; + } else { + throw noDestinationError; + } + + const query = {}; + if (is.defined(this.generation)) { + query.sourceGeneration = this.generation; + } + if (is.defined(options.token)) { + query.rewriteToken = options.token; + } + if (is.defined(options.userProject)) { + query.userProject = options.userProject; + delete options.userProject; + } + + newFile = newFile || destBucket.file(destName); + + const headers = {}; + + if (is.defined(this.encryptionKey)) { + headers['x-goog-copy-source-encryption-algorithm'] = 'AES256'; + headers['x-goog-copy-source-encryption-key'] = this.encryptionKeyBase64; + headers[ + 'x-goog-copy-source-encryption-key-sha256' + ] = this.encryptionKeyHash; + } + + if (is.defined(newFile.encryptionKey)) { + this.setEncryptionKey(newFile.encryptionKey); + } else if (is.defined(options.destinationKmsKeyName)) { + query.destinationKmsKeyName = options.destinationKmsKeyName; + delete options.destinationKmsKeyName; + } else if (is.defined(newFile.kmsKeyName)) { + query.destinationKmsKeyName = newFile.kmsKeyName; + } + + if (query.destinationKmsKeyName) { + this.kmsKeyName = query.destinationKmsKeyName; + + const keyIndex = this.interceptors.indexOf(this.encryptionKeyInterceptor); + if (keyIndex > -1) { + this.interceptors.splice(keyIndex, 1); + } + } + + this.request( + { + method: 'POST', + uri: `/rewriteTo/b/${destBucket.name}/o/${encodeURIComponent(destName)}`, + qs: query, + json: options, + headers: headers, + }, + function(err, resp) { + if (err) { + callback(err, null, resp); + return; + } + + if (resp.rewriteToken) { + const options = { + token: resp.rewriteToken, + }; + + if (query.userProject) { + options.userProject = query.userProject; + } + + if (query.destinationKmsKeyName) { + options.destinationKmsKeyName = query.destinationKmsKeyName; + } + + self.copy(newFile, options, callback); + return; + } + + callback(null, newFile, resp); + } + ); +}; + +/** + * Create a readable stream to read the contents of the remote file. It can be + * piped to a writable stream or listened to for 'data' events to read a file's + * contents. + * + * In the unlikely event there is a mismatch between what you downloaded and the + * version in your Bucket, your error handler will receive an error with code + * "CONTENT_DOWNLOAD_MISMATCH". If you receive this error, the best recourse is + * to try downloading the file again. + * + * For faster crc32c computation, you must manually install + * [`fast-crc32c`](http://www.gitnpm.com/fast-crc32c): + * + * $ npm install --save fast-crc32c + * + * NOTE: Readable streams will emit the `end` event when the file is fully + * downloaded. + * + * @param {object} [options] Configuration options. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {string|boolean} [options.validation] Possible values: `"md5"`, + * `"crc32c"`, or `false`. By default, data integrity is validated with a + * CRC32c checksum. You may use MD5 if preferred, but that hash is not + * supported for composite objects. An error will be raised if MD5 is + * specified but is not available. You may also choose to skip validation + * completely, however this is **not recommended**. + * @param {number} [options.start] A byte offset to begin the file's download + * from. Default is 0. NOTE: Byte ranges are inclusive; that is, + * `options.start = 0` and `options.end = 999` represent the first 1000 + * bytes in a file or object. NOTE: when specifying a byte range, data + * integrity is not available. + * @param {number} [options.end] A byte offset to stop reading the file at. + * NOTE: Byte ranges are inclusive; that is, `options.start = 0` and + * `options.end = 999` represent the first 1000 bytes in a file or object. + * NOTE: when specifying a byte range, data integrity is not available. + * @returns {ReadableStream} + * + * @example + * //- + * //

Downloading a File

+ * // + * // The example below demonstrates how we can reference a remote file, then + * // pipe its contents to a local file. This is effectively creating a local + * // backup of your remote data. + * //- + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('my-bucket'); + * + * const fs = require('fs'); + * const remoteFile = bucket.file('image.png'); + * const localFilename = '/Users/stephen/Photos/image.png'; + * + * remoteFile.createReadStream() + * .on('error', function(err) {}) + * .on('response', function(response) { + * // Server connected and responded with the specified status and headers. + * }) + * .on('end', function() { + * // The file is fully downloaded. + * }) + * .pipe(fs.createWriteStream(localFilename)); + * + * //- + * // To limit the downloaded data to only a byte range, pass an options object. + * //- + * const logFile = myBucket.file('access_log'); + * logFile.createReadStream({ + * start: 10000, + * end: 20000 + * }) + * .on('error', function(err) {}) + * .pipe(fs.createWriteStream('/Users/stephen/logfile.txt')); + * + * //- + * // To read a tail byte range, specify only `options.end` as a negative + * // number. + * //- + * const logFile = myBucket.file('access_log'); + * logFile.createReadStream({ + * end: -100 + * }) + * .on('error', function(err) {}) + * .pipe(fs.createWriteStream('/Users/stephen/logfile.txt')); + */ +File.prototype.createReadStream = function(options) { + options = options || {}; + + const self = this; + const rangeRequest = is.number(options.start) || is.number(options.end); + const tailRequest = options.end < 0; + + let validateStream; // Created later, if necessary. + const throughStream = streamEvents(through()); + + let crc32c = true; + let md5 = false; + + let refreshedMetadata = false; + + if (is.string(options.validation)) { + options.validation = options.validation.toLowerCase(); + crc32c = options.validation === 'crc32c'; + md5 = options.validation === 'md5'; + } else if (options.validation === false) { + crc32c = false; + } + + if (rangeRequest) { + if (is.string(options.validation) || options.validation === true) { + throw new Error('Cannot use validation with file ranges (start/end).'); + } + // Range requests can't receive data integrity checks. + crc32c = false; + md5 = false; + } + + // Authenticate the request, then pipe the remote API request to the stream + // returned to the user. + function makeRequest() { + const reqOpts = { + forever: false, + uri: '', + headers: { + 'Accept-Encoding': 'gzip', + }, + qs: { + alt: 'media', + }, + }; + + if (self.generation) { + reqOpts.qs.generation = self.generation; + } + + if (options.userProject) { + reqOpts.qs.userProject = options.userProject; + } + + if (rangeRequest) { + const start = is.number(options.start) ? options.start : '0'; + const end = is.number(options.end) ? options.end : ''; + + reqOpts.headers.Range = `bytes=${tailRequest ? end : `${start}-${end}`}`; + } + + self + .requestStream(reqOpts) + .on('error', err => { + throughStream.destroy(err); + }) + .on('response', res => { + throughStream.emit('response', res); + common.util.handleResp(null, res, null, onResponse); + }) + .resume(); + + // We listen to the response event from the request stream so that we can... + // + // 1) Intercept any data from going to the user if an error occurred. + // 2) Calculate the hashes from the http.IncomingMessage response stream, + // which will return the bytes from the source without decompressing + // gzip'd content. We then send it through decompressed, if applicable, + // to the user. + function onResponse(err, body, rawResponseStream) { + if (err) { + // Get error message from the body. + rawResponseStream.pipe( + concat(function(body) { + err.message = body.toString(); + throughStream.destroy(err); + }) + ); + + return; + } + + const headers = rawResponseStream.toJSON().headers; + const isCompressed = headers['content-encoding'] === 'gzip'; + + const shouldRunValidation = !rangeRequest && (crc32c || md5); + + const throughStreams = []; + + if (shouldRunValidation) { + validateStream = hashStreamValidation({crc32c, md5}); + throughStreams.push(validateStream); + } + + if (isCompressed) { + throughStreams.push(zlib.createGunzip()); + } + + if (throughStreams.length === 1) { + rawResponseStream = rawResponseStream.pipe(throughStreams[0]); + } else if (throughStreams.length > 1) { + rawResponseStream = rawResponseStream.pipe(pumpify.obj(throughStreams)); + } + + rawResponseStream.on('end', onComplete).pipe(throughStream, {end: false}); + } + + // This is hooked to the `complete` event from the request stream. This is + // our chance to validate the data and let the user know if anything went + // wrong. + function onComplete(err) { + if (err) { + throughStream.destroy(err); + return; + } + + if (rangeRequest) { + throughStream.end(); + return; + } + + if (!refreshedMetadata) { + refreshedMetadata = true; + self.getMetadata({userProject: options.userProject}, onComplete); + return; + } + + const hashes = { + crc32c: self.metadata.crc32c, + md5: self.metadata.md5Hash, + }; + + // If we're doing validation, assume the worst-- a data integrity + // mismatch. If not, these tests won't be performed, and we can assume the + // best. + let failed = crc32c || md5; + + if (crc32c && hashes.crc32c) { + // We must remove the first four bytes from the returned checksum. + // http://stackoverflow.com/questions/25096737/ + // base64-encoding-of-crc32c-long-value + failed = !validateStream.test('crc32c', hashes.crc32c.substr(4)); + } + + if (md5 && hashes.md5) { + failed = !validateStream.test('md5', hashes.md5); + } + + if (md5 && !hashes.md5) { + const hashError = new Error( + [ + 'MD5 verification was specified, but is not available for the', + 'requested object. MD5 is not available for composite objects.', + ].join(' ') + ); + hashError.code = 'MD5_NOT_AVAILABLE'; + + throughStream.destroy(hashError); + } else if (failed) { + const mismatchError = new Error( + [ + 'The downloaded data did not match the data from the server.', + 'To be sure the content is the same, you should download the', + 'file again.', + ].join(' ') + ); + mismatchError.code = 'CONTENT_DOWNLOAD_MISMATCH'; + + throughStream.destroy(mismatchError); + } else { + throughStream.end(); + } + } + } + + throughStream.on('reading', makeRequest); + + return throughStream; +}; + +/** + * @typedef {array} CreateResumableUploadResponse + * @property {string} 0 The resumable upload's unique session URI. + */ +/** + * @callback CreateResumableUploadCallback + * @param {?Error} err Request error, if any. + * @param {string} uri The resumable upload's unique session URI. + */ +/** + * Create a unique resumable upload session URI. This is the first step when + * performing a resumable upload. + * + * See the [Resumable upload guide](https://cloud.google.com/storage/docs/json_api/v1/how-tos/resumable-upload) + * for more on how the entire process works. + * + *

Note

+ * + * If you are just looking to perform a resumable upload without worrying about + * any of the details, see {@link File#createWriteStream}. Resumable uploads + * are performed by default. + * + * @see [Resumable upload guide]{@link https://cloud.google.com/storage/docs/json_api/v1/how-tos/resumable-upload} + * + * @param {object} [options] Configuration options. + * @param {object} [options.metadata] Metadata to set on the file. + * @param {string} [options.origin] Origin header to set for the upload. + * @param {string} [options.predefinedAcl] Apply a predefined set of access + * controls to this object. + * + * Acceptable values are: + * - **`authenticatedRead`** - Object owner gets `OWNER` access, and + * `allAuthenticatedUsers` get `READER` access. + * + * - **`bucketOwnerFullControl`** - Object owner gets `OWNER` access, and + * project team owners get `OWNER` access. + * + * - **`bucketOwnerRead`** - Object owner gets `OWNER` access, and project + * team owners get `READER` access. + * + * - **`private`** - Object owner gets `OWNER` access. + * + * - **`projectPrivate`** - Object owner gets `OWNER` access, and project + * team members get access according to their roles. + * + * - **`publicRead`** - Object owner gets `OWNER` access, and `allUsers` get + * `READER` access. + * @param {boolean} [options.private] Make the uploaded file private. (Alias for + * `options.predefinedAcl = 'private'`) + * @param {boolean} [options.public] Make the uploaded file public. (Alias for + * `options.predefinedAcl = 'publicRead'`) + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {CreateResumableUploadCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * + * const file = myBucket.file('my-file'); + * file.createResumableUpload(function(err, uri) { + * if (!err) { + * // `uri` can be used to PUT data to. + * } + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * file.createResumableUpload().then(function(data) { + * const uri = data[0]; + * }); + */ +File.prototype.createResumableUpload = function(options, callback) { + if (is.fn(options)) { + callback = options; + options = {}; + } + + resumableUpload.createURI( + { + authClient: this.storage.authClient, + bucket: this.bucket.name, + file: this.name, + generation: this.generation, + key: this.encryptionKey, + kmsKeyName: this.kmsKeyName, + metadata: options.metadata, + offset: options.offset, + origin: options.origin, + predefinedAcl: options.predefinedAcl, + private: options.private, + public: options.public, + userProject: options.userProject, + }, + callback + ); +}; + +/** + * Create a writable stream to overwrite the contents of the file in your + * bucket. + * + * A File object can also be used to create files for the first time. + * + * Resumable uploads are automatically enabled and must be shut off explicitly + * by setting `options.resumable` to `false`. + * + * Resumable uploads require write access to the $HOME directory. Through + * [`config-store`](http://www.gitnpm.com/configstore), some metadata is stored. + * By default, if the directory is not writable, we will fall back to a simple + * upload. However, if you explicitly request a resumable upload, and we cannot + * write to the config directory, we will return a `ResumableUploadError`. + * + *

+ * There is some overhead when using a resumable upload that can cause + * noticeable performance degradation while uploading a series of small files. + * When uploading files less than 10MB, it is recommended that the resumable + * feature is disabled. + *

+ * + * For faster crc32c computation, you must manually install + * [`fast-crc32c`](http://www.gitnpm.com/fast-crc32c): + * + * $ npm install --save fast-crc32c + * + * NOTE: Writable streams will emit the `finish` event when the file is fully + * uploaded. + * + * @see [Upload Options (Simple or Resumable)]{@link https://cloud.google.com/storage/docs/json_api/v1/how-tos/upload} + * @see [Objects: insert API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/objects/insert} + * + * @param {object} [options] Configuration options. + * @param {string} [options.contentType] Alias for + * `options.metadata.contentType`. If set to `auto`, the file name is used + * to determine the contentType. + * @param {string|boolean} [options.gzip] If true, automatically gzip the file. + * If set to `auto`, the contentType is used to determine if the file should + * be gzipped. This will set `options.metadata.contentEncoding` to `gzip` if + * necessary. + * @param {object} [options.metadata] See the examples below or + * [Objects: insert request body](https://cloud.google.com/storage/docs/json_api/v1/objects/insert#request_properties_JSON) + * for more details. + * @param {string} [options.offset] The starting byte of the upload stream, for + * resuming an interrupted upload. Defaults to 0. + * @param {string} [options.predefinedAcl] Apply a predefined set of access + * controls to this object. + * + * Acceptable values are: + * - **`authenticatedRead`** - Object owner gets `OWNER` access, and + * `allAuthenticatedUsers` get `READER` access. + * + * - **`bucketOwnerFullControl`** - Object owner gets `OWNER` access, and + * project team owners get `OWNER` access. + * + * - **`bucketOwnerRead`** - Object owner gets `OWNER` access, and project + * team owners get `READER` access. + * + * - **`private`** - Object owner gets `OWNER` access. + * + * - **`projectPrivate`** - Object owner gets `OWNER` access, and project + * team members get access according to their roles. + * + * - **`publicRead`** - Object owner gets `OWNER` access, and `allUsers` get + * `READER` access. + * @param {boolean} [options.private] Make the uploaded file private. (Alias for + * `options.predefinedAcl = 'private'`) + * @param {boolean} [options.public] Make the uploaded file public. (Alias for + * `options.predefinedAcl = 'publicRead'`) + * @param {boolean} [options.resumable] Force a resumable upload. NOTE: When + * working with streams, the file format and size is unknown until it's + * completely consumed. Because of this, it's best for you to be explicit + * for what makes sense given your input. + * @param {string} [options.uri] The URI for an already-created resumable + * upload. See {@link File#createResumableUpload}. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {string|boolean} [options.validation] Possible values: `"md5"`, + * `"crc32c"`, or `false`. By default, data integrity is validated with a + * CRC32c checksum. You may use MD5 if preferred, but that hash is not + * supported for composite objects. An error will be raised if MD5 is + * specified but is not available. You may also choose to skip validation + * completely, however this is **not recommended**. + * @returns {WritableStream} + * + * @example + * const fs = require('fs'); + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * + * const file = myBucket.file('my-file'); + * + * //- + * //

Uploading a File

+ * // + * // Now, consider a case where we want to upload a file to your bucket. You + * // have the option of using {@link Bucket#upload}, but that is just + * // a convenience method which will do the following. + * //- + * fs.createReadStream('/Users/stephen/Photos/birthday-at-the-zoo/panda.jpg') + * .pipe(file.createWriteStream()) + * .on('error', function(err) {}) + * .on('finish', function() { + * // The file upload is complete. + * }); + * + * //- + * //

Uploading a File with gzip compression

+ * //- + * fs.createReadStream('/Users/stephen/site/index.html') + * .pipe(file.createWriteStream({ gzip: true })) + * .on('error', function(err) {}) + * .on('finish', function() { + * // The file upload is complete. + * }); + * + * //- + * // Downloading the file with `createReadStream` will automatically decode the + * // file. + * //- + * + * //- + * //

Uploading a File with Metadata

+ * // + * // One last case you may run into is when you want to upload a file to your + * // bucket and set its metadata at the same time. Like above, you can use + * // {@link Bucket#upload} to do this, which is just a wrapper around + * // the following. + * //- + * fs.createReadStream('/Users/stephen/Photos/birthday-at-the-zoo/panda.jpg') + * .pipe(file.createWriteStream({ + * metadata: { + * contentType: 'image/jpeg', + * metadata: { + * custom: 'metadata' + * } + * } + * })) + * .on('error', function(err) {}) + * .on('finish', function() { + * // The file upload is complete. + * }); + */ +File.prototype.createWriteStream = function(options) { + options = options || {}; + + const self = this; + + options = extend({metadata: {}}, options); + + if (options.contentType) { + options.metadata.contentType = options.contentType; + + if (options.metadata.contentType === 'auto') { + options.metadata.contentType = mime.getType(this.name); + } + } + + let gzip = options.gzip; + + if (gzip === 'auto') { + gzip = compressible(options.metadata.contentType); + } + + if (gzip) { + options.metadata.contentEncoding = 'gzip'; + } + + let crc32c = true; + let md5 = false; + + if (is.string(options.validation)) { + options.validation = options.validation.toLowerCase(); + crc32c = options.validation === 'crc32c'; + md5 = options.validation === 'md5'; + } else if (options.validation === false) { + crc32c = false; + } + + // Collect data as it comes in to store in a hash. This is compared to the + // checksum value on the returned metadata from the API. + const validateStream = hashStreamValidation({ + crc32c: crc32c, + md5: md5, + }); + + const fileWriteStream = duplexify(); + + const stream = streamEvents( + pumpify([ + gzip ? zlib.createGzip() : through(), + validateStream, + fileWriteStream, + ]) + ); + + // Wait until we've received data to determine what upload technique to use. + stream.on('writing', function() { + if (options.resumable === false) { + self.startSimpleUpload_(fileWriteStream, options); + return; + } + + // Same as configstore: + // https://github.com/yeoman/configstore/blob/f09f067e50e6a636cfc648a6fc36a522062bd49d/index.js#L11 + const configDir = xdgBasedir.config || os.tmpdir(); + + fs.access(configDir, fs.W_OK, function(err) { + if (err) { + if (options.resumable) { + const error = new ResumableUploadError( + [ + 'A resumable upload could not be performed. The directory,', + `${configDir}, is not writable. You may try another upload,`, + 'this time setting `options.resumable` to `false`.', + ].join(' ') + ); + stream.destroy(error); + return; + } + + // User didn't care, resumable or not. Fall back to simple upload. + self.startSimpleUpload_(fileWriteStream, options); + return; + } + + self.startResumableUpload_(fileWriteStream, options); + }); + }); + + fileWriteStream.on('response', stream.emit.bind(stream, 'response')); + + // This is to preserve the `finish` event. We wait until the request stream + // emits "complete", as that is when we do validation of the data. After that + // is successful, we can allow the stream to naturally finish. + // + // Reference for tracking when we can use a non-hack solution: + // https://github.com/nodejs/node/pull/2314 + fileWriteStream.on('prefinish', function() { + stream.cork(); + }); + + // Compare our hashed version vs the completed upload's version. + fileWriteStream.on('complete', function() { + const metadata = self.metadata; + + // If we're doing validation, assume the worst-- a data integrity mismatch. + // If not, these tests won't be performed, and we can assume the best. + let failed = crc32c || md5; + + if (crc32c && metadata.crc32c) { + // We must remove the first four bytes from the returned checksum. + // http://stackoverflow.com/questions/25096737/ + // base64-encoding-of-crc32c-long-value + failed = !validateStream.test('crc32c', metadata.crc32c.substr(4)); + } + + if (md5 && metadata.md5Hash) { + failed = !validateStream.test('md5', metadata.md5Hash); + } + + if (failed) { + self.delete(function(err) { + let code; + let message; + + if (err) { + code = 'FILE_NO_UPLOAD_DELETE'; + message = [ + 'The uploaded data did not match the data from the server. As a', + 'precaution, we attempted to delete the file, but it was not', + 'successful. To be sure the content is the same, you should try', + 'removing the file manually, then uploading the file again.', + '\n\nThe delete attempt failed with this message:', + '\n\n ' + err.message, + ].join(' '); + } else if (md5 && !metadata.md5Hash) { + code = 'MD5_NOT_AVAILABLE'; + message = [ + 'MD5 verification was specified, but is not available for the', + 'requested object. MD5 is not available for composite objects.', + ].join(' '); + } else { + code = 'FILE_NO_UPLOAD'; + message = [ + 'The uploaded data did not match the data from the server. As a', + 'precaution, the file has been deleted. To be sure the content', + 'is the same, you should try uploading the file again.', + ].join(' '); + } + + const error = new Error(message); + error.code = code; + error.errors = [err]; + + fileWriteStream.destroy(error); + }); + + return; + } + + stream.uncork(); + }); + + return stream; +}; + +/** + * @typedef {array} DeleteFileResponse + * @property {object} 0 The full API response. + */ +/** + * @callback DeleteFileCallback + * @param {?Error} err Request error, if any. + * @param {object} apiResponse The full API response. + */ +/** + * Delete the file. + * + * @see [Objects: delete API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/objects/delete} + * + * @param {object} [options] Configuration options. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {DeleteFileCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * + * const file = myBucket.file('my-file'); + * file.delete(function(err, apiResponse) {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * file.delete().then(function(data) { + * const apiResponse = data[0]; + * }); + * + * @example include:samples/files.js + * region_tag:storage_delete_file + * Another example: + */ +File.prototype.delete = function(options, callback) { + if (is.fn(options)) { + callback = options; + options = {}; + } + + options = extend({}, this.requestQueryObject, options); + + this.parent.delete.call(this, options, callback); +}; + +/** + * @typedef {array} DownloadResponse + * @property {object} [0] The contents of a File. + */ +/** + * @callback DownloadCallback + * @param {?Error} err Request error, if any. + * @param {buffer} [contents] The contents of a File. + */ +/** + * Convenience method to download a file into memory or to a local destination. + * + * @param {object} [options] Configuration options. The arguments match those + * passed to {@link File#createReadStream}. + * @param {string} [options.destination] Local file path to write the file's + * contents to. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {DownloadCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * + * const file = myBucket.file('my-file'); + * + * //- + * // Download a file into memory. The contents will be available as the second + * // argument in the demonstration below, `contents`. + * //- + * file.download(function(err, contents) {}); + * + * //- + * // Download a file to a local destination. + * //- + * file.download({ + * destination: '/Users/me/Desktop/file-backup.txt' + * }, function(err) {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * file.download().then(function(data) { + * const contents = data[0]; + * }); + * + * @example include:samples/files.js + * region_tag:storage_download_file + * Another example: + * + * @example include:samples/encryption.js + * region_tag:storage_download_encrypted_file + * Example of downloading an encrypted file: + * + * @example include:samples/requesterPays.js + * region_tag:storage_download_file_requester_pays + * Example of downloading a file where the requester pays: + */ +File.prototype.download = function(options, callback) { + if (is.fn(options)) { + callback = options; + options = {}; + } + + callback = once(callback); + + const destination = options.destination; + delete options.destination; + + const fileStream = this.createReadStream(options); + + if (destination) { + fileStream + .on('error', callback) + .pipe(fs.createWriteStream(destination)) + .on('error', callback) + .on('finish', callback); + } else { + fileStream.on('error', callback).pipe(concat(callback.bind(null, null))); + } +}; + +/** + * @typedef {array} FileExistsResponse + * @property {boolean} 0 Whether the {@link File} exists. + */ +/** + * @callback FileExistsCallback + * @param {?Error} err Request error, if any. + * @param {boolean} exists Whether the {@link File} exists. + */ +/** + * Check if the file exists. + * + * @param {options} [options] Configuration options. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {FileExistsCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * + * const file = myBucket.file('my-file'); + * + * file.exists(function(err, exists) {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * file.exists().then(function(data) { + * const exists = data[0]; + * }); + */ +File.prototype.exists = function(options, callback) { + this.parent.exists.call(this, options, callback); +}; + +/** + * The Storage API allows you to use a custom key for server-side encryption. + * + * @see [Customer-supplied Encryption Keys]{@link https://cloud.google.com/storage/docs/encryption#customer-supplied} + * + * @param {string|buffer} encryptionKey An AES-256 encryption key. + * @returns {File} + * + * @example + * const crypto = require('crypto'); + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * + * const encryptionKey = crypto.randomBytes(32); + * + * const fileWithCustomEncryption = myBucket.file('my-file'); + * fileWithCustomEncryption.setEncryptionKey(encryptionKey); + * + * const fileWithoutCustomEncryption = myBucket.file('my-file'); + * + * fileWithCustomEncryption.save('data', function(err) { + * // Try to download with the File object that hasn't had + * // `setEncryptionKey()` called: + * fileWithoutCustomEncryption.download(function(err) { + * // We will receive an error: + * // err.message === 'Bad Request' + * + * // Try again with the File object we called `setEncryptionKey()` on: + * fileWithCustomEncryption.download(function(err, contents) { + * // contents.toString() === 'data' + * }); + * }); + * }); + * + * @example include:samples/encryption.js + * region_tag:storage_upload_encrypted_file + * Example of uploading an encrypted file: + * + * @example include:samples/encryption.js + * region_tag:storage_download_encrypted_file + * Example of downloading an encrypted file: + */ +File.prototype.setEncryptionKey = function(encryptionKey) { + const self = this; + + this.encryptionKey = encryptionKey; + this.encryptionKeyBase64 = Buffer.from(encryptionKey).toString('base64'); + + this.encryptionKeyHash = crypto + .createHash('sha256') + .update(this.encryptionKeyBase64, 'base64') + .digest('base64'); + + this.encryptionKeyInterceptor = { + request: function(reqOpts) { + reqOpts.headers = reqOpts.headers || {}; + reqOpts.headers['x-goog-encryption-algorithm'] = 'AES256'; + reqOpts.headers['x-goog-encryption-key'] = self.encryptionKeyBase64; + reqOpts.headers['x-goog-encryption-key-sha256'] = self.encryptionKeyHash; + return reqOpts; + }, + }; + + this.interceptors.push(this.encryptionKeyInterceptor); + + return this; +}; + +/** + * @typedef {array} GetFileResponse + * @property {File} 0 The {@link File}. + * @property {object} 1 The full API response. + */ +/** + * @callback GetFileCallback + * @param {?Error} err Request error, if any. + * @param {File} file The {@link File}. + * @param {object} apiResponse The full API response. + */ +/** + * Get a file object and its metadata if it exists. + * + * @param {options} [options] Configuration options. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {GetFileCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * + * const file = myBucket.file('my-file'); + * + * file.get(function(err, file, apiResponse) { + * // file.metadata` has been populated. + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * file.get().then(function(data) { + * const file = data[0]; + * const apiResponse = data[1]; + * }); + */ +File.prototype.get = function(options, callback) { + this.parent.get.call(this, options, callback); +}; + +/** + * @typedef {array} GetFileMetadataResponse + * @property {object} 0 The {@link File} metadata. + * @property {object} 1 The full API response. + */ +/** + * @callback GetFileMetadataCallback + * @param {?Error} err Request error, if any. + * @param {object} metadata The {@link File} metadata. + * @param {object} apiResponse The full API response. + */ +/** + * Get the file's metadata. + * + * @see [Objects: get API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/objects/get} + * + * @param {object} [options] Configuration options. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {GetFileMetadataCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * + * const file = myBucket.file('my-file'); + * + * file.getMetadata(function(err, metadata, apiResponse) {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * file.getMetadata().then(function(data) { + * const metadata = data[0]; + * const apiResponse = data[1]; + * }); + * + * @example include:samples/files.js + * region_tag:storage_get_metadata + * Another example: + */ +File.prototype.getMetadata = function(options, callback) { + if (is.fn(options)) { + callback = options; + options = {}; + } + + options = extend({}, this.requestQueryObject, options); + + this.parent.getMetadata.call(this, options, callback); +}; + +/** + * @typedef {array} GetSignedPolicyResponse + * @property {object} 0 The document policy. + */ +/** + * @callback GetSignedPolicyCallback + * @param {?Error} err Request error, if any. + * @param {object} policy The document policy. + */ +/** + * Get a signed policy document to allow a user to upload data with a POST + * request. + * + * In Google Cloud Platform environments, such as Cloud Functions and App + * Engine, you usually don't provide a `keyFilename` or `credentials` during + * instantiation. In those environments, we call the + * [signBlob API](https://cloud.google.com/iam/reference/rest/v1/projects.serviceAccounts/signBlob#authorization-scopes) + * to create a signed policy. That API requires either the + * `https://www.googleapis.com/auth/iam` or + * `https://www.googleapis.com/auth/cloud-platform` scope, so be sure they are + * enabled. + * + * @see [Policy Document Reference]{@link https://cloud.google.com/storage/docs/xml-api/post-object#policydocument} + * + * @throws {Error} If an expiration timestamp from the past is given. + * @throws {Error} If options.equals has an array with less or more than two + * members. + * @throws {Error} If options.startsWith has an array with less or more than two + * members. + * + * @param {object} options Configuration options. + * @param {array|array[]} [options.equals] Array of request parameters and + * their expected value (e.g. [['$', '']]). Values are + * translated into equality constraints in the conditions field of the + * policy document (e.g. ['eq', '$', '']). If only one + * equality condition is to be specified, options.equals can be a one- + * dimensional array (e.g. ['$', '']). + * @param {*} options.expires - A timestamp when this policy will expire. Any + * value given is passed to `new Date()`. + * @param {array|array[]} [options.startsWith] Array of request parameters and + * their expected prefixes (e.g. [['$', '']). Values are + * translated into starts-with constraints in the conditions field of the + * policy document (e.g. ['starts-with', '$', '']). If only + * one prefix condition is to be specified, options.startsWith can be a one- + * dimensional array (e.g. ['$', '']). + * @param {string} [options.acl] ACL for the object from possibly predefined + * ACLs. + * @param {string} [options.successRedirect] The URL to which the user client + * is redirected if the upload is successful. + * @param {string} [options.successStatus] - The status of the Google Storage + * response if the upload is successful (must be string). + * @param {object} [options.contentLengthRange] + * @param {number} [options.contentLengthRange.min] Minimum value for the + * request's content length. + * @param {number} [options.contentLengthRange.max] Maximum value for the + * request's content length. + * @param {GetSignedPolicyCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * + * const file = myBucket.file('my-file'); + * const options = { + * equals: ['$Content-Type', 'image/jpeg'], + * expires: '10-25-2022', + * contentLengthRange: { + * min: 0, + * max: 1024 + * } + * }; + * + * file.getSignedPolicy(options, function(err, policy) { + * // policy.string: the policy document in plain text. + * // policy.base64: the policy document in base64. + * // policy.signature: the policy signature in base64. + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * file.getSignedPolicy(options).then(function(data) { + * const policy = data[0]; + * }); + */ +File.prototype.getSignedPolicy = function(options, callback) { + const expires = new Date(options.expires); + + if (expires < Date.now()) { + throw new Error('An expiration date cannot be in the past.'); + } + + options = extend({}, options); + + const conditions = [ + ['eq', '$key', this.name], + { + bucket: this.bucket.name, + }, + ]; + + if (is.array(options.equals)) { + if (!is.array(options.equals[0])) { + options.equals = [options.equals]; + } + options.equals.forEach(function(condition) { + if (!is.array(condition) || condition.length !== 2) { + throw new Error('Equals condition must be an array of 2 elements.'); + } + conditions.push(['eq', condition[0], condition[1]]); + }); + } + + if (is.array(options.startsWith)) { + if (!is.array(options.startsWith[0])) { + options.startsWith = [options.startsWith]; + } + options.startsWith.forEach(function(condition) { + if (!is.array(condition) || condition.length !== 2) { + throw new Error('StartsWith condition must be an array of 2 elements.'); + } + conditions.push(['starts-with', condition[0], condition[1]]); + }); + } + + if (options.acl) { + conditions.push({ + acl: options.acl, + }); + } + + if (options.successRedirect) { + conditions.push({ + success_action_redirect: options.successRedirect, + }); + } + + if (options.successStatus) { + conditions.push({ + success_action_status: options.successStatus, + }); + } + + if (options.contentLengthRange) { + const min = options.contentLengthRange.min; + const max = options.contentLengthRange.max; + if (!is.number(min) || !is.number(max)) { + throw new Error('ContentLengthRange must have numeric min & max fields.'); + } + conditions.push(['content-length-range', min, max]); + } + + const policy = { + expiration: expires.toISOString(), + conditions: conditions, + }; + + const policyString = JSON.stringify(policy); + const policyBase64 = Buffer.from(policyString).toString('base64'); + + this.storage.authClient.sign(policyBase64, function(err, signature) { + if (err) { + callback(new SigningError(err.message)); + return; + } + + callback(null, { + string: policyString, + base64: policyBase64, + signature: signature, + }); + }); +}; + +/** + * @typedef {array} GetSignedUrlResponse + * @property {object} 0 The signed URL. + */ +/** + * @callback GetSignedUrlCallback + * @param {?Error} err Request error, if any. + * @param {object} url The signed URL. + */ +/** + * Get a signed URL to allow limited time access to the file. + * + * In Google Cloud Platform environments, such as Cloud Functions and App + * Engine, you usually don't provide a `keyFilename` or `credentials` during + * instantiation. In those environments, we call the + * [signBlob API](https://cloud.google.com/iam/reference/rest/v1/projects.serviceAccounts/signBlob#authorization-scopes) + * to create a signed URL. That API requires either the + * `https://www.googleapis.com/auth/iam` or + * `https://www.googleapis.com/auth/cloud-platform` scope, so be sure they are + * enabled. + * + * @see [Signed URLs Reference]{@link https://cloud.google.com/storage/docs/access-control/signed-urls} + * + * @throws {Error} if an expiration timestamp from the past is given. + * + * @param {object} config Configuration object. + * @param {string} config.action "read" (HTTP: GET), "write" (HTTP: PUT), or + * "delete" (HTTP: DELETE), "resumable" (HTTP: POST). + * @param {string} [config.cname] The cname for this bucket, i.e., + * "https://cdn.example.com". + * @param {string} [config.contentMd5] The MD5 digest value in base64. If you + * provide this, the client must provide this HTTP header with this same + * value in its request. + * @param {string} [config.contentType] If you provide this value, the client + * must provide this HTTP header set to the same value. + * @param {*} config.expires A timestamp when this link will expire. Any value + * given is passed to `new Date()`. + * @param {object} [config.extensionHeaders] If these headers are used, the + * server will check to make sure that the client provides matching values. + * See [Canonical extension headers](https://cloud.google.com/storage/docs/access-control/signed-urls#about-canonical-extension-headers) + * for the requirements of this feature, most notably: + * - The header name must be prefixed with `x-goog-` + * - The header name must be all lowercase + * @param {string} [config.promptSaveAs] The filename to prompt the user to + * save the file as when the signed url is accessed. This is ignored if + * `config.responseDisposition` is set. + * @param {string} [config.responseDisposition] The + * [response-content-disposition parameter](http://goo.gl/yMWxQV) of the + * signed url. + * @param {string} [config.responseType] The response-content-type parameter + * of the signed url. + * @param {GetSignedUrlCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * + * const file = myBucket.file('my-file'); + * + * //- + * // Generate a URL that allows temporary access to download your file. + * //- + * const request = require('request'); + * + * const config = { + * action: 'read', + * expires: '03-17-2025' + * }; + * + * file.getSignedUrl(config, function(err, url) { + * if (err) { + * console.error(err); + * return; + * } + * + * // The file is now available to read from this URL. + * request(url, function(err, resp) { + * // resp.statusCode = 200 + * }); + * }); + * + * //- + * // Generate a URL to allow write permissions. This means anyone with this URL + * // can send a POST request with new data that will overwrite the file. + * //- + * file.getSignedUrl({ + * action: 'write', + * expires: '03-17-2025' + * }, function(err, url) { + * if (err) { + * console.error(err); + * return; + * } + * + * // The file is now available to be written to. + * const writeStream = request.put(url); + * writeStream.end('New data'); + * + * writeStream.on('complete', function(resp) { + * // Confirm the new content was saved. + * file.download(function(err, fileContents) { + * console.log('Contents:', fileContents.toString()); + * // Contents: New data + * }); + * }); + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * file.getSignedUrl(config).then(function(data) { + * const url = data[0]; + * }); + * + * @example include:samples/files.js + * region_tag:storage_generate_signed_url + * Another example: + */ +File.prototype.getSignedUrl = function(config, callback) { + const self = this; + const expires = new Date(config.expires); + const expiresInSeconds = Math.round(expires / 1000); // The API expects seconds. + + if (expires < Date.now()) { + throw new Error('An expiration date cannot be in the past.'); + } + + config = extend({}, config); + + config.action = { + read: 'GET', + write: 'PUT', + delete: 'DELETE', + resumable: 'POST', + }[config.action]; + + const name = encodeURIComponent(this.name); + config.resource = '/' + this.bucket.name + '/' + name; + + let extensionHeadersString = ''; + + if (config.action === 'POST') { + config.extensionHeaders = extend({}, config.extensionHeaders, { + 'x-goog-resumable': 'start', + }); + } + + if (config.extensionHeaders) { + for (const headerName in config.extensionHeaders) { + extensionHeadersString += `${headerName}:${ + config.extensionHeaders[headerName] + }\n`; + } + } + + const blobToSign = [ + config.action, + config.contentMd5 || '', + config.contentType || '', + expiresInSeconds, + extensionHeadersString + config.resource, + ].join('\n'); + + const authClient = this.storage.authClient; + + authClient.sign(blobToSign, function(err, signature) { + if (err) { + callback(new SigningError(err.message)); + return; + } + + const query = { + GoogleAccessId: authClient.credentials.client_email, + Expires: expiresInSeconds, + Signature: signature, + }; + + if (is.string(config.responseType)) { + query['response-content-type'] = config.responseType; + } + + if (is.string(config.promptSaveAs)) { + query['response-content-disposition'] = + 'attachment; filename="' + config.promptSaveAs + '"'; + } + if (is.string(config.responseDisposition)) { + query['response-content-disposition'] = config.responseDisposition; + } + + if (self.generation) { + query.generation = self.generation; + } + + const parsedHost = url.parse(config.cname || STORAGE_DOWNLOAD_BASE_URL); + const signedUrl = url.format({ + protocol: parsedHost.protocol, + hostname: parsedHost.hostname, + pathname: self.bucket.name + '/' + name, + query: query, + }); + + callback(null, signedUrl); + }); +}; + +/** + * @typedef {array} MakeFilePrivateResponse + * @property {object} 0 The full API response. + */ +/** + * @callback MakeFilePrivateCallback + * @param {?Error} err Request error, if any. + * @param {object} apiResponse The full API response. + */ +/** + * Make a file private to the project and remove all other permissions. + * Set `options.strict` to true to make the file private to only the owner. + * + * @see [Objects: patch API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/objects/patch} + * + * @param {object} [options] Configuration options. + * @param {boolean} [options.strict] If true, set the file to be private to + * only the owner user. Otherwise, it will be private to the project. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {MakeFilePrivateCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * + * const file = myBucket.file('my-file'); + * + * //- + * // Set the file private so only project maintainers can see and modify it. + * //- + * file.makePrivate(function(err) {}); + * + * //- + * // Set the file private so only the owner can see and modify it. + * //- + * file.makePrivate({ strict: true }, function(err) {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * file.makePrivate().then(function(data) { + * const apiResponse = data[0]; + * }); + */ +File.prototype.makePrivate = function(options, callback) { + if (is.fn(options)) { + callback = options; + options = {}; + } + + const query = { + predefinedAcl: options.strict ? 'private' : 'projectPrivate', + }; + + if (options.userProject) { + query.userProject = options.userProject; + } + + this.setMetadata( + { + // You aren't allowed to set both predefinedAcl & acl properties on a file, + // so acl must explicitly be nullified, destroying all previous acls on the + // file. + acl: null, + }, + query, + callback + ); +}; + +/** + * @typedef {array} MakeFilePublicResponse + * @property {object} 0 The full API response. + */ +/** + * @callback MakeFilePublicCallback + * @param {?Error} err Request error, if any. + * @param {object} apiResponse The full API response. + */ +/** + * Set a file to be publicly readable and maintain all previous permissions. + * + * @see [ObjectAccessControls: insert API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/objectAccessControls/insert} + * + * @param {MakeFilePublicCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * + * const file = myBucket.file('my-file'); + * + * file.makePublic(function(err, apiResponse) {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * file.makePublic().then(function(data) { + * const apiResponse = data[0]; + * }); + * + * @example include:samples/files.js + * region_tag:storage_make_public + * Another example: + */ +File.prototype.makePublic = function(callback) { + callback = callback || common.util.noop; + + this.acl.add( + { + entity: 'allUsers', + role: 'READER', + }, + function(err, resp) { + callback(err, resp); + } + ); +}; + +/** + * @typedef {array} MoveResponse + * @property {File} 0 The destination File. + * @property {object} 1 The full API response. + */ +/** + * @callback MoveCallback + * @param {?Error} err Request error, if any. + * @param {File} destinationFile The destination File. + * @param {object} apiResponse The full API response. + */ +/** + * Move this file to another location. By default, this will rename the file + * and keep it in the same bucket, but you can choose to move it to another + * Bucket by providing a Bucket or File object or a URL beginning with "gs://". + * + * **Warning**: + * There is currently no atomic `move` method in the Cloud Storage API, + * so this method is a composition of {@link File#copy} (to the new + * location) and {@link File#delete} (from the old location). While + * unlikely, it is possible that an error returned to your callback could be + * triggered from either one of these API calls failing, which could leave a + * duplicate file lingering. + * + * @see [Objects: copy API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/objects/copy} + * + * @throws {Error} If the destination file is not provided. + * + * @param {string|Bucket|File} destination Destination file. + * @param {object} [options] Configuration options. See an + * [Object resource](https://cloud.google.com/storage/docs/json_api/v1/objects#resource). + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {MoveCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * //- + * // You can pass in a variety of types for the destination. + * // + * // For all of the below examples, assume we are working with the following + * // Bucket and File objects. + * //- + * const bucket = storage.bucket('my-bucket'); + * const file = bucket.file('my-image.png'); + * + * //- + * // If you pass in a string for the destination, the file is moved to its + * // current bucket, under the new name provided. + * //- + * file.move('my-image-new.png', function(err, destinationFile, apiResponse) { + * // `my-bucket` no longer contains: + * // - "my-image.png" + * // but contains instead: + * // - "my-image-new.png" + * + * // `destinationFile` is an instance of a File object that refers to your + * // new file. + * }); + * + * //- + * // If you pass in a string starting with "gs://" for the destination, the + * // file is copied to the other bucket and under the new name provided. + * //- + * const newLocation = 'gs://another-bucket/my-image-new.png'; + * file.move(newLocation, function(err, destinationFile, apiResponse) { + * // `my-bucket` no longer contains: + * // - "my-image.png" + * // + * // `another-bucket` now contains: + * // - "my-image-new.png" + * + * // `destinationFile` is an instance of a File object that refers to your + * // new file. + * }); + * + * //- + * // If you pass in a Bucket object, the file will be moved to that bucket + * // using the same name. + * //- + * const anotherBucket = gcs.bucket('another-bucket'); + * + * file.move(anotherBucket, function(err, destinationFile, apiResponse) { + * // `my-bucket` no longer contains: + * // - "my-image.png" + * // + * // `another-bucket` now contains: + * // - "my-image.png" + * + * // `destinationFile` is an instance of a File object that refers to your + * // new file. + * }); + * + * //- + * // If you pass in a File object, you have complete control over the new + * // bucket and filename. + * //- + * const anotherFile = anotherBucket.file('my-awesome-image.png'); + * + * file.move(anotherFile, function(err, destinationFile, apiResponse) { + * // `my-bucket` no longer contains: + * // - "my-image.png" + * // + * // `another-bucket` now contains: + * // - "my-awesome-image.png" + * + * // Note: + * // The `destinationFile` parameter is equal to `anotherFile`. + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * file.move('my-image-new.png').then(function(data) { + * const destinationFile = data[0]; + * const apiResponse = data[1]; + * }); + * + * @example include:samples/files.js + * region_tag:storage_move_file + * Another example: + */ +File.prototype.move = function(destination, options, callback) { + const self = this; + + if (is.fn(options)) { + callback = options; + options = {}; + } + + callback = callback || common.util.noop; + + this.copy(destination, options, function(err, destinationFile, apiResponse) { + if (err) { + callback(err, null, apiResponse); + return; + } + + self.delete(options, function(err, apiResponse) { + callback(err, destinationFile, apiResponse); + }); + }); +}; + +/** + * Makes request and applies userProject query parameter if necessary. + * + * @private + * + * @param {object} reqOpts - The request options. + * @param {function} callback - The callback function. + */ +File.prototype.request = function(reqOpts, callback) { + if (this.userProject && (!reqOpts.qs || !reqOpts.qs.userProject)) { + reqOpts.qs = extend(reqOpts.qs, {userProject: this.userProject}); + } + + return common.ServiceObject.prototype.request.call(this, reqOpts, callback); +}; + +/** + * This method allows you to update the encryption key associated with this + * file. + * + * @see [Customer-supplied Encryption Keys]{@link https://cloud.google.com/storage/docs/encryption#customer-supplied} + * + * @param {string|buffer|object} options If a string or Buffer is provided, it + * is interpreted as an AES-256, customer-supplied encryption key. If you'd + * like to use a Cloud KMS key name, you must specify an options object with + * the property name: `kmsKeyName`. + * @param {string|buffer} [options.encryptionKey] An AES-256 encryption key. + * @param {string} [options.kmsKeyName] A Cloud KMS key name. + * @returns {File} + * + * @example include:samples/encryption.js + * region_tag:storage_rotate_encryption_key + * Example of rotating the encryption key for this file: + */ +File.prototype.rotateEncryptionKey = function(options, callback) { + if (!is.object(options)) { + options = { + encryptionKey: options, + }; + } + + const newFile = this.bucket.file(this.id, options); + this.copy(newFile, callback); +}; + +/** + * @callback SaveCallback + * @param {?Error} err Request error, if any. + */ +/** + * Write arbitrary data to a file. + * + * *This is a convenience method which wraps {@link File#createWriteStream}.* + * + * Resumable uploads are automatically enabled and must be shut off explicitly + * by setting `options.resumable` to `false`. + * + *

+ * There is some overhead when using a resumable upload that can cause + * noticeable performance degradation while uploading a series of small files. + * When uploading files less than 10MB, it is recommended that the resumable + * feature is disabled. + *

+ * + * @param {*} data The data to write to a file. + * @param {object} [options] See {@link File#createWriteStream}'s `options` + * parameter. + * @param {SaveCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * + * const file = myBucket.file('my-file'); + * const contents = 'This is the contents of the file.'; + * + * file.save(contents, function(err) { + * if (!err) { + * // File written successfully. + * } + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * file.save(contents).then(function() {}); + */ +File.prototype.save = function(data, options, callback) { + if (is.fn(options)) { + callback = options; + options = {}; + } + + this.createWriteStream(options) + .on('error', callback) + .on('finish', callback) + .end(data); +}; + +/** + * @typedef {array} SetFileMetadataResponse + * @property {object} 0 The full API response. + */ +/** + * @callback SetFileMetadataCallback + * @param {?Error} err Request error, if any. + * @param {object} apiResponse The full API response. + */ +/** + * Merge the given metadata with the current remote file's metadata. This + * will set metadata if it was previously unset or update previously set + * metadata. To unset previously set metadata, set its value to null. + * + * You can set custom key/value pairs in the metadata key of the given + * object, however the other properties outside of this object must adhere + * to the [official API documentation](https://goo.gl/BOnnCK). + * + * See the examples below for more information. + * + * @see [Objects: patch API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/objects/patch} + * + * @param {object} [metadata] The metadata you wish to update. + * @param {object} [options] Configuration options. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {SetFileMetadataCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * + * const file = myBucket.file('my-file'); + * + * const metadata = { + * contentType: 'application/x-font-ttf', + * metadata: { + * my: 'custom', + * properties: 'go here' + * } + * }; + * + * file.setMetadata(metadata, function(err, apiResponse) {}); + * + * // Assuming current metadata = { hello: 'world', unsetMe: 'will do' } + * file.setMetadata({ + * metadata: { + * abc: '123', // will be set. + * unsetMe: null, // will be unset (deleted). + * hello: 'goodbye' // will be updated from 'hello' to 'goodbye'. + * } + * }, function(err, apiResponse) { + * // metadata should now be { abc: '123', hello: 'goodbye' } + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * file.setMetadata(metadata).then(function(data) { + * const apiResponse = data[0]; + * }); + */ +File.prototype.setMetadata = function(metadata, options, callback) { + if (is.fn(options)) { + callback = options; + options = {}; + } + + options = extend({}, this.requestQueryObject, options); + + this.parent.setMetadata.call(this, metadata, options, callback); +}; + +/** + * @typedef {array} SetStorageClassResponse + * @property {object} 0 The full API response. + */ +/** + * @callback SetStorageClassCallback + * @param {?Error} err Request error, if any. + * @param {object} apiResponse The full API response. + */ +/** + * Set the storage class for this file. + * + * @see [Per-Object Storage Class]{@link https://cloud.google.com/storage/docs/per-object-storage-class} + * @see [Storage Classes]{@link https://cloud.google.com/storage/docs/storage-classes} + * + * @param {string} storageClass The new storage class. (`multi_regional`, + * `regional`, `nearline`, `coldline`) + * @param {object} [options] Configuration options. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {SetStorageClassCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * file.setStorageClass('regional', function(err, apiResponse) { + * if (err) { + * // Error handling omitted. + * } + * + * // The storage class was updated successfully. + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * file.setStorageClass('regional').then(function() {}); + */ +File.prototype.setStorageClass = function(storageClass, options, callback) { + const self = this; + + if (is.fn(options)) { + callback = options; + options = {}; + } + + options = extend(true, {}, options); + + // In case we get input like `storageClass`, convert to `storage_class`. + options.storageClass = storageClass + .replace(/-/g, '_') + .replace(/([a-z])([A-Z])/g, function(_, low, up) { + return low + '_' + up; + }) + .toUpperCase(); + + this.copy(this, options, function(err, file, apiResponse) { + if (err) { + callback(err, apiResponse); + return; + } + + self.metadata = file.metadata; + + callback(null, apiResponse); + }); +}; + +/** + * Set a user project to be billed for all requests made from this File object. + * + * @param {string} userProject The user project. + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('albums'); + * const file = bucket.file('my-file'); + * + * file.setUserProject('grape-spaceship-123'); + */ +File.prototype.setUserProject = function(userProject) { + this.userProject = userProject; +}; + +/** + * This creates a gcs-resumable-upload upload stream. + * + * @see [gcs-resumable-upload]{@link https://github.com/stephenplusplus/gcs-resumable-upload} + * + * @param {Duplexify} stream - Duplexify stream of data to pipe to the file. + * @param {object=} options - Configuration object. + * + * @private + */ +File.prototype.startResumableUpload_ = function(dup, options) { + const self = this; + + options = extend( + { + metadata: {}, + }, + options + ); + + const uploadStream = resumableUpload({ + authClient: this.storage.authClient, + bucket: this.bucket.name, + file: this.name, + generation: this.generation, + key: this.encryptionKey, + kmsKeyName: this.kmsKeyName, + metadata: options.metadata, + offset: options.offset, + predefinedAcl: options.predefinedAcl, + private: options.private, + public: options.public, + uri: options.uri, + userProject: options.userProject, + }); + + uploadStream + .on('response', function(resp) { + dup.emit('response', resp); + }) + .on('metadata', function(metadata) { + self.metadata = metadata; + }) + .on('finish', function() { + dup.emit('complete'); + }); + + dup.setWritable(uploadStream); +}; + +/** + * Takes a readable stream and pipes it to a remote file. Unlike + * `startResumableUpload_`, which uses the resumable upload technique, this + * method uses a simple upload (all or nothing). + * + * @param {Duplexify} dup - Duplexify stream of data to pipe to the file. + * @param {object=} options - Configuration object. + * + * @private + */ +File.prototype.startSimpleUpload_ = function(dup, options) { + const self = this; + + options = extend( + { + metadata: {}, + }, + options + ); + + const reqOpts = { + qs: { + name: self.name, + }, + uri: `${STORAGE_UPLOAD_BASE_URL}/${self.bucket.name}/o`, + }; + + if (is.defined(this.generation)) { + reqOpts.qs.ifGenerationMatch = this.generation; + } + + if (is.defined(this.kmsKeyName)) { + reqOpts.qs.kmsKeyName = this.kmsKeyName; + } + + if (options.userProject) { + reqOpts.qs.userProject = options.userProject; + } + + if (options.predefinedAcl) { + reqOpts.qs.predefinedAcl = options.predefinedAcl; + } else if (options.private) { + reqOpts.qs.predefinedAcl = 'private'; + } else if (options.public) { + reqOpts.qs.predefinedAcl = 'publicRead'; + } + + common.util.makeWritableStream(dup, { + makeAuthenticatedRequest: function(reqOpts) { + self.request(reqOpts, function(err, body, resp) { + if (err) { + dup.destroy(err); + return; + } + + self.metadata = body; + dup.emit('response', resp); + dup.emit('complete'); + }); + }, + metadata: options.metadata, + request: reqOpts, + }); +}; + +/*! Developer Documentation + * + * All async methods (except for streams) will return a Promise in the event + * that a callback is omitted. + */ +common.util.promisifyAll(File, { + exclude: ['setEncryptionKey'], +}); + +/** + * Reference to the {@link File} class. + * @name module:@google-cloud/storage.File + * @see File + */ +module.exports = File; diff --git a/website/functions/node_modules/@google-cloud/storage/src/iam.js b/website/functions/node_modules/@google-cloud/storage/src/iam.js new file mode 100644 index 00000000..90b9bc08 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/storage/src/iam.js @@ -0,0 +1,300 @@ +/*! + * Copyright 2017 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. + */ + +'use strict'; + +const arrify = require('arrify'); +const common = require('@google-cloud/common'); +const extend = require('extend'); +const is = require('is'); + +/** + * Get and set IAM policies for your Cloud Storage bucket. + * + * @see [Cloud Storage IAM Management](https://cloud.google.com/storage/docs/access-control/iam#short_title_iam_management) + * @see [Granting, Changing, and Revoking Access](https://cloud.google.com/iam/docs/granting-changing-revoking-access) + * @see [IAM Roles](https://cloud.google.com/iam/docs/understanding-roles) + * + * @constructor Iam + * @mixin + * + * @param {Bucket} bucket The parent instance. + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('my-bucket'); + * // bucket.iam + */ +function Iam(bucket) { + this.request_ = bucket.request.bind(bucket); + this.resourceId_ = 'buckets/' + bucket.id; +} + +/** + * @typedef {object} GetPolicyRequest + * @property {string} userProject The ID of the project which will be billed for + * the request. + */ +/** + * @typedef {array} GetPolicyResponse + * @property {object} 0 The policy. + * @property {object} 1 The full API response. + */ +/** + * @callback GetPolicyCallback + * @param {?Error} err Request error, if any. + * @param {object} acl The policy. + * @param {object} apiResponse The full API response. + */ +/** + * Get the IAM policy. + * + * @param {GetPolicyRequest} [options] Request options. + * @param {GetPolicyCallback} [callback] Callback function. + * @returns {Promise} + * + * @see [Buckets: setIamPolicy API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/buckets/getIamPolicy} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('my-bucket'); + * bucket.iam.getPolicy(function(err, policy, apiResponse) {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * bucket.iam.getPolicy().then(function(data) { + * const policy = data[0]; + * const apiResponse = data[1]; + * }); + * + * @example include:samples/iam.js + * region_tag:storage_view_bucket_iam_members + * Example of retrieving a bucket's IAM policy: + */ +Iam.prototype.getPolicy = function(options, callback) { + if (is.fn(options)) { + callback = options; + options = {}; + } + + this.request_( + { + uri: '/iam', + qs: options, + }, + callback + ); +}; + +/** + * @typedef {array} SetPolicyResponse + * @property {object} 0 The policy. + * @property {object} 1 The full API response. + */ +/** + * @callback SetPolicyCallback + * @param {?Error} err Request error, if any. + * @param {object} acl The policy. + * @param {object} apiResponse The full API response. + */ +/** + * Set the IAM policy. + * + * @throws {Error} If no policy is provided. + * + * @param {object} policy The policy. + * @param {array} policy.bindings Bindings associate members with roles. + * @param {string} [policy.etag] Etags are used to perform a read-modify-write. + * @param {object} [options] Configuration opbject. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {SetPolicyCallback} callback Callback function. + * @returns {Promise} + * + * @see [Buckets: setIamPolicy API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/buckets/setIamPolicy} + * @see [IAM Roles](https://cloud.google.com/iam/docs/understanding-roles) + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('my-bucket'); + * + * const myPolicy = { + * bindings: [ + * { + * role: 'roles/storage.admin', + * members: ['serviceAccount:myotherproject@appspot.gserviceaccount.com'] + * } + * ] + * }; + * + * bucket.iam.setPolicy(myPolicy, function(err, policy, apiResponse) {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * bucket.iam.setPolicy(myPolicy).then(function(data) { + * const policy = data[0]; + * const apiResponse = data[1]; + * }); + * + * @example include:samples/iam.js + * region_tag:storage_add_bucket_iam_member + * Example of adding to a bucket's IAM policy: + * + * @example include:samples/iam.js + * region_tag:storage_remove_bucket_iam_member + * Example of removing from a bucket's IAM policy: + */ +Iam.prototype.setPolicy = function(policy, options, callback) { + if (!is.object(policy)) { + throw new Error('A policy object is required.'); + } + + if (is.fn(options)) { + callback = options; + options = {}; + } + + this.request_( + { + method: 'PUT', + uri: '/iam', + json: extend( + { + resourceId: this.resourceId_, + }, + policy + ), + qs: options, + }, + callback + ); +}; + +/** + * @typedef {array} TestIamPermissionsResponse + * @property {object[]} 0 A subset of permissions that the caller is allowed. + * @property {object} 1 The full API response. + */ +/** + * @callback TestIamPermissionsCallback + * @param {?Error} err Request error, if any. + * @param {object[]} acl A subset of permissions that the caller is allowed. + * @param {object} apiResponse The full API response. + */ +/** + * Test a set of permissions for a resource. + * + * @throws {Error} If permissions are not provided. + * + * @param {string|string[]} permissions The permission(s) to test for. + * @param {object} [options] Configuration object. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {TestIamPermissionsCallback} [callback] Callback function. + * @returns {Promise} + * + * @see [Buckets: testIamPermissions API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/buckets/testIamPermissions} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const bucket = storage.bucket('my-bucket'); + * + * //- + * // Test a single permission. + * //- + * const test = 'storage.buckets.delete'; + * + * bucket.iam.testPermissions(test, function(err, permissions, apiResponse) { + * console.log(permissions); + * // { + * // "storage.buckets.delete": true + * // } + * }); + * + * //- + * // Test several permissions at once. + * //- + * const tests = [ + * 'storage.buckets.delete', + * 'storage.buckets.get' + * ]; + * + * bucket.iam.testPermissions(tests, function(err, permissions) { + * console.log(permissions); + * // { + * // "storage.buckets.delete": false, + * // "storage.buckets.get": true + * // } + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * bucket.iam.testPermissions(test).then(function(data) { + * const permissions = data[0]; + * const apiResponse = data[1]; + * }); + */ +Iam.prototype.testPermissions = function(permissions, options, callback) { + if (!is.array(permissions) && !is.string(permissions)) { + throw new Error('Permissions are required.'); + } + + if (is.fn(options)) { + callback = options; + options = {}; + } + + options = extend( + { + permissions: arrify(permissions), + }, + options + ); + + this.request_( + { + uri: '/iam/testPermissions', + qs: options, + useQuerystring: true, + }, + function(err, resp) { + if (err) { + callback(err, null, resp); + return; + } + + const availablePermissions = arrify(resp.permissions); + + const permissionsHash = permissions.reduce(function(acc, permission) { + acc[permission] = availablePermissions.indexOf(permission) > -1; + return acc; + }, {}); + + callback(null, permissionsHash, resp); + } + ); +}; + +/*! Developer Documentation + * + * All async methods (except for streams) will return a Promise in the event + * that a callback is omitted. + */ +common.util.promisifyAll(Iam); + +module.exports = Iam; diff --git a/website/functions/node_modules/@google-cloud/storage/src/index.js b/website/functions/node_modules/@google-cloud/storage/src/index.js new file mode 100644 index 00000000..09953035 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/storage/src/index.js @@ -0,0 +1,591 @@ +/** + * Copyright 2014-2017 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. + */ + +'use strict'; + +const arrify = require('arrify'); +const common = require('@google-cloud/common'); +const extend = require('extend'); +const util = require('util'); + +const Bucket = require('./bucket.js'); +const Channel = require('./channel.js'); +const File = require('./file.js'); + +/** + * @typedef {object} ClientConfig + * @property {string} [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://cloud.google.com/docs/authentication/production#providing_credentials_to_your_application Application Default Credentials}, + * your project ID will be detected automatically. + * @property {string} [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 above is not necessary. NOTE: .pem and + * .p12 require you to specify the `email` option as well. + * @property {string} [email] Account email address. Required when using a .pem + * or .p12 keyFilename. + * @property {object} [credentials] Credentials object. + * @property {string} [credentials.client_email] + * @property {string} [credentials.private_key] + * @property {boolean} [autoRetry=true] Automatically retry requests if the + * response is related to rate limits or certain intermittent server errors. + * We will exponentially backoff subsequent requests by default. + * @property {number} [maxRetries=3] Maximum number of automatic retries + * attempted before returning the error. + * @property {Constructor} [promise] Custom promise module to use instead of + * native Promises. + */ + +/*! Developer Documentation + * + * Invoke this method to create a new Storage object bound with pre-determined + * configuration options. For each object that can be created (e.g., a bucket), + * there is an equivalent static and instance method. While they are classes, + * they can be instantiated without use of the `new` keyword. + */ +/** + *

ACLs

+ * Cloud Storage uses access control lists (ACLs) to manage object and + * bucket access. ACLs are the mechanism you use to share files with other users + * and allow other users to access your buckets and files. + * + * To learn more about ACLs, read this overview on + * [Access Control](https://cloud.google.com/storage/docs/access-control). + * + * @see [Cloud Storage overview]{@link https://cloud.google.com/storage/docs/overview} + * @see [Access Control]{@link https://cloud.google.com/storage/docs/access-control} + * + * @class + * @hideconstructor + * + * @example Create a client that uses Application Default Credentials (ADC) + * const Storage = require('@google-cloud/storage'); + * const storage = new Storage(); + * + * @example Create a client with explicit credentials + * const Storage = require('@google-cloud/storage'); + * const storage = new Storage({ + * projectId: 'your-project-id', + * keyFilename: '/path/to/keyfile.json' + * }); + * + * @param {ClientConfig} [options] Configuration options. + */ +function Storage(options) { + if (!(this instanceof Storage)) { + return new Storage(options); + } + + options = common.util.normalizeArguments(this, options); + + const config = { + baseUrl: 'https://www.googleapis.com/storage/v1', + projectIdRequired: false, + scopes: [ + 'https://www.googleapis.com/auth/iam', + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/devstorage.full_control', + ], + packageJson: require('../package.json'), + }; + + common.Service.call(this, config, options); +} + +util.inherits(Storage, common.Service); + +/** + * Cloud Storage uses access control lists (ACLs) to manage object and + * bucket access. ACLs are the mechanism you use to share objects with other + * users and allow other users to access your buckets and objects. + * + * This object provides constants to refer to the three permission levels that + * can be granted to an entity: + * + * - `gcs.acl.OWNER_ROLE` - ("OWNER") + * - `gcs.acl.READER_ROLE` - ("READER") + * - `gcs.acl.WRITER_ROLE` - ("WRITER") + * + * @see [About Access Control Lists]{@link https://cloud.google.com/storage/docs/access-control/lists} + * + * @name Storage.acl + * @type {object} + * @property {string} OWNER_ROLE + * @property {string} READER_ROLE + * @property {string} WRITER_ROLE + * + * @example + * const storage = require('@google-cloud/storage')(); + * const albums = storage.bucket('albums'); + * + * //- + * // Make all of the files currently in a bucket publicly readable. + * //- + * const options = { + * entity: 'allUsers', + * role: storage.acl.READER_ROLE + * }; + * + * albums.acl.add(options, function(err, aclObject) {}); + * + * //- + * // Make any new objects added to a bucket publicly readable. + * //- + * albums.acl.default.add(options, function(err, aclObject) {}); + * + * //- + * // Grant a user ownership permissions to a bucket. + * //- + * albums.acl.add({ + * entity: 'user-useremail@example.com', + * role: storage.acl.OWNER_ROLE + * }, function(err, aclObject) {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * albums.acl.add(options).then(function(data) { + * const aclObject = data[0]; + * const apiResponse = data[1]; + * }); + */ +Storage.acl = { + OWNER_ROLE: 'OWNER', + READER_ROLE: 'READER', + WRITER_ROLE: 'WRITER', +}; + +/** + * Reference to {@link Storage.acl}. + * + * @name Storage#acl + * @see Storage.acl + */ +Storage.prototype.acl = Storage.acl; + +/** + * Get a reference to a Cloud Storage bucket. + * + * @param {string} name Name of the bucket. + * @param {object} [options] Configuration object. + * @param {string} [options.kmsKeyName] A Cloud KMS key that will be used to + * encrypt objects inserted into this bucket, if no encryption method is + * specified. + * @param {string} [options.userProject] User project to be billed for all + * requests made from this Bucket object. + * @returns {Bucket} + * @see Bucket + * + * @example + * const storage = require('@google-cloud/storage')(); + * const albums = storage.bucket('albums'); + * const photos = storage.bucket('photos'); + */ +Storage.prototype.bucket = function(name, options) { + if (!name) { + throw new Error('A bucket name is needed to use Cloud Storage.'); + } + + return new Bucket(this, name, options); +}; + +/** + * Reference a channel to receive notifications about changes to your bucket. + * + * @param {string} id The ID of the channel. + * @param {string} resourceId The resource ID of the channel. + * @returns {Channel} + * @see Channel + * + * @example + * const storage = require('@google-cloud/storage')(); + * const channel = storage.channel('id', 'resource-id'); + */ +Storage.prototype.channel = function(id, resourceId) { + return new Channel(this, id, resourceId); +}; + +/** + * Metadata to set for the bucket. + * + * @typedef {object} CreateBucketRequest + * @property {boolean} [coldline=false] Specify the storage class as Coldline. + * @property {boolean} [dra=false] Specify the storage class as Durable Reduced + * Availability. + * @property {boolean} [multiRegional=false] Specify the storage class as + * Multi-Regional. + * @property {boolean} [nearline=false] Specify the storage class as Nearline. + * @property {boolean} [regional=false] Specify the storage class as Regional. + * @property {boolean} [requesterPays=false] **Early Access Testers Only** + * Force the use of the User Project metadata field to assign operational + * costs when an operation is made on a Bucket and its objects. + * @property {string} [userProject] The ID of the project which will be billed + * for the request. + */ +/** + * @typedef {array} CreateBucketResponse + * @property {Bucket} 0 The new {@link Bucket}. + * @property {object} 1 The full API response. + */ +/** + * @callback CreateBucketCallback + * @param {?Error} err Request error, if any. + * @param {Bucket} bucket The new {@link Bucket}. + * @param {object} apiResponse The full API response. + */ +/** + * Create a bucket. + * + * Cloud Storage uses a flat namespace, so you can't create a bucket with + * a name that is already in use. For more information, see + * [Bucket Naming Guidelines](https://cloud.google.com/storage/docs/bucketnaming.html#requirements). + * + * @see [Buckets: insert API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/buckets/insert} + * @see [Storage Classes]{@link https://cloud.google.com/storage/docs/storage-classes} + * + * @param {string} name Name of the bucket to create. + * @param {CreateBucketRequest} [metadata] Metadata to set for the bucket. + * @param {CreateBucketCallback} [callback] Callback function. + * @returns {Promise} + * @throws {Error} If a name is not provided. + * @see Bucket#create + * + * @example + * const storage = require('@google-cloud/storage')(); + * const callback = function(err, bucket, apiResponse) { + * // `bucket` is a Bucket object. + * }; + * + * storage.createBucket('new-bucket', callback); + * + * //- + * // Create a bucket in a specific location and region. See the + * // Official JSON API docs for complete details on the `location` option. + * // + * //- + * const metadata = { + * location: 'US-CENTRAL1', + * regional: true + * }; + * + * storage.createBucket('new-bucket', metadata, callback); + * + * //- + * // Enable versioning on a new bucket. + * //- + * const metadata = { + * versioning: { + * enabled: true + * } + * }; + * + * storage.createBucket('new-bucket', metadata, callback); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * storage.createBucket('new-bucket').then(function(data) { + * const bucket = data[0]; + * const apiResponse = data[1]; + * }); + * + * @example include:samples/buckets.js + * region_tag:storage_create_bucket + * Another example: + */ +Storage.prototype.createBucket = function(name, metadata, callback) { + const self = this; + + if (!name) { + throw new Error('A name is required to create a bucket.'); + } + + if (!callback) { + callback = metadata; + metadata = {}; + } + + const body = extend({}, metadata, { + name: name, + }); + + const storageClasses = { + coldline: 'COLDLINE', + dra: 'DURABLE_REDUCED_AVAILABILITY', + multiRegional: 'MULTI_REGIONAL', + nearline: 'NEARLINE', + regional: 'REGIONAL', + }; + + Object.keys(storageClasses).forEach(function(storageClass) { + if (body[storageClass]) { + body.storageClass = storageClasses[storageClass]; + delete body[storageClass]; + } + }); + + if (body.requesterPays) { + body.billing = { + requesterPays: body.requesterPays, + }; + delete body.requesterPays; + } + + const query = { + project: this.projectId, + }; + + if (body.userProject) { + query.userProject = body.userProject; + delete body.userProject; + } + + this.request( + { + method: 'POST', + uri: '/b', + qs: query, + json: body, + }, + function(err, resp) { + if (err) { + callback(err, null, resp); + return; + } + + const bucket = self.bucket(name); + bucket.metadata = resp; + + callback(null, bucket, resp); + } + ); +}; + +/** + * Query object for listing buckets. + * + * @typedef {object} GetBucketsRequest + * @property {boolean} [autoPaginate=true] Have pagination handled + * automatically. + * @property {number} [maxApiCalls] Maximum number of API calls to make. + * @property {number} [maxResults] Maximum number of items plus prefixes to + * return. + * @property {string} [pageToken] A previously-returned page token + * representing part of the larger set of results to view. + * @property {string} [userProject] The ID of the project which will be billed + * for the request. + */ +/** + * @typedef {array} GetBucketsResponse + * @property {Bucket[]} 0 Array of {@link Bucket} instances. + */ +/** + * @callback GetBucketsCallback + * @param {?Error} err Request error, if any. + * @param {Bucket[]} buckets Array of {@link Bucket} instances. + */ +/** + * Get Bucket objects for all of the buckets in your project. + * + * @see [Buckets: list API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/buckets/list} + * + * @param {GetBucketsRequest} [query] Query object for listing buckets. + * @param {GetBucketsCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * storage.getBuckets(function(err, buckets) { + * if (!err) { + * // buckets is an array of Bucket objects. + * } + * }); + * + * //- + * // To control how many API requests are made and page through the results + * // manually, set `autoPaginate` to `false`. + * //- + * const callback = function(err, buckets, nextQuery, apiResponse) { + * if (nextQuery) { + * // More results exist. + * storage.getBuckets(nextQuery, callback); + * } + * + * // The `metadata` property is populated for you with the metadata at the + * // time of fetching. + * buckets[0].metadata; + * + * // However, in cases where you are concerned the metadata could have + * // changed, use the `getMetadata` method. + * buckets[0].getMetadata(function(err, metadata, apiResponse) {}); + * }; + * + * storage.getBuckets({ + * autoPaginate: false + * }, callback); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * storage.getBuckets().then(function(data) { + * const buckets = data[0]; + * }); + * + * @example include:samples/buckets.js + * region_tag:storage_list_buckets + * Another example: + */ +Storage.prototype.getBuckets = function(query, callback) { + const self = this; + + if (!callback) { + callback = query; + query = {}; + } + + query.project = query.project || this.projectId; + + this.request( + { + uri: '/b', + qs: query, + }, + function(err, resp) { + if (err) { + callback(err, null, null, resp); + return; + } + + const buckets = arrify(resp.items).map(function(bucket) { + const bucketInstance = self.bucket(bucket.id); + bucketInstance.metadata = bucket; + return bucketInstance; + }); + + let nextQuery = null; + if (resp.nextPageToken) { + nextQuery = extend({}, query, {pageToken: resp.nextPageToken}); + } + + callback(null, buckets, nextQuery, resp); + } + ); +}; + +/** + * Get {@link Bucket} objects for all of the buckets in your project as + * a readable object stream. + * + * @method Storage#getBucketsStream + * @param {GetBucketsRequest} [query] Query object for listing buckets. + * @returns {ReadableStream} A readable stream that emits {@link Bucket} instances. + * + * @example + * storage.getBucketsStream() + * .on('error', console.error) + * .on('data', function(bucket) { + * // bucket is a Bucket object. + * }) + * .on('end', function() { + * // All buckets retrieved. + * }); + * + * //- + * // If you anticipate many results, you can end a stream early to prevent + * // unnecessary processing and API requests. + * //- + * storage.getBucketsStream() + * .on('data', function(bucket) { + * this.end(); + * }); + */ +Storage.prototype.getBucketsStream = common.paginator.streamify('getBuckets'); + +/*! Developer Documentation + * + * These methods can be auto-paginated. + */ +common.paginator.extend(Storage, 'getBuckets'); + +/*! Developer Documentation + * + * All async methods (except for streams) will return a Promise in the event + * that a callback is omitted. + */ +common.util.promisifyAll(Storage, { + exclude: ['bucket', 'channel'], +}); + +/** + * {@link Bucket} class. + * + * @name Storage.Bucket + * @see Bucket + * @type {Constructor} + */ +Storage.Bucket = Bucket; + +/** + * {@link Channel} class. + * + * @name Storage.Channel + * @see Channel + * @type {Constructor} + */ +Storage.Channel = Channel; + +/** + * {@link File} class. + * + * @name Storage.File + * @see File + * @type {Constructor} + */ +Storage.File = File; + +/** + * The default export of the `@google-cloud/storage` package is the + * {@link Storage} class, which also serves as a factory function which produces + * {@link Storage} instances. + * + * See {@link Storage} and {@link ClientConfig} for client methods and + * configuration options. + * + * @module {Storage} @google-cloud/storage + * @alias nodejs-storage + * + * @example Install the client library with npm: + * npm install --save @google-cloud/storage + * + * @example Import the client library + * const Storage = require('@google-cloud/storage'); + * + * @example Create a client that uses Application Default Credentials (ADC): + * const storage = new Storage(); + * + * @example Create a client with explicit credentials: + * const storage = new Storage({ + * projectId: 'your-project-id', + * keyFilename: '/path/to/keyfile.json' + * }); + * + * @example include:samples/quickstart.js + * region_tag:storage_quickstart + * Full quickstart example: + */ +module.exports = Storage; diff --git a/website/functions/node_modules/@google-cloud/storage/src/notification.js b/website/functions/node_modules/@google-cloud/storage/src/notification.js new file mode 100644 index 00000000..ed30cf56 --- /dev/null +++ b/website/functions/node_modules/@google-cloud/storage/src/notification.js @@ -0,0 +1,350 @@ +/*! + * Copyright 2017 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. + */ + +'use strict'; + +const common = require('@google-cloud/common'); +const is = require('is'); +const util = require('util'); + +/** + * A Notification object is created from your {@link Bucket} object using + * {@link Bucket#notification}. Use it to interact with Cloud Pub/Sub + * notifications. + * + * @see [Cloud Pub/Sub Notifications for Google Cloud Storage]{@link https://cloud.google.com/storage/docs/pubsub-notifications} + * + * @class + * @hideconstructor + * + * @param {Bucket} bucket The bucket instance this notification is attached to. + * @param {string} id The ID of the notification. + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * + * const notification = myBucket.notification('1'); + */ +function Notification(bucket, id) { + const methods = { + /** + * Creates a notification subscription for the bucket. + * + * @see [Notifications: insert]{@link https://cloud.google.com/storage/docs/json_api/v1/notifications/insert} + * + * @param {Topic|string} topic The Cloud PubSub topic to which this + * subscription publishes. If the project ID is omitted, the current + * project ID will be used. + * + * Acceptable formats are: + * - `projects/grape-spaceship-123/topics/my-topic` + * + * - `my-topic` + * @param {CreateNotificationRequest} [options] Metadata to set for + * the notification. + * @param {CreateNotificationCallback} [callback] Callback function. + * @returns {Promise} + * @throws {Error} If a valid topic is not provided. + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * const notification = myBucket.notification('1'); + * + * notification.create(function(err, notification, apiResponse) { + * if (!err) { + * // The notification was created successfully. + * } + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * notification.create().then(function(data) { + * const notification = data[0]; + * const apiResponse = data[1]; + * }); + */ + create: true, + + /** + * @typedef {array} NotificationExistsResponse + * @property {boolean} 0 Whether the notification exists or not. + */ + /** + * @callback NotificationExistsCallback + * @param {?Error} err Request error, if any. + * @param {boolean} exists Whether the notification exists or not. + */ + /** + * Check if the notification exists. + * + * @param {NotificationExistsCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * const notification = myBucket.notification('1'); + * + * notification.exists(function(err, exists) {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * notification.exists().then(function(data) { + * const exists = data[0]; + * }); + */ + exists: true, + }; + + common.ServiceObject.call(this, { + parent: bucket, + baseUrl: '/notificationConfigs', + id: id.toString(), + createMethod: bucket.createNotification.bind(bucket), + methods: methods, + }); +} + +util.inherits(Notification, common.ServiceObject); + +/** + * @typedef {array} DeleteNotificationResponse + * @property {object} 0 The full API response. + */ +/** + * @callback DeleteNotificationCallback + * @param {?Error} err Request error, if any. + * @param {object} apiResponse The full API response. + */ +/** + * Permanently deletes a notification subscription. + * + * @see [Notifications: delete API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/notifications/delete} + * + * @param {object} [options] Configuration options. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {DeleteNotificationCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * const notification = myBucket.notification('1'); + * + * notification.delete(function(err, apiResponse) {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * notification.delete().then(function(data) { + * const apiResponse = data[0]; + * }); + * + * @example include:samples/notifications.js + * region_tag:storage_delete_notification + * Another example: + */ +Notification.prototype.delete = function(options, callback) { + if (is.fn(options)) { + callback = options; + options = {}; + } + + this.request( + { + method: 'DELETE', + uri: '', + qs: options, + }, + callback || common.util.noop + ); +}; + +/** + * @typedef {array} GetNotificationResponse + * @property {Notification} 0 The {@link Notification} + * @property {object} 1 The full API response. + */ +/** + * @callback GetNotificationCallback + * @param {?Error} err Request error, if any. + * @param {Notification} notification The {@link Notification}. + * @param {object} apiResponse The full API response. + */ +/** + * Get a notification and its metadata if it exists. + * + * @see [Notifications: get API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/notifications/get} + * + * @param {object} [options] Configuration options. + * See {@link Bucket#createNotification} for create options. + * @param {boolean} [options.autoCreate] Automatically create the object if + * it does not exist. Default: `false`. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {GetNotificationCallback} [callback] Callback function. + * @return {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * const notification = myBucket.notification('1'); + * + * notification.get(function(err, notification, apiResponse) { + * // `notification.metadata` has been populated. + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * notification.get().then(function(data) { + * const notification = data[0]; + * const apiResponse = data[1]; + * }); + */ +Notification.prototype.get = function(options, callback) { + const self = this; + + if (is.fn(options)) { + callback = options; + options = {}; + } + + const autoCreate = options.autoCreate; + delete options.autoCreate; + + function onCreate(err, notification, apiResponse) { + if (err) { + if (err.code === 409) { + self.get(options, callback); + return; + } + + callback(err, null, apiResponse); + return; + } + + callback(null, notification, apiResponse); + } + + this.getMetadata(options, function(err, metadata) { + if (err) { + if (err.code === 404 && autoCreate) { + const args = []; + + if (!is.empty(options)) { + args.push(options); + } + + args.push(onCreate); + + self.create.apply(self, args); + return; + } + + callback(err, null, metadata); + return; + } + + callback(null, self, metadata); + }); +}; + +/** + * @typedef {array} GetNotificationMetadataResponse + * @property {object} 0 The notification metadata. + * @property {object} 1 The full API response. + */ +/** + * @callback GetNotificationMetadataCallback + * @param {?Error} err Request error, if any. + * @param {object} files The notification metadata. + * @param {object} apiResponse The full API response. + */ +/** + * Get the notification's metadata. + * + * @see [Notifications: get API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/notifications/get} + * + * @param {object} [options] Configuration options. + * @param {string} [options.userProject] The ID of the project which will be + * billed for the request. + * @param {GetNotificationMetadataCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const storage = require('@google-cloud/storage')(); + * const myBucket = storage.bucket('my-bucket'); + * const notification = myBucket.notification('1'); + * + * notification.getMetadata(function(err, metadata, apiResponse) {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * notification.getMetadata().then(function(data) { + * const metadata = data[0]; + * const apiResponse = data[1]; + * }); + * + * @example include:samples/notifications.js + * region_tag:storage_notifications_get_metadata + * Another example: + */ +Notification.prototype.getMetadata = function(options, callback) { + const self = this; + + if (is.fn(options)) { + callback = options; + options = {}; + } + + this.request( + { + uri: '', + qs: options, + }, + function(err, resp) { + if (err) { + callback(err, null, resp); + return; + } + + self.metadata = resp; + + callback(null, self.metadata, resp); + } + ); +}; + +/*! Developer Documentation + * + * All async methods (except for streams) will return a Promise in the event + * that a callback is omitted. + */ +common.util.promisifyAll(Notification); + +/** + * Reference to the {@link Notification} class. + * @name module:@google-cloud/storage.Notification + * @see Notification + */ +module.exports = Notification;