@google-cloud/firestore-api 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +111 -0
  2. package/build/protos/google/firestore/admin/v1/backup.proto +112 -0
  3. package/build/protos/google/firestore/admin/v1/database.proto +403 -0
  4. package/build/protos/google/firestore/admin/v1/field.proto +154 -0
  5. package/build/protos/google/firestore/admin/v1/firestore_admin.proto +1229 -0
  6. package/build/protos/google/firestore/admin/v1/index.proto +378 -0
  7. package/build/protos/google/firestore/admin/v1/location.proto +30 -0
  8. package/build/protos/google/firestore/admin/v1/operation.proto +330 -0
  9. package/build/protos/google/firestore/admin/v1/realtime_updates.proto +40 -0
  10. package/build/protos/google/firestore/admin/v1/schedule.proto +95 -0
  11. package/build/protos/google/firestore/admin/v1/snapshot.proto +53 -0
  12. package/build/protos/google/firestore/admin/v1/user_creds.proto +86 -0
  13. package/build/protos/google/firestore/v1/aggregation_result.proto +43 -0
  14. package/build/protos/google/firestore/v1/bloom_filter.proto +73 -0
  15. package/build/protos/google/firestore/v1/common.proto +111 -0
  16. package/build/protos/google/firestore/v1/document.proto +247 -0
  17. package/build/protos/google/firestore/v1/explain_stats.proto +41 -0
  18. package/build/protos/google/firestore/v1/firestore.proto +1237 -0
  19. package/build/protos/google/firestore/v1/pipeline.proto +43 -0
  20. package/build/protos/google/firestore/v1/query.proto +600 -0
  21. package/build/protos/google/firestore/v1/query_profile.proto +92 -0
  22. package/build/protos/google/firestore/v1/write.proto +286 -0
  23. package/build/protos/google/firestore/v1beta1/common.proto +82 -0
  24. package/build/protos/google/firestore/v1beta1/document.proto +149 -0
  25. package/build/protos/google/firestore/v1beta1/firestore.proto +900 -0
  26. package/build/protos/google/firestore/v1beta1/query.proto +300 -0
  27. package/build/protos/google/firestore/v1beta1/undeliverable_first_gen_event.proto +75 -0
  28. package/build/protos/google/firestore/v1beta1/write.proto +258 -0
  29. package/build/protos/protos.d.ts +35648 -0
  30. package/build/protos/protos.js +1 -0
  31. package/build/protos/protos.json +1 -0
  32. package/build/src/index.d.ts +13 -0
  33. package/build/src/index.js +30 -0
  34. package/build/src/index.js.map +1 -0
  35. package/build/src/v1/firestore_admin_client.d.ts +1925 -0
  36. package/build/src/v1/firestore_admin_client.js +2734 -0
  37. package/build/src/v1/firestore_admin_client.js.map +1 -0
  38. package/build/src/v1/firestore_admin_client_config.json +172 -0
  39. package/build/src/v1/firestore_admin_proto_list.json +13 -0
  40. package/build/src/v1/firestore_client.d.ts +1204 -0
  41. package/build/src/v1/firestore_client.js +1605 -0
  42. package/build/src/v1/firestore_client.js.map +1 -0
  43. package/build/src/v1/firestore_client_config.json +135 -0
  44. package/build/src/v1/firestore_proto_list.json +12 -0
  45. package/build/src/v1/gapic_metadata.json +351 -0
  46. package/build/src/v1/index.d.ts +2 -0
  47. package/build/src/v1/index.js +25 -0
  48. package/build/src/v1/index.js.map +1 -0
  49. package/build/src/v1beta1/firestore_client.d.ts +930 -0
  50. package/build/src/v1beta1/firestore_client.js +1310 -0
  51. package/build/src/v1beta1/firestore_client.js.map +1 -0
  52. package/build/src/v1beta1/firestore_client_config.json +99 -0
  53. package/build/src/v1beta1/firestore_proto_list.json +8 -0
  54. package/build/src/v1beta1/gapic_metadata.json +165 -0
  55. package/build/src/v1beta1/index.d.ts +1 -0
  56. package/build/src/v1beta1/index.js +23 -0
  57. package/build/src/v1beta1/index.js.map +1 -0
  58. package/package.json +65 -0
