@firebase/firestore 3.3.1-canary.cb7299cbf → 3.3.1-canary.dc6b447ba
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.
- package/dist/firestore/src/api/credentials.d.ts +64 -30
- package/dist/firestore/src/api/database.d.ts +2 -1
- package/dist/firestore/src/api.d.ts +2 -1
- package/dist/firestore/src/core/component_provider.d.ts +2 -1
- package/dist/firestore/src/core/firestore_client.d.ts +4 -3
- package/dist/firestore/src/lite-api/components.d.ts +3 -1
- package/dist/firestore/src/lite-api/database.d.ts +4 -2
- package/dist/firestore/src/platform/browser/webchannel_connection.d.ts +1 -1
- package/dist/firestore/src/platform/node/grpc_connection.d.ts +3 -3
- package/dist/firestore/src/remote/connection.d.ts +3 -3
- package/dist/firestore/src/remote/datastore.d.ts +2 -1
- package/dist/firestore/src/remote/persistent_stream.d.ts +9 -7
- package/dist/firestore/src/remote/rest_connection.d.ts +4 -4
- package/dist/firestore/test/integration/remote/stream.test.d.ts +2 -2
- package/dist/firestore/test/integration/util/internal_helpers.d.ts +5 -5
- package/dist/firestore/test/unit/remote/rest_connection.test.d.ts +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.esm2017.js +3413 -3359
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +3688 -3639
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +188 -95
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +187 -95
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +3408 -3354
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +34 -20
- package/dist/lite/firestore/src/api/credentials.d.ts +64 -30
- package/dist/lite/firestore/src/api/database.d.ts +2 -1
- package/dist/lite/firestore/src/api.d.ts +2 -1
- package/dist/lite/firestore/src/core/component_provider.d.ts +2 -1
- package/dist/lite/firestore/src/core/firestore_client.d.ts +4 -3
- package/dist/lite/firestore/src/lite-api/components.d.ts +3 -1
- package/dist/lite/firestore/src/lite-api/database.d.ts +4 -2
- package/dist/lite/firestore/src/platform/browser/webchannel_connection.d.ts +1 -1
- package/dist/lite/firestore/src/platform/node/grpc_connection.d.ts +3 -3
- package/dist/lite/firestore/src/remote/connection.d.ts +3 -3
- package/dist/lite/firestore/src/remote/datastore.d.ts +2 -1
- package/dist/lite/firestore/src/remote/persistent_stream.d.ts +9 -7
- package/dist/lite/firestore/src/remote/rest_connection.d.ts +4 -4
- package/dist/lite/firestore/test/integration/remote/stream.test.d.ts +2 -2
- package/dist/lite/firestore/test/integration/util/internal_helpers.d.ts +5 -5
- package/dist/lite/firestore/test/unit/remote/rest_connection.test.d.ts +1 -1
- package/dist/lite/index.browser.esm2017.js +860 -846
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +934 -925
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.node.cjs.js +95 -60
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +95 -60
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +924 -910
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +14 -13
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +126 -125
- package/dist/lite/packages/firestore/src/api/credentials.d.ts +64 -30
- package/dist/lite/packages/firestore/src/api/database.d.ts +2 -1
- package/dist/lite/packages/firestore/src/api.d.ts +2 -1
- package/dist/lite/packages/firestore/src/core/component_provider.d.ts +2 -1
- package/dist/lite/packages/firestore/src/core/firestore_client.d.ts +4 -3
- package/dist/lite/packages/firestore/src/lite-api/components.d.ts +3 -1
- package/dist/lite/packages/firestore/src/lite-api/database.d.ts +4 -2
- package/dist/lite/packages/firestore/src/platform/browser/webchannel_connection.d.ts +1 -1
- package/dist/lite/packages/firestore/src/platform/node/grpc_connection.d.ts +3 -3
- package/dist/lite/packages/firestore/src/remote/connection.d.ts +3 -3
- package/dist/lite/packages/firestore/src/remote/datastore.d.ts +2 -1
- package/dist/lite/packages/firestore/src/remote/persistent_stream.d.ts +9 -7
- package/dist/lite/packages/firestore/src/remote/rest_connection.d.ts +4 -4
- package/dist/lite/packages/firestore/test/integration/remote/stream.test.d.ts +2 -2
- package/dist/lite/packages/firestore/test/integration/util/internal_helpers.d.ts +5 -5
- package/dist/lite/packages/firestore/test/unit/remote/rest_connection.test.d.ts +1 -1
- package/dist/lite/private.d.ts +14 -13
- package/dist/packages/firestore/dist/index.esm2017.d.ts +211 -195
- package/dist/packages/firestore/src/api/credentials.d.ts +64 -30
- package/dist/packages/firestore/src/api/database.d.ts +2 -1
- package/dist/packages/firestore/src/api.d.ts +2 -1
- package/dist/packages/firestore/src/core/component_provider.d.ts +2 -1
- package/dist/packages/firestore/src/core/firestore_client.d.ts +4 -3
- package/dist/packages/firestore/src/lite-api/components.d.ts +3 -1
- package/dist/packages/firestore/src/lite-api/database.d.ts +4 -2
- package/dist/packages/firestore/src/platform/browser/webchannel_connection.d.ts +1 -1
- package/dist/packages/firestore/src/platform/node/grpc_connection.d.ts +3 -3
- package/dist/packages/firestore/src/remote/connection.d.ts +3 -3
- package/dist/packages/firestore/src/remote/datastore.d.ts +2 -1
- package/dist/packages/firestore/src/remote/persistent_stream.d.ts +9 -7
- package/dist/packages/firestore/src/remote/rest_connection.d.ts +4 -4
- package/dist/packages/firestore/test/integration/remote/stream.test.d.ts +2 -2
- package/dist/packages/firestore/test/integration/util/internal_helpers.d.ts +5 -5
- package/dist/packages/firestore/test/unit/remote/rest_connection.test.d.ts +1 -1
- package/dist/private.d.ts +24 -19
- package/package.json +9 -9
|
@@ -63,7 +63,7 @@ h.MOCK_USER = new h("mock-user");
|
|
|
63
63
|
* See the License for the specific language governing permissions and
|
|
64
64
|
* limitations under the License.
|
|
65
65
|
*/
|
|
66
|
-
let l = "9.5.0-canary.
|
|
66
|
+
let l = "9.5.0-canary.dc6b447ba";
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* @license
|
|
@@ -279,18 +279,16 @@ n) {
|
|
|
279
279
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
280
280
|
* See the License for the specific language governing permissions and
|
|
281
281
|
* limitations under the License.
|
|
282
|
-
*/ class
|
|
282
|
+
*/ class k {
|
|
283
283
|
constructor(t, n) {
|
|
284
|
-
this.user = n, this.type = "OAuth", this.
|
|
285
|
-
// Set the headers using Object Literal notation to avoid minification
|
|
286
|
-
this.authHeaders.Authorization = `Bearer ${t}`;
|
|
284
|
+
this.user = n, this.type = "OAuth", this.headers = new Map, this.headers.set("Authorization", `Bearer ${t}`);
|
|
287
285
|
}
|
|
288
286
|
}
|
|
289
287
|
|
|
290
288
|
/**
|
|
291
289
|
* A CredentialsProvider that always yields an empty token.
|
|
292
290
|
* @internal
|
|
293
|
-
*/ class
|
|
291
|
+
*/ class j {
|
|
294
292
|
getToken() {
|
|
295
293
|
return Promise.resolve(null);
|
|
296
294
|
}
|
|
@@ -305,7 +303,7 @@ n) {
|
|
|
305
303
|
/**
|
|
306
304
|
* A CredentialsProvider that always returns a constant token. Used for
|
|
307
305
|
* emulator token mocking.
|
|
308
|
-
*/ class
|
|
306
|
+
*/ class M {
|
|
309
307
|
constructor(t) {
|
|
310
308
|
this.token = t,
|
|
311
309
|
/**
|
|
@@ -329,7 +327,7 @@ n) {
|
|
|
329
327
|
}
|
|
330
328
|
}
|
|
331
329
|
|
|
332
|
-
/** Credential provider for the Lite SDK. */ class
|
|
330
|
+
/** Credential provider for the Lite SDK. */ class B {
|
|
333
331
|
constructor(t) {
|
|
334
332
|
this.auth = null, t.onInit((t => {
|
|
335
333
|
this.auth = t;
|
|
@@ -337,7 +335,7 @@ n) {
|
|
|
337
335
|
}
|
|
338
336
|
getToken() {
|
|
339
337
|
return this.auth ? this.auth.getToken().then((t => t ? (g("string" == typeof t.accessToken),
|
|
340
|
-
new
|
|
338
|
+
new k(t.accessToken, new h(this.auth.getUid()))) : null)) : Promise.resolve(null);
|
|
341
339
|
}
|
|
342
340
|
invalidateToken() {}
|
|
343
341
|
start(t, n) {}
|
|
@@ -350,17 +348,11 @@ n) {
|
|
|
350
348
|
* Technically this may no longer be necessary since the SDK should gracefully
|
|
351
349
|
* recover from unauthenticated errors (see b/33147818 for context), but it's
|
|
352
350
|
* safer to keep the implementation as-is.
|
|
353
|
-
*/ class
|
|
351
|
+
*/ class z {
|
|
354
352
|
constructor(t, n, e) {
|
|
355
|
-
this.
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
const t = {
|
|
359
|
-
"X-Goog-AuthUser": this.i
|
|
360
|
-
}, n = this.t.auth.getAuthHeaderValueForFirstParty([]);
|
|
361
|
-
// Use array notation to prevent minification
|
|
362
|
-
return n && (t.Authorization = n), this.o && (t["X-Goog-Iam-Authorization-Token"] = this.o),
|
|
363
|
-
t;
|
|
353
|
+
this.type = "FirstParty", this.user = h.FIRST_PARTY, this.headers = new Map, this.headers.set("X-Goog-AuthUser", n);
|
|
354
|
+
const r = t.auth.getAuthHeaderValueForFirstParty([]);
|
|
355
|
+
r && this.headers.set("Authorization", r), e && this.headers.set("X-Goog-Iam-Authorization-Token", e);
|
|
364
356
|
}
|
|
365
357
|
}
|
|
366
358
|
|
|
@@ -368,12 +360,12 @@ n) {
|
|
|
368
360
|
* Provides user credentials required for the Firestore JavaScript SDK
|
|
369
361
|
* to authenticate the user, using technique that is only available
|
|
370
362
|
* to applications hosted by Google.
|
|
371
|
-
*/ class
|
|
363
|
+
*/ class G {
|
|
372
364
|
constructor(t, n, e) {
|
|
373
365
|
this.t = t, this.i = n, this.o = e;
|
|
374
366
|
}
|
|
375
367
|
getToken() {
|
|
376
|
-
return Promise.resolve(new
|
|
368
|
+
return Promise.resolve(new z(this.t, this.i, this.o));
|
|
377
369
|
}
|
|
378
370
|
start(t, n) {
|
|
379
371
|
// Fire with initial uid.
|
|
@@ -383,6 +375,27 @@ n) {
|
|
|
383
375
|
invalidateToken() {}
|
|
384
376
|
}
|
|
385
377
|
|
|
378
|
+
class Q {
|
|
379
|
+
constructor(t) {
|
|
380
|
+
this.value = t, this.type = "AppCheck", this.headers = new Map, t && t.length > 0 && this.headers.set("x-firebase-appcheck", this.value);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/** AppCheck token provider for the Lite SDK. */ class W {
|
|
385
|
+
constructor(t) {
|
|
386
|
+
this.u = t, this.appCheck = null, t.onInit((t => {
|
|
387
|
+
this.appCheck = t;
|
|
388
|
+
}));
|
|
389
|
+
}
|
|
390
|
+
getToken() {
|
|
391
|
+
return this.appCheck ? this.appCheck.getToken().then((t => t ? (g("string" == typeof t.token),
|
|
392
|
+
new Q(t.token)) : null)) : Promise.resolve(null);
|
|
393
|
+
}
|
|
394
|
+
invalidateToken() {}
|
|
395
|
+
start(t, n) {}
|
|
396
|
+
shutdown() {}
|
|
397
|
+
}
|
|
398
|
+
|
|
386
399
|
/**
|
|
387
400
|
* Builds a CredentialsProvider depending on the type of
|
|
388
401
|
* the credentials passed in.
|
|
@@ -403,7 +416,7 @@ n) {
|
|
|
403
416
|
* See the License for the specific language governing permissions and
|
|
404
417
|
* limitations under the License.
|
|
405
418
|
*/
|
|
406
|
-
class
|
|
419
|
+
class Y {
|
|
407
420
|
/**
|
|
408
421
|
* Constructs a DatabaseInfo using the provided host, databaseId and
|
|
409
422
|
* persistenceKey.
|
|
@@ -432,7 +445,7 @@ class G {
|
|
|
432
445
|
* Represents the database ID a Firestore client is associated with.
|
|
433
446
|
* @internal
|
|
434
447
|
*/
|
|
435
|
-
class
|
|
448
|
+
class H {
|
|
436
449
|
constructor(t, n) {
|
|
437
450
|
this.projectId = t, this.database = n || "(default)";
|
|
438
451
|
}
|
|
@@ -440,7 +453,7 @@ class W {
|
|
|
440
453
|
return "(default)" === this.database;
|
|
441
454
|
}
|
|
442
455
|
isEqual(t) {
|
|
443
|
-
return t instanceof
|
|
456
|
+
return t instanceof H && t.projectId === this.projectId && t.database === this.database;
|
|
444
457
|
}
|
|
445
458
|
}
|
|
446
459
|
|
|
@@ -463,7 +476,7 @@ class W {
|
|
|
463
476
|
/**
|
|
464
477
|
* Path represents an ordered sequence of string segments.
|
|
465
478
|
*/
|
|
466
|
-
class
|
|
479
|
+
class K {
|
|
467
480
|
constructor(t, n, e) {
|
|
468
481
|
void 0 === n ? n = 0 : n > t.length && _(), void 0 === e ? e = t.length - n : e > t.length - n && _(),
|
|
469
482
|
this.segments = t, this.offset = n, this.len = e;
|
|
@@ -472,11 +485,11 @@ class H {
|
|
|
472
485
|
return this.len;
|
|
473
486
|
}
|
|
474
487
|
isEqual(t) {
|
|
475
|
-
return 0 ===
|
|
488
|
+
return 0 === K.comparator(this, t);
|
|
476
489
|
}
|
|
477
490
|
child(t) {
|
|
478
491
|
const n = this.segments.slice(this.offset, this.limit());
|
|
479
|
-
return t instanceof
|
|
492
|
+
return t instanceof K ? t.forEach((t => {
|
|
480
493
|
n.push(t);
|
|
481
494
|
})) : n.push(t), this.construct(n);
|
|
482
495
|
}
|
|
@@ -533,9 +546,9 @@ class H {
|
|
|
533
546
|
* within Firestore.
|
|
534
547
|
*
|
|
535
548
|
* @internal
|
|
536
|
-
*/ class
|
|
549
|
+
*/ class J extends K {
|
|
537
550
|
construct(t, n, e) {
|
|
538
|
-
return new
|
|
551
|
+
return new J(t, n, e);
|
|
539
552
|
}
|
|
540
553
|
canonicalString() {
|
|
541
554
|
// NOTE: The client is ignorant of any path segments containing escape
|
|
@@ -560,31 +573,31 @@ class H {
|
|
|
560
573
|
// Strip leading and traling slashed.
|
|
561
574
|
n.push(...e.split("/").filter((t => t.length > 0)));
|
|
562
575
|
}
|
|
563
|
-
return new
|
|
576
|
+
return new J(n);
|
|
564
577
|
}
|
|
565
578
|
static emptyPath() {
|
|
566
|
-
return new
|
|
579
|
+
return new J([]);
|
|
567
580
|
}
|
|
568
581
|
}
|
|
569
582
|
|
|
570
|
-
const
|
|
583
|
+
const X = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
571
584
|
|
|
572
585
|
/**
|
|
573
586
|
* A dot-separated path for navigating sub-objects within a document.
|
|
574
587
|
* @internal
|
|
575
|
-
*/ class
|
|
588
|
+
*/ class Z extends K {
|
|
576
589
|
construct(t, n, e) {
|
|
577
|
-
return new
|
|
590
|
+
return new Z(t, n, e);
|
|
578
591
|
}
|
|
579
592
|
/**
|
|
580
593
|
* Returns true if the string could be used as a segment in a field path
|
|
581
594
|
* without escaping.
|
|
582
595
|
*/ static isValidIdentifier(t) {
|
|
583
|
-
return
|
|
596
|
+
return X.test(t);
|
|
584
597
|
}
|
|
585
598
|
canonicalString() {
|
|
586
599
|
return this.toArray().map((t => (t = t.replace(/\\/g, "\\\\").replace(/`/g, "\\`"),
|
|
587
|
-
|
|
600
|
+
Z.isValidIdentifier(t) || (t = "`" + t + "`"), t))).join(".");
|
|
588
601
|
}
|
|
589
602
|
toString() {
|
|
590
603
|
return this.canonicalString();
|
|
@@ -597,7 +610,7 @@ const K = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
597
610
|
/**
|
|
598
611
|
* The field designating the key of a document.
|
|
599
612
|
*/ static keyField() {
|
|
600
|
-
return new
|
|
613
|
+
return new Z([ "__name__" ]);
|
|
601
614
|
}
|
|
602
615
|
/**
|
|
603
616
|
* Parses a field string from the given server-formatted string.
|
|
@@ -626,10 +639,10 @@ const K = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
626
639
|
} else "`" === n ? (i = !i, r++) : "." !== n || i ? (e += n, r++) : (s(), r++);
|
|
627
640
|
}
|
|
628
641
|
if (s(), i) throw new L(I, "Unterminated ` in path: " + t);
|
|
629
|
-
return new
|
|
642
|
+
return new Z(n);
|
|
630
643
|
}
|
|
631
644
|
static emptyPath() {
|
|
632
|
-
return new
|
|
645
|
+
return new Z([]);
|
|
633
646
|
}
|
|
634
647
|
}
|
|
635
648
|
|
|
@@ -651,27 +664,27 @@ const K = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
651
664
|
*/
|
|
652
665
|
/**
|
|
653
666
|
* @internal
|
|
654
|
-
*/ class
|
|
667
|
+
*/ class tt {
|
|
655
668
|
constructor(t) {
|
|
656
669
|
this.path = t;
|
|
657
670
|
}
|
|
658
671
|
static fromPath(t) {
|
|
659
|
-
return new
|
|
672
|
+
return new tt(J.fromString(t));
|
|
660
673
|
}
|
|
661
674
|
static fromName(t) {
|
|
662
|
-
return new
|
|
675
|
+
return new tt(J.fromString(t).popFirst(5));
|
|
663
676
|
}
|
|
664
677
|
/** Returns true if the document is in the specified collectionId. */ hasCollectionId(t) {
|
|
665
678
|
return this.path.length >= 2 && this.path.get(this.path.length - 2) === t;
|
|
666
679
|
}
|
|
667
680
|
isEqual(t) {
|
|
668
|
-
return null !== t && 0 ===
|
|
681
|
+
return null !== t && 0 === J.comparator(this.path, t.path);
|
|
669
682
|
}
|
|
670
683
|
toString() {
|
|
671
684
|
return this.path.toString();
|
|
672
685
|
}
|
|
673
686
|
static comparator(t, n) {
|
|
674
|
-
return
|
|
687
|
+
return J.comparator(t.path, n.path);
|
|
675
688
|
}
|
|
676
689
|
static isDocumentKey(t) {
|
|
677
690
|
return t.length % 2 == 0;
|
|
@@ -682,7 +695,7 @@ const K = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
682
695
|
* @param segments - The segments of the path to the document
|
|
683
696
|
* @returns A new instance of DocumentKey
|
|
684
697
|
*/ static fromSegments(t) {
|
|
685
|
-
return new
|
|
698
|
+
return new tt(new J(t.slice()));
|
|
686
699
|
}
|
|
687
700
|
}
|
|
688
701
|
|
|
@@ -701,7 +714,7 @@ const K = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
701
714
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
702
715
|
* See the License for the specific language governing permissions and
|
|
703
716
|
* limitations under the License.
|
|
704
|
-
*/ function
|
|
717
|
+
*/ function nt(t, n, e) {
|
|
705
718
|
if (!e) throw new L(I, `Function ${t}() cannot be called with an empty ${n}.`);
|
|
706
719
|
}
|
|
707
720
|
|
|
@@ -713,15 +726,15 @@ const K = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
713
726
|
* Validates that `path` refers to a document (indicated by the fact it contains
|
|
714
727
|
* an even numbers of segments).
|
|
715
728
|
*/
|
|
716
|
-
function
|
|
717
|
-
if (!
|
|
729
|
+
function et(t) {
|
|
730
|
+
if (!tt.isDocumentKey(t)) throw new L(I, `Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`);
|
|
718
731
|
}
|
|
719
732
|
|
|
720
733
|
/**
|
|
721
734
|
* Validates that `path` refers to a collection (indicated by the fact it
|
|
722
735
|
* contains an odd numbers of segments).
|
|
723
|
-
*/ function
|
|
724
|
-
if (
|
|
736
|
+
*/ function rt(t) {
|
|
737
|
+
if (tt.isDocumentKey(t)) throw new L(I, `Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`);
|
|
725
738
|
}
|
|
726
739
|
|
|
727
740
|
/**
|
|
@@ -729,7 +742,7 @@ function tt(t) {
|
|
|
729
742
|
* (i.e. excludes Array, Date, etc.).
|
|
730
743
|
*/
|
|
731
744
|
/** Returns a string describing the type / value of the provided input. */
|
|
732
|
-
function
|
|
745
|
+
function st(t) {
|
|
733
746
|
if (void 0 === t) return "undefined";
|
|
734
747
|
if (null === t) return "null";
|
|
735
748
|
if ("string" == typeof t) return t.length > 20 && (t = `${t.substring(0, 20)}...`),
|
|
@@ -758,7 +771,7 @@ function et(t) {
|
|
|
758
771
|
return "function" == typeof t ? "a function" : _();
|
|
759
772
|
}
|
|
760
773
|
|
|
761
|
-
function
|
|
774
|
+
function it(t,
|
|
762
775
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
763
776
|
n) {
|
|
764
777
|
if ("_delegate" in t && (
|
|
@@ -767,14 +780,14 @@ n) {
|
|
|
767
780
|
t = t._delegate), !(t instanceof n)) {
|
|
768
781
|
if (n.name === t.constructor.name) throw new L(I, "Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");
|
|
769
782
|
{
|
|
770
|
-
const e =
|
|
783
|
+
const e = st(t);
|
|
771
784
|
throw new L(I, `Expected type '${n.name}', but it was: ${e}`);
|
|
772
785
|
}
|
|
773
786
|
}
|
|
774
787
|
return t;
|
|
775
788
|
}
|
|
776
789
|
|
|
777
|
-
function
|
|
790
|
+
function ot(t, n) {
|
|
778
791
|
if (n <= 0) throw new L(I, `Function ${t}() requires a positive number, but it was: ${n}.`);
|
|
779
792
|
}
|
|
780
793
|
|
|
@@ -796,11 +809,11 @@ function st(t, n) {
|
|
|
796
809
|
*/
|
|
797
810
|
/**
|
|
798
811
|
* Returns whether a variable is either undefined or null.
|
|
799
|
-
*/ function
|
|
812
|
+
*/ function ut(t) {
|
|
800
813
|
return null == t;
|
|
801
814
|
}
|
|
802
815
|
|
|
803
|
-
/** Returns whether the value represents -0. */ function
|
|
816
|
+
/** Returns whether the value represents -0. */ function ct(t) {
|
|
804
817
|
// Detect if the value is -0.0. Based on polyfill from
|
|
805
818
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
806
819
|
return 0 === t && 1 / t == -1 / 0;
|
|
@@ -826,7 +839,7 @@ function st(t, n) {
|
|
|
826
839
|
* See the License for the specific language governing permissions and
|
|
827
840
|
* limitations under the License.
|
|
828
841
|
*/
|
|
829
|
-
const
|
|
842
|
+
const at = {
|
|
830
843
|
BatchGetDocuments: "batchGet",
|
|
831
844
|
Commit: "commit",
|
|
832
845
|
RunQuery: "runQuery"
|
|
@@ -863,7 +876,7 @@ const ut = {
|
|
|
863
876
|
* are used for reverse lookups from the webchannel stream. Do NOT change the
|
|
864
877
|
* names of these identifiers or change this into a const enum.
|
|
865
878
|
*/
|
|
866
|
-
var
|
|
879
|
+
var ht, lt;
|
|
867
880
|
|
|
868
881
|
/**
|
|
869
882
|
* Converts an HTTP Status Code to the equivalent error code.
|
|
@@ -872,7 +885,7 @@ var ct, at;
|
|
|
872
885
|
* @returns The equivalent Code. Unknown status codes are mapped to
|
|
873
886
|
* Code.UNKNOWN.
|
|
874
887
|
*/
|
|
875
|
-
function
|
|
888
|
+
function ft(t) {
|
|
876
889
|
if (void 0 === t) return m("RPC_ERROR", "HTTP error has no status"), T;
|
|
877
890
|
// The canonical error codes for Google APIs [1] specify mapping onto HTTP
|
|
878
891
|
// status codes but the mapping is not bijective. In each case of ambiguity
|
|
@@ -965,16 +978,16 @@ function ht(t) {
|
|
|
965
978
|
/**
|
|
966
979
|
* A Rest-based connection that relies on the native HTTP stack
|
|
967
980
|
* (e.g. `fetch` or a polyfill).
|
|
968
|
-
*/ (
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
981
|
+
*/ (lt = ht || (ht = {}))[lt.OK = 0] = "OK", lt[lt.CANCELLED = 1] = "CANCELLED",
|
|
982
|
+
lt[lt.UNKNOWN = 2] = "UNKNOWN", lt[lt.INVALID_ARGUMENT = 3] = "INVALID_ARGUMENT",
|
|
983
|
+
lt[lt.DEADLINE_EXCEEDED = 4] = "DEADLINE_EXCEEDED", lt[lt.NOT_FOUND = 5] = "NOT_FOUND",
|
|
984
|
+
lt[lt.ALREADY_EXISTS = 6] = "ALREADY_EXISTS", lt[lt.PERMISSION_DENIED = 7] = "PERMISSION_DENIED",
|
|
985
|
+
lt[lt.UNAUTHENTICATED = 16] = "UNAUTHENTICATED", lt[lt.RESOURCE_EXHAUSTED = 8] = "RESOURCE_EXHAUSTED",
|
|
986
|
+
lt[lt.FAILED_PRECONDITION = 9] = "FAILED_PRECONDITION", lt[lt.ABORTED = 10] = "ABORTED",
|
|
987
|
+
lt[lt.OUT_OF_RANGE = 11] = "OUT_OF_RANGE", lt[lt.UNIMPLEMENTED = 12] = "UNIMPLEMENTED",
|
|
988
|
+
lt[lt.INTERNAL = 13] = "INTERNAL", lt[lt.UNAVAILABLE = 14] = "UNAVAILABLE", lt[lt.DATA_LOSS = 15] = "DATA_LOSS";
|
|
976
989
|
|
|
977
|
-
class
|
|
990
|
+
class dt extends
|
|
978
991
|
/**
|
|
979
992
|
* Base class for all Rest-based connections to the backend (WebChannel and
|
|
980
993
|
* HTTP).
|
|
@@ -983,38 +996,38 @@ class {
|
|
|
983
996
|
constructor(t) {
|
|
984
997
|
this.databaseInfo = t, this.databaseId = t.databaseId;
|
|
985
998
|
const n = t.ssl ? "https" : "http";
|
|
986
|
-
this.
|
|
999
|
+
this.h = n + "://" + t.host, this.l = "projects/" + this.databaseId.projectId + "/databases/" + this.databaseId.database + "/documents";
|
|
987
1000
|
}
|
|
988
|
-
|
|
989
|
-
const
|
|
990
|
-
w("RestConnection", "Sending: ",
|
|
991
|
-
const
|
|
992
|
-
return this.
|
|
1001
|
+
m(t, n, e, r, s) {
|
|
1002
|
+
const i = this.p(t, n);
|
|
1003
|
+
w("RestConnection", "Sending: ", i, e);
|
|
1004
|
+
const o = {};
|
|
1005
|
+
return this.g(o, r, s), this.v(t, i, o, e).then((t => (w("RestConnection", "Received: ", t),
|
|
993
1006
|
t)), (n => {
|
|
994
|
-
throw p("RestConnection", `${t} failed with error: `, n, "url: ",
|
|
1007
|
+
throw p("RestConnection", `${t} failed with error: `, n, "url: ", i, "request:", e),
|
|
995
1008
|
n;
|
|
996
1009
|
}));
|
|
997
1010
|
}
|
|
998
|
-
|
|
1011
|
+
T(t, n, e, r, s) {
|
|
999
1012
|
// The REST API automatically aggregates all of the streamed results, so we
|
|
1000
1013
|
// can just use the normal invoke() method.
|
|
1001
|
-
return this.
|
|
1014
|
+
return this.m(t, n, e, r, s);
|
|
1002
1015
|
}
|
|
1003
1016
|
/**
|
|
1004
1017
|
* Modifies the headers for a request, adding any authorization token if
|
|
1005
1018
|
* present and any additional headers for the request.
|
|
1006
|
-
*/
|
|
1007
|
-
|
|
1019
|
+
*/ g(t, n, e) {
|
|
1020
|
+
t["X-Goog-Api-Client"] = "gl-js/ fire/" + l,
|
|
1008
1021
|
// Content-Type: text/plain will avoid preflight requests which might
|
|
1009
1022
|
// mess with CORS and redirects by proxies. If we add custom headers
|
|
1010
1023
|
// we will need to change this code to potentially use the $httpOverwrite
|
|
1011
1024
|
// parameter supported by ESF to avoid triggering preflight requests.
|
|
1012
1025
|
t["Content-Type"] = "text/plain", this.databaseInfo.appId && (t["X-Firebase-GMPID"] = this.databaseInfo.appId),
|
|
1013
|
-
n
|
|
1026
|
+
n && n.headers.forEach(((n, e) => t[e] = n)), e && e.headers.forEach(((n, e) => t[e] = n));
|
|
1014
1027
|
}
|
|
1015
|
-
|
|
1016
|
-
const e =
|
|
1017
|
-
return `${this.
|
|
1028
|
+
p(t, n) {
|
|
1029
|
+
const e = at[t];
|
|
1030
|
+
return `${this.h}/v1/${n}:${e}`;
|
|
1018
1031
|
}
|
|
1019
1032
|
} {
|
|
1020
1033
|
/**
|
|
@@ -1022,24 +1035,24 @@ class {
|
|
|
1022
1035
|
* @param fetchImpl - `fetch` or a Polyfill that implements the fetch API.
|
|
1023
1036
|
*/
|
|
1024
1037
|
constructor(t, n) {
|
|
1025
|
-
super(t), this.
|
|
1038
|
+
super(t), this.I = n;
|
|
1026
1039
|
}
|
|
1027
|
-
|
|
1040
|
+
A(t, n) {
|
|
1028
1041
|
throw new Error("Not supported by FetchConnection");
|
|
1029
1042
|
}
|
|
1030
|
-
async
|
|
1043
|
+
async v(t, n, e, r) {
|
|
1031
1044
|
const s = JSON.stringify(r);
|
|
1032
1045
|
let i;
|
|
1033
1046
|
try {
|
|
1034
|
-
i = await this.
|
|
1047
|
+
i = await this.I(n, {
|
|
1035
1048
|
method: "POST",
|
|
1036
1049
|
headers: e,
|
|
1037
1050
|
body: s
|
|
1038
1051
|
});
|
|
1039
1052
|
} catch (t) {
|
|
1040
|
-
throw new L(
|
|
1053
|
+
throw new L(ft(t.status), "Request failed with error: " + t.statusText);
|
|
1041
1054
|
}
|
|
1042
|
-
if (!i.ok) throw new L(
|
|
1055
|
+
if (!i.ok) throw new L(ft(i.status), "Request failed with error: " + i.statusText);
|
|
1043
1056
|
return i.json();
|
|
1044
1057
|
}
|
|
1045
1058
|
}
|
|
@@ -1082,7 +1095,7 @@ class {
|
|
|
1082
1095
|
*
|
|
1083
1096
|
* If `nBytes < 0` , an error will be thrown.
|
|
1084
1097
|
*/
|
|
1085
|
-
function
|
|
1098
|
+
function wt(t) {
|
|
1086
1099
|
// Polyfills for IE and WebWorker by using `self` and `msCrypto` when `crypto` is not available.
|
|
1087
1100
|
const n =
|
|
1088
1101
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1108,14 +1121,14 @@ function ft(t) {
|
|
|
1108
1121
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1109
1122
|
* See the License for the specific language governing permissions and
|
|
1110
1123
|
* limitations under the License.
|
|
1111
|
-
*/ class
|
|
1112
|
-
static
|
|
1124
|
+
*/ class mt {
|
|
1125
|
+
static P() {
|
|
1113
1126
|
// Alphanumeric characters
|
|
1114
1127
|
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", n = Math.floor(256 / t.length) * t.length;
|
|
1115
1128
|
// The largest byte value that is a multiple of `char.length`.
|
|
1116
1129
|
let e = "";
|
|
1117
1130
|
for (;e.length < 20; ) {
|
|
1118
|
-
const r =
|
|
1131
|
+
const r = wt(40);
|
|
1119
1132
|
for (let s = 0; s < r.length; ++s)
|
|
1120
1133
|
// Only accept values that are [0, maxMultiple), this ensures they can
|
|
1121
1134
|
// be evenly mapped to indices of `chars` via a modulo operation.
|
|
@@ -1125,11 +1138,11 @@ function ft(t) {
|
|
|
1125
1138
|
}
|
|
1126
1139
|
}
|
|
1127
1140
|
|
|
1128
|
-
function
|
|
1141
|
+
function pt(t, n) {
|
|
1129
1142
|
return t < n ? -1 : t > n ? 1 : 0;
|
|
1130
1143
|
}
|
|
1131
1144
|
|
|
1132
|
-
/** Helper to compare arrays using isEqual(). */ function
|
|
1145
|
+
/** Helper to compare arrays using isEqual(). */ function yt(t, n, e) {
|
|
1133
1146
|
return t.length === n.length && t.every(((t, r) => e(t, n[r])));
|
|
1134
1147
|
}
|
|
1135
1148
|
|
|
@@ -1164,7 +1177,7 @@ function wt(t, n) {
|
|
|
1164
1177
|
* For examples and further specifications, refer to the
|
|
1165
1178
|
* {@link https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto | Timestamp definition}.
|
|
1166
1179
|
*/
|
|
1167
|
-
class
|
|
1180
|
+
class _t {
|
|
1168
1181
|
/**
|
|
1169
1182
|
* Creates a new timestamp.
|
|
1170
1183
|
*
|
|
@@ -1196,7 +1209,7 @@ class pt {
|
|
|
1196
1209
|
*
|
|
1197
1210
|
* @returns a new timestamp representing the current date.
|
|
1198
1211
|
*/ static now() {
|
|
1199
|
-
return
|
|
1212
|
+
return _t.fromMillis(Date.now());
|
|
1200
1213
|
}
|
|
1201
1214
|
/**
|
|
1202
1215
|
* Creates a new timestamp from the given date.
|
|
@@ -1205,7 +1218,7 @@ class pt {
|
|
|
1205
1218
|
* @returns A new `Timestamp` representing the same point in time as the given
|
|
1206
1219
|
* date.
|
|
1207
1220
|
*/ static fromDate(t) {
|
|
1208
|
-
return
|
|
1221
|
+
return _t.fromMillis(t.getTime());
|
|
1209
1222
|
}
|
|
1210
1223
|
/**
|
|
1211
1224
|
* Creates a new timestamp from the given number of milliseconds.
|
|
@@ -1216,7 +1229,7 @@ class pt {
|
|
|
1216
1229
|
* number of milliseconds.
|
|
1217
1230
|
*/ static fromMillis(t) {
|
|
1218
1231
|
const n = Math.floor(t / 1e3), e = Math.floor(1e6 * (t - 1e3 * n));
|
|
1219
|
-
return new
|
|
1232
|
+
return new _t(n, e);
|
|
1220
1233
|
}
|
|
1221
1234
|
/**
|
|
1222
1235
|
* Converts a `Timestamp` to a JavaScript `Date` object. This conversion
|
|
@@ -1238,7 +1251,7 @@ class pt {
|
|
|
1238
1251
|
return 1e3 * this.seconds + this.nanoseconds / 1e6;
|
|
1239
1252
|
}
|
|
1240
1253
|
_compareTo(t) {
|
|
1241
|
-
return this.seconds === t.seconds ?
|
|
1254
|
+
return this.seconds === t.seconds ? pt(this.nanoseconds, t.nanoseconds) : pt(this.seconds, t.seconds);
|
|
1242
1255
|
}
|
|
1243
1256
|
/**
|
|
1244
1257
|
* Returns true if this `Timestamp` is equal to the provided one.
|
|
@@ -1294,15 +1307,15 @@ class pt {
|
|
|
1294
1307
|
/**
|
|
1295
1308
|
* A version of a document in Firestore. This corresponds to the version
|
|
1296
1309
|
* timestamp, such as update_time or read_time.
|
|
1297
|
-
*/ class
|
|
1310
|
+
*/ class gt {
|
|
1298
1311
|
constructor(t) {
|
|
1299
1312
|
this.timestamp = t;
|
|
1300
1313
|
}
|
|
1301
1314
|
static fromTimestamp(t) {
|
|
1302
|
-
return new
|
|
1315
|
+
return new gt(t);
|
|
1303
1316
|
}
|
|
1304
1317
|
static min() {
|
|
1305
|
-
return new
|
|
1318
|
+
return new gt(new _t(0, 0));
|
|
1306
1319
|
}
|
|
1307
1320
|
compareTo(t) {
|
|
1308
1321
|
return this.timestamp._compareTo(t.timestamp);
|
|
@@ -1337,13 +1350,13 @@ class pt {
|
|
|
1337
1350
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1338
1351
|
* See the License for the specific language governing permissions and
|
|
1339
1352
|
* limitations under the License.
|
|
1340
|
-
*/ function
|
|
1353
|
+
*/ function bt(t) {
|
|
1341
1354
|
let n = 0;
|
|
1342
1355
|
for (const e in t) Object.prototype.hasOwnProperty.call(t, e) && n++;
|
|
1343
1356
|
return n;
|
|
1344
1357
|
}
|
|
1345
1358
|
|
|
1346
|
-
function
|
|
1359
|
+
function vt(t, n) {
|
|
1347
1360
|
for (const e in t) Object.prototype.hasOwnProperty.call(t, e) && n(e, t[e]);
|
|
1348
1361
|
}
|
|
1349
1362
|
|
|
@@ -1373,12 +1386,12 @@ function gt(t, n) {
|
|
|
1373
1386
|
* If foo is not an object, foo is replaced with an object
|
|
1374
1387
|
* containing foo
|
|
1375
1388
|
*/
|
|
1376
|
-
class
|
|
1389
|
+
class Et {
|
|
1377
1390
|
constructor(t) {
|
|
1378
1391
|
this.fields = t,
|
|
1379
1392
|
// TODO(dimond): validation of FieldMask
|
|
1380
1393
|
// Sort the field mask to support `FieldMask.isEqual()` and assert below.
|
|
1381
|
-
t.sort(
|
|
1394
|
+
t.sort(Z.comparator);
|
|
1382
1395
|
}
|
|
1383
1396
|
/**
|
|
1384
1397
|
* Verifies that `fieldPath` is included by at least one field in this field
|
|
@@ -1390,7 +1403,7 @@ class bt {
|
|
|
1390
1403
|
return !1;
|
|
1391
1404
|
}
|
|
1392
1405
|
isEqual(t) {
|
|
1393
|
-
return
|
|
1406
|
+
return yt(this.fields, t.fields, ((t, n) => t.isEqual(n)));
|
|
1394
1407
|
}
|
|
1395
1408
|
}
|
|
1396
1409
|
|
|
@@ -1436,13 +1449,13 @@ class bt {
|
|
|
1436
1449
|
* before being sent as a proto.
|
|
1437
1450
|
* @internal
|
|
1438
1451
|
*/
|
|
1439
|
-
class
|
|
1452
|
+
class Tt {
|
|
1440
1453
|
constructor(t) {
|
|
1441
1454
|
this.binaryString = t;
|
|
1442
1455
|
}
|
|
1443
1456
|
static fromBase64String(t) {
|
|
1444
1457
|
const n = atob(t);
|
|
1445
|
-
return new
|
|
1458
|
+
return new Tt(n);
|
|
1446
1459
|
}
|
|
1447
1460
|
static fromUint8Array(t) {
|
|
1448
1461
|
const n =
|
|
@@ -1457,7 +1470,7 @@ class vt {
|
|
|
1457
1470
|
/**
|
|
1458
1471
|
* Helper function to convert a binary string to an Uint8Array.
|
|
1459
1472
|
*/ (t);
|
|
1460
|
-
return new
|
|
1473
|
+
return new Tt(n);
|
|
1461
1474
|
}
|
|
1462
1475
|
toBase64() {
|
|
1463
1476
|
return t = this.binaryString, btoa(t);
|
|
@@ -1493,21 +1506,21 @@ class vt {
|
|
|
1493
1506
|
return 2 * this.binaryString.length;
|
|
1494
1507
|
}
|
|
1495
1508
|
compareTo(t) {
|
|
1496
|
-
return
|
|
1509
|
+
return pt(this.binaryString, t.binaryString);
|
|
1497
1510
|
}
|
|
1498
1511
|
isEqual(t) {
|
|
1499
1512
|
return this.binaryString === t.binaryString;
|
|
1500
1513
|
}
|
|
1501
1514
|
}
|
|
1502
1515
|
|
|
1503
|
-
|
|
1516
|
+
Tt.EMPTY_BYTE_STRING = new Tt("");
|
|
1504
1517
|
|
|
1505
|
-
const
|
|
1518
|
+
const It = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
1506
1519
|
|
|
1507
1520
|
/**
|
|
1508
1521
|
* Converts the possible Proto values for a timestamp value into a "seconds and
|
|
1509
1522
|
* nanos" representation.
|
|
1510
|
-
*/ function
|
|
1523
|
+
*/ function At(t) {
|
|
1511
1524
|
// The json interface (for the browser) will return an iso timestamp string,
|
|
1512
1525
|
// while the proto js library (for node) will return a
|
|
1513
1526
|
// google.protobuf.Timestamp instance.
|
|
@@ -1516,7 +1529,7 @@ const Et = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1516
1529
|
// (millis), so we do some custom parsing here.
|
|
1517
1530
|
// Parse the nanos right out of the string.
|
|
1518
1531
|
let n = 0;
|
|
1519
|
-
const e =
|
|
1532
|
+
const e = It.exec(t);
|
|
1520
1533
|
if (g(!!e), e[1]) {
|
|
1521
1534
|
// Pad the fraction out to 9 digits (nanos).
|
|
1522
1535
|
let t = e[1];
|
|
@@ -1530,21 +1543,21 @@ const Et = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1530
1543
|
};
|
|
1531
1544
|
}
|
|
1532
1545
|
return {
|
|
1533
|
-
seconds:
|
|
1534
|
-
nanos:
|
|
1546
|
+
seconds: Pt(t.seconds),
|
|
1547
|
+
nanos: Pt(t.nanos)
|
|
1535
1548
|
};
|
|
1536
1549
|
}
|
|
1537
1550
|
|
|
1538
1551
|
/**
|
|
1539
1552
|
* Converts the possible Proto types for numbers into a JavaScript number.
|
|
1540
1553
|
* Returns 0 if the value is not numeric.
|
|
1541
|
-
*/ function
|
|
1554
|
+
*/ function Pt(t) {
|
|
1542
1555
|
// TODO(bjornick): Handle int64 greater than 53 bits.
|
|
1543
1556
|
return "number" == typeof t ? t : "string" == typeof t ? Number(t) : 0;
|
|
1544
1557
|
}
|
|
1545
1558
|
|
|
1546
|
-
/** Converts the possible Proto types for Blobs into a ByteString. */ function
|
|
1547
|
-
return "string" == typeof t ?
|
|
1559
|
+
/** Converts the possible Proto types for Blobs into a ByteString. */ function Rt(t) {
|
|
1560
|
+
return "string" == typeof t ? Tt.fromBase64String(t) : Tt.fromUint8Array(t);
|
|
1548
1561
|
}
|
|
1549
1562
|
|
|
1550
1563
|
/**
|
|
@@ -1580,7 +1593,7 @@ const Et = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1580
1593
|
* FieldValueOptions to value().
|
|
1581
1594
|
* - With respect to other ServerTimestampValues, they sort by their
|
|
1582
1595
|
* localWriteTime.
|
|
1583
|
-
*/ function
|
|
1596
|
+
*/ function Vt(t) {
|
|
1584
1597
|
var n, e;
|
|
1585
1598
|
return "server_timestamp" === (null === (e = ((null === (n = null == t ? void 0 : t.mapValue) || void 0 === n ? void 0 : n.fields) || {}).__type__) || void 0 === e ? void 0 : e.stringValue);
|
|
1586
1599
|
}
|
|
@@ -1590,16 +1603,16 @@ const Et = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1590
1603
|
*
|
|
1591
1604
|
* Preserving the previous values allows the user to display the last resoled
|
|
1592
1605
|
* value until the backend responds with the timestamp.
|
|
1593
|
-
*/ function
|
|
1606
|
+
*/ function Dt(t) {
|
|
1594
1607
|
const n = t.mapValue.fields.__previous_value__;
|
|
1595
|
-
return
|
|
1608
|
+
return Vt(n) ? Dt(n) : n;
|
|
1596
1609
|
}
|
|
1597
1610
|
|
|
1598
1611
|
/**
|
|
1599
1612
|
* Returns the local time at which this timestamp was first set.
|
|
1600
|
-
*/ function
|
|
1601
|
-
const n =
|
|
1602
|
-
return new
|
|
1613
|
+
*/ function Nt(t) {
|
|
1614
|
+
const n = At(t.mapValue.fields.__local_write_time__.timestampValue);
|
|
1615
|
+
return new _t(n.seconds, n.nanos);
|
|
1603
1616
|
}
|
|
1604
1617
|
|
|
1605
1618
|
/**
|
|
@@ -1618,13 +1631,13 @@ const Et = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1618
1631
|
* See the License for the specific language governing permissions and
|
|
1619
1632
|
* limitations under the License.
|
|
1620
1633
|
*/
|
|
1621
|
-
/** Extracts the backend's type order for the provided value. */ function
|
|
1622
|
-
return "nullValue" in t ? 0 /* NullValue */ : "booleanValue" in t ? 1 /* BooleanValue */ : "integerValue" in t || "doubleValue" in t ? 2 /* NumberValue */ : "timestampValue" in t ? 3 /* TimestampValue */ : "stringValue" in t ? 5 /* StringValue */ : "bytesValue" in t ? 6 /* BlobValue */ : "referenceValue" in t ? 7 /* RefValue */ : "geoPointValue" in t ? 8 /* GeoPointValue */ : "arrayValue" in t ? 9 /* ArrayValue */ : "mapValue" in t ?
|
|
1634
|
+
/** Extracts the backend's type order for the provided value. */ function $t(t) {
|
|
1635
|
+
return "nullValue" in t ? 0 /* NullValue */ : "booleanValue" in t ? 1 /* BooleanValue */ : "integerValue" in t || "doubleValue" in t ? 2 /* NumberValue */ : "timestampValue" in t ? 3 /* TimestampValue */ : "stringValue" in t ? 5 /* StringValue */ : "bytesValue" in t ? 6 /* BlobValue */ : "referenceValue" in t ? 7 /* RefValue */ : "geoPointValue" in t ? 8 /* GeoPointValue */ : "arrayValue" in t ? 9 /* ArrayValue */ : "mapValue" in t ? Vt(t) ? 4 /* ServerTimestampValue */ : 10 /* ObjectValue */ : _();
|
|
1623
1636
|
}
|
|
1624
1637
|
|
|
1625
|
-
/** Tests `left` and `right` for equality based on the backend semantics. */ function
|
|
1626
|
-
const e =
|
|
1627
|
-
if (e !==
|
|
1638
|
+
/** Tests `left` and `right` for equality based on the backend semantics. */ function Ft(t, n) {
|
|
1639
|
+
const e = $t(t);
|
|
1640
|
+
if (e !== $t(n)) return !1;
|
|
1628
1641
|
switch (e) {
|
|
1629
1642
|
case 0 /* NullValue */ :
|
|
1630
1643
|
return !0;
|
|
@@ -1633,14 +1646,14 @@ const Et = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1633
1646
|
return t.booleanValue === n.booleanValue;
|
|
1634
1647
|
|
|
1635
1648
|
case 4 /* ServerTimestampValue */ :
|
|
1636
|
-
return
|
|
1649
|
+
return Nt(t).isEqual(Nt(n));
|
|
1637
1650
|
|
|
1638
1651
|
case 3 /* TimestampValue */ :
|
|
1639
1652
|
return function(t, n) {
|
|
1640
1653
|
if ("string" == typeof t.timestampValue && "string" == typeof n.timestampValue && t.timestampValue.length === n.timestampValue.length)
|
|
1641
1654
|
// Use string equality for ISO 8601 timestamps
|
|
1642
1655
|
return t.timestampValue === n.timestampValue;
|
|
1643
|
-
const e =
|
|
1656
|
+
const e = At(t.timestampValue), r = At(n.timestampValue);
|
|
1644
1657
|
return e.seconds === r.seconds && e.nanos === r.nanos;
|
|
1645
1658
|
}(t, n);
|
|
1646
1659
|
|
|
@@ -1649,7 +1662,7 @@ const Et = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1649
1662
|
|
|
1650
1663
|
case 6 /* BlobValue */ :
|
|
1651
1664
|
return function(t, n) {
|
|
1652
|
-
return
|
|
1665
|
+
return Rt(t.bytesValue).isEqual(Rt(n.bytesValue));
|
|
1653
1666
|
}(t, n);
|
|
1654
1667
|
|
|
1655
1668
|
case 7 /* RefValue */ :
|
|
@@ -1657,27 +1670,27 @@ const Et = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1657
1670
|
|
|
1658
1671
|
case 8 /* GeoPointValue */ :
|
|
1659
1672
|
return function(t, n) {
|
|
1660
|
-
return
|
|
1673
|
+
return Pt(t.geoPointValue.latitude) === Pt(n.geoPointValue.latitude) && Pt(t.geoPointValue.longitude) === Pt(n.geoPointValue.longitude);
|
|
1661
1674
|
}(t, n);
|
|
1662
1675
|
|
|
1663
1676
|
case 2 /* NumberValue */ :
|
|
1664
1677
|
return function(t, n) {
|
|
1665
|
-
if ("integerValue" in t && "integerValue" in n) return
|
|
1678
|
+
if ("integerValue" in t && "integerValue" in n) return Pt(t.integerValue) === Pt(n.integerValue);
|
|
1666
1679
|
if ("doubleValue" in t && "doubleValue" in n) {
|
|
1667
|
-
const e =
|
|
1668
|
-
return e === r ?
|
|
1680
|
+
const e = Pt(t.doubleValue), r = Pt(n.doubleValue);
|
|
1681
|
+
return e === r ? ct(e) === ct(r) : isNaN(e) && isNaN(r);
|
|
1669
1682
|
}
|
|
1670
1683
|
return !1;
|
|
1671
1684
|
}(t, n);
|
|
1672
1685
|
|
|
1673
1686
|
case 9 /* ArrayValue */ :
|
|
1674
|
-
return
|
|
1687
|
+
return yt(t.arrayValue.values || [], n.arrayValue.values || [], Ft);
|
|
1675
1688
|
|
|
1676
1689
|
case 10 /* ObjectValue */ :
|
|
1677
1690
|
return function(t, n) {
|
|
1678
1691
|
const e = t.mapValue.fields || {}, r = n.mapValue.fields || {};
|
|
1679
|
-
if (
|
|
1680
|
-
for (const t in e) if (e.hasOwnProperty(t) && (void 0 === r[t] || !
|
|
1692
|
+
if (bt(e) !== bt(r)) return !1;
|
|
1693
|
+
for (const t in e) if (e.hasOwnProperty(t) && (void 0 === r[t] || !Ft(e[t], r[t]))) return !1;
|
|
1681
1694
|
return !0;
|
|
1682
1695
|
}
|
|
1683
1696
|
/** Returns true if the ArrayValue contains the specified element. */ (t, n);
|
|
@@ -1687,40 +1700,40 @@ const Et = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1687
1700
|
}
|
|
1688
1701
|
}
|
|
1689
1702
|
|
|
1690
|
-
function
|
|
1691
|
-
return void 0 !== (t.values || []).find((t =>
|
|
1703
|
+
function St(t, n) {
|
|
1704
|
+
return void 0 !== (t.values || []).find((t => Ft(t, n)));
|
|
1692
1705
|
}
|
|
1693
1706
|
|
|
1694
|
-
function
|
|
1695
|
-
const e =
|
|
1696
|
-
if (e !== r) return
|
|
1707
|
+
function qt(t, n) {
|
|
1708
|
+
const e = $t(t), r = $t(n);
|
|
1709
|
+
if (e !== r) return pt(e, r);
|
|
1697
1710
|
switch (e) {
|
|
1698
1711
|
case 0 /* NullValue */ :
|
|
1699
1712
|
return 0;
|
|
1700
1713
|
|
|
1701
1714
|
case 1 /* BooleanValue */ :
|
|
1702
|
-
return
|
|
1715
|
+
return pt(t.booleanValue, n.booleanValue);
|
|
1703
1716
|
|
|
1704
1717
|
case 2 /* NumberValue */ :
|
|
1705
1718
|
return function(t, n) {
|
|
1706
|
-
const e =
|
|
1719
|
+
const e = Pt(t.integerValue || t.doubleValue), r = Pt(n.integerValue || n.doubleValue);
|
|
1707
1720
|
return e < r ? -1 : e > r ? 1 : e === r ? 0 :
|
|
1708
1721
|
// one or both are NaN.
|
|
1709
1722
|
isNaN(e) ? isNaN(r) ? 0 : -1 : 1;
|
|
1710
1723
|
}(t, n);
|
|
1711
1724
|
|
|
1712
1725
|
case 3 /* TimestampValue */ :
|
|
1713
|
-
return
|
|
1726
|
+
return xt(t.timestampValue, n.timestampValue);
|
|
1714
1727
|
|
|
1715
1728
|
case 4 /* ServerTimestampValue */ :
|
|
1716
|
-
return
|
|
1729
|
+
return xt(Nt(t), Nt(n));
|
|
1717
1730
|
|
|
1718
1731
|
case 5 /* StringValue */ :
|
|
1719
|
-
return
|
|
1732
|
+
return pt(t.stringValue, n.stringValue);
|
|
1720
1733
|
|
|
1721
1734
|
case 6 /* BlobValue */ :
|
|
1722
1735
|
return function(t, n) {
|
|
1723
|
-
const e =
|
|
1736
|
+
const e = Rt(t), r = Rt(n);
|
|
1724
1737
|
return e.compareTo(r);
|
|
1725
1738
|
}(t.bytesValue, n.bytesValue);
|
|
1726
1739
|
|
|
@@ -1728,27 +1741,27 @@ function Ft(t, n) {
|
|
|
1728
1741
|
return function(t, n) {
|
|
1729
1742
|
const e = t.split("/"), r = n.split("/");
|
|
1730
1743
|
for (let t = 0; t < e.length && t < r.length; t++) {
|
|
1731
|
-
const n =
|
|
1744
|
+
const n = pt(e[t], r[t]);
|
|
1732
1745
|
if (0 !== n) return n;
|
|
1733
1746
|
}
|
|
1734
|
-
return
|
|
1747
|
+
return pt(e.length, r.length);
|
|
1735
1748
|
}(t.referenceValue, n.referenceValue);
|
|
1736
1749
|
|
|
1737
1750
|
case 8 /* GeoPointValue */ :
|
|
1738
1751
|
return function(t, n) {
|
|
1739
|
-
const e =
|
|
1752
|
+
const e = pt(Pt(t.latitude), Pt(n.latitude));
|
|
1740
1753
|
if (0 !== e) return e;
|
|
1741
|
-
return
|
|
1754
|
+
return pt(Pt(t.longitude), Pt(n.longitude));
|
|
1742
1755
|
}(t.geoPointValue, n.geoPointValue);
|
|
1743
1756
|
|
|
1744
1757
|
case 9 /* ArrayValue */ :
|
|
1745
1758
|
return function(t, n) {
|
|
1746
1759
|
const e = t.values || [], r = n.values || [];
|
|
1747
1760
|
for (let t = 0; t < e.length && t < r.length; ++t) {
|
|
1748
|
-
const n =
|
|
1761
|
+
const n = qt(e[t], r[t]);
|
|
1749
1762
|
if (n) return n;
|
|
1750
1763
|
}
|
|
1751
|
-
return
|
|
1764
|
+
return pt(e.length, r.length);
|
|
1752
1765
|
}(t.arrayValue, n.arrayValue);
|
|
1753
1766
|
|
|
1754
1767
|
case 10 /* ObjectValue */ :
|
|
@@ -1760,12 +1773,12 @@ function Ft(t, n) {
|
|
|
1760
1773
|
// canonical IDs are independent of insertion order.
|
|
1761
1774
|
r.sort(), i.sort();
|
|
1762
1775
|
for (let t = 0; t < r.length && t < i.length; ++t) {
|
|
1763
|
-
const n =
|
|
1776
|
+
const n = pt(r[t], i[t]);
|
|
1764
1777
|
if (0 !== n) return n;
|
|
1765
|
-
const o =
|
|
1778
|
+
const o = qt(e[r[t]], s[i[t]]);
|
|
1766
1779
|
if (0 !== o) return o;
|
|
1767
1780
|
}
|
|
1768
|
-
return
|
|
1781
|
+
return pt(r.length, i.length);
|
|
1769
1782
|
}
|
|
1770
1783
|
/** Returns a reference value for the provided database and key. */ (t.mapValue, n.mapValue);
|
|
1771
1784
|
|
|
@@ -1774,35 +1787,35 @@ function Ft(t, n) {
|
|
|
1774
1787
|
}
|
|
1775
1788
|
}
|
|
1776
1789
|
|
|
1777
|
-
function
|
|
1778
|
-
if ("string" == typeof t && "string" == typeof n && t.length === n.length) return
|
|
1779
|
-
const e =
|
|
1780
|
-
return 0 !== s ? s :
|
|
1790
|
+
function xt(t, n) {
|
|
1791
|
+
if ("string" == typeof t && "string" == typeof n && t.length === n.length) return pt(t, n);
|
|
1792
|
+
const e = At(t), r = At(n), s = pt(e.seconds, r.seconds);
|
|
1793
|
+
return 0 !== s ? s : pt(e.nanos, r.nanos);
|
|
1781
1794
|
}
|
|
1782
1795
|
|
|
1783
|
-
function
|
|
1796
|
+
function Ot(t, n) {
|
|
1784
1797
|
return {
|
|
1785
1798
|
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${n.path.canonicalString()}`
|
|
1786
1799
|
};
|
|
1787
1800
|
}
|
|
1788
1801
|
|
|
1789
|
-
/** Returns true if `value` is an ArrayValue. */ function
|
|
1802
|
+
/** Returns true if `value` is an ArrayValue. */ function Ct(t) {
|
|
1790
1803
|
return !!t && "arrayValue" in t;
|
|
1791
1804
|
}
|
|
1792
1805
|
|
|
1793
|
-
/** Returns true if `value` is a NullValue. */ function
|
|
1806
|
+
/** Returns true if `value` is a NullValue. */ function Lt(t) {
|
|
1794
1807
|
return !!t && "nullValue" in t;
|
|
1795
1808
|
}
|
|
1796
1809
|
|
|
1797
|
-
/** Returns true if `value` is NaN. */ function
|
|
1810
|
+
/** Returns true if `value` is NaN. */ function Ut(t) {
|
|
1798
1811
|
return !!t && "doubleValue" in t && isNaN(Number(t.doubleValue));
|
|
1799
1812
|
}
|
|
1800
1813
|
|
|
1801
|
-
/** Returns true if `value` is a MapValue. */ function
|
|
1814
|
+
/** Returns true if `value` is a MapValue. */ function kt(t) {
|
|
1802
1815
|
return !!t && "mapValue" in t;
|
|
1803
1816
|
}
|
|
1804
1817
|
|
|
1805
|
-
/** Creates a deep copy of `source`. */ function
|
|
1818
|
+
/** Creates a deep copy of `source`. */ function jt(t) {
|
|
1806
1819
|
if (t.geoPointValue) return {
|
|
1807
1820
|
geoPointValue: Object.assign({}, t.geoPointValue)
|
|
1808
1821
|
};
|
|
@@ -1815,7 +1828,7 @@ function qt(t, n) {
|
|
|
1815
1828
|
fields: {}
|
|
1816
1829
|
}
|
|
1817
1830
|
};
|
|
1818
|
-
return
|
|
1831
|
+
return vt(t.mapValue.fields, ((t, e) => n.mapValue.fields[t] = jt(e))), n;
|
|
1819
1832
|
}
|
|
1820
1833
|
if (t.arrayValue) {
|
|
1821
1834
|
const n = {
|
|
@@ -1823,7 +1836,7 @@ function qt(t, n) {
|
|
|
1823
1836
|
values: []
|
|
1824
1837
|
}
|
|
1825
1838
|
};
|
|
1826
|
-
for (let e = 0; e < (t.arrayValue.values || []).length; ++e) n.arrayValue.values[e] =
|
|
1839
|
+
for (let e = 0; e < (t.arrayValue.values || []).length; ++e) n.arrayValue.values[e] = jt(t.arrayValue.values[e]);
|
|
1827
1840
|
return n;
|
|
1828
1841
|
}
|
|
1829
1842
|
return Object.assign({}, t);
|
|
@@ -1848,12 +1861,12 @@ function qt(t, n) {
|
|
|
1848
1861
|
/**
|
|
1849
1862
|
* An ObjectValue represents a MapValue in the Firestore Proto and offers the
|
|
1850
1863
|
* ability to add and remove fields (via the ObjectValueBuilder).
|
|
1851
|
-
*/ class
|
|
1864
|
+
*/ class Mt {
|
|
1852
1865
|
constructor(t) {
|
|
1853
1866
|
this.value = t;
|
|
1854
1867
|
}
|
|
1855
1868
|
static empty() {
|
|
1856
|
-
return new
|
|
1869
|
+
return new Mt({
|
|
1857
1870
|
mapValue: {}
|
|
1858
1871
|
});
|
|
1859
1872
|
}
|
|
@@ -1867,7 +1880,7 @@ function qt(t, n) {
|
|
|
1867
1880
|
{
|
|
1868
1881
|
let n = this.value;
|
|
1869
1882
|
for (let e = 0; e < t.length - 1; ++e) if (n = (n.mapValue.fields || {})[t.get(e)],
|
|
1870
|
-
!
|
|
1883
|
+
!kt(n)) return null;
|
|
1871
1884
|
return n = (n.mapValue.fields || {})[t.lastSegment()], n || null;
|
|
1872
1885
|
}
|
|
1873
1886
|
}
|
|
@@ -1877,21 +1890,21 @@ function qt(t, n) {
|
|
|
1877
1890
|
* @param path - The field path to set.
|
|
1878
1891
|
* @param value - The value to set.
|
|
1879
1892
|
*/ set(t, n) {
|
|
1880
|
-
this.getFieldsMap(t.popLast())[t.lastSegment()] =
|
|
1893
|
+
this.getFieldsMap(t.popLast())[t.lastSegment()] = jt(n);
|
|
1881
1894
|
}
|
|
1882
1895
|
/**
|
|
1883
1896
|
* Sets the provided fields to the provided values.
|
|
1884
1897
|
*
|
|
1885
1898
|
* @param data - A map of fields to values (or null for deletes).
|
|
1886
1899
|
*/ setAll(t) {
|
|
1887
|
-
let n =
|
|
1900
|
+
let n = Z.emptyPath(), e = {}, r = [];
|
|
1888
1901
|
t.forEach(((t, s) => {
|
|
1889
1902
|
if (!n.isImmediateParentOf(s)) {
|
|
1890
1903
|
// Insert the accumulated changes at this parent location
|
|
1891
1904
|
const t = this.getFieldsMap(n);
|
|
1892
1905
|
this.applyChanges(t, e, r), e = {}, r = [], n = s.popLast();
|
|
1893
1906
|
}
|
|
1894
|
-
t ? e[s.lastSegment()] =
|
|
1907
|
+
t ? e[s.lastSegment()] = jt(t) : r.push(s.lastSegment());
|
|
1895
1908
|
}));
|
|
1896
1909
|
const s = this.getFieldsMap(n);
|
|
1897
1910
|
this.applyChanges(s, e, r);
|
|
@@ -1903,10 +1916,10 @@ function qt(t, n) {
|
|
|
1903
1916
|
* @param path - The field path to remove.
|
|
1904
1917
|
*/ delete(t) {
|
|
1905
1918
|
const n = this.field(t.popLast());
|
|
1906
|
-
|
|
1919
|
+
kt(n) && n.mapValue.fields && delete n.mapValue.fields[t.lastSegment()];
|
|
1907
1920
|
}
|
|
1908
1921
|
isEqual(t) {
|
|
1909
|
-
return
|
|
1922
|
+
return Ft(this.value, t.value);
|
|
1910
1923
|
}
|
|
1911
1924
|
/**
|
|
1912
1925
|
* Returns the map that contains the leaf element of `path`. If the parent
|
|
@@ -1918,7 +1931,7 @@ function qt(t, n) {
|
|
|
1918
1931
|
});
|
|
1919
1932
|
for (let e = 0; e < t.length; ++e) {
|
|
1920
1933
|
let r = n.mapValue.fields[t.get(e)];
|
|
1921
|
-
|
|
1934
|
+
kt(r) && r.mapValue.fields || (r = {
|
|
1922
1935
|
mapValue: {
|
|
1923
1936
|
fields: {}
|
|
1924
1937
|
}
|
|
@@ -1930,11 +1943,11 @@ function qt(t, n) {
|
|
|
1930
1943
|
* Modifies `fieldsMap` by adding, replacing or deleting the specified
|
|
1931
1944
|
* entries.
|
|
1932
1945
|
*/ applyChanges(t, n, e) {
|
|
1933
|
-
|
|
1946
|
+
vt(n, ((n, e) => t[n] = e));
|
|
1934
1947
|
for (const n of e) delete t[n];
|
|
1935
1948
|
}
|
|
1936
1949
|
clone() {
|
|
1937
|
-
return new jt(
|
|
1950
|
+
return new Mt(jt(this.value));
|
|
1938
1951
|
}
|
|
1939
1952
|
}
|
|
1940
1953
|
|
|
@@ -1963,7 +1976,7 @@ function qt(t, n) {
|
|
|
1963
1976
|
* not transition to one of these states even after all mutations have been
|
|
1964
1977
|
* applied, `isValidDocument()` returns false and the document should be removed
|
|
1965
1978
|
* from all views.
|
|
1966
|
-
*/ class
|
|
1979
|
+
*/ class Bt {
|
|
1967
1980
|
constructor(t, n, e, r, s) {
|
|
1968
1981
|
this.key = t, this.documentType = n, this.version = e, this.data = r, this.documentState = s;
|
|
1969
1982
|
}
|
|
@@ -1971,23 +1984,23 @@ function qt(t, n) {
|
|
|
1971
1984
|
* Creates a document with no known version or data, but which can serve as
|
|
1972
1985
|
* base document for mutations.
|
|
1973
1986
|
*/ static newInvalidDocument(t) {
|
|
1974
|
-
return new
|
|
1987
|
+
return new Bt(t, 0 /* INVALID */ , gt.min(), Mt.empty(), 0 /* SYNCED */);
|
|
1975
1988
|
}
|
|
1976
1989
|
/**
|
|
1977
1990
|
* Creates a new document that is known to exist with the given data at the
|
|
1978
1991
|
* given version.
|
|
1979
1992
|
*/ static newFoundDocument(t, n, e) {
|
|
1980
|
-
return new
|
|
1993
|
+
return new Bt(t, 1 /* FOUND_DOCUMENT */ , n, e, 0 /* SYNCED */);
|
|
1981
1994
|
}
|
|
1982
1995
|
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t, n) {
|
|
1983
|
-
return new
|
|
1996
|
+
return new Bt(t, 2 /* NO_DOCUMENT */ , n, Mt.empty(), 0 /* SYNCED */);
|
|
1984
1997
|
}
|
|
1985
1998
|
/**
|
|
1986
1999
|
* Creates a new document that is known to exist at the given version but
|
|
1987
2000
|
* whose data is not known (e.g. a document that was updated without a known
|
|
1988
2001
|
* base document).
|
|
1989
2002
|
*/ static newUnknownDocument(t, n) {
|
|
1990
|
-
return new
|
|
2003
|
+
return new Bt(t, 3 /* UNKNOWN_DOCUMENT */ , n, Mt.empty(), 2 /* HAS_COMMITTED_MUTATIONS */);
|
|
1991
2004
|
}
|
|
1992
2005
|
/**
|
|
1993
2006
|
* Changes the document type to indicate that it exists and that its version
|
|
@@ -2000,7 +2013,7 @@ function qt(t, n) {
|
|
|
2000
2013
|
* Changes the document type to indicate that it doesn't exist at the given
|
|
2001
2014
|
* version.
|
|
2002
2015
|
*/ convertToNoDocument(t) {
|
|
2003
|
-
return this.version = t, this.documentType = 2 /* NO_DOCUMENT */ , this.data =
|
|
2016
|
+
return this.version = t, this.documentType = 2 /* NO_DOCUMENT */ , this.data = Mt.empty(),
|
|
2004
2017
|
this.documentState = 0 /* SYNCED */ , this;
|
|
2005
2018
|
}
|
|
2006
2019
|
/**
|
|
@@ -2008,7 +2021,7 @@ function qt(t, n) {
|
|
|
2008
2021
|
* that its data is not known (e.g. a document that was updated without a known
|
|
2009
2022
|
* base document).
|
|
2010
2023
|
*/ convertToUnknownDocument(t) {
|
|
2011
|
-
return this.version = t, this.documentType = 3 /* UNKNOWN_DOCUMENT */ , this.data =
|
|
2024
|
+
return this.version = t, this.documentType = 3 /* UNKNOWN_DOCUMENT */ , this.data = Mt.empty(),
|
|
2012
2025
|
this.documentState = 2 /* HAS_COMMITTED_MUTATIONS */ , this;
|
|
2013
2026
|
}
|
|
2014
2027
|
setHasCommittedMutations() {
|
|
@@ -2039,10 +2052,10 @@ function qt(t, n) {
|
|
|
2039
2052
|
return 3 /* UNKNOWN_DOCUMENT */ === this.documentType;
|
|
2040
2053
|
}
|
|
2041
2054
|
isEqual(t) {
|
|
2042
|
-
return t instanceof
|
|
2055
|
+
return t instanceof Bt && this.key.isEqual(t.key) && this.version.isEqual(t.version) && this.documentType === t.documentType && this.documentState === t.documentState && this.data.isEqual(t.data);
|
|
2043
2056
|
}
|
|
2044
2057
|
clone() {
|
|
2045
|
-
return new
|
|
2058
|
+
return new Bt(this.key, this.documentType, this.version, this.data.clone(), this.documentState);
|
|
2046
2059
|
}
|
|
2047
2060
|
toString() {
|
|
2048
2061
|
return `Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`;
|
|
@@ -2066,10 +2079,10 @@ function qt(t, n) {
|
|
|
2066
2079
|
* limitations under the License.
|
|
2067
2080
|
*/
|
|
2068
2081
|
// Visible for testing
|
|
2069
|
-
class
|
|
2082
|
+
class zt {
|
|
2070
2083
|
constructor(t, n = null, e = [], r = [], s = null, i = null, o = null) {
|
|
2071
2084
|
this.path = t, this.collectionGroup = n, this.orderBy = e, this.filters = r, this.limit = s,
|
|
2072
|
-
this.startAt = i, this.endAt = o, this.
|
|
2085
|
+
this.startAt = i, this.endAt = o, this.R = null;
|
|
2073
2086
|
}
|
|
2074
2087
|
}
|
|
2075
2088
|
|
|
@@ -2080,8 +2093,8 @@ class Bt {
|
|
|
2080
2093
|
* NOTE: you should always construct `Target` from `Query.toTarget` instead of
|
|
2081
2094
|
* using this factory method, because `Query` provides an implicit `orderBy`
|
|
2082
2095
|
* property.
|
|
2083
|
-
*/ function
|
|
2084
|
-
return new
|
|
2096
|
+
*/ function Gt(t, n = null, e = [], r = [], s = null, i = null, o = null) {
|
|
2097
|
+
return new zt(t, n, e, r, s, i, o);
|
|
2085
2098
|
}
|
|
2086
2099
|
|
|
2087
2100
|
class Qt extends class {} {
|
|
@@ -2091,18 +2104,18 @@ class Qt extends class {} {
|
|
|
2091
2104
|
/**
|
|
2092
2105
|
* Creates a filter based on the provided arguments.
|
|
2093
2106
|
*/ static create(t, n, e) {
|
|
2094
|
-
return t.isKeyField() ? "in" /* IN */ === n || "not-in" /* NOT_IN */ === n ? this.
|
|
2107
|
+
return t.isKeyField() ? "in" /* IN */ === n || "not-in" /* NOT_IN */ === n ? this.V(t, n, e) : new Wt(t, n, e) : "array-contains" /* ARRAY_CONTAINS */ === n ? new Jt(t, e) : "in" /* IN */ === n ? new Xt(t, e) : "not-in" /* NOT_IN */ === n ? new Zt(t, e) : "array-contains-any" /* ARRAY_CONTAINS_ANY */ === n ? new tn(t, e) : new Qt(t, n, e);
|
|
2095
2108
|
}
|
|
2096
|
-
static
|
|
2097
|
-
return "in" /* IN */ === n ? new
|
|
2109
|
+
static V(t, n, e) {
|
|
2110
|
+
return "in" /* IN */ === n ? new Yt(t, e) : new Ht(t, e);
|
|
2098
2111
|
}
|
|
2099
2112
|
matches(t) {
|
|
2100
2113
|
const n = t.data.field(this.field);
|
|
2101
2114
|
// Types do not have to match in NOT_EQUAL filters.
|
|
2102
|
-
return "!=" /* NOT_EQUAL */ === this.op ? null !== n && this.
|
|
2115
|
+
return "!=" /* NOT_EQUAL */ === this.op ? null !== n && this.D(qt(n, this.value)) : null !== n && $t(this.value) === $t(n) && this.D(qt(n, this.value));
|
|
2103
2116
|
// Only compare types with matching backend order (such as double and int).
|
|
2104
2117
|
}
|
|
2105
|
-
|
|
2118
|
+
D(t) {
|
|
2106
2119
|
switch (this.op) {
|
|
2107
2120
|
case "<" /* LESS_THAN */ :
|
|
2108
2121
|
return t < 0;
|
|
@@ -2126,85 +2139,85 @@ class Qt extends class {} {
|
|
|
2126
2139
|
return _();
|
|
2127
2140
|
}
|
|
2128
2141
|
}
|
|
2129
|
-
|
|
2142
|
+
N() {
|
|
2130
2143
|
return [ "<" /* LESS_THAN */ , "<=" /* LESS_THAN_OR_EQUAL */ , ">" /* GREATER_THAN */ , ">=" /* GREATER_THAN_OR_EQUAL */ , "!=" /* NOT_EQUAL */ , "not-in" /* NOT_IN */ ].indexOf(this.op) >= 0;
|
|
2131
2144
|
}
|
|
2132
2145
|
}
|
|
2133
2146
|
|
|
2134
2147
|
/** Filter that matches on key fields (i.e. '__name__'). */
|
|
2135
|
-
class
|
|
2148
|
+
class Wt extends Qt {
|
|
2136
2149
|
constructor(t, n, e) {
|
|
2137
|
-
super(t, n, e), this.key =
|
|
2150
|
+
super(t, n, e), this.key = tt.fromName(e.referenceValue);
|
|
2138
2151
|
}
|
|
2139
2152
|
matches(t) {
|
|
2140
|
-
const n =
|
|
2141
|
-
return this.
|
|
2153
|
+
const n = tt.comparator(t.key, this.key);
|
|
2154
|
+
return this.D(n);
|
|
2142
2155
|
}
|
|
2143
2156
|
}
|
|
2144
2157
|
|
|
2145
|
-
/** Filter that matches on key fields within an array. */ class
|
|
2158
|
+
/** Filter that matches on key fields within an array. */ class Yt extends Qt {
|
|
2146
2159
|
constructor(t, n) {
|
|
2147
|
-
super(t, "in" /* IN */ , n), this.keys =
|
|
2160
|
+
super(t, "in" /* IN */ , n), this.keys = Kt("in" /* IN */ , n);
|
|
2148
2161
|
}
|
|
2149
2162
|
matches(t) {
|
|
2150
2163
|
return this.keys.some((n => n.isEqual(t.key)));
|
|
2151
2164
|
}
|
|
2152
2165
|
}
|
|
2153
2166
|
|
|
2154
|
-
/** Filter that matches on key fields not present within an array. */ class
|
|
2167
|
+
/** Filter that matches on key fields not present within an array. */ class Ht extends Qt {
|
|
2155
2168
|
constructor(t, n) {
|
|
2156
|
-
super(t, "not-in" /* NOT_IN */ , n), this.keys =
|
|
2169
|
+
super(t, "not-in" /* NOT_IN */ , n), this.keys = Kt("not-in" /* NOT_IN */ , n);
|
|
2157
2170
|
}
|
|
2158
2171
|
matches(t) {
|
|
2159
2172
|
return !this.keys.some((n => n.isEqual(t.key)));
|
|
2160
2173
|
}
|
|
2161
2174
|
}
|
|
2162
2175
|
|
|
2163
|
-
function
|
|
2176
|
+
function Kt(t, n) {
|
|
2164
2177
|
var e;
|
|
2165
|
-
return ((null === (e = n.arrayValue) || void 0 === e ? void 0 : e.values) || []).map((t =>
|
|
2178
|
+
return ((null === (e = n.arrayValue) || void 0 === e ? void 0 : e.values) || []).map((t => tt.fromName(t.referenceValue)));
|
|
2166
2179
|
}
|
|
2167
2180
|
|
|
2168
|
-
/** A Filter that implements the array-contains operator. */ class
|
|
2181
|
+
/** A Filter that implements the array-contains operator. */ class Jt extends Qt {
|
|
2169
2182
|
constructor(t, n) {
|
|
2170
2183
|
super(t, "array-contains" /* ARRAY_CONTAINS */ , n);
|
|
2171
2184
|
}
|
|
2172
2185
|
matches(t) {
|
|
2173
2186
|
const n = t.data.field(this.field);
|
|
2174
|
-
return
|
|
2187
|
+
return Ct(n) && St(n.arrayValue, this.value);
|
|
2175
2188
|
}
|
|
2176
2189
|
}
|
|
2177
2190
|
|
|
2178
|
-
/** A Filter that implements the IN operator. */ class
|
|
2191
|
+
/** A Filter that implements the IN operator. */ class Xt extends Qt {
|
|
2179
2192
|
constructor(t, n) {
|
|
2180
2193
|
super(t, "in" /* IN */ , n);
|
|
2181
2194
|
}
|
|
2182
2195
|
matches(t) {
|
|
2183
2196
|
const n = t.data.field(this.field);
|
|
2184
|
-
return null !== n &&
|
|
2197
|
+
return null !== n && St(this.value.arrayValue, n);
|
|
2185
2198
|
}
|
|
2186
2199
|
}
|
|
2187
2200
|
|
|
2188
|
-
/** A Filter that implements the not-in operator. */ class
|
|
2201
|
+
/** A Filter that implements the not-in operator. */ class Zt extends Qt {
|
|
2189
2202
|
constructor(t, n) {
|
|
2190
2203
|
super(t, "not-in" /* NOT_IN */ , n);
|
|
2191
2204
|
}
|
|
2192
2205
|
matches(t) {
|
|
2193
|
-
if (
|
|
2206
|
+
if (St(this.value.arrayValue, {
|
|
2194
2207
|
nullValue: "NULL_VALUE"
|
|
2195
2208
|
})) return !1;
|
|
2196
2209
|
const n = t.data.field(this.field);
|
|
2197
|
-
return null !== n &&
|
|
2210
|
+
return null !== n && !St(this.value.arrayValue, n);
|
|
2198
2211
|
}
|
|
2199
2212
|
}
|
|
2200
2213
|
|
|
2201
|
-
/** A Filter that implements the array-contains-any operator. */ class
|
|
2214
|
+
/** A Filter that implements the array-contains-any operator. */ class tn extends Qt {
|
|
2202
2215
|
constructor(t, n) {
|
|
2203
2216
|
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ , n);
|
|
2204
2217
|
}
|
|
2205
2218
|
matches(t) {
|
|
2206
2219
|
const n = t.data.field(this.field);
|
|
2207
|
-
return !(!
|
|
2220
|
+
return !(!Ct(n) || !n.arrayValue.values) && n.arrayValue.values.some((t => St(this.value.arrayValue, t)));
|
|
2208
2221
|
}
|
|
2209
2222
|
}
|
|
2210
2223
|
|
|
@@ -2221,7 +2234,7 @@ function Ht(t, n) {
|
|
|
2221
2234
|
* Bound provides a function to determine whether a document comes before or
|
|
2222
2235
|
* after a bound. This is influenced by whether the position is just before or
|
|
2223
2236
|
* just after the provided values.
|
|
2224
|
-
*/ class
|
|
2237
|
+
*/ class nn {
|
|
2225
2238
|
constructor(t, n) {
|
|
2226
2239
|
this.position = t, this.before = n;
|
|
2227
2240
|
}
|
|
@@ -2229,22 +2242,22 @@ function Ht(t, n) {
|
|
|
2229
2242
|
|
|
2230
2243
|
/**
|
|
2231
2244
|
* An ordering on a field, in some Direction. Direction defaults to ASCENDING.
|
|
2232
|
-
*/ class
|
|
2245
|
+
*/ class en {
|
|
2233
2246
|
constructor(t, n = "asc" /* ASCENDING */) {
|
|
2234
2247
|
this.field = t, this.dir = n;
|
|
2235
2248
|
}
|
|
2236
2249
|
}
|
|
2237
2250
|
|
|
2238
|
-
function
|
|
2251
|
+
function rn(t, n) {
|
|
2239
2252
|
return t.dir === n.dir && t.field.isEqual(n.field);
|
|
2240
2253
|
}
|
|
2241
2254
|
|
|
2242
|
-
function
|
|
2255
|
+
function sn(t, n) {
|
|
2243
2256
|
if (null === t) return null === n;
|
|
2244
2257
|
if (null === n) return !1;
|
|
2245
2258
|
if (t.before !== n.before || t.position.length !== n.position.length) return !1;
|
|
2246
2259
|
for (let e = 0; e < t.position.length; e++) {
|
|
2247
|
-
if (!
|
|
2260
|
+
if (!Ft(t.position[e], n.position[e])) return !1;
|
|
2248
2261
|
}
|
|
2249
2262
|
return !0;
|
|
2250
2263
|
}
|
|
@@ -2271,29 +2284,29 @@ function en(t, n) {
|
|
|
2271
2284
|
* query the RemoteStore results.
|
|
2272
2285
|
*
|
|
2273
2286
|
* Visible for testing.
|
|
2274
|
-
*/ class
|
|
2287
|
+
*/ class on {
|
|
2275
2288
|
/**
|
|
2276
2289
|
* Initializes a Query with a path and optional additional query constraints.
|
|
2277
2290
|
* Path must currently be empty if this is a collection group query.
|
|
2278
2291
|
*/
|
|
2279
2292
|
constructor(t, n = null, e = [], r = [], s = null, i = "F" /* First */ , o = null, u = null) {
|
|
2280
2293
|
this.path = t, this.collectionGroup = n, this.explicitOrderBy = e, this.filters = r,
|
|
2281
|
-
this.limit = s, this.limitType = i, this.startAt = o, this.endAt = u, this
|
|
2294
|
+
this.limit = s, this.limitType = i, this.startAt = o, this.endAt = u, this.$ = null,
|
|
2282
2295
|
// The corresponding `Target` of this `Query` instance.
|
|
2283
|
-
this
|
|
2296
|
+
this.F = null, this.startAt, this.endAt;
|
|
2284
2297
|
}
|
|
2285
2298
|
}
|
|
2286
2299
|
|
|
2287
|
-
/** Creates a new Query for a query that matches all documents at `path` */ function
|
|
2288
|
-
return !
|
|
2300
|
+
/** Creates a new Query for a query that matches all documents at `path` */ function un(t) {
|
|
2301
|
+
return !ut(t.limit) && "L" /* Last */ === t.limitType;
|
|
2289
2302
|
}
|
|
2290
2303
|
|
|
2291
|
-
function
|
|
2304
|
+
function cn(t) {
|
|
2292
2305
|
return t.explicitOrderBy.length > 0 ? t.explicitOrderBy[0].field : null;
|
|
2293
2306
|
}
|
|
2294
2307
|
|
|
2295
|
-
function
|
|
2296
|
-
for (const n of t.filters) if (n.
|
|
2308
|
+
function an(t) {
|
|
2309
|
+
for (const n of t.filters) if (n.N()) return n.field;
|
|
2297
2310
|
return null;
|
|
2298
2311
|
}
|
|
2299
2312
|
|
|
@@ -2305,7 +2318,7 @@ function un(t) {
|
|
|
2305
2318
|
* Returns whether the query matches a collection group rather than a specific
|
|
2306
2319
|
* collection.
|
|
2307
2320
|
*/
|
|
2308
|
-
function
|
|
2321
|
+
function hn(t) {
|
|
2309
2322
|
return null !== t.collectionGroup;
|
|
2310
2323
|
}
|
|
2311
2324
|
|
|
@@ -2313,59 +2326,59 @@ function cn(t) {
|
|
|
2313
2326
|
* Returns the implicit order by constraint that is used to execute the Query,
|
|
2314
2327
|
* which can be different from the order by constraints the user provided (e.g.
|
|
2315
2328
|
* the SDK and backend always orders by `__name__`).
|
|
2316
|
-
*/ function
|
|
2329
|
+
*/ function ln(t) {
|
|
2317
2330
|
const n = b(t);
|
|
2318
|
-
if (null === n
|
|
2319
|
-
n
|
|
2320
|
-
const t =
|
|
2331
|
+
if (null === n.$) {
|
|
2332
|
+
n.$ = [];
|
|
2333
|
+
const t = an(n), e = cn(n);
|
|
2321
2334
|
if (null !== t && null === e)
|
|
2322
2335
|
// In order to implicitly add key ordering, we must also add the
|
|
2323
2336
|
// inequality filter field for it to be a valid query.
|
|
2324
2337
|
// Note that the default inequality field and key ordering is ascending.
|
|
2325
|
-
t.isKeyField() || n
|
|
2338
|
+
t.isKeyField() || n.$.push(new en(t)), n.$.push(new en(Z.keyField(), "asc" /* ASCENDING */)); else {
|
|
2326
2339
|
let t = !1;
|
|
2327
|
-
for (const e of n.explicitOrderBy) n
|
|
2340
|
+
for (const e of n.explicitOrderBy) n.$.push(e), e.field.isKeyField() && (t = !0);
|
|
2328
2341
|
if (!t) {
|
|
2329
2342
|
// The order of the implicit key ordering always matches the last
|
|
2330
2343
|
// explicit order by
|
|
2331
2344
|
const t = n.explicitOrderBy.length > 0 ? n.explicitOrderBy[n.explicitOrderBy.length - 1].dir : "asc" /* ASCENDING */;
|
|
2332
|
-
n
|
|
2345
|
+
n.$.push(new en(Z.keyField(), t));
|
|
2333
2346
|
}
|
|
2334
2347
|
}
|
|
2335
2348
|
}
|
|
2336
|
-
return n
|
|
2349
|
+
return n.$;
|
|
2337
2350
|
}
|
|
2338
2351
|
|
|
2339
2352
|
/**
|
|
2340
2353
|
* Converts this `Query` instance to it's corresponding `Target` representation.
|
|
2341
|
-
*/ function
|
|
2354
|
+
*/ function fn(t) {
|
|
2342
2355
|
const n = b(t);
|
|
2343
|
-
if (!n
|
|
2356
|
+
if (!n.F) if ("F" /* First */ === n.limitType) n.F = Gt(n.path, n.collectionGroup, ln(n), n.filters, n.limit, n.startAt, n.endAt); else {
|
|
2344
2357
|
// Flip the orderBy directions since we want the last results
|
|
2345
2358
|
const t = [];
|
|
2346
|
-
for (const e of
|
|
2359
|
+
for (const e of ln(n)) {
|
|
2347
2360
|
const n = "desc" /* DESCENDING */ === e.dir ? "asc" /* ASCENDING */ : "desc" /* DESCENDING */;
|
|
2348
|
-
t.push(new
|
|
2361
|
+
t.push(new en(e.field, n));
|
|
2349
2362
|
}
|
|
2350
2363
|
// We need to swap the cursors to match the now-flipped query ordering.
|
|
2351
|
-
const e = n.endAt ? new
|
|
2364
|
+
const e = n.endAt ? new nn(n.endAt.position, !n.endAt.before) : null, r = n.startAt ? new nn(n.startAt.position, !n.startAt.before) : null;
|
|
2352
2365
|
// Now return as a LimitType.First query.
|
|
2353
|
-
n
|
|
2366
|
+
n.F = Gt(n.path, n.collectionGroup, t, n.filters, n.limit, e, r);
|
|
2354
2367
|
}
|
|
2355
|
-
return n
|
|
2368
|
+
return n.F;
|
|
2356
2369
|
}
|
|
2357
2370
|
|
|
2358
|
-
function
|
|
2371
|
+
function dn(t, n) {
|
|
2359
2372
|
return function(t, n) {
|
|
2360
2373
|
if (t.limit !== n.limit) return !1;
|
|
2361
2374
|
if (t.orderBy.length !== n.orderBy.length) return !1;
|
|
2362
|
-
for (let e = 0; e < t.orderBy.length; e++) if (!
|
|
2375
|
+
for (let e = 0; e < t.orderBy.length; e++) if (!rn(t.orderBy[e], n.orderBy[e])) return !1;
|
|
2363
2376
|
if (t.filters.length !== n.filters.length) return !1;
|
|
2364
2377
|
for (let s = 0; s < t.filters.length; s++) if (e = t.filters[s], r = n.filters[s],
|
|
2365
|
-
e.op !== r.op || !e.field.isEqual(r.field) || !
|
|
2378
|
+
e.op !== r.op || !e.field.isEqual(r.field) || !Ft(e.value, r.value)) return !1;
|
|
2366
2379
|
var e, r;
|
|
2367
|
-
return t.collectionGroup === n.collectionGroup && !!t.path.isEqual(n.path) && !!
|
|
2368
|
-
}(
|
|
2380
|
+
return t.collectionGroup === n.collectionGroup && !!t.path.isEqual(n.path) && !!sn(t.startAt, n.startAt) && sn(t.endAt, n.endAt);
|
|
2381
|
+
}(fn(t), fn(n)) && t.limitType === n.limitType;
|
|
2369
2382
|
}
|
|
2370
2383
|
|
|
2371
2384
|
/**
|
|
@@ -2393,9 +2406,9 @@ function ln(t, n) {
|
|
|
2393
2406
|
* The return value is an IntegerValue if it can safely represent the value,
|
|
2394
2407
|
* otherwise a DoubleValue is returned.
|
|
2395
2408
|
*/
|
|
2396
|
-
function
|
|
2409
|
+
function wn(t, n) {
|
|
2397
2410
|
return function(t) {
|
|
2398
|
-
return "number" == typeof t && Number.isInteger(t) && !
|
|
2411
|
+
return "number" == typeof t && Number.isInteger(t) && !ct(t) && t <= Number.MAX_SAFE_INTEGER && t >= Number.MIN_SAFE_INTEGER;
|
|
2399
2412
|
}(n) ?
|
|
2400
2413
|
/**
|
|
2401
2414
|
* Returns an IntegerValue for `value`.
|
|
@@ -2405,7 +2418,7 @@ function fn(t, n) {
|
|
|
2405
2418
|
integerValue: "" + t
|
|
2406
2419
|
};
|
|
2407
2420
|
}(n) : function(t, n) {
|
|
2408
|
-
if (t.
|
|
2421
|
+
if (t.S) {
|
|
2409
2422
|
if (isNaN(n)) return {
|
|
2410
2423
|
doubleValue: "NaN"
|
|
2411
2424
|
};
|
|
@@ -2417,7 +2430,7 @@ function fn(t, n) {
|
|
|
2417
2430
|
};
|
|
2418
2431
|
}
|
|
2419
2432
|
return {
|
|
2420
|
-
doubleValue:
|
|
2433
|
+
doubleValue: ct(n) ? "-0" : n
|
|
2421
2434
|
};
|
|
2422
2435
|
}(t, n);
|
|
2423
2436
|
}
|
|
@@ -2438,7 +2451,7 @@ function fn(t, n) {
|
|
|
2438
2451
|
* See the License for the specific language governing permissions and
|
|
2439
2452
|
* limitations under the License.
|
|
2440
2453
|
*/
|
|
2441
|
-
/** Used to represent a field transform on a mutation. */ class
|
|
2454
|
+
/** Used to represent a field transform on a mutation. */ class mn {
|
|
2442
2455
|
constructor() {
|
|
2443
2456
|
// Make sure that the structural type of `TransformOperation` is unique.
|
|
2444
2457
|
// See https://github.com/microsoft/TypeScript/issues/5451
|
|
@@ -2446,15 +2459,15 @@ function fn(t, n) {
|
|
|
2446
2459
|
}
|
|
2447
2460
|
}
|
|
2448
2461
|
|
|
2449
|
-
/** Transforms a value into a server-generated timestamp. */ class
|
|
2462
|
+
/** Transforms a value into a server-generated timestamp. */ class pn extends mn {}
|
|
2450
2463
|
|
|
2451
|
-
/** Transforms an array value via a union operation. */ class
|
|
2464
|
+
/** Transforms an array value via a union operation. */ class yn extends mn {
|
|
2452
2465
|
constructor(t) {
|
|
2453
2466
|
super(), this.elements = t;
|
|
2454
2467
|
}
|
|
2455
2468
|
}
|
|
2456
2469
|
|
|
2457
|
-
/** Transforms an array value via a remove operation. */ class
|
|
2470
|
+
/** Transforms an array value via a remove operation. */ class _n extends mn {
|
|
2458
2471
|
constructor(t) {
|
|
2459
2472
|
super(), this.elements = t;
|
|
2460
2473
|
}
|
|
@@ -2465,9 +2478,9 @@ function fn(t, n) {
|
|
|
2465
2478
|
* transforms. Converts all field values to integers or doubles, but unlike the
|
|
2466
2479
|
* backend does not cap integer values at 2^63. Instead, JavaScript number
|
|
2467
2480
|
* arithmetic is used and precision loss can occur for values greater than 2^53.
|
|
2468
|
-
*/ class
|
|
2481
|
+
*/ class gn extends mn {
|
|
2469
2482
|
constructor(t, n) {
|
|
2470
|
-
super(), this.
|
|
2483
|
+
super(), this.q = t, this.O = n;
|
|
2471
2484
|
}
|
|
2472
2485
|
}
|
|
2473
2486
|
|
|
@@ -2487,7 +2500,7 @@ function fn(t, n) {
|
|
|
2487
2500
|
* See the License for the specific language governing permissions and
|
|
2488
2501
|
* limitations under the License.
|
|
2489
2502
|
*/
|
|
2490
|
-
/** A field path and the TransformOperation to perform upon it. */ class
|
|
2503
|
+
/** A field path and the TransformOperation to perform upon it. */ class bn {
|
|
2491
2504
|
constructor(t, n) {
|
|
2492
2505
|
this.field = t, this.transform = n;
|
|
2493
2506
|
}
|
|
@@ -2497,18 +2510,18 @@ function fn(t, n) {
|
|
|
2497
2510
|
* Encodes a precondition for a mutation. This follows the model that the
|
|
2498
2511
|
* backend accepts with the special case of an explicit "empty" precondition
|
|
2499
2512
|
* (meaning no precondition).
|
|
2500
|
-
*/ class
|
|
2513
|
+
*/ class vn {
|
|
2501
2514
|
constructor(t, n) {
|
|
2502
2515
|
this.updateTime = t, this.exists = n;
|
|
2503
2516
|
}
|
|
2504
2517
|
/** Creates a new empty Precondition. */ static none() {
|
|
2505
|
-
return new
|
|
2518
|
+
return new vn;
|
|
2506
2519
|
}
|
|
2507
2520
|
/** Creates a new Precondition with an exists flag. */ static exists(t) {
|
|
2508
|
-
return new
|
|
2521
|
+
return new vn(void 0, t);
|
|
2509
2522
|
}
|
|
2510
2523
|
/** Creates a new Precondition based on a version a document exists at. */ static updateTime(t) {
|
|
2511
|
-
return new
|
|
2524
|
+
return new vn(t);
|
|
2512
2525
|
}
|
|
2513
2526
|
/** Returns whether this Precondition is empty. */ get isNone() {
|
|
2514
2527
|
return void 0 === this.updateTime && void 0 === this.exists;
|
|
@@ -2561,12 +2574,12 @@ function fn(t, n) {
|
|
|
2561
2574
|
* applyToLocalView() to implement the actual behavior of applying the mutation
|
|
2562
2575
|
* to some source document (see `setMutationApplyToRemoteDocument()` for an
|
|
2563
2576
|
* example).
|
|
2564
|
-
*/ class
|
|
2577
|
+
*/ class En {}
|
|
2565
2578
|
|
|
2566
2579
|
/**
|
|
2567
2580
|
* A mutation that creates or replaces the document at the given key with the
|
|
2568
2581
|
* object value contents.
|
|
2569
|
-
*/ class
|
|
2582
|
+
*/ class Tn extends En {
|
|
2570
2583
|
constructor(t, n, e, r = []) {
|
|
2571
2584
|
super(), this.key = t, this.value = n, this.precondition = e, this.fieldTransforms = r,
|
|
2572
2585
|
this.type = 0 /* Set */;
|
|
@@ -2585,14 +2598,14 @@ function fn(t, n) {
|
|
|
2585
2598
|
* is deleted.
|
|
2586
2599
|
* * When a field is not in the mask but is in the values, the values map is
|
|
2587
2600
|
* ignored.
|
|
2588
|
-
*/ class
|
|
2601
|
+
*/ class In extends En {
|
|
2589
2602
|
constructor(t, n, e, r, s = []) {
|
|
2590
2603
|
super(), this.key = t, this.data = n, this.fieldMask = e, this.precondition = r,
|
|
2591
2604
|
this.fieldTransforms = s, this.type = 1 /* Patch */;
|
|
2592
2605
|
}
|
|
2593
2606
|
}
|
|
2594
2607
|
|
|
2595
|
-
/** A mutation that deletes the document at the given key. */ class
|
|
2608
|
+
/** A mutation that deletes the document at the given key. */ class An extends En {
|
|
2596
2609
|
constructor(t, n) {
|
|
2597
2610
|
super(), this.key = t, this.precondition = n, this.type = 2 /* Delete */ , this.fieldTransforms = [];
|
|
2598
2611
|
}
|
|
@@ -2604,7 +2617,7 @@ function fn(t, n) {
|
|
|
2604
2617
|
*
|
|
2605
2618
|
* The `verify` operation is only used in Transactions, and this class serves
|
|
2606
2619
|
* primarily to facilitate serialization into protos.
|
|
2607
|
-
*/ class
|
|
2620
|
+
*/ class Pn extends En {
|
|
2608
2621
|
constructor(t, n) {
|
|
2609
2622
|
super(), this.key = t, this.precondition = n, this.type = 3 /* Verify */ , this.fieldTransforms = [];
|
|
2610
2623
|
}
|
|
@@ -2625,13 +2638,13 @@ function fn(t, n) {
|
|
|
2625
2638
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2626
2639
|
* See the License for the specific language governing permissions and
|
|
2627
2640
|
* limitations under the License.
|
|
2628
|
-
*/ const
|
|
2641
|
+
*/ const Rn = (() => {
|
|
2629
2642
|
const t = {
|
|
2630
2643
|
asc: "ASCENDING",
|
|
2631
2644
|
desc: "DESCENDING"
|
|
2632
2645
|
};
|
|
2633
2646
|
return t;
|
|
2634
|
-
})(),
|
|
2647
|
+
})(), Vn = (() => {
|
|
2635
2648
|
const t = {
|
|
2636
2649
|
"<": "LESS_THAN",
|
|
2637
2650
|
"<=": "LESS_THAN_OR_EQUAL",
|
|
@@ -2661,9 +2674,9 @@ function fn(t, n) {
|
|
|
2661
2674
|
* TODO(klimt): We can remove the databaseId argument if we keep the full
|
|
2662
2675
|
* resource name in documents.
|
|
2663
2676
|
*/
|
|
2664
|
-
class
|
|
2677
|
+
class Dn {
|
|
2665
2678
|
constructor(t, n) {
|
|
2666
|
-
this.databaseId = t, this.
|
|
2679
|
+
this.databaseId = t, this.S = n;
|
|
2667
2680
|
}
|
|
2668
2681
|
}
|
|
2669
2682
|
|
|
@@ -2678,8 +2691,8 @@ class Rn {
|
|
|
2678
2691
|
/**
|
|
2679
2692
|
* Returns a value for a Date that's appropriate to put into a proto.
|
|
2680
2693
|
*/
|
|
2681
|
-
function
|
|
2682
|
-
if (t.
|
|
2694
|
+
function Nn(t, n) {
|
|
2695
|
+
if (t.S) {
|
|
2683
2696
|
return `${new Date(1e3 * n.seconds).toISOString().replace(/\.\d*/, "").replace("Z", "")}.${("000000000" + n.nanoseconds).slice(-9)}Z`;
|
|
2684
2697
|
}
|
|
2685
2698
|
return {
|
|
@@ -2693,129 +2706,129 @@ function Vn(t, n) {
|
|
|
2693
2706
|
*
|
|
2694
2707
|
* Visible for testing.
|
|
2695
2708
|
*/
|
|
2696
|
-
function
|
|
2697
|
-
return t.
|
|
2709
|
+
function $n(t, n) {
|
|
2710
|
+
return t.S ? n.toBase64() : n.toUint8Array();
|
|
2698
2711
|
}
|
|
2699
2712
|
|
|
2700
|
-
function
|
|
2701
|
-
return
|
|
2713
|
+
function Fn(t, n) {
|
|
2714
|
+
return Nn(t, n.toTimestamp());
|
|
2702
2715
|
}
|
|
2703
2716
|
|
|
2704
|
-
function
|
|
2705
|
-
return g(!!t),
|
|
2706
|
-
const n =
|
|
2707
|
-
return new
|
|
2717
|
+
function Sn(t) {
|
|
2718
|
+
return g(!!t), gt.fromTimestamp(function(t) {
|
|
2719
|
+
const n = At(t);
|
|
2720
|
+
return new _t(n.seconds, n.nanos);
|
|
2708
2721
|
}(t));
|
|
2709
2722
|
}
|
|
2710
2723
|
|
|
2711
|
-
function
|
|
2724
|
+
function qn(t, n) {
|
|
2712
2725
|
return function(t) {
|
|
2713
|
-
return new
|
|
2726
|
+
return new J([ "projects", t.projectId, "databases", t.database ]);
|
|
2714
2727
|
}(t).child("documents").child(n).canonicalString();
|
|
2715
2728
|
}
|
|
2716
2729
|
|
|
2717
|
-
function
|
|
2718
|
-
return
|
|
2730
|
+
function xn(t, n) {
|
|
2731
|
+
return qn(t.databaseId, n.path);
|
|
2719
2732
|
}
|
|
2720
2733
|
|
|
2721
|
-
function
|
|
2734
|
+
function On(t, n) {
|
|
2722
2735
|
const e = function(t) {
|
|
2723
|
-
const n =
|
|
2724
|
-
return g(
|
|
2736
|
+
const n = J.fromString(t);
|
|
2737
|
+
return g(Yn(n)), n;
|
|
2725
2738
|
}(n);
|
|
2726
2739
|
if (e.get(1) !== t.databaseId.projectId) throw new L(I, "Tried to deserialize key from different project: " + e.get(1) + " vs " + t.databaseId.projectId);
|
|
2727
2740
|
if (e.get(3) !== t.databaseId.database) throw new L(I, "Tried to deserialize key from different database: " + e.get(3) + " vs " + t.databaseId.database);
|
|
2728
|
-
return new
|
|
2741
|
+
return new tt((g((r = e).length > 4 && "documents" === r.get(4)), r.popFirst(5)));
|
|
2729
2742
|
var r;
|
|
2730
2743
|
/** Creates a Document proto from key and fields (but no create/update time) */}
|
|
2731
2744
|
|
|
2732
|
-
function
|
|
2733
|
-
return
|
|
2745
|
+
function Cn(t, n) {
|
|
2746
|
+
return qn(t.databaseId, n);
|
|
2734
2747
|
}
|
|
2735
2748
|
|
|
2736
|
-
function
|
|
2737
|
-
return new
|
|
2749
|
+
function Ln(t) {
|
|
2750
|
+
return new J([ "projects", t.databaseId.projectId, "databases", t.databaseId.database ]).canonicalString();
|
|
2738
2751
|
}
|
|
2739
2752
|
|
|
2740
|
-
function
|
|
2753
|
+
function Un(t, n, e) {
|
|
2741
2754
|
return {
|
|
2742
|
-
name:
|
|
2755
|
+
name: xn(t, n),
|
|
2743
2756
|
fields: e.value.mapValue.fields
|
|
2744
2757
|
};
|
|
2745
2758
|
}
|
|
2746
2759
|
|
|
2747
|
-
function
|
|
2760
|
+
function kn(t, n) {
|
|
2748
2761
|
return "found" in n ? function(t, n) {
|
|
2749
2762
|
g(!!n.found), n.found.name, n.found.updateTime;
|
|
2750
|
-
const e =
|
|
2763
|
+
const e = On(t, n.found.name), r = Sn(n.found.updateTime), s = new Mt({
|
|
2751
2764
|
mapValue: {
|
|
2752
2765
|
fields: n.found.fields
|
|
2753
2766
|
}
|
|
2754
2767
|
});
|
|
2755
|
-
return
|
|
2768
|
+
return Bt.newFoundDocument(e, r, s);
|
|
2756
2769
|
}(t, n) : "missing" in n ? function(t, n) {
|
|
2757
2770
|
g(!!n.missing), g(!!n.readTime);
|
|
2758
|
-
const e =
|
|
2759
|
-
return
|
|
2771
|
+
const e = On(t, n.missing), r = Sn(n.readTime);
|
|
2772
|
+
return Bt.newNoDocument(e, r);
|
|
2760
2773
|
}(t, n) : _();
|
|
2761
2774
|
}
|
|
2762
2775
|
|
|
2763
|
-
function
|
|
2776
|
+
function jn(t, n) {
|
|
2764
2777
|
let e;
|
|
2765
|
-
if (n instanceof
|
|
2766
|
-
update:
|
|
2767
|
-
}; else if (n instanceof
|
|
2768
|
-
delete:
|
|
2769
|
-
}; else if (n instanceof
|
|
2770
|
-
update:
|
|
2771
|
-
updateMask:
|
|
2778
|
+
if (n instanceof Tn) e = {
|
|
2779
|
+
update: Un(t, n.key, n.value)
|
|
2780
|
+
}; else if (n instanceof An) e = {
|
|
2781
|
+
delete: xn(t, n.key)
|
|
2782
|
+
}; else if (n instanceof In) e = {
|
|
2783
|
+
update: Un(t, n.key, n.data),
|
|
2784
|
+
updateMask: Wn(n.fieldMask)
|
|
2772
2785
|
}; else {
|
|
2773
|
-
if (!(n instanceof
|
|
2786
|
+
if (!(n instanceof Pn)) return _();
|
|
2774
2787
|
e = {
|
|
2775
|
-
verify:
|
|
2788
|
+
verify: xn(t, n.key)
|
|
2776
2789
|
};
|
|
2777
2790
|
}
|
|
2778
2791
|
return n.fieldTransforms.length > 0 && (e.updateTransforms = n.fieldTransforms.map((t => function(t, n) {
|
|
2779
2792
|
const e = n.transform;
|
|
2780
|
-
if (e instanceof
|
|
2793
|
+
if (e instanceof pn) return {
|
|
2781
2794
|
fieldPath: n.field.canonicalString(),
|
|
2782
2795
|
setToServerValue: "REQUEST_TIME"
|
|
2783
2796
|
};
|
|
2784
|
-
if (e instanceof
|
|
2797
|
+
if (e instanceof yn) return {
|
|
2785
2798
|
fieldPath: n.field.canonicalString(),
|
|
2786
2799
|
appendMissingElements: {
|
|
2787
2800
|
values: e.elements
|
|
2788
2801
|
}
|
|
2789
2802
|
};
|
|
2790
|
-
if (e instanceof
|
|
2803
|
+
if (e instanceof _n) return {
|
|
2791
2804
|
fieldPath: n.field.canonicalString(),
|
|
2792
2805
|
removeAllFromArray: {
|
|
2793
2806
|
values: e.elements
|
|
2794
2807
|
}
|
|
2795
2808
|
};
|
|
2796
|
-
if (e instanceof
|
|
2809
|
+
if (e instanceof gn) return {
|
|
2797
2810
|
fieldPath: n.field.canonicalString(),
|
|
2798
|
-
increment: e.
|
|
2811
|
+
increment: e.O
|
|
2799
2812
|
};
|
|
2800
2813
|
throw _();
|
|
2801
2814
|
}(0, t)))), n.precondition.isNone || (e.currentDocument = function(t, n) {
|
|
2802
2815
|
return void 0 !== n.updateTime ? {
|
|
2803
|
-
updateTime:
|
|
2816
|
+
updateTime: Fn(t, n.updateTime)
|
|
2804
2817
|
} : void 0 !== n.exists ? {
|
|
2805
2818
|
exists: n.exists
|
|
2806
2819
|
} : _();
|
|
2807
2820
|
}(t, n.precondition)), e;
|
|
2808
2821
|
}
|
|
2809
2822
|
|
|
2810
|
-
function
|
|
2823
|
+
function Mn(t, n) {
|
|
2811
2824
|
// Dissect the path into parent, collectionId, and optional key filter.
|
|
2812
2825
|
const e = {
|
|
2813
2826
|
structuredQuery: {}
|
|
2814
2827
|
}, r = n.path;
|
|
2815
|
-
null !== n.collectionGroup ? (e.parent =
|
|
2828
|
+
null !== n.collectionGroup ? (e.parent = Cn(t, r), e.structuredQuery.from = [ {
|
|
2816
2829
|
collectionId: n.collectionGroup,
|
|
2817
2830
|
allDescendants: !0
|
|
2818
|
-
} ]) : (e.parent =
|
|
2831
|
+
} ]) : (e.parent = Cn(t, r.popLast()), e.structuredQuery.from = [ {
|
|
2819
2832
|
collectionId: r.lastSegment()
|
|
2820
2833
|
} ]);
|
|
2821
2834
|
const s = function(t) {
|
|
@@ -2824,26 +2837,26 @@ function jn(t, n) {
|
|
|
2824
2837
|
// visible for testing
|
|
2825
2838
|
function(t) {
|
|
2826
2839
|
if ("==" /* EQUAL */ === t.op) {
|
|
2827
|
-
if (
|
|
2840
|
+
if (Ut(t.value)) return {
|
|
2828
2841
|
unaryFilter: {
|
|
2829
2842
|
field: Qn(t.field),
|
|
2830
2843
|
op: "IS_NAN"
|
|
2831
2844
|
}
|
|
2832
2845
|
};
|
|
2833
|
-
if (
|
|
2846
|
+
if (Lt(t.value)) return {
|
|
2834
2847
|
unaryFilter: {
|
|
2835
2848
|
field: Qn(t.field),
|
|
2836
2849
|
op: "IS_NULL"
|
|
2837
2850
|
}
|
|
2838
2851
|
};
|
|
2839
2852
|
} else if ("!=" /* NOT_EQUAL */ === t.op) {
|
|
2840
|
-
if (
|
|
2853
|
+
if (Ut(t.value)) return {
|
|
2841
2854
|
unaryFilter: {
|
|
2842
2855
|
field: Qn(t.field),
|
|
2843
2856
|
op: "IS_NOT_NAN"
|
|
2844
2857
|
}
|
|
2845
2858
|
};
|
|
2846
|
-
if (
|
|
2859
|
+
if (Lt(t.value)) return {
|
|
2847
2860
|
unaryFilter: {
|
|
2848
2861
|
field: Qn(t.field),
|
|
2849
2862
|
op: "IS_NOT_NULL"
|
|
@@ -2853,7 +2866,7 @@ function jn(t, n) {
|
|
|
2853
2866
|
return {
|
|
2854
2867
|
fieldFilter: {
|
|
2855
2868
|
field: Qn(t.field),
|
|
2856
|
-
op:
|
|
2869
|
+
op: Gn(t.op),
|
|
2857
2870
|
value: t.value
|
|
2858
2871
|
}
|
|
2859
2872
|
};
|
|
@@ -2874,21 +2887,21 @@ function jn(t, n) {
|
|
|
2874
2887
|
function(t) {
|
|
2875
2888
|
return {
|
|
2876
2889
|
field: Qn(t.field),
|
|
2877
|
-
direction:
|
|
2890
|
+
direction: zn(t.dir)
|
|
2878
2891
|
};
|
|
2879
2892
|
}(t)));
|
|
2880
2893
|
}(n.orderBy);
|
|
2881
2894
|
i && (e.structuredQuery.orderBy = i);
|
|
2882
2895
|
const o = function(t, n) {
|
|
2883
|
-
return t.
|
|
2896
|
+
return t.S || ut(n) ? n : {
|
|
2884
2897
|
value: n
|
|
2885
2898
|
};
|
|
2886
2899
|
}(t, n.limit);
|
|
2887
|
-
return null !== o && (e.structuredQuery.limit = o), n.startAt && (e.structuredQuery.startAt =
|
|
2888
|
-
n.endAt && (e.structuredQuery.endAt =
|
|
2900
|
+
return null !== o && (e.structuredQuery.limit = o), n.startAt && (e.structuredQuery.startAt = Bn(n.startAt)),
|
|
2901
|
+
n.endAt && (e.structuredQuery.endAt = Bn(n.endAt)), e;
|
|
2889
2902
|
}
|
|
2890
2903
|
|
|
2891
|
-
function
|
|
2904
|
+
function Bn(t) {
|
|
2892
2905
|
return {
|
|
2893
2906
|
before: t.before,
|
|
2894
2907
|
values: t.position
|
|
@@ -2896,13 +2909,13 @@ function kn(t) {
|
|
|
2896
2909
|
}
|
|
2897
2910
|
|
|
2898
2911
|
// visible for testing
|
|
2899
|
-
function
|
|
2900
|
-
return
|
|
2912
|
+
function zn(t) {
|
|
2913
|
+
return Rn[t];
|
|
2901
2914
|
}
|
|
2902
2915
|
|
|
2903
2916
|
// visible for testing
|
|
2904
|
-
function
|
|
2905
|
-
return
|
|
2917
|
+
function Gn(t) {
|
|
2918
|
+
return Vn[t];
|
|
2906
2919
|
}
|
|
2907
2920
|
|
|
2908
2921
|
function Qn(t) {
|
|
@@ -2911,14 +2924,14 @@ function Qn(t) {
|
|
|
2911
2924
|
};
|
|
2912
2925
|
}
|
|
2913
2926
|
|
|
2914
|
-
function
|
|
2927
|
+
function Wn(t) {
|
|
2915
2928
|
const n = [];
|
|
2916
2929
|
return t.fields.forEach((t => n.push(t.canonicalString()))), {
|
|
2917
2930
|
fieldPaths: n
|
|
2918
2931
|
};
|
|
2919
2932
|
}
|
|
2920
2933
|
|
|
2921
|
-
function
|
|
2934
|
+
function Yn(t) {
|
|
2922
2935
|
// Resource names have at least 4 components (project ID, database ID)
|
|
2923
2936
|
return t.length >= 4 && "projects" === t.get(0) && "databases" === t.get(2);
|
|
2924
2937
|
}
|
|
@@ -2938,8 +2951,8 @@ function Gn(t) {
|
|
|
2938
2951
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2939
2952
|
* See the License for the specific language governing permissions and
|
|
2940
2953
|
* limitations under the License.
|
|
2941
|
-
*/ function
|
|
2942
|
-
return new
|
|
2954
|
+
*/ function Hn(t) {
|
|
2955
|
+
return new Dn(t, /* useProto3Json= */ !0);
|
|
2943
2956
|
}
|
|
2944
2957
|
|
|
2945
2958
|
/**
|
|
@@ -2967,7 +2980,7 @@ function Gn(t) {
|
|
|
2967
2980
|
* base delay. This prevents clients from accidentally synchronizing their
|
|
2968
2981
|
* delays causing spikes of load to the backend.
|
|
2969
2982
|
*/
|
|
2970
|
-
class
|
|
2983
|
+
class Kn {
|
|
2971
2984
|
constructor(
|
|
2972
2985
|
/**
|
|
2973
2986
|
* The AsyncQueue to run backoff operations on.
|
|
@@ -2992,7 +3005,7 @@ class Hn {
|
|
|
2992
3005
|
* Note that jitter will still be applied, so the actual delay could be as
|
|
2993
3006
|
* much as 1.5*maxDelayMs.
|
|
2994
3007
|
*/ , s = 6e4) {
|
|
2995
|
-
this.
|
|
3008
|
+
this.C = t, this.timerId = n, this.L = e, this.U = r, this.k = s, this.j = 0, this.M = null,
|
|
2996
3009
|
/** The last backoff attempt, as epoch milliseconds. */
|
|
2997
3010
|
this.B = Date.now(), this.reset();
|
|
2998
3011
|
}
|
|
@@ -3008,34 +3021,34 @@ class Hn {
|
|
|
3008
3021
|
/**
|
|
3009
3022
|
* Resets the backoff delay to the maximum delay (e.g. for use after a
|
|
3010
3023
|
* RESOURCE_EXHAUSTED error).
|
|
3011
|
-
*/
|
|
3012
|
-
this.j = this.
|
|
3024
|
+
*/ G() {
|
|
3025
|
+
this.j = this.k;
|
|
3013
3026
|
}
|
|
3014
3027
|
/**
|
|
3015
3028
|
* Returns a promise that resolves after currentDelayMs, and increases the
|
|
3016
3029
|
* delay for any subsequent attempts. If there was a pending backoff operation
|
|
3017
3030
|
* already, it will be canceled.
|
|
3018
|
-
*/
|
|
3031
|
+
*/ W(t) {
|
|
3019
3032
|
// Cancel any pending backoff operation.
|
|
3020
3033
|
this.cancel();
|
|
3021
3034
|
// First schedule using the current base (which may be 0 and should be
|
|
3022
3035
|
// honored as such).
|
|
3023
|
-
const n = Math.floor(this.j + this.
|
|
3036
|
+
const n = Math.floor(this.j + this.Y()), e = Math.max(0, Date.now() - this.B), r = Math.max(0, n - e);
|
|
3024
3037
|
// Guard against lastAttemptTime being in the future due to a clock change.
|
|
3025
3038
|
r > 0 && w("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.j} ms, delay with jitter: ${n} ms, last attempt: ${e} ms ago)`),
|
|
3026
|
-
this.
|
|
3039
|
+
this.M = this.C.enqueueAfterDelay(this.timerId, r, (() => (this.B = Date.now(),
|
|
3027
3040
|
t()))),
|
|
3028
3041
|
// Apply backoff factor to determine next delay and ensure it is within
|
|
3029
3042
|
// bounds.
|
|
3030
|
-
this.j *= this.
|
|
3043
|
+
this.j *= this.U, this.j < this.L && (this.j = this.L), this.j > this.k && (this.j = this.k);
|
|
3031
3044
|
}
|
|
3032
3045
|
H() {
|
|
3033
|
-
null !== this.
|
|
3046
|
+
null !== this.M && (this.M.skipDelay(), this.M = null);
|
|
3034
3047
|
}
|
|
3035
3048
|
cancel() {
|
|
3036
|
-
null !== this.
|
|
3049
|
+
null !== this.M && (this.M.cancel(), this.M = null);
|
|
3037
3050
|
}
|
|
3038
|
-
/** Returns a random value in the range [-currentBaseMs/2, currentBaseMs/2] */
|
|
3051
|
+
/** Returns a random value in the range [-currentBaseMs/2, currentBaseMs/2] */ Y() {
|
|
3039
3052
|
return (Math.random() - .5) * this.j;
|
|
3040
3053
|
}
|
|
3041
3054
|
}
|
|
@@ -3065,45 +3078,46 @@ class Hn {
|
|
|
3065
3078
|
* An implementation of Datastore that exposes additional state for internal
|
|
3066
3079
|
* consumption.
|
|
3067
3080
|
*/
|
|
3068
|
-
class
|
|
3069
|
-
constructor(t, n, e) {
|
|
3070
|
-
super(), this.
|
|
3081
|
+
class Jn extends class {} {
|
|
3082
|
+
constructor(t, n, e, r) {
|
|
3083
|
+
super(), this.authCredentials = t, this.appCheckCredentials = n, this.K = e, this.q = r,
|
|
3084
|
+
this.J = !1;
|
|
3071
3085
|
}
|
|
3072
|
-
|
|
3073
|
-
if (this.
|
|
3086
|
+
X() {
|
|
3087
|
+
if (this.J) throw new L($, "The client has already been terminated.");
|
|
3074
3088
|
}
|
|
3075
|
-
/**
|
|
3076
|
-
return this.
|
|
3077
|
-
throw "FirebaseError" === t.name ? (t.code === D && this.
|
|
3078
|
-
t) : new L(T, t.toString());
|
|
3089
|
+
/** Invokes the provided RPC with auth and AppCheck tokens. */ m(t, n, e) {
|
|
3090
|
+
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.m(t, n, e, r, s))).catch((t => {
|
|
3091
|
+
throw "FirebaseError" === t.name ? (t.code === D && (this.authCredentials.invalidateToken(),
|
|
3092
|
+
this.appCheckCredentials.invalidateToken()), t) : new L(T, t.toString());
|
|
3079
3093
|
}));
|
|
3080
3094
|
}
|
|
3081
|
-
/**
|
|
3082
|
-
return this.
|
|
3083
|
-
throw "FirebaseError" === t.name ? (t.code === D && this.
|
|
3084
|
-
t) : new L(T, t.toString());
|
|
3095
|
+
/** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */ T(t, n, e) {
|
|
3096
|
+
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.T(t, n, e, r, s))).catch((t => {
|
|
3097
|
+
throw "FirebaseError" === t.name ? (t.code === D && (this.authCredentials.invalidateToken(),
|
|
3098
|
+
this.appCheckCredentials.invalidateToken()), t) : new L(T, t.toString());
|
|
3085
3099
|
}));
|
|
3086
3100
|
}
|
|
3087
3101
|
terminate() {
|
|
3088
|
-
this.
|
|
3102
|
+
this.J = !0;
|
|
3089
3103
|
}
|
|
3090
3104
|
}
|
|
3091
3105
|
|
|
3092
3106
|
// TODO(firestorexp): Make sure there is only one Datastore instance per
|
|
3093
3107
|
// firestore-exp client.
|
|
3094
|
-
async function
|
|
3095
|
-
const e = b(t), r =
|
|
3096
|
-
writes: n.map((t =>
|
|
3108
|
+
async function Xn(t, n) {
|
|
3109
|
+
const e = b(t), r = Ln(e.q) + "/documents", s = {
|
|
3110
|
+
writes: n.map((t => jn(e.q, t)))
|
|
3097
3111
|
};
|
|
3098
|
-
await e.
|
|
3112
|
+
await e.m("Commit", r, s);
|
|
3099
3113
|
}
|
|
3100
3114
|
|
|
3101
|
-
async function
|
|
3102
|
-
const e = b(t), r =
|
|
3103
|
-
documents: n.map((t =>
|
|
3104
|
-
}, i = await e.
|
|
3115
|
+
async function Zn(t, n) {
|
|
3116
|
+
const e = b(t), r = Ln(e.q) + "/documents", s = {
|
|
3117
|
+
documents: n.map((t => xn(e.q, t)))
|
|
3118
|
+
}, i = await e.T("BatchGetDocuments", r, s), o = new Map;
|
|
3105
3119
|
i.forEach((t => {
|
|
3106
|
-
const n =
|
|
3120
|
+
const n = kn(e.q, t);
|
|
3107
3121
|
o.set(n.key.toString(), n);
|
|
3108
3122
|
}));
|
|
3109
3123
|
const u = [];
|
|
@@ -3113,18 +3127,18 @@ async function Jn(t, n) {
|
|
|
3113
3127
|
})), u;
|
|
3114
3128
|
}
|
|
3115
3129
|
|
|
3116
|
-
async function
|
|
3117
|
-
const e = b(t), r =
|
|
3118
|
-
return (await e.
|
|
3130
|
+
async function te(t, n) {
|
|
3131
|
+
const e = b(t), r = Mn(e.q, fn(n));
|
|
3132
|
+
return (await e.T("RunQuery", r.parent, {
|
|
3119
3133
|
structuredQuery: r.structuredQuery
|
|
3120
3134
|
})).filter((t => !!t.document)).map((t => function(t, n, e) {
|
|
3121
|
-
const r =
|
|
3135
|
+
const r = On(t, n.name), s = Sn(n.updateTime), i = new Mt({
|
|
3122
3136
|
mapValue: {
|
|
3123
3137
|
fields: n.fields
|
|
3124
3138
|
}
|
|
3125
|
-
}), o =
|
|
3139
|
+
}), o = Bt.newFoundDocument(r, s, i);
|
|
3126
3140
|
return e && o.setHasCommittedMutations(), e ? o.setHasCommittedMutations() : o;
|
|
3127
|
-
}(e.
|
|
3141
|
+
}(e.q, t.document, void 0)));
|
|
3128
3142
|
}
|
|
3129
3143
|
|
|
3130
3144
|
/**
|
|
@@ -3142,7 +3156,7 @@ async function Zn(t, n) {
|
|
|
3142
3156
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3143
3157
|
* See the License for the specific language governing permissions and
|
|
3144
3158
|
* limitations under the License.
|
|
3145
|
-
*/ const
|
|
3159
|
+
*/ const ne = new Map;
|
|
3146
3160
|
|
|
3147
3161
|
/**
|
|
3148
3162
|
* An instance map that ensures only one Datastore exists per Firestore
|
|
@@ -3153,17 +3167,17 @@ async function Zn(t, n) {
|
|
|
3153
3167
|
* instance. Callers must invoke removeComponents() when the Firestore
|
|
3154
3168
|
* instance is terminated.
|
|
3155
3169
|
*/
|
|
3156
|
-
function
|
|
3170
|
+
function ee(t) {
|
|
3157
3171
|
if (t._terminated) throw new L($, "The client has already been terminated.");
|
|
3158
|
-
if (!
|
|
3172
|
+
if (!ne.has(t)) {
|
|
3159
3173
|
w("ComponentProvider", "Initializing Datastore");
|
|
3160
3174
|
const i = function(t) {
|
|
3161
|
-
return new
|
|
3175
|
+
return new dt(t, fetch.bind(null));
|
|
3162
3176
|
}((n = t._databaseId, e = t.app.options.appId || "", r = t._persistenceKey, s = t._freezeSettings(),
|
|
3163
|
-
new
|
|
3164
|
-
return new
|
|
3165
|
-
}(t.
|
|
3166
|
-
|
|
3177
|
+
new Y(n, e, r, s.host, s.ssl, s.experimentalForceLongPolling, s.experimentalAutoDetectLongPolling, s.useFetchStreams))), o = Hn(t._databaseId), u = function(t, n, e, r) {
|
|
3178
|
+
return new Jn(t, n, e, r);
|
|
3179
|
+
}(t._authCredentials, t._appCheckCredentials, i, o);
|
|
3180
|
+
ne.set(t, u);
|
|
3167
3181
|
}
|
|
3168
3182
|
var n, e, r, s;
|
|
3169
3183
|
/**
|
|
@@ -3181,7 +3195,7 @@ function te(t) {
|
|
|
3181
3195
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3182
3196
|
* See the License for the specific language governing permissions and
|
|
3183
3197
|
* limitations under the License.
|
|
3184
|
-
*/ return
|
|
3198
|
+
*/ return ne.get(t);
|
|
3185
3199
|
}
|
|
3186
3200
|
|
|
3187
3201
|
/**
|
|
@@ -3193,7 +3207,7 @@ function te(t) {
|
|
|
3193
3207
|
* user-supplied `FirestoreSettings` object. This is a separate type so that
|
|
3194
3208
|
* defaults can be supplied and the value can be checked for equality.
|
|
3195
3209
|
*/
|
|
3196
|
-
class
|
|
3210
|
+
class re {
|
|
3197
3211
|
constructor(t) {
|
|
3198
3212
|
var n;
|
|
3199
3213
|
if (void 0 === t.host) {
|
|
@@ -3235,18 +3249,18 @@ class ne {
|
|
|
3235
3249
|
* The Cloud Firestore service interface.
|
|
3236
3250
|
*
|
|
3237
3251
|
* Do not call this constructor directly. Instead, use {@link getFirestore}.
|
|
3238
|
-
*/ class
|
|
3252
|
+
*/ class se {
|
|
3239
3253
|
/** @hideconstructor */
|
|
3240
|
-
constructor(t, n) {
|
|
3241
|
-
this.
|
|
3254
|
+
constructor(t, n, e) {
|
|
3255
|
+
this._authCredentials = n, this._appCheckCredentials = e,
|
|
3242
3256
|
/**
|
|
3243
3257
|
* Whether it's a Firestore or Firestore Lite instance.
|
|
3244
3258
|
*/
|
|
3245
|
-
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new
|
|
3246
|
-
this._settingsFrozen = !1, t instanceof
|
|
3259
|
+
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new re({}),
|
|
3260
|
+
this._settingsFrozen = !1, t instanceof H ? this._databaseId = t : (this._app = t,
|
|
3247
3261
|
this._databaseId = function(t) {
|
|
3248
3262
|
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new L(I, '"projectId" not provided in firebase.initializeApp.');
|
|
3249
|
-
return new
|
|
3263
|
+
return new H(t.options.projectId);
|
|
3250
3264
|
}
|
|
3251
3265
|
/**
|
|
3252
3266
|
* Initializes a new instance of Cloud Firestore with the provided settings.
|
|
@@ -3275,20 +3289,20 @@ class ne {
|
|
|
3275
3289
|
}
|
|
3276
3290
|
_setSettings(t) {
|
|
3277
3291
|
if (this._settingsFrozen) throw new L($, "Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");
|
|
3278
|
-
this._settings = new
|
|
3279
|
-
if (!t) return new
|
|
3292
|
+
this._settings = new re(t), void 0 !== t.credentials && (this._authCredentials = function(t) {
|
|
3293
|
+
if (!t) return new j;
|
|
3280
3294
|
switch (t.type) {
|
|
3281
3295
|
case "gapi":
|
|
3282
3296
|
const n = t.client;
|
|
3283
3297
|
// Make sure this really is a Gapi client.
|
|
3284
3298
|
return g(!("object" != typeof n || null === n || !n.auth || !n.auth.getAuthHeaderValueForFirstParty)),
|
|
3285
|
-
new
|
|
3299
|
+
new G(n, t.sessionIndex || "0", t.iamToken || null);
|
|
3286
3300
|
|
|
3287
3301
|
case "provider":
|
|
3288
3302
|
return t.client;
|
|
3289
3303
|
|
|
3290
3304
|
default:
|
|
3291
|
-
throw new L(I, "
|
|
3305
|
+
throw new L(I, "makeAuthCredentialsProvider failed due to invalid credential type");
|
|
3292
3306
|
}
|
|
3293
3307
|
}(t.credentials));
|
|
3294
3308
|
}
|
|
@@ -3316,13 +3330,13 @@ class ne {
|
|
|
3316
3330
|
* Only ever called once.
|
|
3317
3331
|
*/ _terminate() {
|
|
3318
3332
|
return function(t) {
|
|
3319
|
-
const n =
|
|
3320
|
-
n && (w("ComponentProvider", "Removing Datastore"),
|
|
3333
|
+
const n = ne.get(t);
|
|
3334
|
+
n && (w("ComponentProvider", "Removing Datastore"), ne.delete(t), n.terminate());
|
|
3321
3335
|
}(this), Promise.resolve();
|
|
3322
3336
|
}
|
|
3323
3337
|
}
|
|
3324
3338
|
|
|
3325
|
-
function
|
|
3339
|
+
function ie(t, n) {
|
|
3326
3340
|
const e = _getProvider(t, "firestore/lite");
|
|
3327
3341
|
if (e.isInitialized()) throw new L($, "Firestore can only be initialized once per app.");
|
|
3328
3342
|
return e.initialize({
|
|
@@ -3338,7 +3352,7 @@ function re(t, n) {
|
|
|
3338
3352
|
* @param app - The {@link @firebase/app#FirebaseApp} instance that the returned `Firestore`
|
|
3339
3353
|
* instance is associated with.
|
|
3340
3354
|
* @returns The `Firestore` instance of the provided app.
|
|
3341
|
-
*/ function
|
|
3355
|
+
*/ function oe(n = getApp()) {
|
|
3342
3356
|
return _getProvider(n, "firestore/lite").getImmediate();
|
|
3343
3357
|
}
|
|
3344
3358
|
|
|
@@ -3354,9 +3368,9 @@ function re(t, n) {
|
|
|
3354
3368
|
* @param port - the emulator port (ex: 9000).
|
|
3355
3369
|
* @param options.mockUserToken - the mock auth token to use for unit testing
|
|
3356
3370
|
* Security Rules.
|
|
3357
|
-
*/ function
|
|
3371
|
+
*/ function ue(t, n, e, r = {}) {
|
|
3358
3372
|
var s;
|
|
3359
|
-
const i = (t =
|
|
3373
|
+
const i = (t = it(t, se))._getSettings();
|
|
3360
3374
|
if ("firestore.googleapis.com" !== i.host && i.host !== n && p("Host has been set in both settings() and useEmulator(), emulator host will be used"),
|
|
3361
3375
|
t._setSettings(Object.assign(Object.assign({}, i), {
|
|
3362
3376
|
host: `${n}:${e}`,
|
|
@@ -3371,7 +3385,7 @@ function re(t, n) {
|
|
|
3371
3385
|
if (!i) throw new L(I, "mockUserToken must contain 'sub' or 'user_id' field!");
|
|
3372
3386
|
e = new h(i);
|
|
3373
3387
|
}
|
|
3374
|
-
t.
|
|
3388
|
+
t._authCredentials = new M(new k(n, e));
|
|
3375
3389
|
}
|
|
3376
3390
|
}
|
|
3377
3391
|
|
|
@@ -3394,8 +3408,8 @@ function re(t, n) {
|
|
|
3394
3408
|
* @param firestore - The `Firestore` instance to terminate.
|
|
3395
3409
|
* @returns A `Promise` that is resolved when the instance has been successfully
|
|
3396
3410
|
* terminated.
|
|
3397
|
-
*/ function
|
|
3398
|
-
return t =
|
|
3411
|
+
*/ function ce(t) {
|
|
3412
|
+
return t = it(t, se), _removeServiceInstance(t.app, "firestore/lite"), t._delete();
|
|
3399
3413
|
}
|
|
3400
3414
|
|
|
3401
3415
|
/**
|
|
@@ -3435,7 +3449,7 @@ function re(t, n) {
|
|
|
3435
3449
|
* and can be used to write, read, or listen to the location. The document at
|
|
3436
3450
|
* the referenced location may or may not exist.
|
|
3437
3451
|
*/
|
|
3438
|
-
class
|
|
3452
|
+
class ae {
|
|
3439
3453
|
/** @hideconstructor */
|
|
3440
3454
|
constructor(t,
|
|
3441
3455
|
/**
|
|
@@ -3463,17 +3477,17 @@ class ue {
|
|
|
3463
3477
|
/**
|
|
3464
3478
|
* The collection this `DocumentReference` belongs to.
|
|
3465
3479
|
*/ get parent() {
|
|
3466
|
-
return new
|
|
3480
|
+
return new le(this.firestore, this.converter, this._key.path.popLast());
|
|
3467
3481
|
}
|
|
3468
3482
|
withConverter(t) {
|
|
3469
|
-
return new
|
|
3483
|
+
return new ae(this.firestore, t, this._key);
|
|
3470
3484
|
}
|
|
3471
3485
|
}
|
|
3472
3486
|
|
|
3473
3487
|
/**
|
|
3474
3488
|
* A `Query` refers to a query which you can read or listen to. You can also
|
|
3475
3489
|
* construct refined `Query` objects by adding filters and ordering.
|
|
3476
|
-
*/ class
|
|
3490
|
+
*/ class he {
|
|
3477
3491
|
// This is the lite version of the Query class in the main SDK.
|
|
3478
3492
|
/** @hideconstructor protected */
|
|
3479
3493
|
constructor(t,
|
|
@@ -3486,17 +3500,17 @@ class ue {
|
|
|
3486
3500
|
this.type = "query", this.firestore = t;
|
|
3487
3501
|
}
|
|
3488
3502
|
withConverter(t) {
|
|
3489
|
-
return new
|
|
3503
|
+
return new he(this.firestore, t, this._query);
|
|
3490
3504
|
}
|
|
3491
3505
|
}
|
|
3492
3506
|
|
|
3493
3507
|
/**
|
|
3494
3508
|
* A `CollectionReference` object can be used for adding documents, getting
|
|
3495
3509
|
* document references, and querying for documents (using {@link query}).
|
|
3496
|
-
*/ class
|
|
3510
|
+
*/ class le extends he {
|
|
3497
3511
|
/** @hideconstructor */
|
|
3498
3512
|
constructor(t, n, e) {
|
|
3499
|
-
super(t, n, new
|
|
3513
|
+
super(t, n, new on(e)), this._path = e,
|
|
3500
3514
|
/** The type of this Firestore reference. */
|
|
3501
3515
|
this.type = "collection";
|
|
3502
3516
|
}
|
|
@@ -3514,23 +3528,23 @@ class ue {
|
|
|
3514
3528
|
* subcollection. If this isn't a subcollection, the reference is null.
|
|
3515
3529
|
*/ get parent() {
|
|
3516
3530
|
const t = this._path.popLast();
|
|
3517
|
-
return t.isEmpty() ? null : new
|
|
3518
|
-
/* converter= */ null, new
|
|
3531
|
+
return t.isEmpty() ? null : new ae(this.firestore,
|
|
3532
|
+
/* converter= */ null, new tt(t));
|
|
3519
3533
|
}
|
|
3520
3534
|
withConverter(t) {
|
|
3521
|
-
return new
|
|
3535
|
+
return new le(this.firestore, t, this._path);
|
|
3522
3536
|
}
|
|
3523
3537
|
}
|
|
3524
3538
|
|
|
3525
|
-
function
|
|
3526
|
-
if (t = getModularInstance(t),
|
|
3527
|
-
const r =
|
|
3528
|
-
return
|
|
3539
|
+
function fe(t, n, ...e) {
|
|
3540
|
+
if (t = getModularInstance(t), nt("collection", "path", n), t instanceof se) {
|
|
3541
|
+
const r = J.fromString(n, ...e);
|
|
3542
|
+
return rt(r), new le(t, /* converter= */ null, r);
|
|
3529
3543
|
}
|
|
3530
3544
|
{
|
|
3531
|
-
if (!(t instanceof
|
|
3532
|
-
const r = t._path.child(
|
|
3533
|
-
return
|
|
3545
|
+
if (!(t instanceof ae || t instanceof le)) throw new L(I, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3546
|
+
const r = t._path.child(J.fromString(n, ...e));
|
|
3547
|
+
return rt(r), new le(t.firestore,
|
|
3534
3548
|
/* converter= */ null, r);
|
|
3535
3549
|
}
|
|
3536
3550
|
}
|
|
@@ -3547,32 +3561,32 @@ function he(t, n, ...e) {
|
|
|
3547
3561
|
* collection or subcollection with this ID as the last segment of its path
|
|
3548
3562
|
* will be included. Cannot contain a slash.
|
|
3549
3563
|
* @returns The created `Query`.
|
|
3550
|
-
*/ function
|
|
3551
|
-
if (t =
|
|
3552
|
-
return new
|
|
3564
|
+
*/ function de(t, n) {
|
|
3565
|
+
if (t = it(t, se), nt("collectionGroup", "collection id", n), n.indexOf("/") >= 0) throw new L(I, `Invalid collection ID '${n}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);
|
|
3566
|
+
return new he(t,
|
|
3553
3567
|
/* converter= */ null,
|
|
3554
3568
|
/**
|
|
3555
3569
|
* Creates a new Query for a collection group query that matches all documents
|
|
3556
3570
|
* within the provided collection group.
|
|
3557
3571
|
*/
|
|
3558
3572
|
function(t) {
|
|
3559
|
-
return new
|
|
3573
|
+
return new on(J.emptyPath(), t);
|
|
3560
3574
|
}(n));
|
|
3561
3575
|
}
|
|
3562
3576
|
|
|
3563
|
-
function
|
|
3577
|
+
function we(t, n, ...e) {
|
|
3564
3578
|
if (t = getModularInstance(t),
|
|
3565
3579
|
// We allow omission of 'pathString' but explicitly prohibit passing in both
|
|
3566
3580
|
// 'undefined' and 'null'.
|
|
3567
|
-
1 === arguments.length && (n =
|
|
3568
|
-
const r =
|
|
3569
|
-
return
|
|
3570
|
-
/* converter= */ null, new
|
|
3581
|
+
1 === arguments.length && (n = mt.P()), nt("doc", "path", n), t instanceof se) {
|
|
3582
|
+
const r = J.fromString(n, ...e);
|
|
3583
|
+
return et(r), new ae(t,
|
|
3584
|
+
/* converter= */ null, new tt(r));
|
|
3571
3585
|
}
|
|
3572
3586
|
{
|
|
3573
|
-
if (!(t instanceof
|
|
3574
|
-
const r = t._path.child(
|
|
3575
|
-
return
|
|
3587
|
+
if (!(t instanceof ae || t instanceof le)) throw new L(I, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3588
|
+
const r = t._path.child(J.fromString(n, ...e));
|
|
3589
|
+
return et(r), new ae(t.firestore, t instanceof le ? t.converter : null, new tt(r));
|
|
3576
3590
|
}
|
|
3577
3591
|
}
|
|
3578
3592
|
|
|
@@ -3583,8 +3597,8 @@ function fe(t, n, ...e) {
|
|
|
3583
3597
|
* @param right - A reference to compare.
|
|
3584
3598
|
* @returns true if the references point to the same location in the same
|
|
3585
3599
|
* Firestore database.
|
|
3586
|
-
*/ function
|
|
3587
|
-
return t = getModularInstance(t), n = getModularInstance(n), (t instanceof
|
|
3600
|
+
*/ function me(t, n) {
|
|
3601
|
+
return t = getModularInstance(t), n = getModularInstance(n), (t instanceof ae || t instanceof le) && (n instanceof ae || n instanceof le) && (t.firestore === n.firestore && t.path === n.path && t.converter === n.converter);
|
|
3588
3602
|
}
|
|
3589
3603
|
|
|
3590
3604
|
/**
|
|
@@ -3595,8 +3609,8 @@ function fe(t, n, ...e) {
|
|
|
3595
3609
|
* @param right - A `Query` to compare.
|
|
3596
3610
|
* @returns true if the references point to the same location in the same
|
|
3597
3611
|
* Firestore database.
|
|
3598
|
-
*/ function
|
|
3599
|
-
return t = getModularInstance(t), n = getModularInstance(n), t instanceof
|
|
3612
|
+
*/ function pe(t, n) {
|
|
3613
|
+
return t = getModularInstance(t), n = getModularInstance(n), t instanceof he && n instanceof he && (t.firestore === n.firestore && dn(t._query, n._query) && t.converter === n.converter);
|
|
3600
3614
|
}
|
|
3601
3615
|
|
|
3602
3616
|
/**
|
|
@@ -3622,7 +3636,7 @@ function fe(t, n, ...e) {
|
|
|
3622
3636
|
*
|
|
3623
3637
|
* Create a `FieldPath` by providing field names. If more than one field
|
|
3624
3638
|
* name is provided, the path will point to a nested field in a document.
|
|
3625
|
-
*/ class
|
|
3639
|
+
*/ class ye {
|
|
3626
3640
|
/**
|
|
3627
3641
|
* Creates a `FieldPath` from the provided field names. If more than one field
|
|
3628
3642
|
* name is provided, the path will point to a nested field in a document.
|
|
@@ -3631,7 +3645,7 @@ function fe(t, n, ...e) {
|
|
|
3631
3645
|
*/
|
|
3632
3646
|
constructor(...t) {
|
|
3633
3647
|
for (let n = 0; n < t.length; ++n) if (0 === t[n].length) throw new L(I, "Invalid field name at argument $(i + 1). Field names must not be empty.");
|
|
3634
|
-
this._internalPath = new
|
|
3648
|
+
this._internalPath = new Z(t);
|
|
3635
3649
|
}
|
|
3636
3650
|
/**
|
|
3637
3651
|
* Returns true if this `FieldPath` is equal to the provided one.
|
|
@@ -3646,8 +3660,8 @@ function fe(t, n, ...e) {
|
|
|
3646
3660
|
/**
|
|
3647
3661
|
* Returns a special sentinel `FieldPath` to refer to the ID of a document.
|
|
3648
3662
|
* It can be used in queries to sort or filter by the document ID.
|
|
3649
|
-
*/ function
|
|
3650
|
-
return new
|
|
3663
|
+
*/ function _e() {
|
|
3664
|
+
return new ye("__name__");
|
|
3651
3665
|
}
|
|
3652
3666
|
|
|
3653
3667
|
/**
|
|
@@ -3668,7 +3682,7 @@ function fe(t, n, ...e) {
|
|
|
3668
3682
|
*/
|
|
3669
3683
|
/**
|
|
3670
3684
|
* An immutable object representing an array of bytes.
|
|
3671
|
-
*/ class
|
|
3685
|
+
*/ class ge {
|
|
3672
3686
|
/** @hideconstructor */
|
|
3673
3687
|
constructor(t) {
|
|
3674
3688
|
this._byteString = t;
|
|
@@ -3680,7 +3694,7 @@ function fe(t, n, ...e) {
|
|
|
3680
3694
|
* @param base64 - The Base64 string used to create the `Bytes` object.
|
|
3681
3695
|
*/ static fromBase64String(t) {
|
|
3682
3696
|
try {
|
|
3683
|
-
return new
|
|
3697
|
+
return new ge(Tt.fromBase64String(t));
|
|
3684
3698
|
} catch (t) {
|
|
3685
3699
|
throw new L(I, "Failed to construct data from Base64 string: " + t);
|
|
3686
3700
|
}
|
|
@@ -3690,7 +3704,7 @@ function fe(t, n, ...e) {
|
|
|
3690
3704
|
*
|
|
3691
3705
|
* @param array - The Uint8Array used to create the `Bytes` object.
|
|
3692
3706
|
*/ static fromUint8Array(t) {
|
|
3693
|
-
return new
|
|
3707
|
+
return new ge(Tt.fromUint8Array(t));
|
|
3694
3708
|
}
|
|
3695
3709
|
/**
|
|
3696
3710
|
* Returns the underlying bytes as a Base64-encoded string.
|
|
@@ -3742,7 +3756,7 @@ function fe(t, n, ...e) {
|
|
|
3742
3756
|
/**
|
|
3743
3757
|
* Sentinel values that can be used when writing document fields with `set()`
|
|
3744
3758
|
* or `update()`.
|
|
3745
|
-
*/ class
|
|
3759
|
+
*/ class be {
|
|
3746
3760
|
/**
|
|
3747
3761
|
* @param _methodName - The public API endpoint that returns this class.
|
|
3748
3762
|
* @hideconstructor
|
|
@@ -3774,7 +3788,7 @@ function fe(t, n, ...e) {
|
|
|
3774
3788
|
*
|
|
3775
3789
|
* Latitude values are in the range of [-90, 90].
|
|
3776
3790
|
* Longitude values are in the range of [-180, 180].
|
|
3777
|
-
*/ class
|
|
3791
|
+
*/ class ve {
|
|
3778
3792
|
/**
|
|
3779
3793
|
* Creates a new immutable `GeoPoint` object with the provided latitude and
|
|
3780
3794
|
* longitude values.
|
|
@@ -3814,7 +3828,7 @@ function fe(t, n, ...e) {
|
|
|
3814
3828
|
* Actually private to JS consumers of our API, so this function is prefixed
|
|
3815
3829
|
* with an underscore.
|
|
3816
3830
|
*/ _compareTo(t) {
|
|
3817
|
-
return
|
|
3831
|
+
return pt(this._lat, t._lat) || pt(this._long, t._long);
|
|
3818
3832
|
}
|
|
3819
3833
|
}
|
|
3820
3834
|
|
|
@@ -3833,29 +3847,29 @@ function fe(t, n, ...e) {
|
|
|
3833
3847
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3834
3848
|
* See the License for the specific language governing permissions and
|
|
3835
3849
|
* limitations under the License.
|
|
3836
|
-
*/ const
|
|
3850
|
+
*/ const Ee = /^__.*__$/;
|
|
3837
3851
|
|
|
3838
|
-
/** The result of parsing document data (e.g. for a setData call). */ class
|
|
3852
|
+
/** The result of parsing document data (e.g. for a setData call). */ class Te {
|
|
3839
3853
|
constructor(t, n, e) {
|
|
3840
3854
|
this.data = t, this.fieldMask = n, this.fieldTransforms = e;
|
|
3841
3855
|
}
|
|
3842
3856
|
toMutation(t, n) {
|
|
3843
|
-
return null !== this.fieldMask ? new
|
|
3857
|
+
return null !== this.fieldMask ? new In(t, this.data, this.fieldMask, n, this.fieldTransforms) : new Tn(t, this.data, n, this.fieldTransforms);
|
|
3844
3858
|
}
|
|
3845
3859
|
}
|
|
3846
3860
|
|
|
3847
|
-
/** The result of parsing "update" data (i.e. for an updateData call). */ class
|
|
3861
|
+
/** The result of parsing "update" data (i.e. for an updateData call). */ class Ie {
|
|
3848
3862
|
constructor(t,
|
|
3849
3863
|
// The fieldMask does not include document transforms.
|
|
3850
3864
|
n, e) {
|
|
3851
3865
|
this.data = t, this.fieldMask = n, this.fieldTransforms = e;
|
|
3852
3866
|
}
|
|
3853
3867
|
toMutation(t, n) {
|
|
3854
|
-
return new
|
|
3868
|
+
return new In(t, this.data, this.fieldMask, n, this.fieldTransforms);
|
|
3855
3869
|
}
|
|
3856
3870
|
}
|
|
3857
3871
|
|
|
3858
|
-
function
|
|
3872
|
+
function Ae(t) {
|
|
3859
3873
|
switch (t) {
|
|
3860
3874
|
case 0 /* Set */ :
|
|
3861
3875
|
// fall through
|
|
@@ -3873,7 +3887,7 @@ function Te(t) {
|
|
|
3873
3887
|
}
|
|
3874
3888
|
}
|
|
3875
3889
|
|
|
3876
|
-
/** A "context" object passed around while parsing user data. */ class
|
|
3890
|
+
/** A "context" object passed around while parsing user data. */ class Pe {
|
|
3877
3891
|
/**
|
|
3878
3892
|
* Initializes a ParseContext with the given source and path.
|
|
3879
3893
|
*
|
|
@@ -3893,7 +3907,7 @@ function Te(t) {
|
|
|
3893
3907
|
* compromised).
|
|
3894
3908
|
*/
|
|
3895
3909
|
constructor(t, n, e, r, s, i) {
|
|
3896
|
-
this.settings = t, this.databaseId = n, this.
|
|
3910
|
+
this.settings = t, this.databaseId = n, this.q = e, this.ignoreUndefinedProperties = r,
|
|
3897
3911
|
// Minor hack: If fieldTransforms is undefined, we assume this is an
|
|
3898
3912
|
// external call and we need to validate the entire path.
|
|
3899
3913
|
void 0 === s && this.Z(), this.fieldTransforms = s || [], this.fieldMask = i || [];
|
|
@@ -3901,38 +3915,38 @@ function Te(t) {
|
|
|
3901
3915
|
get path() {
|
|
3902
3916
|
return this.settings.path;
|
|
3903
3917
|
}
|
|
3904
|
-
get
|
|
3905
|
-
return this.settings.
|
|
3918
|
+
get tt() {
|
|
3919
|
+
return this.settings.tt;
|
|
3906
3920
|
}
|
|
3907
|
-
/** Returns a new context with the specified settings overwritten. */
|
|
3908
|
-
return new
|
|
3921
|
+
/** Returns a new context with the specified settings overwritten. */ nt(t) {
|
|
3922
|
+
return new Pe(Object.assign(Object.assign({}, this.settings), t), this.databaseId, this.q, this.ignoreUndefinedProperties, this.fieldTransforms, this.fieldMask);
|
|
3909
3923
|
}
|
|
3910
|
-
|
|
3924
|
+
et(t) {
|
|
3911
3925
|
var n;
|
|
3912
|
-
const e = null === (n = this.path) || void 0 === n ? void 0 : n.child(t), r = this.
|
|
3926
|
+
const e = null === (n = this.path) || void 0 === n ? void 0 : n.child(t), r = this.nt({
|
|
3913
3927
|
path: e,
|
|
3914
|
-
|
|
3928
|
+
rt: !1
|
|
3915
3929
|
});
|
|
3916
|
-
return r.
|
|
3930
|
+
return r.st(t), r;
|
|
3917
3931
|
}
|
|
3918
|
-
|
|
3932
|
+
it(t) {
|
|
3919
3933
|
var n;
|
|
3920
|
-
const e = null === (n = this.path) || void 0 === n ? void 0 : n.child(t), r = this.
|
|
3934
|
+
const e = null === (n = this.path) || void 0 === n ? void 0 : n.child(t), r = this.nt({
|
|
3921
3935
|
path: e,
|
|
3922
|
-
|
|
3936
|
+
rt: !1
|
|
3923
3937
|
});
|
|
3924
3938
|
return r.Z(), r;
|
|
3925
3939
|
}
|
|
3926
|
-
|
|
3940
|
+
ot(t) {
|
|
3927
3941
|
// TODO(b/34871131): We don't support array paths right now; so make path
|
|
3928
3942
|
// undefined.
|
|
3929
|
-
return this.
|
|
3943
|
+
return this.nt({
|
|
3930
3944
|
path: void 0,
|
|
3931
|
-
|
|
3945
|
+
rt: !0
|
|
3932
3946
|
});
|
|
3933
3947
|
}
|
|
3934
|
-
|
|
3935
|
-
return Qe(t, this.settings.methodName, this.settings.
|
|
3948
|
+
ut(t) {
|
|
3949
|
+
return Qe(t, this.settings.methodName, this.settings.ct || !1, this.path, this.settings.at);
|
|
3936
3950
|
}
|
|
3937
3951
|
/** Returns 'true' if 'fieldPath' was traversed when creating this context. */ contains(t) {
|
|
3938
3952
|
return void 0 !== this.fieldMask.find((n => t.isPrefixOf(n))) || void 0 !== this.fieldTransforms.find((n => t.isPrefixOf(n.field)));
|
|
@@ -3940,64 +3954,64 @@ function Te(t) {
|
|
|
3940
3954
|
Z() {
|
|
3941
3955
|
// TODO(b/34871131): Remove null check once we have proper paths for fields
|
|
3942
3956
|
// within arrays.
|
|
3943
|
-
if (this.path) for (let t = 0; t < this.path.length; t++) this.
|
|
3957
|
+
if (this.path) for (let t = 0; t < this.path.length; t++) this.st(this.path.get(t));
|
|
3944
3958
|
}
|
|
3945
|
-
|
|
3946
|
-
if (0 === t.length) throw this.
|
|
3947
|
-
if (
|
|
3959
|
+
st(t) {
|
|
3960
|
+
if (0 === t.length) throw this.ut("Document fields must not be empty");
|
|
3961
|
+
if (Ae(this.tt) && Ee.test(t)) throw this.ut('Document fields cannot begin and end with "__"');
|
|
3948
3962
|
}
|
|
3949
3963
|
}
|
|
3950
3964
|
|
|
3951
3965
|
/**
|
|
3952
3966
|
* Helper for parsing raw user input (provided via the API) into internal model
|
|
3953
3967
|
* classes.
|
|
3954
|
-
*/ class
|
|
3968
|
+
*/ class Re {
|
|
3955
3969
|
constructor(t, n, e) {
|
|
3956
|
-
this.databaseId = t, this.ignoreUndefinedProperties = n, this.
|
|
3970
|
+
this.databaseId = t, this.ignoreUndefinedProperties = n, this.q = e || Hn(t);
|
|
3957
3971
|
}
|
|
3958
|
-
/** Creates a new top-level parse context. */
|
|
3959
|
-
return new
|
|
3960
|
-
|
|
3972
|
+
/** Creates a new top-level parse context. */ ht(t, n, e, r = !1) {
|
|
3973
|
+
return new Pe({
|
|
3974
|
+
tt: t,
|
|
3961
3975
|
methodName: n,
|
|
3962
|
-
|
|
3963
|
-
path:
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
}, this.databaseId, this.
|
|
3976
|
+
at: e,
|
|
3977
|
+
path: Z.emptyPath(),
|
|
3978
|
+
rt: !1,
|
|
3979
|
+
ct: r
|
|
3980
|
+
}, this.databaseId, this.q, this.ignoreUndefinedProperties);
|
|
3967
3981
|
}
|
|
3968
3982
|
}
|
|
3969
3983
|
|
|
3970
|
-
function
|
|
3971
|
-
const n = t._freezeSettings(), e =
|
|
3972
|
-
return new
|
|
3984
|
+
function Ve(t) {
|
|
3985
|
+
const n = t._freezeSettings(), e = Hn(t._databaseId);
|
|
3986
|
+
return new Re(t._databaseId, !!n.ignoreUndefinedProperties, e);
|
|
3973
3987
|
}
|
|
3974
3988
|
|
|
3975
|
-
/** Parse document data from a set() call. */ function
|
|
3976
|
-
const o = t.
|
|
3977
|
-
|
|
3978
|
-
const u =
|
|
3989
|
+
/** Parse document data from a set() call. */ function De(t, n, e, r, s, i = {}) {
|
|
3990
|
+
const o = t.ht(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ , n, e, s);
|
|
3991
|
+
Me("Data must be an object, but it was:", o, r);
|
|
3992
|
+
const u = ke(r, o);
|
|
3979
3993
|
let c, a;
|
|
3980
|
-
if (i.merge) c = new
|
|
3994
|
+
if (i.merge) c = new Et(o.fieldMask), a = o.fieldTransforms; else if (i.mergeFields) {
|
|
3981
3995
|
const t = [];
|
|
3982
3996
|
for (const r of i.mergeFields) {
|
|
3983
|
-
const s =
|
|
3997
|
+
const s = Be(n, r, e);
|
|
3984
3998
|
if (!o.contains(s)) throw new L(I, `Field '${s}' is specified in your field mask but missing from your input data.`);
|
|
3985
|
-
|
|
3999
|
+
We(t, s) || t.push(s);
|
|
3986
4000
|
}
|
|
3987
|
-
c = new
|
|
4001
|
+
c = new Et(t), a = o.fieldTransforms.filter((t => c.covers(t.field)));
|
|
3988
4002
|
} else c = null, a = o.fieldTransforms;
|
|
3989
|
-
return new
|
|
4003
|
+
return new Te(new Mt(u), c, a);
|
|
3990
4004
|
}
|
|
3991
4005
|
|
|
3992
|
-
class
|
|
4006
|
+
class Ne extends be {
|
|
3993
4007
|
_toFieldTransform(t) {
|
|
3994
|
-
if (2 /* MergeSet */ !== t.
|
|
4008
|
+
if (2 /* MergeSet */ !== t.tt) throw 1 /* Update */ === t.tt ? t.ut(`${this._methodName}() can only appear at the top level of your update data`) : t.ut(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);
|
|
3995
4009
|
// No transform to add for a delete, but we need to add it to our
|
|
3996
4010
|
// fieldMask so it gets deleted.
|
|
3997
4011
|
return t.fieldMask.push(t.path), null;
|
|
3998
4012
|
}
|
|
3999
4013
|
isEqual(t) {
|
|
4000
|
-
return t instanceof
|
|
4014
|
+
return t instanceof Ne;
|
|
4001
4015
|
}
|
|
4002
4016
|
}
|
|
4003
4017
|
|
|
@@ -4016,32 +4030,32 @@ class Ve extends _e {
|
|
|
4016
4030
|
* context.
|
|
4017
4031
|
* @param context - The parent context.
|
|
4018
4032
|
* @param arrayElement - Whether or not the FieldValue has an array.
|
|
4019
|
-
*/ function
|
|
4020
|
-
return new
|
|
4021
|
-
|
|
4022
|
-
|
|
4033
|
+
*/ function $e(t, n, e) {
|
|
4034
|
+
return new Pe({
|
|
4035
|
+
tt: 3 /* Argument */ ,
|
|
4036
|
+
at: n.settings.at,
|
|
4023
4037
|
methodName: t._methodName,
|
|
4024
|
-
|
|
4025
|
-
}, n.databaseId, n.
|
|
4038
|
+
rt: e
|
|
4039
|
+
}, n.databaseId, n.q, n.ignoreUndefinedProperties);
|
|
4026
4040
|
}
|
|
4027
4041
|
|
|
4028
|
-
class
|
|
4042
|
+
class Fe extends be {
|
|
4029
4043
|
_toFieldTransform(t) {
|
|
4030
|
-
return new
|
|
4044
|
+
return new bn(t.path, new pn);
|
|
4031
4045
|
}
|
|
4032
4046
|
isEqual(t) {
|
|
4033
|
-
return t instanceof
|
|
4047
|
+
return t instanceof Fe;
|
|
4034
4048
|
}
|
|
4035
4049
|
}
|
|
4036
4050
|
|
|
4037
|
-
class
|
|
4051
|
+
class Se extends be {
|
|
4038
4052
|
constructor(t, n) {
|
|
4039
|
-
super(t), this.
|
|
4053
|
+
super(t), this.lt = n;
|
|
4040
4054
|
}
|
|
4041
4055
|
_toFieldTransform(t) {
|
|
4042
|
-
const n =
|
|
4043
|
-
/*array=*/ !0), e = this.
|
|
4044
|
-
return new
|
|
4056
|
+
const n = $e(this, t,
|
|
4057
|
+
/*array=*/ !0), e = this.lt.map((t => Ue(t, n))), r = new yn(e);
|
|
4058
|
+
return new bn(t.path, r);
|
|
4045
4059
|
}
|
|
4046
4060
|
isEqual(t) {
|
|
4047
4061
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4049,14 +4063,14 @@ class $e extends _e {
|
|
|
4049
4063
|
}
|
|
4050
4064
|
}
|
|
4051
4065
|
|
|
4052
|
-
class
|
|
4066
|
+
class qe extends be {
|
|
4053
4067
|
constructor(t, n) {
|
|
4054
|
-
super(t), this.
|
|
4068
|
+
super(t), this.lt = n;
|
|
4055
4069
|
}
|
|
4056
4070
|
_toFieldTransform(t) {
|
|
4057
|
-
const n =
|
|
4058
|
-
/*array=*/ !0), e = this.
|
|
4059
|
-
return new
|
|
4071
|
+
const n = $e(this, t,
|
|
4072
|
+
/*array=*/ !0), e = this.lt.map((t => Ue(t, n))), r = new _n(e);
|
|
4073
|
+
return new bn(t.path, r);
|
|
4060
4074
|
}
|
|
4061
4075
|
isEqual(t) {
|
|
4062
4076
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4064,13 +4078,13 @@ class Fe extends _e {
|
|
|
4064
4078
|
}
|
|
4065
4079
|
}
|
|
4066
4080
|
|
|
4067
|
-
class
|
|
4081
|
+
class xe extends be {
|
|
4068
4082
|
constructor(t, n) {
|
|
4069
|
-
super(t), this.
|
|
4083
|
+
super(t), this.ft = n;
|
|
4070
4084
|
}
|
|
4071
4085
|
_toFieldTransform(t) {
|
|
4072
|
-
const n = new
|
|
4073
|
-
return new
|
|
4086
|
+
const n = new gn(t.q, wn(t.q, this.ft));
|
|
4087
|
+
return new bn(t.path, n);
|
|
4074
4088
|
}
|
|
4075
4089
|
isEqual(t) {
|
|
4076
4090
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4078,50 +4092,50 @@ class Se extends _e {
|
|
|
4078
4092
|
}
|
|
4079
4093
|
}
|
|
4080
4094
|
|
|
4081
|
-
/** Parse update data from an update() call. */ function
|
|
4082
|
-
const s = t.
|
|
4083
|
-
|
|
4084
|
-
const i = [], o =
|
|
4085
|
-
|
|
4086
|
-
const u =
|
|
4095
|
+
/** Parse update data from an update() call. */ function Oe(t, n, e, r) {
|
|
4096
|
+
const s = t.ht(1 /* Update */ , n, e);
|
|
4097
|
+
Me("Data must be an object, but it was:", s, r);
|
|
4098
|
+
const i = [], o = Mt.empty();
|
|
4099
|
+
vt(r, ((t, r) => {
|
|
4100
|
+
const u = Ge(n, t, e);
|
|
4087
4101
|
// For Compat types, we have to "extract" the underlying types before
|
|
4088
4102
|
// performing validation.
|
|
4089
4103
|
r = getModularInstance(r);
|
|
4090
|
-
const c = s.
|
|
4091
|
-
if (r instanceof
|
|
4104
|
+
const c = s.it(u);
|
|
4105
|
+
if (r instanceof Ne)
|
|
4092
4106
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4093
4107
|
i.push(u); else {
|
|
4094
|
-
const t =
|
|
4108
|
+
const t = Ue(r, c);
|
|
4095
4109
|
null != t && (i.push(u), o.set(u, t));
|
|
4096
4110
|
}
|
|
4097
4111
|
}));
|
|
4098
|
-
const u = new
|
|
4099
|
-
return new
|
|
4112
|
+
const u = new Et(i);
|
|
4113
|
+
return new Ie(o, u, s.fieldTransforms);
|
|
4100
4114
|
}
|
|
4101
4115
|
|
|
4102
|
-
/** Parse update data from a list of field/value arguments. */ function
|
|
4103
|
-
const o = t.
|
|
4116
|
+
/** Parse update data from a list of field/value arguments. */ function Ce(t, n, e, r, s, i) {
|
|
4117
|
+
const o = t.ht(1 /* Update */ , n, e), u = [ Be(n, r, e) ], c = [ s ];
|
|
4104
4118
|
if (i.length % 2 != 0) throw new L(I, `Function ${n}() needs to be called with an even number of arguments that alternate between field names and values.`);
|
|
4105
|
-
for (let t = 0; t < i.length; t += 2) u.push(
|
|
4106
|
-
const h = [], l =
|
|
4119
|
+
for (let t = 0; t < i.length; t += 2) u.push(Be(n, i[t])), c.push(i[t + 1]);
|
|
4120
|
+
const h = [], l = Mt.empty();
|
|
4107
4121
|
// We iterate in reverse order to pick the last value for a field if the
|
|
4108
4122
|
// user specified the field multiple times.
|
|
4109
|
-
for (let t = u.length - 1; t >= 0; --t) if (!
|
|
4123
|
+
for (let t = u.length - 1; t >= 0; --t) if (!We(h, u[t])) {
|
|
4110
4124
|
const n = u[t];
|
|
4111
4125
|
let e = c[t];
|
|
4112
4126
|
// For Compat types, we have to "extract" the underlying types before
|
|
4113
4127
|
// performing validation.
|
|
4114
4128
|
e = getModularInstance(e);
|
|
4115
|
-
const r = o.
|
|
4116
|
-
if (e instanceof
|
|
4129
|
+
const r = o.it(n);
|
|
4130
|
+
if (e instanceof Ne)
|
|
4117
4131
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4118
4132
|
h.push(n); else {
|
|
4119
|
-
const t =
|
|
4133
|
+
const t = Ue(e, r);
|
|
4120
4134
|
null != t && (h.push(n), l.set(n, t));
|
|
4121
4135
|
}
|
|
4122
4136
|
}
|
|
4123
|
-
const f = new
|
|
4124
|
-
return new
|
|
4137
|
+
const f = new Et(h);
|
|
4138
|
+
return new Ie(l, f, o.fieldTransforms);
|
|
4125
4139
|
}
|
|
4126
4140
|
|
|
4127
4141
|
/**
|
|
@@ -4130,8 +4144,8 @@ class Se extends _e {
|
|
|
4130
4144
|
*
|
|
4131
4145
|
* @param allowArrays - Whether the query value is an array that may directly
|
|
4132
4146
|
* contain additional arrays (e.g. the operand of an `in` query).
|
|
4133
|
-
*/ function
|
|
4134
|
-
return
|
|
4147
|
+
*/ function Le(t, n, e, r = !1) {
|
|
4148
|
+
return Ue(e, t.ht(r ? 4 /* ArrayArgument */ : 3 /* Argument */ , n));
|
|
4135
4149
|
}
|
|
4136
4150
|
|
|
4137
4151
|
/**
|
|
@@ -4142,12 +4156,12 @@ class Se extends _e {
|
|
|
4142
4156
|
* the source of the data being parsed, etc.
|
|
4143
4157
|
* @returns The parsed value, or null if the value was a FieldValue sentinel
|
|
4144
4158
|
* that should not be included in the resulting parsed data.
|
|
4145
|
-
*/ function
|
|
4146
|
-
if (
|
|
4159
|
+
*/ function Ue(t, n) {
|
|
4160
|
+
if (je(
|
|
4147
4161
|
// Unwrap the API type from the Compat SDK. This will return the API type
|
|
4148
4162
|
// from firestore-exp.
|
|
4149
|
-
t = getModularInstance(t))) return
|
|
4150
|
-
if (t instanceof
|
|
4163
|
+
t = getModularInstance(t))) return Me("Unsupported field value:", n, t), ke(t, n);
|
|
4164
|
+
if (t instanceof be)
|
|
4151
4165
|
// FieldValues usually parse into transforms (except FieldValue.delete())
|
|
4152
4166
|
// in which case we do not want to include this field in our parsed data
|
|
4153
4167
|
// (as doing so will overwrite the field directly prior to the transform
|
|
@@ -4159,8 +4173,8 @@ class Se extends _e {
|
|
|
4159
4173
|
*/
|
|
4160
4174
|
return function(t, n) {
|
|
4161
4175
|
// Sentinels are only supported with writes, and not within arrays.
|
|
4162
|
-
if (!
|
|
4163
|
-
if (!n.path) throw n.
|
|
4176
|
+
if (!Ae(n.tt)) throw n.ut(`${t._methodName}() can only be used with update() and set()`);
|
|
4177
|
+
if (!n.path) throw n.ut(`${t._methodName}() is not currently supported inside arrays`);
|
|
4164
4178
|
const e = t._toFieldTransform(n);
|
|
4165
4179
|
e && n.fieldTransforms.push(e);
|
|
4166
4180
|
}
|
|
@@ -4184,12 +4198,12 @@ class Se extends _e {
|
|
|
4184
4198
|
// the set of values to be included for the IN query) that may directly
|
|
4185
4199
|
// contain additional arrays (each representing an individual field
|
|
4186
4200
|
// value), so we disable this validation.
|
|
4187
|
-
if (n.settings.
|
|
4201
|
+
if (n.settings.rt && 4 /* ArrayArgument */ !== n.tt) throw n.ut("Nested arrays are not supported");
|
|
4188
4202
|
return function(t, n) {
|
|
4189
4203
|
const e = [];
|
|
4190
4204
|
let r = 0;
|
|
4191
4205
|
for (const s of t) {
|
|
4192
|
-
let t =
|
|
4206
|
+
let t = Ue(s, n.ot(r));
|
|
4193
4207
|
null == t && (
|
|
4194
4208
|
// Just include nulls in the array for fields being replaced with a
|
|
4195
4209
|
// sentinel.
|
|
@@ -4208,7 +4222,7 @@ class Se extends _e {
|
|
|
4208
4222
|
if (null === (t = getModularInstance(t))) return {
|
|
4209
4223
|
nullValue: "NULL_VALUE"
|
|
4210
4224
|
};
|
|
4211
|
-
if ("number" == typeof t) return
|
|
4225
|
+
if ("number" == typeof t) return wn(n.q, t);
|
|
4212
4226
|
if ("boolean" == typeof t) return {
|
|
4213
4227
|
booleanValue: t
|
|
4214
4228
|
};
|
|
@@ -4216,37 +4230,37 @@ class Se extends _e {
|
|
|
4216
4230
|
stringValue: t
|
|
4217
4231
|
};
|
|
4218
4232
|
if (t instanceof Date) {
|
|
4219
|
-
const e =
|
|
4233
|
+
const e = _t.fromDate(t);
|
|
4220
4234
|
return {
|
|
4221
|
-
timestampValue:
|
|
4235
|
+
timestampValue: Nn(n.q, e)
|
|
4222
4236
|
};
|
|
4223
4237
|
}
|
|
4224
|
-
if (t instanceof
|
|
4238
|
+
if (t instanceof _t) {
|
|
4225
4239
|
// Firestore backend truncates precision down to microseconds. To ensure
|
|
4226
4240
|
// offline mode works the same with regards to truncation, perform the
|
|
4227
4241
|
// truncation immediately without waiting for the backend to do that.
|
|
4228
|
-
const e = new
|
|
4242
|
+
const e = new _t(t.seconds, 1e3 * Math.floor(t.nanoseconds / 1e3));
|
|
4229
4243
|
return {
|
|
4230
|
-
timestampValue:
|
|
4244
|
+
timestampValue: Nn(n.q, e)
|
|
4231
4245
|
};
|
|
4232
4246
|
}
|
|
4233
|
-
if (t instanceof
|
|
4247
|
+
if (t instanceof ve) return {
|
|
4234
4248
|
geoPointValue: {
|
|
4235
4249
|
latitude: t.latitude,
|
|
4236
4250
|
longitude: t.longitude
|
|
4237
4251
|
}
|
|
4238
4252
|
};
|
|
4239
|
-
if (t instanceof
|
|
4240
|
-
bytesValue:
|
|
4253
|
+
if (t instanceof ge) return {
|
|
4254
|
+
bytesValue: $n(n.q, t._byteString)
|
|
4241
4255
|
};
|
|
4242
|
-
if (t instanceof
|
|
4256
|
+
if (t instanceof ae) {
|
|
4243
4257
|
const e = n.databaseId, r = t.firestore._databaseId;
|
|
4244
|
-
if (!r.isEqual(e)) throw n.
|
|
4258
|
+
if (!r.isEqual(e)) throw n.ut(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${e.projectId}/${e.database}`);
|
|
4245
4259
|
return {
|
|
4246
|
-
referenceValue:
|
|
4260
|
+
referenceValue: qn(t.firestore._databaseId || n.databaseId, t._key.path)
|
|
4247
4261
|
};
|
|
4248
4262
|
}
|
|
4249
|
-
throw n.
|
|
4263
|
+
throw n.ut(`Unsupported field value: ${st(t)}`);
|
|
4250
4264
|
}
|
|
4251
4265
|
/**
|
|
4252
4266
|
* Checks whether an object looks like a JSON object that should be converted
|
|
@@ -4257,13 +4271,13 @@ class Se extends _e {
|
|
|
4257
4271
|
*/ (t, n);
|
|
4258
4272
|
}
|
|
4259
4273
|
|
|
4260
|
-
function
|
|
4274
|
+
function ke(t, n) {
|
|
4261
4275
|
const e = {};
|
|
4262
4276
|
return !function(t) {
|
|
4263
4277
|
for (const n in t) if (Object.prototype.hasOwnProperty.call(t, n)) return !1;
|
|
4264
4278
|
return !0;
|
|
4265
|
-
}(t) ?
|
|
4266
|
-
const s =
|
|
4279
|
+
}(t) ? vt(t, ((t, r) => {
|
|
4280
|
+
const s = Ue(r, n.et(t));
|
|
4267
4281
|
null != s && (e[t] = s);
|
|
4268
4282
|
})) :
|
|
4269
4283
|
// If we encounter an empty object, we explicitly add it to the update
|
|
@@ -4275,27 +4289,27 @@ function Le(t, n) {
|
|
|
4275
4289
|
};
|
|
4276
4290
|
}
|
|
4277
4291
|
|
|
4278
|
-
function
|
|
4279
|
-
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof
|
|
4292
|
+
function je(t) {
|
|
4293
|
+
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof _t || t instanceof ve || t instanceof ge || t instanceof ae || t instanceof be);
|
|
4280
4294
|
}
|
|
4281
4295
|
|
|
4282
|
-
function
|
|
4283
|
-
if (!
|
|
4296
|
+
function Me(t, n, e) {
|
|
4297
|
+
if (!je(e) || !function(t) {
|
|
4284
4298
|
return "object" == typeof t && null !== t && (Object.getPrototypeOf(t) === Object.prototype || null === Object.getPrototypeOf(t));
|
|
4285
4299
|
}(e)) {
|
|
4286
|
-
const r =
|
|
4287
|
-
throw "an object" === r ? n.
|
|
4300
|
+
const r = st(e);
|
|
4301
|
+
throw "an object" === r ? n.ut(t + " a custom object") : n.ut(t + " " + r);
|
|
4288
4302
|
}
|
|
4289
4303
|
}
|
|
4290
4304
|
|
|
4291
4305
|
/**
|
|
4292
4306
|
* Helper that calls fromDotSeparatedString() but wraps any error thrown.
|
|
4293
|
-
*/ function
|
|
4307
|
+
*/ function Be(t, n, e) {
|
|
4294
4308
|
if ((
|
|
4295
4309
|
// If required, replace the FieldPath Compat class with with the firestore-exp
|
|
4296
4310
|
// FieldPath.
|
|
4297
|
-
n = getModularInstance(n)) instanceof
|
|
4298
|
-
if ("string" == typeof n) return
|
|
4311
|
+
n = getModularInstance(n)) instanceof ye) return n._internalPath;
|
|
4312
|
+
if ("string" == typeof n) return Ge(t, n);
|
|
4299
4313
|
throw Qe("Field path arguments must be of type string or FieldPath.", t,
|
|
4300
4314
|
/* hasConverter= */ !1,
|
|
4301
4315
|
/* path= */ void 0, e);
|
|
@@ -4303,7 +4317,7 @@ function je(t, n, e) {
|
|
|
4303
4317
|
|
|
4304
4318
|
/**
|
|
4305
4319
|
* Matches any characters in a field path string that are reserved.
|
|
4306
|
-
*/ const
|
|
4320
|
+
*/ const ze = new RegExp("[~\\*/\\[\\]]");
|
|
4307
4321
|
|
|
4308
4322
|
/**
|
|
4309
4323
|
* Wraps fromDotSeparatedString with an error message about the method that
|
|
@@ -4313,12 +4327,12 @@ function je(t, n, e) {
|
|
|
4313
4327
|
* split on dots.
|
|
4314
4328
|
* @param targetDoc - The document against which the field path will be
|
|
4315
4329
|
* evaluated.
|
|
4316
|
-
*/ function
|
|
4317
|
-
if (n.search(
|
|
4330
|
+
*/ function Ge(t, n, e) {
|
|
4331
|
+
if (n.search(ze) >= 0) throw Qe(`Invalid field path (${n}). Paths must not contain '~', '*', '/', '[', or ']'`, t,
|
|
4318
4332
|
/* hasConverter= */ !1,
|
|
4319
4333
|
/* path= */ void 0, e);
|
|
4320
4334
|
try {
|
|
4321
|
-
return new
|
|
4335
|
+
return new ye(...n.split("."))._internalPath;
|
|
4322
4336
|
} catch (r) {
|
|
4323
4337
|
throw Qe(`Invalid field path (${n}). Paths must not be empty, begin with '.', end with '.', or contain '..'`, t,
|
|
4324
4338
|
/* hasConverter= */ !1,
|
|
@@ -4335,7 +4349,7 @@ function Qe(t, n, e, r, s) {
|
|
|
4335
4349
|
c += ")"), new L(I, u + t + c);
|
|
4336
4350
|
}
|
|
4337
4351
|
|
|
4338
|
-
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function
|
|
4352
|
+
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function We(t, n) {
|
|
4339
4353
|
return t.some((t => t.isEqual(n)));
|
|
4340
4354
|
}
|
|
4341
4355
|
|
|
@@ -4363,7 +4377,7 @@ function Qe(t, n, e, r, s) {
|
|
|
4363
4377
|
* For a `DocumentSnapshot` that points to a non-existing document, any data
|
|
4364
4378
|
* access will return 'undefined'. You can use the `exists()` method to
|
|
4365
4379
|
* explicitly verify a document's existence.
|
|
4366
|
-
*/ class
|
|
4380
|
+
*/ class Ye {
|
|
4367
4381
|
// Note: This class is stripped down version of the DocumentSnapshot in
|
|
4368
4382
|
// the legacy SDK. The changes are:
|
|
4369
4383
|
// - No support for SnapshotMetadata.
|
|
@@ -4379,7 +4393,7 @@ function Qe(t, n, e, r, s) {
|
|
|
4379
4393
|
/**
|
|
4380
4394
|
* The `DocumentReference` for the document included in the `DocumentSnapshot`.
|
|
4381
4395
|
*/ get ref() {
|
|
4382
|
-
return new
|
|
4396
|
+
return new ae(this._firestore, this._converter, this._key);
|
|
4383
4397
|
}
|
|
4384
4398
|
/**
|
|
4385
4399
|
* Signals whether or not the document at the snapshot's location exists.
|
|
@@ -4399,7 +4413,7 @@ function Qe(t, n, e, r, s) {
|
|
|
4399
4413
|
if (this._converter) {
|
|
4400
4414
|
// We only want to use the converter and create a new DocumentSnapshot
|
|
4401
4415
|
// if a converter has been provided.
|
|
4402
|
-
const t = new
|
|
4416
|
+
const t = new He(this._firestore, this._userDataWriter, this._key, this._document,
|
|
4403
4417
|
/* converter= */ null);
|
|
4404
4418
|
return this._converter.fromFirestore(t);
|
|
4405
4419
|
}
|
|
@@ -4419,7 +4433,7 @@ function Qe(t, n, e, r, s) {
|
|
|
4419
4433
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4420
4434
|
get(t) {
|
|
4421
4435
|
if (this._document) {
|
|
4422
|
-
const n = this._document.data.field(
|
|
4436
|
+
const n = this._document.data.field(Xe("DocumentSnapshot.get", t));
|
|
4423
4437
|
if (null !== n) return this._userDataWriter.convertValue(n);
|
|
4424
4438
|
}
|
|
4425
4439
|
}
|
|
@@ -4435,7 +4449,7 @@ function Qe(t, n, e, r, s) {
|
|
|
4435
4449
|
* `DocumentSnapshot`. Since query results contain only existing documents, the
|
|
4436
4450
|
* `exists` property will always be true and `data()` will never return
|
|
4437
4451
|
* 'undefined'.
|
|
4438
|
-
*/ class
|
|
4452
|
+
*/ class He extends Ye {
|
|
4439
4453
|
/**
|
|
4440
4454
|
* Retrieves all fields in the document as an `Object`.
|
|
4441
4455
|
*
|
|
@@ -4453,7 +4467,7 @@ function Qe(t, n, e, r, s) {
|
|
|
4453
4467
|
* array via the `docs` property or enumerated using the `forEach` method. The
|
|
4454
4468
|
* number of documents can be determined via the `empty` and `size`
|
|
4455
4469
|
* properties.
|
|
4456
|
-
*/ class
|
|
4470
|
+
*/ class Ke {
|
|
4457
4471
|
/** @hideconstructor */
|
|
4458
4472
|
constructor(t, n) {
|
|
4459
4473
|
this._docs = n, this.query = t;
|
|
@@ -4484,14 +4498,14 @@ function Qe(t, n, e, r, s) {
|
|
|
4484
4498
|
* @param left - A snapshot to compare.
|
|
4485
4499
|
* @param right - A snapshot to compare.
|
|
4486
4500
|
* @returns true if the snapshots are equal.
|
|
4487
|
-
*/ function
|
|
4488
|
-
return t = getModularInstance(t), n = getModularInstance(n), t instanceof
|
|
4501
|
+
*/ function Je(t, n) {
|
|
4502
|
+
return t = getModularInstance(t), n = getModularInstance(n), t instanceof Ye && n instanceof Ye ? t._firestore === n._firestore && t._key.isEqual(n._key) && (null === t._document ? null === n._document : t._document.isEqual(n._document)) && t._converter === n._converter : t instanceof Ke && n instanceof Ke && (pe(t.query, n.query) && yt(t.docs, n.docs, Je));
|
|
4489
4503
|
}
|
|
4490
4504
|
|
|
4491
4505
|
/**
|
|
4492
4506
|
* Helper that calls `fromDotSeparatedString()` but wraps any error thrown.
|
|
4493
|
-
*/ function
|
|
4494
|
-
return "string" == typeof n ?
|
|
4507
|
+
*/ function Xe(t, n) {
|
|
4508
|
+
return "string" == typeof n ? Ge(t, n) : n instanceof ye ? n._internalPath : n._delegate._internalPath;
|
|
4495
4509
|
}
|
|
4496
4510
|
|
|
4497
4511
|
/**
|
|
@@ -4518,7 +4532,7 @@ function Qe(t, n, e, r, s) {
|
|
|
4518
4532
|
* can then be passed to {@link query} to create a new query instance that
|
|
4519
4533
|
* also contains this `QueryConstraint`.
|
|
4520
4534
|
*/
|
|
4521
|
-
class
|
|
4535
|
+
class Ze {}
|
|
4522
4536
|
|
|
4523
4537
|
/**
|
|
4524
4538
|
* Creates a new immutable instance of {@link Query} that is extended to also include
|
|
@@ -4528,40 +4542,40 @@ class Je {}
|
|
|
4528
4542
|
* @param queryConstraints - The list of {@link QueryConstraint}s to apply.
|
|
4529
4543
|
* @throws if any of the provided query constraints cannot be combined with the
|
|
4530
4544
|
* existing or new constraints.
|
|
4531
|
-
*/ function
|
|
4545
|
+
*/ function tr(t, ...n) {
|
|
4532
4546
|
for (const e of n) t = e._apply(t);
|
|
4533
4547
|
return t;
|
|
4534
4548
|
}
|
|
4535
4549
|
|
|
4536
|
-
class
|
|
4550
|
+
class nr extends Ze {
|
|
4537
4551
|
constructor(t, n, e) {
|
|
4538
|
-
super(), this.
|
|
4552
|
+
super(), this.dt = t, this.wt = n, this.yt = e, this.type = "where";
|
|
4539
4553
|
}
|
|
4540
4554
|
_apply(t) {
|
|
4541
|
-
const n =
|
|
4555
|
+
const n = Ve(t.firestore), e = function(t, n, e, r, s, i, o) {
|
|
4542
4556
|
let u;
|
|
4543
4557
|
if (s.isKeyField()) {
|
|
4544
4558
|
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new L(I, `Invalid Query. You can't perform '${i}' queries on FieldPath.documentId().`);
|
|
4545
4559
|
if ("in" /* IN */ === i || "not-in" /* NOT_IN */ === i) {
|
|
4546
|
-
|
|
4560
|
+
pr(o, i);
|
|
4547
4561
|
const n = [];
|
|
4548
|
-
for (const e of o) n.push(
|
|
4562
|
+
for (const e of o) n.push(mr(r, t, e));
|
|
4549
4563
|
u = {
|
|
4550
4564
|
arrayValue: {
|
|
4551
4565
|
values: n
|
|
4552
4566
|
}
|
|
4553
4567
|
};
|
|
4554
|
-
} else u =
|
|
4555
|
-
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i ||
|
|
4556
|
-
u =
|
|
4568
|
+
} else u = mr(r, t, o);
|
|
4569
|
+
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i || pr(o, i),
|
|
4570
|
+
u = Le(e, n, o,
|
|
4557
4571
|
/* allowArrays= */ "in" /* IN */ === i || "not-in" /* NOT_IN */ === i);
|
|
4558
4572
|
const c = Qt.create(s, i, u);
|
|
4559
4573
|
return function(t, n) {
|
|
4560
|
-
if (n.
|
|
4561
|
-
const e =
|
|
4574
|
+
if (n.N()) {
|
|
4575
|
+
const e = an(t);
|
|
4562
4576
|
if (null !== e && !e.isEqual(n.field)) throw new L(I, `Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '${e.toString()}' and '${n.field.toString()}'`);
|
|
4563
|
-
const r =
|
|
4564
|
-
null !== r &&
|
|
4577
|
+
const r = cn(t);
|
|
4578
|
+
null !== r && yr(t, n.field, r);
|
|
4565
4579
|
}
|
|
4566
4580
|
const e = function(t, n) {
|
|
4567
4581
|
for (const e of t.filters) if (n.indexOf(e.op) >= 0) return e.op;
|
|
@@ -4604,10 +4618,10 @@ class Xe extends Je {
|
|
|
4604
4618
|
// Special case when it's a duplicate op to give a slightly clearer error message.
|
|
4605
4619
|
throw e === n.op ? new L(I, `Invalid query. You cannot use more than one '${n.op.toString()}' filter.`) : new L(I, `Invalid query. You cannot use '${n.op.toString()}' filters with '${e.toString()}' filters.`);
|
|
4606
4620
|
}(t, c), c;
|
|
4607
|
-
}(t._query, "where", n, t.firestore._databaseId, this.
|
|
4608
|
-
return new
|
|
4621
|
+
}(t._query, "where", n, t.firestore._databaseId, this.dt, this.wt, this.yt);
|
|
4622
|
+
return new he(t.firestore, t.converter, function(t, n) {
|
|
4609
4623
|
const e = t.filters.concat([ n ]);
|
|
4610
|
-
return new
|
|
4624
|
+
return new on(t.path, t.collectionGroup, t.explicitOrderBy.slice(), e, t.limit, t.limitType, t.startAt, t.endAt);
|
|
4611
4625
|
}(t._query, e));
|
|
4612
4626
|
}
|
|
4613
4627
|
}
|
|
@@ -4622,25 +4636,25 @@ class Xe extends Je {
|
|
|
4622
4636
|
* "<=", "!=").
|
|
4623
4637
|
* @param value - The value for comparison
|
|
4624
4638
|
* @returns The created {@link Query}.
|
|
4625
|
-
*/ function
|
|
4626
|
-
const r = n, s =
|
|
4627
|
-
return new
|
|
4639
|
+
*/ function er(t, n, e) {
|
|
4640
|
+
const r = n, s = Xe("where", t);
|
|
4641
|
+
return new nr(s, r, e);
|
|
4628
4642
|
}
|
|
4629
4643
|
|
|
4630
|
-
class
|
|
4644
|
+
class rr extends Ze {
|
|
4631
4645
|
constructor(t, n) {
|
|
4632
|
-
super(), this.
|
|
4646
|
+
super(), this.dt = t, this._t = n, this.type = "orderBy";
|
|
4633
4647
|
}
|
|
4634
4648
|
_apply(t) {
|
|
4635
4649
|
const n = function(t, n, e) {
|
|
4636
4650
|
if (null !== t.startAt) throw new L(I, "Invalid query. You must not call startAt() or startAfter() before calling orderBy().");
|
|
4637
4651
|
if (null !== t.endAt) throw new L(I, "Invalid query. You must not call endAt() or endBefore() before calling orderBy().");
|
|
4638
|
-
const r = new
|
|
4652
|
+
const r = new en(n, e);
|
|
4639
4653
|
return function(t, n) {
|
|
4640
|
-
if (null ===
|
|
4654
|
+
if (null === cn(t)) {
|
|
4641
4655
|
// This is the first order by. It must match any inequality.
|
|
4642
|
-
const e =
|
|
4643
|
-
null !== e &&
|
|
4656
|
+
const e = an(t);
|
|
4657
|
+
null !== e && yr(t, e, n.field);
|
|
4644
4658
|
}
|
|
4645
4659
|
}(t, r), r;
|
|
4646
4660
|
}
|
|
@@ -4654,11 +4668,11 @@ class nr extends Je {
|
|
|
4654
4668
|
* Will throw if the document does not contain all fields of the order by
|
|
4655
4669
|
* of the query or if any of the fields in the order by are an uncommitted
|
|
4656
4670
|
* server timestamp.
|
|
4657
|
-
*/ (t._query, this.
|
|
4658
|
-
return new
|
|
4671
|
+
*/ (t._query, this.dt, this._t);
|
|
4672
|
+
return new he(t.firestore, t.converter, function(t, n) {
|
|
4659
4673
|
// TODO(dimond): validate that orderBy does not list the same key twice.
|
|
4660
4674
|
const e = t.explicitOrderBy.concat([ n ]);
|
|
4661
|
-
return new
|
|
4675
|
+
return new on(t.path, t.collectionGroup, e, t.filters.slice(), t.limit, t.limitType, t.startAt, t.endAt);
|
|
4662
4676
|
}(t._query, n));
|
|
4663
4677
|
}
|
|
4664
4678
|
}
|
|
@@ -4671,19 +4685,19 @@ class nr extends Je {
|
|
|
4671
4685
|
* @param directionStr - Optional direction to sort by ('asc' or 'desc'). If
|
|
4672
4686
|
* not specified, order will be ascending.
|
|
4673
4687
|
* @returns The created {@link Query}.
|
|
4674
|
-
*/ function
|
|
4675
|
-
const e = n, r =
|
|
4676
|
-
return new
|
|
4688
|
+
*/ function sr(t, n = "asc") {
|
|
4689
|
+
const e = n, r = Xe("orderBy", t);
|
|
4690
|
+
return new rr(r, e);
|
|
4677
4691
|
}
|
|
4678
4692
|
|
|
4679
|
-
class
|
|
4693
|
+
class ir extends Ze {
|
|
4680
4694
|
constructor(t, n, e) {
|
|
4681
|
-
super(), this.type = t, this.
|
|
4695
|
+
super(), this.type = t, this.gt = n, this.bt = e;
|
|
4682
4696
|
}
|
|
4683
4697
|
_apply(t) {
|
|
4684
|
-
return new
|
|
4685
|
-
return new
|
|
4686
|
-
}(t._query, this.
|
|
4698
|
+
return new he(t.firestore, t.converter, function(t, n, e) {
|
|
4699
|
+
return new on(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), n, e, t.startAt, t.endAt);
|
|
4700
|
+
}(t._query, this.gt, this.bt));
|
|
4687
4701
|
}
|
|
4688
4702
|
}
|
|
4689
4703
|
|
|
@@ -4692,8 +4706,8 @@ class rr extends Je {
|
|
|
4692
4706
|
*
|
|
4693
4707
|
* @param limit - The maximum number of items to return.
|
|
4694
4708
|
* @returns The created {@link Query}.
|
|
4695
|
-
*/ function
|
|
4696
|
-
return
|
|
4709
|
+
*/ function or(t) {
|
|
4710
|
+
return ot("limit", t), new ir("limit", t, "F" /* First */);
|
|
4697
4711
|
}
|
|
4698
4712
|
|
|
4699
4713
|
/**
|
|
@@ -4704,53 +4718,53 @@ class rr extends Je {
|
|
|
4704
4718
|
*
|
|
4705
4719
|
* @param limit - The maximum number of items to return.
|
|
4706
4720
|
* @returns The created {@link Query}.
|
|
4707
|
-
*/ function
|
|
4708
|
-
return
|
|
4721
|
+
*/ function ur(t) {
|
|
4722
|
+
return ot("limitToLast", t), new ir("limitToLast", t, "L" /* Last */);
|
|
4709
4723
|
}
|
|
4710
4724
|
|
|
4711
|
-
class
|
|
4725
|
+
class cr extends Ze {
|
|
4712
4726
|
constructor(t, n, e) {
|
|
4713
|
-
super(), this.type = t, this.
|
|
4727
|
+
super(), this.type = t, this.vt = n, this.Et = e;
|
|
4714
4728
|
}
|
|
4715
4729
|
_apply(t) {
|
|
4716
|
-
const n =
|
|
4717
|
-
return new
|
|
4718
|
-
return new
|
|
4730
|
+
const n = wr(t, this.type, this.vt, this.Et);
|
|
4731
|
+
return new he(t.firestore, t.converter, function(t, n) {
|
|
4732
|
+
return new on(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, n, t.endAt);
|
|
4719
4733
|
}(t._query, n));
|
|
4720
4734
|
}
|
|
4721
4735
|
}
|
|
4722
4736
|
|
|
4723
|
-
function
|
|
4724
|
-
return new
|
|
4737
|
+
function ar(...t) {
|
|
4738
|
+
return new cr("startAt", t, /*before=*/ !0);
|
|
4725
4739
|
}
|
|
4726
4740
|
|
|
4727
|
-
function
|
|
4728
|
-
return new
|
|
4741
|
+
function hr(...t) {
|
|
4742
|
+
return new cr("startAfter", t,
|
|
4729
4743
|
/*before=*/ !1);
|
|
4730
4744
|
}
|
|
4731
4745
|
|
|
4732
|
-
class
|
|
4746
|
+
class lr extends Ze {
|
|
4733
4747
|
constructor(t, n, e) {
|
|
4734
|
-
super(), this.type = t, this.
|
|
4748
|
+
super(), this.type = t, this.vt = n, this.Et = e;
|
|
4735
4749
|
}
|
|
4736
4750
|
_apply(t) {
|
|
4737
|
-
const n =
|
|
4738
|
-
return new
|
|
4739
|
-
return new
|
|
4751
|
+
const n = wr(t, this.type, this.vt, this.Et);
|
|
4752
|
+
return new he(t.firestore, t.converter, function(t, n) {
|
|
4753
|
+
return new on(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, t.startAt, n);
|
|
4740
4754
|
}(t._query, n));
|
|
4741
4755
|
}
|
|
4742
4756
|
}
|
|
4743
4757
|
|
|
4744
|
-
function
|
|
4745
|
-
return new
|
|
4758
|
+
function fr(...t) {
|
|
4759
|
+
return new lr("endBefore", t, /*before=*/ !0);
|
|
4746
4760
|
}
|
|
4747
4761
|
|
|
4748
|
-
function
|
|
4749
|
-
return new
|
|
4762
|
+
function dr(...t) {
|
|
4763
|
+
return new lr("endAt", t, /*before=*/ !1);
|
|
4750
4764
|
}
|
|
4751
4765
|
|
|
4752
|
-
/** Helper function to create a bound from a document or fields */ function
|
|
4753
|
-
if (e[0] = getModularInstance(e[0]), e[0] instanceof
|
|
4766
|
+
/** Helper function to create a bound from a document or fields */ function wr(t, n, e, r) {
|
|
4767
|
+
if (e[0] = getModularInstance(e[0]), e[0] instanceof Ye) return function(t, n, e, r, s) {
|
|
4754
4768
|
if (!r) throw new L(P, `Can't use a DocumentSnapshot that doesn't exist for ${e}().`);
|
|
4755
4769
|
const i = [];
|
|
4756
4770
|
// Because people expect to continue/end a query at the exact document
|
|
@@ -4760,22 +4774,22 @@ function lr(...t) {
|
|
|
4760
4774
|
// the provided document. Without the key (by using the explicit sort
|
|
4761
4775
|
// orders), multiple documents could match the position, yielding duplicate
|
|
4762
4776
|
// results.
|
|
4763
|
-
for (const e of
|
|
4777
|
+
for (const e of ln(t)) if (e.field.isKeyField()) i.push(Ot(n, r.key)); else {
|
|
4764
4778
|
const t = r.data.field(e.field);
|
|
4765
|
-
if (
|
|
4779
|
+
if (Vt(t)) throw new L(I, 'Invalid query. You are trying to start or end a query using a document for which the field "' + e.field + '" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');
|
|
4766
4780
|
if (null === t) {
|
|
4767
4781
|
const t = e.field.canonicalString();
|
|
4768
4782
|
throw new L(I, `Invalid query. You are trying to start or end a query using a document for which the field '${t}' (used as the orderBy) does not exist.`);
|
|
4769
4783
|
}
|
|
4770
4784
|
i.push(t);
|
|
4771
4785
|
}
|
|
4772
|
-
return new
|
|
4786
|
+
return new nn(i, s);
|
|
4773
4787
|
}
|
|
4774
4788
|
/**
|
|
4775
4789
|
* Converts a list of field values to a `Bound` for the given query.
|
|
4776
4790
|
*/ (t._query, t.firestore._databaseId, n, e[0]._document, r);
|
|
4777
4791
|
{
|
|
4778
|
-
const s =
|
|
4792
|
+
const s = Ve(t.firestore);
|
|
4779
4793
|
return function(t, n, e, r, s, i) {
|
|
4780
4794
|
// Use explicit order by's because it has to match the query the user made
|
|
4781
4795
|
const o = t.explicitOrderBy;
|
|
@@ -4785,17 +4799,17 @@ function lr(...t) {
|
|
|
4785
4799
|
const c = s[i];
|
|
4786
4800
|
if (o[i].field.isKeyField()) {
|
|
4787
4801
|
if ("string" != typeof c) throw new L(I, `Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);
|
|
4788
|
-
if (!
|
|
4789
|
-
const e = t.path.child(
|
|
4790
|
-
if (!
|
|
4791
|
-
const s = new
|
|
4792
|
-
u.push(
|
|
4802
|
+
if (!hn(t) && -1 !== c.indexOf("/")) throw new L(I, `Invalid query. When querying a collection and ordering by FieldPath.documentId(), the value passed to ${r}() must be a plain document ID, but '${c}' contains a slash.`);
|
|
4803
|
+
const e = t.path.child(J.fromString(c));
|
|
4804
|
+
if (!tt.isDocumentKey(e)) throw new L(I, `Invalid query. When querying a collection group and ordering by FieldPath.documentId(), the value passed to ${r}() must result in a valid document path, but '${e}' is not because it contains an odd number of segments.`);
|
|
4805
|
+
const s = new tt(e);
|
|
4806
|
+
u.push(Ot(n, s));
|
|
4793
4807
|
} else {
|
|
4794
|
-
const t =
|
|
4808
|
+
const t = Le(e, r, c);
|
|
4795
4809
|
u.push(t);
|
|
4796
4810
|
}
|
|
4797
4811
|
}
|
|
4798
|
-
return new
|
|
4812
|
+
return new nn(u, i);
|
|
4799
4813
|
}
|
|
4800
4814
|
/**
|
|
4801
4815
|
* Parses the given `documentIdValue` into a `ReferenceValue`, throwing
|
|
@@ -4805,27 +4819,27 @@ function lr(...t) {
|
|
|
4805
4819
|
}
|
|
4806
4820
|
}
|
|
4807
4821
|
|
|
4808
|
-
function
|
|
4822
|
+
function mr(t, n, e) {
|
|
4809
4823
|
if ("string" == typeof (e = getModularInstance(e))) {
|
|
4810
4824
|
if ("" === e) throw new L(I, "Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.");
|
|
4811
|
-
if (!
|
|
4812
|
-
const r = n.path.child(
|
|
4813
|
-
if (!
|
|
4814
|
-
return
|
|
4825
|
+
if (!hn(n) && -1 !== e.indexOf("/")) throw new L(I, `Invalid query. When querying a collection by FieldPath.documentId(), you must provide a plain document ID, but '${e}' contains a '/' character.`);
|
|
4826
|
+
const r = n.path.child(J.fromString(e));
|
|
4827
|
+
if (!tt.isDocumentKey(r)) throw new L(I, `Invalid query. When querying a collection group by FieldPath.documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);
|
|
4828
|
+
return Ot(t, new tt(r));
|
|
4815
4829
|
}
|
|
4816
|
-
if (e instanceof
|
|
4817
|
-
throw new L(I, `Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: ${
|
|
4830
|
+
if (e instanceof ae) return Ot(t, e._key);
|
|
4831
|
+
throw new L(I, `Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: ${st(e)}.`);
|
|
4818
4832
|
}
|
|
4819
4833
|
|
|
4820
4834
|
/**
|
|
4821
4835
|
* Validates that the value passed into a disjunctive filter satisfies all
|
|
4822
4836
|
* array requirements.
|
|
4823
|
-
*/ function
|
|
4837
|
+
*/ function pr(t, n) {
|
|
4824
4838
|
if (!Array.isArray(t) || 0 === t.length) throw new L(I, `Invalid Query. A non-empty array is required for '${n.toString()}' filters.`);
|
|
4825
4839
|
if (t.length > 10) throw new L(I, `Invalid Query. '${n.toString()}' filters support a maximum of 10 elements in the value array.`);
|
|
4826
4840
|
}
|
|
4827
4841
|
|
|
4828
|
-
function
|
|
4842
|
+
function yr(t, n, e) {
|
|
4829
4843
|
if (!e.isEqual(n)) throw new L(I, `Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '${n.toString()}' and so you must also use '${n.toString()}' as your first argument to orderBy(), but your first orderBy() is on field '${e.toString()}' instead.`);
|
|
4830
4844
|
}
|
|
4831
4845
|
|
|
@@ -4876,7 +4890,7 @@ function mr(t, n, e) {
|
|
|
4876
4890
|
* their `set()` or fails due to invalid data originating from a `toFirestore()`
|
|
4877
4891
|
* call.
|
|
4878
4892
|
*/
|
|
4879
|
-
function
|
|
4893
|
+
function _r(t, n, e) {
|
|
4880
4894
|
let r;
|
|
4881
4895
|
// Cast to `any` in order to satisfy the union type constraint on
|
|
4882
4896
|
// toFirestore().
|
|
@@ -4885,9 +4899,9 @@ function pr(t, n, e) {
|
|
|
4885
4899
|
r;
|
|
4886
4900
|
}
|
|
4887
4901
|
|
|
4888
|
-
class
|
|
4902
|
+
class gr extends class {
|
|
4889
4903
|
convertValue(t, n = "none") {
|
|
4890
|
-
switch (
|
|
4904
|
+
switch ($t(t)) {
|
|
4891
4905
|
case 0 /* NullValue */ :
|
|
4892
4906
|
return null;
|
|
4893
4907
|
|
|
@@ -4895,7 +4909,7 @@ class yr extends class {
|
|
|
4895
4909
|
return t.booleanValue;
|
|
4896
4910
|
|
|
4897
4911
|
case 2 /* NumberValue */ :
|
|
4898
|
-
return
|
|
4912
|
+
return Pt(t.integerValue || t.doubleValue);
|
|
4899
4913
|
|
|
4900
4914
|
case 3 /* TimestampValue */ :
|
|
4901
4915
|
return this.convertTimestamp(t.timestampValue);
|
|
@@ -4907,7 +4921,7 @@ class yr extends class {
|
|
|
4907
4921
|
return t.stringValue;
|
|
4908
4922
|
|
|
4909
4923
|
case 6 /* BlobValue */ :
|
|
4910
|
-
return this.convertBytes(
|
|
4924
|
+
return this.convertBytes(Rt(t.bytesValue));
|
|
4911
4925
|
|
|
4912
4926
|
case 7 /* RefValue */ :
|
|
4913
4927
|
return this.convertReference(t.referenceValue);
|
|
@@ -4927,12 +4941,12 @@ class yr extends class {
|
|
|
4927
4941
|
}
|
|
4928
4942
|
convertObject(t, n) {
|
|
4929
4943
|
const e = {};
|
|
4930
|
-
return
|
|
4944
|
+
return vt(t.fields, ((t, r) => {
|
|
4931
4945
|
e[t] = this.convertValue(r, n);
|
|
4932
4946
|
})), e;
|
|
4933
4947
|
}
|
|
4934
4948
|
convertGeoPoint(t) {
|
|
4935
|
-
return new
|
|
4949
|
+
return new ve(Pt(t.latitude), Pt(t.longitude));
|
|
4936
4950
|
}
|
|
4937
4951
|
convertArray(t, n) {
|
|
4938
4952
|
return (t.values || []).map((t => this.convertValue(t, n)));
|
|
@@ -4940,24 +4954,24 @@ class yr extends class {
|
|
|
4940
4954
|
convertServerTimestamp(t, n) {
|
|
4941
4955
|
switch (n) {
|
|
4942
4956
|
case "previous":
|
|
4943
|
-
const e =
|
|
4957
|
+
const e = Dt(t);
|
|
4944
4958
|
return null == e ? null : this.convertValue(e, n);
|
|
4945
4959
|
|
|
4946
4960
|
case "estimate":
|
|
4947
|
-
return this.convertTimestamp(
|
|
4961
|
+
return this.convertTimestamp(Nt(t));
|
|
4948
4962
|
|
|
4949
4963
|
default:
|
|
4950
4964
|
return null;
|
|
4951
4965
|
}
|
|
4952
4966
|
}
|
|
4953
4967
|
convertTimestamp(t) {
|
|
4954
|
-
const n =
|
|
4955
|
-
return new
|
|
4968
|
+
const n = At(t);
|
|
4969
|
+
return new _t(n.seconds, n.nanos);
|
|
4956
4970
|
}
|
|
4957
4971
|
convertDocumentKey(t, n) {
|
|
4958
|
-
const e =
|
|
4959
|
-
g(
|
|
4960
|
-
const r = new
|
|
4972
|
+
const e = J.fromString(t);
|
|
4973
|
+
g(Yn(e));
|
|
4974
|
+
const r = new H(e.get(1), e.get(3)), s = new tt(e.popFirst(5));
|
|
4961
4975
|
return r.isEqual(n) ||
|
|
4962
4976
|
// TODO(b/64130202): Somehow support foreign references.
|
|
4963
4977
|
m(`Document ${s} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${n.projectId}/${n.database}) instead.`),
|
|
@@ -4968,11 +4982,11 @@ class yr extends class {
|
|
|
4968
4982
|
super(), this.firestore = t;
|
|
4969
4983
|
}
|
|
4970
4984
|
convertBytes(t) {
|
|
4971
|
-
return new
|
|
4985
|
+
return new ge(t);
|
|
4972
4986
|
}
|
|
4973
4987
|
convertReference(t) {
|
|
4974
4988
|
const n = this.convertDocumentKey(t, this.firestore._databaseId);
|
|
4975
|
-
return new
|
|
4989
|
+
return new ae(this.firestore, /* converter= */ null, n);
|
|
4976
4990
|
}
|
|
4977
4991
|
}
|
|
4978
4992
|
|
|
@@ -4988,12 +5002,12 @@ class yr extends class {
|
|
|
4988
5002
|
* @param reference - The reference of the document to fetch.
|
|
4989
5003
|
* @returns A Promise resolved with a `DocumentSnapshot` containing the current
|
|
4990
5004
|
* document contents.
|
|
4991
|
-
*/ function
|
|
4992
|
-
const n =
|
|
4993
|
-
return
|
|
5005
|
+
*/ function br(t) {
|
|
5006
|
+
const n = ee((t = it(t, ae)).firestore), e = new gr(t.firestore);
|
|
5007
|
+
return Zn(n, [ t._key ]).then((n => {
|
|
4994
5008
|
g(1 === n.length);
|
|
4995
5009
|
const r = n[0];
|
|
4996
|
-
return new
|
|
5010
|
+
return new Ye(t.firestore, e, t._key, r.isFoundDocument() ? r : null, t.converter);
|
|
4997
5011
|
}));
|
|
4998
5012
|
}
|
|
4999
5013
|
|
|
@@ -5008,33 +5022,33 @@ class yr extends class {
|
|
|
5008
5022
|
*
|
|
5009
5023
|
* @param query - The `Query` to execute.
|
|
5010
5024
|
* @returns A Promise that will be resolved with the results of the query.
|
|
5011
|
-
*/ function
|
|
5025
|
+
*/ function vr(t) {
|
|
5012
5026
|
!function(t) {
|
|
5013
|
-
if (
|
|
5014
|
-
}((t =
|
|
5015
|
-
const n =
|
|
5016
|
-
return
|
|
5017
|
-
const r = n.map((n => new
|
|
5018
|
-
return
|
|
5027
|
+
if (un(t) && 0 === t.explicitOrderBy.length) throw new L(q, "limitToLast() queries require specifying at least one orderBy() clause");
|
|
5028
|
+
}((t = it(t, he))._query);
|
|
5029
|
+
const n = ee(t.firestore), e = new gr(t.firestore);
|
|
5030
|
+
return te(n, t._query).then((n => {
|
|
5031
|
+
const r = n.map((n => new He(t.firestore, e, n.key, n, t.converter)));
|
|
5032
|
+
return un(t._query) &&
|
|
5019
5033
|
// Limit to last queries reverse the orderBy constraint that was
|
|
5020
5034
|
// specified by the user. As such, we need to reverse the order of the
|
|
5021
5035
|
// results to return the documents in the expected order.
|
|
5022
|
-
r.reverse(), new
|
|
5036
|
+
r.reverse(), new Ke(t, r);
|
|
5023
5037
|
}));
|
|
5024
5038
|
}
|
|
5025
5039
|
|
|
5026
|
-
function
|
|
5027
|
-
const r =
|
|
5028
|
-
return
|
|
5040
|
+
function Er(t, n, e) {
|
|
5041
|
+
const r = _r((t = it(t, ae)).converter, n, e), s = De(Ve(t.firestore), "setDoc", t._key, r, null !== t.converter, e);
|
|
5042
|
+
return Xn(ee(t.firestore), [ s.toMutation(t._key, vn.none()) ]);
|
|
5029
5043
|
}
|
|
5030
5044
|
|
|
5031
|
-
function
|
|
5032
|
-
const s =
|
|
5045
|
+
function Tr(t, n, e, ...r) {
|
|
5046
|
+
const s = Ve((t = it(t, ae)).firestore);
|
|
5033
5047
|
// For Compat types, we have to "extract" the underlying types before
|
|
5034
5048
|
// performing validation.
|
|
5035
5049
|
let i;
|
|
5036
|
-
i = "string" == typeof (n = getModularInstance(n)) || n instanceof
|
|
5037
|
-
return
|
|
5050
|
+
i = "string" == typeof (n = getModularInstance(n)) || n instanceof ye ? Ce(s, "updateDoc", t._key, n, e, r) : Oe(s, "updateDoc", t._key, n);
|
|
5051
|
+
return Xn(ee(t.firestore), [ i.toMutation(t._key, vn.exists(!0)) ]);
|
|
5038
5052
|
}
|
|
5039
5053
|
|
|
5040
5054
|
/**
|
|
@@ -5048,8 +5062,8 @@ function vr(t, n, e, ...r) {
|
|
|
5048
5062
|
* @param reference - A reference to the document to delete.
|
|
5049
5063
|
* @returns A `Promise` resolved once the document has been successfully
|
|
5050
5064
|
* deleted from the backend.
|
|
5051
|
-
*/ function
|
|
5052
|
-
return
|
|
5065
|
+
*/ function Ir(t) {
|
|
5066
|
+
return Xn(ee((t = it(t, ae)).firestore), [ new An(t._key, vn.none()) ]);
|
|
5053
5067
|
}
|
|
5054
5068
|
|
|
5055
5069
|
/**
|
|
@@ -5065,9 +5079,9 @@ function vr(t, n, e, ...r) {
|
|
|
5065
5079
|
* @param data - An Object containing the data for the new document.
|
|
5066
5080
|
* @returns A `Promise` resolved with a `DocumentReference` pointing to the
|
|
5067
5081
|
* newly created document after it has been written to the backend.
|
|
5068
|
-
*/ function
|
|
5069
|
-
const e =
|
|
5070
|
-
return
|
|
5082
|
+
*/ function Ar(t, n) {
|
|
5083
|
+
const e = we(t = it(t, le)), r = _r(t.converter, n), s = De(Ve(t.firestore), "addDoc", e._key, r, null !== e.converter, {});
|
|
5084
|
+
return Xn(ee(t.firestore), [ s.toMutation(e._key, vn.exists(!1)) ]).then((() => e));
|
|
5071
5085
|
}
|
|
5072
5086
|
|
|
5073
5087
|
/**
|
|
@@ -5089,15 +5103,15 @@ function vr(t, n, e, ...r) {
|
|
|
5089
5103
|
/**
|
|
5090
5104
|
* Returns a sentinel for use with {@link @firebase/firestore/lite#(updateDoc:1)} or
|
|
5091
5105
|
* {@link @firebase/firestore/lite#(setDoc:1)} with `{merge: true}` to mark a field for deletion.
|
|
5092
|
-
*/ function
|
|
5093
|
-
return new
|
|
5106
|
+
*/ function Pr() {
|
|
5107
|
+
return new Ne("deleteField");
|
|
5094
5108
|
}
|
|
5095
5109
|
|
|
5096
5110
|
/**
|
|
5097
5111
|
* Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
|
|
5098
5112
|
* include a server-generated timestamp in the written data.
|
|
5099
|
-
*/ function
|
|
5100
|
-
return new
|
|
5113
|
+
*/ function Rr() {
|
|
5114
|
+
return new Fe("serverTimestamp");
|
|
5101
5115
|
}
|
|
5102
5116
|
|
|
5103
5117
|
/**
|
|
@@ -5111,10 +5125,10 @@ function vr(t, n, e, ...r) {
|
|
|
5111
5125
|
* @param elements - The elements to union into the array.
|
|
5112
5126
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5113
5127
|
* `updateDoc()`.
|
|
5114
|
-
*/ function
|
|
5128
|
+
*/ function Vr(...t) {
|
|
5115
5129
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5116
5130
|
// update() since we'd need the Firestore instance to do this.
|
|
5117
|
-
return new
|
|
5131
|
+
return new Se("arrayUnion", t);
|
|
5118
5132
|
}
|
|
5119
5133
|
|
|
5120
5134
|
/**
|
|
@@ -5127,10 +5141,10 @@ function vr(t, n, e, ...r) {
|
|
|
5127
5141
|
* @param elements - The elements to remove from the array.
|
|
5128
5142
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5129
5143
|
* `updateDoc()`
|
|
5130
|
-
*/ function
|
|
5144
|
+
*/ function Dr(...t) {
|
|
5131
5145
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5132
5146
|
// update() since we'd need the Firestore instance to do this.
|
|
5133
|
-
return new
|
|
5147
|
+
return new qe("arrayRemove", t);
|
|
5134
5148
|
}
|
|
5135
5149
|
|
|
5136
5150
|
/**
|
|
@@ -5151,8 +5165,8 @@ function vr(t, n, e, ...r) {
|
|
|
5151
5165
|
* @param n - The value to increment by.
|
|
5152
5166
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5153
5167
|
* `updateDoc()`
|
|
5154
|
-
*/ function
|
|
5155
|
-
return new
|
|
5168
|
+
*/ function Nr(t) {
|
|
5169
|
+
return new xe("increment", t);
|
|
5156
5170
|
}
|
|
5157
5171
|
|
|
5158
5172
|
/**
|
|
@@ -5178,25 +5192,25 @@ function vr(t, n, e, ...r) {
|
|
|
5178
5192
|
* provides methods for adding writes to the write batch. None of the writes
|
|
5179
5193
|
* will be committed (or visible locally) until {@link WriteBatch.commit} is
|
|
5180
5194
|
* called.
|
|
5181
|
-
*/ class
|
|
5195
|
+
*/ class $r {
|
|
5182
5196
|
/** @hideconstructor */
|
|
5183
5197
|
constructor(t, n) {
|
|
5184
5198
|
this._firestore = t, this._commitHandler = n, this._mutations = [], this._committed = !1,
|
|
5185
|
-
this._dataReader =
|
|
5199
|
+
this._dataReader = Ve(t);
|
|
5186
5200
|
}
|
|
5187
5201
|
set(t, n, e) {
|
|
5188
5202
|
this._verifyNotCommitted();
|
|
5189
|
-
const r =
|
|
5190
|
-
return this._mutations.push(i.toMutation(r._key,
|
|
5203
|
+
const r = Fr(t, this._firestore), s = _r(r.converter, n, e), i = De(this._dataReader, "WriteBatch.set", r._key, s, null !== r.converter, e);
|
|
5204
|
+
return this._mutations.push(i.toMutation(r._key, vn.none())), this;
|
|
5191
5205
|
}
|
|
5192
5206
|
update(t, n, e, ...r) {
|
|
5193
5207
|
this._verifyNotCommitted();
|
|
5194
|
-
const s =
|
|
5208
|
+
const s = Fr(t, this._firestore);
|
|
5195
5209
|
// For Compat types, we have to "extract" the underlying types before
|
|
5196
5210
|
// performing validation.
|
|
5197
5211
|
let i;
|
|
5198
|
-
return i = "string" == typeof (n = getModularInstance(n)) || n instanceof
|
|
5199
|
-
this._mutations.push(i.toMutation(s._key,
|
|
5212
|
+
return i = "string" == typeof (n = getModularInstance(n)) || n instanceof ye ? Ce(this._dataReader, "WriteBatch.update", s._key, n, e, r) : Oe(this._dataReader, "WriteBatch.update", s._key, n),
|
|
5213
|
+
this._mutations.push(i.toMutation(s._key, vn.exists(!0))), this;
|
|
5200
5214
|
}
|
|
5201
5215
|
/**
|
|
5202
5216
|
* Deletes the document referred to by the provided {@link DocumentReference}.
|
|
@@ -5205,8 +5219,8 @@ function vr(t, n, e, ...r) {
|
|
|
5205
5219
|
* @returns This `WriteBatch` instance. Used for chaining method calls.
|
|
5206
5220
|
*/ delete(t) {
|
|
5207
5221
|
this._verifyNotCommitted();
|
|
5208
|
-
const n =
|
|
5209
|
-
return this._mutations = this._mutations.concat(new
|
|
5222
|
+
const n = Fr(t, this._firestore);
|
|
5223
|
+
return this._mutations = this._mutations.concat(new An(n._key, vn.none())), this;
|
|
5210
5224
|
}
|
|
5211
5225
|
/**
|
|
5212
5226
|
* Commits all of the writes in this write batch as a single atomic unit.
|
|
@@ -5227,7 +5241,7 @@ function vr(t, n, e, ...r) {
|
|
|
5227
5241
|
}
|
|
5228
5242
|
}
|
|
5229
5243
|
|
|
5230
|
-
function
|
|
5244
|
+
function Fr(t, n) {
|
|
5231
5245
|
if ((t = getModularInstance(t)).firestore !== n) throw new L(I, "Provided document reference is from a different Firestore instance.");
|
|
5232
5246
|
return t;
|
|
5233
5247
|
}
|
|
@@ -5244,9 +5258,9 @@ function Nr(t, n) {
|
|
|
5244
5258
|
*
|
|
5245
5259
|
* @returns A `WriteBatch` that can be used to atomically execute multiple
|
|
5246
5260
|
* writes.
|
|
5247
|
-
*/ function
|
|
5248
|
-
const n =
|
|
5249
|
-
return new
|
|
5261
|
+
*/ function Sr(t) {
|
|
5262
|
+
const n = ee(t = it(t, se));
|
|
5263
|
+
return new $r(t, (t => Xn(n, t)));
|
|
5250
5264
|
}
|
|
5251
5265
|
|
|
5252
5266
|
/**
|
|
@@ -5268,7 +5282,7 @@ function Nr(t, n) {
|
|
|
5268
5282
|
/**
|
|
5269
5283
|
* Internal transaction object responsible for accumulating the mutations to
|
|
5270
5284
|
* perform and the base versions for any documents read.
|
|
5271
|
-
*/ class
|
|
5285
|
+
*/ class qr {
|
|
5272
5286
|
constructor(t) {
|
|
5273
5287
|
this.datastore = t,
|
|
5274
5288
|
// The version of each document that was read during this transaction.
|
|
@@ -5288,7 +5302,7 @@ function Nr(t, n) {
|
|
|
5288
5302
|
}
|
|
5289
5303
|
async lookup(t) {
|
|
5290
5304
|
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new L(I, "Firestore transactions require all reads to be executed before all writes.");
|
|
5291
|
-
const n = await
|
|
5305
|
+
const n = await Zn(this.datastore, t);
|
|
5292
5306
|
return n.forEach((t => this.recordVersion(t))), n;
|
|
5293
5307
|
}
|
|
5294
5308
|
set(t, n) {
|
|
@@ -5303,7 +5317,7 @@ function Nr(t, n) {
|
|
|
5303
5317
|
this.writtenDocs.add(t.toString());
|
|
5304
5318
|
}
|
|
5305
5319
|
delete(t) {
|
|
5306
|
-
this.write(new
|
|
5320
|
+
this.write(new An(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5307
5321
|
}
|
|
5308
5322
|
async commit() {
|
|
5309
5323
|
if (this.ensureCommitNotCalled(), this.lastWriteError) throw this.lastWriteError;
|
|
@@ -5315,16 +5329,16 @@ function Nr(t, n) {
|
|
|
5315
5329
|
// For each document that was read but not written to, we want to perform
|
|
5316
5330
|
// a `verify` operation.
|
|
5317
5331
|
t.forEach(((t, n) => {
|
|
5318
|
-
const e =
|
|
5319
|
-
this.mutations.push(new
|
|
5320
|
-
})), await
|
|
5332
|
+
const e = tt.fromPath(n);
|
|
5333
|
+
this.mutations.push(new Pn(e, this.precondition(e)));
|
|
5334
|
+
})), await Xn(this.datastore, this.mutations), this.committed = !0;
|
|
5321
5335
|
}
|
|
5322
5336
|
recordVersion(t) {
|
|
5323
5337
|
let n;
|
|
5324
5338
|
if (t.isFoundDocument()) n = t.version; else {
|
|
5325
5339
|
if (!t.isNoDocument()) throw _();
|
|
5326
5340
|
// For deleted docs, we must use baseVersion 0 when we overwrite them.
|
|
5327
|
-
n =
|
|
5341
|
+
n = gt.min();
|
|
5328
5342
|
}
|
|
5329
5343
|
const e = this.readVersions.get(t.key.toString());
|
|
5330
5344
|
if (e) {
|
|
@@ -5338,7 +5352,7 @@ function Nr(t, n) {
|
|
|
5338
5352
|
* as a precondition, or no precondition if it was not read.
|
|
5339
5353
|
*/ precondition(t) {
|
|
5340
5354
|
const n = this.readVersions.get(t.toString());
|
|
5341
|
-
return !this.writtenDocs.has(t.toString()) && n ?
|
|
5355
|
+
return !this.writtenDocs.has(t.toString()) && n ? vn.updateTime(n) : vn.none();
|
|
5342
5356
|
}
|
|
5343
5357
|
/**
|
|
5344
5358
|
* Returns the precondition for a document if the operation is an update.
|
|
@@ -5347,7 +5361,7 @@ function Nr(t, n) {
|
|
|
5347
5361
|
// The first time a document is written, we want to take into account the
|
|
5348
5362
|
// read time and existence
|
|
5349
5363
|
if (!this.writtenDocs.has(t.toString()) && n) {
|
|
5350
|
-
if (n.isEqual(
|
|
5364
|
+
if (n.isEqual(gt.min()))
|
|
5351
5365
|
// The document doesn't exist, so fail the transaction.
|
|
5352
5366
|
// This has to be validated locally because you can't send a
|
|
5353
5367
|
// precondition that a document does not exist without changing the
|
|
@@ -5359,11 +5373,11 @@ function Nr(t, n) {
|
|
|
5359
5373
|
// transaction.
|
|
5360
5374
|
throw new L(I, "Can't update a document that doesn't exist.");
|
|
5361
5375
|
// Document exists, base precondition on document update time.
|
|
5362
|
-
return
|
|
5376
|
+
return vn.updateTime(n);
|
|
5363
5377
|
}
|
|
5364
5378
|
// Document was not read, so we just use the preconditions for a blind
|
|
5365
5379
|
// update.
|
|
5366
|
-
return
|
|
5380
|
+
return vn.exists(!0);
|
|
5367
5381
|
}
|
|
5368
5382
|
write(t) {
|
|
5369
5383
|
this.ensureCommitNotCalled(), this.mutations.push(t);
|
|
@@ -5391,43 +5405,43 @@ function Nr(t, n) {
|
|
|
5391
5405
|
* TransactionRunner encapsulates the logic needed to run and retry transactions
|
|
5392
5406
|
* with backoff.
|
|
5393
5407
|
*/
|
|
5394
|
-
class
|
|
5408
|
+
class xr {
|
|
5395
5409
|
constructor(t, n, e, r) {
|
|
5396
5410
|
this.asyncQueue = t, this.datastore = n, this.updateFunction = e, this.deferred = r,
|
|
5397
|
-
this.
|
|
5411
|
+
this.Tt = 5, this.It = new Kn(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
|
|
5398
5412
|
}
|
|
5399
5413
|
/** Runs the transaction and sets the result on deferred. */ run() {
|
|
5400
|
-
this.
|
|
5414
|
+
this.Tt -= 1, this.At();
|
|
5401
5415
|
}
|
|
5402
|
-
|
|
5403
|
-
this.
|
|
5404
|
-
const t = new
|
|
5416
|
+
At() {
|
|
5417
|
+
this.It.W((async () => {
|
|
5418
|
+
const t = new qr(this.datastore), n = this.Pt(t);
|
|
5405
5419
|
n && n.then((n => {
|
|
5406
5420
|
this.asyncQueue.enqueueAndForget((() => t.commit().then((() => {
|
|
5407
5421
|
this.deferred.resolve(n);
|
|
5408
5422
|
})).catch((t => {
|
|
5409
|
-
this.
|
|
5423
|
+
this.Rt(t);
|
|
5410
5424
|
}))));
|
|
5411
5425
|
})).catch((t => {
|
|
5412
|
-
this.
|
|
5426
|
+
this.Rt(t);
|
|
5413
5427
|
}));
|
|
5414
5428
|
}));
|
|
5415
5429
|
}
|
|
5416
|
-
|
|
5430
|
+
Pt(t) {
|
|
5417
5431
|
try {
|
|
5418
5432
|
const n = this.updateFunction(t);
|
|
5419
|
-
return !
|
|
5433
|
+
return !ut(n) && n.catch && n.then ? n : (this.deferred.reject(Error("Transaction callback must return a Promise")),
|
|
5420
5434
|
null);
|
|
5421
5435
|
} catch (t) {
|
|
5422
5436
|
// Do not retry errors thrown by user provided updateFunction.
|
|
5423
5437
|
return this.deferred.reject(t), null;
|
|
5424
5438
|
}
|
|
5425
5439
|
}
|
|
5426
|
-
|
|
5427
|
-
this.
|
|
5440
|
+
Rt(t) {
|
|
5441
|
+
this.Tt > 0 && this.Vt(t) ? (this.Tt -= 1, this.asyncQueue.enqueueAndForget((() => (this.At(),
|
|
5428
5442
|
Promise.resolve())))) : this.deferred.reject(t);
|
|
5429
5443
|
}
|
|
5430
|
-
|
|
5444
|
+
Vt(t) {
|
|
5431
5445
|
if ("FirebaseError" === t.name) {
|
|
5432
5446
|
// In transactions, the backend will fail outdated reads with FAILED_PRECONDITION and
|
|
5433
5447
|
// non-matching document versions with ABORTED. These errors should be retried.
|
|
@@ -5491,7 +5505,7 @@ class Sr {
|
|
|
5491
5505
|
* See the License for the specific language governing permissions and
|
|
5492
5506
|
* limitations under the License.
|
|
5493
5507
|
*/
|
|
5494
|
-
/** The Platform's 'document' implementation or null if not available. */ function
|
|
5508
|
+
/** The Platform's 'document' implementation or null if not available. */ function Or() {
|
|
5495
5509
|
// `document` is not always available, e.g. in ReactNative and WebWorkers.
|
|
5496
5510
|
// eslint-disable-next-line no-restricted-globals
|
|
5497
5511
|
return "undefined" != typeof document ? document : null;
|
|
@@ -5523,7 +5537,7 @@ class Sr {
|
|
|
5523
5537
|
* Note: We implement `PromiseLike` instead of `Promise`, as the `Promise` type
|
|
5524
5538
|
* in newer versions of TypeScript defines `finally`, which is not available in
|
|
5525
5539
|
* IE.
|
|
5526
|
-
*/ class
|
|
5540
|
+
*/ class Cr {
|
|
5527
5541
|
constructor(t, n, e, r, s) {
|
|
5528
5542
|
this.asyncQueue = t, this.timerId = n, this.targetTimeMs = e, this.op = r, this.removalCallback = s,
|
|
5529
5543
|
this.deferred = new U, this.then = this.deferred.promise.then.bind(this.deferred.promise),
|
|
@@ -5546,7 +5560,7 @@ class Sr {
|
|
|
5546
5560
|
* PORTING NOTE: This exists to prevent making removeDelayedOperation() and
|
|
5547
5561
|
* the DelayedOperation class public.
|
|
5548
5562
|
*/ static createAndSchedule(t, n, e, r, s) {
|
|
5549
|
-
const i = Date.now() + e, o = new
|
|
5563
|
+
const i = Date.now() + e, o = new Cr(t, n, i, r, s);
|
|
5550
5564
|
return o.start(e), o;
|
|
5551
5565
|
}
|
|
5552
5566
|
/**
|
|
@@ -5595,42 +5609,42 @@ class Sr {
|
|
|
5595
5609
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5596
5610
|
* See the License for the specific language governing permissions and
|
|
5597
5611
|
* limitations under the License.
|
|
5598
|
-
*/ class
|
|
5612
|
+
*/ class Lr {
|
|
5599
5613
|
constructor() {
|
|
5600
5614
|
// The last promise in the queue.
|
|
5601
|
-
this.
|
|
5615
|
+
this.Dt = Promise.resolve(),
|
|
5602
5616
|
// A list of retryable operations. Retryable operations are run in order and
|
|
5603
5617
|
// retried with backoff.
|
|
5604
|
-
this.
|
|
5618
|
+
this.Nt = [],
|
|
5605
5619
|
// Is this AsyncQueue being shut down? Once it is set to true, it will not
|
|
5606
5620
|
// be changed again.
|
|
5607
|
-
this
|
|
5621
|
+
this.$t = !1,
|
|
5608
5622
|
// Operations scheduled to be queued in the future. Operations are
|
|
5609
5623
|
// automatically removed after they are run or canceled.
|
|
5610
|
-
this
|
|
5624
|
+
this.Ft = [],
|
|
5611
5625
|
// visible for testing
|
|
5612
|
-
this.
|
|
5626
|
+
this.St = null,
|
|
5613
5627
|
// Flag set while there's an outstanding AsyncQueue operation, used for
|
|
5614
5628
|
// assertion sanity-checks.
|
|
5615
|
-
this.St = !1,
|
|
5616
|
-
// Enabled during shutdown on Safari to prevent future access to IndexedDB.
|
|
5617
5629
|
this.qt = !1,
|
|
5630
|
+
// Enabled during shutdown on Safari to prevent future access to IndexedDB.
|
|
5631
|
+
this.xt = !1,
|
|
5618
5632
|
// List of TimerIds to fast-forward delays for.
|
|
5619
|
-
this.
|
|
5633
|
+
this.Ot = [],
|
|
5620
5634
|
// Backoff timer used to schedule retries for retryable operations
|
|
5621
|
-
this.
|
|
5635
|
+
this.It = new Kn(this, "async_queue_retry" /* AsyncQueueRetry */),
|
|
5622
5636
|
// Visibility handler that triggers an immediate retry of all retryable
|
|
5623
5637
|
// operations. Meant to speed up recovery when we regain file system access
|
|
5624
5638
|
// after page comes into foreground.
|
|
5625
|
-
this.
|
|
5626
|
-
const t =
|
|
5627
|
-
t && w("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.
|
|
5639
|
+
this.Ct = () => {
|
|
5640
|
+
const t = Or();
|
|
5641
|
+
t && w("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.It.H();
|
|
5628
5642
|
};
|
|
5629
|
-
const t =
|
|
5630
|
-
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.
|
|
5643
|
+
const t = Or();
|
|
5644
|
+
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.Ct);
|
|
5631
5645
|
}
|
|
5632
5646
|
get isShuttingDown() {
|
|
5633
|
-
return this
|
|
5647
|
+
return this.$t;
|
|
5634
5648
|
}
|
|
5635
5649
|
/**
|
|
5636
5650
|
* Adds a new operation to the queue without waiting for it to complete (i.e.
|
|
@@ -5640,38 +5654,38 @@ class Sr {
|
|
|
5640
5654
|
this.enqueue(t);
|
|
5641
5655
|
}
|
|
5642
5656
|
enqueueAndForgetEvenWhileRestricted(t) {
|
|
5643
|
-
this.
|
|
5657
|
+
this.Lt(),
|
|
5644
5658
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
5645
|
-
this.
|
|
5659
|
+
this.Ut(t);
|
|
5646
5660
|
}
|
|
5647
5661
|
enterRestrictedMode(t) {
|
|
5648
|
-
if (!this
|
|
5649
|
-
this
|
|
5650
|
-
const n =
|
|
5651
|
-
n && "function" == typeof n.removeEventListener && n.removeEventListener("visibilitychange", this.
|
|
5662
|
+
if (!this.$t) {
|
|
5663
|
+
this.$t = !0, this.xt = t || !1;
|
|
5664
|
+
const n = Or();
|
|
5665
|
+
n && "function" == typeof n.removeEventListener && n.removeEventListener("visibilitychange", this.Ct);
|
|
5652
5666
|
}
|
|
5653
5667
|
}
|
|
5654
5668
|
enqueue(t) {
|
|
5655
|
-
if (this.
|
|
5669
|
+
if (this.Lt(), this.$t)
|
|
5656
5670
|
// Return a Promise which never resolves.
|
|
5657
5671
|
return new Promise((() => {}));
|
|
5658
5672
|
// Create a deferred Promise that we can return to the callee. This
|
|
5659
5673
|
// allows us to return a "hanging Promise" only to the callee and still
|
|
5660
5674
|
// advance the queue even when the operation is not run.
|
|
5661
5675
|
const n = new U;
|
|
5662
|
-
return this.
|
|
5676
|
+
return this.Ut((() => this.$t && this.xt ? Promise.resolve() : (t().then(n.resolve, n.reject),
|
|
5663
5677
|
n.promise))).then((() => n.promise));
|
|
5664
5678
|
}
|
|
5665
5679
|
enqueueRetryable(t) {
|
|
5666
|
-
this.enqueueAndForget((() => (this.
|
|
5680
|
+
this.enqueueAndForget((() => (this.Nt.push(t), this.kt())));
|
|
5667
5681
|
}
|
|
5668
5682
|
/**
|
|
5669
5683
|
* Runs the next operation from the retryable queue. If the operation fails,
|
|
5670
5684
|
* reschedules with backoff.
|
|
5671
|
-
*/ async
|
|
5672
|
-
if (0 !== this.
|
|
5685
|
+
*/ async kt() {
|
|
5686
|
+
if (0 !== this.Nt.length) {
|
|
5673
5687
|
try {
|
|
5674
|
-
await this.
|
|
5688
|
+
await this.Nt[0](), this.Nt.shift(), this.It.reset();
|
|
5675
5689
|
} catch (t) {
|
|
5676
5690
|
if (!
|
|
5677
5691
|
/**
|
|
@@ -5715,7 +5729,7 @@ class Sr {
|
|
|
5715
5729
|
// Failure will be handled by AsyncQueue
|
|
5716
5730
|
w("AsyncQueue", "Operation failed with retryable error: " + t);
|
|
5717
5731
|
}
|
|
5718
|
-
this.
|
|
5732
|
+
this.Nt.length > 0 &&
|
|
5719
5733
|
// If there are additional operations, we re-schedule `retryNextOp()`.
|
|
5720
5734
|
// This is necessary to run retryable operations that failed during
|
|
5721
5735
|
// their initial attempt since we don't know whether they are already
|
|
@@ -5726,12 +5740,12 @@ class Sr {
|
|
|
5726
5740
|
// Since `backoffAndRun()` cancels an existing backoff and schedules a
|
|
5727
5741
|
// new backoff on every call, there is only ever a single additional
|
|
5728
5742
|
// operation in the queue.
|
|
5729
|
-
this.
|
|
5743
|
+
this.It.W((() => this.kt()));
|
|
5730
5744
|
}
|
|
5731
5745
|
}
|
|
5732
|
-
|
|
5733
|
-
const n = this.
|
|
5734
|
-
this.
|
|
5746
|
+
Ut(t) {
|
|
5747
|
+
const n = this.Dt.then((() => (this.qt = !0, t().catch((t => {
|
|
5748
|
+
this.St = t, this.qt = !1;
|
|
5735
5749
|
const n =
|
|
5736
5750
|
/**
|
|
5737
5751
|
* Chrome includes Error.message in Error.stack. Other browsers do not.
|
|
@@ -5772,38 +5786,38 @@ class Sr {
|
|
|
5772
5786
|
// all further attempts to chain (via .then) will just short-circuit
|
|
5773
5787
|
// and return the rejected Promise.
|
|
5774
5788
|
throw m("INTERNAL UNHANDLED ERROR: ", n), t;
|
|
5775
|
-
})).then((t => (this.
|
|
5776
|
-
return this.
|
|
5789
|
+
})).then((t => (this.qt = !1, t))))));
|
|
5790
|
+
return this.Dt = n, n;
|
|
5777
5791
|
}
|
|
5778
5792
|
enqueueAfterDelay(t, n, e) {
|
|
5779
|
-
this.
|
|
5793
|
+
this.Lt(),
|
|
5780
5794
|
// Fast-forward delays for timerIds that have been overriden.
|
|
5781
|
-
this.
|
|
5782
|
-
const r =
|
|
5783
|
-
return this
|
|
5795
|
+
this.Ot.indexOf(t) > -1 && (n = 0);
|
|
5796
|
+
const r = Cr.createAndSchedule(this, t, n, e, (t => this.jt(t)));
|
|
5797
|
+
return this.Ft.push(r), r;
|
|
5784
5798
|
}
|
|
5785
|
-
|
|
5786
|
-
this.
|
|
5799
|
+
Lt() {
|
|
5800
|
+
this.St && _();
|
|
5787
5801
|
}
|
|
5788
5802
|
verifyOperationInProgress() {}
|
|
5789
5803
|
/**
|
|
5790
5804
|
* Waits until all currently queued tasks are finished executing. Delayed
|
|
5791
5805
|
* operations are not run.
|
|
5792
|
-
*/ async
|
|
5806
|
+
*/ async Mt() {
|
|
5793
5807
|
// Operations in the queue prior to draining may have enqueued additional
|
|
5794
5808
|
// operations. Keep draining the queue until the tail is no longer advanced,
|
|
5795
5809
|
// which indicates that no more new operations were enqueued and that all
|
|
5796
5810
|
// operations were executed.
|
|
5797
5811
|
let t;
|
|
5798
5812
|
do {
|
|
5799
|
-
t = this.
|
|
5800
|
-
} while (t !== this.
|
|
5813
|
+
t = this.Dt, await t;
|
|
5814
|
+
} while (t !== this.Dt);
|
|
5801
5815
|
}
|
|
5802
5816
|
/**
|
|
5803
5817
|
* For Tests: Determine if a delayed operation with a particular TimerId
|
|
5804
5818
|
* exists.
|
|
5805
5819
|
*/ Bt(t) {
|
|
5806
|
-
for (const n of this
|
|
5820
|
+
for (const n of this.Ft) if (n.timerId === t) return !0;
|
|
5807
5821
|
return !1;
|
|
5808
5822
|
}
|
|
5809
5823
|
/**
|
|
@@ -5812,31 +5826,31 @@ class Sr {
|
|
|
5812
5826
|
* @param lastTimerId - Delayed operations up to and including this TimerId
|
|
5813
5827
|
* will be drained. Pass TimerId.All to run all delayed operations.
|
|
5814
5828
|
* @returns a Promise that resolves once all operations have been run.
|
|
5815
|
-
*/
|
|
5829
|
+
*/ zt(t) {
|
|
5816
5830
|
// Note that draining may generate more delayed ops, so we do that first.
|
|
5817
|
-
return this.
|
|
5831
|
+
return this.Mt().then((() => {
|
|
5818
5832
|
// Run ops in the same order they'd run if they ran naturally.
|
|
5819
|
-
this
|
|
5820
|
-
for (const n of this
|
|
5821
|
-
return this.
|
|
5833
|
+
this.Ft.sort(((t, n) => t.targetTimeMs - n.targetTimeMs));
|
|
5834
|
+
for (const n of this.Ft) if (n.skipDelay(), "all" /* All */ !== t && n.timerId === t) break;
|
|
5835
|
+
return this.Mt();
|
|
5822
5836
|
}));
|
|
5823
5837
|
}
|
|
5824
5838
|
/**
|
|
5825
5839
|
* For Tests: Skip all subsequent delays for a timer id.
|
|
5826
|
-
*/
|
|
5827
|
-
this.
|
|
5840
|
+
*/ Gt(t) {
|
|
5841
|
+
this.Ot.push(t);
|
|
5828
5842
|
}
|
|
5829
5843
|
/** Called once a DelayedOperation is run or canceled. */ jt(t) {
|
|
5830
5844
|
// NOTE: indexOf / slice are O(n), but delayedOperations is expected to be small.
|
|
5831
|
-
const n = this
|
|
5832
|
-
this
|
|
5845
|
+
const n = this.Ft.indexOf(t);
|
|
5846
|
+
this.Ft.splice(n, 1);
|
|
5833
5847
|
}
|
|
5834
5848
|
}
|
|
5835
5849
|
|
|
5836
|
-
class
|
|
5850
|
+
class Ur {
|
|
5837
5851
|
/** @hideconstructor */
|
|
5838
5852
|
constructor(t, n) {
|
|
5839
|
-
this._firestore = t, this._transaction = n, this._dataReader =
|
|
5853
|
+
this._firestore = t, this._transaction = n, this._dataReader = Ve(t);
|
|
5840
5854
|
}
|
|
5841
5855
|
/**
|
|
5842
5856
|
* Reads the document referenced by the provided {@link DocumentReference}.
|
|
@@ -5844,25 +5858,25 @@ class Cr {
|
|
|
5844
5858
|
* @param documentRef - A reference to the document to be read.
|
|
5845
5859
|
* @returns A `DocumentSnapshot` with the read data.
|
|
5846
5860
|
*/ get(t) {
|
|
5847
|
-
const n =
|
|
5861
|
+
const n = Fr(t, this._firestore), e = new gr(this._firestore);
|
|
5848
5862
|
return this._transaction.lookup([ n._key ]).then((t => {
|
|
5849
5863
|
if (!t || 1 !== t.length) return _();
|
|
5850
5864
|
const r = t[0];
|
|
5851
|
-
if (r.isFoundDocument()) return new
|
|
5852
|
-
if (r.isNoDocument()) return new
|
|
5865
|
+
if (r.isFoundDocument()) return new Ye(this._firestore, e, r.key, r, n.converter);
|
|
5866
|
+
if (r.isNoDocument()) return new Ye(this._firestore, e, n._key, null, n.converter);
|
|
5853
5867
|
throw _();
|
|
5854
5868
|
}));
|
|
5855
5869
|
}
|
|
5856
5870
|
set(t, n, e) {
|
|
5857
|
-
const r =
|
|
5871
|
+
const r = Fr(t, this._firestore), s = _r(r.converter, n, e), i = De(this._dataReader, "Transaction.set", r._key, s, null !== r.converter, e);
|
|
5858
5872
|
return this._transaction.set(r._key, i), this;
|
|
5859
5873
|
}
|
|
5860
5874
|
update(t, n, e, ...r) {
|
|
5861
|
-
const s =
|
|
5875
|
+
const s = Fr(t, this._firestore);
|
|
5862
5876
|
// For Compat types, we have to "extract" the underlying types before
|
|
5863
5877
|
// performing validation.
|
|
5864
5878
|
let i;
|
|
5865
|
-
return i = "string" == typeof (n = getModularInstance(n)) || n instanceof
|
|
5879
|
+
return i = "string" == typeof (n = getModularInstance(n)) || n instanceof ye ? Ce(this._dataReader, "Transaction.update", s._key, n, e, r) : Oe(this._dataReader, "Transaction.update", s._key, n),
|
|
5866
5880
|
this._transaction.update(s._key, i), this;
|
|
5867
5881
|
}
|
|
5868
5882
|
/**
|
|
@@ -5871,7 +5885,7 @@ class Cr {
|
|
|
5871
5885
|
* @param documentRef - A reference to the document to be deleted.
|
|
5872
5886
|
* @returns This `Transaction` instance. Used for chaining method calls.
|
|
5873
5887
|
*/ delete(t) {
|
|
5874
|
-
const n =
|
|
5888
|
+
const n = Fr(t, this._firestore);
|
|
5875
5889
|
return this._transaction.delete(n._key), this;
|
|
5876
5890
|
}
|
|
5877
5891
|
}
|
|
@@ -5892,9 +5906,9 @@ class Cr {
|
|
|
5892
5906
|
* (the `updateFunction` returned a failed promise), the promise returned by the
|
|
5893
5907
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
5894
5908
|
* rejected promise with the corresponding failure error is returned.
|
|
5895
|
-
*/ function
|
|
5896
|
-
const e =
|
|
5897
|
-
return new
|
|
5909
|
+
*/ function kr(t, n) {
|
|
5910
|
+
const e = ee(t = it(t, se)), r = new U;
|
|
5911
|
+
return new xr(new Lr, e, (e => n(new Ur(t, e))), r).run(), r.promise;
|
|
5898
5912
|
}
|
|
5899
5913
|
|
|
5900
5914
|
/**
|
|
@@ -5907,11 +5921,11 @@ class Cr {
|
|
|
5907
5921
|
*/ !function(t) {
|
|
5908
5922
|
l = t;
|
|
5909
5923
|
}(`${SDK_VERSION}_lite`), _registerComponent(new Component("firestore/lite", ((t, {options: n}) => {
|
|
5910
|
-
const e = t.getProvider("app").getImmediate(), r = new
|
|
5924
|
+
const e = t.getProvider("app").getImmediate(), r = new se(e, new B(t.getProvider("auth-internal")), new W(t.getProvider("app-check-internal")));
|
|
5911
5925
|
return n && r._setSettings(n), r;
|
|
5912
5926
|
}), "PUBLIC" /* PUBLIC */)),
|
|
5913
5927
|
// RUNTIME_ENV and BUILD_TARGET are replaced by real values during the compilation
|
|
5914
|
-
registerVersion("firestore-lite", "3.3.1-canary.
|
|
5928
|
+
registerVersion("firestore-lite", "3.3.1-canary.dc6b447ba", ""), registerVersion("firestore-lite", "3.3.1-canary.dc6b447ba", "esm2017");
|
|
5915
5929
|
|
|
5916
|
-
export {
|
|
5930
|
+
export { ge as Bytes, le as CollectionReference, ae as DocumentReference, Ye as DocumentSnapshot, ye as FieldPath, be as FieldValue, se as Firestore, L as FirestoreError, ve as GeoPoint, he as Query, Ze as QueryConstraint, He as QueryDocumentSnapshot, Ke as QuerySnapshot, _t as Timestamp, Ur as Transaction, $r as WriteBatch, Ar as addDoc, Dr as arrayRemove, Vr as arrayUnion, fe as collection, de as collectionGroup, ue as connectFirestoreEmulator, Ir as deleteDoc, Pr as deleteField, we as doc, _e as documentId, dr as endAt, fr as endBefore, br as getDoc, vr as getDocs, oe as getFirestore, Nr as increment, ie as initializeFirestore, or as limit, ur as limitToLast, sr as orderBy, tr as query, pe as queryEqual, me as refEqual, kr as runTransaction, Rr as serverTimestamp, Er as setDoc, d as setLogLevel, Je as snapshotEqual, hr as startAfter, ar as startAt, ce as terminate, Tr as updateDoc, er as where, Sr as writeBatch };
|
|
5917
5931
|
//# sourceMappingURL=index.browser.esm2017.js.map
|