@@ -31,6 +31,7 @@ import type {
31
31
import { Transform , PassThrough } from 'stream' ;
32
32
import * as protos from '../../protos/firestore_v1_proto_api' ;
33
33
import jsonProtos = require( '../../protos/v1.json' ) ;
34
+
34
35
/**
35
36
* Client JSON configuration object, loaded from
36
37
* `src/v1/firestore_client_config.json`.
@@ -59,6 +60,8 @@ export class FirestoreClient {
59
60
private _gaxGrpc : gax . GrpcClient | gax . fallback . GrpcClient ;
60
61
private _protos : { } ;
61
62
private _defaults : { [ method : string ] : gax . CallSettings } ;
63
+ private _universeDomain : string ;
64
+ private _servicePath : string ;
62
65
auth : gax . GoogleAuth ;
63
66
descriptors : Descriptors = {
64
67
page : { } ,
@@ -116,8 +119,20 @@ export class FirestoreClient {
116
119
) {
117
120
// Ensure that options include all the required fields.
118
121
const staticMembers = this . constructor as typeof FirestoreClient ;
122
+ if (
123
+ opts ?. universe_domain &&
124
+ opts ?. universeDomain &&
125
+ opts ?. universe_domain !== opts ?. universeDomain
126
+ ) {
127
+ throw new Error (
128
+ 'Please set either universe_domain or universeDomain, but not both.'
129
+ ) ;
130
+ }
131
+ this . _universeDomain =
132
+ opts ?. universeDomain ?? opts ?. universe_domain ?? 'googleapis.com' ;
133
+ this . _servicePath = 'firestore.' + this . _universeDomain ;
119
134
const servicePath =
120
- opts ?. servicePath || opts ?. apiEndpoint || staticMembers . servicePath ;
135
+ opts ?. servicePath || opts ?. apiEndpoint || this . _servicePath ;
121
136
this . _providedCustomServicePath = ! ! (
122
137
opts ?. servicePath || opts ?. apiEndpoint
123
138
) ;
@@ -132,7 +147,7 @@ export class FirestoreClient {
132
147
opts . numericEnums = true ;
133
148
134
149
// If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
135
- if ( servicePath !== staticMembers . servicePath && ! ( 'scopes' in opts ) ) {
150
+ if ( servicePath !== this . _servicePath && ! ( 'scopes' in opts ) ) {
136
151
opts [ 'scopes' ] = staticMembers . scopes ;
137
152
}
138
153
@@ -157,10 +172,10 @@ export class FirestoreClient {
157
172
this . auth . useJWTAccessWithScope = true ;
158
173
159
174
// Set defaultServicePath on the auth object.
160
- this . auth . defaultServicePath = staticMembers . servicePath ;
175
+ this . auth . defaultServicePath = this . _servicePath ;
161
176
162
177
// Set the default scopes in auth client if needed.
163
- if ( servicePath === staticMembers . servicePath ) {
178
+ if ( servicePath === this . _servicePath ) {
164
179
this . auth . defaultScopes = staticMembers . scopes ;
165
180
}
166
181
this . locationsClient = new this . _gaxModule . LocationsClient (
@@ -213,27 +228,27 @@ export class FirestoreClient {
213
228
batchGetDocuments : new this . _gaxModule . StreamDescriptor (
214
229
this . _gaxModule . StreamType . SERVER_STREAMING ,
215
230
! ! opts . fallback ,
216
- /* gaxStreamingRetries: */ true
231
+ /* gaxStreamingRetries: */ false
217
232
) ,
218
233
runQuery : new this . _gaxModule . StreamDescriptor (
219
234
this . _gaxModule . StreamType . SERVER_STREAMING ,
220
235
! ! opts . fallback ,
221
- /* gaxStreamingRetries: */ true
236
+ /* gaxStreamingRetries: */ false
222
237
) ,
223
238
runAggregationQuery : new this . _gaxModule . StreamDescriptor (
224
239
this . _gaxModule . StreamType . SERVER_STREAMING ,
225
240
! ! opts . fallback ,
226
- /* gaxStreamingRetries: */ true
241
+ /* gaxStreamingRetries: */ false
227
242
) ,
228
243
write : new this . _gaxModule . StreamDescriptor (
229
244
this . _gaxModule . StreamType . BIDI_STREAMING ,
230
245
! ! opts . fallback ,
231
- /* gaxStreamingRetries: */ true
246
+ /* gaxStreamingRetries: */ false
232
247
) ,
233
248
listen : new this . _gaxModule . StreamDescriptor (
234
249
this . _gaxModule . StreamType . BIDI_STREAMING ,
235
250
! ! opts . fallback ,
236
- /* gaxStreamingRetries: */ true
251
+ /* gaxStreamingRetries: */ false
237
252
) ,
238
253
} ;
239
254
@@ -350,21 +365,52 @@ export class FirestoreClient {
350
365
351
366
/**
352
367
* The DNS address for this API service.
368
+ * @deprecated Use the apiEndpoint method of the client instance.
353
369
* @returns {string } The DNS address for this service.
354
370
*/
355
371
static get servicePath ( ) {
372
+ if (
373
+ typeof process !== undefined &&
374
+ typeof process . emitWarning === 'function'
375
+ ) {
376
+ process . emitWarning (
377
+ 'Static servicePath is deprecated, please use the instance method instead.' ,
378
+ 'DeprecationWarning'
379
+ ) ;
380
+ }
356
381
return 'firestore.googleapis.com' ;
357
382
}
358
383
359
384
/**
360
- * The DNS address for this API service - same as servicePath(),
361
- * exists for compatibility reasons .
385
+ * The DNS address for this API service - same as servicePath.
386
+ * @deprecated Use the apiEndpoint method of the client instance .
362
387
* @returns {string } The DNS address for this service.
363
388
*/
364
389
static get apiEndpoint ( ) {
390
+ if (
391
+ typeof process !== undefined &&
392
+ typeof process . emitWarning === 'function'
393
+ ) {
394
+ process . emitWarning (
395
+ 'Static apiEndpoint is deprecated, please use the instance method instead.' ,
396
+ 'DeprecationWarning'
397
+ ) ;
398
+ }
365
399
return 'firestore.googleapis.com' ;
366
400
}
367
401
402
+ /**
403
+ * The DNS address for this API service.
404
+ * @returns {string } The DNS address for this service.
405
+ */
406
+ get apiEndpoint ( ) {
407
+ return this . _servicePath ;
408
+ }
409
+
410
+ get universeDomain ( ) {
411
+ return this . _universeDomain ;
412
+ }
413
+
368
414
/**
369
415
* The port for this API service.
370
416
* @returns {number } The default port for this service.
0 commit comments