@@ -0,0 +1,1605 @@
1
+ "use strict";
2
+ // Copyright 2026 Google LLC
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // https://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ //
16
+ // ** This file is automatically generated by gapic-generator-typescript. **
17
+ // ** https://github.com/googleapis/gapic-generator-typescript **
18
+ // ** All changes to this file may be overwritten. **
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.FirestoreClient = void 0;
21
+ const stream_1 = require("stream");
22
+ const jsonProtos = require("../../protos/protos.json");
23
+ const google_gax_1 = require("google-gax");
24
+ /**
25
+ * Client JSON configuration object, loaded from
26
+ * `src/v1/firestore_client_config.json`.
27
+ * This file defines retry strategy and timeouts for all API methods in this library.
28
+ */
29
+ const gapicConfig = require("./firestore_client_config.json");
30
+ const version = require('../../../package.json').version;
31
+ /**
32
+ * The Cloud Firestore service.
33
+ *
34
+ * Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL
35
+ * document database that simplifies storing, syncing, and querying data for
36
+ * your mobile, web, and IoT apps at global scale. Its client libraries provide
37
+ * live synchronization and offline support, while its security features and
38
+ * integrations with Firebase and Google Cloud Platform accelerate building
39
+ * truly serverless apps.
40
+ * @class
41
+ * @memberof v1
42
+ */
43
+ class FirestoreClient {
44
+ _terminated = false;
45
+ _opts;
46
+ _providedCustomServicePath;
47
+ _gaxModule;
48
+ _gaxGrpc;
49
+ _protos;
50
+ _defaults;
51
+ _universeDomain;
52
+ _servicePath;
53
+ _log = google_gax_1.loggingUtils.log('firestore-api');
54
+ auth;
55
+ descriptors = {
56
+ page: {},
57
+ stream: {},
58
+ longrunning: {},
59
+ batching: {},
60
+ };
61
+ warn;
62
+ innerApiCalls;
63
+ locationsClient;
64
+ firestoreStub;
65
+ /**
66
+ * Construct an instance of FirestoreClient.
67
+ *
68
+ * @param {object} [options] - The configuration object.
69
+ * The options accepted by the constructor are described in detail
70
+ * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
71
+ * The common options are:
72
+ * @param {object} [options.credentials] - Credentials object.
73
+ * @param {string} [options.credentials.client_email]
74
+ * @param {string} [options.credentials.private_key]
75
+ * @param {string} [options.email] - Account email address. Required when
76
+ * using a .pem or .p12 keyFilename.
77
+ * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or
78
+ * .p12 key downloaded from the Google Developers Console. If you provide
79
+ * a path to a JSON file, the projectId option below is not necessary.
80
+ * NOTE: .pem and .p12 require you to specify options.email as well.
81
+ * @param {number} [options.port] - The port on which to connect to
82
+ * the remote host.
83
+ * @param {string} [options.projectId] - The project ID from the Google
84
+ * Developer's Console, e.g. 'grape-spaceship-123'. We will also check
85
+ * the environment variable GCLOUD_PROJECT for your project ID. If your
86
+ * app is running in an environment which supports
87
+ * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials},
88
+ * your project ID will be detected automatically.
89
+ * @param {string} [options.apiEndpoint] - The domain name of the
90
+ * API remote host.
91
+ * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
92
+ * Follows the structure of {@link gapicConfig}.
93
+ * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode.
94
+ * For more information, please check the
95
+ * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
96
+ * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
97
+ * need to avoid loading the default gRPC version and want to use the fallback
98
+ * HTTP implementation. Load only fallback version and pass it to the constructor:
99
+ * ```
100
+ * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
101
+ * const client = new FirestoreClient({fallback: true}, gax);
102
+ * ```
103
+ */
104
+ constructor(opts, gaxInstance) {
105
+ // Ensure that options include all the required fields.
106
+ const staticMembers = this.constructor;
107
+ if (opts?.universe_domain &&
108
+ opts?.universeDomain &&
109
+ opts?.universe_domain !== opts?.universeDomain) {
110
+ throw new Error('Please set either universe_domain or universeDomain, but not both.');
111
+ }
112
+ const universeDomainEnvVar = typeof process === 'object' && typeof process.env === 'object'
113
+ ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
114
+ : undefined;
115
+ this._universeDomain =
116
+ opts?.universeDomain ??
117
+ opts?.universe_domain ??
118
+ universeDomainEnvVar ??
119
+ 'googleapis.com';
120
+ this._servicePath = 'firestore.' + this._universeDomain;
121
+ const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath;
122
+ this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint);
123
+ const port = opts?.port || staticMembers.port;
124
+ const clientConfig = opts?.clientConfig ?? {};
125
+ const fallback = opts?.fallback ??
126
+ (typeof window !== 'undefined' && typeof window?.fetch === 'function');
127
+ opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
128
+ // Request numeric enum values if REST transport is used.
129
+ opts.numericEnums = true;
130
+ // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
131
+ if (servicePath !== this._servicePath && !('scopes' in opts)) {
132
+ opts['scopes'] = staticMembers.scopes;
133
+ }
134
+ // Load google-gax module synchronously if needed
135
+ if (!gaxInstance) {
136
+ gaxInstance = require('google-gax');
137
+ }
138
+ // Choose either gRPC or proto-over-HTTP implementation of google-gax.
139
+ this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance;
140
+ // Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
141
+ this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
142
+ // Save options to use in initialize() method.
143
+ this._opts = opts;
144
+ // Save the auth object to the client, for use by other methods.
145
+ this.auth = this._gaxGrpc.auth;
146
+ // Set useJWTAccessWithScope on the auth object.
147
+ this.auth.useJWTAccessWithScope = true;
148
+ // Set defaultServicePath on the auth object.
149
+ this.auth.defaultServicePath = this._servicePath;
150
+ // Set the default scopes in auth client if needed.
151
+ if (servicePath === this._servicePath) {
152
+ this.auth.defaultScopes = staticMembers.scopes;
153
+ }
154
+ this.locationsClient = new this._gaxModule.LocationsClient(this._gaxGrpc, opts);
155
+ // Determine the client header string.
156
+ const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
157
+ if (typeof process === 'object' && 'versions' in process) {
158
+ clientHeader.push(`gl-node/${process.versions.node}`);
159
+ }
160
+ else {
161
+ clientHeader.push(`gl-web/${this._gaxModule.version}`);
162
+ }
163
+ if (!opts.fallback) {
164
+ clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
165
+ }
166
+ else {
167
+ clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);
168
+ }
169
+ if (opts.libName && opts.libVersion) {
170
+ clientHeader.push(`${opts.libName}/${opts.libVersion}`);
171
+ }
172
+ // Load the applicable protos.
173
+ this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
174
+ // Some of the methods on this service return "paged" results,
175
+ // (e.g. 50 results at a time, with tokens to get subsequent
176
+ // pages). Denote the keys used for pagination and results.
177
+ this.descriptors.page = {
178
+ listDocuments: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'documents'),
179
+ partitionQuery: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'partitions'),
180
+ listCollectionIds: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'collectionIds'),
181
+ };
182
+ // Some of the methods on this service provide streaming responses.
183
+ // Provide descriptors for these.
184
+ this.descriptors.stream = {
185
+ batchGetDocuments: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries),
186
+ runQuery: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries),
187
+ executePipeline: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries),
188
+ runAggregationQuery: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries),
189
+ write: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries),
190
+ listen: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries),
191
+ };
192
+ // Put together the default options sent with requests.
193
+ this._defaults = this._gaxGrpc.constructSettings('google.firestore.v1.Firestore', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
194
+ // Set up a dictionary of "inner API calls"; the core implementation
195
+ // of calling the API is handled in `google-gax`, with this code
196
+ // merely providing the destination and request information.
197
+ this.innerApiCalls = {};
198
+ // Add a warn function to the client constructor so it can be easily tested.
199
+ this.warn = this._gaxModule.warn;
200
+ }
201
+ /**
202
+ * Initialize the client.
203
+ * Performs asynchronous operations (such as authentication) and prepares the client.
204
+ * This function will be called automatically when any class method is called for the
205
+ * first time, but if you need to initialize it before calling an actual method,
206
+ * feel free to call initialize() directly.
207
+ *
208
+ * You can await on this method if you want to make sure the client is initialized.
209
+ *
210
+ * @returns {Promise} A promise that resolves to an authenticated service stub.
211
+ */
212
+ initialize() {
213
+ // If the client stub promise is already initialized, return immediately.
214
+ if (this.firestoreStub) {
215
+ return this.firestoreStub;
216
+ }
217
+ // Put together the "service stub" for
218
+ // google.firestore.v1.Firestore.
219
+ this.firestoreStub = this._gaxGrpc.createStub(this._opts.fallback
220
+ ? this._protos.lookupService('google.firestore.v1.Firestore')
221
+ : // eslint-disable-next-line @typescript-eslint/no-explicit-any
222
+ this._protos.google.firestore.v1.Firestore, this._opts, this._providedCustomServicePath);
223
+ // Iterate over each of the methods that the service provides
224
+ // and create an API call method for each.
225
+ const firestoreStubMethods = [
226
+ 'getDocument',
227
+ 'listDocuments',
228
+ 'updateDocument',
229
+ 'deleteDocument',
230
+ 'batchGetDocuments',
231
+ 'beginTransaction',
232
+ 'commit',
233
+ 'rollback',
234
+ 'runQuery',
235
+ 'executePipeline',
236
+ 'runAggregationQuery',
237
+ 'partitionQuery',
238
+ 'write',
239
+ 'listen',
240
+ 'listCollectionIds',
241
+ 'batchWrite',
242
+ 'createDocument',
243
+ ];
244
+ for (const methodName of firestoreStubMethods) {
245
+ const callPromise = this.firestoreStub.then((stub) => (...args) => {
246
+ if (this._terminated) {
247
+ if (methodName in this.descriptors.stream) {
248
+ const stream = new stream_1.PassThrough({ objectMode: true });
249
+ setImmediate(() => {
250
+ stream.emit('error', new this._gaxModule.GoogleError('The client has already been closed.'));
251
+ });
252
+ return stream;
253
+ }
254
+ return Promise.reject('The client has already been closed.');
255
+ }
256
+ const func = stub[methodName];
257
+ return func.apply(stub, args);
258
+ }, (err) => () => {
259
+ throw err;
260
+ });
261
+ const descriptor = this.descriptors.page[methodName] ||
262
+ this.descriptors.stream[methodName] ||
263
+ undefined;
264
+ const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], descriptor, this._opts.fallback);
265
+ this.innerApiCalls[methodName] = apiCall;
266
+ }
267
+ return this.firestoreStub;
268
+ }
269
+ /**
270
+ * The DNS address for this API service.
271
+ * @deprecated Use the apiEndpoint method of the client instance.
272
+ * @returns {string} The DNS address for this service.
273
+ */
274
+ static get servicePath() {
275
+ if (typeof process === 'object' &&
276
+ typeof process.emitWarning === 'function') {
277
+ process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning');
278
+ }
279
+ return 'firestore.googleapis.com';
280
+ }
281
+ /**
282
+ * The DNS address for this API service - same as servicePath.
283
+ * @deprecated Use the apiEndpoint method of the client instance.
284
+ * @returns {string} The DNS address for this service.
285
+ */
286
+ static get apiEndpoint() {
287
+ if (typeof process === 'object' &&
288
+ typeof process.emitWarning === 'function') {
289
+ process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning');
290
+ }
291
+ return 'firestore.googleapis.com';
292
+ }
293
+ /**
294
+ * The DNS address for this API service.
295
+ * @returns {string} The DNS address for this service.
296
+ */
297
+ get apiEndpoint() {
298
+ return this._servicePath;
299
+ }
300
+ get universeDomain() {
301
+ return this._universeDomain;
302
+ }
303
+ /**
304
+ * The port for this API service.
305
+ * @returns {number} The default port for this service.
306
+ */
307
+ static get port() {
308
+ return 443;
309
+ }
310
+ /**
311
+ * The scopes needed to make gRPC calls for every method defined
312
+ * in this service.
313
+ * @returns {string[]} List of default scopes.
314
+ */
315
+ static get scopes() {
316
+ return [
317
+ 'https://www.googleapis.com/auth/cloud-platform',
318
+ 'https://www.googleapis.com/auth/datastore',
319
+ ];
320
+ }
321
+ /**
322
+ * Return the project ID used by this class.
323
+ * @returns {Promise} A promise that resolves to string containing the project ID.
324
+ */
325
+ getProjectId(callback) {
326
+ if (callback) {
327
+ this.auth.getProjectId(callback);
328
+ return;
329
+ }
330
+ return this.auth.getProjectId();
331
+ }
332
+ getDocument(request, optionsOrCallback, callback) {
333
+ request = request || {};
334
+ let options;
335
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
336
+ callback = optionsOrCallback;
337
+ options = {};
338
+ }
339
+ else {
340
+ options = optionsOrCallback;
341
+ }
342
+ options = options || {};
343
+ options.otherArgs = options.otherArgs || {};
344
+ options.otherArgs.headers = options.otherArgs.headers || {};
345
+ options.otherArgs.headers['x-goog-request-params'] =
346
+ this._gaxModule.routingHeader.fromParams({
347
+ name: request.name ?? '',
348
+ });
349
+ this.initialize().catch((err) => {
350
+ throw err;
351
+ });
352
+ this._log.info('getDocument request %j', request);
353
+ const wrappedCallback = callback
354
+ ? (error, response, options, rawResponse) => {
355
+ this._log.info('getDocument response %j', response);
356
+ callback(error, response, options, rawResponse); // We verified callback above.
357
+ }
358
+ : undefined;
359
+ return this.innerApiCalls
360
+ .getDocument(request, options, wrappedCallback)
361
+ ?.then(([response, options, rawResponse]) => {
362
+ this._log.info('getDocument response %j', response);
363
+ return [response, options, rawResponse];
364
+ })
365
+ .catch((error) => {
366
+ if (error &&
367
+ 'statusDetails' in error &&
368
+ error.statusDetails instanceof Array) {
369
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
370
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
371
+ }
372
+ throw error;
373
+ });
374
+ }
375
+ updateDocument(request, optionsOrCallback, callback) {
376
+ request = request || {};
377
+ let options;
378
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
379
+ callback = optionsOrCallback;
380
+ options = {};
381
+ }
382
+ else {
383
+ options = optionsOrCallback;
384
+ }
385
+ options = options || {};
386
+ options.otherArgs = options.otherArgs || {};
387
+ options.otherArgs.headers = options.otherArgs.headers || {};
388
+ options.otherArgs.headers['x-goog-request-params'] =
389
+ this._gaxModule.routingHeader.fromParams({
390
+ 'document.name': request.document.name ?? '',
391
+ });
392
+ this.initialize().catch((err) => {
393
+ throw err;
394
+ });
395
+ this._log.info('updateDocument request %j', request);
396
+ const wrappedCallback = callback
397
+ ? (error, response, options, rawResponse) => {
398
+ this._log.info('updateDocument response %j', response);
399
+ callback(error, response, options, rawResponse); // We verified callback above.
400
+ }
401
+ : undefined;
402
+ return this.innerApiCalls
403
+ .updateDocument(request, options, wrappedCallback)
404
+ ?.then(([response, options, rawResponse]) => {
405
+ this._log.info('updateDocument response %j', response);
406
+ return [response, options, rawResponse];
407
+ })
408
+ .catch((error) => {
409
+ if (error &&
410
+ 'statusDetails' in error &&
411
+ error.statusDetails instanceof Array) {
412
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
413
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
414
+ }
415
+ throw error;
416
+ });
417
+ }
418
+ deleteDocument(request, optionsOrCallback, callback) {
419
+ request = request || {};
420
+ let options;
421
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
422
+ callback = optionsOrCallback;
423
+ options = {};
424
+ }
425
+ else {
426
+ options = optionsOrCallback;
427
+ }
428
+ options = options || {};
429
+ options.otherArgs = options.otherArgs || {};
430
+ options.otherArgs.headers = options.otherArgs.headers || {};
431
+ options.otherArgs.headers['x-goog-request-params'] =
432
+ this._gaxModule.routingHeader.fromParams({
433
+ name: request.name ?? '',
434
+ });
435
+ this.initialize().catch((err) => {
436
+ throw err;
437
+ });
438
+ this._log.info('deleteDocument request %j', request);
439
+ const wrappedCallback = callback
440
+ ? (error, response, options, rawResponse) => {
441
+ this._log.info('deleteDocument response %j', response);
442
+ callback(error, response, options, rawResponse); // We verified callback above.
443
+ }
444
+ : undefined;
445
+ return this.innerApiCalls
446
+ .deleteDocument(request, options, wrappedCallback)
447
+ ?.then(([response, options, rawResponse]) => {
448
+ this._log.info('deleteDocument response %j', response);
449
+ return [response, options, rawResponse];
450
+ })
451
+ .catch((error) => {
452
+ if (error &&
453
+ 'statusDetails' in error &&
454
+ error.statusDetails instanceof Array) {
455
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
456
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
457
+ }
458
+ throw error;
459
+ });
460
+ }
461
+ beginTransaction(request, optionsOrCallback, callback) {
462
+ request = request || {};
463
+ let options;
464
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
465
+ callback = optionsOrCallback;
466
+ options = {};
467
+ }
468
+ else {
469
+ options = optionsOrCallback;
470
+ }
471
+ options = options || {};
472
+ options.otherArgs = options.otherArgs || {};
473
+ options.otherArgs.headers = options.otherArgs.headers || {};
474
+ options.otherArgs.headers['x-goog-request-params'] =
475
+ this._gaxModule.routingHeader.fromParams({
476
+ database: request.database ?? '',
477
+ });
478
+ this.initialize().catch((err) => {
479
+ throw err;
480
+ });
481
+ this._log.info('beginTransaction request %j', request);
482
+ const wrappedCallback = callback
483
+ ? (error, response, options, rawResponse) => {
484
+ this._log.info('beginTransaction response %j', response);
485
+ callback(error, response, options, rawResponse); // We verified callback above.
486
+ }
487
+ : undefined;
488
+ return this.innerApiCalls
489
+ .beginTransaction(request, options, wrappedCallback)
490
+ ?.then(([response, options, rawResponse]) => {
491
+ this._log.info('beginTransaction response %j', response);
492
+ return [response, options, rawResponse];
493
+ })
494
+ .catch((error) => {
495
+ if (error &&
496
+ 'statusDetails' in error &&
497
+ error.statusDetails instanceof Array) {
498
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
499
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
500
+ }
501
+ throw error;
502
+ });
503
+ }
504
+ commit(request, optionsOrCallback, callback) {
505
+ request = request || {};
506
+ let options;
507
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
508
+ callback = optionsOrCallback;
509
+ options = {};
510
+ }
511
+ else {
512
+ options = optionsOrCallback;
513
+ }
514
+ options = options || {};
515
+ options.otherArgs = options.otherArgs || {};
516
+ options.otherArgs.headers = options.otherArgs.headers || {};
517
+ options.otherArgs.headers['x-goog-request-params'] =
518
+ this._gaxModule.routingHeader.fromParams({
519
+ database: request.database ?? '',
520
+ });
521
+ this.initialize().catch((err) => {
522
+ throw err;
523
+ });
524
+ this._log.info('commit request %j', request);
525
+ const wrappedCallback = callback
526
+ ? (error, response, options, rawResponse) => {
527
+ this._log.info('commit response %j', response);
528
+ callback(error, response, options, rawResponse); // We verified callback above.
529
+ }
530
+ : undefined;
531
+ return this.innerApiCalls
532
+ .commit(request, options, wrappedCallback)
533
+ ?.then(([response, options, rawResponse]) => {
534
+ this._log.info('commit response %j', response);
535
+ return [response, options, rawResponse];
536
+ })
537
+ .catch((error) => {
538
+ if (error &&
539
+ 'statusDetails' in error &&
540
+ error.statusDetails instanceof Array) {
541
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
542
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
543
+ }
544
+ throw error;
545
+ });
546
+ }
547
+ rollback(request, optionsOrCallback, callback) {
548
+ request = request || {};
549
+ let options;
550
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
551
+ callback = optionsOrCallback;
552
+ options = {};
553
+ }
554
+ else {
555
+ options = optionsOrCallback;
556
+ }
557
+ options = options || {};
558
+ options.otherArgs = options.otherArgs || {};
559
+ options.otherArgs.headers = options.otherArgs.headers || {};
560
+ options.otherArgs.headers['x-goog-request-params'] =
561
+ this._gaxModule.routingHeader.fromParams({
562
+ database: request.database ?? '',
563
+ });
564
+ this.initialize().catch((err) => {
565
+ throw err;
566
+ });
567
+ this._log.info('rollback request %j', request);
568
+ const wrappedCallback = callback
569
+ ? (error, response, options, rawResponse) => {
570
+ this._log.info('rollback response %j', response);
571
+ callback(error, response, options, rawResponse); // We verified callback above.
572
+ }
573
+ : undefined;
574
+ return this.innerApiCalls
575
+ .rollback(request, options, wrappedCallback)
576
+ ?.then(([response, options, rawResponse]) => {
577
+ this._log.info('rollback response %j', response);
578
+ return [response, options, rawResponse];
579
+ })
580
+ .catch((error) => {
581
+ if (error &&
582
+ 'statusDetails' in error &&
583
+ error.statusDetails instanceof Array) {
584
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
585
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
586
+ }
587
+ throw error;
588
+ });
589
+ }
590
+ batchWrite(request, optionsOrCallback, callback) {
591
+ request = request || {};
592
+ let options;
593
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
594
+ callback = optionsOrCallback;
595
+ options = {};
596
+ }
597
+ else {
598
+ options = optionsOrCallback;
599
+ }
600
+ options = options || {};
601
+ options.otherArgs = options.otherArgs || {};
602
+ options.otherArgs.headers = options.otherArgs.headers || {};
603
+ options.otherArgs.headers['x-goog-request-params'] =
604
+ this._gaxModule.routingHeader.fromParams({
605
+ database: request.database ?? '',
606
+ });
607
+ this.initialize().catch((err) => {
608
+ throw err;
609
+ });
610
+ this._log.info('batchWrite request %j', request);
611
+ const wrappedCallback = callback
612
+ ? (error, response, options, rawResponse) => {
613
+ this._log.info('batchWrite response %j', response);
614
+ callback(error, response, options, rawResponse); // We verified callback above.
615
+ }
616
+ : undefined;
617
+ return this.innerApiCalls
618
+ .batchWrite(request, options, wrappedCallback)
619
+ ?.then(([response, options, rawResponse]) => {
620
+ this._log.info('batchWrite response %j', response);
621
+ return [response, options, rawResponse];
622
+ })
623
+ .catch((error) => {
624
+ if (error &&
625
+ 'statusDetails' in error &&
626
+ error.statusDetails instanceof Array) {
627
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
628
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
629
+ }
630
+ throw error;
631
+ });
632
+ }
633
+ createDocument(request, optionsOrCallback, callback) {
634
+ request = request || {};
635
+ let options;
636
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
637
+ callback = optionsOrCallback;
638
+ options = {};
639
+ }
640
+ else {
641
+ options = optionsOrCallback;
642
+ }
643
+ options = options || {};
644
+ options.otherArgs = options.otherArgs || {};
645
+ options.otherArgs.headers = options.otherArgs.headers || {};
646
+ options.otherArgs.headers['x-goog-request-params'] =
647
+ this._gaxModule.routingHeader.fromParams({
648
+ parent: request.parent ?? '',
649
+ collection_id: request.collectionId?.toString() ?? '',
650
+ });
651
+ this.initialize().catch((err) => {
652
+ throw err;
653
+ });
654
+ this._log.info('createDocument request %j', request);
655
+ const wrappedCallback = callback
656
+ ? (error, response, options, rawResponse) => {
657
+ this._log.info('createDocument response %j', response);
658
+ callback(error, response, options, rawResponse); // We verified callback above.
659
+ }
660
+ : undefined;
661
+ return this.innerApiCalls
662
+ .createDocument(request, options, wrappedCallback)
663
+ ?.then(([response, options, rawResponse]) => {
664
+ this._log.info('createDocument response %j', response);
665
+ return [response, options, rawResponse];
666
+ })
667
+ .catch((error) => {
668
+ if (error &&
669
+ 'statusDetails' in error &&
670
+ error.statusDetails instanceof Array) {
671
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
672
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
673
+ }
674
+ throw error;
675
+ });
676
+ }
677
+ /**
678
+ * Gets multiple documents.
679
+ *
680
+ * Documents returned by this method are not guaranteed to be returned in the
681
+ * same order that they were requested.
682
+ *
683
+ * @param {Object} request
684
+ * The request object that will be sent.
685
+ * @param {string} request.database
686
+ * Required. The database name. In the format:
687
+ * `projects/{project_id}/databases/{database_id}`.
688
+ * @param {string[]} request.documents
689
+ * The names of the documents to retrieve. In the format:
690
+ * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
691
+ * The request will fail if any of the document is not a child resource of the
692
+ * given `database`. Duplicate names will be elided.
693
+ * @param {google.firestore.v1.DocumentMask} request.mask
694
+ * The fields to return. If not set, returns all fields.
695
+ *
696
+ * If a document has a field that is not present in this mask, that field will
697
+ * not be returned in the response.
698
+ * @param {Buffer} request.transaction
699
+ * Reads documents in a transaction.
700
+ * @param {google.firestore.v1.TransactionOptions} request.newTransaction
701
+ * Starts a new transaction and reads the documents.
702
+ * Defaults to a read-only transaction.
703
+ * The new transaction ID will be returned as the first response in the
704
+ * stream.
705
+ * @param {google.protobuf.Timestamp} request.readTime
706
+ * Reads documents as they were at the given time.
707
+ *
708
+ * This must be a microsecond precision timestamp within the past one hour,
709
+ * or if Point-in-Time Recovery is enabled, can additionally be a whole
710
+ * minute timestamp within the past 7 days.
711
+ * @param {object} [options]
712
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
713
+ * @returns {Stream}
714
+ * An object stream which emits {@link protos.google.firestore.v1.BatchGetDocumentsResponse|BatchGetDocumentsResponse} on 'data' event.
715
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation }
716
+ * for more details and examples.
717
+ * @example <caption>include:samples/generated/v1/firestore.batch_get_documents.js</caption>
718
+ * region_tag:firestore_v1_generated_Firestore_BatchGetDocuments_async
719
+ */
720
+ batchGetDocuments(request, options) {
721
+ request = request || {};
722
+ options = options || {};
723
+ options.otherArgs = options.otherArgs || {};
724
+ options.otherArgs.headers = options.otherArgs.headers || {};
725
+ options.otherArgs.headers['x-goog-request-params'] =
726
+ this._gaxModule.routingHeader.fromParams({
727
+ database: request.database ?? '',
728
+ });
729
+ this.initialize().catch((err) => {
730
+ throw err;
731
+ });
732
+ this._log.info('batchGetDocuments stream %j', options);
733
+ return this.innerApiCalls.batchGetDocuments(request, options);
734
+ }
735
+ /**
736
+ * Runs a query.
737
+ *
738
+ * @param {Object} request
739
+ * The request object that will be sent.
740
+ * @param {string} request.parent
741
+ * Required. The parent resource name. In the format:
742
+ * `projects/{project_id}/databases/{database_id}/documents` or
743
+ * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
744
+ * For example:
745
+ * `projects/my-project/databases/my-database/documents` or
746
+ * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
747
+ * @param {google.firestore.v1.StructuredQuery} request.structuredQuery
748
+ * A structured query.
749
+ * @param {Buffer} request.transaction
750
+ * Run the query within an already active transaction.
751
+ *
752
+ * The value here is the opaque transaction ID to execute the query in.
753
+ * @param {google.firestore.v1.TransactionOptions} request.newTransaction
754
+ * Starts a new transaction and reads the documents.
755
+ * Defaults to a read-only transaction.
756
+ * The new transaction ID will be returned as the first response in the
757
+ * stream.
758
+ * @param {google.protobuf.Timestamp} request.readTime
759
+ * Reads documents as they were at the given time.
760
+ *
761
+ * This must be a microsecond precision timestamp within the past one hour,
762
+ * or if Point-in-Time Recovery is enabled, can additionally be a whole
763
+ * minute timestamp within the past 7 days.
764
+ * @param {google.firestore.v1.ExplainOptions} [request.explainOptions]
765
+ * Optional. Explain options for the query. If set, additional query
766
+ * statistics will be returned. If not, only query results will be returned.
767
+ * @param {object} [options]
768
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
769
+ * @returns {Stream}
770
+ * An object stream which emits {@link protos.google.firestore.v1.RunQueryResponse|RunQueryResponse} on 'data' event.
771
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation }
772
+ * for more details and examples.
773
+ * @example <caption>include:samples/generated/v1/firestore.run_query.js</caption>
774
+ * region_tag:firestore_v1_generated_Firestore_RunQuery_async
775
+ */
776
+ runQuery(request, options) {
777
+ request = request || {};
778
+ options = options || {};
779
+ options.otherArgs = options.otherArgs || {};
780
+ options.otherArgs.headers = options.otherArgs.headers || {};
781
+ options.otherArgs.headers['x-goog-request-params'] =
782
+ this._gaxModule.routingHeader.fromParams({
783
+ parent: request.parent ?? '',
784
+ });
785
+ this.initialize().catch((err) => {
786
+ throw err;
787
+ });
788
+ this._log.info('runQuery stream %j', options);
789
+ return this.innerApiCalls.runQuery(request, options);
790
+ }
791
+ /**
792
+ * Executes a pipeline query.
793
+ *
794
+ * @param {Object} request
795
+ * The request object that will be sent.
796
+ * @param {string} request.database
797
+ * Required. Database identifier, in the form
798
+ * `projects/{project}/databases/{database}`.
799
+ * @param {google.firestore.v1.StructuredPipeline} request.structuredPipeline
800
+ * A pipelined operation.
801
+ * @param {Buffer} request.transaction
802
+ * Run the query within an already active transaction.
803
+ *
804
+ * The value here is the opaque transaction ID to execute the query in.
805
+ * @param {google.firestore.v1.TransactionOptions} request.newTransaction
806
+ * Execute the pipeline in a new transaction.
807
+ *
808
+ * The identifier of the newly created transaction will be returned in the
809
+ * first response on the stream. This defaults to a read-only transaction.
810
+ * @param {google.protobuf.Timestamp} request.readTime
811
+ * Execute the pipeline in a snapshot transaction at the given time.
812
+ *
813
+ * This must be a microsecond precision timestamp within the past one hour,
814
+ * or if Point-in-Time Recovery is enabled, can additionally be a whole
815
+ * minute timestamp within the past 7 days.
816
+ * @param {boolean} [request.autoCommitTransaction]
817
+ * Optional. Automatically commits the transaction after the pipeline has been
818
+ * executed. Only permitted in combination with `transaction` or
819
+ * `new_transaction`.
820
+ * @param {object} [options]
821
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
822
+ * @returns {Stream}
823
+ * An object stream which emits {@link protos.google.firestore.v1.ExecutePipelineResponse|ExecutePipelineResponse} on 'data' event.
824
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation }
825
+ * for more details and examples.
826
+ * @example <caption>include:samples/generated/v1/firestore.execute_pipeline.js</caption>
827
+ * region_tag:firestore_v1_generated_Firestore_ExecutePipeline_async
828
+ */
829
+ executePipeline(request, options) {
830
+ request = request || {};
831
+ options = options || {};
832
+ options.otherArgs = options.otherArgs || {};
833
+ options.otherArgs.headers = options.otherArgs.headers || {};
834
+ let routingParameter = {};
835
+ {
836
+ const fieldValue = request.database;
837
+ if (fieldValue !== undefined && fieldValue !== null) {
838
+ const match = fieldValue
839
+ .toString()
840
+ .match(RegExp('projects/(?<project_id>[^/]+)(?:/.*)?'));
841
+ if (match) {
842
+ const parameterValue = match.groups?.['project_id'] ?? fieldValue;
843
+ Object.assign(routingParameter, { project_id: parameterValue });
844
+ }
845
+ }
846
+ }
847
+ {
848
+ const fieldValue = request.database;
849
+ if (fieldValue !== undefined && fieldValue !== null) {
850
+ const match = fieldValue
851
+ .toString()
852
+ .match(RegExp('projects/[^/]+/databases/(?<database_id>[^/]+)(?:/.*)?'));
853
+ if (match) {
854
+ const parameterValue = match.groups?.['database_id'] ?? fieldValue;
855
+ Object.assign(routingParameter, { database_id: parameterValue });
856
+ }
857
+ }
858
+ }
859
+ options.otherArgs.headers['x-goog-request-params'] =
860
+ this._gaxModule.routingHeader.fromParams(routingParameter);
861
+ this.initialize().catch((err) => {
862
+ throw err;
863
+ });
864
+ this._log.info('executePipeline stream %j', options);
865
+ return this.innerApiCalls.executePipeline(request, options);
866
+ }
867
+ /**
868
+ * Runs an aggregation query.
869
+ *
870
+ * Rather than producing {@link protos.google.firestore.v1.Document|Document} results like
871
+ * {@link protos.google.firestore.v1.Firestore.RunQuery|Firestore.RunQuery}, this API
872
+ * allows running an aggregation to produce a series of
873
+ * {@link protos.google.firestore.v1.AggregationResult|AggregationResult} server-side.
874
+ *
875
+ * High-Level Example:
876
+ *
877
+ * ```
878
+ * -- Return the number of documents in table given a filter.
879
+ * SELECT COUNT(*) FROM ( SELECT * FROM k where a = true );
880
+ * ```
881
+ *
882
+ * @param {Object} request
883
+ * The request object that will be sent.
884
+ * @param {string} request.parent
885
+ * Required. The parent resource name. In the format:
886
+ * `projects/{project_id}/databases/{database_id}/documents` or
887
+ * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
888
+ * For example:
889
+ * `projects/my-project/databases/my-database/documents` or
890
+ * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
891
+ * @param {google.firestore.v1.StructuredAggregationQuery} request.structuredAggregationQuery
892
+ * An aggregation query.
893
+ * @param {Buffer} request.transaction
894
+ * Run the aggregation within an already active transaction.
895
+ *
896
+ * The value here is the opaque transaction ID to execute the query in.
897
+ * @param {google.firestore.v1.TransactionOptions} request.newTransaction
898
+ * Starts a new transaction as part of the query, defaulting to read-only.
899
+ *
900
+ * The new transaction ID will be returned as the first response in the
901
+ * stream.
902
+ * @param {google.protobuf.Timestamp} request.readTime
903
+ * Executes the query at the given timestamp.
904
+ *
905
+ * This must be a microsecond precision timestamp within the past one hour,
906
+ * or if Point-in-Time Recovery is enabled, can additionally be a whole
907
+ * minute timestamp within the past 7 days.
908
+ * @param {google.firestore.v1.ExplainOptions} [request.explainOptions]
909
+ * Optional. Explain options for the query. If set, additional query
910
+ * statistics will be returned. If not, only query results will be returned.
911
+ * @param {object} [options]
912
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
913
+ * @returns {Stream}
914
+ * An object stream which emits {@link protos.google.firestore.v1.RunAggregationQueryResponse|RunAggregationQueryResponse} on 'data' event.
915
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation }
916
+ * for more details and examples.
917
+ * @example <caption>include:samples/generated/v1/firestore.run_aggregation_query.js</caption>
918
+ * region_tag:firestore_v1_generated_Firestore_RunAggregationQuery_async
919
+ */
920
+ runAggregationQuery(request, options) {
921
+ request = request || {};
922
+ options = options || {};
923
+ options.otherArgs = options.otherArgs || {};
924
+ options.otherArgs.headers = options.otherArgs.headers || {};
925
+ options.otherArgs.headers['x-goog-request-params'] =
926
+ this._gaxModule.routingHeader.fromParams({
927
+ parent: request.parent ?? '',
928
+ });
929
+ this.initialize().catch((err) => {
930
+ throw err;
931
+ });
932
+ this._log.info('runAggregationQuery stream %j', options);
933
+ return this.innerApiCalls.runAggregationQuery(request, options);
934
+ }
935
+ /**
936
+ * Streams batches of document updates and deletes, in order. This method is
937
+ * only available via gRPC or WebChannel (not REST).
938
+ *
939
+ * @param {object} [options]
940
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
941
+ * @returns {Stream}
942
+ * An object stream which is both readable and writable. It accepts objects
943
+ * representing {@link protos.google.firestore.v1.WriteRequest|WriteRequest} for write() method, and
944
+ * will emit objects representing {@link protos.google.firestore.v1.WriteResponse|WriteResponse} on 'data' event asynchronously.
945
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation }
946
+ * for more details and examples.
947
+ * @example <caption>include:samples/generated/v1/firestore.write.js</caption>
948
+ * region_tag:firestore_v1_generated_Firestore_Write_async
949
+ */
950
+ write(options) {
951
+ this.initialize().catch((err) => {
952
+ throw err;
953
+ });
954
+ this._log.info('write stream %j', options);
955
+ return this.innerApiCalls.write(null, options);
956
+ }
957
+ /**
958
+ * Listens to changes. This method is only available via gRPC or WebChannel
959
+ * (not REST).
960
+ *
961
+ * @param {object} [options]
962
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
963
+ * @returns {Stream}
964
+ * An object stream which is both readable and writable. It accepts objects
965
+ * representing {@link protos.google.firestore.v1.ListenRequest|ListenRequest} for write() method, and
966
+ * will emit objects representing {@link protos.google.firestore.v1.ListenResponse|ListenResponse} on 'data' event asynchronously.
967
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation }
968
+ * for more details and examples.
969
+ * @example <caption>include:samples/generated/v1/firestore.listen.js</caption>
970
+ * region_tag:firestore_v1_generated_Firestore_Listen_async
971
+ */
972
+ listen(options) {
973
+ this.initialize().catch((err) => {
974
+ throw err;
975
+ });
976
+ this._log.info('listen stream %j', options);
977
+ return this.innerApiCalls.listen(null, options);
978
+ }
979
+ listDocuments(request, optionsOrCallback, callback) {
980
+ request = request || {};
981
+ let options;
982
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
983
+ callback = optionsOrCallback;
984
+ options = {};
985
+ }
986
+ else {
987
+ options = optionsOrCallback;
988
+ }
989
+ options = options || {};
990
+ options.otherArgs = options.otherArgs || {};
991
+ options.otherArgs.headers = options.otherArgs.headers || {};
992
+ options.otherArgs.headers['x-goog-request-params'] =
993
+ this._gaxModule.routingHeader.fromParams({
994
+ parent: request.parent ?? '',
995
+ collection_id: request.collectionId?.toString() ?? '',
996
+ });
997
+ this.initialize().catch((err) => {
998
+ throw err;
999
+ });
1000
+ const wrappedCallback = callback
1001
+ ? (error, values, nextPageRequest, rawResponse) => {
1002
+ this._log.info('listDocuments values %j', values);
1003
+ callback(error, values, nextPageRequest, rawResponse); // We verified callback above.
1004
+ }
1005
+ : undefined;
1006
+ this._log.info('listDocuments request %j', request);
1007
+ return this.innerApiCalls
1008
+ .listDocuments(request, options, wrappedCallback)
1009
+ ?.then(([response, input, output]) => {
1010
+ this._log.info('listDocuments values %j', response);
1011
+ return [response, input, output];
1012
+ });
1013
+ }
1014
+ /**
1015
+ * Equivalent to `listDocuments`, but returns a NodeJS Stream object.
1016
+ * @param {Object} request
1017
+ * The request object that will be sent.
1018
+ * @param {string} request.parent
1019
+ * Required. The parent resource name. In the format:
1020
+ * `projects/{project_id}/databases/{database_id}/documents` or
1021
+ * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
1022
+ *
1023
+ * For example:
1024
+ * `projects/my-project/databases/my-database/documents` or
1025
+ * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
1026
+ * @param {string} [request.collectionId]
1027
+ * Optional. The collection ID, relative to `parent`, to list.
1028
+ *
1029
+ * For example: `chatrooms` or `messages`.
1030
+ *
1031
+ * This is optional, and when not provided, Firestore will list documents
1032
+ * from all collections under the provided `parent`.
1033
+ * @param {number} [request.pageSize]
1034
+ * Optional. The maximum number of documents to return in a single response.
1035
+ *
1036
+ * Firestore may return fewer than this value.
1037
+ * @param {string} [request.pageToken]
1038
+ * Optional. A page token, received from a previous `ListDocuments` response.
1039
+ *
1040
+ * Provide this to retrieve the subsequent page. When paginating, all other
1041
+ * parameters (with the exception of `page_size`) must match the values set
1042
+ * in the request that generated the page token.
1043
+ * @param {string} [request.orderBy]
1044
+ * Optional. The optional ordering of the documents to return.
1045
+ *
1046
+ * For example: `priority desc, __name__ desc`.
1047
+ *
1048
+ * This mirrors the {@link protos.google.firestore.v1.StructuredQuery.order_by|`ORDER BY`}
1049
+ * used in Firestore queries but in a string representation. When absent,
1050
+ * documents are ordered based on `__name__ ASC`.
1051
+ * @param {google.firestore.v1.DocumentMask} [request.mask]
1052
+ * Optional. The fields to return. If not set, returns all fields.
1053
+ *
1054
+ * If a document has a field that is not present in this mask, that field
1055
+ * will not be returned in the response.
1056
+ * @param {Buffer} request.transaction
1057
+ * Perform the read as part of an already active transaction.
1058
+ * @param {google.protobuf.Timestamp} request.readTime
1059
+ * Perform the read at the provided time.
1060
+ *
1061
+ * This must be a microsecond precision timestamp within the past one hour,
1062
+ * or if Point-in-Time Recovery is enabled, can additionally be a whole
1063
+ * minute timestamp within the past 7 days.
1064
+ * @param {boolean} request.showMissing
1065
+ * If the list should show missing documents.
1066
+ *
1067
+ * A document is missing if it does not exist, but there are sub-documents
1068
+ * nested underneath it. When true, such missing documents will be returned
1069
+ * with a key but will not have fields,
1070
+ * {@link protos.google.firestore.v1.Document.create_time|`create_time`}, or
1071
+ * {@link protos.google.firestore.v1.Document.update_time|`update_time`} set.
1072
+ *
1073
+ * Requests with `show_missing` may not specify `where` or `order_by`.
1074
+ * @param {object} [options]
1075
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
1076
+ * @returns {Stream}
1077
+ * An object stream which emits an object representing {@link protos.google.firestore.v1.Document|Document} on 'data' event.
1078
+ * The client library will perform auto-pagination by default: it will call the API as many
1079
+ * times as needed. Note that it can affect your quota.
1080
+ * We recommend using `listDocumentsAsync()`
1081
+ * method described below for async iteration which you can stop as needed.
1082
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
1083
+ * for more details and examples.
1084
+ */
1085
+ listDocumentsStream(request, options) {
1086
+ request = request || {};
1087
+ options = options || {};
1088
+ options.otherArgs = options.otherArgs || {};
1089
+ options.otherArgs.headers = options.otherArgs.headers || {};
1090
+ options.otherArgs.headers['x-goog-request-params'] =
1091
+ this._gaxModule.routingHeader.fromParams({
1092
+ parent: request.parent ?? '',
1093
+ collection_id: request.collectionId?.toString() ?? '',
1094
+ });
1095
+ const defaultCallSettings = this._defaults['listDocuments'];
1096
+ const callSettings = defaultCallSettings.merge(options);
1097
+ this.initialize().catch((err) => {
1098
+ throw err;
1099
+ });
1100
+ this._log.info('listDocuments stream %j', request);
1101
+ return this.descriptors.page.listDocuments.createStream(this.innerApiCalls.listDocuments, request, callSettings);
1102
+ }
1103
+ /**
1104
+ * Equivalent to `listDocuments`, but returns an iterable object.
1105
+ *
1106
+ * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
1107
+ * @param {Object} request
1108
+ * The request object that will be sent.
1109
+ * @param {string} request.parent
1110
+ * Required. The parent resource name. In the format:
1111
+ * `projects/{project_id}/databases/{database_id}/documents` or
1112
+ * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
1113
+ *
1114
+ * For example:
1115
+ * `projects/my-project/databases/my-database/documents` or
1116
+ * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
1117
+ * @param {string} [request.collectionId]
1118
+ * Optional. The collection ID, relative to `parent`, to list.
1119
+ *
1120
+ * For example: `chatrooms` or `messages`.
1121
+ *
1122
+ * This is optional, and when not provided, Firestore will list documents
1123
+ * from all collections under the provided `parent`.
1124
+ * @param {number} [request.pageSize]
1125
+ * Optional. The maximum number of documents to return in a single response.
1126
+ *
1127
+ * Firestore may return fewer than this value.
1128
+ * @param {string} [request.pageToken]
1129
+ * Optional. A page token, received from a previous `ListDocuments` response.
1130
+ *
1131
+ * Provide this to retrieve the subsequent page. When paginating, all other
1132
+ * parameters (with the exception of `page_size`) must match the values set
1133
+ * in the request that generated the page token.
1134
+ * @param {string} [request.orderBy]
1135
+ * Optional. The optional ordering of the documents to return.
1136
+ *
1137
+ * For example: `priority desc, __name__ desc`.
1138
+ *
1139
+ * This mirrors the {@link protos.google.firestore.v1.StructuredQuery.order_by|`ORDER BY`}
1140
+ * used in Firestore queries but in a string representation. When absent,
1141
+ * documents are ordered based on `__name__ ASC`.
1142
+ * @param {google.firestore.v1.DocumentMask} [request.mask]
1143
+ * Optional. The fields to return. If not set, returns all fields.
1144
+ *
1145
+ * If a document has a field that is not present in this mask, that field
1146
+ * will not be returned in the response.
1147
+ * @param {Buffer} request.transaction
1148
+ * Perform the read as part of an already active transaction.
1149
+ * @param {google.protobuf.Timestamp} request.readTime
1150
+ * Perform the read at the provided time.
1151
+ *
1152
+ * This must be a microsecond precision timestamp within the past one hour,
1153
+ * or if Point-in-Time Recovery is enabled, can additionally be a whole
1154
+ * minute timestamp within the past 7 days.
1155
+ * @param {boolean} request.showMissing
1156
+ * If the list should show missing documents.
1157
+ *
1158
+ * A document is missing if it does not exist, but there are sub-documents
1159
+ * nested underneath it. When true, such missing documents will be returned
1160
+ * with a key but will not have fields,
1161
+ * {@link protos.google.firestore.v1.Document.create_time|`create_time`}, or
1162
+ * {@link protos.google.firestore.v1.Document.update_time|`update_time`} set.
1163
+ *
1164
+ * Requests with `show_missing` may not specify `where` or `order_by`.
1165
+ * @param {object} [options]
1166
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
1167
+ * @returns {Object}
1168
+ * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }.
1169
+ * When you iterate the returned iterable, each element will be an object representing
1170
+ * {@link protos.google.firestore.v1.Document|Document}. The API will be called under the hood as needed, once per the page,
1171
+ * so you can stop the iteration when you don't need more results.
1172
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
1173
+ * for more details and examples.
1174
+ * @example <caption>include:samples/generated/v1/firestore.list_documents.js</caption>
1175
+ * region_tag:firestore_v1_generated_Firestore_ListDocuments_async
1176
+ */
1177
+ listDocumentsAsync(request, options) {
1178
+ request = request || {};
1179
+ options = options || {};
1180
+ options.otherArgs = options.otherArgs || {};
1181
+ options.otherArgs.headers = options.otherArgs.headers || {};
1182
+ options.otherArgs.headers['x-goog-request-params'] =
1183
+ this._gaxModule.routingHeader.fromParams({
1184
+ parent: request.parent ?? '',
1185
+ collection_id: request.collectionId?.toString() ?? '',
1186
+ });
1187
+ const defaultCallSettings = this._defaults['listDocuments'];
1188
+ const callSettings = defaultCallSettings.merge(options);
1189
+ this.initialize().catch((err) => {
1190
+ throw err;
1191
+ });
1192
+ this._log.info('listDocuments iterate %j', request);
1193
+ return this.descriptors.page.listDocuments.asyncIterate(this.innerApiCalls['listDocuments'], request, callSettings);
1194
+ }
1195
+ partitionQuery(request, optionsOrCallback, callback) {
1196
+ request = request || {};
1197
+ let options;
1198
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
1199
+ callback = optionsOrCallback;
1200
+ options = {};
1201
+ }
1202
+ else {
1203
+ options = optionsOrCallback;
1204
+ }
1205
+ options = options || {};
1206
+ options.otherArgs = options.otherArgs || {};
1207
+ options.otherArgs.headers = options.otherArgs.headers || {};
1208
+ options.otherArgs.headers['x-goog-request-params'] =
1209
+ this._gaxModule.routingHeader.fromParams({
1210
+ parent: request.parent ?? '',
1211
+ });
1212
+ this.initialize().catch((err) => {
1213
+ throw err;
1214
+ });
1215
+ const wrappedCallback = callback
1216
+ ? (error, values, nextPageRequest, rawResponse) => {
1217
+ this._log.info('partitionQuery values %j', values);
1218
+ callback(error, values, nextPageRequest, rawResponse); // We verified callback above.
1219
+ }
1220
+ : undefined;
1221
+ this._log.info('partitionQuery request %j', request);
1222
+ return this.innerApiCalls
1223
+ .partitionQuery(request, options, wrappedCallback)
1224
+ ?.then(([response, input, output]) => {
1225
+ this._log.info('partitionQuery values %j', response);
1226
+ return [response, input, output];
1227
+ });
1228
+ }
1229
+ /**
1230
+ * Equivalent to `partitionQuery`, but returns a NodeJS Stream object.
1231
+ * @param {Object} request
1232
+ * The request object that will be sent.
1233
+ * @param {string} request.parent
1234
+ * Required. The parent resource name. In the format:
1235
+ * `projects/{project_id}/databases/{database_id}/documents`.
1236
+ * Document resource names are not supported; only database resource names
1237
+ * can be specified.
1238
+ * @param {google.firestore.v1.StructuredQuery} request.structuredQuery
1239
+ * A structured query.
1240
+ * Query must specify collection with all descendants and be ordered by name
1241
+ * ascending. Other filters, order bys, limits, offsets, and start/end
1242
+ * cursors are not supported.
1243
+ * @param {number} request.partitionCount
1244
+ * The desired maximum number of partition points.
1245
+ * The partitions may be returned across multiple pages of results.
1246
+ * The number must be positive. The actual number of partitions
1247
+ * returned may be fewer.
1248
+ *
1249
+ * For example, this may be set to one fewer than the number of parallel
1250
+ * queries to be run, or in running a data pipeline job, one fewer than the
1251
+ * number of workers or compute instances available.
1252
+ * @param {string} request.pageToken
1253
+ * The `next_page_token` value returned from a previous call to
1254
+ * PartitionQuery that may be used to get an additional set of results.
1255
+ * There are no ordering guarantees between sets of results. Thus, using
1256
+ * multiple sets of results will require merging the different result sets.
1257
+ *
1258
+ * For example, two subsequent calls using a page_token may return:
1259
+ *
1260
+ * * cursor B, cursor M, cursor Q
1261
+ * * cursor A, cursor U, cursor W
1262
+ *
1263
+ * To obtain a complete result set ordered with respect to the results of the
1264
+ * query supplied to PartitionQuery, the results sets should be merged:
1265
+ * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W
1266
+ * @param {number} request.pageSize
1267
+ * The maximum number of partitions to return in this call, subject to
1268
+ * `partition_count`.
1269
+ *
1270
+ * For example, if `partition_count` = 10 and `page_size` = 8, the first call
1271
+ * to PartitionQuery will return up to 8 partitions and a `next_page_token`
1272
+ * if more results exist. A second call to PartitionQuery will return up to
1273
+ * 2 partitions, to complete the total of 10 specified in `partition_count`.
1274
+ * @param {google.protobuf.Timestamp} request.readTime
1275
+ * Reads documents as they were at the given time.
1276
+ *
1277
+ * This must be a microsecond precision timestamp within the past one hour,
1278
+ * or if Point-in-Time Recovery is enabled, can additionally be a whole
1279
+ * minute timestamp within the past 7 days.
1280
+ * @param {object} [options]
1281
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
1282
+ * @returns {Stream}
1283
+ * An object stream which emits an object representing {@link protos.google.firestore.v1.Cursor|Cursor} on 'data' event.
1284
+ * The client library will perform auto-pagination by default: it will call the API as many
1285
+ * times as needed. Note that it can affect your quota.
1286
+ * We recommend using `partitionQueryAsync()`
1287
+ * method described below for async iteration which you can stop as needed.
1288
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
1289
+ * for more details and examples.
1290
+ */
1291
+ partitionQueryStream(request, options) {
1292
+ request = request || {};
1293
+ options = options || {};
1294
+ options.otherArgs = options.otherArgs || {};
1295
+ options.otherArgs.headers = options.otherArgs.headers || {};
1296
+ options.otherArgs.headers['x-goog-request-params'] =
1297
+ this._gaxModule.routingHeader.fromParams({
1298
+ parent: request.parent ?? '',
1299
+ });
1300
+ const defaultCallSettings = this._defaults['partitionQuery'];
1301
+ const callSettings = defaultCallSettings.merge(options);
1302
+ this.initialize().catch((err) => {
1303
+ throw err;
1304
+ });
1305
+ this._log.info('partitionQuery stream %j', request);
1306
+ return this.descriptors.page.partitionQuery.createStream(this.innerApiCalls.partitionQuery, request, callSettings);
1307
+ }
1308
+ /**
1309
+ * Equivalent to `partitionQuery`, but returns an iterable object.
1310
+ *
1311
+ * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
1312
+ * @param {Object} request
1313
+ * The request object that will be sent.
1314
+ * @param {string} request.parent
1315
+ * Required. The parent resource name. In the format:
1316
+ * `projects/{project_id}/databases/{database_id}/documents`.
1317
+ * Document resource names are not supported; only database resource names
1318
+ * can be specified.
1319
+ * @param {google.firestore.v1.StructuredQuery} request.structuredQuery
1320
+ * A structured query.
1321
+ * Query must specify collection with all descendants and be ordered by name
1322
+ * ascending. Other filters, order bys, limits, offsets, and start/end
1323
+ * cursors are not supported.
1324
+ * @param {number} request.partitionCount
1325
+ * The desired maximum number of partition points.
1326
+ * The partitions may be returned across multiple pages of results.
1327
+ * The number must be positive. The actual number of partitions
1328
+ * returned may be fewer.
1329
+ *
1330
+ * For example, this may be set to one fewer than the number of parallel
1331
+ * queries to be run, or in running a data pipeline job, one fewer than the
1332
+ * number of workers or compute instances available.
1333
+ * @param {string} request.pageToken
1334
+ * The `next_page_token` value returned from a previous call to
1335
+ * PartitionQuery that may be used to get an additional set of results.
1336
+ * There are no ordering guarantees between sets of results. Thus, using
1337
+ * multiple sets of results will require merging the different result sets.
1338
+ *
1339
+ * For example, two subsequent calls using a page_token may return:
1340
+ *
1341
+ * * cursor B, cursor M, cursor Q
1342
+ * * cursor A, cursor U, cursor W
1343
+ *
1344
+ * To obtain a complete result set ordered with respect to the results of the
1345
+ * query supplied to PartitionQuery, the results sets should be merged:
1346
+ * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W
1347
+ * @param {number} request.pageSize
1348
+ * The maximum number of partitions to return in this call, subject to
1349
+ * `partition_count`.
1350
+ *
1351
+ * For example, if `partition_count` = 10 and `page_size` = 8, the first call
1352
+ * to PartitionQuery will return up to 8 partitions and a `next_page_token`
1353
+ * if more results exist. A second call to PartitionQuery will return up to
1354
+ * 2 partitions, to complete the total of 10 specified in `partition_count`.
1355
+ * @param {google.protobuf.Timestamp} request.readTime
1356
+ * Reads documents as they were at the given time.
1357
+ *
1358
+ * This must be a microsecond precision timestamp within the past one hour,
1359
+ * or if Point-in-Time Recovery is enabled, can additionally be a whole
1360
+ * minute timestamp within the past 7 days.
1361
+ * @param {object} [options]
1362
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
1363
+ * @returns {Object}
1364
+ * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }.
1365
+ * When you iterate the returned iterable, each element will be an object representing
1366
+ * {@link protos.google.firestore.v1.Cursor|Cursor}. The API will be called under the hood as needed, once per the page,
1367
+ * so you can stop the iteration when you don't need more results.
1368
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
1369
+ * for more details and examples.
1370
+ * @example <caption>include:samples/generated/v1/firestore.partition_query.js</caption>
1371
+ * region_tag:firestore_v1_generated_Firestore_PartitionQuery_async
1372
+ */
1373
+ partitionQueryAsync(request, options) {
1374
+ request = request || {};
1375
+ options = options || {};
1376
+ options.otherArgs = options.otherArgs || {};
1377
+ options.otherArgs.headers = options.otherArgs.headers || {};
1378
+ options.otherArgs.headers['x-goog-request-params'] =
1379
+ this._gaxModule.routingHeader.fromParams({
1380
+ parent: request.parent ?? '',
1381
+ });
1382
+ const defaultCallSettings = this._defaults['partitionQuery'];
1383
+ const callSettings = defaultCallSettings.merge(options);
1384
+ this.initialize().catch((err) => {
1385
+ throw err;
1386
+ });
1387
+ this._log.info('partitionQuery iterate %j', request);
1388
+ return this.descriptors.page.partitionQuery.asyncIterate(this.innerApiCalls['partitionQuery'], request, callSettings);
1389
+ }
1390
+ listCollectionIds(request, optionsOrCallback, callback) {
1391
+ request = request || {};
1392
+ let options;
1393
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
1394
+ callback = optionsOrCallback;
1395
+ options = {};
1396
+ }
1397
+ else {
1398
+ options = optionsOrCallback;
1399
+ }
1400
+ options = options || {};
1401
+ options.otherArgs = options.otherArgs || {};
1402
+ options.otherArgs.headers = options.otherArgs.headers || {};
1403
+ options.otherArgs.headers['x-goog-request-params'] =
1404
+ this._gaxModule.routingHeader.fromParams({
1405
+ parent: request.parent ?? '',
1406
+ });
1407
+ this.initialize().catch((err) => {
1408
+ throw err;
1409
+ });
1410
+ const wrappedCallback = callback
1411
+ ? (error, values, nextPageRequest, rawResponse) => {
1412
+ this._log.info('listCollectionIds values %j', values);
1413
+ callback(error, values, nextPageRequest, rawResponse); // We verified callback above.
1414
+ }
1415
+ : undefined;
1416
+ this._log.info('listCollectionIds request %j', request);
1417
+ return this.innerApiCalls
1418
+ .listCollectionIds(request, options, wrappedCallback)
1419
+ ?.then(([response, input, output]) => {
1420
+ this._log.info('listCollectionIds values %j', response);
1421
+ return [response, input, output];
1422
+ });
1423
+ }
1424
+ /**
1425
+ * Equivalent to `listCollectionIds`, but returns a NodeJS Stream object.
1426
+ * @param {Object} request
1427
+ * The request object that will be sent.
1428
+ * @param {string} request.parent
1429
+ * Required. The parent document. In the format:
1430
+ * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
1431
+ * For example:
1432
+ * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
1433
+ *
1434
+ * Use `projects/{project_id}/databases/{database_id}/documents` to list
1435
+ * top-level collections.
1436
+ * @param {number} request.pageSize
1437
+ * The maximum number of results to return.
1438
+ * @param {string} request.pageToken
1439
+ * A page token. Must be a value from
1440
+ * {@link protos.google.firestore.v1.ListCollectionIdsResponse|ListCollectionIdsResponse}.
1441
+ * @param {google.protobuf.Timestamp} request.readTime
1442
+ * Reads documents as they were at the given time.
1443
+ *
1444
+ * This must be a microsecond precision timestamp within the past one hour,
1445
+ * or if Point-in-Time Recovery is enabled, can additionally be a whole
1446
+ * minute timestamp within the past 7 days.
1447
+ * @param {object} [options]
1448
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
1449
+ * @returns {Stream}
1450
+ * An object stream which emits an object representing string on 'data' event.
1451
+ * The client library will perform auto-pagination by default: it will call the API as many
1452
+ * times as needed. Note that it can affect your quota.
1453
+ * We recommend using `listCollectionIdsAsync()`
1454
+ * method described below for async iteration which you can stop as needed.
1455
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
1456
+ * for more details and examples.
1457
+ */
1458
+ listCollectionIdsStream(request, options) {
1459
+ request = request || {};
1460
+ options = options || {};
1461
+ options.otherArgs = options.otherArgs || {};
1462
+ options.otherArgs.headers = options.otherArgs.headers || {};
1463
+ options.otherArgs.headers['x-goog-request-params'] =
1464
+ this._gaxModule.routingHeader.fromParams({
1465
+ parent: request.parent ?? '',
1466
+ });
1467
+ const defaultCallSettings = this._defaults['listCollectionIds'];
1468
+ const callSettings = defaultCallSettings.merge(options);
1469
+ this.initialize().catch((err) => {
1470
+ throw err;
1471
+ });
1472
+ this._log.info('listCollectionIds stream %j', request);
1473
+ return this.descriptors.page.listCollectionIds.createStream(this.innerApiCalls.listCollectionIds, request, callSettings);
1474
+ }
1475
+ /**
1476
+ * Equivalent to `listCollectionIds`, but returns an iterable object.
1477
+ *
1478
+ * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
1479
+ * @param {Object} request
1480
+ * The request object that will be sent.
1481
+ * @param {string} request.parent
1482
+ * Required. The parent document. In the format:
1483
+ * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
1484
+ * For example:
1485
+ * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
1486
+ *
1487
+ * Use `projects/{project_id}/databases/{database_id}/documents` to list
1488
+ * top-level collections.
1489
+ * @param {number} request.pageSize
1490
+ * The maximum number of results to return.
1491
+ * @param {string} request.pageToken
1492
+ * A page token. Must be a value from
1493
+ * {@link protos.google.firestore.v1.ListCollectionIdsResponse|ListCollectionIdsResponse}.
1494
+ * @param {google.protobuf.Timestamp} request.readTime
1495
+ * Reads documents as they were at the given time.
1496
+ *
1497
+ * This must be a microsecond precision timestamp within the past one hour,
1498
+ * or if Point-in-Time Recovery is enabled, can additionally be a whole
1499
+ * minute timestamp within the past 7 days.
1500
+ * @param {object} [options]
1501
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
1502
+ * @returns {Object}
1503
+ * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }.
1504
+ * When you iterate the returned iterable, each element will be an object representing
1505
+ * string. The API will be called under the hood as needed, once per the page,
1506
+ * so you can stop the iteration when you don't need more results.
1507
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
1508
+ * for more details and examples.
1509
+ * @example <caption>include:samples/generated/v1/firestore.list_collection_ids.js</caption>
1510
+ * region_tag:firestore_v1_generated_Firestore_ListCollectionIds_async
1511
+ */
1512
+ listCollectionIdsAsync(request, options) {
1513
+ request = request || {};
1514
+ options = options || {};
1515
+ options.otherArgs = options.otherArgs || {};
1516
+ options.otherArgs.headers = options.otherArgs.headers || {};
1517
+ options.otherArgs.headers['x-goog-request-params'] =
1518
+ this._gaxModule.routingHeader.fromParams({
1519
+ parent: request.parent ?? '',
1520
+ });
1521
+ const defaultCallSettings = this._defaults['listCollectionIds'];
1522
+ const callSettings = defaultCallSettings.merge(options);
1523
+ this.initialize().catch((err) => {
1524
+ throw err;
1525
+ });
1526
+ this._log.info('listCollectionIds iterate %j', request);
1527
+ return this.descriptors.page.listCollectionIds.asyncIterate(this.innerApiCalls['listCollectionIds'], request, callSettings);
1528
+ }
1529
+ /**
1530
+ * Gets information about a location.
1531
+ *
1532
+ * @param {Object} request
1533
+ * The request object that will be sent.
1534
+ * @param {string} request.name
1535
+ * Resource name for the location.
1536
+ * @param {object} [options]
1537
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details.
1538
+ * @returns {Promise} - The promise which resolves to an array.
1539
+ * The first element of the array is an object representing {@link google.cloud.location.Location | Location}.
1540
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
1541
+ * for more details and examples.
1542
+ * @example
1543
+ * ```
1544
+ * const [response] = await client.getLocation(request);
1545
+ * ```
1546
+ */
1547
+ getLocation(request, options, callback) {
1548
+ return this.locationsClient.getLocation(request, options, callback);
1549
+ }
1550
+ /**
1551
+ * Lists information about the supported locations for this service. Returns an iterable object.
1552
+ *
1553
+ * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
1554
+ * @param {Object} request
1555
+ * The request object that will be sent.
1556
+ * @param {string} request.name
1557
+ * The resource that owns the locations collection, if applicable.
1558
+ * @param {string} request.filter
1559
+ * The standard list filter.
1560
+ * @param {number} request.pageSize
1561
+ * The standard list page size.
1562
+ * @param {string} request.pageToken
1563
+ * The standard list page token.
1564
+ * @param {object} [options]
1565
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
1566
+ * @returns {Object}
1567
+ * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }.
1568
+ * When you iterate the returned iterable, each element will be an object representing
1569
+ * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page,
1570
+ * so you can stop the iteration when you don't need more results.
1571
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
1572
+ * for more details and examples.
1573
+ * @example
1574
+ * ```
1575
+ * const iterable = client.listLocationsAsync(request);
1576
+ * for await (const response of iterable) {
1577
+ * // process response
1578
+ * }
1579
+ * ```
1580
+ */
1581
+ listLocationsAsync(request, options) {
1582
+ return this.locationsClient.listLocationsAsync(request, options);
1583
+ }
1584
+ /**
1585
+ * Terminate the gRPC channel and close the client.
1586
+ *
1587
+ * The client will no longer be usable and all future behavior is undefined.
1588
+ * @returns {Promise} A promise that resolves when the client is closed.
1589
+ */
1590
+ close() {
1591
+ if (this.firestoreStub && !this._terminated) {
1592
+ return this.firestoreStub.then((stub) => {
1593
+ this._log.info('ending gRPC channel');
1594
+ this._terminated = true;
1595
+ stub.close();
1596
+ this.locationsClient.close().catch((err) => {
1597
+ throw err;
1598
+ });
1599
+ });
1600
+ }
1601
+ return Promise.resolve();
1602
+ }
1603
+ }
1604
+ exports.FirestoreClient = FirestoreClient;
1605
+ //# sourceMappingURL=firestore_client.js.map