@firebase/firestore 3.3.0 → 3.3.1-canary.086df7c7e
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/CHANGELOG.md +8 -0
- 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 +3401 -3347
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +3676 -3627
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +194 -101
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +191 -99
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +3394 -3340
- 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 +1378 -1364
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +933 -924
- 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 +150 -149
- 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
|
@@ -66,7 +66,7 @@ l.MOCK_USER = new l("mock-user");
|
|
|
66
66
|
* See the License for the specific language governing permissions and
|
|
67
67
|
* limitations under the License.
|
|
68
68
|
*/
|
|
69
|
-
let f = "9.
|
|
69
|
+
let f = "9.5.0-canary.086df7c7e";
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* @license
|
|
@@ -221,9 +221,9 @@ n) {
|
|
|
221
221
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
222
222
|
* See the License for the specific language governing permissions and
|
|
223
223
|
* limitations under the License.
|
|
224
|
-
*/ const E = "ok",
|
|
224
|
+
*/ const E = "ok", T = "cancelled", I = "unknown", A = "invalid-argument", P = "deadline-exceeded", R = "not-found", V = "already-exists", N = "permission-denied", D = "unauthenticated", $ = "resource-exhausted", F = "failed-precondition", S = "aborted", q = "out-of-range", x = "unimplemented", O = "internal", C = "unavailable", L = "data-loss";
|
|
225
225
|
|
|
226
|
-
/** An error returned by a Firestore operation. */ class
|
|
226
|
+
/** An error returned by a Firestore operation. */ class k extends Error {
|
|
227
227
|
/** @hideconstructor */
|
|
228
228
|
constructor(
|
|
229
229
|
/**
|
|
@@ -259,7 +259,7 @@ n) {
|
|
|
259
259
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
260
260
|
* See the License for the specific language governing permissions and
|
|
261
261
|
* limitations under the License.
|
|
262
|
-
*/ class
|
|
262
|
+
*/ class U {
|
|
263
263
|
constructor() {
|
|
264
264
|
this.promise = new Promise(((t, n) => {
|
|
265
265
|
this.resolve = t, this.reject = n;
|
|
@@ -282,11 +282,9 @@ n) {
|
|
|
282
282
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
283
283
|
* See the License for the specific language governing permissions and
|
|
284
284
|
* limitations under the License.
|
|
285
|
-
*/ class
|
|
285
|
+
*/ class j {
|
|
286
286
|
constructor(t, n) {
|
|
287
|
-
this.user = n, this.type = "OAuth", this.
|
|
288
|
-
// Set the headers using Object Literal notation to avoid minification
|
|
289
|
-
this.authHeaders.Authorization = `Bearer ${t}`;
|
|
287
|
+
this.user = n, this.type = "OAuth", this.headers = new Map, this.headers.set("Authorization", `Bearer ${t}`);
|
|
290
288
|
}
|
|
291
289
|
}
|
|
292
290
|
|
|
@@ -332,7 +330,7 @@ n) {
|
|
|
332
330
|
}
|
|
333
331
|
}
|
|
334
332
|
|
|
335
|
-
/** Credential provider for the Lite SDK. */ class
|
|
333
|
+
/** Credential provider for the Lite SDK. */ class z {
|
|
336
334
|
constructor(t) {
|
|
337
335
|
this.auth = null, t.onInit((t => {
|
|
338
336
|
this.auth = t;
|
|
@@ -340,7 +338,7 @@ n) {
|
|
|
340
338
|
}
|
|
341
339
|
getToken() {
|
|
342
340
|
return this.auth ? this.auth.getToken().then((t => t ? (v("string" == typeof t.accessToken),
|
|
343
|
-
new
|
|
341
|
+
new j(t.accessToken, new l(this.auth.getUid()))) : null)) : Promise.resolve(null);
|
|
344
342
|
}
|
|
345
343
|
invalidateToken() {}
|
|
346
344
|
start(t, n) {}
|
|
@@ -353,17 +351,11 @@ n) {
|
|
|
353
351
|
* Technically this may no longer be necessary since the SDK should gracefully
|
|
354
352
|
* recover from unauthenticated errors (see b/33147818 for context), but it's
|
|
355
353
|
* safer to keep the implementation as-is.
|
|
356
|
-
*/ class
|
|
354
|
+
*/ class Q {
|
|
357
355
|
constructor(t, n, e) {
|
|
358
|
-
this.
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
const t = {
|
|
362
|
-
"X-Goog-AuthUser": this.i
|
|
363
|
-
}, n = this.t.auth.getAuthHeaderValueForFirstParty([]);
|
|
364
|
-
// Use array notation to prevent minification
|
|
365
|
-
return n && (t.Authorization = n), this.o && (t["X-Goog-Iam-Authorization-Token"] = this.o),
|
|
366
|
-
t;
|
|
356
|
+
this.type = "FirstParty", this.user = l.FIRST_PARTY, this.headers = new Map, this.headers.set("X-Goog-AuthUser", n);
|
|
357
|
+
const r = t.auth.getAuthHeaderValueForFirstParty([]);
|
|
358
|
+
r && this.headers.set("Authorization", r), e && this.headers.set("X-Goog-Iam-Authorization-Token", e);
|
|
367
359
|
}
|
|
368
360
|
}
|
|
369
361
|
|
|
@@ -371,12 +363,12 @@ n) {
|
|
|
371
363
|
* Provides user credentials required for the Firestore JavaScript SDK
|
|
372
364
|
* to authenticate the user, using technique that is only available
|
|
373
365
|
* to applications hosted by Google.
|
|
374
|
-
*/ class
|
|
366
|
+
*/ class G {
|
|
375
367
|
constructor(t, n, e) {
|
|
376
368
|
this.t = t, this.i = n, this.o = e;
|
|
377
369
|
}
|
|
378
370
|
getToken() {
|
|
379
|
-
return Promise.resolve(new
|
|
371
|
+
return Promise.resolve(new Q(this.t, this.i, this.o));
|
|
380
372
|
}
|
|
381
373
|
start(t, n) {
|
|
382
374
|
// Fire with initial uid.
|
|
@@ -386,6 +378,27 @@ n) {
|
|
|
386
378
|
invalidateToken() {}
|
|
387
379
|
}
|
|
388
380
|
|
|
381
|
+
class W {
|
|
382
|
+
constructor(t) {
|
|
383
|
+
this.value = t, this.type = "AppCheck", this.headers = new Map, t && t.length > 0 && this.headers.set("x-firebase-appcheck", this.value);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/** AppCheck token provider for the Lite SDK. */ class Y {
|
|
388
|
+
constructor(t) {
|
|
389
|
+
this.u = t, this.appCheck = null, t.onInit((t => {
|
|
390
|
+
this.appCheck = t;
|
|
391
|
+
}));
|
|
392
|
+
}
|
|
393
|
+
getToken() {
|
|
394
|
+
return this.appCheck ? this.appCheck.getToken().then((t => t ? (v("string" == typeof t.token),
|
|
395
|
+
new W(t.token)) : null)) : Promise.resolve(null);
|
|
396
|
+
}
|
|
397
|
+
invalidateToken() {}
|
|
398
|
+
start(t, n) {}
|
|
399
|
+
shutdown() {}
|
|
400
|
+
}
|
|
401
|
+
|
|
389
402
|
/**
|
|
390
403
|
* Builds a CredentialsProvider depending on the type of
|
|
391
404
|
* the credentials passed in.
|
|
@@ -406,7 +419,7 @@ n) {
|
|
|
406
419
|
* See the License for the specific language governing permissions and
|
|
407
420
|
* limitations under the License.
|
|
408
421
|
*/
|
|
409
|
-
class
|
|
422
|
+
class H {
|
|
410
423
|
/**
|
|
411
424
|
* Constructs a DatabaseInfo using the provided host, databaseId and
|
|
412
425
|
* persistenceKey.
|
|
@@ -435,7 +448,7 @@ class G {
|
|
|
435
448
|
* Represents the database ID a Firestore client is associated with.
|
|
436
449
|
* @internal
|
|
437
450
|
*/
|
|
438
|
-
class
|
|
451
|
+
class K {
|
|
439
452
|
constructor(t, n) {
|
|
440
453
|
this.projectId = t, this.database = n || "(default)";
|
|
441
454
|
}
|
|
@@ -443,7 +456,7 @@ class H {
|
|
|
443
456
|
return "(default)" === this.database;
|
|
444
457
|
}
|
|
445
458
|
isEqual(t) {
|
|
446
|
-
return t instanceof
|
|
459
|
+
return t instanceof K && t.projectId === this.projectId && t.database === this.database;
|
|
447
460
|
}
|
|
448
461
|
}
|
|
449
462
|
|
|
@@ -466,7 +479,7 @@ class H {
|
|
|
466
479
|
/**
|
|
467
480
|
* Path represents an ordered sequence of string segments.
|
|
468
481
|
*/
|
|
469
|
-
class
|
|
482
|
+
class J {
|
|
470
483
|
constructor(t, n, e) {
|
|
471
484
|
void 0 === n ? n = 0 : n > t.length && g(), void 0 === e ? e = t.length - n : e > t.length - n && g(),
|
|
472
485
|
this.segments = t, this.offset = n, this.len = e;
|
|
@@ -475,11 +488,11 @@ class Y {
|
|
|
475
488
|
return this.len;
|
|
476
489
|
}
|
|
477
490
|
isEqual(t) {
|
|
478
|
-
return 0 ===
|
|
491
|
+
return 0 === J.comparator(this, t);
|
|
479
492
|
}
|
|
480
493
|
child(t) {
|
|
481
494
|
const n = this.segments.slice(this.offset, this.limit());
|
|
482
|
-
return t instanceof
|
|
495
|
+
return t instanceof J ? t.forEach((t => {
|
|
483
496
|
n.push(t);
|
|
484
497
|
})) : n.push(t), this.construct(n);
|
|
485
498
|
}
|
|
@@ -536,9 +549,9 @@ class Y {
|
|
|
536
549
|
* within Firestore.
|
|
537
550
|
*
|
|
538
551
|
* @internal
|
|
539
|
-
*/ class
|
|
552
|
+
*/ class X extends J {
|
|
540
553
|
construct(t, n, e) {
|
|
541
|
-
return new
|
|
554
|
+
return new X(t, n, e);
|
|
542
555
|
}
|
|
543
556
|
canonicalString() {
|
|
544
557
|
// NOTE: The client is ignorant of any path segments containing escape
|
|
@@ -559,35 +572,35 @@ class Y {
|
|
|
559
572
|
// for legacy reasons and should not be used frequently).
|
|
560
573
|
const n = [];
|
|
561
574
|
for (const e of t) {
|
|
562
|
-
if (e.indexOf("//") >= 0) throw new
|
|
575
|
+
if (e.indexOf("//") >= 0) throw new k(A, `Invalid segment (${e}). Paths must not contain // in them.`);
|
|
563
576
|
// Strip leading and traling slashed.
|
|
564
577
|
n.push(...e.split("/").filter((t => t.length > 0)));
|
|
565
578
|
}
|
|
566
|
-
return new
|
|
579
|
+
return new X(n);
|
|
567
580
|
}
|
|
568
581
|
static emptyPath() {
|
|
569
|
-
return new
|
|
582
|
+
return new X([]);
|
|
570
583
|
}
|
|
571
584
|
}
|
|
572
585
|
|
|
573
|
-
const
|
|
586
|
+
const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
574
587
|
|
|
575
588
|
/**
|
|
576
589
|
* A dot-separated path for navigating sub-objects within a document.
|
|
577
590
|
* @internal
|
|
578
|
-
*/ class
|
|
591
|
+
*/ class tt extends J {
|
|
579
592
|
construct(t, n, e) {
|
|
580
|
-
return new
|
|
593
|
+
return new tt(t, n, e);
|
|
581
594
|
}
|
|
582
595
|
/**
|
|
583
596
|
* Returns true if the string could be used as a segment in a field path
|
|
584
597
|
* without escaping.
|
|
585
598
|
*/ static isValidIdentifier(t) {
|
|
586
|
-
return
|
|
599
|
+
return Z.test(t);
|
|
587
600
|
}
|
|
588
601
|
canonicalString() {
|
|
589
602
|
return this.toArray().map((t => (t = t.replace(/\\/g, "\\\\").replace(/`/g, "\\`"),
|
|
590
|
-
|
|
603
|
+
tt.isValidIdentifier(t) || (t = "`" + t + "`"), t))).join(".");
|
|
591
604
|
}
|
|
592
605
|
toString() {
|
|
593
606
|
return this.canonicalString();
|
|
@@ -600,7 +613,7 @@ const J = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
600
613
|
/**
|
|
601
614
|
* The field designating the key of a document.
|
|
602
615
|
*/ static keyField() {
|
|
603
|
-
return new
|
|
616
|
+
return new tt([ "__name__" ]);
|
|
604
617
|
}
|
|
605
618
|
/**
|
|
606
619
|
* Parses a field string from the given server-formatted string.
|
|
@@ -615,24 +628,24 @@ const J = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
615
628
|
const n = [];
|
|
616
629
|
let e = "", r = 0;
|
|
617
630
|
const s = () => {
|
|
618
|
-
if (0 === e.length) throw new
|
|
631
|
+
if (0 === e.length) throw new k(A, `Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);
|
|
619
632
|
n.push(e), e = "";
|
|
620
633
|
};
|
|
621
634
|
let i = !1;
|
|
622
635
|
for (;r < t.length; ) {
|
|
623
636
|
const n = t[r];
|
|
624
637
|
if ("\\" === n) {
|
|
625
|
-
if (r + 1 === t.length) throw new
|
|
638
|
+
if (r + 1 === t.length) throw new k(A, "Path has trailing escape character: " + t);
|
|
626
639
|
const n = t[r + 1];
|
|
627
|
-
if ("\\" !== n && "." !== n && "`" !== n) throw new
|
|
640
|
+
if ("\\" !== n && "." !== n && "`" !== n) throw new k(A, "Path has invalid escape sequence: " + t);
|
|
628
641
|
e += n, r += 2;
|
|
629
642
|
} else "`" === n ? (i = !i, r++) : "." !== n || i ? (e += n, r++) : (s(), r++);
|
|
630
643
|
}
|
|
631
|
-
if (s(), i) throw new
|
|
632
|
-
return new
|
|
644
|
+
if (s(), i) throw new k(A, "Unterminated ` in path: " + t);
|
|
645
|
+
return new tt(n);
|
|
633
646
|
}
|
|
634
647
|
static emptyPath() {
|
|
635
|
-
return new
|
|
648
|
+
return new tt([]);
|
|
636
649
|
}
|
|
637
650
|
}
|
|
638
651
|
|
|
@@ -654,27 +667,27 @@ const J = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
654
667
|
*/
|
|
655
668
|
/**
|
|
656
669
|
* @internal
|
|
657
|
-
*/ class
|
|
670
|
+
*/ class nt {
|
|
658
671
|
constructor(t) {
|
|
659
672
|
this.path = t;
|
|
660
673
|
}
|
|
661
674
|
static fromPath(t) {
|
|
662
|
-
return new X
|
|
675
|
+
return new nt(X.fromString(t));
|
|
663
676
|
}
|
|
664
677
|
static fromName(t) {
|
|
665
|
-
return new X
|
|
678
|
+
return new nt(X.fromString(t).popFirst(5));
|
|
666
679
|
}
|
|
667
680
|
/** Returns true if the document is in the specified collectionId. */ hasCollectionId(t) {
|
|
668
681
|
return this.path.length >= 2 && this.path.get(this.path.length - 2) === t;
|
|
669
682
|
}
|
|
670
683
|
isEqual(t) {
|
|
671
|
-
return null !== t && 0 ===
|
|
684
|
+
return null !== t && 0 === X.comparator(this.path, t.path);
|
|
672
685
|
}
|
|
673
686
|
toString() {
|
|
674
687
|
return this.path.toString();
|
|
675
688
|
}
|
|
676
689
|
static comparator(t, n) {
|
|
677
|
-
return
|
|
690
|
+
return X.comparator(t.path, n.path);
|
|
678
691
|
}
|
|
679
692
|
static isDocumentKey(t) {
|
|
680
693
|
return t.length % 2 == 0;
|
|
@@ -685,7 +698,7 @@ const J = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
685
698
|
* @param segments - The segments of the path to the document
|
|
686
699
|
* @returns A new instance of DocumentKey
|
|
687
700
|
*/ static fromSegments(t) {
|
|
688
|
-
return new
|
|
701
|
+
return new nt(new X(t.slice()));
|
|
689
702
|
}
|
|
690
703
|
}
|
|
691
704
|
|
|
@@ -704,8 +717,8 @@ const J = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
704
717
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
705
718
|
* See the License for the specific language governing permissions and
|
|
706
719
|
* limitations under the License.
|
|
707
|
-
*/ function
|
|
708
|
-
if (!e) throw new
|
|
720
|
+
*/ function et(t, n, e) {
|
|
721
|
+
if (!e) throw new k(A, `Function ${t}() cannot be called with an empty ${n}.`);
|
|
709
722
|
}
|
|
710
723
|
|
|
711
724
|
/**
|
|
@@ -716,15 +729,15 @@ const J = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
716
729
|
* Validates that `path` refers to a document (indicated by the fact it contains
|
|
717
730
|
* an even numbers of segments).
|
|
718
731
|
*/
|
|
719
|
-
function
|
|
720
|
-
if (!
|
|
732
|
+
function rt(t) {
|
|
733
|
+
if (!nt.isDocumentKey(t)) throw new k(A, `Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`);
|
|
721
734
|
}
|
|
722
735
|
|
|
723
736
|
/**
|
|
724
737
|
* Validates that `path` refers to a collection (indicated by the fact it
|
|
725
738
|
* contains an odd numbers of segments).
|
|
726
|
-
*/ function
|
|
727
|
-
if (
|
|
739
|
+
*/ function st(t) {
|
|
740
|
+
if (nt.isDocumentKey(t)) throw new k(A, `Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`);
|
|
728
741
|
}
|
|
729
742
|
|
|
730
743
|
/**
|
|
@@ -732,7 +745,7 @@ function nt(t) {
|
|
|
732
745
|
* (i.e. excludes Array, Date, etc.).
|
|
733
746
|
*/
|
|
734
747
|
/** Returns a string describing the type / value of the provided input. */
|
|
735
|
-
function
|
|
748
|
+
function it(t) {
|
|
736
749
|
if (void 0 === t) return "undefined";
|
|
737
750
|
if (null === t) return "null";
|
|
738
751
|
if ("string" == typeof t) return t.length > 20 && (t = `${t.substring(0, 20)}...`),
|
|
@@ -761,24 +774,24 @@ function rt(t) {
|
|
|
761
774
|
return "function" == typeof t ? "a function" : g();
|
|
762
775
|
}
|
|
763
776
|
|
|
764
|
-
function
|
|
777
|
+
function ot(t,
|
|
765
778
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
766
779
|
n) {
|
|
767
780
|
if ("_delegate" in t && (
|
|
768
781
|
// Unwrap Compat types
|
|
769
782
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
770
783
|
t = t._delegate), !(t instanceof n)) {
|
|
771
|
-
if (n.name === t.constructor.name) throw new
|
|
784
|
+
if (n.name === t.constructor.name) throw new k(A, "Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");
|
|
772
785
|
{
|
|
773
|
-
const e =
|
|
774
|
-
throw new
|
|
786
|
+
const e = it(t);
|
|
787
|
+
throw new k(A, `Expected type '${n.name}', but it was: ${e}`);
|
|
775
788
|
}
|
|
776
789
|
}
|
|
777
790
|
return t;
|
|
778
791
|
}
|
|
779
792
|
|
|
780
|
-
function
|
|
781
|
-
if (n <= 0) throw new
|
|
793
|
+
function ut(t, n) {
|
|
794
|
+
if (n <= 0) throw new k(A, `Function ${t}() requires a positive number, but it was: ${n}.`);
|
|
782
795
|
}
|
|
783
796
|
|
|
784
797
|
/**
|
|
@@ -799,11 +812,11 @@ function it(t, n) {
|
|
|
799
812
|
*/
|
|
800
813
|
/**
|
|
801
814
|
* Returns whether a variable is either undefined or null.
|
|
802
|
-
*/ function
|
|
815
|
+
*/ function ct(t) {
|
|
803
816
|
return null == t;
|
|
804
817
|
}
|
|
805
818
|
|
|
806
|
-
/** Returns whether the value represents -0. */ function
|
|
819
|
+
/** Returns whether the value represents -0. */ function at(t) {
|
|
807
820
|
// Detect if the value is -0.0. Based on polyfill from
|
|
808
821
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
809
822
|
return 0 === t && 1 / t == -1 / 0;
|
|
@@ -829,7 +842,7 @@ function it(t, n) {
|
|
|
829
842
|
* See the License for the specific language governing permissions and
|
|
830
843
|
* limitations under the License.
|
|
831
844
|
*/
|
|
832
|
-
const
|
|
845
|
+
const ht = {
|
|
833
846
|
BatchGetDocuments: "batchGet",
|
|
834
847
|
Commit: "commit",
|
|
835
848
|
RunQuery: "runQuery"
|
|
@@ -866,7 +879,7 @@ const ct = {
|
|
|
866
879
|
* are used for reverse lookups from the webchannel stream. Do NOT change the
|
|
867
880
|
* names of these identifiers or change this into a const enum.
|
|
868
881
|
*/
|
|
869
|
-
var
|
|
882
|
+
var lt, ft;
|
|
870
883
|
|
|
871
884
|
/**
|
|
872
885
|
* Converts an HTTP Status Code to the equivalent error code.
|
|
@@ -875,8 +888,8 @@ var at, ht;
|
|
|
875
888
|
* @returns The equivalent Code. Unknown status codes are mapped to
|
|
876
889
|
* Code.UNKNOWN.
|
|
877
890
|
*/
|
|
878
|
-
function
|
|
879
|
-
if (void 0 === t) return p("RPC_ERROR", "HTTP error has no status"),
|
|
891
|
+
function dt(t) {
|
|
892
|
+
if (void 0 === t) return p("RPC_ERROR", "HTTP error has no status"), I;
|
|
880
893
|
// The canonical error codes for Google APIs [1] specify mapping onto HTTP
|
|
881
894
|
// status codes but the mapping is not bijective. In each case of ambiguity
|
|
882
895
|
// this function chooses a primary error.
|
|
@@ -923,11 +936,11 @@ function lt(t) {
|
|
|
923
936
|
|
|
924
937
|
case 499:
|
|
925
938
|
// Client Closed Request
|
|
926
|
-
return
|
|
939
|
+
return T;
|
|
927
940
|
|
|
928
941
|
case 500:
|
|
929
942
|
// Internal Server Error
|
|
930
|
-
return
|
|
943
|
+
return I;
|
|
931
944
|
|
|
932
945
|
// Other possibilities:
|
|
933
946
|
// return Code.INTERNAL;
|
|
@@ -945,7 +958,7 @@ function lt(t) {
|
|
|
945
958
|
return P;
|
|
946
959
|
|
|
947
960
|
default:
|
|
948
|
-
return t >= 200 && t < 300 ? E : t >= 400 && t < 500 ? F : t >= 500 && t < 600 ? O :
|
|
961
|
+
return t >= 200 && t < 300 ? E : t >= 400 && t < 500 ? F : t >= 500 && t < 600 ? O : I;
|
|
949
962
|
}
|
|
950
963
|
}
|
|
951
964
|
|
|
@@ -968,16 +981,16 @@ function lt(t) {
|
|
|
968
981
|
/**
|
|
969
982
|
* A Rest-based connection that relies on the native HTTP stack
|
|
970
983
|
* (e.g. `fetch` or a polyfill).
|
|
971
|
-
*/ (
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
984
|
+
*/ (ft = lt || (lt = {}))[ft.OK = 0] = "OK", ft[ft.CANCELLED = 1] = "CANCELLED",
|
|
985
|
+
ft[ft.UNKNOWN = 2] = "UNKNOWN", ft[ft.INVALID_ARGUMENT = 3] = "INVALID_ARGUMENT",
|
|
986
|
+
ft[ft.DEADLINE_EXCEEDED = 4] = "DEADLINE_EXCEEDED", ft[ft.NOT_FOUND = 5] = "NOT_FOUND",
|
|
987
|
+
ft[ft.ALREADY_EXISTS = 6] = "ALREADY_EXISTS", ft[ft.PERMISSION_DENIED = 7] = "PERMISSION_DENIED",
|
|
988
|
+
ft[ft.UNAUTHENTICATED = 16] = "UNAUTHENTICATED", ft[ft.RESOURCE_EXHAUSTED = 8] = "RESOURCE_EXHAUSTED",
|
|
989
|
+
ft[ft.FAILED_PRECONDITION = 9] = "FAILED_PRECONDITION", ft[ft.ABORTED = 10] = "ABORTED",
|
|
990
|
+
ft[ft.OUT_OF_RANGE = 11] = "OUT_OF_RANGE", ft[ft.UNIMPLEMENTED = 12] = "UNIMPLEMENTED",
|
|
991
|
+
ft[ft.INTERNAL = 13] = "INTERNAL", ft[ft.UNAVAILABLE = 14] = "UNAVAILABLE", ft[ft.DATA_LOSS = 15] = "DATA_LOSS";
|
|
979
992
|
|
|
980
|
-
class
|
|
993
|
+
class wt extends
|
|
981
994
|
/**
|
|
982
995
|
* Base class for all Rest-based connections to the backend (WebChannel and
|
|
983
996
|
* HTTP).
|
|
@@ -986,38 +999,38 @@ class {
|
|
|
986
999
|
constructor(t) {
|
|
987
1000
|
this.databaseInfo = t, this.databaseId = t.databaseId;
|
|
988
1001
|
const n = t.ssl ? "https" : "http";
|
|
989
|
-
this.
|
|
1002
|
+
this.h = n + "://" + t.host, this.l = "projects/" + this.databaseId.projectId + "/databases/" + this.databaseId.database + "/documents";
|
|
990
1003
|
}
|
|
991
|
-
|
|
992
|
-
const
|
|
993
|
-
m("RestConnection", "Sending: ",
|
|
994
|
-
const
|
|
995
|
-
return this.
|
|
1004
|
+
m(t, n, e, r, s) {
|
|
1005
|
+
const i = this.p(t, n);
|
|
1006
|
+
m("RestConnection", "Sending: ", i, e);
|
|
1007
|
+
const o = {};
|
|
1008
|
+
return this.g(o, r, s), this.v(t, i, o, e).then((t => (m("RestConnection", "Received: ", t),
|
|
996
1009
|
t)), (n => {
|
|
997
|
-
throw y("RestConnection", `${t} failed with error: `, n, "url: ",
|
|
1010
|
+
throw y("RestConnection", `${t} failed with error: `, n, "url: ", i, "request:", e),
|
|
998
1011
|
n;
|
|
999
1012
|
}));
|
|
1000
1013
|
}
|
|
1001
|
-
|
|
1014
|
+
T(t, n, e, r, s) {
|
|
1002
1015
|
// The REST API automatically aggregates all of the streamed results, so we
|
|
1003
1016
|
// can just use the normal invoke() method.
|
|
1004
|
-
return this.
|
|
1017
|
+
return this.m(t, n, e, r, s);
|
|
1005
1018
|
}
|
|
1006
1019
|
/**
|
|
1007
1020
|
* Modifies the headers for a request, adding any authorization token if
|
|
1008
1021
|
* present and any additional headers for the request.
|
|
1009
|
-
*/
|
|
1010
|
-
|
|
1022
|
+
*/ g(t, n, e) {
|
|
1023
|
+
t["X-Goog-Api-Client"] = "gl-js/ fire/" + f,
|
|
1011
1024
|
// Content-Type: text/plain will avoid preflight requests which might
|
|
1012
1025
|
// mess with CORS and redirects by proxies. If we add custom headers
|
|
1013
1026
|
// we will need to change this code to potentially use the $httpOverwrite
|
|
1014
1027
|
// parameter supported by ESF to avoid triggering preflight requests.
|
|
1015
1028
|
t["Content-Type"] = "text/plain", this.databaseInfo.appId && (t["X-Firebase-GMPID"] = this.databaseInfo.appId),
|
|
1016
|
-
n
|
|
1029
|
+
n && n.headers.forEach(((n, e) => t[e] = n)), e && e.headers.forEach(((n, e) => t[e] = n));
|
|
1017
1030
|
}
|
|
1018
|
-
|
|
1019
|
-
const e =
|
|
1020
|
-
return `${this.
|
|
1031
|
+
p(t, n) {
|
|
1032
|
+
const e = ht[t];
|
|
1033
|
+
return `${this.h}/v1/${n}:${e}`;
|
|
1021
1034
|
}
|
|
1022
1035
|
} {
|
|
1023
1036
|
/**
|
|
@@ -1027,10 +1040,10 @@ class {
|
|
|
1027
1040
|
constructor(t, n) {
|
|
1028
1041
|
super(t), this.I = n;
|
|
1029
1042
|
}
|
|
1030
|
-
|
|
1043
|
+
A(t, n) {
|
|
1031
1044
|
throw new Error("Not supported by FetchConnection");
|
|
1032
1045
|
}
|
|
1033
|
-
async
|
|
1046
|
+
async v(t, n, e, r) {
|
|
1034
1047
|
const s = JSON.stringify(r);
|
|
1035
1048
|
let i;
|
|
1036
1049
|
try {
|
|
@@ -1040,9 +1053,9 @@ class {
|
|
|
1040
1053
|
body: s
|
|
1041
1054
|
});
|
|
1042
1055
|
} catch (t) {
|
|
1043
|
-
throw new
|
|
1056
|
+
throw new k(dt(t.status), "Request failed with error: " + t.statusText);
|
|
1044
1057
|
}
|
|
1045
|
-
if (!i.ok) throw new
|
|
1058
|
+
if (!i.ok) throw new k(dt(i.status), "Request failed with error: " + i.statusText);
|
|
1046
1059
|
return i.json();
|
|
1047
1060
|
}
|
|
1048
1061
|
}
|
|
@@ -1085,7 +1098,7 @@ class {
|
|
|
1085
1098
|
*
|
|
1086
1099
|
* If `nBytes < 0` , an error will be thrown.
|
|
1087
1100
|
*/
|
|
1088
|
-
function
|
|
1101
|
+
function mt(t) {
|
|
1089
1102
|
// Polyfills for IE and WebWorker by using `self` and `msCrypto` when `crypto` is not available.
|
|
1090
1103
|
const n =
|
|
1091
1104
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1111,14 +1124,14 @@ function dt(t) {
|
|
|
1111
1124
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1112
1125
|
* See the License for the specific language governing permissions and
|
|
1113
1126
|
* limitations under the License.
|
|
1114
|
-
*/ class
|
|
1115
|
-
static
|
|
1127
|
+
*/ class pt {
|
|
1128
|
+
static P() {
|
|
1116
1129
|
// Alphanumeric characters
|
|
1117
1130
|
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", n = Math.floor(256 / t.length) * t.length;
|
|
1118
1131
|
// The largest byte value that is a multiple of `char.length`.
|
|
1119
1132
|
let e = "";
|
|
1120
1133
|
for (;e.length < 20; ) {
|
|
1121
|
-
const r =
|
|
1134
|
+
const r = mt(40);
|
|
1122
1135
|
for (let s = 0; s < r.length; ++s)
|
|
1123
1136
|
// Only accept values that are [0, maxMultiple), this ensures they can
|
|
1124
1137
|
// be evenly mapped to indices of `chars` via a modulo operation.
|
|
@@ -1128,11 +1141,11 @@ function dt(t) {
|
|
|
1128
1141
|
}
|
|
1129
1142
|
}
|
|
1130
1143
|
|
|
1131
|
-
function
|
|
1144
|
+
function yt(t, n) {
|
|
1132
1145
|
return t < n ? -1 : t > n ? 1 : 0;
|
|
1133
1146
|
}
|
|
1134
1147
|
|
|
1135
|
-
/** Helper to compare arrays using isEqual(). */ function
|
|
1148
|
+
/** Helper to compare arrays using isEqual(). */ function _t(t, n, e) {
|
|
1136
1149
|
return t.length === n.length && t.every(((t, r) => e(t, n[r])));
|
|
1137
1150
|
}
|
|
1138
1151
|
|
|
@@ -1167,7 +1180,7 @@ function mt(t, n) {
|
|
|
1167
1180
|
* For examples and further specifications, refer to the
|
|
1168
1181
|
* {@link https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto | Timestamp definition}.
|
|
1169
1182
|
*/
|
|
1170
|
-
class
|
|
1183
|
+
class gt {
|
|
1171
1184
|
/**
|
|
1172
1185
|
* Creates a new timestamp.
|
|
1173
1186
|
*
|
|
@@ -1188,18 +1201,18 @@ class yt {
|
|
|
1188
1201
|
* The fractions of a second at nanosecond resolution.*
|
|
1189
1202
|
*/
|
|
1190
1203
|
n) {
|
|
1191
|
-
if (this.seconds = t, this.nanoseconds = n, n < 0) throw new
|
|
1192
|
-
if (n >= 1e9) throw new
|
|
1193
|
-
if (t < -62135596800) throw new
|
|
1204
|
+
if (this.seconds = t, this.nanoseconds = n, n < 0) throw new k(A, "Timestamp nanoseconds out of range: " + n);
|
|
1205
|
+
if (n >= 1e9) throw new k(A, "Timestamp nanoseconds out of range: " + n);
|
|
1206
|
+
if (t < -62135596800) throw new k(A, "Timestamp seconds out of range: " + t);
|
|
1194
1207
|
// This will break in the year 10,000.
|
|
1195
|
-
if (t >= 253402300800) throw new
|
|
1208
|
+
if (t >= 253402300800) throw new k(A, "Timestamp seconds out of range: " + t);
|
|
1196
1209
|
}
|
|
1197
1210
|
/**
|
|
1198
1211
|
* Creates a new timestamp with the current date, with millisecond precision.
|
|
1199
1212
|
*
|
|
1200
1213
|
* @returns a new timestamp representing the current date.
|
|
1201
1214
|
*/ static now() {
|
|
1202
|
-
return
|
|
1215
|
+
return gt.fromMillis(Date.now());
|
|
1203
1216
|
}
|
|
1204
1217
|
/**
|
|
1205
1218
|
* Creates a new timestamp from the given date.
|
|
@@ -1208,7 +1221,7 @@ class yt {
|
|
|
1208
1221
|
* @returns A new `Timestamp` representing the same point in time as the given
|
|
1209
1222
|
* date.
|
|
1210
1223
|
*/ static fromDate(t) {
|
|
1211
|
-
return
|
|
1224
|
+
return gt.fromMillis(t.getTime());
|
|
1212
1225
|
}
|
|
1213
1226
|
/**
|
|
1214
1227
|
* Creates a new timestamp from the given number of milliseconds.
|
|
@@ -1219,7 +1232,7 @@ class yt {
|
|
|
1219
1232
|
* number of milliseconds.
|
|
1220
1233
|
*/ static fromMillis(t) {
|
|
1221
1234
|
const n = Math.floor(t / 1e3), e = Math.floor(1e6 * (t - 1e3 * n));
|
|
1222
|
-
return new
|
|
1235
|
+
return new gt(n, e);
|
|
1223
1236
|
}
|
|
1224
1237
|
/**
|
|
1225
1238
|
* Converts a `Timestamp` to a JavaScript `Date` object. This conversion
|
|
@@ -1241,7 +1254,7 @@ class yt {
|
|
|
1241
1254
|
return 1e3 * this.seconds + this.nanoseconds / 1e6;
|
|
1242
1255
|
}
|
|
1243
1256
|
_compareTo(t) {
|
|
1244
|
-
return this.seconds === t.seconds ?
|
|
1257
|
+
return this.seconds === t.seconds ? yt(this.nanoseconds, t.nanoseconds) : yt(this.seconds, t.seconds);
|
|
1245
1258
|
}
|
|
1246
1259
|
/**
|
|
1247
1260
|
* Returns true if this `Timestamp` is equal to the provided one.
|
|
@@ -1297,15 +1310,15 @@ class yt {
|
|
|
1297
1310
|
/**
|
|
1298
1311
|
* A version of a document in Firestore. This corresponds to the version
|
|
1299
1312
|
* timestamp, such as update_time or read_time.
|
|
1300
|
-
*/ class
|
|
1313
|
+
*/ class vt {
|
|
1301
1314
|
constructor(t) {
|
|
1302
1315
|
this.timestamp = t;
|
|
1303
1316
|
}
|
|
1304
1317
|
static fromTimestamp(t) {
|
|
1305
|
-
return new
|
|
1318
|
+
return new vt(t);
|
|
1306
1319
|
}
|
|
1307
1320
|
static min() {
|
|
1308
|
-
return new
|
|
1321
|
+
return new vt(new gt(0, 0));
|
|
1309
1322
|
}
|
|
1310
1323
|
compareTo(t) {
|
|
1311
1324
|
return this.timestamp._compareTo(t.timestamp);
|
|
@@ -1340,13 +1353,13 @@ class yt {
|
|
|
1340
1353
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1341
1354
|
* See the License for the specific language governing permissions and
|
|
1342
1355
|
* limitations under the License.
|
|
1343
|
-
*/ function
|
|
1356
|
+
*/ function bt(t) {
|
|
1344
1357
|
let n = 0;
|
|
1345
1358
|
for (const e in t) Object.prototype.hasOwnProperty.call(t, e) && n++;
|
|
1346
1359
|
return n;
|
|
1347
1360
|
}
|
|
1348
1361
|
|
|
1349
|
-
function
|
|
1362
|
+
function Et(t, n) {
|
|
1350
1363
|
for (const e in t) Object.prototype.hasOwnProperty.call(t, e) && n(e, t[e]);
|
|
1351
1364
|
}
|
|
1352
1365
|
|
|
@@ -1376,12 +1389,12 @@ function vt(t, n) {
|
|
|
1376
1389
|
* If foo is not an object, foo is replaced with an object
|
|
1377
1390
|
* containing foo
|
|
1378
1391
|
*/
|
|
1379
|
-
class
|
|
1392
|
+
class Tt {
|
|
1380
1393
|
constructor(t) {
|
|
1381
1394
|
this.fields = t,
|
|
1382
1395
|
// TODO(dimond): validation of FieldMask
|
|
1383
1396
|
// Sort the field mask to support `FieldMask.isEqual()` and assert below.
|
|
1384
|
-
t.sort(
|
|
1397
|
+
t.sort(tt.comparator);
|
|
1385
1398
|
}
|
|
1386
1399
|
/**
|
|
1387
1400
|
* Verifies that `fieldPath` is included by at least one field in this field
|
|
@@ -1393,7 +1406,7 @@ class bt {
|
|
|
1393
1406
|
return !1;
|
|
1394
1407
|
}
|
|
1395
1408
|
isEqual(t) {
|
|
1396
|
-
return
|
|
1409
|
+
return _t(this.fields, t.fields, ((t, n) => t.isEqual(n)));
|
|
1397
1410
|
}
|
|
1398
1411
|
}
|
|
1399
1412
|
|
|
@@ -1416,7 +1429,7 @@ class bt {
|
|
|
1416
1429
|
// WebSafe uses a different URL-encoding safe alphabet that doesn't match
|
|
1417
1430
|
// the encoding used on the backend.
|
|
1418
1431
|
/** Converts a Base64 encoded string to a binary string. */
|
|
1419
|
-
function
|
|
1432
|
+
function It(t) {
|
|
1420
1433
|
return String.fromCharCode.apply(null,
|
|
1421
1434
|
// We use `decodeStringToByteArray()` instead of `decodeString()` since
|
|
1422
1435
|
// `decodeString()` returns Unicode strings, which doesn't match the values
|
|
@@ -1450,13 +1463,13 @@ function Et(t) {
|
|
|
1450
1463
|
* before being sent as a proto.
|
|
1451
1464
|
* @internal
|
|
1452
1465
|
*/
|
|
1453
|
-
class
|
|
1466
|
+
class At {
|
|
1454
1467
|
constructor(t) {
|
|
1455
1468
|
this.binaryString = t;
|
|
1456
1469
|
}
|
|
1457
1470
|
static fromBase64String(t) {
|
|
1458
|
-
const n =
|
|
1459
|
-
return new
|
|
1471
|
+
const n = It(t);
|
|
1472
|
+
return new At(n);
|
|
1460
1473
|
}
|
|
1461
1474
|
static fromUint8Array(t) {
|
|
1462
1475
|
const n =
|
|
@@ -1471,7 +1484,7 @@ class It {
|
|
|
1471
1484
|
/**
|
|
1472
1485
|
* Helper function to convert a binary string to an Uint8Array.
|
|
1473
1486
|
*/ (t);
|
|
1474
|
-
return new
|
|
1487
|
+
return new At(n);
|
|
1475
1488
|
}
|
|
1476
1489
|
toBase64() {
|
|
1477
1490
|
return function(t) {
|
|
@@ -1509,21 +1522,21 @@ class It {
|
|
|
1509
1522
|
return 2 * this.binaryString.length;
|
|
1510
1523
|
}
|
|
1511
1524
|
compareTo(t) {
|
|
1512
|
-
return
|
|
1525
|
+
return yt(this.binaryString, t.binaryString);
|
|
1513
1526
|
}
|
|
1514
1527
|
isEqual(t) {
|
|
1515
1528
|
return this.binaryString === t.binaryString;
|
|
1516
1529
|
}
|
|
1517
1530
|
}
|
|
1518
1531
|
|
|
1519
|
-
|
|
1532
|
+
At.EMPTY_BYTE_STRING = new At("");
|
|
1520
1533
|
|
|
1521
|
-
const
|
|
1534
|
+
const Pt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
1522
1535
|
|
|
1523
1536
|
/**
|
|
1524
1537
|
* Converts the possible Proto values for a timestamp value into a "seconds and
|
|
1525
1538
|
* nanos" representation.
|
|
1526
|
-
*/ function
|
|
1539
|
+
*/ function Rt(t) {
|
|
1527
1540
|
// The json interface (for the browser) will return an iso timestamp string,
|
|
1528
1541
|
// while the proto js library (for node) will return a
|
|
1529
1542
|
// google.protobuf.Timestamp instance.
|
|
@@ -1532,7 +1545,7 @@ const Tt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1532
1545
|
// (millis), so we do some custom parsing here.
|
|
1533
1546
|
// Parse the nanos right out of the string.
|
|
1534
1547
|
let n = 0;
|
|
1535
|
-
const e =
|
|
1548
|
+
const e = Pt.exec(t);
|
|
1536
1549
|
if (v(!!e), e[1]) {
|
|
1537
1550
|
// Pad the fraction out to 9 digits (nanos).
|
|
1538
1551
|
let t = e[1];
|
|
@@ -1546,21 +1559,21 @@ const Tt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1546
1559
|
};
|
|
1547
1560
|
}
|
|
1548
1561
|
return {
|
|
1549
|
-
seconds:
|
|
1550
|
-
nanos:
|
|
1562
|
+
seconds: Vt(t.seconds),
|
|
1563
|
+
nanos: Vt(t.nanos)
|
|
1551
1564
|
};
|
|
1552
1565
|
}
|
|
1553
1566
|
|
|
1554
1567
|
/**
|
|
1555
1568
|
* Converts the possible Proto types for numbers into a JavaScript number.
|
|
1556
1569
|
* Returns 0 if the value is not numeric.
|
|
1557
|
-
*/ function
|
|
1570
|
+
*/ function Vt(t) {
|
|
1558
1571
|
// TODO(bjornick): Handle int64 greater than 53 bits.
|
|
1559
1572
|
return "number" == typeof t ? t : "string" == typeof t ? Number(t) : 0;
|
|
1560
1573
|
}
|
|
1561
1574
|
|
|
1562
|
-
/** Converts the possible Proto types for Blobs into a ByteString. */ function
|
|
1563
|
-
return "string" == typeof t ?
|
|
1575
|
+
/** Converts the possible Proto types for Blobs into a ByteString. */ function Nt(t) {
|
|
1576
|
+
return "string" == typeof t ? At.fromBase64String(t) : At.fromUint8Array(t);
|
|
1564
1577
|
}
|
|
1565
1578
|
|
|
1566
1579
|
/**
|
|
@@ -1596,7 +1609,7 @@ const Tt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1596
1609
|
* FieldValueOptions to value().
|
|
1597
1610
|
* - With respect to other ServerTimestampValues, they sort by their
|
|
1598
1611
|
* localWriteTime.
|
|
1599
|
-
*/ function
|
|
1612
|
+
*/ function Dt(t) {
|
|
1600
1613
|
var n, e;
|
|
1601
1614
|
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);
|
|
1602
1615
|
}
|
|
@@ -1606,16 +1619,16 @@ const Tt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1606
1619
|
*
|
|
1607
1620
|
* Preserving the previous values allows the user to display the last resoled
|
|
1608
1621
|
* value until the backend responds with the timestamp.
|
|
1609
|
-
*/ function
|
|
1622
|
+
*/ function $t(t) {
|
|
1610
1623
|
const n = t.mapValue.fields.__previous_value__;
|
|
1611
|
-
return
|
|
1624
|
+
return Dt(n) ? $t(n) : n;
|
|
1612
1625
|
}
|
|
1613
1626
|
|
|
1614
1627
|
/**
|
|
1615
1628
|
* Returns the local time at which this timestamp was first set.
|
|
1616
|
-
*/ function
|
|
1617
|
-
const n =
|
|
1618
|
-
return new
|
|
1629
|
+
*/ function Ft(t) {
|
|
1630
|
+
const n = Rt(t.mapValue.fields.__local_write_time__.timestampValue);
|
|
1631
|
+
return new gt(n.seconds, n.nanos);
|
|
1619
1632
|
}
|
|
1620
1633
|
|
|
1621
1634
|
/**
|
|
@@ -1634,13 +1647,13 @@ const Tt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1634
1647
|
* See the License for the specific language governing permissions and
|
|
1635
1648
|
* limitations under the License.
|
|
1636
1649
|
*/
|
|
1637
|
-
/** Extracts the backend's type order for the provided value. */ function
|
|
1638
|
-
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 ?
|
|
1650
|
+
/** Extracts the backend's type order for the provided value. */ function St(t) {
|
|
1651
|
+
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 ? Dt(t) ? 4 /* ServerTimestampValue */ : 10 /* ObjectValue */ : g();
|
|
1639
1652
|
}
|
|
1640
1653
|
|
|
1641
|
-
/** Tests `left` and `right` for equality based on the backend semantics. */ function
|
|
1642
|
-
const e =
|
|
1643
|
-
if (e !==
|
|
1654
|
+
/** Tests `left` and `right` for equality based on the backend semantics. */ function qt(t, n) {
|
|
1655
|
+
const e = St(t);
|
|
1656
|
+
if (e !== St(n)) return !1;
|
|
1644
1657
|
switch (e) {
|
|
1645
1658
|
case 0 /* NullValue */ :
|
|
1646
1659
|
return !0;
|
|
@@ -1649,14 +1662,14 @@ const Tt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1649
1662
|
return t.booleanValue === n.booleanValue;
|
|
1650
1663
|
|
|
1651
1664
|
case 4 /* ServerTimestampValue */ :
|
|
1652
|
-
return
|
|
1665
|
+
return Ft(t).isEqual(Ft(n));
|
|
1653
1666
|
|
|
1654
1667
|
case 3 /* TimestampValue */ :
|
|
1655
1668
|
return function(t, n) {
|
|
1656
1669
|
if ("string" == typeof t.timestampValue && "string" == typeof n.timestampValue && t.timestampValue.length === n.timestampValue.length)
|
|
1657
1670
|
// Use string equality for ISO 8601 timestamps
|
|
1658
1671
|
return t.timestampValue === n.timestampValue;
|
|
1659
|
-
const e =
|
|
1672
|
+
const e = Rt(t.timestampValue), r = Rt(n.timestampValue);
|
|
1660
1673
|
return e.seconds === r.seconds && e.nanos === r.nanos;
|
|
1661
1674
|
}(t, n);
|
|
1662
1675
|
|
|
@@ -1665,7 +1678,7 @@ const Tt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1665
1678
|
|
|
1666
1679
|
case 6 /* BlobValue */ :
|
|
1667
1680
|
return function(t, n) {
|
|
1668
|
-
return
|
|
1681
|
+
return Nt(t.bytesValue).isEqual(Nt(n.bytesValue));
|
|
1669
1682
|
}(t, n);
|
|
1670
1683
|
|
|
1671
1684
|
case 7 /* RefValue */ :
|
|
@@ -1673,27 +1686,27 @@ const Tt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1673
1686
|
|
|
1674
1687
|
case 8 /* GeoPointValue */ :
|
|
1675
1688
|
return function(t, n) {
|
|
1676
|
-
return
|
|
1689
|
+
return Vt(t.geoPointValue.latitude) === Vt(n.geoPointValue.latitude) && Vt(t.geoPointValue.longitude) === Vt(n.geoPointValue.longitude);
|
|
1677
1690
|
}(t, n);
|
|
1678
1691
|
|
|
1679
1692
|
case 2 /* NumberValue */ :
|
|
1680
1693
|
return function(t, n) {
|
|
1681
|
-
if ("integerValue" in t && "integerValue" in n) return
|
|
1694
|
+
if ("integerValue" in t && "integerValue" in n) return Vt(t.integerValue) === Vt(n.integerValue);
|
|
1682
1695
|
if ("doubleValue" in t && "doubleValue" in n) {
|
|
1683
|
-
const e =
|
|
1684
|
-
return e === r ?
|
|
1696
|
+
const e = Vt(t.doubleValue), r = Vt(n.doubleValue);
|
|
1697
|
+
return e === r ? at(e) === at(r) : isNaN(e) && isNaN(r);
|
|
1685
1698
|
}
|
|
1686
1699
|
return !1;
|
|
1687
1700
|
}(t, n);
|
|
1688
1701
|
|
|
1689
1702
|
case 9 /* ArrayValue */ :
|
|
1690
|
-
return
|
|
1703
|
+
return _t(t.arrayValue.values || [], n.arrayValue.values || [], qt);
|
|
1691
1704
|
|
|
1692
1705
|
case 10 /* ObjectValue */ :
|
|
1693
1706
|
return function(t, n) {
|
|
1694
1707
|
const e = t.mapValue.fields || {}, r = n.mapValue.fields || {};
|
|
1695
|
-
if (
|
|
1696
|
-
for (const t in e) if (e.hasOwnProperty(t) && (void 0 === r[t] || !
|
|
1708
|
+
if (bt(e) !== bt(r)) return !1;
|
|
1709
|
+
for (const t in e) if (e.hasOwnProperty(t) && (void 0 === r[t] || !qt(e[t], r[t]))) return !1;
|
|
1697
1710
|
return !0;
|
|
1698
1711
|
}
|
|
1699
1712
|
/** Returns true if the ArrayValue contains the specified element. */ (t, n);
|
|
@@ -1703,40 +1716,40 @@ const Tt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1703
1716
|
}
|
|
1704
1717
|
}
|
|
1705
1718
|
|
|
1706
|
-
function
|
|
1707
|
-
return void 0 !== (t.values || []).find((t =>
|
|
1719
|
+
function xt(t, n) {
|
|
1720
|
+
return void 0 !== (t.values || []).find((t => qt(t, n)));
|
|
1708
1721
|
}
|
|
1709
1722
|
|
|
1710
|
-
function
|
|
1711
|
-
const e =
|
|
1712
|
-
if (e !== r) return
|
|
1723
|
+
function Ot(t, n) {
|
|
1724
|
+
const e = St(t), r = St(n);
|
|
1725
|
+
if (e !== r) return yt(e, r);
|
|
1713
1726
|
switch (e) {
|
|
1714
1727
|
case 0 /* NullValue */ :
|
|
1715
1728
|
return 0;
|
|
1716
1729
|
|
|
1717
1730
|
case 1 /* BooleanValue */ :
|
|
1718
|
-
return
|
|
1731
|
+
return yt(t.booleanValue, n.booleanValue);
|
|
1719
1732
|
|
|
1720
1733
|
case 2 /* NumberValue */ :
|
|
1721
1734
|
return function(t, n) {
|
|
1722
|
-
const e =
|
|
1735
|
+
const e = Vt(t.integerValue || t.doubleValue), r = Vt(n.integerValue || n.doubleValue);
|
|
1723
1736
|
return e < r ? -1 : e > r ? 1 : e === r ? 0 :
|
|
1724
1737
|
// one or both are NaN.
|
|
1725
1738
|
isNaN(e) ? isNaN(r) ? 0 : -1 : 1;
|
|
1726
1739
|
}(t, n);
|
|
1727
1740
|
|
|
1728
1741
|
case 3 /* TimestampValue */ :
|
|
1729
|
-
return
|
|
1742
|
+
return Ct(t.timestampValue, n.timestampValue);
|
|
1730
1743
|
|
|
1731
1744
|
case 4 /* ServerTimestampValue */ :
|
|
1732
|
-
return
|
|
1745
|
+
return Ct(Ft(t), Ft(n));
|
|
1733
1746
|
|
|
1734
1747
|
case 5 /* StringValue */ :
|
|
1735
|
-
return
|
|
1748
|
+
return yt(t.stringValue, n.stringValue);
|
|
1736
1749
|
|
|
1737
1750
|
case 6 /* BlobValue */ :
|
|
1738
1751
|
return function(t, n) {
|
|
1739
|
-
const e =
|
|
1752
|
+
const e = Nt(t), r = Nt(n);
|
|
1740
1753
|
return e.compareTo(r);
|
|
1741
1754
|
}(t.bytesValue, n.bytesValue);
|
|
1742
1755
|
|
|
@@ -1744,27 +1757,27 @@ function qt(t, n) {
|
|
|
1744
1757
|
return function(t, n) {
|
|
1745
1758
|
const e = t.split("/"), r = n.split("/");
|
|
1746
1759
|
for (let t = 0; t < e.length && t < r.length; t++) {
|
|
1747
|
-
const n =
|
|
1760
|
+
const n = yt(e[t], r[t]);
|
|
1748
1761
|
if (0 !== n) return n;
|
|
1749
1762
|
}
|
|
1750
|
-
return
|
|
1763
|
+
return yt(e.length, r.length);
|
|
1751
1764
|
}(t.referenceValue, n.referenceValue);
|
|
1752
1765
|
|
|
1753
1766
|
case 8 /* GeoPointValue */ :
|
|
1754
1767
|
return function(t, n) {
|
|
1755
|
-
const e =
|
|
1768
|
+
const e = yt(Vt(t.latitude), Vt(n.latitude));
|
|
1756
1769
|
if (0 !== e) return e;
|
|
1757
|
-
return
|
|
1770
|
+
return yt(Vt(t.longitude), Vt(n.longitude));
|
|
1758
1771
|
}(t.geoPointValue, n.geoPointValue);
|
|
1759
1772
|
|
|
1760
1773
|
case 9 /* ArrayValue */ :
|
|
1761
1774
|
return function(t, n) {
|
|
1762
1775
|
const e = t.values || [], r = n.values || [];
|
|
1763
1776
|
for (let t = 0; t < e.length && t < r.length; ++t) {
|
|
1764
|
-
const n =
|
|
1777
|
+
const n = Ot(e[t], r[t]);
|
|
1765
1778
|
if (n) return n;
|
|
1766
1779
|
}
|
|
1767
|
-
return
|
|
1780
|
+
return yt(e.length, r.length);
|
|
1768
1781
|
}(t.arrayValue, n.arrayValue);
|
|
1769
1782
|
|
|
1770
1783
|
case 10 /* ObjectValue */ :
|
|
@@ -1776,12 +1789,12 @@ function qt(t, n) {
|
|
|
1776
1789
|
// canonical IDs are independent of insertion order.
|
|
1777
1790
|
r.sort(), i.sort();
|
|
1778
1791
|
for (let t = 0; t < r.length && t < i.length; ++t) {
|
|
1779
|
-
const n =
|
|
1792
|
+
const n = yt(r[t], i[t]);
|
|
1780
1793
|
if (0 !== n) return n;
|
|
1781
|
-
const o =
|
|
1794
|
+
const o = Ot(e[r[t]], s[i[t]]);
|
|
1782
1795
|
if (0 !== o) return o;
|
|
1783
1796
|
}
|
|
1784
|
-
return
|
|
1797
|
+
return yt(r.length, i.length);
|
|
1785
1798
|
}
|
|
1786
1799
|
/** Returns a reference value for the provided database and key. */ (t.mapValue, n.mapValue);
|
|
1787
1800
|
|
|
@@ -1790,35 +1803,35 @@ function qt(t, n) {
|
|
|
1790
1803
|
}
|
|
1791
1804
|
}
|
|
1792
1805
|
|
|
1793
|
-
function
|
|
1794
|
-
if ("string" == typeof t && "string" == typeof n && t.length === n.length) return
|
|
1795
|
-
const e =
|
|
1796
|
-
return 0 !== s ? s :
|
|
1806
|
+
function Ct(t, n) {
|
|
1807
|
+
if ("string" == typeof t && "string" == typeof n && t.length === n.length) return yt(t, n);
|
|
1808
|
+
const e = Rt(t), r = Rt(n), s = yt(e.seconds, r.seconds);
|
|
1809
|
+
return 0 !== s ? s : yt(e.nanos, r.nanos);
|
|
1797
1810
|
}
|
|
1798
1811
|
|
|
1799
|
-
function
|
|
1812
|
+
function Lt(t, n) {
|
|
1800
1813
|
return {
|
|
1801
1814
|
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${n.path.canonicalString()}`
|
|
1802
1815
|
};
|
|
1803
1816
|
}
|
|
1804
1817
|
|
|
1805
|
-
/** Returns true if `value` is an ArrayValue. */ function
|
|
1818
|
+
/** Returns true if `value` is an ArrayValue. */ function kt(t) {
|
|
1806
1819
|
return !!t && "arrayValue" in t;
|
|
1807
1820
|
}
|
|
1808
1821
|
|
|
1809
|
-
/** Returns true if `value` is a NullValue. */ function
|
|
1822
|
+
/** Returns true if `value` is a NullValue. */ function Ut(t) {
|
|
1810
1823
|
return !!t && "nullValue" in t;
|
|
1811
1824
|
}
|
|
1812
1825
|
|
|
1813
|
-
/** Returns true if `value` is NaN. */ function
|
|
1826
|
+
/** Returns true if `value` is NaN. */ function jt(t) {
|
|
1814
1827
|
return !!t && "doubleValue" in t && isNaN(Number(t.doubleValue));
|
|
1815
1828
|
}
|
|
1816
1829
|
|
|
1817
|
-
/** Returns true if `value` is a MapValue. */ function
|
|
1830
|
+
/** Returns true if `value` is a MapValue. */ function Mt(t) {
|
|
1818
1831
|
return !!t && "mapValue" in t;
|
|
1819
1832
|
}
|
|
1820
1833
|
|
|
1821
|
-
/** Creates a deep copy of `source`. */ function
|
|
1834
|
+
/** Creates a deep copy of `source`. */ function Bt(t) {
|
|
1822
1835
|
if (t.geoPointValue) return {
|
|
1823
1836
|
geoPointValue: Object.assign({}, t.geoPointValue)
|
|
1824
1837
|
};
|
|
@@ -1831,7 +1844,7 @@ function Ot(t, n) {
|
|
|
1831
1844
|
fields: {}
|
|
1832
1845
|
}
|
|
1833
1846
|
};
|
|
1834
|
-
return
|
|
1847
|
+
return Et(t.mapValue.fields, ((t, e) => n.mapValue.fields[t] = Bt(e))), n;
|
|
1835
1848
|
}
|
|
1836
1849
|
if (t.arrayValue) {
|
|
1837
1850
|
const n = {
|
|
@@ -1839,7 +1852,7 @@ function Ot(t, n) {
|
|
|
1839
1852
|
values: []
|
|
1840
1853
|
}
|
|
1841
1854
|
};
|
|
1842
|
-
for (let e = 0; e < (t.arrayValue.values || []).length; ++e) n.arrayValue.values[e] =
|
|
1855
|
+
for (let e = 0; e < (t.arrayValue.values || []).length; ++e) n.arrayValue.values[e] = Bt(t.arrayValue.values[e]);
|
|
1843
1856
|
return n;
|
|
1844
1857
|
}
|
|
1845
1858
|
return Object.assign({}, t);
|
|
@@ -1864,12 +1877,12 @@ function Ot(t, n) {
|
|
|
1864
1877
|
/**
|
|
1865
1878
|
* An ObjectValue represents a MapValue in the Firestore Proto and offers the
|
|
1866
1879
|
* ability to add and remove fields (via the ObjectValueBuilder).
|
|
1867
|
-
*/ class
|
|
1880
|
+
*/ class zt {
|
|
1868
1881
|
constructor(t) {
|
|
1869
1882
|
this.value = t;
|
|
1870
1883
|
}
|
|
1871
1884
|
static empty() {
|
|
1872
|
-
return new
|
|
1885
|
+
return new zt({
|
|
1873
1886
|
mapValue: {}
|
|
1874
1887
|
});
|
|
1875
1888
|
}
|
|
@@ -1883,7 +1896,7 @@ function Ot(t, n) {
|
|
|
1883
1896
|
{
|
|
1884
1897
|
let n = this.value;
|
|
1885
1898
|
for (let e = 0; e < t.length - 1; ++e) if (n = (n.mapValue.fields || {})[t.get(e)],
|
|
1886
|
-
!
|
|
1899
|
+
!Mt(n)) return null;
|
|
1887
1900
|
return n = (n.mapValue.fields || {})[t.lastSegment()], n || null;
|
|
1888
1901
|
}
|
|
1889
1902
|
}
|
|
@@ -1893,21 +1906,21 @@ function Ot(t, n) {
|
|
|
1893
1906
|
* @param path - The field path to set.
|
|
1894
1907
|
* @param value - The value to set.
|
|
1895
1908
|
*/ set(t, n) {
|
|
1896
|
-
this.getFieldsMap(t.popLast())[t.lastSegment()] =
|
|
1909
|
+
this.getFieldsMap(t.popLast())[t.lastSegment()] = Bt(n);
|
|
1897
1910
|
}
|
|
1898
1911
|
/**
|
|
1899
1912
|
* Sets the provided fields to the provided values.
|
|
1900
1913
|
*
|
|
1901
1914
|
* @param data - A map of fields to values (or null for deletes).
|
|
1902
1915
|
*/ setAll(t) {
|
|
1903
|
-
let n =
|
|
1916
|
+
let n = tt.emptyPath(), e = {}, r = [];
|
|
1904
1917
|
t.forEach(((t, s) => {
|
|
1905
1918
|
if (!n.isImmediateParentOf(s)) {
|
|
1906
1919
|
// Insert the accumulated changes at this parent location
|
|
1907
1920
|
const t = this.getFieldsMap(n);
|
|
1908
1921
|
this.applyChanges(t, e, r), e = {}, r = [], n = s.popLast();
|
|
1909
1922
|
}
|
|
1910
|
-
t ? e[s.lastSegment()] =
|
|
1923
|
+
t ? e[s.lastSegment()] = Bt(t) : r.push(s.lastSegment());
|
|
1911
1924
|
}));
|
|
1912
1925
|
const s = this.getFieldsMap(n);
|
|
1913
1926
|
this.applyChanges(s, e, r);
|
|
@@ -1919,10 +1932,10 @@ function Ot(t, n) {
|
|
|
1919
1932
|
* @param path - The field path to remove.
|
|
1920
1933
|
*/ delete(t) {
|
|
1921
1934
|
const n = this.field(t.popLast());
|
|
1922
|
-
|
|
1935
|
+
Mt(n) && n.mapValue.fields && delete n.mapValue.fields[t.lastSegment()];
|
|
1923
1936
|
}
|
|
1924
1937
|
isEqual(t) {
|
|
1925
|
-
return
|
|
1938
|
+
return qt(this.value, t.value);
|
|
1926
1939
|
}
|
|
1927
1940
|
/**
|
|
1928
1941
|
* Returns the map that contains the leaf element of `path`. If the parent
|
|
@@ -1934,7 +1947,7 @@ function Ot(t, n) {
|
|
|
1934
1947
|
});
|
|
1935
1948
|
for (let e = 0; e < t.length; ++e) {
|
|
1936
1949
|
let r = n.mapValue.fields[t.get(e)];
|
|
1937
|
-
|
|
1950
|
+
Mt(r) && r.mapValue.fields || (r = {
|
|
1938
1951
|
mapValue: {
|
|
1939
1952
|
fields: {}
|
|
1940
1953
|
}
|
|
@@ -1946,11 +1959,11 @@ function Ot(t, n) {
|
|
|
1946
1959
|
* Modifies `fieldsMap` by adding, replacing or deleting the specified
|
|
1947
1960
|
* entries.
|
|
1948
1961
|
*/ applyChanges(t, n, e) {
|
|
1949
|
-
|
|
1962
|
+
Et(n, ((n, e) => t[n] = e));
|
|
1950
1963
|
for (const n of e) delete t[n];
|
|
1951
1964
|
}
|
|
1952
1965
|
clone() {
|
|
1953
|
-
return new
|
|
1966
|
+
return new zt(Bt(this.value));
|
|
1954
1967
|
}
|
|
1955
1968
|
}
|
|
1956
1969
|
|
|
@@ -1979,7 +1992,7 @@ function Ot(t, n) {
|
|
|
1979
1992
|
* not transition to one of these states even after all mutations have been
|
|
1980
1993
|
* applied, `isValidDocument()` returns false and the document should be removed
|
|
1981
1994
|
* from all views.
|
|
1982
|
-
*/ class
|
|
1995
|
+
*/ class Qt {
|
|
1983
1996
|
constructor(t, n, e, r, s) {
|
|
1984
1997
|
this.key = t, this.documentType = n, this.version = e, this.data = r, this.documentState = s;
|
|
1985
1998
|
}
|
|
@@ -1987,23 +2000,23 @@ function Ot(t, n) {
|
|
|
1987
2000
|
* Creates a document with no known version or data, but which can serve as
|
|
1988
2001
|
* base document for mutations.
|
|
1989
2002
|
*/ static newInvalidDocument(t) {
|
|
1990
|
-
return new
|
|
2003
|
+
return new Qt(t, 0 /* INVALID */ , vt.min(), zt.empty(), 0 /* SYNCED */);
|
|
1991
2004
|
}
|
|
1992
2005
|
/**
|
|
1993
2006
|
* Creates a new document that is known to exist with the given data at the
|
|
1994
2007
|
* given version.
|
|
1995
2008
|
*/ static newFoundDocument(t, n, e) {
|
|
1996
|
-
return new
|
|
2009
|
+
return new Qt(t, 1 /* FOUND_DOCUMENT */ , n, e, 0 /* SYNCED */);
|
|
1997
2010
|
}
|
|
1998
2011
|
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t, n) {
|
|
1999
|
-
return new
|
|
2012
|
+
return new Qt(t, 2 /* NO_DOCUMENT */ , n, zt.empty(), 0 /* SYNCED */);
|
|
2000
2013
|
}
|
|
2001
2014
|
/**
|
|
2002
2015
|
* Creates a new document that is known to exist at the given version but
|
|
2003
2016
|
* whose data is not known (e.g. a document that was updated without a known
|
|
2004
2017
|
* base document).
|
|
2005
2018
|
*/ static newUnknownDocument(t, n) {
|
|
2006
|
-
return new
|
|
2019
|
+
return new Qt(t, 3 /* UNKNOWN_DOCUMENT */ , n, zt.empty(), 2 /* HAS_COMMITTED_MUTATIONS */);
|
|
2007
2020
|
}
|
|
2008
2021
|
/**
|
|
2009
2022
|
* Changes the document type to indicate that it exists and that its version
|
|
@@ -2016,7 +2029,7 @@ function Ot(t, n) {
|
|
|
2016
2029
|
* Changes the document type to indicate that it doesn't exist at the given
|
|
2017
2030
|
* version.
|
|
2018
2031
|
*/ convertToNoDocument(t) {
|
|
2019
|
-
return this.version = t, this.documentType = 2 /* NO_DOCUMENT */ , this.data =
|
|
2032
|
+
return this.version = t, this.documentType = 2 /* NO_DOCUMENT */ , this.data = zt.empty(),
|
|
2020
2033
|
this.documentState = 0 /* SYNCED */ , this;
|
|
2021
2034
|
}
|
|
2022
2035
|
/**
|
|
@@ -2024,7 +2037,7 @@ function Ot(t, n) {
|
|
|
2024
2037
|
* that its data is not known (e.g. a document that was updated without a known
|
|
2025
2038
|
* base document).
|
|
2026
2039
|
*/ convertToUnknownDocument(t) {
|
|
2027
|
-
return this.version = t, this.documentType = 3 /* UNKNOWN_DOCUMENT */ , this.data =
|
|
2040
|
+
return this.version = t, this.documentType = 3 /* UNKNOWN_DOCUMENT */ , this.data = zt.empty(),
|
|
2028
2041
|
this.documentState = 2 /* HAS_COMMITTED_MUTATIONS */ , this;
|
|
2029
2042
|
}
|
|
2030
2043
|
setHasCommittedMutations() {
|
|
@@ -2055,10 +2068,10 @@ function Ot(t, n) {
|
|
|
2055
2068
|
return 3 /* UNKNOWN_DOCUMENT */ === this.documentType;
|
|
2056
2069
|
}
|
|
2057
2070
|
isEqual(t) {
|
|
2058
|
-
return t instanceof
|
|
2071
|
+
return t instanceof Qt && this.key.isEqual(t.key) && this.version.isEqual(t.version) && this.documentType === t.documentType && this.documentState === t.documentState && this.data.isEqual(t.data);
|
|
2059
2072
|
}
|
|
2060
2073
|
clone() {
|
|
2061
|
-
return new
|
|
2074
|
+
return new Qt(this.key, this.documentType, this.version, this.data.clone(), this.documentState);
|
|
2062
2075
|
}
|
|
2063
2076
|
toString() {
|
|
2064
2077
|
return `Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`;
|
|
@@ -2082,10 +2095,10 @@ function Ot(t, n) {
|
|
|
2082
2095
|
* limitations under the License.
|
|
2083
2096
|
*/
|
|
2084
2097
|
// Visible for testing
|
|
2085
|
-
class
|
|
2098
|
+
class Gt {
|
|
2086
2099
|
constructor(t, n = null, e = [], r = [], s = null, i = null, o = null) {
|
|
2087
2100
|
this.path = t, this.collectionGroup = n, this.orderBy = e, this.filters = r, this.limit = s,
|
|
2088
|
-
this.startAt = i, this.endAt = o, this.
|
|
2101
|
+
this.startAt = i, this.endAt = o, this.R = null;
|
|
2089
2102
|
}
|
|
2090
2103
|
}
|
|
2091
2104
|
|
|
@@ -2096,29 +2109,29 @@ class Qt {
|
|
|
2096
2109
|
* NOTE: you should always construct `Target` from `Query.toTarget` instead of
|
|
2097
2110
|
* using this factory method, because `Query` provides an implicit `orderBy`
|
|
2098
2111
|
* property.
|
|
2099
|
-
*/ function
|
|
2100
|
-
return new
|
|
2112
|
+
*/ function Wt(t, n = null, e = [], r = [], s = null, i = null, o = null) {
|
|
2113
|
+
return new Gt(t, n, e, r, s, i, o);
|
|
2101
2114
|
}
|
|
2102
2115
|
|
|
2103
|
-
class
|
|
2116
|
+
class Yt extends class {} {
|
|
2104
2117
|
constructor(t, n, e) {
|
|
2105
2118
|
super(), this.field = t, this.op = n, this.value = e;
|
|
2106
2119
|
}
|
|
2107
2120
|
/**
|
|
2108
2121
|
* Creates a filter based on the provided arguments.
|
|
2109
2122
|
*/ static create(t, n, e) {
|
|
2110
|
-
return t.isKeyField() ? "in" /* IN */ === n || "not-in" /* NOT_IN */ === n ? this.
|
|
2123
|
+
return t.isKeyField() ? "in" /* IN */ === n || "not-in" /* NOT_IN */ === n ? this.V(t, n, e) : new Ht(t, n, e) : "array-contains" /* ARRAY_CONTAINS */ === n ? new Zt(t, e) : "in" /* IN */ === n ? new tn(t, e) : "not-in" /* NOT_IN */ === n ? new nn(t, e) : "array-contains-any" /* ARRAY_CONTAINS_ANY */ === n ? new en(t, e) : new Yt(t, n, e);
|
|
2111
2124
|
}
|
|
2112
|
-
static
|
|
2113
|
-
return "in" /* IN */ === n ? new
|
|
2125
|
+
static V(t, n, e) {
|
|
2126
|
+
return "in" /* IN */ === n ? new Kt(t, e) : new Jt(t, e);
|
|
2114
2127
|
}
|
|
2115
2128
|
matches(t) {
|
|
2116
2129
|
const n = t.data.field(this.field);
|
|
2117
2130
|
// Types do not have to match in NOT_EQUAL filters.
|
|
2118
|
-
return "!=" /* NOT_EQUAL */ === this.op ? null !== n && this.
|
|
2131
|
+
return "!=" /* NOT_EQUAL */ === this.op ? null !== n && this.N(Ot(n, this.value)) : null !== n && St(this.value) === St(n) && this.N(Ot(n, this.value));
|
|
2119
2132
|
// Only compare types with matching backend order (such as double and int).
|
|
2120
2133
|
}
|
|
2121
|
-
|
|
2134
|
+
N(t) {
|
|
2122
2135
|
switch (this.op) {
|
|
2123
2136
|
case "<" /* LESS_THAN */ :
|
|
2124
2137
|
return t < 0;
|
|
@@ -2142,85 +2155,85 @@ class Wt extends class {} {
|
|
|
2142
2155
|
return g();
|
|
2143
2156
|
}
|
|
2144
2157
|
}
|
|
2145
|
-
|
|
2158
|
+
D() {
|
|
2146
2159
|
return [ "<" /* LESS_THAN */ , "<=" /* LESS_THAN_OR_EQUAL */ , ">" /* GREATER_THAN */ , ">=" /* GREATER_THAN_OR_EQUAL */ , "!=" /* NOT_EQUAL */ , "not-in" /* NOT_IN */ ].indexOf(this.op) >= 0;
|
|
2147
2160
|
}
|
|
2148
2161
|
}
|
|
2149
2162
|
|
|
2150
2163
|
/** Filter that matches on key fields (i.e. '__name__'). */
|
|
2151
|
-
class
|
|
2164
|
+
class Ht extends Yt {
|
|
2152
2165
|
constructor(t, n, e) {
|
|
2153
|
-
super(t, n, e), this.key =
|
|
2166
|
+
super(t, n, e), this.key = nt.fromName(e.referenceValue);
|
|
2154
2167
|
}
|
|
2155
2168
|
matches(t) {
|
|
2156
|
-
const n =
|
|
2157
|
-
return this.
|
|
2169
|
+
const n = nt.comparator(t.key, this.key);
|
|
2170
|
+
return this.N(n);
|
|
2158
2171
|
}
|
|
2159
2172
|
}
|
|
2160
2173
|
|
|
2161
|
-
/** Filter that matches on key fields within an array. */ class
|
|
2174
|
+
/** Filter that matches on key fields within an array. */ class Kt extends Yt {
|
|
2162
2175
|
constructor(t, n) {
|
|
2163
|
-
super(t, "in" /* IN */ , n), this.keys =
|
|
2176
|
+
super(t, "in" /* IN */ , n), this.keys = Xt("in" /* IN */ , n);
|
|
2164
2177
|
}
|
|
2165
2178
|
matches(t) {
|
|
2166
2179
|
return this.keys.some((n => n.isEqual(t.key)));
|
|
2167
2180
|
}
|
|
2168
2181
|
}
|
|
2169
2182
|
|
|
2170
|
-
/** Filter that matches on key fields not present within an array. */ class
|
|
2183
|
+
/** Filter that matches on key fields not present within an array. */ class Jt extends Yt {
|
|
2171
2184
|
constructor(t, n) {
|
|
2172
|
-
super(t, "not-in" /* NOT_IN */ , n), this.keys =
|
|
2185
|
+
super(t, "not-in" /* NOT_IN */ , n), this.keys = Xt("not-in" /* NOT_IN */ , n);
|
|
2173
2186
|
}
|
|
2174
2187
|
matches(t) {
|
|
2175
2188
|
return !this.keys.some((n => n.isEqual(t.key)));
|
|
2176
2189
|
}
|
|
2177
2190
|
}
|
|
2178
2191
|
|
|
2179
|
-
function
|
|
2192
|
+
function Xt(t, n) {
|
|
2180
2193
|
var e;
|
|
2181
|
-
return ((null === (e = n.arrayValue) || void 0 === e ? void 0 : e.values) || []).map((t =>
|
|
2194
|
+
return ((null === (e = n.arrayValue) || void 0 === e ? void 0 : e.values) || []).map((t => nt.fromName(t.referenceValue)));
|
|
2182
2195
|
}
|
|
2183
2196
|
|
|
2184
|
-
/** A Filter that implements the array-contains operator. */ class
|
|
2197
|
+
/** A Filter that implements the array-contains operator. */ class Zt extends Yt {
|
|
2185
2198
|
constructor(t, n) {
|
|
2186
2199
|
super(t, "array-contains" /* ARRAY_CONTAINS */ , n);
|
|
2187
2200
|
}
|
|
2188
2201
|
matches(t) {
|
|
2189
2202
|
const n = t.data.field(this.field);
|
|
2190
|
-
return
|
|
2203
|
+
return kt(n) && xt(n.arrayValue, this.value);
|
|
2191
2204
|
}
|
|
2192
2205
|
}
|
|
2193
2206
|
|
|
2194
|
-
/** A Filter that implements the IN operator. */ class
|
|
2207
|
+
/** A Filter that implements the IN operator. */ class tn extends Yt {
|
|
2195
2208
|
constructor(t, n) {
|
|
2196
2209
|
super(t, "in" /* IN */ , n);
|
|
2197
2210
|
}
|
|
2198
2211
|
matches(t) {
|
|
2199
2212
|
const n = t.data.field(this.field);
|
|
2200
|
-
return null !== n &&
|
|
2213
|
+
return null !== n && xt(this.value.arrayValue, n);
|
|
2201
2214
|
}
|
|
2202
2215
|
}
|
|
2203
2216
|
|
|
2204
|
-
/** A Filter that implements the not-in operator. */ class
|
|
2217
|
+
/** A Filter that implements the not-in operator. */ class nn extends Yt {
|
|
2205
2218
|
constructor(t, n) {
|
|
2206
2219
|
super(t, "not-in" /* NOT_IN */ , n);
|
|
2207
2220
|
}
|
|
2208
2221
|
matches(t) {
|
|
2209
|
-
if (
|
|
2222
|
+
if (xt(this.value.arrayValue, {
|
|
2210
2223
|
nullValue: "NULL_VALUE"
|
|
2211
2224
|
})) return !1;
|
|
2212
2225
|
const n = t.data.field(this.field);
|
|
2213
|
-
return null !== n && !
|
|
2226
|
+
return null !== n && !xt(this.value.arrayValue, n);
|
|
2214
2227
|
}
|
|
2215
2228
|
}
|
|
2216
2229
|
|
|
2217
|
-
/** A Filter that implements the array-contains-any operator. */ class
|
|
2230
|
+
/** A Filter that implements the array-contains-any operator. */ class en extends Yt {
|
|
2218
2231
|
constructor(t, n) {
|
|
2219
2232
|
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ , n);
|
|
2220
2233
|
}
|
|
2221
2234
|
matches(t) {
|
|
2222
2235
|
const n = t.data.field(this.field);
|
|
2223
|
-
return !(!
|
|
2236
|
+
return !(!kt(n) || !n.arrayValue.values) && n.arrayValue.values.some((t => xt(this.value.arrayValue, t)));
|
|
2224
2237
|
}
|
|
2225
2238
|
}
|
|
2226
2239
|
|
|
@@ -2237,7 +2250,7 @@ function Kt(t, n) {
|
|
|
2237
2250
|
* Bound provides a function to determine whether a document comes before or
|
|
2238
2251
|
* after a bound. This is influenced by whether the position is just before or
|
|
2239
2252
|
* just after the provided values.
|
|
2240
|
-
*/ class
|
|
2253
|
+
*/ class rn {
|
|
2241
2254
|
constructor(t, n) {
|
|
2242
2255
|
this.position = t, this.before = n;
|
|
2243
2256
|
}
|
|
@@ -2245,22 +2258,22 @@ function Kt(t, n) {
|
|
|
2245
2258
|
|
|
2246
2259
|
/**
|
|
2247
2260
|
* An ordering on a field, in some Direction. Direction defaults to ASCENDING.
|
|
2248
|
-
*/ class
|
|
2261
|
+
*/ class sn {
|
|
2249
2262
|
constructor(t, n = "asc" /* ASCENDING */) {
|
|
2250
2263
|
this.field = t, this.dir = n;
|
|
2251
2264
|
}
|
|
2252
2265
|
}
|
|
2253
2266
|
|
|
2254
|
-
function
|
|
2267
|
+
function on(t, n) {
|
|
2255
2268
|
return t.dir === n.dir && t.field.isEqual(n.field);
|
|
2256
2269
|
}
|
|
2257
2270
|
|
|
2258
|
-
function
|
|
2271
|
+
function un(t, n) {
|
|
2259
2272
|
if (null === t) return null === n;
|
|
2260
2273
|
if (null === n) return !1;
|
|
2261
2274
|
if (t.before !== n.before || t.position.length !== n.position.length) return !1;
|
|
2262
2275
|
for (let e = 0; e < t.position.length; e++) {
|
|
2263
|
-
if (!
|
|
2276
|
+
if (!qt(t.position[e], n.position[e])) return !1;
|
|
2264
2277
|
}
|
|
2265
2278
|
return !0;
|
|
2266
2279
|
}
|
|
@@ -2287,29 +2300,29 @@ function sn(t, n) {
|
|
|
2287
2300
|
* query the RemoteStore results.
|
|
2288
2301
|
*
|
|
2289
2302
|
* Visible for testing.
|
|
2290
|
-
*/ class
|
|
2303
|
+
*/ class cn {
|
|
2291
2304
|
/**
|
|
2292
2305
|
* Initializes a Query with a path and optional additional query constraints.
|
|
2293
2306
|
* Path must currently be empty if this is a collection group query.
|
|
2294
2307
|
*/
|
|
2295
2308
|
constructor(t, n = null, e = [], r = [], s = null, i = "F" /* First */ , o = null, u = null) {
|
|
2296
2309
|
this.path = t, this.collectionGroup = n, this.explicitOrderBy = e, this.filters = r,
|
|
2297
|
-
this.limit = s, this.limitType = i, this.startAt = o, this.endAt = u, this
|
|
2310
|
+
this.limit = s, this.limitType = i, this.startAt = o, this.endAt = u, this.$ = null,
|
|
2298
2311
|
// The corresponding `Target` of this `Query` instance.
|
|
2299
|
-
this
|
|
2312
|
+
this.F = null, this.startAt, this.endAt;
|
|
2300
2313
|
}
|
|
2301
2314
|
}
|
|
2302
2315
|
|
|
2303
|
-
/** Creates a new Query for a query that matches all documents at `path` */ function
|
|
2304
|
-
return !
|
|
2316
|
+
/** Creates a new Query for a query that matches all documents at `path` */ function an(t) {
|
|
2317
|
+
return !ct(t.limit) && "L" /* Last */ === t.limitType;
|
|
2305
2318
|
}
|
|
2306
2319
|
|
|
2307
|
-
function
|
|
2320
|
+
function hn(t) {
|
|
2308
2321
|
return t.explicitOrderBy.length > 0 ? t.explicitOrderBy[0].field : null;
|
|
2309
2322
|
}
|
|
2310
2323
|
|
|
2311
|
-
function
|
|
2312
|
-
for (const n of t.filters) if (n.
|
|
2324
|
+
function ln(t) {
|
|
2325
|
+
for (const n of t.filters) if (n.D()) return n.field;
|
|
2313
2326
|
return null;
|
|
2314
2327
|
}
|
|
2315
2328
|
|
|
@@ -2321,7 +2334,7 @@ function an(t) {
|
|
|
2321
2334
|
* Returns whether the query matches a collection group rather than a specific
|
|
2322
2335
|
* collection.
|
|
2323
2336
|
*/
|
|
2324
|
-
function
|
|
2337
|
+
function fn(t) {
|
|
2325
2338
|
return null !== t.collectionGroup;
|
|
2326
2339
|
}
|
|
2327
2340
|
|
|
@@ -2329,59 +2342,59 @@ function hn(t) {
|
|
|
2329
2342
|
* Returns the implicit order by constraint that is used to execute the Query,
|
|
2330
2343
|
* which can be different from the order by constraints the user provided (e.g.
|
|
2331
2344
|
* the SDK and backend always orders by `__name__`).
|
|
2332
|
-
*/ function
|
|
2345
|
+
*/ function dn(t) {
|
|
2333
2346
|
const n = b(t);
|
|
2334
|
-
if (null === n
|
|
2335
|
-
n
|
|
2336
|
-
const t =
|
|
2347
|
+
if (null === n.$) {
|
|
2348
|
+
n.$ = [];
|
|
2349
|
+
const t = ln(n), e = hn(n);
|
|
2337
2350
|
if (null !== t && null === e)
|
|
2338
2351
|
// In order to implicitly add key ordering, we must also add the
|
|
2339
2352
|
// inequality filter field for it to be a valid query.
|
|
2340
2353
|
// Note that the default inequality field and key ordering is ascending.
|
|
2341
|
-
t.isKeyField() || n
|
|
2354
|
+
t.isKeyField() || n.$.push(new sn(t)), n.$.push(new sn(tt.keyField(), "asc" /* ASCENDING */)); else {
|
|
2342
2355
|
let t = !1;
|
|
2343
|
-
for (const e of n.explicitOrderBy) n
|
|
2356
|
+
for (const e of n.explicitOrderBy) n.$.push(e), e.field.isKeyField() && (t = !0);
|
|
2344
2357
|
if (!t) {
|
|
2345
2358
|
// The order of the implicit key ordering always matches the last
|
|
2346
2359
|
// explicit order by
|
|
2347
2360
|
const t = n.explicitOrderBy.length > 0 ? n.explicitOrderBy[n.explicitOrderBy.length - 1].dir : "asc" /* ASCENDING */;
|
|
2348
|
-
n
|
|
2361
|
+
n.$.push(new sn(tt.keyField(), t));
|
|
2349
2362
|
}
|
|
2350
2363
|
}
|
|
2351
2364
|
}
|
|
2352
|
-
return n
|
|
2365
|
+
return n.$;
|
|
2353
2366
|
}
|
|
2354
2367
|
|
|
2355
2368
|
/**
|
|
2356
2369
|
* Converts this `Query` instance to it's corresponding `Target` representation.
|
|
2357
|
-
*/ function
|
|
2370
|
+
*/ function wn(t) {
|
|
2358
2371
|
const n = b(t);
|
|
2359
|
-
if (!n
|
|
2372
|
+
if (!n.F) if ("F" /* First */ === n.limitType) n.F = Wt(n.path, n.collectionGroup, dn(n), n.filters, n.limit, n.startAt, n.endAt); else {
|
|
2360
2373
|
// Flip the orderBy directions since we want the last results
|
|
2361
2374
|
const t = [];
|
|
2362
|
-
for (const e of
|
|
2375
|
+
for (const e of dn(n)) {
|
|
2363
2376
|
const n = "desc" /* DESCENDING */ === e.dir ? "asc" /* ASCENDING */ : "desc" /* DESCENDING */;
|
|
2364
|
-
t.push(new
|
|
2377
|
+
t.push(new sn(e.field, n));
|
|
2365
2378
|
}
|
|
2366
2379
|
// We need to swap the cursors to match the now-flipped query ordering.
|
|
2367
|
-
const e = n.endAt ? new
|
|
2380
|
+
const e = n.endAt ? new rn(n.endAt.position, !n.endAt.before) : null, r = n.startAt ? new rn(n.startAt.position, !n.startAt.before) : null;
|
|
2368
2381
|
// Now return as a LimitType.First query.
|
|
2369
|
-
n
|
|
2382
|
+
n.F = Wt(n.path, n.collectionGroup, t, n.filters, n.limit, e, r);
|
|
2370
2383
|
}
|
|
2371
|
-
return n
|
|
2384
|
+
return n.F;
|
|
2372
2385
|
}
|
|
2373
2386
|
|
|
2374
|
-
function
|
|
2387
|
+
function mn(t, n) {
|
|
2375
2388
|
return function(t, n) {
|
|
2376
2389
|
if (t.limit !== n.limit) return !1;
|
|
2377
2390
|
if (t.orderBy.length !== n.orderBy.length) return !1;
|
|
2378
|
-
for (let e = 0; e < t.orderBy.length; e++) if (!
|
|
2391
|
+
for (let e = 0; e < t.orderBy.length; e++) if (!on(t.orderBy[e], n.orderBy[e])) return !1;
|
|
2379
2392
|
if (t.filters.length !== n.filters.length) return !1;
|
|
2380
2393
|
for (let s = 0; s < t.filters.length; s++) if (e = t.filters[s], r = n.filters[s],
|
|
2381
|
-
e.op !== r.op || !e.field.isEqual(r.field) || !
|
|
2394
|
+
e.op !== r.op || !e.field.isEqual(r.field) || !qt(e.value, r.value)) return !1;
|
|
2382
2395
|
var e, r;
|
|
2383
|
-
return t.collectionGroup === n.collectionGroup && !!t.path.isEqual(n.path) && !!
|
|
2384
|
-
}(
|
|
2396
|
+
return t.collectionGroup === n.collectionGroup && !!t.path.isEqual(n.path) && !!un(t.startAt, n.startAt) && un(t.endAt, n.endAt);
|
|
2397
|
+
}(wn(t), wn(n)) && t.limitType === n.limitType;
|
|
2385
2398
|
}
|
|
2386
2399
|
|
|
2387
2400
|
/**
|
|
@@ -2409,9 +2422,9 @@ function dn(t, n) {
|
|
|
2409
2422
|
* The return value is an IntegerValue if it can safely represent the value,
|
|
2410
2423
|
* otherwise a DoubleValue is returned.
|
|
2411
2424
|
*/
|
|
2412
|
-
function
|
|
2425
|
+
function pn(t, n) {
|
|
2413
2426
|
return function(t) {
|
|
2414
|
-
return "number" == typeof t && Number.isInteger(t) && !
|
|
2427
|
+
return "number" == typeof t && Number.isInteger(t) && !at(t) && t <= Number.MAX_SAFE_INTEGER && t >= Number.MIN_SAFE_INTEGER;
|
|
2415
2428
|
}(n) ?
|
|
2416
2429
|
/**
|
|
2417
2430
|
* Returns an IntegerValue for `value`.
|
|
@@ -2421,7 +2434,7 @@ function wn(t, n) {
|
|
|
2421
2434
|
integerValue: "" + t
|
|
2422
2435
|
};
|
|
2423
2436
|
}(n) : function(t, n) {
|
|
2424
|
-
if (t.
|
|
2437
|
+
if (t.S) {
|
|
2425
2438
|
if (isNaN(n)) return {
|
|
2426
2439
|
doubleValue: "NaN"
|
|
2427
2440
|
};
|
|
@@ -2433,7 +2446,7 @@ function wn(t, n) {
|
|
|
2433
2446
|
};
|
|
2434
2447
|
}
|
|
2435
2448
|
return {
|
|
2436
|
-
doubleValue:
|
|
2449
|
+
doubleValue: at(n) ? "-0" : n
|
|
2437
2450
|
};
|
|
2438
2451
|
}(t, n);
|
|
2439
2452
|
}
|
|
@@ -2454,7 +2467,7 @@ function wn(t, n) {
|
|
|
2454
2467
|
* See the License for the specific language governing permissions and
|
|
2455
2468
|
* limitations under the License.
|
|
2456
2469
|
*/
|
|
2457
|
-
/** Used to represent a field transform on a mutation. */ class
|
|
2470
|
+
/** Used to represent a field transform on a mutation. */ class yn {
|
|
2458
2471
|
constructor() {
|
|
2459
2472
|
// Make sure that the structural type of `TransformOperation` is unique.
|
|
2460
2473
|
// See https://github.com/microsoft/TypeScript/issues/5451
|
|
@@ -2462,15 +2475,15 @@ function wn(t, n) {
|
|
|
2462
2475
|
}
|
|
2463
2476
|
}
|
|
2464
2477
|
|
|
2465
|
-
/** Transforms a value into a server-generated timestamp. */ class
|
|
2478
|
+
/** Transforms a value into a server-generated timestamp. */ class _n extends yn {}
|
|
2466
2479
|
|
|
2467
|
-
/** Transforms an array value via a union operation. */ class
|
|
2480
|
+
/** Transforms an array value via a union operation. */ class gn extends yn {
|
|
2468
2481
|
constructor(t) {
|
|
2469
2482
|
super(), this.elements = t;
|
|
2470
2483
|
}
|
|
2471
2484
|
}
|
|
2472
2485
|
|
|
2473
|
-
/** Transforms an array value via a remove operation. */ class
|
|
2486
|
+
/** Transforms an array value via a remove operation. */ class vn extends yn {
|
|
2474
2487
|
constructor(t) {
|
|
2475
2488
|
super(), this.elements = t;
|
|
2476
2489
|
}
|
|
@@ -2481,9 +2494,9 @@ function wn(t, n) {
|
|
|
2481
2494
|
* transforms. Converts all field values to integers or doubles, but unlike the
|
|
2482
2495
|
* backend does not cap integer values at 2^63. Instead, JavaScript number
|
|
2483
2496
|
* arithmetic is used and precision loss can occur for values greater than 2^53.
|
|
2484
|
-
*/ class
|
|
2497
|
+
*/ class bn extends yn {
|
|
2485
2498
|
constructor(t, n) {
|
|
2486
|
-
super(), this.
|
|
2499
|
+
super(), this.q = t, this.O = n;
|
|
2487
2500
|
}
|
|
2488
2501
|
}
|
|
2489
2502
|
|
|
@@ -2503,7 +2516,7 @@ function wn(t, n) {
|
|
|
2503
2516
|
* See the License for the specific language governing permissions and
|
|
2504
2517
|
* limitations under the License.
|
|
2505
2518
|
*/
|
|
2506
|
-
/** A field path and the TransformOperation to perform upon it. */ class
|
|
2519
|
+
/** A field path and the TransformOperation to perform upon it. */ class En {
|
|
2507
2520
|
constructor(t, n) {
|
|
2508
2521
|
this.field = t, this.transform = n;
|
|
2509
2522
|
}
|
|
@@ -2513,18 +2526,18 @@ function wn(t, n) {
|
|
|
2513
2526
|
* Encodes a precondition for a mutation. This follows the model that the
|
|
2514
2527
|
* backend accepts with the special case of an explicit "empty" precondition
|
|
2515
2528
|
* (meaning no precondition).
|
|
2516
|
-
*/ class
|
|
2529
|
+
*/ class Tn {
|
|
2517
2530
|
constructor(t, n) {
|
|
2518
2531
|
this.updateTime = t, this.exists = n;
|
|
2519
2532
|
}
|
|
2520
2533
|
/** Creates a new empty Precondition. */ static none() {
|
|
2521
|
-
return new
|
|
2534
|
+
return new Tn;
|
|
2522
2535
|
}
|
|
2523
2536
|
/** Creates a new Precondition with an exists flag. */ static exists(t) {
|
|
2524
|
-
return new
|
|
2537
|
+
return new Tn(void 0, t);
|
|
2525
2538
|
}
|
|
2526
2539
|
/** Creates a new Precondition based on a version a document exists at. */ static updateTime(t) {
|
|
2527
|
-
return new
|
|
2540
|
+
return new Tn(t);
|
|
2528
2541
|
}
|
|
2529
2542
|
/** Returns whether this Precondition is empty. */ get isNone() {
|
|
2530
2543
|
return void 0 === this.updateTime && void 0 === this.exists;
|
|
@@ -2577,12 +2590,12 @@ function wn(t, n) {
|
|
|
2577
2590
|
* applyToLocalView() to implement the actual behavior of applying the mutation
|
|
2578
2591
|
* to some source document (see `setMutationApplyToRemoteDocument()` for an
|
|
2579
2592
|
* example).
|
|
2580
|
-
*/ class
|
|
2593
|
+
*/ class In {}
|
|
2581
2594
|
|
|
2582
2595
|
/**
|
|
2583
2596
|
* A mutation that creates or replaces the document at the given key with the
|
|
2584
2597
|
* object value contents.
|
|
2585
|
-
*/ class
|
|
2598
|
+
*/ class An extends In {
|
|
2586
2599
|
constructor(t, n, e, r = []) {
|
|
2587
2600
|
super(), this.key = t, this.value = n, this.precondition = e, this.fieldTransforms = r,
|
|
2588
2601
|
this.type = 0 /* Set */;
|
|
@@ -2601,14 +2614,14 @@ function wn(t, n) {
|
|
|
2601
2614
|
* is deleted.
|
|
2602
2615
|
* * When a field is not in the mask but is in the values, the values map is
|
|
2603
2616
|
* ignored.
|
|
2604
|
-
*/ class
|
|
2617
|
+
*/ class Pn extends In {
|
|
2605
2618
|
constructor(t, n, e, r, s = []) {
|
|
2606
2619
|
super(), this.key = t, this.data = n, this.fieldMask = e, this.precondition = r,
|
|
2607
2620
|
this.fieldTransforms = s, this.type = 1 /* Patch */;
|
|
2608
2621
|
}
|
|
2609
2622
|
}
|
|
2610
2623
|
|
|
2611
|
-
/** A mutation that deletes the document at the given key. */ class
|
|
2624
|
+
/** A mutation that deletes the document at the given key. */ class Rn extends In {
|
|
2612
2625
|
constructor(t, n) {
|
|
2613
2626
|
super(), this.key = t, this.precondition = n, this.type = 2 /* Delete */ , this.fieldTransforms = [];
|
|
2614
2627
|
}
|
|
@@ -2620,7 +2633,7 @@ function wn(t, n) {
|
|
|
2620
2633
|
*
|
|
2621
2634
|
* The `verify` operation is only used in Transactions, and this class serves
|
|
2622
2635
|
* primarily to facilitate serialization into protos.
|
|
2623
|
-
*/ class
|
|
2636
|
+
*/ class Vn extends In {
|
|
2624
2637
|
constructor(t, n) {
|
|
2625
2638
|
super(), this.key = t, this.precondition = n, this.type = 3 /* Verify */ , this.fieldTransforms = [];
|
|
2626
2639
|
}
|
|
@@ -2641,13 +2654,13 @@ function wn(t, n) {
|
|
|
2641
2654
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2642
2655
|
* See the License for the specific language governing permissions and
|
|
2643
2656
|
* limitations under the License.
|
|
2644
|
-
*/ const
|
|
2657
|
+
*/ const Nn = (() => {
|
|
2645
2658
|
const t = {
|
|
2646
2659
|
asc: "ASCENDING",
|
|
2647
2660
|
desc: "DESCENDING"
|
|
2648
2661
|
};
|
|
2649
2662
|
return t;
|
|
2650
|
-
})(),
|
|
2663
|
+
})(), Dn = (() => {
|
|
2651
2664
|
const t = {
|
|
2652
2665
|
"<": "LESS_THAN",
|
|
2653
2666
|
"<=": "LESS_THAN_OR_EQUAL",
|
|
@@ -2677,9 +2690,9 @@ function wn(t, n) {
|
|
|
2677
2690
|
* TODO(klimt): We can remove the databaseId argument if we keep the full
|
|
2678
2691
|
* resource name in documents.
|
|
2679
2692
|
*/
|
|
2680
|
-
class
|
|
2693
|
+
class $n {
|
|
2681
2694
|
constructor(t, n) {
|
|
2682
|
-
this.databaseId = t, this.
|
|
2695
|
+
this.databaseId = t, this.S = n;
|
|
2683
2696
|
}
|
|
2684
2697
|
}
|
|
2685
2698
|
|
|
@@ -2694,8 +2707,8 @@ class Nn {
|
|
|
2694
2707
|
/**
|
|
2695
2708
|
* Returns a value for a Date that's appropriate to put into a proto.
|
|
2696
2709
|
*/
|
|
2697
|
-
function
|
|
2698
|
-
if (t.
|
|
2710
|
+
function Fn(t, n) {
|
|
2711
|
+
if (t.S) {
|
|
2699
2712
|
return `${new Date(1e3 * n.seconds).toISOString().replace(/\.\d*/, "").replace("Z", "")}.${("000000000" + n.nanoseconds).slice(-9)}Z`;
|
|
2700
2713
|
}
|
|
2701
2714
|
return {
|
|
@@ -2709,129 +2722,129 @@ function Dn(t, n) {
|
|
|
2709
2722
|
*
|
|
2710
2723
|
* Visible for testing.
|
|
2711
2724
|
*/
|
|
2712
|
-
function
|
|
2713
|
-
return t.
|
|
2725
|
+
function Sn(t, n) {
|
|
2726
|
+
return t.S ? n.toBase64() : n.toUint8Array();
|
|
2714
2727
|
}
|
|
2715
2728
|
|
|
2716
|
-
function
|
|
2717
|
-
return
|
|
2729
|
+
function qn(t, n) {
|
|
2730
|
+
return Fn(t, n.toTimestamp());
|
|
2718
2731
|
}
|
|
2719
2732
|
|
|
2720
|
-
function
|
|
2721
|
-
return v(!!t),
|
|
2722
|
-
const n =
|
|
2723
|
-
return new
|
|
2733
|
+
function xn(t) {
|
|
2734
|
+
return v(!!t), vt.fromTimestamp(function(t) {
|
|
2735
|
+
const n = Rt(t);
|
|
2736
|
+
return new gt(n.seconds, n.nanos);
|
|
2724
2737
|
}(t));
|
|
2725
2738
|
}
|
|
2726
2739
|
|
|
2727
|
-
function
|
|
2740
|
+
function On(t, n) {
|
|
2728
2741
|
return function(t) {
|
|
2729
|
-
return new
|
|
2742
|
+
return new X([ "projects", t.projectId, "databases", t.database ]);
|
|
2730
2743
|
}(t).child("documents").child(n).canonicalString();
|
|
2731
2744
|
}
|
|
2732
2745
|
|
|
2733
|
-
function
|
|
2734
|
-
return
|
|
2746
|
+
function Cn(t, n) {
|
|
2747
|
+
return On(t.databaseId, n.path);
|
|
2735
2748
|
}
|
|
2736
2749
|
|
|
2737
|
-
function
|
|
2750
|
+
function Ln(t, n) {
|
|
2738
2751
|
const e = function(t) {
|
|
2739
|
-
const n =
|
|
2740
|
-
return v(
|
|
2752
|
+
const n = X.fromString(t);
|
|
2753
|
+
return v(Kn(n)), n;
|
|
2741
2754
|
}(n);
|
|
2742
|
-
if (e.get(1) !== t.databaseId.projectId) throw new
|
|
2743
|
-
if (e.get(3) !== t.databaseId.database) throw new
|
|
2744
|
-
return new
|
|
2755
|
+
if (e.get(1) !== t.databaseId.projectId) throw new k(A, "Tried to deserialize key from different project: " + e.get(1) + " vs " + t.databaseId.projectId);
|
|
2756
|
+
if (e.get(3) !== t.databaseId.database) throw new k(A, "Tried to deserialize key from different database: " + e.get(3) + " vs " + t.databaseId.database);
|
|
2757
|
+
return new nt((v((r = e).length > 4 && "documents" === r.get(4)), r.popFirst(5)));
|
|
2745
2758
|
var r;
|
|
2746
2759
|
/** Creates a Document proto from key and fields (but no create/update time) */}
|
|
2747
2760
|
|
|
2748
|
-
function
|
|
2749
|
-
return
|
|
2761
|
+
function kn(t, n) {
|
|
2762
|
+
return On(t.databaseId, n);
|
|
2750
2763
|
}
|
|
2751
2764
|
|
|
2752
|
-
function
|
|
2753
|
-
return new
|
|
2765
|
+
function Un(t) {
|
|
2766
|
+
return new X([ "projects", t.databaseId.projectId, "databases", t.databaseId.database ]).canonicalString();
|
|
2754
2767
|
}
|
|
2755
2768
|
|
|
2756
|
-
function
|
|
2769
|
+
function jn(t, n, e) {
|
|
2757
2770
|
return {
|
|
2758
|
-
name:
|
|
2771
|
+
name: Cn(t, n),
|
|
2759
2772
|
fields: e.value.mapValue.fields
|
|
2760
2773
|
};
|
|
2761
2774
|
}
|
|
2762
2775
|
|
|
2763
|
-
function
|
|
2776
|
+
function Mn(t, n) {
|
|
2764
2777
|
return "found" in n ? function(t, n) {
|
|
2765
2778
|
v(!!n.found), n.found.name, n.found.updateTime;
|
|
2766
|
-
const e =
|
|
2779
|
+
const e = Ln(t, n.found.name), r = xn(n.found.updateTime), s = new zt({
|
|
2767
2780
|
mapValue: {
|
|
2768
2781
|
fields: n.found.fields
|
|
2769
2782
|
}
|
|
2770
2783
|
});
|
|
2771
|
-
return
|
|
2784
|
+
return Qt.newFoundDocument(e, r, s);
|
|
2772
2785
|
}(t, n) : "missing" in n ? function(t, n) {
|
|
2773
2786
|
v(!!n.missing), v(!!n.readTime);
|
|
2774
|
-
const e =
|
|
2775
|
-
return
|
|
2787
|
+
const e = Ln(t, n.missing), r = xn(n.readTime);
|
|
2788
|
+
return Qt.newNoDocument(e, r);
|
|
2776
2789
|
}(t, n) : g();
|
|
2777
2790
|
}
|
|
2778
2791
|
|
|
2779
|
-
function
|
|
2792
|
+
function Bn(t, n) {
|
|
2780
2793
|
let e;
|
|
2781
|
-
if (n instanceof
|
|
2782
|
-
update:
|
|
2783
|
-
}; else if (n instanceof
|
|
2784
|
-
delete:
|
|
2785
|
-
}; else if (n instanceof
|
|
2786
|
-
update:
|
|
2787
|
-
updateMask:
|
|
2794
|
+
if (n instanceof An) e = {
|
|
2795
|
+
update: jn(t, n.key, n.value)
|
|
2796
|
+
}; else if (n instanceof Rn) e = {
|
|
2797
|
+
delete: Cn(t, n.key)
|
|
2798
|
+
}; else if (n instanceof Pn) e = {
|
|
2799
|
+
update: jn(t, n.key, n.data),
|
|
2800
|
+
updateMask: Hn(n.fieldMask)
|
|
2788
2801
|
}; else {
|
|
2789
|
-
if (!(n instanceof
|
|
2802
|
+
if (!(n instanceof Vn)) return g();
|
|
2790
2803
|
e = {
|
|
2791
|
-
verify:
|
|
2804
|
+
verify: Cn(t, n.key)
|
|
2792
2805
|
};
|
|
2793
2806
|
}
|
|
2794
2807
|
return n.fieldTransforms.length > 0 && (e.updateTransforms = n.fieldTransforms.map((t => function(t, n) {
|
|
2795
2808
|
const e = n.transform;
|
|
2796
|
-
if (e instanceof
|
|
2809
|
+
if (e instanceof _n) return {
|
|
2797
2810
|
fieldPath: n.field.canonicalString(),
|
|
2798
2811
|
setToServerValue: "REQUEST_TIME"
|
|
2799
2812
|
};
|
|
2800
|
-
if (e instanceof
|
|
2813
|
+
if (e instanceof gn) return {
|
|
2801
2814
|
fieldPath: n.field.canonicalString(),
|
|
2802
2815
|
appendMissingElements: {
|
|
2803
2816
|
values: e.elements
|
|
2804
2817
|
}
|
|
2805
2818
|
};
|
|
2806
|
-
if (e instanceof
|
|
2819
|
+
if (e instanceof vn) return {
|
|
2807
2820
|
fieldPath: n.field.canonicalString(),
|
|
2808
2821
|
removeAllFromArray: {
|
|
2809
2822
|
values: e.elements
|
|
2810
2823
|
}
|
|
2811
2824
|
};
|
|
2812
|
-
if (e instanceof
|
|
2825
|
+
if (e instanceof bn) return {
|
|
2813
2826
|
fieldPath: n.field.canonicalString(),
|
|
2814
|
-
increment: e.
|
|
2827
|
+
increment: e.O
|
|
2815
2828
|
};
|
|
2816
2829
|
throw g();
|
|
2817
2830
|
}(0, t)))), n.precondition.isNone || (e.currentDocument = function(t, n) {
|
|
2818
2831
|
return void 0 !== n.updateTime ? {
|
|
2819
|
-
updateTime:
|
|
2832
|
+
updateTime: qn(t, n.updateTime)
|
|
2820
2833
|
} : void 0 !== n.exists ? {
|
|
2821
2834
|
exists: n.exists
|
|
2822
2835
|
} : g();
|
|
2823
2836
|
}(t, n.precondition)), e;
|
|
2824
2837
|
}
|
|
2825
2838
|
|
|
2826
|
-
function
|
|
2839
|
+
function zn(t, n) {
|
|
2827
2840
|
// Dissect the path into parent, collectionId, and optional key filter.
|
|
2828
2841
|
const e = {
|
|
2829
2842
|
structuredQuery: {}
|
|
2830
2843
|
}, r = n.path;
|
|
2831
|
-
null !== n.collectionGroup ? (e.parent =
|
|
2844
|
+
null !== n.collectionGroup ? (e.parent = kn(t, r), e.structuredQuery.from = [ {
|
|
2832
2845
|
collectionId: n.collectionGroup,
|
|
2833
2846
|
allDescendants: !0
|
|
2834
|
-
} ]) : (e.parent =
|
|
2847
|
+
} ]) : (e.parent = kn(t, r.popLast()), e.structuredQuery.from = [ {
|
|
2835
2848
|
collectionId: r.lastSegment()
|
|
2836
2849
|
} ]);
|
|
2837
2850
|
const s = function(t) {
|
|
@@ -2840,36 +2853,36 @@ function Mn(t, n) {
|
|
|
2840
2853
|
// visible for testing
|
|
2841
2854
|
function(t) {
|
|
2842
2855
|
if ("==" /* EQUAL */ === t.op) {
|
|
2843
|
-
if (
|
|
2856
|
+
if (jt(t.value)) return {
|
|
2844
2857
|
unaryFilter: {
|
|
2845
|
-
field:
|
|
2858
|
+
field: Yn(t.field),
|
|
2846
2859
|
op: "IS_NAN"
|
|
2847
2860
|
}
|
|
2848
2861
|
};
|
|
2849
|
-
if (
|
|
2862
|
+
if (Ut(t.value)) return {
|
|
2850
2863
|
unaryFilter: {
|
|
2851
|
-
field:
|
|
2864
|
+
field: Yn(t.field),
|
|
2852
2865
|
op: "IS_NULL"
|
|
2853
2866
|
}
|
|
2854
2867
|
};
|
|
2855
2868
|
} else if ("!=" /* NOT_EQUAL */ === t.op) {
|
|
2856
|
-
if (
|
|
2869
|
+
if (jt(t.value)) return {
|
|
2857
2870
|
unaryFilter: {
|
|
2858
|
-
field:
|
|
2871
|
+
field: Yn(t.field),
|
|
2859
2872
|
op: "IS_NOT_NAN"
|
|
2860
2873
|
}
|
|
2861
2874
|
};
|
|
2862
|
-
if (
|
|
2875
|
+
if (Ut(t.value)) return {
|
|
2863
2876
|
unaryFilter: {
|
|
2864
|
-
field:
|
|
2877
|
+
field: Yn(t.field),
|
|
2865
2878
|
op: "IS_NOT_NULL"
|
|
2866
2879
|
}
|
|
2867
2880
|
};
|
|
2868
2881
|
}
|
|
2869
2882
|
return {
|
|
2870
2883
|
fieldFilter: {
|
|
2871
|
-
field:
|
|
2872
|
-
op:
|
|
2884
|
+
field: Yn(t.field),
|
|
2885
|
+
op: Wn(t.op),
|
|
2873
2886
|
value: t.value
|
|
2874
2887
|
}
|
|
2875
2888
|
};
|
|
@@ -2889,22 +2902,22 @@ function Mn(t, n) {
|
|
|
2889
2902
|
// visible for testing
|
|
2890
2903
|
function(t) {
|
|
2891
2904
|
return {
|
|
2892
|
-
field:
|
|
2893
|
-
direction:
|
|
2905
|
+
field: Yn(t.field),
|
|
2906
|
+
direction: Gn(t.dir)
|
|
2894
2907
|
};
|
|
2895
2908
|
}(t)));
|
|
2896
2909
|
}(n.orderBy);
|
|
2897
2910
|
i && (e.structuredQuery.orderBy = i);
|
|
2898
2911
|
const o = function(t, n) {
|
|
2899
|
-
return t.
|
|
2912
|
+
return t.S || ct(n) ? n : {
|
|
2900
2913
|
value: n
|
|
2901
2914
|
};
|
|
2902
2915
|
}(t, n.limit);
|
|
2903
|
-
return null !== o && (e.structuredQuery.limit = o), n.startAt && (e.structuredQuery.startAt =
|
|
2904
|
-
n.endAt && (e.structuredQuery.endAt =
|
|
2916
|
+
return null !== o && (e.structuredQuery.limit = o), n.startAt && (e.structuredQuery.startAt = Qn(n.startAt)),
|
|
2917
|
+
n.endAt && (e.structuredQuery.endAt = Qn(n.endAt)), e;
|
|
2905
2918
|
}
|
|
2906
2919
|
|
|
2907
|
-
function
|
|
2920
|
+
function Qn(t) {
|
|
2908
2921
|
return {
|
|
2909
2922
|
before: t.before,
|
|
2910
2923
|
values: t.position
|
|
@@ -2912,29 +2925,29 @@ function Bn(t) {
|
|
|
2912
2925
|
}
|
|
2913
2926
|
|
|
2914
2927
|
// visible for testing
|
|
2915
|
-
function
|
|
2916
|
-
return
|
|
2928
|
+
function Gn(t) {
|
|
2929
|
+
return Nn[t];
|
|
2917
2930
|
}
|
|
2918
2931
|
|
|
2919
2932
|
// visible for testing
|
|
2920
|
-
function
|
|
2921
|
-
return
|
|
2933
|
+
function Wn(t) {
|
|
2934
|
+
return Dn[t];
|
|
2922
2935
|
}
|
|
2923
2936
|
|
|
2924
|
-
function
|
|
2937
|
+
function Yn(t) {
|
|
2925
2938
|
return {
|
|
2926
2939
|
fieldPath: t.canonicalString()
|
|
2927
2940
|
};
|
|
2928
2941
|
}
|
|
2929
2942
|
|
|
2930
|
-
function
|
|
2943
|
+
function Hn(t) {
|
|
2931
2944
|
const n = [];
|
|
2932
2945
|
return t.fields.forEach((t => n.push(t.canonicalString()))), {
|
|
2933
2946
|
fieldPaths: n
|
|
2934
2947
|
};
|
|
2935
2948
|
}
|
|
2936
2949
|
|
|
2937
|
-
function
|
|
2950
|
+
function Kn(t) {
|
|
2938
2951
|
// Resource names have at least 4 components (project ID, database ID)
|
|
2939
2952
|
return t.length >= 4 && "projects" === t.get(0) && "databases" === t.get(2);
|
|
2940
2953
|
}
|
|
@@ -2954,8 +2967,8 @@ function Hn(t) {
|
|
|
2954
2967
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2955
2968
|
* See the License for the specific language governing permissions and
|
|
2956
2969
|
* limitations under the License.
|
|
2957
|
-
*/ function
|
|
2958
|
-
return new
|
|
2970
|
+
*/ function Jn(t) {
|
|
2971
|
+
return new $n(t, /* useProto3Json= */ !0);
|
|
2959
2972
|
}
|
|
2960
2973
|
|
|
2961
2974
|
/**
|
|
@@ -2983,7 +2996,7 @@ function Hn(t) {
|
|
|
2983
2996
|
* base delay. This prevents clients from accidentally synchronizing their
|
|
2984
2997
|
* delays causing spikes of load to the backend.
|
|
2985
2998
|
*/
|
|
2986
|
-
class
|
|
2999
|
+
class Xn {
|
|
2987
3000
|
constructor(
|
|
2988
3001
|
/**
|
|
2989
3002
|
* The AsyncQueue to run backoff operations on.
|
|
@@ -3008,9 +3021,9 @@ class Kn {
|
|
|
3008
3021
|
* Note that jitter will still be applied, so the actual delay could be as
|
|
3009
3022
|
* much as 1.5*maxDelayMs.
|
|
3010
3023
|
*/ , s = 6e4) {
|
|
3011
|
-
this.
|
|
3024
|
+
this.C = t, this.timerId = n, this.L = e, this.k = r, this.U = s, this.j = 0, this.M = null,
|
|
3012
3025
|
/** The last backoff attempt, as epoch milliseconds. */
|
|
3013
|
-
this.
|
|
3026
|
+
this.B = Date.now(), this.reset();
|
|
3014
3027
|
}
|
|
3015
3028
|
/**
|
|
3016
3029
|
* Resets the backoff delay.
|
|
@@ -3024,7 +3037,7 @@ class Kn {
|
|
|
3024
3037
|
/**
|
|
3025
3038
|
* Resets the backoff delay to the maximum delay (e.g. for use after a
|
|
3026
3039
|
* RESOURCE_EXHAUSTED error).
|
|
3027
|
-
*/
|
|
3040
|
+
*/ G() {
|
|
3028
3041
|
this.j = this.U;
|
|
3029
3042
|
}
|
|
3030
3043
|
/**
|
|
@@ -3036,22 +3049,22 @@ class Kn {
|
|
|
3036
3049
|
this.cancel();
|
|
3037
3050
|
// First schedule using the current base (which may be 0 and should be
|
|
3038
3051
|
// honored as such).
|
|
3039
|
-
const n = Math.floor(this.j + this.
|
|
3052
|
+
const n = Math.floor(this.j + this.Y()), e = Math.max(0, Date.now() - this.B), r = Math.max(0, n - e);
|
|
3040
3053
|
// Guard against lastAttemptTime being in the future due to a clock change.
|
|
3041
3054
|
r > 0 && m("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.j} ms, delay with jitter: ${n} ms, last attempt: ${e} ms ago)`),
|
|
3042
|
-
this.
|
|
3055
|
+
this.M = this.C.enqueueAfterDelay(this.timerId, r, (() => (this.B = Date.now(),
|
|
3043
3056
|
t()))),
|
|
3044
3057
|
// Apply backoff factor to determine next delay and ensure it is within
|
|
3045
3058
|
// bounds.
|
|
3046
|
-
this.j *= this.
|
|
3059
|
+
this.j *= this.k, this.j < this.L && (this.j = this.L), this.j > this.U && (this.j = this.U);
|
|
3047
3060
|
}
|
|
3048
3061
|
H() {
|
|
3049
|
-
null !== this.
|
|
3062
|
+
null !== this.M && (this.M.skipDelay(), this.M = null);
|
|
3050
3063
|
}
|
|
3051
3064
|
cancel() {
|
|
3052
|
-
null !== this.
|
|
3065
|
+
null !== this.M && (this.M.cancel(), this.M = null);
|
|
3053
3066
|
}
|
|
3054
|
-
/** Returns a random value in the range [-currentBaseMs/2, currentBaseMs/2] */
|
|
3067
|
+
/** Returns a random value in the range [-currentBaseMs/2, currentBaseMs/2] */ Y() {
|
|
3055
3068
|
return (Math.random() - .5) * this.j;
|
|
3056
3069
|
}
|
|
3057
3070
|
}
|
|
@@ -3081,45 +3094,46 @@ class Kn {
|
|
|
3081
3094
|
* An implementation of Datastore that exposes additional state for internal
|
|
3082
3095
|
* consumption.
|
|
3083
3096
|
*/
|
|
3084
|
-
class
|
|
3085
|
-
constructor(t, n, e) {
|
|
3086
|
-
super(), this.
|
|
3097
|
+
class Zn extends class {} {
|
|
3098
|
+
constructor(t, n, e, r) {
|
|
3099
|
+
super(), this.authCredentials = t, this.appCheckCredentials = n, this.K = e, this.q = r,
|
|
3100
|
+
this.J = !1;
|
|
3087
3101
|
}
|
|
3088
|
-
|
|
3089
|
-
if (this.
|
|
3102
|
+
X() {
|
|
3103
|
+
if (this.J) throw new k(F, "The client has already been terminated.");
|
|
3090
3104
|
}
|
|
3091
|
-
/**
|
|
3092
|
-
return this.
|
|
3093
|
-
throw "FirebaseError" === t.name ? (t.code === D && this.
|
|
3094
|
-
t) : new
|
|
3105
|
+
/** Invokes the provided RPC with auth and AppCheck tokens. */ m(t, n, e) {
|
|
3106
|
+
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.m(t, n, e, r, s))).catch((t => {
|
|
3107
|
+
throw "FirebaseError" === t.name ? (t.code === D && (this.authCredentials.invalidateToken(),
|
|
3108
|
+
this.appCheckCredentials.invalidateToken()), t) : new k(I, t.toString());
|
|
3095
3109
|
}));
|
|
3096
3110
|
}
|
|
3097
|
-
/**
|
|
3098
|
-
return this.
|
|
3099
|
-
throw "FirebaseError" === t.name ? (t.code === D && this.
|
|
3100
|
-
t) : new
|
|
3111
|
+
/** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */ T(t, n, e) {
|
|
3112
|
+
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.T(t, n, e, r, s))).catch((t => {
|
|
3113
|
+
throw "FirebaseError" === t.name ? (t.code === D && (this.authCredentials.invalidateToken(),
|
|
3114
|
+
this.appCheckCredentials.invalidateToken()), t) : new k(I, t.toString());
|
|
3101
3115
|
}));
|
|
3102
3116
|
}
|
|
3103
3117
|
terminate() {
|
|
3104
|
-
this.
|
|
3118
|
+
this.J = !0;
|
|
3105
3119
|
}
|
|
3106
3120
|
}
|
|
3107
3121
|
|
|
3108
3122
|
// TODO(firestorexp): Make sure there is only one Datastore instance per
|
|
3109
3123
|
// firestore-exp client.
|
|
3110
|
-
async function
|
|
3111
|
-
const e = b(t), r =
|
|
3112
|
-
writes: n.map((t =>
|
|
3124
|
+
async function te(t, n) {
|
|
3125
|
+
const e = b(t), r = Un(e.q) + "/documents", s = {
|
|
3126
|
+
writes: n.map((t => Bn(e.q, t)))
|
|
3113
3127
|
};
|
|
3114
|
-
await e.
|
|
3128
|
+
await e.m("Commit", r, s);
|
|
3115
3129
|
}
|
|
3116
3130
|
|
|
3117
|
-
async function
|
|
3118
|
-
const e = b(t), r =
|
|
3119
|
-
documents: n.map((t =>
|
|
3120
|
-
}, i = await e.
|
|
3131
|
+
async function ne(t, n) {
|
|
3132
|
+
const e = b(t), r = Un(e.q) + "/documents", s = {
|
|
3133
|
+
documents: n.map((t => Cn(e.q, t)))
|
|
3134
|
+
}, i = await e.T("BatchGetDocuments", r, s), o = new Map;
|
|
3121
3135
|
i.forEach((t => {
|
|
3122
|
-
const n =
|
|
3136
|
+
const n = Mn(e.q, t);
|
|
3123
3137
|
o.set(n.key.toString(), n);
|
|
3124
3138
|
}));
|
|
3125
3139
|
const u = [];
|
|
@@ -3129,18 +3143,18 @@ async function Xn(t, n) {
|
|
|
3129
3143
|
})), u;
|
|
3130
3144
|
}
|
|
3131
3145
|
|
|
3132
|
-
async function
|
|
3133
|
-
const e = b(t), r =
|
|
3134
|
-
return (await e.
|
|
3146
|
+
async function ee(t, n) {
|
|
3147
|
+
const e = b(t), r = zn(e.q, wn(n));
|
|
3148
|
+
return (await e.T("RunQuery", r.parent, {
|
|
3135
3149
|
structuredQuery: r.structuredQuery
|
|
3136
3150
|
})).filter((t => !!t.document)).map((t => function(t, n, e) {
|
|
3137
|
-
const r =
|
|
3151
|
+
const r = Ln(t, n.name), s = xn(n.updateTime), i = new zt({
|
|
3138
3152
|
mapValue: {
|
|
3139
3153
|
fields: n.fields
|
|
3140
3154
|
}
|
|
3141
|
-
}), o =
|
|
3155
|
+
}), o = Qt.newFoundDocument(r, s, i);
|
|
3142
3156
|
return e && o.setHasCommittedMutations(), e ? o.setHasCommittedMutations() : o;
|
|
3143
|
-
}(e.
|
|
3157
|
+
}(e.q, t.document, void 0)));
|
|
3144
3158
|
}
|
|
3145
3159
|
|
|
3146
3160
|
/**
|
|
@@ -3158,7 +3172,7 @@ async function te(t, n) {
|
|
|
3158
3172
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3159
3173
|
* See the License for the specific language governing permissions and
|
|
3160
3174
|
* limitations under the License.
|
|
3161
|
-
*/ const
|
|
3175
|
+
*/ const re = new Map;
|
|
3162
3176
|
|
|
3163
3177
|
/**
|
|
3164
3178
|
* An instance map that ensures only one Datastore exists per Firestore
|
|
@@ -3169,17 +3183,17 @@ async function te(t, n) {
|
|
|
3169
3183
|
* instance. Callers must invoke removeComponents() when the Firestore
|
|
3170
3184
|
* instance is terminated.
|
|
3171
3185
|
*/
|
|
3172
|
-
function
|
|
3173
|
-
if (t._terminated) throw new
|
|
3174
|
-
if (!
|
|
3186
|
+
function se(t) {
|
|
3187
|
+
if (t._terminated) throw new k(F, "The client has already been terminated.");
|
|
3188
|
+
if (!re.has(t)) {
|
|
3175
3189
|
m("ComponentProvider", "Initializing Datastore");
|
|
3176
3190
|
const i = function(t) {
|
|
3177
|
-
return new
|
|
3191
|
+
return new wt(t, fetch.bind(null));
|
|
3178
3192
|
}((n = t._databaseId, e = t.app.options.appId || "", r = t._persistenceKey, s = t._freezeSettings(),
|
|
3179
|
-
new
|
|
3180
|
-
return new
|
|
3181
|
-
}(t.
|
|
3182
|
-
|
|
3193
|
+
new H(n, e, r, s.host, s.ssl, s.experimentalForceLongPolling, s.experimentalAutoDetectLongPolling, s.useFetchStreams))), o = Jn(t._databaseId), u = function(t, n, e, r) {
|
|
3194
|
+
return new Zn(t, n, e, r);
|
|
3195
|
+
}(t._authCredentials, t._appCheckCredentials, i, o);
|
|
3196
|
+
re.set(t, u);
|
|
3183
3197
|
}
|
|
3184
3198
|
var n, e, r, s;
|
|
3185
3199
|
/**
|
|
@@ -3197,7 +3211,7 @@ function ee(t) {
|
|
|
3197
3211
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3198
3212
|
* See the License for the specific language governing permissions and
|
|
3199
3213
|
* limitations under the License.
|
|
3200
|
-
*/ return
|
|
3214
|
+
*/ return re.get(t);
|
|
3201
3215
|
}
|
|
3202
3216
|
|
|
3203
3217
|
/**
|
|
@@ -3209,21 +3223,21 @@ function ee(t) {
|
|
|
3209
3223
|
* user-supplied `FirestoreSettings` object. This is a separate type so that
|
|
3210
3224
|
* defaults can be supplied and the value can be checked for equality.
|
|
3211
3225
|
*/
|
|
3212
|
-
class
|
|
3226
|
+
class ie {
|
|
3213
3227
|
constructor(t) {
|
|
3214
3228
|
var n;
|
|
3215
3229
|
if (void 0 === t.host) {
|
|
3216
|
-
if (void 0 !== t.ssl) throw new
|
|
3230
|
+
if (void 0 !== t.ssl) throw new k(A, "Can't provide ssl option if host option is not set");
|
|
3217
3231
|
this.host = "firestore.googleapis.com", this.ssl = true;
|
|
3218
3232
|
} else this.host = t.host, this.ssl = null === (n = t.ssl) || void 0 === n || n;
|
|
3219
3233
|
if (this.credentials = t.credentials, this.ignoreUndefinedProperties = !!t.ignoreUndefinedProperties,
|
|
3220
3234
|
void 0 === t.cacheSizeBytes) this.cacheSizeBytes = 41943040; else {
|
|
3221
|
-
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new
|
|
3235
|
+
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new k(A, "cacheSizeBytes must be at least 1048576");
|
|
3222
3236
|
this.cacheSizeBytes = t.cacheSizeBytes;
|
|
3223
3237
|
}
|
|
3224
3238
|
this.experimentalForceLongPolling = !!t.experimentalForceLongPolling, this.experimentalAutoDetectLongPolling = !!t.experimentalAutoDetectLongPolling,
|
|
3225
3239
|
this.useFetchStreams = !!t.useFetchStreams, function(t, n, e, r) {
|
|
3226
|
-
if (!0 === n && !0 === r) throw new
|
|
3240
|
+
if (!0 === n && !0 === r) throw new k(A, `${t} and ${e} cannot be used together.`);
|
|
3227
3241
|
}("experimentalForceLongPolling", t.experimentalForceLongPolling, "experimentalAutoDetectLongPolling", t.experimentalAutoDetectLongPolling);
|
|
3228
3242
|
}
|
|
3229
3243
|
isEqual(t) {
|
|
@@ -3251,18 +3265,18 @@ class re {
|
|
|
3251
3265
|
* The Cloud Firestore service interface.
|
|
3252
3266
|
*
|
|
3253
3267
|
* Do not call this constructor directly. Instead, use {@link getFirestore}.
|
|
3254
|
-
*/ class
|
|
3268
|
+
*/ class oe {
|
|
3255
3269
|
/** @hideconstructor */
|
|
3256
|
-
constructor(t, n) {
|
|
3257
|
-
this.
|
|
3270
|
+
constructor(t, n, e) {
|
|
3271
|
+
this._authCredentials = n, this._appCheckCredentials = e,
|
|
3258
3272
|
/**
|
|
3259
3273
|
* Whether it's a Firestore or Firestore Lite instance.
|
|
3260
3274
|
*/
|
|
3261
|
-
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new
|
|
3262
|
-
this._settingsFrozen = !1, t instanceof
|
|
3275
|
+
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new ie({}),
|
|
3276
|
+
this._settingsFrozen = !1, t instanceof K ? this._databaseId = t : (this._app = t,
|
|
3263
3277
|
this._databaseId = function(t) {
|
|
3264
|
-
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new
|
|
3265
|
-
return new
|
|
3278
|
+
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new k(A, '"projectId" not provided in firebase.initializeApp.');
|
|
3279
|
+
return new K(t.options.projectId);
|
|
3266
3280
|
}
|
|
3267
3281
|
/**
|
|
3268
3282
|
* Initializes a new instance of Cloud Firestore with the provided settings.
|
|
@@ -3280,7 +3294,7 @@ class re {
|
|
|
3280
3294
|
* The {@link @firebase/app#FirebaseApp} associated with this `Firestore` service
|
|
3281
3295
|
* instance.
|
|
3282
3296
|
*/ get app() {
|
|
3283
|
-
if (!this._app) throw new
|
|
3297
|
+
if (!this._app) throw new k(F, "Firestore was not initialized using the Firebase SDK. 'app' is not available");
|
|
3284
3298
|
return this._app;
|
|
3285
3299
|
}
|
|
3286
3300
|
get _initialized() {
|
|
@@ -3290,21 +3304,21 @@ class re {
|
|
|
3290
3304
|
return void 0 !== this._terminateTask;
|
|
3291
3305
|
}
|
|
3292
3306
|
_setSettings(t) {
|
|
3293
|
-
if (this._settingsFrozen) throw new
|
|
3294
|
-
this._settings = new
|
|
3307
|
+
if (this._settingsFrozen) throw new k(F, "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.");
|
|
3308
|
+
this._settings = new ie(t), void 0 !== t.credentials && (this._authCredentials = function(t) {
|
|
3295
3309
|
if (!t) return new M;
|
|
3296
3310
|
switch (t.type) {
|
|
3297
3311
|
case "gapi":
|
|
3298
3312
|
const n = t.client;
|
|
3299
3313
|
// Make sure this really is a Gapi client.
|
|
3300
3314
|
return v(!("object" != typeof n || null === n || !n.auth || !n.auth.getAuthHeaderValueForFirstParty)),
|
|
3301
|
-
new
|
|
3315
|
+
new G(n, t.sessionIndex || "0", t.iamToken || null);
|
|
3302
3316
|
|
|
3303
3317
|
case "provider":
|
|
3304
3318
|
return t.client;
|
|
3305
3319
|
|
|
3306
3320
|
default:
|
|
3307
|
-
throw new
|
|
3321
|
+
throw new k(A, "makeAuthCredentialsProvider failed due to invalid credential type");
|
|
3308
3322
|
}
|
|
3309
3323
|
}(t.credentials));
|
|
3310
3324
|
}
|
|
@@ -3332,15 +3346,15 @@ class re {
|
|
|
3332
3346
|
* Only ever called once.
|
|
3333
3347
|
*/ _terminate() {
|
|
3334
3348
|
return function(t) {
|
|
3335
|
-
const n =
|
|
3336
|
-
n && (m("ComponentProvider", "Removing Datastore"),
|
|
3349
|
+
const n = re.get(t);
|
|
3350
|
+
n && (m("ComponentProvider", "Removing Datastore"), re.delete(t), n.terminate());
|
|
3337
3351
|
}(this), Promise.resolve();
|
|
3338
3352
|
}
|
|
3339
3353
|
}
|
|
3340
3354
|
|
|
3341
|
-
function
|
|
3355
|
+
function ue(t, n) {
|
|
3342
3356
|
const e = _getProvider(t, "firestore/lite");
|
|
3343
|
-
if (e.isInitialized()) throw new
|
|
3357
|
+
if (e.isInitialized()) throw new k(F, "Firestore can only be initialized once per app.");
|
|
3344
3358
|
return e.initialize({
|
|
3345
3359
|
options: n
|
|
3346
3360
|
});
|
|
@@ -3354,7 +3368,7 @@ function ie(t, n) {
|
|
|
3354
3368
|
* @param app - The {@link @firebase/app#FirebaseApp} instance that the returned `Firestore`
|
|
3355
3369
|
* instance is associated with.
|
|
3356
3370
|
* @returns The `Firestore` instance of the provided app.
|
|
3357
|
-
*/ function
|
|
3371
|
+
*/ function ce(n = t()) {
|
|
3358
3372
|
return _getProvider(n, "firestore/lite").getImmediate();
|
|
3359
3373
|
}
|
|
3360
3374
|
|
|
@@ -3370,9 +3384,9 @@ function ie(t, n) {
|
|
|
3370
3384
|
* @param port - the emulator port (ex: 9000).
|
|
3371
3385
|
* @param options.mockUserToken - the mock auth token to use for unit testing
|
|
3372
3386
|
* Security Rules.
|
|
3373
|
-
*/ function
|
|
3387
|
+
*/ function ae(t, n, e, r = {}) {
|
|
3374
3388
|
var s;
|
|
3375
|
-
const i = (t =
|
|
3389
|
+
const i = (t = ot(t, oe))._getSettings();
|
|
3376
3390
|
if ("firestore.googleapis.com" !== i.host && i.host !== n && y("Host has been set in both settings() and useEmulator(), emulator host will be used"),
|
|
3377
3391
|
t._setSettings(Object.assign(Object.assign({}, i), {
|
|
3378
3392
|
host: `${n}:${e}`,
|
|
@@ -3384,10 +3398,10 @@ function ie(t, n) {
|
|
|
3384
3398
|
// invalid field "uid" and missing field "sub" / "user_id".)
|
|
3385
3399
|
n = a(r.mockUserToken, null === (s = t._app) || void 0 === s ? void 0 : s.options.projectId);
|
|
3386
3400
|
const i = r.mockUserToken.sub || r.mockUserToken.user_id;
|
|
3387
|
-
if (!i) throw new
|
|
3401
|
+
if (!i) throw new k(A, "mockUserToken must contain 'sub' or 'user_id' field!");
|
|
3388
3402
|
e = new l(i);
|
|
3389
3403
|
}
|
|
3390
|
-
t.
|
|
3404
|
+
t._authCredentials = new B(new j(n, e));
|
|
3391
3405
|
}
|
|
3392
3406
|
}
|
|
3393
3407
|
|
|
@@ -3410,8 +3424,8 @@ function ie(t, n) {
|
|
|
3410
3424
|
* @param firestore - The `Firestore` instance to terminate.
|
|
3411
3425
|
* @returns A `Promise` that is resolved when the instance has been successfully
|
|
3412
3426
|
* terminated.
|
|
3413
|
-
*/ function
|
|
3414
|
-
return t =
|
|
3427
|
+
*/ function he(t) {
|
|
3428
|
+
return t = ot(t, oe), n(t.app, "firestore/lite"), t._delete();
|
|
3415
3429
|
}
|
|
3416
3430
|
|
|
3417
3431
|
/**
|
|
@@ -3451,7 +3465,7 @@ function ie(t, n) {
|
|
|
3451
3465
|
* and can be used to write, read, or listen to the location. The document at
|
|
3452
3466
|
* the referenced location may or may not exist.
|
|
3453
3467
|
*/
|
|
3454
|
-
class
|
|
3468
|
+
class le {
|
|
3455
3469
|
/** @hideconstructor */
|
|
3456
3470
|
constructor(t,
|
|
3457
3471
|
/**
|
|
@@ -3479,17 +3493,17 @@ class ae {
|
|
|
3479
3493
|
/**
|
|
3480
3494
|
* The collection this `DocumentReference` belongs to.
|
|
3481
3495
|
*/ get parent() {
|
|
3482
|
-
return new
|
|
3496
|
+
return new de(this.firestore, this.converter, this._key.path.popLast());
|
|
3483
3497
|
}
|
|
3484
3498
|
withConverter(t) {
|
|
3485
|
-
return new
|
|
3499
|
+
return new le(this.firestore, t, this._key);
|
|
3486
3500
|
}
|
|
3487
3501
|
}
|
|
3488
3502
|
|
|
3489
3503
|
/**
|
|
3490
3504
|
* A `Query` refers to a query which you can read or listen to. You can also
|
|
3491
3505
|
* construct refined `Query` objects by adding filters and ordering.
|
|
3492
|
-
*/ class
|
|
3506
|
+
*/ class fe {
|
|
3493
3507
|
// This is the lite version of the Query class in the main SDK.
|
|
3494
3508
|
/** @hideconstructor protected */
|
|
3495
3509
|
constructor(t,
|
|
@@ -3502,17 +3516,17 @@ class ae {
|
|
|
3502
3516
|
this.type = "query", this.firestore = t;
|
|
3503
3517
|
}
|
|
3504
3518
|
withConverter(t) {
|
|
3505
|
-
return new
|
|
3519
|
+
return new fe(this.firestore, t, this._query);
|
|
3506
3520
|
}
|
|
3507
3521
|
}
|
|
3508
3522
|
|
|
3509
3523
|
/**
|
|
3510
3524
|
* A `CollectionReference` object can be used for adding documents, getting
|
|
3511
3525
|
* document references, and querying for documents (using {@link query}).
|
|
3512
|
-
*/ class
|
|
3526
|
+
*/ class de extends fe {
|
|
3513
3527
|
/** @hideconstructor */
|
|
3514
3528
|
constructor(t, n, e) {
|
|
3515
|
-
super(t, n, new
|
|
3529
|
+
super(t, n, new cn(e)), this._path = e,
|
|
3516
3530
|
/** The type of this Firestore reference. */
|
|
3517
3531
|
this.type = "collection";
|
|
3518
3532
|
}
|
|
@@ -3530,23 +3544,23 @@ class ae {
|
|
|
3530
3544
|
* subcollection. If this isn't a subcollection, the reference is null.
|
|
3531
3545
|
*/ get parent() {
|
|
3532
3546
|
const t = this._path.popLast();
|
|
3533
|
-
return t.isEmpty() ? null : new
|
|
3534
|
-
/* converter= */ null, new
|
|
3547
|
+
return t.isEmpty() ? null : new le(this.firestore,
|
|
3548
|
+
/* converter= */ null, new nt(t));
|
|
3535
3549
|
}
|
|
3536
3550
|
withConverter(t) {
|
|
3537
|
-
return new
|
|
3551
|
+
return new de(this.firestore, t, this._path);
|
|
3538
3552
|
}
|
|
3539
3553
|
}
|
|
3540
3554
|
|
|
3541
|
-
function
|
|
3542
|
-
if (t = h(t),
|
|
3543
|
-
const r =
|
|
3544
|
-
return
|
|
3555
|
+
function we(t, n, ...e) {
|
|
3556
|
+
if (t = h(t), et("collection", "path", n), t instanceof oe) {
|
|
3557
|
+
const r = X.fromString(n, ...e);
|
|
3558
|
+
return st(r), new de(t, /* converter= */ null, r);
|
|
3545
3559
|
}
|
|
3546
3560
|
{
|
|
3547
|
-
if (!(t instanceof
|
|
3548
|
-
const r = t._path.child(
|
|
3549
|
-
return
|
|
3561
|
+
if (!(t instanceof le || t instanceof de)) throw new k(A, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3562
|
+
const r = t._path.child(X.fromString(n, ...e));
|
|
3563
|
+
return st(r), new de(t.firestore,
|
|
3550
3564
|
/* converter= */ null, r);
|
|
3551
3565
|
}
|
|
3552
3566
|
}
|
|
@@ -3563,32 +3577,32 @@ function fe(t, n, ...e) {
|
|
|
3563
3577
|
* collection or subcollection with this ID as the last segment of its path
|
|
3564
3578
|
* will be included. Cannot contain a slash.
|
|
3565
3579
|
* @returns The created `Query`.
|
|
3566
|
-
*/ function
|
|
3567
|
-
if (t =
|
|
3568
|
-
return new
|
|
3580
|
+
*/ function me(t, n) {
|
|
3581
|
+
if (t = ot(t, oe), et("collectionGroup", "collection id", n), n.indexOf("/") >= 0) throw new k(A, `Invalid collection ID '${n}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);
|
|
3582
|
+
return new fe(t,
|
|
3569
3583
|
/* converter= */ null,
|
|
3570
3584
|
/**
|
|
3571
3585
|
* Creates a new Query for a collection group query that matches all documents
|
|
3572
3586
|
* within the provided collection group.
|
|
3573
3587
|
*/
|
|
3574
3588
|
function(t) {
|
|
3575
|
-
return new
|
|
3589
|
+
return new cn(X.emptyPath(), t);
|
|
3576
3590
|
}(n));
|
|
3577
3591
|
}
|
|
3578
3592
|
|
|
3579
|
-
function
|
|
3593
|
+
function pe(t, n, ...e) {
|
|
3580
3594
|
if (t = h(t),
|
|
3581
3595
|
// We allow omission of 'pathString' but explicitly prohibit passing in both
|
|
3582
3596
|
// 'undefined' and 'null'.
|
|
3583
|
-
1 === arguments.length && (n =
|
|
3584
|
-
const r =
|
|
3585
|
-
return
|
|
3586
|
-
/* converter= */ null, new
|
|
3597
|
+
1 === arguments.length && (n = pt.P()), et("doc", "path", n), t instanceof oe) {
|
|
3598
|
+
const r = X.fromString(n, ...e);
|
|
3599
|
+
return rt(r), new le(t,
|
|
3600
|
+
/* converter= */ null, new nt(r));
|
|
3587
3601
|
}
|
|
3588
3602
|
{
|
|
3589
|
-
if (!(t instanceof
|
|
3590
|
-
const r = t._path.child(
|
|
3591
|
-
return
|
|
3603
|
+
if (!(t instanceof le || t instanceof de)) throw new k(A, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3604
|
+
const r = t._path.child(X.fromString(n, ...e));
|
|
3605
|
+
return rt(r), new le(t.firestore, t instanceof de ? t.converter : null, new nt(r));
|
|
3592
3606
|
}
|
|
3593
3607
|
}
|
|
3594
3608
|
|
|
@@ -3599,8 +3613,8 @@ function we(t, n, ...e) {
|
|
|
3599
3613
|
* @param right - A reference to compare.
|
|
3600
3614
|
* @returns true if the references point to the same location in the same
|
|
3601
3615
|
* Firestore database.
|
|
3602
|
-
*/ function
|
|
3603
|
-
return t = h(t), n = h(n), (t instanceof
|
|
3616
|
+
*/ function ye(t, n) {
|
|
3617
|
+
return t = h(t), n = h(n), (t instanceof le || t instanceof de) && (n instanceof le || n instanceof de) && (t.firestore === n.firestore && t.path === n.path && t.converter === n.converter);
|
|
3604
3618
|
}
|
|
3605
3619
|
|
|
3606
3620
|
/**
|
|
@@ -3611,8 +3625,8 @@ function we(t, n, ...e) {
|
|
|
3611
3625
|
* @param right - A `Query` to compare.
|
|
3612
3626
|
* @returns true if the references point to the same location in the same
|
|
3613
3627
|
* Firestore database.
|
|
3614
|
-
*/ function
|
|
3615
|
-
return t = h(t), n = h(n), t instanceof
|
|
3628
|
+
*/ function _e(t, n) {
|
|
3629
|
+
return t = h(t), n = h(n), t instanceof fe && n instanceof fe && (t.firestore === n.firestore && mn(t._query, n._query) && t.converter === n.converter);
|
|
3616
3630
|
}
|
|
3617
3631
|
|
|
3618
3632
|
/**
|
|
@@ -3638,7 +3652,7 @@ function we(t, n, ...e) {
|
|
|
3638
3652
|
*
|
|
3639
3653
|
* Create a `FieldPath` by providing field names. If more than one field
|
|
3640
3654
|
* name is provided, the path will point to a nested field in a document.
|
|
3641
|
-
*/ class
|
|
3655
|
+
*/ class ge {
|
|
3642
3656
|
/**
|
|
3643
3657
|
* Creates a `FieldPath` from the provided field names. If more than one field
|
|
3644
3658
|
* name is provided, the path will point to a nested field in a document.
|
|
@@ -3646,8 +3660,8 @@ function we(t, n, ...e) {
|
|
|
3646
3660
|
* @param fieldNames - A list of field names.
|
|
3647
3661
|
*/
|
|
3648
3662
|
constructor(...t) {
|
|
3649
|
-
for (let n = 0; n < t.length; ++n) if (0 === t[n].length) throw new
|
|
3650
|
-
this._internalPath = new
|
|
3663
|
+
for (let n = 0; n < t.length; ++n) if (0 === t[n].length) throw new k(A, "Invalid field name at argument $(i + 1). Field names must not be empty.");
|
|
3664
|
+
this._internalPath = new tt(t);
|
|
3651
3665
|
}
|
|
3652
3666
|
/**
|
|
3653
3667
|
* Returns true if this `FieldPath` is equal to the provided one.
|
|
@@ -3662,8 +3676,8 @@ function we(t, n, ...e) {
|
|
|
3662
3676
|
/**
|
|
3663
3677
|
* Returns a special sentinel `FieldPath` to refer to the ID of a document.
|
|
3664
3678
|
* It can be used in queries to sort or filter by the document ID.
|
|
3665
|
-
*/ function
|
|
3666
|
-
return new
|
|
3679
|
+
*/ function ve() {
|
|
3680
|
+
return new ge("__name__");
|
|
3667
3681
|
}
|
|
3668
3682
|
|
|
3669
3683
|
/**
|
|
@@ -3684,7 +3698,7 @@ function we(t, n, ...e) {
|
|
|
3684
3698
|
*/
|
|
3685
3699
|
/**
|
|
3686
3700
|
* An immutable object representing an array of bytes.
|
|
3687
|
-
*/ class
|
|
3701
|
+
*/ class be {
|
|
3688
3702
|
/** @hideconstructor */
|
|
3689
3703
|
constructor(t) {
|
|
3690
3704
|
this._byteString = t;
|
|
@@ -3696,9 +3710,9 @@ function we(t, n, ...e) {
|
|
|
3696
3710
|
* @param base64 - The Base64 string used to create the `Bytes` object.
|
|
3697
3711
|
*/ static fromBase64String(t) {
|
|
3698
3712
|
try {
|
|
3699
|
-
return new
|
|
3713
|
+
return new be(At.fromBase64String(t));
|
|
3700
3714
|
} catch (t) {
|
|
3701
|
-
throw new
|
|
3715
|
+
throw new k(A, "Failed to construct data from Base64 string: " + t);
|
|
3702
3716
|
}
|
|
3703
3717
|
}
|
|
3704
3718
|
/**
|
|
@@ -3706,7 +3720,7 @@ function we(t, n, ...e) {
|
|
|
3706
3720
|
*
|
|
3707
3721
|
* @param array - The Uint8Array used to create the `Bytes` object.
|
|
3708
3722
|
*/ static fromUint8Array(t) {
|
|
3709
|
-
return new
|
|
3723
|
+
return new be(At.fromUint8Array(t));
|
|
3710
3724
|
}
|
|
3711
3725
|
/**
|
|
3712
3726
|
* Returns the underlying bytes as a Base64-encoded string.
|
|
@@ -3758,7 +3772,7 @@ function we(t, n, ...e) {
|
|
|
3758
3772
|
/**
|
|
3759
3773
|
* Sentinel values that can be used when writing document fields with `set()`
|
|
3760
3774
|
* or `update()`.
|
|
3761
|
-
*/ class
|
|
3775
|
+
*/ class Ee {
|
|
3762
3776
|
/**
|
|
3763
3777
|
* @param _methodName - The public API endpoint that returns this class.
|
|
3764
3778
|
* @hideconstructor
|
|
@@ -3790,7 +3804,7 @@ function we(t, n, ...e) {
|
|
|
3790
3804
|
*
|
|
3791
3805
|
* Latitude values are in the range of [-90, 90].
|
|
3792
3806
|
* Longitude values are in the range of [-180, 180].
|
|
3793
|
-
*/ class
|
|
3807
|
+
*/ class Te {
|
|
3794
3808
|
/**
|
|
3795
3809
|
* Creates a new immutable `GeoPoint` object with the provided latitude and
|
|
3796
3810
|
* longitude values.
|
|
@@ -3798,8 +3812,8 @@ function we(t, n, ...e) {
|
|
|
3798
3812
|
* @param longitude - The longitude as number between -180 and 180.
|
|
3799
3813
|
*/
|
|
3800
3814
|
constructor(t, n) {
|
|
3801
|
-
if (!isFinite(t) || t < -90 || t > 90) throw new
|
|
3802
|
-
if (!isFinite(n) || n < -180 || n > 180) throw new
|
|
3815
|
+
if (!isFinite(t) || t < -90 || t > 90) throw new k(A, "Latitude must be a number between -90 and 90, but was: " + t);
|
|
3816
|
+
if (!isFinite(n) || n < -180 || n > 180) throw new k(A, "Longitude must be a number between -180 and 180, but was: " + n);
|
|
3803
3817
|
this._lat = t, this._long = n;
|
|
3804
3818
|
}
|
|
3805
3819
|
/**
|
|
@@ -3830,7 +3844,7 @@ function we(t, n, ...e) {
|
|
|
3830
3844
|
* Actually private to JS consumers of our API, so this function is prefixed
|
|
3831
3845
|
* with an underscore.
|
|
3832
3846
|
*/ _compareTo(t) {
|
|
3833
|
-
return
|
|
3847
|
+
return yt(this._lat, t._lat) || yt(this._long, t._long);
|
|
3834
3848
|
}
|
|
3835
3849
|
}
|
|
3836
3850
|
|
|
@@ -3849,29 +3863,29 @@ function we(t, n, ...e) {
|
|
|
3849
3863
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3850
3864
|
* See the License for the specific language governing permissions and
|
|
3851
3865
|
* limitations under the License.
|
|
3852
|
-
*/ const
|
|
3866
|
+
*/ const Ie = /^__.*__$/;
|
|
3853
3867
|
|
|
3854
|
-
/** The result of parsing document data (e.g. for a setData call). */ class
|
|
3868
|
+
/** The result of parsing document data (e.g. for a setData call). */ class Ae {
|
|
3855
3869
|
constructor(t, n, e) {
|
|
3856
3870
|
this.data = t, this.fieldMask = n, this.fieldTransforms = e;
|
|
3857
3871
|
}
|
|
3858
3872
|
toMutation(t, n) {
|
|
3859
|
-
return null !== this.fieldMask ? new
|
|
3873
|
+
return null !== this.fieldMask ? new Pn(t, this.data, this.fieldMask, n, this.fieldTransforms) : new An(t, this.data, n, this.fieldTransforms);
|
|
3860
3874
|
}
|
|
3861
3875
|
}
|
|
3862
3876
|
|
|
3863
|
-
/** The result of parsing "update" data (i.e. for an updateData call). */ class
|
|
3877
|
+
/** The result of parsing "update" data (i.e. for an updateData call). */ class Pe {
|
|
3864
3878
|
constructor(t,
|
|
3865
3879
|
// The fieldMask does not include document transforms.
|
|
3866
3880
|
n, e) {
|
|
3867
3881
|
this.data = t, this.fieldMask = n, this.fieldTransforms = e;
|
|
3868
3882
|
}
|
|
3869
3883
|
toMutation(t, n) {
|
|
3870
|
-
return new
|
|
3884
|
+
return new Pn(t, this.data, this.fieldMask, n, this.fieldTransforms);
|
|
3871
3885
|
}
|
|
3872
3886
|
}
|
|
3873
3887
|
|
|
3874
|
-
function
|
|
3888
|
+
function Re(t) {
|
|
3875
3889
|
switch (t) {
|
|
3876
3890
|
case 0 /* Set */ :
|
|
3877
3891
|
// fall through
|
|
@@ -3889,7 +3903,7 @@ function Ae(t) {
|
|
|
3889
3903
|
}
|
|
3890
3904
|
}
|
|
3891
3905
|
|
|
3892
|
-
/** A "context" object passed around while parsing user data. */ class
|
|
3906
|
+
/** A "context" object passed around while parsing user data. */ class Ve {
|
|
3893
3907
|
/**
|
|
3894
3908
|
* Initializes a ParseContext with the given source and path.
|
|
3895
3909
|
*
|
|
@@ -3909,7 +3923,7 @@ function Ae(t) {
|
|
|
3909
3923
|
* compromised).
|
|
3910
3924
|
*/
|
|
3911
3925
|
constructor(t, n, e, r, s, i) {
|
|
3912
|
-
this.settings = t, this.databaseId = n, this.
|
|
3926
|
+
this.settings = t, this.databaseId = n, this.q = e, this.ignoreUndefinedProperties = r,
|
|
3913
3927
|
// Minor hack: If fieldTransforms is undefined, we assume this is an
|
|
3914
3928
|
// external call and we need to validate the entire path.
|
|
3915
3929
|
void 0 === s && this.Z(), this.fieldTransforms = s || [], this.fieldMask = i || [];
|
|
@@ -3917,38 +3931,38 @@ function Ae(t) {
|
|
|
3917
3931
|
get path() {
|
|
3918
3932
|
return this.settings.path;
|
|
3919
3933
|
}
|
|
3920
|
-
get
|
|
3921
|
-
return this.settings.
|
|
3934
|
+
get tt() {
|
|
3935
|
+
return this.settings.tt;
|
|
3922
3936
|
}
|
|
3923
|
-
/** Returns a new context with the specified settings overwritten. */
|
|
3924
|
-
return new
|
|
3937
|
+
/** Returns a new context with the specified settings overwritten. */ nt(t) {
|
|
3938
|
+
return new Ve(Object.assign(Object.assign({}, this.settings), t), this.databaseId, this.q, this.ignoreUndefinedProperties, this.fieldTransforms, this.fieldMask);
|
|
3925
3939
|
}
|
|
3926
|
-
|
|
3940
|
+
et(t) {
|
|
3927
3941
|
var n;
|
|
3928
|
-
const e = null === (n = this.path) || void 0 === n ? void 0 : n.child(t), r = this.
|
|
3942
|
+
const e = null === (n = this.path) || void 0 === n ? void 0 : n.child(t), r = this.nt({
|
|
3929
3943
|
path: e,
|
|
3930
|
-
|
|
3944
|
+
rt: !1
|
|
3931
3945
|
});
|
|
3932
|
-
return r.
|
|
3946
|
+
return r.st(t), r;
|
|
3933
3947
|
}
|
|
3934
|
-
|
|
3948
|
+
it(t) {
|
|
3935
3949
|
var n;
|
|
3936
|
-
const e = null === (n = this.path) || void 0 === n ? void 0 : n.child(t), r = this.
|
|
3950
|
+
const e = null === (n = this.path) || void 0 === n ? void 0 : n.child(t), r = this.nt({
|
|
3937
3951
|
path: e,
|
|
3938
|
-
|
|
3952
|
+
rt: !1
|
|
3939
3953
|
});
|
|
3940
3954
|
return r.Z(), r;
|
|
3941
3955
|
}
|
|
3942
|
-
|
|
3956
|
+
ot(t) {
|
|
3943
3957
|
// TODO(b/34871131): We don't support array paths right now; so make path
|
|
3944
3958
|
// undefined.
|
|
3945
|
-
return this.
|
|
3959
|
+
return this.nt({
|
|
3946
3960
|
path: void 0,
|
|
3947
|
-
|
|
3961
|
+
rt: !0
|
|
3948
3962
|
});
|
|
3949
3963
|
}
|
|
3950
|
-
|
|
3951
|
-
return
|
|
3964
|
+
ut(t) {
|
|
3965
|
+
return Ye(t, this.settings.methodName, this.settings.ct || !1, this.path, this.settings.at);
|
|
3952
3966
|
}
|
|
3953
3967
|
/** Returns 'true' if 'fieldPath' was traversed when creating this context. */ contains(t) {
|
|
3954
3968
|
return void 0 !== this.fieldMask.find((n => t.isPrefixOf(n))) || void 0 !== this.fieldTransforms.find((n => t.isPrefixOf(n.field)));
|
|
@@ -3956,64 +3970,64 @@ function Ae(t) {
|
|
|
3956
3970
|
Z() {
|
|
3957
3971
|
// TODO(b/34871131): Remove null check once we have proper paths for fields
|
|
3958
3972
|
// within arrays.
|
|
3959
|
-
if (this.path) for (let t = 0; t < this.path.length; t++) this.
|
|
3973
|
+
if (this.path) for (let t = 0; t < this.path.length; t++) this.st(this.path.get(t));
|
|
3960
3974
|
}
|
|
3961
|
-
|
|
3962
|
-
if (0 === t.length) throw this.
|
|
3963
|
-
if (
|
|
3975
|
+
st(t) {
|
|
3976
|
+
if (0 === t.length) throw this.ut("Document fields must not be empty");
|
|
3977
|
+
if (Re(this.tt) && Ie.test(t)) throw this.ut('Document fields cannot begin and end with "__"');
|
|
3964
3978
|
}
|
|
3965
3979
|
}
|
|
3966
3980
|
|
|
3967
3981
|
/**
|
|
3968
3982
|
* Helper for parsing raw user input (provided via the API) into internal model
|
|
3969
3983
|
* classes.
|
|
3970
|
-
*/ class
|
|
3984
|
+
*/ class Ne {
|
|
3971
3985
|
constructor(t, n, e) {
|
|
3972
|
-
this.databaseId = t, this.ignoreUndefinedProperties = n, this.
|
|
3986
|
+
this.databaseId = t, this.ignoreUndefinedProperties = n, this.q = e || Jn(t);
|
|
3973
3987
|
}
|
|
3974
|
-
/** Creates a new top-level parse context. */
|
|
3975
|
-
return new
|
|
3976
|
-
|
|
3988
|
+
/** Creates a new top-level parse context. */ ht(t, n, e, r = !1) {
|
|
3989
|
+
return new Ve({
|
|
3990
|
+
tt: t,
|
|
3977
3991
|
methodName: n,
|
|
3978
|
-
|
|
3979
|
-
path:
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
}, this.databaseId, this.
|
|
3992
|
+
at: e,
|
|
3993
|
+
path: tt.emptyPath(),
|
|
3994
|
+
rt: !1,
|
|
3995
|
+
ct: r
|
|
3996
|
+
}, this.databaseId, this.q, this.ignoreUndefinedProperties);
|
|
3983
3997
|
}
|
|
3984
3998
|
}
|
|
3985
3999
|
|
|
3986
|
-
function
|
|
3987
|
-
const n = t._freezeSettings(), e =
|
|
3988
|
-
return new
|
|
4000
|
+
function De(t) {
|
|
4001
|
+
const n = t._freezeSettings(), e = Jn(t._databaseId);
|
|
4002
|
+
return new Ne(t._databaseId, !!n.ignoreUndefinedProperties, e);
|
|
3989
4003
|
}
|
|
3990
4004
|
|
|
3991
|
-
/** Parse document data from a set() call. */ function
|
|
3992
|
-
const o = t.
|
|
3993
|
-
|
|
3994
|
-
const u =
|
|
4005
|
+
/** Parse document data from a set() call. */ function $e(t, n, e, r, s, i = {}) {
|
|
4006
|
+
const o = t.ht(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ , n, e, s);
|
|
4007
|
+
ze("Data must be an object, but it was:", o, r);
|
|
4008
|
+
const u = Me(r, o);
|
|
3995
4009
|
let c, a;
|
|
3996
|
-
if (i.merge) c = new
|
|
4010
|
+
if (i.merge) c = new Tt(o.fieldMask), a = o.fieldTransforms; else if (i.mergeFields) {
|
|
3997
4011
|
const t = [];
|
|
3998
4012
|
for (const r of i.mergeFields) {
|
|
3999
|
-
const s =
|
|
4000
|
-
if (!o.contains(s)) throw new
|
|
4001
|
-
|
|
4013
|
+
const s = Qe(n, r, e);
|
|
4014
|
+
if (!o.contains(s)) throw new k(A, `Field '${s}' is specified in your field mask but missing from your input data.`);
|
|
4015
|
+
He(t, s) || t.push(s);
|
|
4002
4016
|
}
|
|
4003
|
-
c = new
|
|
4017
|
+
c = new Tt(t), a = o.fieldTransforms.filter((t => c.covers(t.field)));
|
|
4004
4018
|
} else c = null, a = o.fieldTransforms;
|
|
4005
|
-
return new
|
|
4019
|
+
return new Ae(new zt(u), c, a);
|
|
4006
4020
|
}
|
|
4007
4021
|
|
|
4008
|
-
class
|
|
4022
|
+
class Fe extends Ee {
|
|
4009
4023
|
_toFieldTransform(t) {
|
|
4010
|
-
if (2 /* MergeSet */ !== t.
|
|
4024
|
+
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}`);
|
|
4011
4025
|
// No transform to add for a delete, but we need to add it to our
|
|
4012
4026
|
// fieldMask so it gets deleted.
|
|
4013
4027
|
return t.fieldMask.push(t.path), null;
|
|
4014
4028
|
}
|
|
4015
4029
|
isEqual(t) {
|
|
4016
|
-
return t instanceof
|
|
4030
|
+
return t instanceof Fe;
|
|
4017
4031
|
}
|
|
4018
4032
|
}
|
|
4019
4033
|
|
|
@@ -4032,32 +4046,32 @@ class De extends ve {
|
|
|
4032
4046
|
* context.
|
|
4033
4047
|
* @param context - The parent context.
|
|
4034
4048
|
* @param arrayElement - Whether or not the FieldValue has an array.
|
|
4035
|
-
*/ function
|
|
4036
|
-
return new
|
|
4037
|
-
|
|
4038
|
-
|
|
4049
|
+
*/ function Se(t, n, e) {
|
|
4050
|
+
return new Ve({
|
|
4051
|
+
tt: 3 /* Argument */ ,
|
|
4052
|
+
at: n.settings.at,
|
|
4039
4053
|
methodName: t._methodName,
|
|
4040
|
-
|
|
4041
|
-
}, n.databaseId, n.
|
|
4054
|
+
rt: e
|
|
4055
|
+
}, n.databaseId, n.q, n.ignoreUndefinedProperties);
|
|
4042
4056
|
}
|
|
4043
4057
|
|
|
4044
|
-
class
|
|
4058
|
+
class qe extends Ee {
|
|
4045
4059
|
_toFieldTransform(t) {
|
|
4046
|
-
return new
|
|
4060
|
+
return new En(t.path, new _n);
|
|
4047
4061
|
}
|
|
4048
4062
|
isEqual(t) {
|
|
4049
|
-
return t instanceof
|
|
4063
|
+
return t instanceof qe;
|
|
4050
4064
|
}
|
|
4051
4065
|
}
|
|
4052
4066
|
|
|
4053
|
-
class
|
|
4067
|
+
class xe extends Ee {
|
|
4054
4068
|
constructor(t, n) {
|
|
4055
|
-
super(t), this.
|
|
4069
|
+
super(t), this.lt = n;
|
|
4056
4070
|
}
|
|
4057
4071
|
_toFieldTransform(t) {
|
|
4058
|
-
const n =
|
|
4059
|
-
/*array=*/ !0), e = this.
|
|
4060
|
-
return new
|
|
4072
|
+
const n = Se(this, t,
|
|
4073
|
+
/*array=*/ !0), e = this.lt.map((t => je(t, n))), r = new gn(e);
|
|
4074
|
+
return new En(t.path, r);
|
|
4061
4075
|
}
|
|
4062
4076
|
isEqual(t) {
|
|
4063
4077
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4065,14 +4079,14 @@ class Se extends ve {
|
|
|
4065
4079
|
}
|
|
4066
4080
|
}
|
|
4067
4081
|
|
|
4068
|
-
class
|
|
4082
|
+
class Oe extends Ee {
|
|
4069
4083
|
constructor(t, n) {
|
|
4070
|
-
super(t), this.
|
|
4084
|
+
super(t), this.lt = n;
|
|
4071
4085
|
}
|
|
4072
4086
|
_toFieldTransform(t) {
|
|
4073
|
-
const n =
|
|
4074
|
-
/*array=*/ !0), e = this.
|
|
4075
|
-
return new
|
|
4087
|
+
const n = Se(this, t,
|
|
4088
|
+
/*array=*/ !0), e = this.lt.map((t => je(t, n))), r = new vn(e);
|
|
4089
|
+
return new En(t.path, r);
|
|
4076
4090
|
}
|
|
4077
4091
|
isEqual(t) {
|
|
4078
4092
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4080,13 +4094,13 @@ class qe extends ve {
|
|
|
4080
4094
|
}
|
|
4081
4095
|
}
|
|
4082
4096
|
|
|
4083
|
-
class
|
|
4097
|
+
class Ce extends Ee {
|
|
4084
4098
|
constructor(t, n) {
|
|
4085
|
-
super(t), this.
|
|
4099
|
+
super(t), this.ft = n;
|
|
4086
4100
|
}
|
|
4087
4101
|
_toFieldTransform(t) {
|
|
4088
|
-
const n = new
|
|
4089
|
-
return new
|
|
4102
|
+
const n = new bn(t.q, pn(t.q, this.ft));
|
|
4103
|
+
return new En(t.path, n);
|
|
4090
4104
|
}
|
|
4091
4105
|
isEqual(t) {
|
|
4092
4106
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4094,50 +4108,50 @@ class xe extends ve {
|
|
|
4094
4108
|
}
|
|
4095
4109
|
}
|
|
4096
4110
|
|
|
4097
|
-
/** Parse update data from an update() call. */ function
|
|
4098
|
-
const s = t.
|
|
4099
|
-
|
|
4100
|
-
const i = [], o =
|
|
4101
|
-
|
|
4102
|
-
const u =
|
|
4111
|
+
/** Parse update data from an update() call. */ function Le(t, n, e, r) {
|
|
4112
|
+
const s = t.ht(1 /* Update */ , n, e);
|
|
4113
|
+
ze("Data must be an object, but it was:", s, r);
|
|
4114
|
+
const i = [], o = zt.empty();
|
|
4115
|
+
Et(r, ((t, r) => {
|
|
4116
|
+
const u = We(n, t, e);
|
|
4103
4117
|
// For Compat types, we have to "extract" the underlying types before
|
|
4104
4118
|
// performing validation.
|
|
4105
4119
|
r = h(r);
|
|
4106
|
-
const c = s.
|
|
4107
|
-
if (r instanceof
|
|
4120
|
+
const c = s.it(u);
|
|
4121
|
+
if (r instanceof Fe)
|
|
4108
4122
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4109
4123
|
i.push(u); else {
|
|
4110
|
-
const t =
|
|
4124
|
+
const t = je(r, c);
|
|
4111
4125
|
null != t && (i.push(u), o.set(u, t));
|
|
4112
4126
|
}
|
|
4113
4127
|
}));
|
|
4114
|
-
const u = new
|
|
4115
|
-
return new
|
|
4128
|
+
const u = new Tt(i);
|
|
4129
|
+
return new Pe(o, u, s.fieldTransforms);
|
|
4116
4130
|
}
|
|
4117
4131
|
|
|
4118
|
-
/** Parse update data from a list of field/value arguments. */ function
|
|
4119
|
-
const o = t.
|
|
4120
|
-
if (i.length % 2 != 0) throw new
|
|
4121
|
-
for (let t = 0; t < i.length; t += 2) u.push(
|
|
4122
|
-
const a = [], l =
|
|
4132
|
+
/** Parse update data from a list of field/value arguments. */ function ke(t, n, e, r, s, i) {
|
|
4133
|
+
const o = t.ht(1 /* Update */ , n, e), u = [ Qe(n, r, e) ], c = [ s ];
|
|
4134
|
+
if (i.length % 2 != 0) throw new k(A, `Function ${n}() needs to be called with an even number of arguments that alternate between field names and values.`);
|
|
4135
|
+
for (let t = 0; t < i.length; t += 2) u.push(Qe(n, i[t])), c.push(i[t + 1]);
|
|
4136
|
+
const a = [], l = zt.empty();
|
|
4123
4137
|
// We iterate in reverse order to pick the last value for a field if the
|
|
4124
4138
|
// user specified the field multiple times.
|
|
4125
|
-
for (let t = u.length - 1; t >= 0; --t) if (!
|
|
4139
|
+
for (let t = u.length - 1; t >= 0; --t) if (!He(a, u[t])) {
|
|
4126
4140
|
const n = u[t];
|
|
4127
4141
|
let e = c[t];
|
|
4128
4142
|
// For Compat types, we have to "extract" the underlying types before
|
|
4129
4143
|
// performing validation.
|
|
4130
4144
|
e = h(e);
|
|
4131
|
-
const r = o.
|
|
4132
|
-
if (e instanceof
|
|
4145
|
+
const r = o.it(n);
|
|
4146
|
+
if (e instanceof Fe)
|
|
4133
4147
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4134
4148
|
a.push(n); else {
|
|
4135
|
-
const t =
|
|
4149
|
+
const t = je(e, r);
|
|
4136
4150
|
null != t && (a.push(n), l.set(n, t));
|
|
4137
4151
|
}
|
|
4138
4152
|
}
|
|
4139
|
-
const f = new
|
|
4140
|
-
return new
|
|
4153
|
+
const f = new Tt(a);
|
|
4154
|
+
return new Pe(l, f, o.fieldTransforms);
|
|
4141
4155
|
}
|
|
4142
4156
|
|
|
4143
4157
|
/**
|
|
@@ -4146,8 +4160,8 @@ class xe extends ve {
|
|
|
4146
4160
|
*
|
|
4147
4161
|
* @param allowArrays - Whether the query value is an array that may directly
|
|
4148
4162
|
* contain additional arrays (e.g. the operand of an `in` query).
|
|
4149
|
-
*/ function
|
|
4150
|
-
return
|
|
4163
|
+
*/ function Ue(t, n, e, r = !1) {
|
|
4164
|
+
return je(e, t.ht(r ? 4 /* ArrayArgument */ : 3 /* Argument */ , n));
|
|
4151
4165
|
}
|
|
4152
4166
|
|
|
4153
4167
|
/**
|
|
@@ -4158,12 +4172,12 @@ class xe extends ve {
|
|
|
4158
4172
|
* the source of the data being parsed, etc.
|
|
4159
4173
|
* @returns The parsed value, or null if the value was a FieldValue sentinel
|
|
4160
4174
|
* that should not be included in the resulting parsed data.
|
|
4161
|
-
*/ function
|
|
4162
|
-
if (
|
|
4175
|
+
*/ function je(t, n) {
|
|
4176
|
+
if (Be(
|
|
4163
4177
|
// Unwrap the API type from the Compat SDK. This will return the API type
|
|
4164
4178
|
// from firestore-exp.
|
|
4165
|
-
t = h(t))) return
|
|
4166
|
-
if (t instanceof
|
|
4179
|
+
t = h(t))) return ze("Unsupported field value:", n, t), Me(t, n);
|
|
4180
|
+
if (t instanceof Ee)
|
|
4167
4181
|
// FieldValues usually parse into transforms (except FieldValue.delete())
|
|
4168
4182
|
// in which case we do not want to include this field in our parsed data
|
|
4169
4183
|
// (as doing so will overwrite the field directly prior to the transform
|
|
@@ -4175,8 +4189,8 @@ class xe extends ve {
|
|
|
4175
4189
|
*/
|
|
4176
4190
|
return function(t, n) {
|
|
4177
4191
|
// Sentinels are only supported with writes, and not within arrays.
|
|
4178
|
-
if (!
|
|
4179
|
-
if (!n.path) throw n.
|
|
4192
|
+
if (!Re(n.tt)) throw n.ut(`${t._methodName}() can only be used with update() and set()`);
|
|
4193
|
+
if (!n.path) throw n.ut(`${t._methodName}() is not currently supported inside arrays`);
|
|
4180
4194
|
const e = t._toFieldTransform(n);
|
|
4181
4195
|
e && n.fieldTransforms.push(e);
|
|
4182
4196
|
}
|
|
@@ -4200,12 +4214,12 @@ class xe extends ve {
|
|
|
4200
4214
|
// the set of values to be included for the IN query) that may directly
|
|
4201
4215
|
// contain additional arrays (each representing an individual field
|
|
4202
4216
|
// value), so we disable this validation.
|
|
4203
|
-
if (n.settings.
|
|
4217
|
+
if (n.settings.rt && 4 /* ArrayArgument */ !== n.tt) throw n.ut("Nested arrays are not supported");
|
|
4204
4218
|
return function(t, n) {
|
|
4205
4219
|
const e = [];
|
|
4206
4220
|
let r = 0;
|
|
4207
4221
|
for (const s of t) {
|
|
4208
|
-
let t =
|
|
4222
|
+
let t = je(s, n.ot(r));
|
|
4209
4223
|
null == t && (
|
|
4210
4224
|
// Just include nulls in the array for fields being replaced with a
|
|
4211
4225
|
// sentinel.
|
|
@@ -4224,7 +4238,7 @@ class xe extends ve {
|
|
|
4224
4238
|
if (null === (t = h(t))) return {
|
|
4225
4239
|
nullValue: "NULL_VALUE"
|
|
4226
4240
|
};
|
|
4227
|
-
if ("number" == typeof t) return
|
|
4241
|
+
if ("number" == typeof t) return pn(n.q, t);
|
|
4228
4242
|
if ("boolean" == typeof t) return {
|
|
4229
4243
|
booleanValue: t
|
|
4230
4244
|
};
|
|
@@ -4232,37 +4246,37 @@ class xe extends ve {
|
|
|
4232
4246
|
stringValue: t
|
|
4233
4247
|
};
|
|
4234
4248
|
if (t instanceof Date) {
|
|
4235
|
-
const e =
|
|
4249
|
+
const e = gt.fromDate(t);
|
|
4236
4250
|
return {
|
|
4237
|
-
timestampValue:
|
|
4251
|
+
timestampValue: Fn(n.q, e)
|
|
4238
4252
|
};
|
|
4239
4253
|
}
|
|
4240
|
-
if (t instanceof
|
|
4254
|
+
if (t instanceof gt) {
|
|
4241
4255
|
// Firestore backend truncates precision down to microseconds. To ensure
|
|
4242
4256
|
// offline mode works the same with regards to truncation, perform the
|
|
4243
4257
|
// truncation immediately without waiting for the backend to do that.
|
|
4244
|
-
const e = new
|
|
4258
|
+
const e = new gt(t.seconds, 1e3 * Math.floor(t.nanoseconds / 1e3));
|
|
4245
4259
|
return {
|
|
4246
|
-
timestampValue:
|
|
4260
|
+
timestampValue: Fn(n.q, e)
|
|
4247
4261
|
};
|
|
4248
4262
|
}
|
|
4249
|
-
if (t instanceof
|
|
4263
|
+
if (t instanceof Te) return {
|
|
4250
4264
|
geoPointValue: {
|
|
4251
4265
|
latitude: t.latitude,
|
|
4252
4266
|
longitude: t.longitude
|
|
4253
4267
|
}
|
|
4254
4268
|
};
|
|
4255
|
-
if (t instanceof
|
|
4256
|
-
bytesValue:
|
|
4269
|
+
if (t instanceof be) return {
|
|
4270
|
+
bytesValue: Sn(n.q, t._byteString)
|
|
4257
4271
|
};
|
|
4258
|
-
if (t instanceof
|
|
4272
|
+
if (t instanceof le) {
|
|
4259
4273
|
const e = n.databaseId, r = t.firestore._databaseId;
|
|
4260
|
-
if (!r.isEqual(e)) throw n.
|
|
4274
|
+
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}`);
|
|
4261
4275
|
return {
|
|
4262
|
-
referenceValue:
|
|
4276
|
+
referenceValue: On(t.firestore._databaseId || n.databaseId, t._key.path)
|
|
4263
4277
|
};
|
|
4264
4278
|
}
|
|
4265
|
-
throw n.
|
|
4279
|
+
throw n.ut(`Unsupported field value: ${it(t)}`);
|
|
4266
4280
|
}
|
|
4267
4281
|
/**
|
|
4268
4282
|
* Checks whether an object looks like a JSON object that should be converted
|
|
@@ -4273,13 +4287,13 @@ class xe extends ve {
|
|
|
4273
4287
|
*/ (t, n);
|
|
4274
4288
|
}
|
|
4275
4289
|
|
|
4276
|
-
function
|
|
4290
|
+
function Me(t, n) {
|
|
4277
4291
|
const e = {};
|
|
4278
4292
|
return !function(t) {
|
|
4279
4293
|
for (const n in t) if (Object.prototype.hasOwnProperty.call(t, n)) return !1;
|
|
4280
4294
|
return !0;
|
|
4281
|
-
}(t) ?
|
|
4282
|
-
const s =
|
|
4295
|
+
}(t) ? Et(t, ((t, r) => {
|
|
4296
|
+
const s = je(r, n.et(t));
|
|
4283
4297
|
null != s && (e[t] = s);
|
|
4284
4298
|
})) :
|
|
4285
4299
|
// If we encounter an empty object, we explicitly add it to the update
|
|
@@ -4291,35 +4305,35 @@ function je(t, n) {
|
|
|
4291
4305
|
};
|
|
4292
4306
|
}
|
|
4293
4307
|
|
|
4294
|
-
function
|
|
4295
|
-
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof
|
|
4308
|
+
function Be(t) {
|
|
4309
|
+
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof gt || t instanceof Te || t instanceof be || t instanceof le || t instanceof Ee);
|
|
4296
4310
|
}
|
|
4297
4311
|
|
|
4298
|
-
function
|
|
4299
|
-
if (!
|
|
4312
|
+
function ze(t, n, e) {
|
|
4313
|
+
if (!Be(e) || !function(t) {
|
|
4300
4314
|
return "object" == typeof t && null !== t && (Object.getPrototypeOf(t) === Object.prototype || null === Object.getPrototypeOf(t));
|
|
4301
4315
|
}(e)) {
|
|
4302
|
-
const r =
|
|
4303
|
-
throw "an object" === r ? n.
|
|
4316
|
+
const r = it(e);
|
|
4317
|
+
throw "an object" === r ? n.ut(t + " a custom object") : n.ut(t + " " + r);
|
|
4304
4318
|
}
|
|
4305
4319
|
}
|
|
4306
4320
|
|
|
4307
4321
|
/**
|
|
4308
4322
|
* Helper that calls fromDotSeparatedString() but wraps any error thrown.
|
|
4309
|
-
*/ function
|
|
4323
|
+
*/ function Qe(t, n, e) {
|
|
4310
4324
|
if ((
|
|
4311
4325
|
// If required, replace the FieldPath Compat class with with the firestore-exp
|
|
4312
4326
|
// FieldPath.
|
|
4313
|
-
n = h(n)) instanceof
|
|
4314
|
-
if ("string" == typeof n) return
|
|
4315
|
-
throw
|
|
4327
|
+
n = h(n)) instanceof ge) return n._internalPath;
|
|
4328
|
+
if ("string" == typeof n) return We(t, n);
|
|
4329
|
+
throw Ye("Field path arguments must be of type string or FieldPath.", t,
|
|
4316
4330
|
/* hasConverter= */ !1,
|
|
4317
4331
|
/* path= */ void 0, e);
|
|
4318
4332
|
}
|
|
4319
4333
|
|
|
4320
4334
|
/**
|
|
4321
4335
|
* Matches any characters in a field path string that are reserved.
|
|
4322
|
-
*/ const
|
|
4336
|
+
*/ const Ge = new RegExp("[~\\*/\\[\\]]");
|
|
4323
4337
|
|
|
4324
4338
|
/**
|
|
4325
4339
|
* Wraps fromDotSeparatedString with an error message about the method that
|
|
@@ -4329,29 +4343,29 @@ function Me(t, n, e) {
|
|
|
4329
4343
|
* split on dots.
|
|
4330
4344
|
* @param targetDoc - The document against which the field path will be
|
|
4331
4345
|
* evaluated.
|
|
4332
|
-
*/ function
|
|
4333
|
-
if (n.search(
|
|
4346
|
+
*/ function We(t, n, e) {
|
|
4347
|
+
if (n.search(Ge) >= 0) throw Ye(`Invalid field path (${n}). Paths must not contain '~', '*', '/', '[', or ']'`, t,
|
|
4334
4348
|
/* hasConverter= */ !1,
|
|
4335
4349
|
/* path= */ void 0, e);
|
|
4336
4350
|
try {
|
|
4337
|
-
return new
|
|
4351
|
+
return new ge(...n.split("."))._internalPath;
|
|
4338
4352
|
} catch (r) {
|
|
4339
|
-
throw
|
|
4353
|
+
throw Ye(`Invalid field path (${n}). Paths must not be empty, begin with '.', end with '.', or contain '..'`, t,
|
|
4340
4354
|
/* hasConverter= */ !1,
|
|
4341
4355
|
/* path= */ void 0, e);
|
|
4342
4356
|
}
|
|
4343
4357
|
}
|
|
4344
4358
|
|
|
4345
|
-
function
|
|
4359
|
+
function Ye(t, n, e, r, s) {
|
|
4346
4360
|
const i = r && !r.isEmpty(), o = void 0 !== s;
|
|
4347
4361
|
let u = `Function ${n}() called with invalid data`;
|
|
4348
4362
|
e && (u += " (via `toFirestore()`)"), u += ". ";
|
|
4349
4363
|
let c = "";
|
|
4350
4364
|
return (i || o) && (c += " (found", i && (c += ` in field ${r}`), o && (c += ` in document ${s}`),
|
|
4351
|
-
c += ")"), new
|
|
4365
|
+
c += ")"), new k(A, u + t + c);
|
|
4352
4366
|
}
|
|
4353
4367
|
|
|
4354
|
-
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function
|
|
4368
|
+
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function He(t, n) {
|
|
4355
4369
|
return t.some((t => t.isEqual(n)));
|
|
4356
4370
|
}
|
|
4357
4371
|
|
|
@@ -4379,7 +4393,7 @@ function We(t, n, e, r, s) {
|
|
|
4379
4393
|
* For a `DocumentSnapshot` that points to a non-existing document, any data
|
|
4380
4394
|
* access will return 'undefined'. You can use the `exists()` method to
|
|
4381
4395
|
* explicitly verify a document's existence.
|
|
4382
|
-
*/ class
|
|
4396
|
+
*/ class Ke {
|
|
4383
4397
|
// Note: This class is stripped down version of the DocumentSnapshot in
|
|
4384
4398
|
// the legacy SDK. The changes are:
|
|
4385
4399
|
// - No support for SnapshotMetadata.
|
|
@@ -4395,7 +4409,7 @@ function We(t, n, e, r, s) {
|
|
|
4395
4409
|
/**
|
|
4396
4410
|
* The `DocumentReference` for the document included in the `DocumentSnapshot`.
|
|
4397
4411
|
*/ get ref() {
|
|
4398
|
-
return new
|
|
4412
|
+
return new le(this._firestore, this._converter, this._key);
|
|
4399
4413
|
}
|
|
4400
4414
|
/**
|
|
4401
4415
|
* Signals whether or not the document at the snapshot's location exists.
|
|
@@ -4415,7 +4429,7 @@ function We(t, n, e, r, s) {
|
|
|
4415
4429
|
if (this._converter) {
|
|
4416
4430
|
// We only want to use the converter and create a new DocumentSnapshot
|
|
4417
4431
|
// if a converter has been provided.
|
|
4418
|
-
const t = new
|
|
4432
|
+
const t = new Je(this._firestore, this._userDataWriter, this._key, this._document,
|
|
4419
4433
|
/* converter= */ null);
|
|
4420
4434
|
return this._converter.fromFirestore(t);
|
|
4421
4435
|
}
|
|
@@ -4435,7 +4449,7 @@ function We(t, n, e, r, s) {
|
|
|
4435
4449
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4436
4450
|
get(t) {
|
|
4437
4451
|
if (this._document) {
|
|
4438
|
-
const n = this._document.data.field(
|
|
4452
|
+
const n = this._document.data.field(tr("DocumentSnapshot.get", t));
|
|
4439
4453
|
if (null !== n) return this._userDataWriter.convertValue(n);
|
|
4440
4454
|
}
|
|
4441
4455
|
}
|
|
@@ -4451,7 +4465,7 @@ function We(t, n, e, r, s) {
|
|
|
4451
4465
|
* `DocumentSnapshot`. Since query results contain only existing documents, the
|
|
4452
4466
|
* `exists` property will always be true and `data()` will never return
|
|
4453
4467
|
* 'undefined'.
|
|
4454
|
-
*/ class
|
|
4468
|
+
*/ class Je extends Ke {
|
|
4455
4469
|
/**
|
|
4456
4470
|
* Retrieves all fields in the document as an `Object`.
|
|
4457
4471
|
*
|
|
@@ -4469,7 +4483,7 @@ function We(t, n, e, r, s) {
|
|
|
4469
4483
|
* array via the `docs` property or enumerated using the `forEach` method. The
|
|
4470
4484
|
* number of documents can be determined via the `empty` and `size`
|
|
4471
4485
|
* properties.
|
|
4472
|
-
*/ class
|
|
4486
|
+
*/ class Xe {
|
|
4473
4487
|
/** @hideconstructor */
|
|
4474
4488
|
constructor(t, n) {
|
|
4475
4489
|
this._docs = n, this.query = t;
|
|
@@ -4500,14 +4514,14 @@ function We(t, n, e, r, s) {
|
|
|
4500
4514
|
* @param left - A snapshot to compare.
|
|
4501
4515
|
* @param right - A snapshot to compare.
|
|
4502
4516
|
* @returns true if the snapshots are equal.
|
|
4503
|
-
*/ function
|
|
4504
|
-
return t = h(t), n = h(n), t instanceof
|
|
4517
|
+
*/ function Ze(t, n) {
|
|
4518
|
+
return t = h(t), n = h(n), t instanceof Ke && n instanceof Ke ? 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 Xe && n instanceof Xe && (_e(t.query, n.query) && _t(t.docs, n.docs, Ze));
|
|
4505
4519
|
}
|
|
4506
4520
|
|
|
4507
4521
|
/**
|
|
4508
4522
|
* Helper that calls `fromDotSeparatedString()` but wraps any error thrown.
|
|
4509
|
-
*/ function
|
|
4510
|
-
return "string" == typeof n ?
|
|
4523
|
+
*/ function tr(t, n) {
|
|
4524
|
+
return "string" == typeof n ? We(t, n) : n instanceof ge ? n._internalPath : n._delegate._internalPath;
|
|
4511
4525
|
}
|
|
4512
4526
|
|
|
4513
4527
|
/**
|
|
@@ -4534,7 +4548,7 @@ function We(t, n, e, r, s) {
|
|
|
4534
4548
|
* can then be passed to {@link query} to create a new query instance that
|
|
4535
4549
|
* also contains this `QueryConstraint`.
|
|
4536
4550
|
*/
|
|
4537
|
-
class
|
|
4551
|
+
class nr {}
|
|
4538
4552
|
|
|
4539
4553
|
/**
|
|
4540
4554
|
* Creates a new immutable instance of {@link Query} that is extended to also include
|
|
@@ -4544,40 +4558,40 @@ class Xe {}
|
|
|
4544
4558
|
* @param queryConstraints - The list of {@link QueryConstraint}s to apply.
|
|
4545
4559
|
* @throws if any of the provided query constraints cannot be combined with the
|
|
4546
4560
|
* existing or new constraints.
|
|
4547
|
-
*/ function
|
|
4561
|
+
*/ function er(t, ...n) {
|
|
4548
4562
|
for (const e of n) t = e._apply(t);
|
|
4549
4563
|
return t;
|
|
4550
4564
|
}
|
|
4551
4565
|
|
|
4552
|
-
class
|
|
4566
|
+
class rr extends nr {
|
|
4553
4567
|
constructor(t, n, e) {
|
|
4554
|
-
super(), this.
|
|
4568
|
+
super(), this.dt = t, this.wt = n, this.yt = e, this.type = "where";
|
|
4555
4569
|
}
|
|
4556
4570
|
_apply(t) {
|
|
4557
|
-
const n =
|
|
4571
|
+
const n = De(t.firestore), e = function(t, n, e, r, s, i, o) {
|
|
4558
4572
|
let u;
|
|
4559
4573
|
if (s.isKeyField()) {
|
|
4560
|
-
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new
|
|
4574
|
+
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new k(A, `Invalid Query. You can't perform '${i}' queries on FieldPath.documentId().`);
|
|
4561
4575
|
if ("in" /* IN */ === i || "not-in" /* NOT_IN */ === i) {
|
|
4562
|
-
|
|
4576
|
+
_r(o, i);
|
|
4563
4577
|
const n = [];
|
|
4564
|
-
for (const e of o) n.push(
|
|
4578
|
+
for (const e of o) n.push(yr(r, t, e));
|
|
4565
4579
|
u = {
|
|
4566
4580
|
arrayValue: {
|
|
4567
4581
|
values: n
|
|
4568
4582
|
}
|
|
4569
4583
|
};
|
|
4570
|
-
} else u =
|
|
4571
|
-
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i ||
|
|
4572
|
-
u =
|
|
4584
|
+
} else u = yr(r, t, o);
|
|
4585
|
+
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i || _r(o, i),
|
|
4586
|
+
u = Ue(e, n, o,
|
|
4573
4587
|
/* allowArrays= */ "in" /* IN */ === i || "not-in" /* NOT_IN */ === i);
|
|
4574
|
-
const c =
|
|
4588
|
+
const c = Yt.create(s, i, u);
|
|
4575
4589
|
return function(t, n) {
|
|
4576
|
-
if (n.
|
|
4577
|
-
const e =
|
|
4578
|
-
if (null !== e && !e.isEqual(n.field)) throw new
|
|
4579
|
-
const r =
|
|
4580
|
-
null !== r &&
|
|
4590
|
+
if (n.D()) {
|
|
4591
|
+
const e = ln(t);
|
|
4592
|
+
if (null !== e && !e.isEqual(n.field)) throw new k(A, `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()}'`);
|
|
4593
|
+
const r = hn(t);
|
|
4594
|
+
null !== r && gr(t, n.field, r);
|
|
4581
4595
|
}
|
|
4582
4596
|
const e = function(t, n) {
|
|
4583
4597
|
for (const e of t.filters) if (n.indexOf(e.op) >= 0) return e.op;
|
|
@@ -4618,12 +4632,12 @@ class nr extends Xe {
|
|
|
4618
4632
|
}(n.op));
|
|
4619
4633
|
if (null !== e)
|
|
4620
4634
|
// Special case when it's a duplicate op to give a slightly clearer error message.
|
|
4621
|
-
throw e === n.op ? new
|
|
4635
|
+
throw e === n.op ? new k(A, `Invalid query. You cannot use more than one '${n.op.toString()}' filter.`) : new k(A, `Invalid query. You cannot use '${n.op.toString()}' filters with '${e.toString()}' filters.`);
|
|
4622
4636
|
}(t, c), c;
|
|
4623
|
-
}(t._query, "where", n, t.firestore._databaseId, this.
|
|
4624
|
-
return new
|
|
4637
|
+
}(t._query, "where", n, t.firestore._databaseId, this.dt, this.wt, this.yt);
|
|
4638
|
+
return new fe(t.firestore, t.converter, function(t, n) {
|
|
4625
4639
|
const e = t.filters.concat([ n ]);
|
|
4626
|
-
return new
|
|
4640
|
+
return new cn(t.path, t.collectionGroup, t.explicitOrderBy.slice(), e, t.limit, t.limitType, t.startAt, t.endAt);
|
|
4627
4641
|
}(t._query, e));
|
|
4628
4642
|
}
|
|
4629
4643
|
}
|
|
@@ -4638,25 +4652,25 @@ class nr extends Xe {
|
|
|
4638
4652
|
* "<=", "!=").
|
|
4639
4653
|
* @param value - The value for comparison
|
|
4640
4654
|
* @returns The created {@link Query}.
|
|
4641
|
-
*/ function
|
|
4642
|
-
const r = n, s =
|
|
4643
|
-
return new
|
|
4655
|
+
*/ function sr(t, n, e) {
|
|
4656
|
+
const r = n, s = tr("where", t);
|
|
4657
|
+
return new rr(s, r, e);
|
|
4644
4658
|
}
|
|
4645
4659
|
|
|
4646
|
-
class
|
|
4660
|
+
class ir extends nr {
|
|
4647
4661
|
constructor(t, n) {
|
|
4648
|
-
super(), this.
|
|
4662
|
+
super(), this.dt = t, this._t = n, this.type = "orderBy";
|
|
4649
4663
|
}
|
|
4650
4664
|
_apply(t) {
|
|
4651
4665
|
const n = function(t, n, e) {
|
|
4652
|
-
if (null !== t.startAt) throw new
|
|
4653
|
-
if (null !== t.endAt) throw new
|
|
4654
|
-
const r = new
|
|
4666
|
+
if (null !== t.startAt) throw new k(A, "Invalid query. You must not call startAt() or startAfter() before calling orderBy().");
|
|
4667
|
+
if (null !== t.endAt) throw new k(A, "Invalid query. You must not call endAt() or endBefore() before calling orderBy().");
|
|
4668
|
+
const r = new sn(n, e);
|
|
4655
4669
|
return function(t, n) {
|
|
4656
|
-
if (null ===
|
|
4670
|
+
if (null === hn(t)) {
|
|
4657
4671
|
// This is the first order by. It must match any inequality.
|
|
4658
|
-
const e =
|
|
4659
|
-
null !== e &&
|
|
4672
|
+
const e = ln(t);
|
|
4673
|
+
null !== e && gr(t, e, n.field);
|
|
4660
4674
|
}
|
|
4661
4675
|
}(t, r), r;
|
|
4662
4676
|
}
|
|
@@ -4670,11 +4684,11 @@ class rr extends Xe {
|
|
|
4670
4684
|
* Will throw if the document does not contain all fields of the order by
|
|
4671
4685
|
* of the query or if any of the fields in the order by are an uncommitted
|
|
4672
4686
|
* server timestamp.
|
|
4673
|
-
*/ (t._query, this.
|
|
4674
|
-
return new
|
|
4687
|
+
*/ (t._query, this.dt, this._t);
|
|
4688
|
+
return new fe(t.firestore, t.converter, function(t, n) {
|
|
4675
4689
|
// TODO(dimond): validate that orderBy does not list the same key twice.
|
|
4676
4690
|
const e = t.explicitOrderBy.concat([ n ]);
|
|
4677
|
-
return new
|
|
4691
|
+
return new cn(t.path, t.collectionGroup, e, t.filters.slice(), t.limit, t.limitType, t.startAt, t.endAt);
|
|
4678
4692
|
}(t._query, n));
|
|
4679
4693
|
}
|
|
4680
4694
|
}
|
|
@@ -4687,19 +4701,19 @@ class rr extends Xe {
|
|
|
4687
4701
|
* @param directionStr - Optional direction to sort by ('asc' or 'desc'). If
|
|
4688
4702
|
* not specified, order will be ascending.
|
|
4689
4703
|
* @returns The created {@link Query}.
|
|
4690
|
-
*/ function
|
|
4691
|
-
const e = n, r =
|
|
4692
|
-
return new
|
|
4704
|
+
*/ function or(t, n = "asc") {
|
|
4705
|
+
const e = n, r = tr("orderBy", t);
|
|
4706
|
+
return new ir(r, e);
|
|
4693
4707
|
}
|
|
4694
4708
|
|
|
4695
|
-
class
|
|
4709
|
+
class ur extends nr {
|
|
4696
4710
|
constructor(t, n, e) {
|
|
4697
|
-
super(), this.type = t, this.
|
|
4711
|
+
super(), this.type = t, this.gt = n, this.vt = e;
|
|
4698
4712
|
}
|
|
4699
4713
|
_apply(t) {
|
|
4700
|
-
return new
|
|
4701
|
-
return new
|
|
4702
|
-
}(t._query, this.
|
|
4714
|
+
return new fe(t.firestore, t.converter, function(t, n, e) {
|
|
4715
|
+
return new cn(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), n, e, t.startAt, t.endAt);
|
|
4716
|
+
}(t._query, this.gt, this.vt));
|
|
4703
4717
|
}
|
|
4704
4718
|
}
|
|
4705
4719
|
|
|
@@ -4708,8 +4722,8 @@ class ir extends Xe {
|
|
|
4708
4722
|
*
|
|
4709
4723
|
* @param limit - The maximum number of items to return.
|
|
4710
4724
|
* @returns The created {@link Query}.
|
|
4711
|
-
*/ function
|
|
4712
|
-
return
|
|
4725
|
+
*/ function cr(t) {
|
|
4726
|
+
return ut("limit", t), new ur("limit", t, "F" /* First */);
|
|
4713
4727
|
}
|
|
4714
4728
|
|
|
4715
4729
|
/**
|
|
@@ -4720,54 +4734,54 @@ class ir extends Xe {
|
|
|
4720
4734
|
*
|
|
4721
4735
|
* @param limit - The maximum number of items to return.
|
|
4722
4736
|
* @returns The created {@link Query}.
|
|
4723
|
-
*/ function
|
|
4724
|
-
return
|
|
4737
|
+
*/ function ar(t) {
|
|
4738
|
+
return ut("limitToLast", t), new ur("limitToLast", t, "L" /* Last */);
|
|
4725
4739
|
}
|
|
4726
4740
|
|
|
4727
|
-
class
|
|
4741
|
+
class hr extends nr {
|
|
4728
4742
|
constructor(t, n, e) {
|
|
4729
|
-
super(), this.type = t, this.
|
|
4743
|
+
super(), this.type = t, this.bt = n, this.Et = e;
|
|
4730
4744
|
}
|
|
4731
4745
|
_apply(t) {
|
|
4732
|
-
const n =
|
|
4733
|
-
return new
|
|
4734
|
-
return new
|
|
4746
|
+
const n = pr(t, this.type, this.bt, this.Et);
|
|
4747
|
+
return new fe(t.firestore, t.converter, function(t, n) {
|
|
4748
|
+
return new cn(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, n, t.endAt);
|
|
4735
4749
|
}(t._query, n));
|
|
4736
4750
|
}
|
|
4737
4751
|
}
|
|
4738
4752
|
|
|
4739
|
-
function
|
|
4740
|
-
return new
|
|
4753
|
+
function lr(...t) {
|
|
4754
|
+
return new hr("startAt", t, /*before=*/ !0);
|
|
4741
4755
|
}
|
|
4742
4756
|
|
|
4743
|
-
function
|
|
4744
|
-
return new
|
|
4757
|
+
function fr(...t) {
|
|
4758
|
+
return new hr("startAfter", t,
|
|
4745
4759
|
/*before=*/ !1);
|
|
4746
4760
|
}
|
|
4747
4761
|
|
|
4748
|
-
class
|
|
4762
|
+
class dr extends nr {
|
|
4749
4763
|
constructor(t, n, e) {
|
|
4750
|
-
super(), this.type = t, this.
|
|
4764
|
+
super(), this.type = t, this.bt = n, this.Et = e;
|
|
4751
4765
|
}
|
|
4752
4766
|
_apply(t) {
|
|
4753
|
-
const n =
|
|
4754
|
-
return new
|
|
4755
|
-
return new
|
|
4767
|
+
const n = pr(t, this.type, this.bt, this.Et);
|
|
4768
|
+
return new fe(t.firestore, t.converter, function(t, n) {
|
|
4769
|
+
return new cn(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, t.startAt, n);
|
|
4756
4770
|
}(t._query, n));
|
|
4757
4771
|
}
|
|
4758
4772
|
}
|
|
4759
4773
|
|
|
4760
|
-
function
|
|
4761
|
-
return new
|
|
4774
|
+
function wr(...t) {
|
|
4775
|
+
return new dr("endBefore", t, /*before=*/ !0);
|
|
4762
4776
|
}
|
|
4763
4777
|
|
|
4764
|
-
function
|
|
4765
|
-
return new
|
|
4778
|
+
function mr(...t) {
|
|
4779
|
+
return new dr("endAt", t, /*before=*/ !1);
|
|
4766
4780
|
}
|
|
4767
4781
|
|
|
4768
|
-
/** Helper function to create a bound from a document or fields */ function
|
|
4769
|
-
if (e[0] = h(e[0]), e[0] instanceof
|
|
4770
|
-
if (!r) throw new
|
|
4782
|
+
/** Helper function to create a bound from a document or fields */ function pr(t, n, e, r) {
|
|
4783
|
+
if (e[0] = h(e[0]), e[0] instanceof Ke) return function(t, n, e, r, s) {
|
|
4784
|
+
if (!r) throw new k(R, `Can't use a DocumentSnapshot that doesn't exist for ${e}().`);
|
|
4771
4785
|
const i = [];
|
|
4772
4786
|
// Because people expect to continue/end a query at the exact document
|
|
4773
4787
|
// provided, we need to use the implicit sort order rather than the explicit
|
|
@@ -4776,42 +4790,42 @@ function dr(...t) {
|
|
|
4776
4790
|
// the provided document. Without the key (by using the explicit sort
|
|
4777
4791
|
// orders), multiple documents could match the position, yielding duplicate
|
|
4778
4792
|
// results.
|
|
4779
|
-
for (const e of
|
|
4793
|
+
for (const e of dn(t)) if (e.field.isKeyField()) i.push(Lt(n, r.key)); else {
|
|
4780
4794
|
const t = r.data.field(e.field);
|
|
4781
|
-
if (
|
|
4795
|
+
if (Dt(t)) throw new k(A, '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.)');
|
|
4782
4796
|
if (null === t) {
|
|
4783
4797
|
const t = e.field.canonicalString();
|
|
4784
|
-
throw new
|
|
4798
|
+
throw new k(A, `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.`);
|
|
4785
4799
|
}
|
|
4786
4800
|
i.push(t);
|
|
4787
4801
|
}
|
|
4788
|
-
return new
|
|
4802
|
+
return new rn(i, s);
|
|
4789
4803
|
}
|
|
4790
4804
|
/**
|
|
4791
4805
|
* Converts a list of field values to a `Bound` for the given query.
|
|
4792
4806
|
*/ (t._query, t.firestore._databaseId, n, e[0]._document, r);
|
|
4793
4807
|
{
|
|
4794
|
-
const s =
|
|
4808
|
+
const s = De(t.firestore);
|
|
4795
4809
|
return function(t, n, e, r, s, i) {
|
|
4796
4810
|
// Use explicit order by's because it has to match the query the user made
|
|
4797
4811
|
const o = t.explicitOrderBy;
|
|
4798
|
-
if (s.length > o.length) throw new
|
|
4812
|
+
if (s.length > o.length) throw new k(A, `Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);
|
|
4799
4813
|
const u = [];
|
|
4800
4814
|
for (let i = 0; i < s.length; i++) {
|
|
4801
4815
|
const c = s[i];
|
|
4802
4816
|
if (o[i].field.isKeyField()) {
|
|
4803
|
-
if ("string" != typeof c) throw new
|
|
4804
|
-
if (!
|
|
4805
|
-
const e = t.path.child(
|
|
4806
|
-
if (!
|
|
4807
|
-
const s = new
|
|
4808
|
-
u.push(
|
|
4817
|
+
if ("string" != typeof c) throw new k(A, `Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);
|
|
4818
|
+
if (!fn(t) && -1 !== c.indexOf("/")) throw new k(A, `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.`);
|
|
4819
|
+
const e = t.path.child(X.fromString(c));
|
|
4820
|
+
if (!nt.isDocumentKey(e)) throw new k(A, `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.`);
|
|
4821
|
+
const s = new nt(e);
|
|
4822
|
+
u.push(Lt(n, s));
|
|
4809
4823
|
} else {
|
|
4810
|
-
const t =
|
|
4824
|
+
const t = Ue(e, r, c);
|
|
4811
4825
|
u.push(t);
|
|
4812
4826
|
}
|
|
4813
4827
|
}
|
|
4814
|
-
return new
|
|
4828
|
+
return new rn(u, i);
|
|
4815
4829
|
}
|
|
4816
4830
|
/**
|
|
4817
4831
|
* Parses the given `documentIdValue` into a `ReferenceValue`, throwing
|
|
@@ -4821,28 +4835,28 @@ function dr(...t) {
|
|
|
4821
4835
|
}
|
|
4822
4836
|
}
|
|
4823
4837
|
|
|
4824
|
-
function
|
|
4838
|
+
function yr(t, n, e) {
|
|
4825
4839
|
if ("string" == typeof (e = h(e))) {
|
|
4826
|
-
if ("" === e) throw new
|
|
4827
|
-
if (!
|
|
4828
|
-
const r = n.path.child(
|
|
4829
|
-
if (!
|
|
4830
|
-
return
|
|
4840
|
+
if ("" === e) throw new k(A, "Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.");
|
|
4841
|
+
if (!fn(n) && -1 !== e.indexOf("/")) throw new k(A, `Invalid query. When querying a collection by FieldPath.documentId(), you must provide a plain document ID, but '${e}' contains a '/' character.`);
|
|
4842
|
+
const r = n.path.child(X.fromString(e));
|
|
4843
|
+
if (!nt.isDocumentKey(r)) throw new k(A, `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}).`);
|
|
4844
|
+
return Lt(t, new nt(r));
|
|
4831
4845
|
}
|
|
4832
|
-
if (e instanceof
|
|
4833
|
-
throw new
|
|
4846
|
+
if (e instanceof le) return Lt(t, e._key);
|
|
4847
|
+
throw new k(A, `Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: ${it(e)}.`);
|
|
4834
4848
|
}
|
|
4835
4849
|
|
|
4836
4850
|
/**
|
|
4837
4851
|
* Validates that the value passed into a disjunctive filter satisfies all
|
|
4838
4852
|
* array requirements.
|
|
4839
|
-
*/ function
|
|
4840
|
-
if (!Array.isArray(t) || 0 === t.length) throw new
|
|
4841
|
-
if (t.length > 10) throw new
|
|
4853
|
+
*/ function _r(t, n) {
|
|
4854
|
+
if (!Array.isArray(t) || 0 === t.length) throw new k(A, `Invalid Query. A non-empty array is required for '${n.toString()}' filters.`);
|
|
4855
|
+
if (t.length > 10) throw new k(A, `Invalid Query. '${n.toString()}' filters support a maximum of 10 elements in the value array.`);
|
|
4842
4856
|
}
|
|
4843
4857
|
|
|
4844
|
-
function
|
|
4845
|
-
if (!e.isEqual(n)) throw new
|
|
4858
|
+
function gr(t, n, e) {
|
|
4859
|
+
if (!e.isEqual(n)) throw new k(A, `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.`);
|
|
4846
4860
|
}
|
|
4847
4861
|
|
|
4848
4862
|
/**
|
|
@@ -4892,7 +4906,7 @@ function yr(t, n, e) {
|
|
|
4892
4906
|
* their `set()` or fails due to invalid data originating from a `toFirestore()`
|
|
4893
4907
|
* call.
|
|
4894
4908
|
*/
|
|
4895
|
-
function
|
|
4909
|
+
function vr(t, n, e) {
|
|
4896
4910
|
let r;
|
|
4897
4911
|
// Cast to `any` in order to satisfy the union type constraint on
|
|
4898
4912
|
// toFirestore().
|
|
@@ -4901,9 +4915,9 @@ function _r(t, n, e) {
|
|
|
4901
4915
|
r;
|
|
4902
4916
|
}
|
|
4903
4917
|
|
|
4904
|
-
class
|
|
4918
|
+
class br extends class {
|
|
4905
4919
|
convertValue(t, n = "none") {
|
|
4906
|
-
switch (
|
|
4920
|
+
switch (St(t)) {
|
|
4907
4921
|
case 0 /* NullValue */ :
|
|
4908
4922
|
return null;
|
|
4909
4923
|
|
|
@@ -4911,7 +4925,7 @@ class gr extends class {
|
|
|
4911
4925
|
return t.booleanValue;
|
|
4912
4926
|
|
|
4913
4927
|
case 2 /* NumberValue */ :
|
|
4914
|
-
return
|
|
4928
|
+
return Vt(t.integerValue || t.doubleValue);
|
|
4915
4929
|
|
|
4916
4930
|
case 3 /* TimestampValue */ :
|
|
4917
4931
|
return this.convertTimestamp(t.timestampValue);
|
|
@@ -4923,7 +4937,7 @@ class gr extends class {
|
|
|
4923
4937
|
return t.stringValue;
|
|
4924
4938
|
|
|
4925
4939
|
case 6 /* BlobValue */ :
|
|
4926
|
-
return this.convertBytes(
|
|
4940
|
+
return this.convertBytes(Nt(t.bytesValue));
|
|
4927
4941
|
|
|
4928
4942
|
case 7 /* RefValue */ :
|
|
4929
4943
|
return this.convertReference(t.referenceValue);
|
|
@@ -4943,12 +4957,12 @@ class gr extends class {
|
|
|
4943
4957
|
}
|
|
4944
4958
|
convertObject(t, n) {
|
|
4945
4959
|
const e = {};
|
|
4946
|
-
return
|
|
4960
|
+
return Et(t.fields, ((t, r) => {
|
|
4947
4961
|
e[t] = this.convertValue(r, n);
|
|
4948
4962
|
})), e;
|
|
4949
4963
|
}
|
|
4950
4964
|
convertGeoPoint(t) {
|
|
4951
|
-
return new
|
|
4965
|
+
return new Te(Vt(t.latitude), Vt(t.longitude));
|
|
4952
4966
|
}
|
|
4953
4967
|
convertArray(t, n) {
|
|
4954
4968
|
return (t.values || []).map((t => this.convertValue(t, n)));
|
|
@@ -4956,24 +4970,24 @@ class gr extends class {
|
|
|
4956
4970
|
convertServerTimestamp(t, n) {
|
|
4957
4971
|
switch (n) {
|
|
4958
4972
|
case "previous":
|
|
4959
|
-
const e =
|
|
4973
|
+
const e = $t(t);
|
|
4960
4974
|
return null == e ? null : this.convertValue(e, n);
|
|
4961
4975
|
|
|
4962
4976
|
case "estimate":
|
|
4963
|
-
return this.convertTimestamp(
|
|
4977
|
+
return this.convertTimestamp(Ft(t));
|
|
4964
4978
|
|
|
4965
4979
|
default:
|
|
4966
4980
|
return null;
|
|
4967
4981
|
}
|
|
4968
4982
|
}
|
|
4969
4983
|
convertTimestamp(t) {
|
|
4970
|
-
const n =
|
|
4971
|
-
return new
|
|
4984
|
+
const n = Rt(t);
|
|
4985
|
+
return new gt(n.seconds, n.nanos);
|
|
4972
4986
|
}
|
|
4973
4987
|
convertDocumentKey(t, n) {
|
|
4974
|
-
const e =
|
|
4975
|
-
v(
|
|
4976
|
-
const r = new
|
|
4988
|
+
const e = X.fromString(t);
|
|
4989
|
+
v(Kn(e));
|
|
4990
|
+
const r = new K(e.get(1), e.get(3)), s = new nt(e.popFirst(5));
|
|
4977
4991
|
return r.isEqual(n) ||
|
|
4978
4992
|
// TODO(b/64130202): Somehow support foreign references.
|
|
4979
4993
|
p(`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.`),
|
|
@@ -4984,11 +4998,11 @@ class gr extends class {
|
|
|
4984
4998
|
super(), this.firestore = t;
|
|
4985
4999
|
}
|
|
4986
5000
|
convertBytes(t) {
|
|
4987
|
-
return new
|
|
5001
|
+
return new be(t);
|
|
4988
5002
|
}
|
|
4989
5003
|
convertReference(t) {
|
|
4990
5004
|
const n = this.convertDocumentKey(t, this.firestore._databaseId);
|
|
4991
|
-
return new
|
|
5005
|
+
return new le(this.firestore, /* converter= */ null, n);
|
|
4992
5006
|
}
|
|
4993
5007
|
}
|
|
4994
5008
|
|
|
@@ -5004,12 +5018,12 @@ class gr extends class {
|
|
|
5004
5018
|
* @param reference - The reference of the document to fetch.
|
|
5005
5019
|
* @returns A Promise resolved with a `DocumentSnapshot` containing the current
|
|
5006
5020
|
* document contents.
|
|
5007
|
-
*/ function
|
|
5008
|
-
const n =
|
|
5009
|
-
return
|
|
5021
|
+
*/ function Er(t) {
|
|
5022
|
+
const n = se((t = ot(t, le)).firestore), e = new br(t.firestore);
|
|
5023
|
+
return ne(n, [ t._key ]).then((n => {
|
|
5010
5024
|
v(1 === n.length);
|
|
5011
5025
|
const r = n[0];
|
|
5012
|
-
return new
|
|
5026
|
+
return new Ke(t.firestore, e, t._key, r.isFoundDocument() ? r : null, t.converter);
|
|
5013
5027
|
}));
|
|
5014
5028
|
}
|
|
5015
5029
|
|
|
@@ -5024,33 +5038,33 @@ class gr extends class {
|
|
|
5024
5038
|
*
|
|
5025
5039
|
* @param query - The `Query` to execute.
|
|
5026
5040
|
* @returns A Promise that will be resolved with the results of the query.
|
|
5027
|
-
*/ function
|
|
5041
|
+
*/ function Tr(t) {
|
|
5028
5042
|
!function(t) {
|
|
5029
|
-
if (
|
|
5030
|
-
}((t =
|
|
5031
|
-
const n =
|
|
5032
|
-
return
|
|
5033
|
-
const r = n.map((n => new
|
|
5034
|
-
return
|
|
5043
|
+
if (an(t) && 0 === t.explicitOrderBy.length) throw new k(x, "limitToLast() queries require specifying at least one orderBy() clause");
|
|
5044
|
+
}((t = ot(t, fe))._query);
|
|
5045
|
+
const n = se(t.firestore), e = new br(t.firestore);
|
|
5046
|
+
return ee(n, t._query).then((n => {
|
|
5047
|
+
const r = n.map((n => new Je(t.firestore, e, n.key, n, t.converter)));
|
|
5048
|
+
return an(t._query) &&
|
|
5035
5049
|
// Limit to last queries reverse the orderBy constraint that was
|
|
5036
5050
|
// specified by the user. As such, we need to reverse the order of the
|
|
5037
5051
|
// results to return the documents in the expected order.
|
|
5038
|
-
r.reverse(), new
|
|
5052
|
+
r.reverse(), new Xe(t, r);
|
|
5039
5053
|
}));
|
|
5040
5054
|
}
|
|
5041
5055
|
|
|
5042
|
-
function
|
|
5043
|
-
const r =
|
|
5044
|
-
return
|
|
5056
|
+
function Ir(t, n, e) {
|
|
5057
|
+
const r = vr((t = ot(t, le)).converter, n, e), s = $e(De(t.firestore), "setDoc", t._key, r, null !== t.converter, e);
|
|
5058
|
+
return te(se(t.firestore), [ s.toMutation(t._key, Tn.none()) ]);
|
|
5045
5059
|
}
|
|
5046
5060
|
|
|
5047
|
-
function
|
|
5048
|
-
const s =
|
|
5061
|
+
function Ar(t, n, e, ...r) {
|
|
5062
|
+
const s = De((t = ot(t, le)).firestore);
|
|
5049
5063
|
// For Compat types, we have to "extract" the underlying types before
|
|
5050
5064
|
// performing validation.
|
|
5051
5065
|
let i;
|
|
5052
|
-
i = "string" == typeof (n = h(n)) || n instanceof
|
|
5053
|
-
return
|
|
5066
|
+
i = "string" == typeof (n = h(n)) || n instanceof ge ? ke(s, "updateDoc", t._key, n, e, r) : Le(s, "updateDoc", t._key, n);
|
|
5067
|
+
return te(se(t.firestore), [ i.toMutation(t._key, Tn.exists(!0)) ]);
|
|
5054
5068
|
}
|
|
5055
5069
|
|
|
5056
5070
|
/**
|
|
@@ -5064,8 +5078,8 @@ function Ir(t, n, e, ...r) {
|
|
|
5064
5078
|
* @param reference - A reference to the document to delete.
|
|
5065
5079
|
* @returns A `Promise` resolved once the document has been successfully
|
|
5066
5080
|
* deleted from the backend.
|
|
5067
|
-
*/ function
|
|
5068
|
-
return
|
|
5081
|
+
*/ function Pr(t) {
|
|
5082
|
+
return te(se((t = ot(t, le)).firestore), [ new Rn(t._key, Tn.none()) ]);
|
|
5069
5083
|
}
|
|
5070
5084
|
|
|
5071
5085
|
/**
|
|
@@ -5081,9 +5095,9 @@ function Ir(t, n, e, ...r) {
|
|
|
5081
5095
|
* @param data - An Object containing the data for the new document.
|
|
5082
5096
|
* @returns A `Promise` resolved with a `DocumentReference` pointing to the
|
|
5083
5097
|
* newly created document after it has been written to the backend.
|
|
5084
|
-
*/ function
|
|
5085
|
-
const e =
|
|
5086
|
-
return
|
|
5098
|
+
*/ function Rr(t, n) {
|
|
5099
|
+
const e = pe(t = ot(t, de)), r = vr(t.converter, n), s = $e(De(t.firestore), "addDoc", e._key, r, null !== e.converter, {});
|
|
5100
|
+
return te(se(t.firestore), [ s.toMutation(e._key, Tn.exists(!1)) ]).then((() => e));
|
|
5087
5101
|
}
|
|
5088
5102
|
|
|
5089
5103
|
/**
|
|
@@ -5105,15 +5119,15 @@ function Ir(t, n, e, ...r) {
|
|
|
5105
5119
|
/**
|
|
5106
5120
|
* Returns a sentinel for use with {@link @firebase/firestore/lite#(updateDoc:1)} or
|
|
5107
5121
|
* {@link @firebase/firestore/lite#(setDoc:1)} with `{merge: true}` to mark a field for deletion.
|
|
5108
|
-
*/ function
|
|
5109
|
-
return new
|
|
5122
|
+
*/ function Vr() {
|
|
5123
|
+
return new Fe("deleteField");
|
|
5110
5124
|
}
|
|
5111
5125
|
|
|
5112
5126
|
/**
|
|
5113
5127
|
* Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
|
|
5114
5128
|
* include a server-generated timestamp in the written data.
|
|
5115
|
-
*/ function
|
|
5116
|
-
return new
|
|
5129
|
+
*/ function Nr() {
|
|
5130
|
+
return new qe("serverTimestamp");
|
|
5117
5131
|
}
|
|
5118
5132
|
|
|
5119
5133
|
/**
|
|
@@ -5127,10 +5141,10 @@ function Ir(t, n, e, ...r) {
|
|
|
5127
5141
|
* @param elements - The elements to union into 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 xe("arrayUnion", t);
|
|
5134
5148
|
}
|
|
5135
5149
|
|
|
5136
5150
|
/**
|
|
@@ -5143,10 +5157,10 @@ function Ir(t, n, e, ...r) {
|
|
|
5143
5157
|
* @param elements - The elements to remove from the array.
|
|
5144
5158
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5145
5159
|
* `updateDoc()`
|
|
5146
|
-
*/ function
|
|
5160
|
+
*/ function $r(...t) {
|
|
5147
5161
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5148
5162
|
// update() since we'd need the Firestore instance to do this.
|
|
5149
|
-
return new
|
|
5163
|
+
return new Oe("arrayRemove", t);
|
|
5150
5164
|
}
|
|
5151
5165
|
|
|
5152
5166
|
/**
|
|
@@ -5167,8 +5181,8 @@ function Ir(t, n, e, ...r) {
|
|
|
5167
5181
|
* @param n - The value to increment by.
|
|
5168
5182
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5169
5183
|
* `updateDoc()`
|
|
5170
|
-
*/ function
|
|
5171
|
-
return new
|
|
5184
|
+
*/ function Fr(t) {
|
|
5185
|
+
return new Ce("increment", t);
|
|
5172
5186
|
}
|
|
5173
5187
|
|
|
5174
5188
|
/**
|
|
@@ -5194,25 +5208,25 @@ function Ir(t, n, e, ...r) {
|
|
|
5194
5208
|
* provides methods for adding writes to the write batch. None of the writes
|
|
5195
5209
|
* will be committed (or visible locally) until {@link WriteBatch.commit} is
|
|
5196
5210
|
* called.
|
|
5197
|
-
*/ class
|
|
5211
|
+
*/ class Sr {
|
|
5198
5212
|
/** @hideconstructor */
|
|
5199
5213
|
constructor(t, n) {
|
|
5200
5214
|
this._firestore = t, this._commitHandler = n, this._mutations = [], this._committed = !1,
|
|
5201
|
-
this._dataReader =
|
|
5215
|
+
this._dataReader = De(t);
|
|
5202
5216
|
}
|
|
5203
5217
|
set(t, n, e) {
|
|
5204
5218
|
this._verifyNotCommitted();
|
|
5205
|
-
const r =
|
|
5206
|
-
return this._mutations.push(i.toMutation(r._key,
|
|
5219
|
+
const r = qr(t, this._firestore), s = vr(r.converter, n, e), i = $e(this._dataReader, "WriteBatch.set", r._key, s, null !== r.converter, e);
|
|
5220
|
+
return this._mutations.push(i.toMutation(r._key, Tn.none())), this;
|
|
5207
5221
|
}
|
|
5208
5222
|
update(t, n, e, ...r) {
|
|
5209
5223
|
this._verifyNotCommitted();
|
|
5210
|
-
const s =
|
|
5224
|
+
const s = qr(t, this._firestore);
|
|
5211
5225
|
// For Compat types, we have to "extract" the underlying types before
|
|
5212
5226
|
// performing validation.
|
|
5213
5227
|
let i;
|
|
5214
|
-
return i = "string" == typeof (n = h(n)) || n instanceof
|
|
5215
|
-
this._mutations.push(i.toMutation(s._key,
|
|
5228
|
+
return i = "string" == typeof (n = h(n)) || n instanceof ge ? ke(this._dataReader, "WriteBatch.update", s._key, n, e, r) : Le(this._dataReader, "WriteBatch.update", s._key, n),
|
|
5229
|
+
this._mutations.push(i.toMutation(s._key, Tn.exists(!0))), this;
|
|
5216
5230
|
}
|
|
5217
5231
|
/**
|
|
5218
5232
|
* Deletes the document referred to by the provided {@link DocumentReference}.
|
|
@@ -5221,8 +5235,8 @@ function Ir(t, n, e, ...r) {
|
|
|
5221
5235
|
* @returns This `WriteBatch` instance. Used for chaining method calls.
|
|
5222
5236
|
*/ delete(t) {
|
|
5223
5237
|
this._verifyNotCommitted();
|
|
5224
|
-
const n =
|
|
5225
|
-
return this._mutations = this._mutations.concat(new
|
|
5238
|
+
const n = qr(t, this._firestore);
|
|
5239
|
+
return this._mutations = this._mutations.concat(new Rn(n._key, Tn.none())), this;
|
|
5226
5240
|
}
|
|
5227
5241
|
/**
|
|
5228
5242
|
* Commits all of the writes in this write batch as a single atomic unit.
|
|
@@ -5239,12 +5253,12 @@ function Ir(t, n, e, ...r) {
|
|
|
5239
5253
|
return this._verifyNotCommitted(), this._committed = !0, this._mutations.length > 0 ? this._commitHandler(this._mutations) : Promise.resolve();
|
|
5240
5254
|
}
|
|
5241
5255
|
_verifyNotCommitted() {
|
|
5242
|
-
if (this._committed) throw new
|
|
5256
|
+
if (this._committed) throw new k(F, "A write batch can no longer be used after commit() has been called.");
|
|
5243
5257
|
}
|
|
5244
5258
|
}
|
|
5245
5259
|
|
|
5246
|
-
function
|
|
5247
|
-
if ((t = h(t)).firestore !== n) throw new
|
|
5260
|
+
function qr(t, n) {
|
|
5261
|
+
if ((t = h(t)).firestore !== n) throw new k(A, "Provided document reference is from a different Firestore instance.");
|
|
5248
5262
|
return t;
|
|
5249
5263
|
}
|
|
5250
5264
|
|
|
@@ -5260,9 +5274,9 @@ function Fr(t, n) {
|
|
|
5260
5274
|
*
|
|
5261
5275
|
* @returns A `WriteBatch` that can be used to atomically execute multiple
|
|
5262
5276
|
* writes.
|
|
5263
|
-
*/ function
|
|
5264
|
-
const n =
|
|
5265
|
-
return new
|
|
5277
|
+
*/ function xr(t) {
|
|
5278
|
+
const n = se(t = ot(t, oe));
|
|
5279
|
+
return new Sr(t, (t => te(n, t)));
|
|
5266
5280
|
}
|
|
5267
5281
|
|
|
5268
5282
|
/**
|
|
@@ -5284,7 +5298,7 @@ function Fr(t, n) {
|
|
|
5284
5298
|
/**
|
|
5285
5299
|
* Internal transaction object responsible for accumulating the mutations to
|
|
5286
5300
|
* perform and the base versions for any documents read.
|
|
5287
|
-
*/ class
|
|
5301
|
+
*/ class Or {
|
|
5288
5302
|
constructor(t) {
|
|
5289
5303
|
this.datastore = t,
|
|
5290
5304
|
// The version of each document that was read during this transaction.
|
|
@@ -5303,8 +5317,8 @@ function Fr(t, n) {
|
|
|
5303
5317
|
this.writtenDocs = new Set;
|
|
5304
5318
|
}
|
|
5305
5319
|
async lookup(t) {
|
|
5306
|
-
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new
|
|
5307
|
-
const n = await
|
|
5320
|
+
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new k(A, "Firestore transactions require all reads to be executed before all writes.");
|
|
5321
|
+
const n = await ne(this.datastore, t);
|
|
5308
5322
|
return n.forEach((t => this.recordVersion(t))), n;
|
|
5309
5323
|
}
|
|
5310
5324
|
set(t, n) {
|
|
@@ -5319,7 +5333,7 @@ function Fr(t, n) {
|
|
|
5319
5333
|
this.writtenDocs.add(t.toString());
|
|
5320
5334
|
}
|
|
5321
5335
|
delete(t) {
|
|
5322
|
-
this.write(new
|
|
5336
|
+
this.write(new Rn(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5323
5337
|
}
|
|
5324
5338
|
async commit() {
|
|
5325
5339
|
if (this.ensureCommitNotCalled(), this.lastWriteError) throw this.lastWriteError;
|
|
@@ -5331,22 +5345,22 @@ function Fr(t, n) {
|
|
|
5331
5345
|
// For each document that was read but not written to, we want to perform
|
|
5332
5346
|
// a `verify` operation.
|
|
5333
5347
|
t.forEach(((t, n) => {
|
|
5334
|
-
const e =
|
|
5335
|
-
this.mutations.push(new
|
|
5336
|
-
})), await
|
|
5348
|
+
const e = nt.fromPath(n);
|
|
5349
|
+
this.mutations.push(new Vn(e, this.precondition(e)));
|
|
5350
|
+
})), await te(this.datastore, this.mutations), this.committed = !0;
|
|
5337
5351
|
}
|
|
5338
5352
|
recordVersion(t) {
|
|
5339
5353
|
let n;
|
|
5340
5354
|
if (t.isFoundDocument()) n = t.version; else {
|
|
5341
5355
|
if (!t.isNoDocument()) throw g();
|
|
5342
5356
|
// For deleted docs, we must use baseVersion 0 when we overwrite them.
|
|
5343
|
-
n =
|
|
5357
|
+
n = vt.min();
|
|
5344
5358
|
}
|
|
5345
5359
|
const e = this.readVersions.get(t.key.toString());
|
|
5346
5360
|
if (e) {
|
|
5347
5361
|
if (!n.isEqual(e))
|
|
5348
5362
|
// This transaction will fail no matter what.
|
|
5349
|
-
throw new
|
|
5363
|
+
throw new k(S, "Document version changed between two reads.");
|
|
5350
5364
|
} else this.readVersions.set(t.key.toString(), n);
|
|
5351
5365
|
}
|
|
5352
5366
|
/**
|
|
@@ -5354,7 +5368,7 @@ function Fr(t, n) {
|
|
|
5354
5368
|
* as a precondition, or no precondition if it was not read.
|
|
5355
5369
|
*/ precondition(t) {
|
|
5356
5370
|
const n = this.readVersions.get(t.toString());
|
|
5357
|
-
return !this.writtenDocs.has(t.toString()) && n ?
|
|
5371
|
+
return !this.writtenDocs.has(t.toString()) && n ? Tn.updateTime(n) : Tn.none();
|
|
5358
5372
|
}
|
|
5359
5373
|
/**
|
|
5360
5374
|
* Returns the precondition for a document if the operation is an update.
|
|
@@ -5363,7 +5377,7 @@ function Fr(t, n) {
|
|
|
5363
5377
|
// The first time a document is written, we want to take into account the
|
|
5364
5378
|
// read time and existence
|
|
5365
5379
|
if (!this.writtenDocs.has(t.toString()) && n) {
|
|
5366
|
-
if (n.isEqual(
|
|
5380
|
+
if (n.isEqual(vt.min()))
|
|
5367
5381
|
// The document doesn't exist, so fail the transaction.
|
|
5368
5382
|
// This has to be validated locally because you can't send a
|
|
5369
5383
|
// precondition that a document does not exist without changing the
|
|
@@ -5373,13 +5387,13 @@ function Fr(t, n) {
|
|
|
5373
5387
|
// express that to the backend, we have to validate locally.
|
|
5374
5388
|
// Note: this can change once we can send separate verify writes in the
|
|
5375
5389
|
// transaction.
|
|
5376
|
-
throw new
|
|
5390
|
+
throw new k(A, "Can't update a document that doesn't exist.");
|
|
5377
5391
|
// Document exists, base precondition on document update time.
|
|
5378
|
-
return
|
|
5392
|
+
return Tn.updateTime(n);
|
|
5379
5393
|
}
|
|
5380
5394
|
// Document was not read, so we just use the preconditions for a blind
|
|
5381
5395
|
// update.
|
|
5382
|
-
return
|
|
5396
|
+
return Tn.exists(!0);
|
|
5383
5397
|
}
|
|
5384
5398
|
write(t) {
|
|
5385
5399
|
this.ensureCommitNotCalled(), this.mutations.push(t);
|
|
@@ -5407,43 +5421,43 @@ function Fr(t, n) {
|
|
|
5407
5421
|
* TransactionRunner encapsulates the logic needed to run and retry transactions
|
|
5408
5422
|
* with backoff.
|
|
5409
5423
|
*/
|
|
5410
|
-
class
|
|
5424
|
+
class Cr {
|
|
5411
5425
|
constructor(t, n, e, r) {
|
|
5412
5426
|
this.asyncQueue = t, this.datastore = n, this.updateFunction = e, this.deferred = r,
|
|
5413
|
-
this.
|
|
5427
|
+
this.Tt = 5, this.It = new Xn(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
|
|
5414
5428
|
}
|
|
5415
5429
|
/** Runs the transaction and sets the result on deferred. */ run() {
|
|
5416
|
-
this.
|
|
5430
|
+
this.Tt -= 1, this.At();
|
|
5417
5431
|
}
|
|
5418
|
-
|
|
5432
|
+
At() {
|
|
5419
5433
|
this.It.W((async () => {
|
|
5420
|
-
const t = new
|
|
5434
|
+
const t = new Or(this.datastore), n = this.Pt(t);
|
|
5421
5435
|
n && n.then((n => {
|
|
5422
5436
|
this.asyncQueue.enqueueAndForget((() => t.commit().then((() => {
|
|
5423
5437
|
this.deferred.resolve(n);
|
|
5424
5438
|
})).catch((t => {
|
|
5425
|
-
this.
|
|
5439
|
+
this.Rt(t);
|
|
5426
5440
|
}))));
|
|
5427
5441
|
})).catch((t => {
|
|
5428
|
-
this.
|
|
5442
|
+
this.Rt(t);
|
|
5429
5443
|
}));
|
|
5430
5444
|
}));
|
|
5431
5445
|
}
|
|
5432
|
-
|
|
5446
|
+
Pt(t) {
|
|
5433
5447
|
try {
|
|
5434
5448
|
const n = this.updateFunction(t);
|
|
5435
|
-
return !
|
|
5449
|
+
return !ct(n) && n.catch && n.then ? n : (this.deferred.reject(Error("Transaction callback must return a Promise")),
|
|
5436
5450
|
null);
|
|
5437
5451
|
} catch (t) {
|
|
5438
5452
|
// Do not retry errors thrown by user provided updateFunction.
|
|
5439
5453
|
return this.deferred.reject(t), null;
|
|
5440
5454
|
}
|
|
5441
5455
|
}
|
|
5442
|
-
|
|
5443
|
-
this.
|
|
5456
|
+
Rt(t) {
|
|
5457
|
+
this.Tt > 0 && this.Vt(t) ? (this.Tt -= 1, this.asyncQueue.enqueueAndForget((() => (this.At(),
|
|
5444
5458
|
Promise.resolve())))) : this.deferred.reject(t);
|
|
5445
5459
|
}
|
|
5446
|
-
|
|
5460
|
+
Vt(t) {
|
|
5447
5461
|
if ("FirebaseError" === t.name) {
|
|
5448
5462
|
// In transactions, the backend will fail outdated reads with FAILED_PRECONDITION and
|
|
5449
5463
|
// non-matching document versions with ABORTED. These errors should be retried.
|
|
@@ -5460,8 +5474,8 @@ class xr {
|
|
|
5460
5474
|
default:
|
|
5461
5475
|
return g();
|
|
5462
5476
|
|
|
5463
|
-
case I:
|
|
5464
5477
|
case T:
|
|
5478
|
+
case I:
|
|
5465
5479
|
case P:
|
|
5466
5480
|
case $:
|
|
5467
5481
|
case O:
|
|
@@ -5507,7 +5521,7 @@ class xr {
|
|
|
5507
5521
|
* See the License for the specific language governing permissions and
|
|
5508
5522
|
* limitations under the License.
|
|
5509
5523
|
*/
|
|
5510
|
-
/** The Platform's 'document' implementation or null if not available. */ function
|
|
5524
|
+
/** The Platform's 'document' implementation or null if not available. */ function Lr() {
|
|
5511
5525
|
// `document` is not always available, e.g. in ReactNative and WebWorkers.
|
|
5512
5526
|
// eslint-disable-next-line no-restricted-globals
|
|
5513
5527
|
return "undefined" != typeof document ? document : null;
|
|
@@ -5539,10 +5553,10 @@ class xr {
|
|
|
5539
5553
|
* Note: We implement `PromiseLike` instead of `Promise`, as the `Promise` type
|
|
5540
5554
|
* in newer versions of TypeScript defines `finally`, which is not available in
|
|
5541
5555
|
* IE.
|
|
5542
|
-
*/ class
|
|
5556
|
+
*/ class kr {
|
|
5543
5557
|
constructor(t, n, e, r, s) {
|
|
5544
5558
|
this.asyncQueue = t, this.timerId = n, this.targetTimeMs = e, this.op = r, this.removalCallback = s,
|
|
5545
|
-
this.deferred = new
|
|
5559
|
+
this.deferred = new U, this.then = this.deferred.promise.then.bind(this.deferred.promise),
|
|
5546
5560
|
// It's normal for the deferred promise to be canceled (due to cancellation)
|
|
5547
5561
|
// and so we attach a dummy catch callback to avoid
|
|
5548
5562
|
// 'UnhandledPromiseRejectionWarning' log spam.
|
|
@@ -5562,7 +5576,7 @@ class xr {
|
|
|
5562
5576
|
* PORTING NOTE: This exists to prevent making removeDelayedOperation() and
|
|
5563
5577
|
* the DelayedOperation class public.
|
|
5564
5578
|
*/ static createAndSchedule(t, n, e, r, s) {
|
|
5565
|
-
const i = Date.now() + e, o = new
|
|
5579
|
+
const i = Date.now() + e, o = new kr(t, n, i, r, s);
|
|
5566
5580
|
return o.start(e), o;
|
|
5567
5581
|
}
|
|
5568
5582
|
/**
|
|
@@ -5584,7 +5598,7 @@ class xr {
|
|
|
5584
5598
|
* As long as the operation has not yet been run, calling cancel() provides a
|
|
5585
5599
|
* guarantee that the operation will not be run.
|
|
5586
5600
|
*/ cancel(t) {
|
|
5587
|
-
null !== this.timerHandle && (this.clearTimeout(), this.deferred.reject(new
|
|
5601
|
+
null !== this.timerHandle && (this.clearTimeout(), this.deferred.reject(new k(T, "Operation cancelled" + (t ? ": " + t : ""))));
|
|
5588
5602
|
}
|
|
5589
5603
|
handleDelayElapsed() {
|
|
5590
5604
|
this.asyncQueue.enqueueAndForget((() => null !== this.timerHandle ? (this.clearTimeout(),
|
|
@@ -5611,42 +5625,42 @@ class xr {
|
|
|
5611
5625
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5612
5626
|
* See the License for the specific language governing permissions and
|
|
5613
5627
|
* limitations under the License.
|
|
5614
|
-
*/ class
|
|
5628
|
+
*/ class Ur {
|
|
5615
5629
|
constructor() {
|
|
5616
5630
|
// The last promise in the queue.
|
|
5617
|
-
this.
|
|
5631
|
+
this.Nt = Promise.resolve(),
|
|
5618
5632
|
// A list of retryable operations. Retryable operations are run in order and
|
|
5619
5633
|
// retried with backoff.
|
|
5620
|
-
this.
|
|
5634
|
+
this.Dt = [],
|
|
5621
5635
|
// Is this AsyncQueue being shut down? Once it is set to true, it will not
|
|
5622
5636
|
// be changed again.
|
|
5623
|
-
this
|
|
5637
|
+
this.$t = !1,
|
|
5624
5638
|
// Operations scheduled to be queued in the future. Operations are
|
|
5625
5639
|
// automatically removed after they are run or canceled.
|
|
5626
|
-
this
|
|
5640
|
+
this.Ft = [],
|
|
5627
5641
|
// visible for testing
|
|
5628
|
-
this.
|
|
5642
|
+
this.St = null,
|
|
5629
5643
|
// Flag set while there's an outstanding AsyncQueue operation, used for
|
|
5630
5644
|
// assertion sanity-checks.
|
|
5631
|
-
this.St = !1,
|
|
5632
|
-
// Enabled during shutdown on Safari to prevent future access to IndexedDB.
|
|
5633
5645
|
this.qt = !1,
|
|
5646
|
+
// Enabled during shutdown on Safari to prevent future access to IndexedDB.
|
|
5647
|
+
this.xt = !1,
|
|
5634
5648
|
// List of TimerIds to fast-forward delays for.
|
|
5635
|
-
this.
|
|
5649
|
+
this.Ot = [],
|
|
5636
5650
|
// Backoff timer used to schedule retries for retryable operations
|
|
5637
|
-
this.It = new
|
|
5651
|
+
this.It = new Xn(this, "async_queue_retry" /* AsyncQueueRetry */),
|
|
5638
5652
|
// Visibility handler that triggers an immediate retry of all retryable
|
|
5639
5653
|
// operations. Meant to speed up recovery when we regain file system access
|
|
5640
5654
|
// after page comes into foreground.
|
|
5641
|
-
this.
|
|
5642
|
-
const t =
|
|
5655
|
+
this.Ct = () => {
|
|
5656
|
+
const t = Lr();
|
|
5643
5657
|
t && m("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.It.H();
|
|
5644
5658
|
};
|
|
5645
|
-
const t =
|
|
5646
|
-
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.
|
|
5659
|
+
const t = Lr();
|
|
5660
|
+
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.Ct);
|
|
5647
5661
|
}
|
|
5648
5662
|
get isShuttingDown() {
|
|
5649
|
-
return this
|
|
5663
|
+
return this.$t;
|
|
5650
5664
|
}
|
|
5651
5665
|
/**
|
|
5652
5666
|
* Adds a new operation to the queue without waiting for it to complete (i.e.
|
|
@@ -5656,38 +5670,38 @@ class xr {
|
|
|
5656
5670
|
this.enqueue(t);
|
|
5657
5671
|
}
|
|
5658
5672
|
enqueueAndForgetEvenWhileRestricted(t) {
|
|
5659
|
-
this.
|
|
5673
|
+
this.Lt(),
|
|
5660
5674
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
5661
|
-
this.
|
|
5675
|
+
this.kt(t);
|
|
5662
5676
|
}
|
|
5663
5677
|
enterRestrictedMode(t) {
|
|
5664
|
-
if (!this
|
|
5665
|
-
this
|
|
5666
|
-
const n =
|
|
5667
|
-
n && "function" == typeof n.removeEventListener && n.removeEventListener("visibilitychange", this.
|
|
5678
|
+
if (!this.$t) {
|
|
5679
|
+
this.$t = !0, this.xt = t || !1;
|
|
5680
|
+
const n = Lr();
|
|
5681
|
+
n && "function" == typeof n.removeEventListener && n.removeEventListener("visibilitychange", this.Ct);
|
|
5668
5682
|
}
|
|
5669
5683
|
}
|
|
5670
5684
|
enqueue(t) {
|
|
5671
|
-
if (this.
|
|
5685
|
+
if (this.Lt(), this.$t)
|
|
5672
5686
|
// Return a Promise which never resolves.
|
|
5673
5687
|
return new Promise((() => {}));
|
|
5674
5688
|
// Create a deferred Promise that we can return to the callee. This
|
|
5675
5689
|
// allows us to return a "hanging Promise" only to the callee and still
|
|
5676
5690
|
// advance the queue even when the operation is not run.
|
|
5677
|
-
const n = new
|
|
5678
|
-
return this.
|
|
5691
|
+
const n = new U;
|
|
5692
|
+
return this.kt((() => this.$t && this.xt ? Promise.resolve() : (t().then(n.resolve, n.reject),
|
|
5679
5693
|
n.promise))).then((() => n.promise));
|
|
5680
5694
|
}
|
|
5681
5695
|
enqueueRetryable(t) {
|
|
5682
|
-
this.enqueueAndForget((() => (this.
|
|
5696
|
+
this.enqueueAndForget((() => (this.Dt.push(t), this.Ut())));
|
|
5683
5697
|
}
|
|
5684
5698
|
/**
|
|
5685
5699
|
* Runs the next operation from the retryable queue. If the operation fails,
|
|
5686
5700
|
* reschedules with backoff.
|
|
5687
5701
|
*/ async Ut() {
|
|
5688
|
-
if (0 !== this.
|
|
5702
|
+
if (0 !== this.Dt.length) {
|
|
5689
5703
|
try {
|
|
5690
|
-
await this.
|
|
5704
|
+
await this.Dt[0](), this.Dt.shift(), this.It.reset();
|
|
5691
5705
|
} catch (t) {
|
|
5692
5706
|
if (!
|
|
5693
5707
|
/**
|
|
@@ -5731,7 +5745,7 @@ class xr {
|
|
|
5731
5745
|
// Failure will be handled by AsyncQueue
|
|
5732
5746
|
m("AsyncQueue", "Operation failed with retryable error: " + t);
|
|
5733
5747
|
}
|
|
5734
|
-
this.
|
|
5748
|
+
this.Dt.length > 0 &&
|
|
5735
5749
|
// If there are additional operations, we re-schedule `retryNextOp()`.
|
|
5736
5750
|
// This is necessary to run retryable operations that failed during
|
|
5737
5751
|
// their initial attempt since we don't know whether they are already
|
|
@@ -5745,9 +5759,9 @@ class xr {
|
|
|
5745
5759
|
this.It.W((() => this.Ut()));
|
|
5746
5760
|
}
|
|
5747
5761
|
}
|
|
5748
|
-
|
|
5749
|
-
const n = this.
|
|
5750
|
-
this.
|
|
5762
|
+
kt(t) {
|
|
5763
|
+
const n = this.Nt.then((() => (this.qt = !0, t().catch((t => {
|
|
5764
|
+
this.St = t, this.qt = !1;
|
|
5751
5765
|
const n =
|
|
5752
5766
|
/**
|
|
5753
5767
|
* Chrome includes Error.message in Error.stack. Other browsers do not.
|
|
@@ -5788,38 +5802,38 @@ class xr {
|
|
|
5788
5802
|
// all further attempts to chain (via .then) will just short-circuit
|
|
5789
5803
|
// and return the rejected Promise.
|
|
5790
5804
|
throw p("INTERNAL UNHANDLED ERROR: ", n), t;
|
|
5791
|
-
})).then((t => (this.
|
|
5792
|
-
return this.
|
|
5805
|
+
})).then((t => (this.qt = !1, t))))));
|
|
5806
|
+
return this.Nt = n, n;
|
|
5793
5807
|
}
|
|
5794
5808
|
enqueueAfterDelay(t, n, e) {
|
|
5795
|
-
this.
|
|
5809
|
+
this.Lt(),
|
|
5796
5810
|
// Fast-forward delays for timerIds that have been overriden.
|
|
5797
|
-
this.
|
|
5798
|
-
const r =
|
|
5799
|
-
return this
|
|
5811
|
+
this.Ot.indexOf(t) > -1 && (n = 0);
|
|
5812
|
+
const r = kr.createAndSchedule(this, t, n, e, (t => this.jt(t)));
|
|
5813
|
+
return this.Ft.push(r), r;
|
|
5800
5814
|
}
|
|
5801
|
-
|
|
5802
|
-
this.
|
|
5815
|
+
Lt() {
|
|
5816
|
+
this.St && g();
|
|
5803
5817
|
}
|
|
5804
5818
|
verifyOperationInProgress() {}
|
|
5805
5819
|
/**
|
|
5806
5820
|
* Waits until all currently queued tasks are finished executing. Delayed
|
|
5807
5821
|
* operations are not run.
|
|
5808
|
-
*/ async
|
|
5822
|
+
*/ async Mt() {
|
|
5809
5823
|
// Operations in the queue prior to draining may have enqueued additional
|
|
5810
5824
|
// operations. Keep draining the queue until the tail is no longer advanced,
|
|
5811
5825
|
// which indicates that no more new operations were enqueued and that all
|
|
5812
5826
|
// operations were executed.
|
|
5813
5827
|
let t;
|
|
5814
5828
|
do {
|
|
5815
|
-
t = this.
|
|
5816
|
-
} while (t !== this.
|
|
5829
|
+
t = this.Nt, await t;
|
|
5830
|
+
} while (t !== this.Nt);
|
|
5817
5831
|
}
|
|
5818
5832
|
/**
|
|
5819
5833
|
* For Tests: Determine if a delayed operation with a particular TimerId
|
|
5820
5834
|
* exists.
|
|
5821
|
-
*/
|
|
5822
|
-
for (const n of this
|
|
5835
|
+
*/ Bt(t) {
|
|
5836
|
+
for (const n of this.Ft) if (n.timerId === t) return !0;
|
|
5823
5837
|
return !1;
|
|
5824
5838
|
}
|
|
5825
5839
|
/**
|
|
@@ -5828,31 +5842,31 @@ class xr {
|
|
|
5828
5842
|
* @param lastTimerId - Delayed operations up to and including this TimerId
|
|
5829
5843
|
* will be drained. Pass TimerId.All to run all delayed operations.
|
|
5830
5844
|
* @returns a Promise that resolves once all operations have been run.
|
|
5831
|
-
*/
|
|
5845
|
+
*/ zt(t) {
|
|
5832
5846
|
// Note that draining may generate more delayed ops, so we do that first.
|
|
5833
|
-
return this.
|
|
5847
|
+
return this.Mt().then((() => {
|
|
5834
5848
|
// Run ops in the same order they'd run if they ran naturally.
|
|
5835
|
-
this
|
|
5836
|
-
for (const n of this
|
|
5837
|
-
return this.
|
|
5849
|
+
this.Ft.sort(((t, n) => t.targetTimeMs - n.targetTimeMs));
|
|
5850
|
+
for (const n of this.Ft) if (n.skipDelay(), "all" /* All */ !== t && n.timerId === t) break;
|
|
5851
|
+
return this.Mt();
|
|
5838
5852
|
}));
|
|
5839
5853
|
}
|
|
5840
5854
|
/**
|
|
5841
5855
|
* For Tests: Skip all subsequent delays for a timer id.
|
|
5842
5856
|
*/ Qt(t) {
|
|
5843
|
-
this.
|
|
5857
|
+
this.Ot.push(t);
|
|
5844
5858
|
}
|
|
5845
5859
|
/** Called once a DelayedOperation is run or canceled. */ jt(t) {
|
|
5846
5860
|
// NOTE: indexOf / slice are O(n), but delayedOperations is expected to be small.
|
|
5847
|
-
const n = this
|
|
5848
|
-
this
|
|
5861
|
+
const n = this.Ft.indexOf(t);
|
|
5862
|
+
this.Ft.splice(n, 1);
|
|
5849
5863
|
}
|
|
5850
5864
|
}
|
|
5851
5865
|
|
|
5852
|
-
class
|
|
5866
|
+
class jr {
|
|
5853
5867
|
/** @hideconstructor */
|
|
5854
5868
|
constructor(t, n) {
|
|
5855
|
-
this._firestore = t, this._transaction = n, this._dataReader =
|
|
5869
|
+
this._firestore = t, this._transaction = n, this._dataReader = De(t);
|
|
5856
5870
|
}
|
|
5857
5871
|
/**
|
|
5858
5872
|
* Reads the document referenced by the provided {@link DocumentReference}.
|
|
@@ -5860,25 +5874,25 @@ class Ur {
|
|
|
5860
5874
|
* @param documentRef - A reference to the document to be read.
|
|
5861
5875
|
* @returns A `DocumentSnapshot` with the read data.
|
|
5862
5876
|
*/ get(t) {
|
|
5863
|
-
const n =
|
|
5877
|
+
const n = qr(t, this._firestore), e = new br(this._firestore);
|
|
5864
5878
|
return this._transaction.lookup([ n._key ]).then((t => {
|
|
5865
5879
|
if (!t || 1 !== t.length) return g();
|
|
5866
5880
|
const r = t[0];
|
|
5867
|
-
if (r.isFoundDocument()) return new
|
|
5868
|
-
if (r.isNoDocument()) return new
|
|
5881
|
+
if (r.isFoundDocument()) return new Ke(this._firestore, e, r.key, r, n.converter);
|
|
5882
|
+
if (r.isNoDocument()) return new Ke(this._firestore, e, n._key, null, n.converter);
|
|
5869
5883
|
throw g();
|
|
5870
5884
|
}));
|
|
5871
5885
|
}
|
|
5872
5886
|
set(t, n, e) {
|
|
5873
|
-
const r =
|
|
5887
|
+
const r = qr(t, this._firestore), s = vr(r.converter, n, e), i = $e(this._dataReader, "Transaction.set", r._key, s, null !== r.converter, e);
|
|
5874
5888
|
return this._transaction.set(r._key, i), this;
|
|
5875
5889
|
}
|
|
5876
5890
|
update(t, n, e, ...r) {
|
|
5877
|
-
const s =
|
|
5891
|
+
const s = qr(t, this._firestore);
|
|
5878
5892
|
// For Compat types, we have to "extract" the underlying types before
|
|
5879
5893
|
// performing validation.
|
|
5880
5894
|
let i;
|
|
5881
|
-
return i = "string" == typeof (n = h(n)) || n instanceof
|
|
5895
|
+
return i = "string" == typeof (n = h(n)) || n instanceof ge ? ke(this._dataReader, "Transaction.update", s._key, n, e, r) : Le(this._dataReader, "Transaction.update", s._key, n),
|
|
5882
5896
|
this._transaction.update(s._key, i), this;
|
|
5883
5897
|
}
|
|
5884
5898
|
/**
|
|
@@ -5887,7 +5901,7 @@ class Ur {
|
|
|
5887
5901
|
* @param documentRef - A reference to the document to be deleted.
|
|
5888
5902
|
* @returns This `Transaction` instance. Used for chaining method calls.
|
|
5889
5903
|
*/ delete(t) {
|
|
5890
|
-
const n =
|
|
5904
|
+
const n = qr(t, this._firestore);
|
|
5891
5905
|
return this._transaction.delete(n._key), this;
|
|
5892
5906
|
}
|
|
5893
5907
|
}
|
|
@@ -5908,9 +5922,9 @@ class Ur {
|
|
|
5908
5922
|
* (the `updateFunction` returned a failed promise), the promise returned by the
|
|
5909
5923
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
5910
5924
|
* rejected promise with the corresponding failure error is returned.
|
|
5911
|
-
*/ function
|
|
5912
|
-
const e =
|
|
5913
|
-
return new
|
|
5925
|
+
*/ function Mr(t, n) {
|
|
5926
|
+
const e = se(t = ot(t, oe)), r = new U;
|
|
5927
|
+
return new Cr(new Ur, e, (e => n(new jr(t, e))), r).run(), r.promise;
|
|
5914
5928
|
}
|
|
5915
5929
|
|
|
5916
5930
|
/**
|
|
@@ -5923,11 +5937,11 @@ class Ur {
|
|
|
5923
5937
|
*/ !function(t) {
|
|
5924
5938
|
f = t;
|
|
5925
5939
|
}(`${s}_lite`), e(new i("firestore/lite", ((t, {options: n}) => {
|
|
5926
|
-
const e = t.getProvider("app").getImmediate(), r = new
|
|
5940
|
+
const e = t.getProvider("app").getImmediate(), r = new oe(e, new z(t.getProvider("auth-internal")), new Y(t.getProvider("app-check-internal")));
|
|
5927
5941
|
return n && r._setSettings(n), r;
|
|
5928
5942
|
}), "PUBLIC" /* PUBLIC */)),
|
|
5929
5943
|
// RUNTIME_ENV and BUILD_TARGET are replaced by real values during the compilation
|
|
5930
|
-
r("firestore-lite", "3.3.
|
|
5944
|
+
r("firestore-lite", "3.3.1-canary.086df7c7e", "rn"), r("firestore-lite", "3.3.1-canary.086df7c7e", "esm2017");
|
|
5931
5945
|
|
|
5932
|
-
export {
|
|
5946
|
+
export { be as Bytes, de as CollectionReference, le as DocumentReference, Ke as DocumentSnapshot, ge as FieldPath, Ee as FieldValue, oe as Firestore, k as FirestoreError, Te as GeoPoint, fe as Query, nr as QueryConstraint, Je as QueryDocumentSnapshot, Xe as QuerySnapshot, gt as Timestamp, jr as Transaction, Sr as WriteBatch, Rr as addDoc, $r as arrayRemove, Dr as arrayUnion, we as collection, me as collectionGroup, ae as connectFirestoreEmulator, Pr as deleteDoc, Vr as deleteField, pe as doc, ve as documentId, mr as endAt, wr as endBefore, Er as getDoc, Tr as getDocs, ce as getFirestore, Fr as increment, ue as initializeFirestore, cr as limit, ar as limitToLast, or as orderBy, er as query, _e as queryEqual, ye as refEqual, Mr as runTransaction, Nr as serverTimestamp, Ir as setDoc, w as setLogLevel, Ze as snapshotEqual, fr as startAfter, lr as startAt, he as terminate, Ar as updateDoc, sr as where, xr as writeBatch };
|
|
5933
5947
|
//# sourceMappingURL=index.rn.esm2017.js.map
|