@firebase/firestore 3.4.7-canary.e9e5f6b3c → 3.4.8
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 +10 -0
- package/dist/firestore/src/local/indexeddb_remote_document_cache.d.ts +9 -0
- package/dist/firestore/src/local/simple_db.d.ts +2 -0
- package/dist/firestore/test/unit/local/test_remote_document_cache.d.ts +0 -4
- package/dist/index.esm2017.js +153 -146
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +69 -65
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +26 -9
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +26 -9
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +14 -7
- package/dist/index.rn.js.map +1 -1
- package/dist/lite/firestore/src/local/indexeddb_remote_document_cache.d.ts +9 -0
- package/dist/lite/firestore/src/local/simple_db.d.ts +2 -0
- package/dist/lite/firestore/test/unit/local/test_remote_document_cache.d.ts +0 -4
- package/dist/lite/index.browser.esm2017.js +73 -73
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +8 -8
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.node.cjs.js +2 -2
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +2 -2
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +1112 -1112
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +18 -18
- package/dist/lite/packages/firestore/src/local/indexeddb_remote_document_cache.d.ts +9 -0
- package/dist/lite/packages/firestore/src/local/simple_db.d.ts +2 -0
- package/dist/lite/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +0 -4
- package/dist/packages/firestore/dist/index.esm2017.d.ts +8 -8
- package/dist/packages/firestore/src/local/indexeddb_remote_document_cache.d.ts +9 -0
- package/dist/packages/firestore/src/local/simple_db.d.ts +2 -0
- package/dist/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +0 -4
- package/package.json +9 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _getProvider, getApp as t, _removeServiceInstance as
|
|
1
|
+
import { _getProvider, getApp as t, _removeServiceInstance as n, _registerComponent as e, registerVersion as r, SDK_VERSION as s } from "@firebase/app";
|
|
2
2
|
|
|
3
3
|
import { Component as i } from "@firebase/component";
|
|
4
4
|
|
|
@@ -66,7 +66,7 @@ f.MOCK_USER = new f("mock-user");
|
|
|
66
66
|
* See the License for the specific language governing permissions and
|
|
67
67
|
* limitations under the License.
|
|
68
68
|
*/
|
|
69
|
-
let d = "9.6.
|
|
69
|
+
let d = "9.6.11";
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* @license
|
|
@@ -102,26 +102,26 @@ const w = new o("@firebase/firestore");
|
|
|
102
102
|
w.setLogLevel(t);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
function p(t, ...
|
|
105
|
+
function p(t, ...n) {
|
|
106
106
|
if (w.logLevel <= u.DEBUG) {
|
|
107
|
-
const
|
|
108
|
-
w.debug(`Firestore (${d}): ${t}`, ...
|
|
107
|
+
const e = n.map(g);
|
|
108
|
+
w.debug(`Firestore (${d}): ${t}`, ...e);
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
function y(t, ...
|
|
112
|
+
function y(t, ...n) {
|
|
113
113
|
if (w.logLevel <= u.ERROR) {
|
|
114
|
-
const
|
|
115
|
-
w.error(`Firestore (${d}): ${t}`, ...
|
|
114
|
+
const e = n.map(g);
|
|
115
|
+
w.error(`Firestore (${d}): ${t}`, ...e);
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
120
|
* @internal
|
|
121
|
-
*/ function _(t, ...
|
|
121
|
+
*/ function _(t, ...n) {
|
|
122
122
|
if (w.logLevel <= u.WARN) {
|
|
123
|
-
const
|
|
124
|
-
w.warn(`Firestore (${d}): ${t}`, ...
|
|
123
|
+
const e = n.map(g);
|
|
124
|
+
w.warn(`Firestore (${d}): ${t}`, ...e);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|
|
@@ -130,8 +130,8 @@ function y(t, ...e) {
|
|
|
130
130
|
*/ function g(t) {
|
|
131
131
|
if ("string" == typeof t) return t;
|
|
132
132
|
try {
|
|
133
|
-
return
|
|
134
|
-
} catch (
|
|
133
|
+
return n = t, JSON.stringify(n);
|
|
134
|
+
} catch (n) {
|
|
135
135
|
// Converting to JSON failed, just log the object directly
|
|
136
136
|
return t;
|
|
137
137
|
}
|
|
@@ -152,7 +152,7 @@ function y(t, ...e) {
|
|
|
152
152
|
* limitations under the License.
|
|
153
153
|
*/
|
|
154
154
|
/** Formats an object as a JSON string, suitable for logging. */
|
|
155
|
-
var
|
|
155
|
+
var n;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
/**
|
|
@@ -181,11 +181,11 @@ function y(t, ...e) {
|
|
|
181
181
|
*/ function v(t = "Unexpected state") {
|
|
182
182
|
// Log the failure in addition to throw an exception, just in case the
|
|
183
183
|
// exception is swallowed.
|
|
184
|
-
const
|
|
184
|
+
const n = `FIRESTORE (${d}) INTERNAL ASSERTION FAILED: ` + t;
|
|
185
185
|
// NOTE: We don't use FirestoreError here because these are internal failures
|
|
186
186
|
// that cannot be handled by the user. (Also it would create a circular
|
|
187
187
|
// dependency between the error and assert modules which doesn't work.)
|
|
188
|
-
throw y(
|
|
188
|
+
throw y(n), new Error(n);
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
/**
|
|
@@ -193,7 +193,7 @@ function y(t, ...e) {
|
|
|
193
193
|
* given message if it did.
|
|
194
194
|
*
|
|
195
195
|
* Messages are stripped in production builds.
|
|
196
|
-
*/ function b(t,
|
|
196
|
+
*/ function b(t, n) {
|
|
197
197
|
t || v();
|
|
198
198
|
}
|
|
199
199
|
|
|
@@ -202,7 +202,7 @@ function y(t, ...e) {
|
|
|
202
202
|
* instance of `T` before casting.
|
|
203
203
|
*/ function E(t,
|
|
204
204
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
205
|
-
|
|
205
|
+
n) {
|
|
206
206
|
return t;
|
|
207
207
|
}
|
|
208
208
|
|
|
@@ -233,8 +233,8 @@ e) {
|
|
|
233
233
|
/**
|
|
234
234
|
* A custom error description.
|
|
235
235
|
*/
|
|
236
|
-
|
|
237
|
-
super(t,
|
|
236
|
+
n) {
|
|
237
|
+
super(t, n), this.code = t, this.message = n,
|
|
238
238
|
// HACK: We write a toString property directly because Error is not a real
|
|
239
239
|
// class and so inheritance does not work correctly. We could alternatively
|
|
240
240
|
// do the same "back-door inheritance" trick that FirebaseError does.
|
|
@@ -259,8 +259,8 @@ e) {
|
|
|
259
259
|
* limitations under the License.
|
|
260
260
|
*/ class j {
|
|
261
261
|
constructor() {
|
|
262
|
-
this.promise = new Promise(((t,
|
|
263
|
-
this.resolve = t, this.reject =
|
|
262
|
+
this.promise = new Promise(((t, n) => {
|
|
263
|
+
this.resolve = t, this.reject = n;
|
|
264
264
|
}));
|
|
265
265
|
}
|
|
266
266
|
}
|
|
@@ -281,8 +281,8 @@ e) {
|
|
|
281
281
|
* See the License for the specific language governing permissions and
|
|
282
282
|
* limitations under the License.
|
|
283
283
|
*/ class M {
|
|
284
|
-
constructor(t,
|
|
285
|
-
this.user =
|
|
284
|
+
constructor(t, n) {
|
|
285
|
+
this.user = n, this.type = "OAuth", this.headers = new Map, this.headers.set("Authorization", `Bearer ${t}`);
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
|
|
@@ -294,9 +294,9 @@ e) {
|
|
|
294
294
|
return Promise.resolve(null);
|
|
295
295
|
}
|
|
296
296
|
invalidateToken() {}
|
|
297
|
-
start(t,
|
|
297
|
+
start(t, n) {
|
|
298
298
|
// Fire with initial user.
|
|
299
|
-
t.enqueueRetryable((() =>
|
|
299
|
+
t.enqueueRetryable((() => n(f.UNAUTHENTICATED)));
|
|
300
300
|
}
|
|
301
301
|
shutdown() {}
|
|
302
302
|
}
|
|
@@ -318,10 +318,10 @@ e) {
|
|
|
318
318
|
return Promise.resolve(this.token);
|
|
319
319
|
}
|
|
320
320
|
invalidateToken() {}
|
|
321
|
-
start(t,
|
|
322
|
-
this.changeListener =
|
|
321
|
+
start(t, n) {
|
|
322
|
+
this.changeListener = n,
|
|
323
323
|
// Fire with initial user.
|
|
324
|
-
t.enqueueRetryable((() =>
|
|
324
|
+
t.enqueueRetryable((() => n(this.token.user)));
|
|
325
325
|
}
|
|
326
326
|
shutdown() {
|
|
327
327
|
this.changeListener = null;
|
|
@@ -339,7 +339,7 @@ e) {
|
|
|
339
339
|
new M(t.accessToken, new f(this.auth.getUid()))) : null)) : Promise.resolve(null);
|
|
340
340
|
}
|
|
341
341
|
invalidateToken() {}
|
|
342
|
-
start(t,
|
|
342
|
+
start(t, n) {}
|
|
343
343
|
shutdown() {}
|
|
344
344
|
}
|
|
345
345
|
|
|
@@ -350,10 +350,10 @@ e) {
|
|
|
350
350
|
* recover from unauthenticated errors (see b/33147818 for context), but it's
|
|
351
351
|
* safer to keep the implementation as-is.
|
|
352
352
|
*/ class Q {
|
|
353
|
-
constructor(t,
|
|
354
|
-
this.type = "FirstParty", this.user = f.FIRST_PARTY, this.headers = new Map, this.headers.set("X-Goog-AuthUser",
|
|
353
|
+
constructor(t, n, e) {
|
|
354
|
+
this.type = "FirstParty", this.user = f.FIRST_PARTY, this.headers = new Map, this.headers.set("X-Goog-AuthUser", n);
|
|
355
355
|
const r = t.auth.getAuthHeaderValueForFirstParty([]);
|
|
356
|
-
r && this.headers.set("Authorization", r),
|
|
356
|
+
r && this.headers.set("Authorization", r), e && this.headers.set("X-Goog-Iam-Authorization-Token", e);
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
359
|
|
|
@@ -362,15 +362,15 @@ e) {
|
|
|
362
362
|
* to authenticate the user, using technique that is only available
|
|
363
363
|
* to applications hosted by Google.
|
|
364
364
|
*/ class W {
|
|
365
|
-
constructor(t,
|
|
366
|
-
this.t = t, this.i =
|
|
365
|
+
constructor(t, n, e) {
|
|
366
|
+
this.t = t, this.i = n, this.o = e;
|
|
367
367
|
}
|
|
368
368
|
getToken() {
|
|
369
369
|
return Promise.resolve(new Q(this.t, this.i, this.o));
|
|
370
370
|
}
|
|
371
|
-
start(t,
|
|
371
|
+
start(t, n) {
|
|
372
372
|
// Fire with initial uid.
|
|
373
|
-
t.enqueueRetryable((() =>
|
|
373
|
+
t.enqueueRetryable((() => n(f.FIRST_PARTY)));
|
|
374
374
|
}
|
|
375
375
|
shutdown() {}
|
|
376
376
|
invalidateToken() {}
|
|
@@ -393,7 +393,7 @@ class Y {
|
|
|
393
393
|
new Y(t.token)) : null)) : Promise.resolve(null);
|
|
394
394
|
}
|
|
395
395
|
invalidateToken() {}
|
|
396
|
-
start(t,
|
|
396
|
+
start(t, n) {}
|
|
397
397
|
shutdown() {}
|
|
398
398
|
}
|
|
399
399
|
|
|
@@ -435,8 +435,8 @@ class K {
|
|
|
435
435
|
* @param useFetchStreams Whether to use the Fetch API instead of
|
|
436
436
|
* XMLHTTPRequest
|
|
437
437
|
*/
|
|
438
|
-
constructor(t,
|
|
439
|
-
this.databaseId = t, this.appId =
|
|
438
|
+
constructor(t, n, e, r, s, i, o, u) {
|
|
439
|
+
this.databaseId = t, this.appId = n, this.persistenceKey = e, this.host = r, this.ssl = s,
|
|
440
440
|
this.forceLongPolling = i, this.autoDetectLongPolling = o, this.useFetchStreams = u;
|
|
441
441
|
}
|
|
442
442
|
}
|
|
@@ -447,8 +447,8 @@ class K {
|
|
|
447
447
|
* @internal
|
|
448
448
|
*/
|
|
449
449
|
class J {
|
|
450
|
-
constructor(t,
|
|
451
|
-
this.projectId = t, this.database =
|
|
450
|
+
constructor(t, n) {
|
|
451
|
+
this.projectId = t, this.database = n || "(default)";
|
|
452
452
|
}
|
|
453
453
|
static empty() {
|
|
454
454
|
return new J("", "");
|
|
@@ -481,9 +481,9 @@ class J {
|
|
|
481
481
|
* Path represents an ordered sequence of string segments.
|
|
482
482
|
*/
|
|
483
483
|
class X {
|
|
484
|
-
constructor(t,
|
|
485
|
-
void 0 ===
|
|
486
|
-
this.segments = t, this.offset =
|
|
484
|
+
constructor(t, n, e) {
|
|
485
|
+
void 0 === n ? n = 0 : n > t.length && v(), void 0 === e ? e = t.length - n : e > t.length - n && v(),
|
|
486
|
+
this.segments = t, this.offset = n, this.len = e;
|
|
487
487
|
}
|
|
488
488
|
get length() {
|
|
489
489
|
return this.len;
|
|
@@ -492,10 +492,10 @@ class X {
|
|
|
492
492
|
return 0 === X.comparator(this, t);
|
|
493
493
|
}
|
|
494
494
|
child(t) {
|
|
495
|
-
const
|
|
495
|
+
const n = this.segments.slice(this.offset, this.limit());
|
|
496
496
|
return t instanceof X ? t.forEach((t => {
|
|
497
|
-
|
|
498
|
-
})) :
|
|
497
|
+
n.push(t);
|
|
498
|
+
})) : n.push(t), this.construct(n);
|
|
499
499
|
}
|
|
500
500
|
/** The index of one past the last segment of the path. */ limit() {
|
|
501
501
|
return this.offset + this.length;
|
|
@@ -520,28 +520,28 @@ class X {
|
|
|
520
520
|
}
|
|
521
521
|
isPrefixOf(t) {
|
|
522
522
|
if (t.length < this.length) return !1;
|
|
523
|
-
for (let
|
|
523
|
+
for (let n = 0; n < this.length; n++) if (this.get(n) !== t.get(n)) return !1;
|
|
524
524
|
return !0;
|
|
525
525
|
}
|
|
526
526
|
isImmediateParentOf(t) {
|
|
527
527
|
if (this.length + 1 !== t.length) return !1;
|
|
528
|
-
for (let
|
|
528
|
+
for (let n = 0; n < this.length; n++) if (this.get(n) !== t.get(n)) return !1;
|
|
529
529
|
return !0;
|
|
530
530
|
}
|
|
531
531
|
forEach(t) {
|
|
532
|
-
for (let
|
|
532
|
+
for (let n = this.offset, e = this.limit(); n < e; n++) t(this.segments[n]);
|
|
533
533
|
}
|
|
534
534
|
toArray() {
|
|
535
535
|
return this.segments.slice(this.offset, this.limit());
|
|
536
536
|
}
|
|
537
|
-
static comparator(t,
|
|
538
|
-
const
|
|
539
|
-
for (let r = 0; r <
|
|
540
|
-
const
|
|
541
|
-
if (
|
|
542
|
-
if (
|
|
537
|
+
static comparator(t, n) {
|
|
538
|
+
const e = Math.min(t.length, n.length);
|
|
539
|
+
for (let r = 0; r < e; r++) {
|
|
540
|
+
const e = t.get(r), s = n.get(r);
|
|
541
|
+
if (e < s) return -1;
|
|
542
|
+
if (e > s) return 1;
|
|
543
543
|
}
|
|
544
|
-
return t.length <
|
|
544
|
+
return t.length < n.length ? -1 : t.length > n.length ? 1 : 0;
|
|
545
545
|
}
|
|
546
546
|
}
|
|
547
547
|
|
|
@@ -551,8 +551,8 @@ class X {
|
|
|
551
551
|
*
|
|
552
552
|
* @internal
|
|
553
553
|
*/ class Z extends X {
|
|
554
|
-
construct(t,
|
|
555
|
-
return new Z(t,
|
|
554
|
+
construct(t, n, e) {
|
|
555
|
+
return new Z(t, n, e);
|
|
556
556
|
}
|
|
557
557
|
canonicalString() {
|
|
558
558
|
// NOTE: The client is ignorant of any path segments containing escape
|
|
@@ -571,13 +571,13 @@ class X {
|
|
|
571
571
|
// NOTE: The client is ignorant of any path segments containing escape
|
|
572
572
|
// sequences (e.g. __id123__) and just passes them through raw (they exist
|
|
573
573
|
// for legacy reasons and should not be used frequently).
|
|
574
|
-
const
|
|
575
|
-
for (const
|
|
576
|
-
if (
|
|
574
|
+
const n = [];
|
|
575
|
+
for (const e of t) {
|
|
576
|
+
if (e.indexOf("//") >= 0) throw new U(R, `Invalid segment (${e}). Paths must not contain // in them.`);
|
|
577
577
|
// Strip leading and traling slashed.
|
|
578
|
-
|
|
578
|
+
n.push(...e.split("/").filter((t => t.length > 0)));
|
|
579
579
|
}
|
|
580
|
-
return new Z(
|
|
580
|
+
return new Z(n);
|
|
581
581
|
}
|
|
582
582
|
static emptyPath() {
|
|
583
583
|
return new Z([]);
|
|
@@ -589,9 +589,9 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
589
589
|
/**
|
|
590
590
|
* A dot-separated path for navigating sub-objects within a document.
|
|
591
591
|
* @internal
|
|
592
|
-
*/ class
|
|
593
|
-
construct(t,
|
|
594
|
-
return new
|
|
592
|
+
*/ class nt extends X {
|
|
593
|
+
construct(t, n, e) {
|
|
594
|
+
return new nt(t, n, e);
|
|
595
595
|
}
|
|
596
596
|
/**
|
|
597
597
|
* Returns true if the string could be used as a segment in a field path
|
|
@@ -601,7 +601,7 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
601
601
|
}
|
|
602
602
|
canonicalString() {
|
|
603
603
|
return this.toArray().map((t => (t = t.replace(/\\/g, "\\\\").replace(/`/g, "\\`"),
|
|
604
|
-
|
|
604
|
+
nt.isValidIdentifier(t) || (t = "`" + t + "`"), t))).join(".");
|
|
605
605
|
}
|
|
606
606
|
toString() {
|
|
607
607
|
return this.canonicalString();
|
|
@@ -614,7 +614,7 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
614
614
|
/**
|
|
615
615
|
* The field designating the key of a document.
|
|
616
616
|
*/ static keyField() {
|
|
617
|
-
return new
|
|
617
|
+
return new nt([ "__name__" ]);
|
|
618
618
|
}
|
|
619
619
|
/**
|
|
620
620
|
* Parses a field string from the given server-formatted string.
|
|
@@ -626,27 +626,27 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
626
626
|
* TODO(b/37244157): we should make this more strict. Right now, it allows
|
|
627
627
|
* non-identifier path components, even if they aren't escaped.
|
|
628
628
|
*/ static fromServerFormat(t) {
|
|
629
|
-
const
|
|
630
|
-
let
|
|
629
|
+
const n = [];
|
|
630
|
+
let e = "", r = 0;
|
|
631
631
|
const s = () => {
|
|
632
|
-
if (0 ===
|
|
633
|
-
|
|
632
|
+
if (0 === e.length) throw new U(R, `Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);
|
|
633
|
+
n.push(e), e = "";
|
|
634
634
|
};
|
|
635
635
|
let i = !1;
|
|
636
636
|
for (;r < t.length; ) {
|
|
637
|
-
const
|
|
638
|
-
if ("\\" ===
|
|
637
|
+
const n = t[r];
|
|
638
|
+
if ("\\" === n) {
|
|
639
639
|
if (r + 1 === t.length) throw new U(R, "Path has trailing escape character: " + t);
|
|
640
|
-
const
|
|
641
|
-
if ("\\" !==
|
|
642
|
-
|
|
643
|
-
} else "`" ===
|
|
640
|
+
const n = t[r + 1];
|
|
641
|
+
if ("\\" !== n && "." !== n && "`" !== n) throw new U(R, "Path has invalid escape sequence: " + t);
|
|
642
|
+
e += n, r += 2;
|
|
643
|
+
} else "`" === n ? (i = !i, r++) : "." !== n || i ? (e += n, r++) : (s(), r++);
|
|
644
644
|
}
|
|
645
645
|
if (s(), i) throw new U(R, "Unterminated ` in path: " + t);
|
|
646
|
-
return new
|
|
646
|
+
return new nt(n);
|
|
647
647
|
}
|
|
648
648
|
static emptyPath() {
|
|
649
|
-
return new
|
|
649
|
+
return new nt([]);
|
|
650
650
|
}
|
|
651
651
|
}
|
|
652
652
|
|
|
@@ -668,18 +668,18 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
668
668
|
*/
|
|
669
669
|
/**
|
|
670
670
|
* @internal
|
|
671
|
-
*/ class
|
|
671
|
+
*/ class et {
|
|
672
672
|
constructor(t) {
|
|
673
673
|
this.path = t;
|
|
674
674
|
}
|
|
675
675
|
static fromPath(t) {
|
|
676
|
-
return new
|
|
676
|
+
return new et(Z.fromString(t));
|
|
677
677
|
}
|
|
678
678
|
static fromName(t) {
|
|
679
|
-
return new
|
|
679
|
+
return new et(Z.fromString(t).popFirst(5));
|
|
680
680
|
}
|
|
681
681
|
static empty() {
|
|
682
|
-
return new
|
|
682
|
+
return new et(Z.emptyPath());
|
|
683
683
|
}
|
|
684
684
|
get collectionGroup() {
|
|
685
685
|
return this.path.popLast().lastSegment();
|
|
@@ -699,8 +699,8 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
699
699
|
toString() {
|
|
700
700
|
return this.path.toString();
|
|
701
701
|
}
|
|
702
|
-
static comparator(t,
|
|
703
|
-
return Z.comparator(t.path,
|
|
702
|
+
static comparator(t, n) {
|
|
703
|
+
return Z.comparator(t.path, n.path);
|
|
704
704
|
}
|
|
705
705
|
static isDocumentKey(t) {
|
|
706
706
|
return t.length % 2 == 0;
|
|
@@ -711,7 +711,7 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
711
711
|
* @param segments - The segments of the path to the document
|
|
712
712
|
* @returns A new instance of DocumentKey
|
|
713
713
|
*/ static fromSegments(t) {
|
|
714
|
-
return new
|
|
714
|
+
return new et(new Z(t.slice()));
|
|
715
715
|
}
|
|
716
716
|
}
|
|
717
717
|
|
|
@@ -730,8 +730,8 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
730
730
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
731
731
|
* See the License for the specific language governing permissions and
|
|
732
732
|
* limitations under the License.
|
|
733
|
-
*/ function rt(t,
|
|
734
|
-
if (!
|
|
733
|
+
*/ function rt(t, n, e) {
|
|
734
|
+
if (!e) throw new U(R, `Function ${t}() cannot be called with an empty ${n}.`);
|
|
735
735
|
}
|
|
736
736
|
|
|
737
737
|
/**
|
|
@@ -743,14 +743,14 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
743
743
|
* an even numbers of segments).
|
|
744
744
|
*/
|
|
745
745
|
function st(t) {
|
|
746
|
-
if (!
|
|
746
|
+
if (!et.isDocumentKey(t)) throw new U(R, `Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`);
|
|
747
747
|
}
|
|
748
748
|
|
|
749
749
|
/**
|
|
750
750
|
* Validates that `path` refers to a collection (indicated by the fact it
|
|
751
751
|
* contains an odd numbers of segments).
|
|
752
752
|
*/ function it(t) {
|
|
753
|
-
if (
|
|
753
|
+
if (et.isDocumentKey(t)) throw new U(R, `Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`);
|
|
754
754
|
}
|
|
755
755
|
|
|
756
756
|
/**
|
|
@@ -767,7 +767,7 @@ function ot(t) {
|
|
|
767
767
|
if ("object" == typeof t) {
|
|
768
768
|
if (t instanceof Array) return "an array";
|
|
769
769
|
{
|
|
770
|
-
const
|
|
770
|
+
const n =
|
|
771
771
|
/** try to get the constructor name for an object. */
|
|
772
772
|
function(t) {
|
|
773
773
|
if (t.constructor) return t.constructor.name;
|
|
@@ -781,7 +781,7 @@ function ot(t) {
|
|
|
781
781
|
* arguments passed to the public API.
|
|
782
782
|
* @internal
|
|
783
783
|
*/ (t);
|
|
784
|
-
return
|
|
784
|
+
return n ? `a custom ${n} object` : "an object";
|
|
785
785
|
}
|
|
786
786
|
}
|
|
787
787
|
return "function" == typeof t ? "a function" : v();
|
|
@@ -789,22 +789,22 @@ function ot(t) {
|
|
|
789
789
|
|
|
790
790
|
function ut(t,
|
|
791
791
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
792
|
-
|
|
792
|
+
n) {
|
|
793
793
|
if ("_delegate" in t && (
|
|
794
794
|
// Unwrap Compat types
|
|
795
795
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
796
|
-
t = t._delegate), !(t instanceof
|
|
797
|
-
if (
|
|
796
|
+
t = t._delegate), !(t instanceof n)) {
|
|
797
|
+
if (n.name === t.constructor.name) throw new U(R, "Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");
|
|
798
798
|
{
|
|
799
|
-
const
|
|
800
|
-
throw new U(R, `Expected type '${
|
|
799
|
+
const e = ot(t);
|
|
800
|
+
throw new U(R, `Expected type '${n.name}', but it was: ${e}`);
|
|
801
801
|
}
|
|
802
802
|
}
|
|
803
803
|
return t;
|
|
804
804
|
}
|
|
805
805
|
|
|
806
|
-
function ct(t,
|
|
807
|
-
if (
|
|
806
|
+
function ct(t, n) {
|
|
807
|
+
if (n <= 0) throw new U(R, `Function ${t}() requires a positive number, but it was: ${n}.`);
|
|
808
808
|
}
|
|
809
809
|
|
|
810
810
|
/**
|
|
@@ -1011,58 +1011,58 @@ class mt extends
|
|
|
1011
1011
|
class {
|
|
1012
1012
|
constructor(t) {
|
|
1013
1013
|
this.databaseInfo = t, this.databaseId = t.databaseId;
|
|
1014
|
-
const
|
|
1015
|
-
this.h =
|
|
1014
|
+
const n = t.ssl ? "https" : "http";
|
|
1015
|
+
this.h = n + "://" + t.host, this.l = "projects/" + this.databaseId.projectId + "/databases/" + this.databaseId.database + "/documents";
|
|
1016
1016
|
}
|
|
1017
|
-
m(t,
|
|
1018
|
-
const i = this.p(t,
|
|
1019
|
-
p("RestConnection", "Sending: ", i,
|
|
1017
|
+
m(t, n, e, r, s) {
|
|
1018
|
+
const i = this.p(t, n);
|
|
1019
|
+
p("RestConnection", "Sending: ", i, e);
|
|
1020
1020
|
const o = {};
|
|
1021
|
-
return this.g(o, r, s), this.v(t, i, o,
|
|
1022
|
-
t)), (
|
|
1023
|
-
throw _("RestConnection", `${t} failed with error: `,
|
|
1024
|
-
|
|
1021
|
+
return this.g(o, r, s), this.v(t, i, o, e).then((t => (p("RestConnection", "Received: ", t),
|
|
1022
|
+
t)), (n => {
|
|
1023
|
+
throw _("RestConnection", `${t} failed with error: `, n, "url: ", i, "request:", e),
|
|
1024
|
+
n;
|
|
1025
1025
|
}));
|
|
1026
1026
|
}
|
|
1027
|
-
T(t,
|
|
1027
|
+
T(t, n, e, r, s) {
|
|
1028
1028
|
// The REST API automatically aggregates all of the streamed results, so we
|
|
1029
1029
|
// can just use the normal invoke() method.
|
|
1030
|
-
return this.m(t,
|
|
1030
|
+
return this.m(t, n, e, r, s);
|
|
1031
1031
|
}
|
|
1032
1032
|
/**
|
|
1033
1033
|
* Modifies the headers for a request, adding any authorization token if
|
|
1034
1034
|
* present and any additional headers for the request.
|
|
1035
|
-
*/ g(t,
|
|
1035
|
+
*/ g(t, n, e) {
|
|
1036
1036
|
t["X-Goog-Api-Client"] = "gl-js/ fire/" + d,
|
|
1037
1037
|
// Content-Type: text/plain will avoid preflight requests which might
|
|
1038
1038
|
// mess with CORS and redirects by proxies. If we add custom headers
|
|
1039
1039
|
// we will need to change this code to potentially use the $httpOverwrite
|
|
1040
1040
|
// parameter supported by ESF to avoid triggering preflight requests.
|
|
1041
1041
|
t["Content-Type"] = "text/plain", this.databaseInfo.appId && (t["X-Firebase-GMPID"] = this.databaseInfo.appId),
|
|
1042
|
-
|
|
1042
|
+
n && n.headers.forEach(((n, e) => t[e] = n)), e && e.headers.forEach(((n, e) => t[e] = n));
|
|
1043
1043
|
}
|
|
1044
|
-
p(t,
|
|
1045
|
-
const
|
|
1046
|
-
return `${this.h}/v1/${
|
|
1044
|
+
p(t, n) {
|
|
1045
|
+
const e = lt[t];
|
|
1046
|
+
return `${this.h}/v1/${n}:${e}`;
|
|
1047
1047
|
}
|
|
1048
1048
|
} {
|
|
1049
1049
|
/**
|
|
1050
1050
|
* @param databaseInfo - The connection info.
|
|
1051
1051
|
* @param fetchImpl - `fetch` or a Polyfill that implements the fetch API.
|
|
1052
1052
|
*/
|
|
1053
|
-
constructor(t,
|
|
1054
|
-
super(t), this.I =
|
|
1053
|
+
constructor(t, n) {
|
|
1054
|
+
super(t), this.I = n;
|
|
1055
1055
|
}
|
|
1056
|
-
A(t,
|
|
1056
|
+
A(t, n) {
|
|
1057
1057
|
throw new Error("Not supported by FetchConnection");
|
|
1058
1058
|
}
|
|
1059
|
-
async v(t,
|
|
1059
|
+
async v(t, n, e, r) {
|
|
1060
1060
|
const s = JSON.stringify(r);
|
|
1061
1061
|
let i;
|
|
1062
1062
|
try {
|
|
1063
|
-
i = await this.I(
|
|
1063
|
+
i = await this.I(n, {
|
|
1064
1064
|
method: "POST",
|
|
1065
|
-
headers:
|
|
1065
|
+
headers: e,
|
|
1066
1066
|
body: s
|
|
1067
1067
|
});
|
|
1068
1068
|
} catch (t) {
|
|
@@ -1113,13 +1113,13 @@ class {
|
|
|
1113
1113
|
*/
|
|
1114
1114
|
function pt(t) {
|
|
1115
1115
|
// Polyfills for IE and WebWorker by using `self` and `msCrypto` when `crypto` is not available.
|
|
1116
|
-
const
|
|
1116
|
+
const n =
|
|
1117
1117
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1118
|
-
"undefined" != typeof self && (self.crypto || self.msCrypto),
|
|
1119
|
-
if (
|
|
1118
|
+
"undefined" != typeof self && (self.crypto || self.msCrypto), e = new Uint8Array(t);
|
|
1119
|
+
if (n && "function" == typeof n.getRandomValues) n.getRandomValues(e); else
|
|
1120
1120
|
// Falls back to Math.random
|
|
1121
|
-
for (let
|
|
1122
|
-
return
|
|
1121
|
+
for (let n = 0; n < t; n++) e[n] = Math.floor(256 * Math.random());
|
|
1122
|
+
return e;
|
|
1123
1123
|
}
|
|
1124
1124
|
|
|
1125
1125
|
/**
|
|
@@ -1140,26 +1140,26 @@ function pt(t) {
|
|
|
1140
1140
|
*/ class yt {
|
|
1141
1141
|
static R() {
|
|
1142
1142
|
// Alphanumeric characters
|
|
1143
|
-
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
|
|
1143
|
+
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", n = Math.floor(256 / t.length) * t.length;
|
|
1144
1144
|
// The largest byte value that is a multiple of `char.length`.
|
|
1145
|
-
let
|
|
1146
|
-
for (;
|
|
1145
|
+
let e = "";
|
|
1146
|
+
for (;e.length < 20; ) {
|
|
1147
1147
|
const r = pt(40);
|
|
1148
1148
|
for (let s = 0; s < r.length; ++s)
|
|
1149
1149
|
// Only accept values that are [0, maxMultiple), this ensures they can
|
|
1150
1150
|
// be evenly mapped to indices of `chars` via a modulo operation.
|
|
1151
|
-
|
|
1151
|
+
e.length < 20 && r[s] < n && (e += t.charAt(r[s] % t.length));
|
|
1152
1152
|
}
|
|
1153
|
-
return
|
|
1153
|
+
return e;
|
|
1154
1154
|
}
|
|
1155
1155
|
}
|
|
1156
1156
|
|
|
1157
|
-
function _t(t,
|
|
1158
|
-
return t <
|
|
1157
|
+
function _t(t, n) {
|
|
1158
|
+
return t < n ? -1 : t > n ? 1 : 0;
|
|
1159
1159
|
}
|
|
1160
1160
|
|
|
1161
|
-
/** Helper to compare arrays using isEqual(). */ function gt(t,
|
|
1162
|
-
return t.length ===
|
|
1161
|
+
/** Helper to compare arrays using isEqual(). */ function gt(t, n, e) {
|
|
1162
|
+
return t.length === n.length && t.every(((t, r) => e(t, n[r])));
|
|
1163
1163
|
}
|
|
1164
1164
|
|
|
1165
1165
|
/**
|
|
@@ -1213,9 +1213,9 @@ class vt {
|
|
|
1213
1213
|
/**
|
|
1214
1214
|
* The fractions of a second at nanosecond resolution.*
|
|
1215
1215
|
*/
|
|
1216
|
-
|
|
1217
|
-
if (this.seconds = t, this.nanoseconds =
|
|
1218
|
-
if (
|
|
1216
|
+
n) {
|
|
1217
|
+
if (this.seconds = t, this.nanoseconds = n, n < 0) throw new U(R, "Timestamp nanoseconds out of range: " + n);
|
|
1218
|
+
if (n >= 1e9) throw new U(R, "Timestamp nanoseconds out of range: " + n);
|
|
1219
1219
|
if (t < -62135596800) throw new U(R, "Timestamp seconds out of range: " + t);
|
|
1220
1220
|
// This will break in the year 10,000.
|
|
1221
1221
|
if (t >= 253402300800) throw new U(R, "Timestamp seconds out of range: " + t);
|
|
@@ -1244,8 +1244,8 @@ class vt {
|
|
|
1244
1244
|
* @returns A new `Timestamp` representing the same point in time as the given
|
|
1245
1245
|
* number of milliseconds.
|
|
1246
1246
|
*/ static fromMillis(t) {
|
|
1247
|
-
const
|
|
1248
|
-
return new vt(
|
|
1247
|
+
const n = Math.floor(t / 1e3), e = Math.floor(1e6 * (t - 1e3 * n));
|
|
1248
|
+
return new vt(n, e);
|
|
1249
1249
|
}
|
|
1250
1250
|
/**
|
|
1251
1251
|
* Converts a `Timestamp` to a JavaScript `Date` object. This conversion
|
|
@@ -1370,13 +1370,13 @@ class vt {
|
|
|
1370
1370
|
* See the License for the specific language governing permissions and
|
|
1371
1371
|
* limitations under the License.
|
|
1372
1372
|
*/ function Et(t) {
|
|
1373
|
-
let
|
|
1374
|
-
for (const
|
|
1375
|
-
return
|
|
1373
|
+
let n = 0;
|
|
1374
|
+
for (const e in t) Object.prototype.hasOwnProperty.call(t, e) && n++;
|
|
1375
|
+
return n;
|
|
1376
1376
|
}
|
|
1377
1377
|
|
|
1378
|
-
function Tt(t,
|
|
1379
|
-
for (const
|
|
1378
|
+
function Tt(t, n) {
|
|
1379
|
+
for (const e in t) Object.prototype.hasOwnProperty.call(t, e) && n(e, t[e]);
|
|
1380
1380
|
}
|
|
1381
1381
|
|
|
1382
1382
|
/**
|
|
@@ -1410,7 +1410,7 @@ class It {
|
|
|
1410
1410
|
this.fields = t,
|
|
1411
1411
|
// TODO(dimond): validation of FieldMask
|
|
1412
1412
|
// Sort the field mask to support `FieldMask.isEqual()` and assert below.
|
|
1413
|
-
t.sort(
|
|
1413
|
+
t.sort(nt.comparator);
|
|
1414
1414
|
}
|
|
1415
1415
|
/**
|
|
1416
1416
|
* Verifies that `fieldPath` is included by at least one field in this field
|
|
@@ -1418,11 +1418,11 @@ class It {
|
|
|
1418
1418
|
*
|
|
1419
1419
|
* This is an O(n) operation, where `n` is the size of the field mask.
|
|
1420
1420
|
*/ covers(t) {
|
|
1421
|
-
for (const
|
|
1421
|
+
for (const n of this.fields) if (n.isPrefixOf(t)) return !0;
|
|
1422
1422
|
return !1;
|
|
1423
1423
|
}
|
|
1424
1424
|
isEqual(t) {
|
|
1425
|
-
return gt(this.fields, t.fields, ((t,
|
|
1425
|
+
return gt(this.fields, t.fields, ((t, n) => t.isEqual(n)));
|
|
1426
1426
|
}
|
|
1427
1427
|
}
|
|
1428
1428
|
|
|
@@ -1484,25 +1484,25 @@ class Rt {
|
|
|
1484
1484
|
this.binaryString = t;
|
|
1485
1485
|
}
|
|
1486
1486
|
static fromBase64String(t) {
|
|
1487
|
-
const
|
|
1488
|
-
return new Rt(
|
|
1487
|
+
const n = At(t);
|
|
1488
|
+
return new Rt(n);
|
|
1489
1489
|
}
|
|
1490
1490
|
static fromUint8Array(t) {
|
|
1491
1491
|
// TODO(indexing); Remove the copy of the byte string here as this method
|
|
1492
1492
|
// is frequently called during indexing.
|
|
1493
|
-
const
|
|
1493
|
+
const n =
|
|
1494
1494
|
/**
|
|
1495
1495
|
* Helper function to convert an Uint8array to a binary string.
|
|
1496
1496
|
*/
|
|
1497
1497
|
function(t) {
|
|
1498
|
-
let
|
|
1499
|
-
for (let
|
|
1500
|
-
return
|
|
1498
|
+
let n = "";
|
|
1499
|
+
for (let e = 0; e < t.length; ++e) n += String.fromCharCode(t[e]);
|
|
1500
|
+
return n;
|
|
1501
1501
|
}
|
|
1502
1502
|
/**
|
|
1503
1503
|
* Helper function to convert a binary string to an Uint8Array.
|
|
1504
1504
|
*/ (t);
|
|
1505
|
-
return new Rt(
|
|
1505
|
+
return new Rt(n);
|
|
1506
1506
|
}
|
|
1507
1507
|
[Symbol.iterator]() {
|
|
1508
1508
|
let t = 0;
|
|
@@ -1518,16 +1518,16 @@ class Rt {
|
|
|
1518
1518
|
}
|
|
1519
1519
|
toBase64() {
|
|
1520
1520
|
return function(t) {
|
|
1521
|
-
const
|
|
1522
|
-
for (let
|
|
1523
|
-
return a.encodeByteArray(
|
|
1521
|
+
const n = [];
|
|
1522
|
+
for (let e = 0; e < t.length; e++) n[e] = t.charCodeAt(e);
|
|
1523
|
+
return a.encodeByteArray(n, !1);
|
|
1524
1524
|
}(this.binaryString);
|
|
1525
1525
|
}
|
|
1526
1526
|
toUint8Array() {
|
|
1527
1527
|
return function(t) {
|
|
1528
|
-
const
|
|
1529
|
-
for (let
|
|
1530
|
-
return
|
|
1528
|
+
const n = new Uint8Array(t.length);
|
|
1529
|
+
for (let e = 0; e < t.length; e++) n[e] = t.charCodeAt(e);
|
|
1530
|
+
return n;
|
|
1531
1531
|
}
|
|
1532
1532
|
/**
|
|
1533
1533
|
* @license
|
|
@@ -1574,18 +1574,18 @@ const Pt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1574
1574
|
// The date string can have higher precision (nanos) than the Date class
|
|
1575
1575
|
// (millis), so we do some custom parsing here.
|
|
1576
1576
|
// Parse the nanos right out of the string.
|
|
1577
|
-
let
|
|
1578
|
-
const
|
|
1579
|
-
if (b(!!
|
|
1577
|
+
let n = 0;
|
|
1578
|
+
const e = Pt.exec(t);
|
|
1579
|
+
if (b(!!e), e[1]) {
|
|
1580
1580
|
// Pad the fraction out to 9 digits (nanos).
|
|
1581
|
-
let t =
|
|
1582
|
-
t = (t + "000000000").substr(0, 9),
|
|
1581
|
+
let t = e[1];
|
|
1582
|
+
t = (t + "000000000").substr(0, 9), n = Number(t);
|
|
1583
1583
|
}
|
|
1584
1584
|
// Parse the date to get the seconds.
|
|
1585
1585
|
const r = new Date(t);
|
|
1586
1586
|
return {
|
|
1587
1587
|
seconds: Math.floor(r.getTime() / 1e3),
|
|
1588
|
-
nanos:
|
|
1588
|
+
nanos: n
|
|
1589
1589
|
};
|
|
1590
1590
|
}
|
|
1591
1591
|
return {
|
|
@@ -1640,8 +1640,8 @@ const Pt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1640
1640
|
* - With respect to other ServerTimestampValues, they sort by their
|
|
1641
1641
|
* localWriteTime.
|
|
1642
1642
|
*/ function $t(t) {
|
|
1643
|
-
var
|
|
1644
|
-
return "server_timestamp" === (null === (
|
|
1643
|
+
var n, e;
|
|
1644
|
+
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);
|
|
1645
1645
|
}
|
|
1646
1646
|
|
|
1647
1647
|
/**
|
|
@@ -1650,15 +1650,15 @@ const Pt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1650
1650
|
* Preserving the previous values allows the user to display the last resoled
|
|
1651
1651
|
* value until the backend responds with the timestamp.
|
|
1652
1652
|
*/ function St(t) {
|
|
1653
|
-
const
|
|
1654
|
-
return $t(
|
|
1653
|
+
const n = t.mapValue.fields.__previous_value__;
|
|
1654
|
+
return $t(n) ? St(n) : n;
|
|
1655
1655
|
}
|
|
1656
1656
|
|
|
1657
1657
|
/**
|
|
1658
1658
|
* Returns the local time at which this timestamp was first set.
|
|
1659
1659
|
*/ function Ft(t) {
|
|
1660
|
-
const
|
|
1661
|
-
return new vt(
|
|
1660
|
+
const n = Vt(t.mapValue.fields.__local_write_time__.timestampValue);
|
|
1661
|
+
return new vt(n.seconds, n.nanos);
|
|
1662
1662
|
}
|
|
1663
1663
|
|
|
1664
1664
|
/**
|
|
@@ -1706,171 +1706,171 @@ function xt(t) {
|
|
|
1706
1706
|
*/ (t) ? 9 /* ArrayValue */ : 10 /* ObjectValue */ : v();
|
|
1707
1707
|
}
|
|
1708
1708
|
|
|
1709
|
-
/** Tests `left` and `right` for equality based on the backend semantics. */ function qt(t,
|
|
1710
|
-
if (t ===
|
|
1711
|
-
const
|
|
1712
|
-
if (
|
|
1713
|
-
switch (
|
|
1709
|
+
/** Tests `left` and `right` for equality based on the backend semantics. */ function qt(t, n) {
|
|
1710
|
+
if (t === n) return !0;
|
|
1711
|
+
const e = xt(t);
|
|
1712
|
+
if (e !== xt(n)) return !1;
|
|
1713
|
+
switch (e) {
|
|
1714
1714
|
case 0 /* NullValue */ :
|
|
1715
1715
|
case 9007199254740991 /* MaxValue */ :
|
|
1716
1716
|
return !0;
|
|
1717
1717
|
|
|
1718
1718
|
case 1 /* BooleanValue */ :
|
|
1719
|
-
return t.booleanValue ===
|
|
1719
|
+
return t.booleanValue === n.booleanValue;
|
|
1720
1720
|
|
|
1721
1721
|
case 4 /* ServerTimestampValue */ :
|
|
1722
|
-
return Ft(t).isEqual(Ft(
|
|
1722
|
+
return Ft(t).isEqual(Ft(n));
|
|
1723
1723
|
|
|
1724
1724
|
case 3 /* TimestampValue */ :
|
|
1725
|
-
return function(t,
|
|
1726
|
-
if ("string" == typeof t.timestampValue && "string" == typeof
|
|
1725
|
+
return function(t, n) {
|
|
1726
|
+
if ("string" == typeof t.timestampValue && "string" == typeof n.timestampValue && t.timestampValue.length === n.timestampValue.length)
|
|
1727
1727
|
// Use string equality for ISO 8601 timestamps
|
|
1728
|
-
return t.timestampValue ===
|
|
1729
|
-
const
|
|
1730
|
-
return
|
|
1731
|
-
}(t,
|
|
1728
|
+
return t.timestampValue === n.timestampValue;
|
|
1729
|
+
const e = Vt(t.timestampValue), r = Vt(n.timestampValue);
|
|
1730
|
+
return e.seconds === r.seconds && e.nanos === r.nanos;
|
|
1731
|
+
}(t, n);
|
|
1732
1732
|
|
|
1733
1733
|
case 5 /* StringValue */ :
|
|
1734
|
-
return t.stringValue ===
|
|
1734
|
+
return t.stringValue === n.stringValue;
|
|
1735
1735
|
|
|
1736
1736
|
case 6 /* BlobValue */ :
|
|
1737
|
-
return function(t,
|
|
1738
|
-
return Dt(t.bytesValue).isEqual(Dt(
|
|
1739
|
-
}(t,
|
|
1737
|
+
return function(t, n) {
|
|
1738
|
+
return Dt(t.bytesValue).isEqual(Dt(n.bytesValue));
|
|
1739
|
+
}(t, n);
|
|
1740
1740
|
|
|
1741
1741
|
case 7 /* RefValue */ :
|
|
1742
|
-
return t.referenceValue ===
|
|
1742
|
+
return t.referenceValue === n.referenceValue;
|
|
1743
1743
|
|
|
1744
1744
|
case 8 /* GeoPointValue */ :
|
|
1745
|
-
return function(t,
|
|
1746
|
-
return Nt(t.geoPointValue.latitude) === Nt(
|
|
1747
|
-
}(t,
|
|
1745
|
+
return function(t, n) {
|
|
1746
|
+
return Nt(t.geoPointValue.latitude) === Nt(n.geoPointValue.latitude) && Nt(t.geoPointValue.longitude) === Nt(n.geoPointValue.longitude);
|
|
1747
|
+
}(t, n);
|
|
1748
1748
|
|
|
1749
1749
|
case 2 /* NumberValue */ :
|
|
1750
|
-
return function(t,
|
|
1751
|
-
if ("integerValue" in t && "integerValue" in
|
|
1752
|
-
if ("doubleValue" in t && "doubleValue" in
|
|
1753
|
-
const
|
|
1754
|
-
return
|
|
1750
|
+
return function(t, n) {
|
|
1751
|
+
if ("integerValue" in t && "integerValue" in n) return Nt(t.integerValue) === Nt(n.integerValue);
|
|
1752
|
+
if ("doubleValue" in t && "doubleValue" in n) {
|
|
1753
|
+
const e = Nt(t.doubleValue), r = Nt(n.doubleValue);
|
|
1754
|
+
return e === r ? ht(e) === ht(r) : isNaN(e) && isNaN(r);
|
|
1755
1755
|
}
|
|
1756
1756
|
return !1;
|
|
1757
|
-
}(t,
|
|
1757
|
+
}(t, n);
|
|
1758
1758
|
|
|
1759
1759
|
case 9 /* ArrayValue */ :
|
|
1760
|
-
return gt(t.arrayValue.values || [],
|
|
1760
|
+
return gt(t.arrayValue.values || [], n.arrayValue.values || [], qt);
|
|
1761
1761
|
|
|
1762
1762
|
case 10 /* ObjectValue */ :
|
|
1763
|
-
return function(t,
|
|
1764
|
-
const
|
|
1765
|
-
if (Et(
|
|
1766
|
-
for (const t in
|
|
1763
|
+
return function(t, n) {
|
|
1764
|
+
const e = t.mapValue.fields || {}, r = n.mapValue.fields || {};
|
|
1765
|
+
if (Et(e) !== Et(r)) return !1;
|
|
1766
|
+
for (const t in e) if (e.hasOwnProperty(t) && (void 0 === r[t] || !qt(e[t], r[t]))) return !1;
|
|
1767
1767
|
return !0;
|
|
1768
1768
|
}
|
|
1769
|
-
/** Returns true if the ArrayValue contains the specified element. */ (t,
|
|
1769
|
+
/** Returns true if the ArrayValue contains the specified element. */ (t, n);
|
|
1770
1770
|
|
|
1771
1771
|
default:
|
|
1772
1772
|
return v();
|
|
1773
1773
|
}
|
|
1774
1774
|
}
|
|
1775
1775
|
|
|
1776
|
-
function Ot(t,
|
|
1777
|
-
return void 0 !== (t.values || []).find((t => qt(t,
|
|
1776
|
+
function Ot(t, n) {
|
|
1777
|
+
return void 0 !== (t.values || []).find((t => qt(t, n)));
|
|
1778
1778
|
}
|
|
1779
1779
|
|
|
1780
|
-
function Ct(t,
|
|
1781
|
-
if (t ===
|
|
1782
|
-
const
|
|
1783
|
-
if (
|
|
1784
|
-
switch (
|
|
1780
|
+
function Ct(t, n) {
|
|
1781
|
+
if (t === n) return 0;
|
|
1782
|
+
const e = xt(t), r = xt(n);
|
|
1783
|
+
if (e !== r) return _t(e, r);
|
|
1784
|
+
switch (e) {
|
|
1785
1785
|
case 0 /* NullValue */ :
|
|
1786
1786
|
case 9007199254740991 /* MaxValue */ :
|
|
1787
1787
|
return 0;
|
|
1788
1788
|
|
|
1789
1789
|
case 1 /* BooleanValue */ :
|
|
1790
|
-
return _t(t.booleanValue,
|
|
1790
|
+
return _t(t.booleanValue, n.booleanValue);
|
|
1791
1791
|
|
|
1792
1792
|
case 2 /* NumberValue */ :
|
|
1793
|
-
return function(t,
|
|
1794
|
-
const
|
|
1795
|
-
return
|
|
1793
|
+
return function(t, n) {
|
|
1794
|
+
const e = Nt(t.integerValue || t.doubleValue), r = Nt(n.integerValue || n.doubleValue);
|
|
1795
|
+
return e < r ? -1 : e > r ? 1 : e === r ? 0 :
|
|
1796
1796
|
// one or both are NaN.
|
|
1797
|
-
isNaN(
|
|
1798
|
-
}(t,
|
|
1797
|
+
isNaN(e) ? isNaN(r) ? 0 : -1 : 1;
|
|
1798
|
+
}(t, n);
|
|
1799
1799
|
|
|
1800
1800
|
case 3 /* TimestampValue */ :
|
|
1801
|
-
return Lt(t.timestampValue,
|
|
1801
|
+
return Lt(t.timestampValue, n.timestampValue);
|
|
1802
1802
|
|
|
1803
1803
|
case 4 /* ServerTimestampValue */ :
|
|
1804
|
-
return Lt(Ft(t), Ft(
|
|
1804
|
+
return Lt(Ft(t), Ft(n));
|
|
1805
1805
|
|
|
1806
1806
|
case 5 /* StringValue */ :
|
|
1807
|
-
return _t(t.stringValue,
|
|
1807
|
+
return _t(t.stringValue, n.stringValue);
|
|
1808
1808
|
|
|
1809
1809
|
case 6 /* BlobValue */ :
|
|
1810
|
-
return function(t,
|
|
1811
|
-
const
|
|
1812
|
-
return
|
|
1813
|
-
}(t.bytesValue,
|
|
1810
|
+
return function(t, n) {
|
|
1811
|
+
const e = Dt(t), r = Dt(n);
|
|
1812
|
+
return e.compareTo(r);
|
|
1813
|
+
}(t.bytesValue, n.bytesValue);
|
|
1814
1814
|
|
|
1815
1815
|
case 7 /* RefValue */ :
|
|
1816
|
-
return function(t,
|
|
1817
|
-
const
|
|
1818
|
-
for (let t = 0; t <
|
|
1819
|
-
const
|
|
1820
|
-
if (0 !==
|
|
1816
|
+
return function(t, n) {
|
|
1817
|
+
const e = t.split("/"), r = n.split("/");
|
|
1818
|
+
for (let t = 0; t < e.length && t < r.length; t++) {
|
|
1819
|
+
const n = _t(e[t], r[t]);
|
|
1820
|
+
if (0 !== n) return n;
|
|
1821
1821
|
}
|
|
1822
|
-
return _t(
|
|
1823
|
-
}(t.referenceValue,
|
|
1822
|
+
return _t(e.length, r.length);
|
|
1823
|
+
}(t.referenceValue, n.referenceValue);
|
|
1824
1824
|
|
|
1825
1825
|
case 8 /* GeoPointValue */ :
|
|
1826
|
-
return function(t,
|
|
1827
|
-
const
|
|
1828
|
-
if (0 !==
|
|
1829
|
-
return _t(Nt(t.longitude), Nt(
|
|
1830
|
-
}(t.geoPointValue,
|
|
1826
|
+
return function(t, n) {
|
|
1827
|
+
const e = _t(Nt(t.latitude), Nt(n.latitude));
|
|
1828
|
+
if (0 !== e) return e;
|
|
1829
|
+
return _t(Nt(t.longitude), Nt(n.longitude));
|
|
1830
|
+
}(t.geoPointValue, n.geoPointValue);
|
|
1831
1831
|
|
|
1832
1832
|
case 9 /* ArrayValue */ :
|
|
1833
|
-
return function(t,
|
|
1834
|
-
const
|
|
1835
|
-
for (let t = 0; t <
|
|
1836
|
-
const
|
|
1837
|
-
if (
|
|
1833
|
+
return function(t, n) {
|
|
1834
|
+
const e = t.values || [], r = n.values || [];
|
|
1835
|
+
for (let t = 0; t < e.length && t < r.length; ++t) {
|
|
1836
|
+
const n = Ct(e[t], r[t]);
|
|
1837
|
+
if (n) return n;
|
|
1838
1838
|
}
|
|
1839
|
-
return _t(
|
|
1840
|
-
}(t.arrayValue,
|
|
1839
|
+
return _t(e.length, r.length);
|
|
1840
|
+
}(t.arrayValue, n.arrayValue);
|
|
1841
1841
|
|
|
1842
1842
|
case 10 /* ObjectValue */ :
|
|
1843
|
-
return function(t,
|
|
1844
|
-
const
|
|
1843
|
+
return function(t, n) {
|
|
1844
|
+
const e = t.fields || {}, r = Object.keys(e), s = n.fields || {}, i = Object.keys(s);
|
|
1845
1845
|
// Even though MapValues are likely sorted correctly based on their insertion
|
|
1846
1846
|
// order (e.g. when received from the backend), local modifications can bring
|
|
1847
1847
|
// elements out of order. We need to re-sort the elements to ensure that
|
|
1848
1848
|
// canonical IDs are independent of insertion order.
|
|
1849
1849
|
r.sort(), i.sort();
|
|
1850
1850
|
for (let t = 0; t < r.length && t < i.length; ++t) {
|
|
1851
|
-
const
|
|
1852
|
-
if (0 !==
|
|
1853
|
-
const o = Ct(
|
|
1851
|
+
const n = _t(r[t], i[t]);
|
|
1852
|
+
if (0 !== n) return n;
|
|
1853
|
+
const o = Ct(e[r[t]], s[i[t]]);
|
|
1854
1854
|
if (0 !== o) return o;
|
|
1855
1855
|
}
|
|
1856
1856
|
return _t(r.length, i.length);
|
|
1857
1857
|
}
|
|
1858
|
-
/** Returns a reference value for the provided database and key. */ (t.mapValue,
|
|
1858
|
+
/** Returns a reference value for the provided database and key. */ (t.mapValue, n.mapValue);
|
|
1859
1859
|
|
|
1860
1860
|
default:
|
|
1861
1861
|
throw v();
|
|
1862
1862
|
}
|
|
1863
1863
|
}
|
|
1864
1864
|
|
|
1865
|
-
function Lt(t,
|
|
1866
|
-
if ("string" == typeof t && "string" == typeof
|
|
1867
|
-
const
|
|
1868
|
-
return 0 !== s ? s : _t(
|
|
1865
|
+
function Lt(t, n) {
|
|
1866
|
+
if ("string" == typeof t && "string" == typeof n && t.length === n.length) return _t(t, n);
|
|
1867
|
+
const e = Vt(t), r = Vt(n), s = _t(e.seconds, r.seconds);
|
|
1868
|
+
return 0 !== s ? s : _t(e.nanos, r.nanos);
|
|
1869
1869
|
}
|
|
1870
1870
|
|
|
1871
|
-
function kt(t,
|
|
1871
|
+
function kt(t, n) {
|
|
1872
1872
|
return {
|
|
1873
|
-
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${
|
|
1873
|
+
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${n.path.canonicalString()}`
|
|
1874
1874
|
};
|
|
1875
1875
|
}
|
|
1876
1876
|
|
|
@@ -1898,21 +1898,21 @@ function kt(t, e) {
|
|
|
1898
1898
|
timestampValue: Object.assign({}, t.timestampValue)
|
|
1899
1899
|
};
|
|
1900
1900
|
if (t.mapValue) {
|
|
1901
|
-
const
|
|
1901
|
+
const n = {
|
|
1902
1902
|
mapValue: {
|
|
1903
1903
|
fields: {}
|
|
1904
1904
|
}
|
|
1905
1905
|
};
|
|
1906
|
-
return Tt(t.mapValue.fields, ((t,
|
|
1906
|
+
return Tt(t.mapValue.fields, ((t, e) => n.mapValue.fields[t] = zt(e))), n;
|
|
1907
1907
|
}
|
|
1908
1908
|
if (t.arrayValue) {
|
|
1909
|
-
const
|
|
1909
|
+
const n = {
|
|
1910
1910
|
arrayValue: {
|
|
1911
1911
|
values: []
|
|
1912
1912
|
}
|
|
1913
1913
|
};
|
|
1914
|
-
for (let
|
|
1915
|
-
return
|
|
1914
|
+
for (let e = 0; e < (t.arrayValue.values || []).length; ++e) n.arrayValue.values[e] = zt(t.arrayValue.values[e]);
|
|
1915
|
+
return n;
|
|
1916
1916
|
}
|
|
1917
1917
|
return Object.assign({}, t);
|
|
1918
1918
|
}
|
|
@@ -1934,10 +1934,10 @@ class Gt {
|
|
|
1934
1934
|
*/ field(t) {
|
|
1935
1935
|
if (t.isEmpty()) return this.value;
|
|
1936
1936
|
{
|
|
1937
|
-
let
|
|
1938
|
-
for (let
|
|
1939
|
-
!Bt(
|
|
1940
|
-
return
|
|
1937
|
+
let n = this.value;
|
|
1938
|
+
for (let e = 0; e < t.length - 1; ++e) if (n = (n.mapValue.fields || {})[t.get(e)],
|
|
1939
|
+
!Bt(n)) return null;
|
|
1940
|
+
return n = (n.mapValue.fields || {})[t.lastSegment()], n || null;
|
|
1941
1941
|
}
|
|
1942
1942
|
}
|
|
1943
1943
|
/**
|
|
@@ -1945,25 +1945,25 @@ class Gt {
|
|
|
1945
1945
|
*
|
|
1946
1946
|
* @param path - The field path to set.
|
|
1947
1947
|
* @param value - The value to set.
|
|
1948
|
-
*/ set(t,
|
|
1949
|
-
this.getFieldsMap(t.popLast())[t.lastSegment()] = zt(
|
|
1948
|
+
*/ set(t, n) {
|
|
1949
|
+
this.getFieldsMap(t.popLast())[t.lastSegment()] = zt(n);
|
|
1950
1950
|
}
|
|
1951
1951
|
/**
|
|
1952
1952
|
* Sets the provided fields to the provided values.
|
|
1953
1953
|
*
|
|
1954
1954
|
* @param data - A map of fields to values (or null for deletes).
|
|
1955
1955
|
*/ setAll(t) {
|
|
1956
|
-
let
|
|
1956
|
+
let n = nt.emptyPath(), e = {}, r = [];
|
|
1957
1957
|
t.forEach(((t, s) => {
|
|
1958
|
-
if (!
|
|
1958
|
+
if (!n.isImmediateParentOf(s)) {
|
|
1959
1959
|
// Insert the accumulated changes at this parent location
|
|
1960
|
-
const t = this.getFieldsMap(
|
|
1961
|
-
this.applyChanges(t,
|
|
1960
|
+
const t = this.getFieldsMap(n);
|
|
1961
|
+
this.applyChanges(t, e, r), e = {}, r = [], n = s.popLast();
|
|
1962
1962
|
}
|
|
1963
|
-
t ?
|
|
1963
|
+
t ? e[s.lastSegment()] = zt(t) : r.push(s.lastSegment());
|
|
1964
1964
|
}));
|
|
1965
|
-
const s = this.getFieldsMap(
|
|
1966
|
-
this.applyChanges(s,
|
|
1965
|
+
const s = this.getFieldsMap(n);
|
|
1966
|
+
this.applyChanges(s, e, r);
|
|
1967
1967
|
}
|
|
1968
1968
|
/**
|
|
1969
1969
|
* Removes the field at the specified path. If there is no field at the
|
|
@@ -1971,8 +1971,8 @@ class Gt {
|
|
|
1971
1971
|
*
|
|
1972
1972
|
* @param path - The field path to remove.
|
|
1973
1973
|
*/ delete(t) {
|
|
1974
|
-
const
|
|
1975
|
-
Bt(
|
|
1974
|
+
const n = this.field(t.popLast());
|
|
1975
|
+
Bt(n) && n.mapValue.fields && delete n.mapValue.fields[t.lastSegment()];
|
|
1976
1976
|
}
|
|
1977
1977
|
isEqual(t) {
|
|
1978
1978
|
return qt(this.value, t.value);
|
|
@@ -1981,26 +1981,26 @@ class Gt {
|
|
|
1981
1981
|
* Returns the map that contains the leaf element of `path`. If the parent
|
|
1982
1982
|
* entry does not yet exist, or if it is not a map, a new map will be created.
|
|
1983
1983
|
*/ getFieldsMap(t) {
|
|
1984
|
-
let
|
|
1985
|
-
|
|
1984
|
+
let n = this.value;
|
|
1985
|
+
n.mapValue.fields || (n.mapValue = {
|
|
1986
1986
|
fields: {}
|
|
1987
1987
|
});
|
|
1988
|
-
for (let
|
|
1989
|
-
let r =
|
|
1988
|
+
for (let e = 0; e < t.length; ++e) {
|
|
1989
|
+
let r = n.mapValue.fields[t.get(e)];
|
|
1990
1990
|
Bt(r) && r.mapValue.fields || (r = {
|
|
1991
1991
|
mapValue: {
|
|
1992
1992
|
fields: {}
|
|
1993
1993
|
}
|
|
1994
|
-
},
|
|
1994
|
+
}, n.mapValue.fields[t.get(e)] = r), n = r;
|
|
1995
1995
|
}
|
|
1996
|
-
return
|
|
1996
|
+
return n.mapValue.fields;
|
|
1997
1997
|
}
|
|
1998
1998
|
/**
|
|
1999
1999
|
* Modifies `fieldsMap` by adding, replacing or deleting the specified
|
|
2000
2000
|
* entries.
|
|
2001
|
-
*/ applyChanges(t,
|
|
2002
|
-
Tt(
|
|
2003
|
-
for (const
|
|
2001
|
+
*/ applyChanges(t, n, e) {
|
|
2002
|
+
Tt(n, ((n, e) => t[n] = e));
|
|
2003
|
+
for (const n of e) delete t[n];
|
|
2004
2004
|
}
|
|
2005
2005
|
clone() {
|
|
2006
2006
|
return new Gt(zt(this.value));
|
|
@@ -2033,8 +2033,8 @@ class Gt {
|
|
|
2033
2033
|
* applied, `isValidDocument()` returns false and the document should be removed
|
|
2034
2034
|
* from all views.
|
|
2035
2035
|
*/ class Qt {
|
|
2036
|
-
constructor(t,
|
|
2037
|
-
this.key = t, this.documentType =
|
|
2036
|
+
constructor(t, n, e, r, s, i) {
|
|
2037
|
+
this.key = t, this.documentType = n, this.version = e, this.readTime = r, this.data = s,
|
|
2038
2038
|
this.documentState = i;
|
|
2039
2039
|
}
|
|
2040
2040
|
/**
|
|
@@ -2046,24 +2046,24 @@ class Gt {
|
|
|
2046
2046
|
/**
|
|
2047
2047
|
* Creates a new document that is known to exist with the given data at the
|
|
2048
2048
|
* given version.
|
|
2049
|
-
*/ static newFoundDocument(t,
|
|
2050
|
-
return new Qt(t, 1 /* FOUND_DOCUMENT */ ,
|
|
2049
|
+
*/ static newFoundDocument(t, n, e) {
|
|
2050
|
+
return new Qt(t, 1 /* FOUND_DOCUMENT */ , n, bt.min(), e, 0 /* SYNCED */);
|
|
2051
2051
|
}
|
|
2052
|
-
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t,
|
|
2053
|
-
return new Qt(t, 2 /* NO_DOCUMENT */ ,
|
|
2052
|
+
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t, n) {
|
|
2053
|
+
return new Qt(t, 2 /* NO_DOCUMENT */ , n, bt.min(), Gt.empty(), 0 /* SYNCED */);
|
|
2054
2054
|
}
|
|
2055
2055
|
/**
|
|
2056
2056
|
* Creates a new document that is known to exist at the given version but
|
|
2057
2057
|
* whose data is not known (e.g. a document that was updated without a known
|
|
2058
2058
|
* base document).
|
|
2059
|
-
*/ static newUnknownDocument(t,
|
|
2060
|
-
return new Qt(t, 3 /* UNKNOWN_DOCUMENT */ ,
|
|
2059
|
+
*/ static newUnknownDocument(t, n) {
|
|
2060
|
+
return new Qt(t, 3 /* UNKNOWN_DOCUMENT */ , n, bt.min(), Gt.empty(), 2 /* HAS_COMMITTED_MUTATIONS */);
|
|
2061
2061
|
}
|
|
2062
2062
|
/**
|
|
2063
2063
|
* Changes the document type to indicate that it exists and that its version
|
|
2064
2064
|
* and data are known.
|
|
2065
|
-
*/ convertToFoundDocument(t,
|
|
2066
|
-
return this.version = t, this.documentType = 1 /* FOUND_DOCUMENT */ , this.data =
|
|
2065
|
+
*/ convertToFoundDocument(t, n) {
|
|
2066
|
+
return this.version = t, this.documentType = 1 /* FOUND_DOCUMENT */ , this.data = n,
|
|
2067
2067
|
this.documentState = 0 /* SYNCED */ , this;
|
|
2068
2068
|
}
|
|
2069
2069
|
/**
|
|
@@ -2140,8 +2140,8 @@ class Gt {
|
|
|
2140
2140
|
*/
|
|
2141
2141
|
// Visible for testing
|
|
2142
2142
|
class Wt {
|
|
2143
|
-
constructor(t,
|
|
2144
|
-
this.path = t, this.collectionGroup =
|
|
2143
|
+
constructor(t, n = null, e = [], r = [], s = null, i = null, o = null) {
|
|
2144
|
+
this.path = t, this.collectionGroup = n, this.orderBy = e, this.filters = r, this.limit = s,
|
|
2145
2145
|
this.startAt = i, this.endAt = o, this.P = null;
|
|
2146
2146
|
}
|
|
2147
2147
|
}
|
|
@@ -2153,26 +2153,26 @@ class Wt {
|
|
|
2153
2153
|
* NOTE: you should always construct `Target` from `Query.toTarget` instead of
|
|
2154
2154
|
* using this factory method, because `Query` provides an implicit `orderBy`
|
|
2155
2155
|
* property.
|
|
2156
|
-
*/ function Yt(t,
|
|
2157
|
-
return new Wt(t,
|
|
2156
|
+
*/ function Yt(t, n = null, e = [], r = [], s = null, i = null, o = null) {
|
|
2157
|
+
return new Wt(t, n, e, r, s, i, o);
|
|
2158
2158
|
}
|
|
2159
2159
|
|
|
2160
2160
|
class Ht extends class {} {
|
|
2161
|
-
constructor(t,
|
|
2162
|
-
super(), this.field = t, this.op =
|
|
2161
|
+
constructor(t, n, e) {
|
|
2162
|
+
super(), this.field = t, this.op = n, this.value = e;
|
|
2163
2163
|
}
|
|
2164
2164
|
/**
|
|
2165
2165
|
* Creates a filter based on the provided arguments.
|
|
2166
|
-
*/ static create(t,
|
|
2167
|
-
return t.isKeyField() ? "in" /* IN */ ===
|
|
2166
|
+
*/ static create(t, n, e) {
|
|
2167
|
+
return t.isKeyField() ? "in" /* IN */ === n || "not-in" /* NOT_IN */ === n ? this.V(t, n, e) : new Kt(t, n, e) : "array-contains" /* ARRAY_CONTAINS */ === n ? new tn(t, e) : "in" /* IN */ === n ? new nn(t, e) : "not-in" /* NOT_IN */ === n ? new en(t, e) : "array-contains-any" /* ARRAY_CONTAINS_ANY */ === n ? new rn(t, e) : new Ht(t, n, e);
|
|
2168
2168
|
}
|
|
2169
|
-
static V(t,
|
|
2170
|
-
return "in" /* IN */ ===
|
|
2169
|
+
static V(t, n, e) {
|
|
2170
|
+
return "in" /* IN */ === n ? new Jt(t, e) : new Xt(t, e);
|
|
2171
2171
|
}
|
|
2172
2172
|
matches(t) {
|
|
2173
|
-
const
|
|
2173
|
+
const n = t.data.field(this.field);
|
|
2174
2174
|
// Types do not have to match in NOT_EQUAL filters.
|
|
2175
|
-
return "!=" /* NOT_EQUAL */ === this.op ? null !==
|
|
2175
|
+
return "!=" /* NOT_EQUAL */ === this.op ? null !== n && this.N(Ct(n, this.value)) : null !== n && xt(this.value) === xt(n) && this.N(Ct(n, this.value));
|
|
2176
2176
|
// Only compare types with matching backend order (such as double and int).
|
|
2177
2177
|
}
|
|
2178
2178
|
N(t) {
|
|
@@ -2206,78 +2206,78 @@ class Ht extends class {} {
|
|
|
2206
2206
|
|
|
2207
2207
|
/** Filter that matches on key fields (i.e. '__name__'). */
|
|
2208
2208
|
class Kt extends Ht {
|
|
2209
|
-
constructor(t,
|
|
2210
|
-
super(t,
|
|
2209
|
+
constructor(t, n, e) {
|
|
2210
|
+
super(t, n, e), this.key = et.fromName(e.referenceValue);
|
|
2211
2211
|
}
|
|
2212
2212
|
matches(t) {
|
|
2213
|
-
const
|
|
2214
|
-
return this.N(
|
|
2213
|
+
const n = et.comparator(t.key, this.key);
|
|
2214
|
+
return this.N(n);
|
|
2215
2215
|
}
|
|
2216
2216
|
}
|
|
2217
2217
|
|
|
2218
2218
|
/** Filter that matches on key fields within an array. */ class Jt extends Ht {
|
|
2219
|
-
constructor(t,
|
|
2220
|
-
super(t, "in" /* IN */ ,
|
|
2219
|
+
constructor(t, n) {
|
|
2220
|
+
super(t, "in" /* IN */ , n), this.keys = Zt("in" /* IN */ , n);
|
|
2221
2221
|
}
|
|
2222
2222
|
matches(t) {
|
|
2223
|
-
return this.keys.some((
|
|
2223
|
+
return this.keys.some((n => n.isEqual(t.key)));
|
|
2224
2224
|
}
|
|
2225
2225
|
}
|
|
2226
2226
|
|
|
2227
2227
|
/** Filter that matches on key fields not present within an array. */ class Xt extends Ht {
|
|
2228
|
-
constructor(t,
|
|
2229
|
-
super(t, "not-in" /* NOT_IN */ ,
|
|
2228
|
+
constructor(t, n) {
|
|
2229
|
+
super(t, "not-in" /* NOT_IN */ , n), this.keys = Zt("not-in" /* NOT_IN */ , n);
|
|
2230
2230
|
}
|
|
2231
2231
|
matches(t) {
|
|
2232
|
-
return !this.keys.some((
|
|
2232
|
+
return !this.keys.some((n => n.isEqual(t.key)));
|
|
2233
2233
|
}
|
|
2234
2234
|
}
|
|
2235
2235
|
|
|
2236
|
-
function Zt(t,
|
|
2237
|
-
var
|
|
2238
|
-
return ((null === (
|
|
2236
|
+
function Zt(t, n) {
|
|
2237
|
+
var e;
|
|
2238
|
+
return ((null === (e = n.arrayValue) || void 0 === e ? void 0 : e.values) || []).map((t => et.fromName(t.referenceValue)));
|
|
2239
2239
|
}
|
|
2240
2240
|
|
|
2241
|
-
/** A Filter that implements the array-contains operator. */ class
|
|
2242
|
-
constructor(t,
|
|
2243
|
-
super(t, "array-contains" /* ARRAY_CONTAINS */ ,
|
|
2241
|
+
/** A Filter that implements the array-contains operator. */ class tn extends Ht {
|
|
2242
|
+
constructor(t, n) {
|
|
2243
|
+
super(t, "array-contains" /* ARRAY_CONTAINS */ , n);
|
|
2244
2244
|
}
|
|
2245
2245
|
matches(t) {
|
|
2246
|
-
const
|
|
2247
|
-
return Ut(
|
|
2246
|
+
const n = t.data.field(this.field);
|
|
2247
|
+
return Ut(n) && Ot(n.arrayValue, this.value);
|
|
2248
2248
|
}
|
|
2249
2249
|
}
|
|
2250
2250
|
|
|
2251
|
-
/** A Filter that implements the IN operator. */ class
|
|
2252
|
-
constructor(t,
|
|
2253
|
-
super(t, "in" /* IN */ ,
|
|
2251
|
+
/** A Filter that implements the IN operator. */ class nn extends Ht {
|
|
2252
|
+
constructor(t, n) {
|
|
2253
|
+
super(t, "in" /* IN */ , n);
|
|
2254
2254
|
}
|
|
2255
2255
|
matches(t) {
|
|
2256
|
-
const
|
|
2257
|
-
return null !==
|
|
2256
|
+
const n = t.data.field(this.field);
|
|
2257
|
+
return null !== n && Ot(this.value.arrayValue, n);
|
|
2258
2258
|
}
|
|
2259
2259
|
}
|
|
2260
2260
|
|
|
2261
|
-
/** A Filter that implements the not-in operator. */ class
|
|
2262
|
-
constructor(t,
|
|
2263
|
-
super(t, "not-in" /* NOT_IN */ ,
|
|
2261
|
+
/** A Filter that implements the not-in operator. */ class en extends Ht {
|
|
2262
|
+
constructor(t, n) {
|
|
2263
|
+
super(t, "not-in" /* NOT_IN */ , n);
|
|
2264
2264
|
}
|
|
2265
2265
|
matches(t) {
|
|
2266
2266
|
if (Ot(this.value.arrayValue, {
|
|
2267
2267
|
nullValue: "NULL_VALUE"
|
|
2268
2268
|
})) return !1;
|
|
2269
|
-
const
|
|
2270
|
-
return null !==
|
|
2269
|
+
const n = t.data.field(this.field);
|
|
2270
|
+
return null !== n && !Ot(this.value.arrayValue, n);
|
|
2271
2271
|
}
|
|
2272
2272
|
}
|
|
2273
2273
|
|
|
2274
|
-
/** A Filter that implements the array-contains-any operator. */ class
|
|
2275
|
-
constructor(t,
|
|
2276
|
-
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ ,
|
|
2274
|
+
/** A Filter that implements the array-contains-any operator. */ class rn extends Ht {
|
|
2275
|
+
constructor(t, n) {
|
|
2276
|
+
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ , n);
|
|
2277
2277
|
}
|
|
2278
2278
|
matches(t) {
|
|
2279
|
-
const
|
|
2280
|
-
return !(!Ut(
|
|
2279
|
+
const n = t.data.field(this.field);
|
|
2280
|
+
return !(!Ut(n) || !n.arrayValue.values) && n.arrayValue.values.some((t => Ot(this.value.arrayValue, t)));
|
|
2281
2281
|
}
|
|
2282
2282
|
}
|
|
2283
2283
|
|
|
@@ -2294,30 +2294,30 @@ function Zt(t, e) {
|
|
|
2294
2294
|
* Bound provides a function to determine whether a document comes before or
|
|
2295
2295
|
* after a bound. This is influenced by whether the position is just before or
|
|
2296
2296
|
* just after the provided values.
|
|
2297
|
-
*/ class
|
|
2298
|
-
constructor(t,
|
|
2299
|
-
this.position = t, this.inclusive =
|
|
2297
|
+
*/ class sn {
|
|
2298
|
+
constructor(t, n) {
|
|
2299
|
+
this.position = t, this.inclusive = n;
|
|
2300
2300
|
}
|
|
2301
2301
|
}
|
|
2302
2302
|
|
|
2303
2303
|
/**
|
|
2304
2304
|
* An ordering on a field, in some Direction. Direction defaults to ASCENDING.
|
|
2305
|
-
*/ class
|
|
2306
|
-
constructor(t,
|
|
2307
|
-
this.field = t, this.dir =
|
|
2305
|
+
*/ class on {
|
|
2306
|
+
constructor(t, n = "asc" /* ASCENDING */) {
|
|
2307
|
+
this.field = t, this.dir = n;
|
|
2308
2308
|
}
|
|
2309
2309
|
}
|
|
2310
2310
|
|
|
2311
|
-
function
|
|
2312
|
-
return t.dir ===
|
|
2311
|
+
function un(t, n) {
|
|
2312
|
+
return t.dir === n.dir && t.field.isEqual(n.field);
|
|
2313
2313
|
}
|
|
2314
2314
|
|
|
2315
|
-
function
|
|
2316
|
-
if (null === t) return null ===
|
|
2317
|
-
if (null ===
|
|
2318
|
-
if (t.inclusive !==
|
|
2319
|
-
for (let
|
|
2320
|
-
if (!qt(t.position[
|
|
2315
|
+
function cn(t, n) {
|
|
2316
|
+
if (null === t) return null === n;
|
|
2317
|
+
if (null === n) return !1;
|
|
2318
|
+
if (t.inclusive !== n.inclusive || t.position.length !== n.position.length) return !1;
|
|
2319
|
+
for (let e = 0; e < t.position.length; e++) {
|
|
2320
|
+
if (!qt(t.position[e], n.position[e])) return !1;
|
|
2321
2321
|
}
|
|
2322
2322
|
return !0;
|
|
2323
2323
|
}
|
|
@@ -2344,29 +2344,29 @@ function ue(t, e) {
|
|
|
2344
2344
|
* query the RemoteStore results.
|
|
2345
2345
|
*
|
|
2346
2346
|
* Visible for testing.
|
|
2347
|
-
*/ class
|
|
2347
|
+
*/ class an {
|
|
2348
2348
|
/**
|
|
2349
2349
|
* Initializes a Query with a path and optional additional query constraints.
|
|
2350
2350
|
* Path must currently be empty if this is a collection group query.
|
|
2351
2351
|
*/
|
|
2352
|
-
constructor(t,
|
|
2353
|
-
this.path = t, this.collectionGroup =
|
|
2352
|
+
constructor(t, n = null, e = [], r = [], s = null, i = "F" /* First */ , o = null, u = null) {
|
|
2353
|
+
this.path = t, this.collectionGroup = n, this.explicitOrderBy = e, this.filters = r,
|
|
2354
2354
|
this.limit = s, this.limitType = i, this.startAt = o, this.endAt = u, this.$ = null,
|
|
2355
2355
|
// The corresponding `Target` of this `Query` instance.
|
|
2356
2356
|
this.S = null, this.startAt, this.endAt;
|
|
2357
2357
|
}
|
|
2358
2358
|
}
|
|
2359
2359
|
|
|
2360
|
-
/** Creates a new Query for a query that matches all documents at `path` */ function
|
|
2360
|
+
/** Creates a new Query for a query that matches all documents at `path` */ function hn(t) {
|
|
2361
2361
|
return !at(t.limit) && "L" /* Last */ === t.limitType;
|
|
2362
2362
|
}
|
|
2363
2363
|
|
|
2364
|
-
function
|
|
2364
|
+
function ln(t) {
|
|
2365
2365
|
return t.explicitOrderBy.length > 0 ? t.explicitOrderBy[0].field : null;
|
|
2366
2366
|
}
|
|
2367
2367
|
|
|
2368
|
-
function
|
|
2369
|
-
for (const
|
|
2368
|
+
function fn(t) {
|
|
2369
|
+
for (const n of t.filters) if (n.D()) return n.field;
|
|
2370
2370
|
return null;
|
|
2371
2371
|
}
|
|
2372
2372
|
|
|
@@ -2378,7 +2378,7 @@ function le(t) {
|
|
|
2378
2378
|
* Returns whether the query matches a collection group rather than a specific
|
|
2379
2379
|
* collection.
|
|
2380
2380
|
*/
|
|
2381
|
-
function
|
|
2381
|
+
function dn(t) {
|
|
2382
2382
|
return null !== t.collectionGroup;
|
|
2383
2383
|
}
|
|
2384
2384
|
|
|
@@ -2386,59 +2386,59 @@ function fe(t) {
|
|
|
2386
2386
|
* Returns the implicit order by constraint that is used to execute the Query,
|
|
2387
2387
|
* which can be different from the order by constraints the user provided (e.g.
|
|
2388
2388
|
* the SDK and backend always orders by `__name__`).
|
|
2389
|
-
*/ function
|
|
2390
|
-
const
|
|
2391
|
-
if (null ===
|
|
2392
|
-
|
|
2393
|
-
const t =
|
|
2394
|
-
if (null !== t && null ===
|
|
2389
|
+
*/ function wn(t) {
|
|
2390
|
+
const n = E(t);
|
|
2391
|
+
if (null === n.$) {
|
|
2392
|
+
n.$ = [];
|
|
2393
|
+
const t = fn(n), e = ln(n);
|
|
2394
|
+
if (null !== t && null === e)
|
|
2395
2395
|
// In order to implicitly add key ordering, we must also add the
|
|
2396
2396
|
// inequality filter field for it to be a valid query.
|
|
2397
2397
|
// Note that the default inequality field and key ordering is ascending.
|
|
2398
|
-
t.isKeyField() ||
|
|
2398
|
+
t.isKeyField() || n.$.push(new on(t)), n.$.push(new on(nt.keyField(), "asc" /* ASCENDING */)); else {
|
|
2399
2399
|
let t = !1;
|
|
2400
|
-
for (const
|
|
2400
|
+
for (const e of n.explicitOrderBy) n.$.push(e), e.field.isKeyField() && (t = !0);
|
|
2401
2401
|
if (!t) {
|
|
2402
2402
|
// The order of the implicit key ordering always matches the last
|
|
2403
2403
|
// explicit order by
|
|
2404
|
-
const t =
|
|
2405
|
-
|
|
2404
|
+
const t = n.explicitOrderBy.length > 0 ? n.explicitOrderBy[n.explicitOrderBy.length - 1].dir : "asc" /* ASCENDING */;
|
|
2405
|
+
n.$.push(new on(nt.keyField(), t));
|
|
2406
2406
|
}
|
|
2407
2407
|
}
|
|
2408
2408
|
}
|
|
2409
|
-
return
|
|
2409
|
+
return n.$;
|
|
2410
2410
|
}
|
|
2411
2411
|
|
|
2412
2412
|
/**
|
|
2413
2413
|
* Converts this `Query` instance to it's corresponding `Target` representation.
|
|
2414
|
-
*/ function
|
|
2415
|
-
const
|
|
2416
|
-
if (!
|
|
2414
|
+
*/ function mn(t) {
|
|
2415
|
+
const n = E(t);
|
|
2416
|
+
if (!n.S) if ("F" /* First */ === n.limitType) n.S = Yt(n.path, n.collectionGroup, wn(n), n.filters, n.limit, n.startAt, n.endAt); else {
|
|
2417
2417
|
// Flip the orderBy directions since we want the last results
|
|
2418
2418
|
const t = [];
|
|
2419
|
-
for (const
|
|
2420
|
-
const
|
|
2421
|
-
t.push(new
|
|
2419
|
+
for (const e of wn(n)) {
|
|
2420
|
+
const n = "desc" /* DESCENDING */ === e.dir ? "asc" /* ASCENDING */ : "desc" /* DESCENDING */;
|
|
2421
|
+
t.push(new on(e.field, n));
|
|
2422
2422
|
}
|
|
2423
2423
|
// We need to swap the cursors to match the now-flipped query ordering.
|
|
2424
|
-
const
|
|
2424
|
+
const e = n.endAt ? new sn(n.endAt.position, !n.endAt.inclusive) : null, r = n.startAt ? new sn(n.startAt.position, !n.startAt.inclusive) : null;
|
|
2425
2425
|
// Now return as a LimitType.First query.
|
|
2426
|
-
|
|
2426
|
+
n.S = Yt(n.path, n.collectionGroup, t, n.filters, n.limit, e, r);
|
|
2427
2427
|
}
|
|
2428
|
-
return
|
|
2428
|
+
return n.S;
|
|
2429
2429
|
}
|
|
2430
2430
|
|
|
2431
|
-
function
|
|
2432
|
-
return function(t,
|
|
2433
|
-
if (t.limit !==
|
|
2434
|
-
if (t.orderBy.length !==
|
|
2435
|
-
for (let
|
|
2436
|
-
if (t.filters.length !==
|
|
2437
|
-
for (let s = 0; s < t.filters.length; s++) if (
|
|
2438
|
-
|
|
2439
|
-
var
|
|
2440
|
-
return t.collectionGroup ===
|
|
2441
|
-
}(
|
|
2431
|
+
function pn(t, n) {
|
|
2432
|
+
return function(t, n) {
|
|
2433
|
+
if (t.limit !== n.limit) return !1;
|
|
2434
|
+
if (t.orderBy.length !== n.orderBy.length) return !1;
|
|
2435
|
+
for (let e = 0; e < t.orderBy.length; e++) if (!un(t.orderBy[e], n.orderBy[e])) return !1;
|
|
2436
|
+
if (t.filters.length !== n.filters.length) return !1;
|
|
2437
|
+
for (let s = 0; s < t.filters.length; s++) if (e = t.filters[s], r = n.filters[s],
|
|
2438
|
+
e.op !== r.op || !e.field.isEqual(r.field) || !qt(e.value, r.value)) return !1;
|
|
2439
|
+
var e, r;
|
|
2440
|
+
return t.collectionGroup === n.collectionGroup && !!t.path.isEqual(n.path) && !!cn(t.startAt, n.startAt) && cn(t.endAt, n.endAt);
|
|
2441
|
+
}(mn(t), mn(n)) && t.limitType === n.limitType;
|
|
2442
2442
|
}
|
|
2443
2443
|
|
|
2444
2444
|
/**
|
|
@@ -2466,10 +2466,10 @@ function me(t, e) {
|
|
|
2466
2466
|
* The return value is an IntegerValue if it can safely represent the value,
|
|
2467
2467
|
* otherwise a DoubleValue is returned.
|
|
2468
2468
|
*/
|
|
2469
|
-
function
|
|
2469
|
+
function yn(t, n) {
|
|
2470
2470
|
return function(t) {
|
|
2471
2471
|
return "number" == typeof t && Number.isInteger(t) && !ht(t) && t <= Number.MAX_SAFE_INTEGER && t >= Number.MIN_SAFE_INTEGER;
|
|
2472
|
-
}(
|
|
2472
|
+
}(n) ?
|
|
2473
2473
|
/**
|
|
2474
2474
|
* Returns an IntegerValue for `value`.
|
|
2475
2475
|
*/
|
|
@@ -2477,22 +2477,22 @@ function pe(t, e) {
|
|
|
2477
2477
|
return {
|
|
2478
2478
|
integerValue: "" + t
|
|
2479
2479
|
};
|
|
2480
|
-
}(
|
|
2480
|
+
}(n) : function(t, n) {
|
|
2481
2481
|
if (t.F) {
|
|
2482
|
-
if (isNaN(
|
|
2482
|
+
if (isNaN(n)) return {
|
|
2483
2483
|
doubleValue: "NaN"
|
|
2484
2484
|
};
|
|
2485
|
-
if (
|
|
2485
|
+
if (n === 1 / 0) return {
|
|
2486
2486
|
doubleValue: "Infinity"
|
|
2487
2487
|
};
|
|
2488
|
-
if (
|
|
2488
|
+
if (n === -1 / 0) return {
|
|
2489
2489
|
doubleValue: "-Infinity"
|
|
2490
2490
|
};
|
|
2491
2491
|
}
|
|
2492
2492
|
return {
|
|
2493
|
-
doubleValue: ht(
|
|
2493
|
+
doubleValue: ht(n) ? "-0" : n
|
|
2494
2494
|
};
|
|
2495
|
-
}(t,
|
|
2495
|
+
}(t, n);
|
|
2496
2496
|
}
|
|
2497
2497
|
|
|
2498
2498
|
/**
|
|
@@ -2511,7 +2511,7 @@ function pe(t, e) {
|
|
|
2511
2511
|
* See the License for the specific language governing permissions and
|
|
2512
2512
|
* limitations under the License.
|
|
2513
2513
|
*/
|
|
2514
|
-
/** Used to represent a field transform on a mutation. */ class
|
|
2514
|
+
/** Used to represent a field transform on a mutation. */ class _n {
|
|
2515
2515
|
constructor() {
|
|
2516
2516
|
// Make sure that the structural type of `TransformOperation` is unique.
|
|
2517
2517
|
// See https://github.com/microsoft/TypeScript/issues/5451
|
|
@@ -2519,15 +2519,15 @@ function pe(t, e) {
|
|
|
2519
2519
|
}
|
|
2520
2520
|
}
|
|
2521
2521
|
|
|
2522
|
-
/** Transforms a value into a server-generated timestamp. */ class
|
|
2522
|
+
/** Transforms a value into a server-generated timestamp. */ class gn extends _n {}
|
|
2523
2523
|
|
|
2524
|
-
/** Transforms an array value via a union operation. */ class
|
|
2524
|
+
/** Transforms an array value via a union operation. */ class vn extends _n {
|
|
2525
2525
|
constructor(t) {
|
|
2526
2526
|
super(), this.elements = t;
|
|
2527
2527
|
}
|
|
2528
2528
|
}
|
|
2529
2529
|
|
|
2530
|
-
/** Transforms an array value via a remove operation. */ class
|
|
2530
|
+
/** Transforms an array value via a remove operation. */ class bn extends _n {
|
|
2531
2531
|
constructor(t) {
|
|
2532
2532
|
super(), this.elements = t;
|
|
2533
2533
|
}
|
|
@@ -2538,9 +2538,9 @@ function pe(t, e) {
|
|
|
2538
2538
|
* transforms. Converts all field values to integers or doubles, but unlike the
|
|
2539
2539
|
* backend does not cap integer values at 2^63. Instead, JavaScript number
|
|
2540
2540
|
* arithmetic is used and precision loss can occur for values greater than 2^53.
|
|
2541
|
-
*/ class
|
|
2542
|
-
constructor(t,
|
|
2543
|
-
super(), this.q = t, this.O =
|
|
2541
|
+
*/ class En extends _n {
|
|
2542
|
+
constructor(t, n) {
|
|
2543
|
+
super(), this.q = t, this.O = n;
|
|
2544
2544
|
}
|
|
2545
2545
|
}
|
|
2546
2546
|
|
|
@@ -2560,9 +2560,9 @@ function pe(t, e) {
|
|
|
2560
2560
|
* See the License for the specific language governing permissions and
|
|
2561
2561
|
* limitations under the License.
|
|
2562
2562
|
*/
|
|
2563
|
-
/** A field path and the TransformOperation to perform upon it. */ class
|
|
2564
|
-
constructor(t,
|
|
2565
|
-
this.field = t, this.transform =
|
|
2563
|
+
/** A field path and the TransformOperation to perform upon it. */ class Tn {
|
|
2564
|
+
constructor(t, n) {
|
|
2565
|
+
this.field = t, this.transform = n;
|
|
2566
2566
|
}
|
|
2567
2567
|
}
|
|
2568
2568
|
|
|
@@ -2570,18 +2570,18 @@ function pe(t, e) {
|
|
|
2570
2570
|
* Encodes a precondition for a mutation. This follows the model that the
|
|
2571
2571
|
* backend accepts with the special case of an explicit "empty" precondition
|
|
2572
2572
|
* (meaning no precondition).
|
|
2573
|
-
*/ class
|
|
2574
|
-
constructor(t,
|
|
2575
|
-
this.updateTime = t, this.exists =
|
|
2573
|
+
*/ class In {
|
|
2574
|
+
constructor(t, n) {
|
|
2575
|
+
this.updateTime = t, this.exists = n;
|
|
2576
2576
|
}
|
|
2577
2577
|
/** Creates a new empty Precondition. */ static none() {
|
|
2578
|
-
return new
|
|
2578
|
+
return new In;
|
|
2579
2579
|
}
|
|
2580
2580
|
/** Creates a new Precondition with an exists flag. */ static exists(t) {
|
|
2581
|
-
return new
|
|
2581
|
+
return new In(void 0, t);
|
|
2582
2582
|
}
|
|
2583
2583
|
/** Creates a new Precondition based on a version a document exists at. */ static updateTime(t) {
|
|
2584
|
-
return new
|
|
2584
|
+
return new In(t);
|
|
2585
2585
|
}
|
|
2586
2586
|
/** Returns whether this Precondition is empty. */ get isNone() {
|
|
2587
2587
|
return void 0 === this.updateTime && void 0 === this.exists;
|
|
@@ -2634,14 +2634,14 @@ function pe(t, e) {
|
|
|
2634
2634
|
* applyToLocalView() to implement the actual behavior of applying the mutation
|
|
2635
2635
|
* to some source document (see `setMutationApplyToRemoteDocument()` for an
|
|
2636
2636
|
* example).
|
|
2637
|
-
*/ class
|
|
2637
|
+
*/ class An {}
|
|
2638
2638
|
|
|
2639
2639
|
/**
|
|
2640
2640
|
* A mutation that creates or replaces the document at the given key with the
|
|
2641
2641
|
* object value contents.
|
|
2642
|
-
*/ class
|
|
2643
|
-
constructor(t,
|
|
2644
|
-
super(), this.key = t, this.value =
|
|
2642
|
+
*/ class Rn extends An {
|
|
2643
|
+
constructor(t, n, e, r = []) {
|
|
2644
|
+
super(), this.key = t, this.value = n, this.precondition = e, this.fieldTransforms = r,
|
|
2645
2645
|
this.type = 0 /* Set */;
|
|
2646
2646
|
}
|
|
2647
2647
|
}
|
|
@@ -2658,16 +2658,16 @@ function pe(t, e) {
|
|
|
2658
2658
|
* is deleted.
|
|
2659
2659
|
* * When a field is not in the mask but is in the values, the values map is
|
|
2660
2660
|
* ignored.
|
|
2661
|
-
*/ class
|
|
2662
|
-
constructor(t,
|
|
2663
|
-
super(), this.key = t, this.data =
|
|
2661
|
+
*/ class Pn extends An {
|
|
2662
|
+
constructor(t, n, e, r, s = []) {
|
|
2663
|
+
super(), this.key = t, this.data = n, this.fieldMask = e, this.precondition = r,
|
|
2664
2664
|
this.fieldTransforms = s, this.type = 1 /* Patch */;
|
|
2665
2665
|
}
|
|
2666
2666
|
}
|
|
2667
2667
|
|
|
2668
|
-
/** A mutation that deletes the document at the given key. */ class
|
|
2669
|
-
constructor(t,
|
|
2670
|
-
super(), this.key = t, this.precondition =
|
|
2668
|
+
/** A mutation that deletes the document at the given key. */ class Vn extends An {
|
|
2669
|
+
constructor(t, n) {
|
|
2670
|
+
super(), this.key = t, this.precondition = n, this.type = 2 /* Delete */ , this.fieldTransforms = [];
|
|
2671
2671
|
}
|
|
2672
2672
|
}
|
|
2673
2673
|
|
|
@@ -2677,9 +2677,9 @@ function pe(t, e) {
|
|
|
2677
2677
|
*
|
|
2678
2678
|
* The `verify` operation is only used in Transactions, and this class serves
|
|
2679
2679
|
* primarily to facilitate serialization into protos.
|
|
2680
|
-
*/ class
|
|
2681
|
-
constructor(t,
|
|
2682
|
-
super(), this.key = t, this.precondition =
|
|
2680
|
+
*/ class Nn extends An {
|
|
2681
|
+
constructor(t, n) {
|
|
2682
|
+
super(), this.key = t, this.precondition = n, this.type = 3 /* Verify */ , this.fieldTransforms = [];
|
|
2683
2683
|
}
|
|
2684
2684
|
}
|
|
2685
2685
|
|
|
@@ -2698,13 +2698,13 @@ function pe(t, e) {
|
|
|
2698
2698
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2699
2699
|
* See the License for the specific language governing permissions and
|
|
2700
2700
|
* limitations under the License.
|
|
2701
|
-
*/ const
|
|
2701
|
+
*/ const Dn = (() => {
|
|
2702
2702
|
const t = {
|
|
2703
2703
|
asc: "ASCENDING",
|
|
2704
2704
|
desc: "DESCENDING"
|
|
2705
2705
|
};
|
|
2706
2706
|
return t;
|
|
2707
|
-
})(),
|
|
2707
|
+
})(), $n = (() => {
|
|
2708
2708
|
const t = {
|
|
2709
2709
|
"<": "LESS_THAN",
|
|
2710
2710
|
"<=": "LESS_THAN_OR_EQUAL",
|
|
@@ -2734,9 +2734,9 @@ function pe(t, e) {
|
|
|
2734
2734
|
* TODO(klimt): We can remove the databaseId argument if we keep the full
|
|
2735
2735
|
* resource name in documents.
|
|
2736
2736
|
*/
|
|
2737
|
-
class
|
|
2738
|
-
constructor(t,
|
|
2739
|
-
this.databaseId = t, this.F =
|
|
2737
|
+
class Sn {
|
|
2738
|
+
constructor(t, n) {
|
|
2739
|
+
this.databaseId = t, this.F = n;
|
|
2740
2740
|
}
|
|
2741
2741
|
}
|
|
2742
2742
|
|
|
@@ -2751,13 +2751,13 @@ class $e {
|
|
|
2751
2751
|
/**
|
|
2752
2752
|
* Returns a value for a Date that's appropriate to put into a proto.
|
|
2753
2753
|
*/
|
|
2754
|
-
function
|
|
2754
|
+
function Fn(t, n) {
|
|
2755
2755
|
if (t.F) {
|
|
2756
|
-
return `${new Date(1e3 *
|
|
2756
|
+
return `${new Date(1e3 * n.seconds).toISOString().replace(/\.\d*/, "").replace("Z", "")}.${("000000000" + n.nanoseconds).slice(-9)}Z`;
|
|
2757
2757
|
}
|
|
2758
2758
|
return {
|
|
2759
|
-
seconds: "" +
|
|
2760
|
-
nanos:
|
|
2759
|
+
seconds: "" + n.seconds,
|
|
2760
|
+
nanos: n.nanoseconds
|
|
2761
2761
|
};
|
|
2762
2762
|
}
|
|
2763
2763
|
|
|
@@ -2766,234 +2766,234 @@ function Se(t, e) {
|
|
|
2766
2766
|
*
|
|
2767
2767
|
* Visible for testing.
|
|
2768
2768
|
*/
|
|
2769
|
-
function
|
|
2770
|
-
return t.F ?
|
|
2769
|
+
function xn(t, n) {
|
|
2770
|
+
return t.F ? n.toBase64() : n.toUint8Array();
|
|
2771
2771
|
}
|
|
2772
2772
|
|
|
2773
|
-
function
|
|
2774
|
-
return
|
|
2773
|
+
function qn(t, n) {
|
|
2774
|
+
return Fn(t, n.toTimestamp());
|
|
2775
2775
|
}
|
|
2776
2776
|
|
|
2777
|
-
function
|
|
2777
|
+
function On(t) {
|
|
2778
2778
|
return b(!!t), bt.fromTimestamp(function(t) {
|
|
2779
|
-
const
|
|
2780
|
-
return new vt(
|
|
2779
|
+
const n = Vt(t);
|
|
2780
|
+
return new vt(n.seconds, n.nanos);
|
|
2781
2781
|
}(t));
|
|
2782
2782
|
}
|
|
2783
2783
|
|
|
2784
|
-
function
|
|
2784
|
+
function Cn(t, n) {
|
|
2785
2785
|
return function(t) {
|
|
2786
2786
|
return new Z([ "projects", t.projectId, "databases", t.database ]);
|
|
2787
|
-
}(t).child("documents").child(
|
|
2787
|
+
}(t).child("documents").child(n).canonicalString();
|
|
2788
2788
|
}
|
|
2789
2789
|
|
|
2790
|
-
function
|
|
2791
|
-
return
|
|
2790
|
+
function Ln(t, n) {
|
|
2791
|
+
return Cn(t.databaseId, n.path);
|
|
2792
2792
|
}
|
|
2793
2793
|
|
|
2794
|
-
function
|
|
2795
|
-
const
|
|
2796
|
-
const
|
|
2797
|
-
return b(
|
|
2798
|
-
}(
|
|
2799
|
-
if (
|
|
2800
|
-
if (
|
|
2801
|
-
return new
|
|
2794
|
+
function kn(t, n) {
|
|
2795
|
+
const e = function(t) {
|
|
2796
|
+
const n = Z.fromString(t);
|
|
2797
|
+
return b(Kn(n)), n;
|
|
2798
|
+
}(n);
|
|
2799
|
+
if (e.get(1) !== t.databaseId.projectId) throw new U(R, "Tried to deserialize key from different project: " + e.get(1) + " vs " + t.databaseId.projectId);
|
|
2800
|
+
if (e.get(3) !== t.databaseId.database) throw new U(R, "Tried to deserialize key from different database: " + e.get(3) + " vs " + t.databaseId.database);
|
|
2801
|
+
return new et((b((r = e).length > 4 && "documents" === r.get(4)), r.popFirst(5)));
|
|
2802
2802
|
var r;
|
|
2803
2803
|
/** Creates a Document proto from key and fields (but no create/update time) */}
|
|
2804
2804
|
|
|
2805
|
-
function
|
|
2806
|
-
return
|
|
2805
|
+
function Un(t, n) {
|
|
2806
|
+
return Cn(t.databaseId, n);
|
|
2807
2807
|
}
|
|
2808
2808
|
|
|
2809
|
-
function
|
|
2809
|
+
function jn(t) {
|
|
2810
2810
|
return new Z([ "projects", t.databaseId.projectId, "databases", t.databaseId.database ]).canonicalString();
|
|
2811
2811
|
}
|
|
2812
2812
|
|
|
2813
|
-
function
|
|
2813
|
+
function Mn(t, n, e) {
|
|
2814
2814
|
return {
|
|
2815
|
-
name:
|
|
2816
|
-
fields:
|
|
2815
|
+
name: Ln(t, n),
|
|
2816
|
+
fields: e.value.mapValue.fields
|
|
2817
2817
|
};
|
|
2818
2818
|
}
|
|
2819
2819
|
|
|
2820
|
-
function
|
|
2821
|
-
return "found" in
|
|
2822
|
-
b(!!
|
|
2823
|
-
const
|
|
2820
|
+
function Bn(t, n) {
|
|
2821
|
+
return "found" in n ? function(t, n) {
|
|
2822
|
+
b(!!n.found), n.found.name, n.found.updateTime;
|
|
2823
|
+
const e = kn(t, n.found.name), r = On(n.found.updateTime), s = new Gt({
|
|
2824
2824
|
mapValue: {
|
|
2825
|
-
fields:
|
|
2825
|
+
fields: n.found.fields
|
|
2826
2826
|
}
|
|
2827
2827
|
});
|
|
2828
|
-
return Qt.newFoundDocument(
|
|
2829
|
-
}(t,
|
|
2830
|
-
b(!!
|
|
2831
|
-
const
|
|
2832
|
-
return Qt.newNoDocument(
|
|
2833
|
-
}(t,
|
|
2834
|
-
}
|
|
2835
|
-
|
|
2836
|
-
function
|
|
2837
|
-
let
|
|
2838
|
-
if (
|
|
2839
|
-
update:
|
|
2840
|
-
}; else if (
|
|
2841
|
-
delete:
|
|
2842
|
-
}; else if (
|
|
2843
|
-
update:
|
|
2844
|
-
updateMask:
|
|
2828
|
+
return Qt.newFoundDocument(e, r, s);
|
|
2829
|
+
}(t, n) : "missing" in n ? function(t, n) {
|
|
2830
|
+
b(!!n.missing), b(!!n.readTime);
|
|
2831
|
+
const e = kn(t, n.missing), r = On(n.readTime);
|
|
2832
|
+
return Qt.newNoDocument(e, r);
|
|
2833
|
+
}(t, n) : v();
|
|
2834
|
+
}
|
|
2835
|
+
|
|
2836
|
+
function zn(t, n) {
|
|
2837
|
+
let e;
|
|
2838
|
+
if (n instanceof Rn) e = {
|
|
2839
|
+
update: Mn(t, n.key, n.value)
|
|
2840
|
+
}; else if (n instanceof Vn) e = {
|
|
2841
|
+
delete: Ln(t, n.key)
|
|
2842
|
+
}; else if (n instanceof Pn) e = {
|
|
2843
|
+
update: Mn(t, n.key, n.data),
|
|
2844
|
+
updateMask: Hn(n.fieldMask)
|
|
2845
2845
|
}; else {
|
|
2846
|
-
if (!(
|
|
2847
|
-
|
|
2848
|
-
verify:
|
|
2846
|
+
if (!(n instanceof Nn)) return v();
|
|
2847
|
+
e = {
|
|
2848
|
+
verify: Ln(t, n.key)
|
|
2849
2849
|
};
|
|
2850
2850
|
}
|
|
2851
|
-
return
|
|
2852
|
-
const
|
|
2853
|
-
if (
|
|
2854
|
-
fieldPath:
|
|
2851
|
+
return n.fieldTransforms.length > 0 && (e.updateTransforms = n.fieldTransforms.map((t => function(t, n) {
|
|
2852
|
+
const e = n.transform;
|
|
2853
|
+
if (e instanceof gn) return {
|
|
2854
|
+
fieldPath: n.field.canonicalString(),
|
|
2855
2855
|
setToServerValue: "REQUEST_TIME"
|
|
2856
2856
|
};
|
|
2857
|
-
if (
|
|
2858
|
-
fieldPath:
|
|
2857
|
+
if (e instanceof vn) return {
|
|
2858
|
+
fieldPath: n.field.canonicalString(),
|
|
2859
2859
|
appendMissingElements: {
|
|
2860
|
-
values:
|
|
2860
|
+
values: e.elements
|
|
2861
2861
|
}
|
|
2862
2862
|
};
|
|
2863
|
-
if (
|
|
2864
|
-
fieldPath:
|
|
2863
|
+
if (e instanceof bn) return {
|
|
2864
|
+
fieldPath: n.field.canonicalString(),
|
|
2865
2865
|
removeAllFromArray: {
|
|
2866
|
-
values:
|
|
2866
|
+
values: e.elements
|
|
2867
2867
|
}
|
|
2868
2868
|
};
|
|
2869
|
-
if (
|
|
2870
|
-
fieldPath:
|
|
2871
|
-
increment:
|
|
2869
|
+
if (e instanceof En) return {
|
|
2870
|
+
fieldPath: n.field.canonicalString(),
|
|
2871
|
+
increment: e.O
|
|
2872
2872
|
};
|
|
2873
2873
|
throw v();
|
|
2874
|
-
}(0, t)))),
|
|
2875
|
-
return void 0 !==
|
|
2876
|
-
updateTime:
|
|
2877
|
-
} : void 0 !==
|
|
2878
|
-
exists:
|
|
2874
|
+
}(0, t)))), n.precondition.isNone || (e.currentDocument = function(t, n) {
|
|
2875
|
+
return void 0 !== n.updateTime ? {
|
|
2876
|
+
updateTime: qn(t, n.updateTime)
|
|
2877
|
+
} : void 0 !== n.exists ? {
|
|
2878
|
+
exists: n.exists
|
|
2879
2879
|
} : v();
|
|
2880
|
-
}(t,
|
|
2880
|
+
}(t, n.precondition)), e;
|
|
2881
2881
|
}
|
|
2882
2882
|
|
|
2883
|
-
function
|
|
2883
|
+
function Gn(t, n) {
|
|
2884
2884
|
// Dissect the path into parent, collectionId, and optional key filter.
|
|
2885
|
-
const
|
|
2885
|
+
const e = {
|
|
2886
2886
|
structuredQuery: {}
|
|
2887
|
-
}, r =
|
|
2888
|
-
null !==
|
|
2889
|
-
collectionId:
|
|
2887
|
+
}, r = n.path;
|
|
2888
|
+
null !== n.collectionGroup ? (e.parent = Un(t, r), e.structuredQuery.from = [ {
|
|
2889
|
+
collectionId: n.collectionGroup,
|
|
2890
2890
|
allDescendants: !0
|
|
2891
|
-
} ]) : (
|
|
2891
|
+
} ]) : (e.parent = Un(t, r.popLast()), e.structuredQuery.from = [ {
|
|
2892
2892
|
collectionId: r.lastSegment()
|
|
2893
2893
|
} ]);
|
|
2894
2894
|
const s = function(t) {
|
|
2895
2895
|
if (0 === t.length) return;
|
|
2896
|
-
const
|
|
2896
|
+
const n = t.map((t =>
|
|
2897
2897
|
// visible for testing
|
|
2898
2898
|
function(t) {
|
|
2899
2899
|
if ("==" /* EQUAL */ === t.op) {
|
|
2900
2900
|
if (Mt(t.value)) return {
|
|
2901
2901
|
unaryFilter: {
|
|
2902
|
-
field:
|
|
2902
|
+
field: Yn(t.field),
|
|
2903
2903
|
op: "IS_NAN"
|
|
2904
2904
|
}
|
|
2905
2905
|
};
|
|
2906
2906
|
if (jt(t.value)) return {
|
|
2907
2907
|
unaryFilter: {
|
|
2908
|
-
field:
|
|
2908
|
+
field: Yn(t.field),
|
|
2909
2909
|
op: "IS_NULL"
|
|
2910
2910
|
}
|
|
2911
2911
|
};
|
|
2912
2912
|
} else if ("!=" /* NOT_EQUAL */ === t.op) {
|
|
2913
2913
|
if (Mt(t.value)) return {
|
|
2914
2914
|
unaryFilter: {
|
|
2915
|
-
field:
|
|
2915
|
+
field: Yn(t.field),
|
|
2916
2916
|
op: "IS_NOT_NAN"
|
|
2917
2917
|
}
|
|
2918
2918
|
};
|
|
2919
2919
|
if (jt(t.value)) return {
|
|
2920
2920
|
unaryFilter: {
|
|
2921
|
-
field:
|
|
2921
|
+
field: Yn(t.field),
|
|
2922
2922
|
op: "IS_NOT_NULL"
|
|
2923
2923
|
}
|
|
2924
2924
|
};
|
|
2925
2925
|
}
|
|
2926
2926
|
return {
|
|
2927
2927
|
fieldFilter: {
|
|
2928
|
-
field:
|
|
2929
|
-
op:
|
|
2928
|
+
field: Yn(t.field),
|
|
2929
|
+
op: Wn(t.op),
|
|
2930
2930
|
value: t.value
|
|
2931
2931
|
}
|
|
2932
2932
|
};
|
|
2933
2933
|
}(t)));
|
|
2934
|
-
if (1 ===
|
|
2934
|
+
if (1 === n.length) return n[0];
|
|
2935
2935
|
return {
|
|
2936
2936
|
compositeFilter: {
|
|
2937
2937
|
op: "AND",
|
|
2938
|
-
filters:
|
|
2938
|
+
filters: n
|
|
2939
2939
|
}
|
|
2940
2940
|
};
|
|
2941
|
-
}(
|
|
2942
|
-
s && (
|
|
2941
|
+
}(n.filters);
|
|
2942
|
+
s && (e.structuredQuery.where = s);
|
|
2943
2943
|
const i = function(t) {
|
|
2944
2944
|
if (0 === t.length) return;
|
|
2945
2945
|
return t.map((t =>
|
|
2946
2946
|
// visible for testing
|
|
2947
2947
|
function(t) {
|
|
2948
2948
|
return {
|
|
2949
|
-
field:
|
|
2950
|
-
direction:
|
|
2949
|
+
field: Yn(t.field),
|
|
2950
|
+
direction: Qn(t.dir)
|
|
2951
2951
|
};
|
|
2952
2952
|
}(t)));
|
|
2953
|
-
}(
|
|
2954
|
-
i && (
|
|
2955
|
-
const o = function(t,
|
|
2956
|
-
return t.F || at(
|
|
2957
|
-
value:
|
|
2953
|
+
}(n.orderBy);
|
|
2954
|
+
i && (e.structuredQuery.orderBy = i);
|
|
2955
|
+
const o = function(t, n) {
|
|
2956
|
+
return t.F || at(n) ? n : {
|
|
2957
|
+
value: n
|
|
2958
2958
|
};
|
|
2959
|
-
}(t,
|
|
2959
|
+
}(t, n.limit);
|
|
2960
2960
|
var u;
|
|
2961
|
-
return null !== o && (
|
|
2962
|
-
before: (u =
|
|
2961
|
+
return null !== o && (e.structuredQuery.limit = o), n.startAt && (e.structuredQuery.startAt = {
|
|
2962
|
+
before: (u = n.startAt).inclusive,
|
|
2963
2963
|
values: u.position
|
|
2964
|
-
}),
|
|
2964
|
+
}), n.endAt && (e.structuredQuery.endAt = function(t) {
|
|
2965
2965
|
return {
|
|
2966
2966
|
before: !t.inclusive,
|
|
2967
2967
|
values: t.position
|
|
2968
2968
|
};
|
|
2969
2969
|
}
|
|
2970
2970
|
// visible for testing
|
|
2971
|
-
(
|
|
2971
|
+
(n.endAt)), e;
|
|
2972
2972
|
}
|
|
2973
2973
|
|
|
2974
|
-
function
|
|
2975
|
-
return
|
|
2974
|
+
function Qn(t) {
|
|
2975
|
+
return Dn[t];
|
|
2976
2976
|
}
|
|
2977
2977
|
|
|
2978
2978
|
// visible for testing
|
|
2979
|
-
function
|
|
2980
|
-
return
|
|
2979
|
+
function Wn(t) {
|
|
2980
|
+
return $n[t];
|
|
2981
2981
|
}
|
|
2982
2982
|
|
|
2983
|
-
function
|
|
2983
|
+
function Yn(t) {
|
|
2984
2984
|
return {
|
|
2985
2985
|
fieldPath: t.canonicalString()
|
|
2986
2986
|
};
|
|
2987
2987
|
}
|
|
2988
2988
|
|
|
2989
|
-
function
|
|
2990
|
-
const
|
|
2991
|
-
return t.fields.forEach((t =>
|
|
2992
|
-
fieldPaths:
|
|
2989
|
+
function Hn(t) {
|
|
2990
|
+
const n = [];
|
|
2991
|
+
return t.fields.forEach((t => n.push(t.canonicalString()))), {
|
|
2992
|
+
fieldPaths: n
|
|
2993
2993
|
};
|
|
2994
2994
|
}
|
|
2995
2995
|
|
|
2996
|
-
function
|
|
2996
|
+
function Kn(t) {
|
|
2997
2997
|
// Resource names have at least 4 components (project ID, database ID)
|
|
2998
2998
|
return t.length >= 4 && "projects" === t.get(0) && "databases" === t.get(2);
|
|
2999
2999
|
}
|
|
@@ -3013,8 +3013,8 @@ function He(t) {
|
|
|
3013
3013
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3014
3014
|
* See the License for the specific language governing permissions and
|
|
3015
3015
|
* limitations under the License.
|
|
3016
|
-
*/ function
|
|
3017
|
-
return new
|
|
3016
|
+
*/ function Jn(t) {
|
|
3017
|
+
return new Sn(t, /* useProto3Json= */ !0);
|
|
3018
3018
|
}
|
|
3019
3019
|
|
|
3020
3020
|
/**
|
|
@@ -3042,7 +3042,7 @@ function He(t) {
|
|
|
3042
3042
|
* base delay. This prevents clients from accidentally synchronizing their
|
|
3043
3043
|
* delays causing spikes of load to the backend.
|
|
3044
3044
|
*/
|
|
3045
|
-
class
|
|
3045
|
+
class Xn {
|
|
3046
3046
|
constructor(
|
|
3047
3047
|
/**
|
|
3048
3048
|
* The AsyncQueue to run backoff operations on.
|
|
@@ -3051,13 +3051,13 @@ class Je {
|
|
|
3051
3051
|
/**
|
|
3052
3052
|
* The ID to use when scheduling backoff operations on the AsyncQueue.
|
|
3053
3053
|
*/
|
|
3054
|
-
|
|
3054
|
+
n,
|
|
3055
3055
|
/**
|
|
3056
3056
|
* The initial delay (used as the base delay on the first retry attempt).
|
|
3057
3057
|
* Note that jitter will still be applied, so the actual delay could be as
|
|
3058
3058
|
* little as 0.5*initialDelayMs.
|
|
3059
3059
|
*/
|
|
3060
|
-
|
|
3060
|
+
e = 1e3
|
|
3061
3061
|
/**
|
|
3062
3062
|
* The multiplier to use to determine the extended base delay after each
|
|
3063
3063
|
* attempt.
|
|
@@ -3067,7 +3067,7 @@ class Je {
|
|
|
3067
3067
|
* Note that jitter will still be applied, so the actual delay could be as
|
|
3068
3068
|
* much as 1.5*maxDelayMs.
|
|
3069
3069
|
*/ , s = 6e4) {
|
|
3070
|
-
this.C = t, this.timerId =
|
|
3070
|
+
this.C = t, this.timerId = n, this.L = e, this.k = r, this.U = s, this.j = 0, this.M = null,
|
|
3071
3071
|
/** The last backoff attempt, as epoch milliseconds. */
|
|
3072
3072
|
this.B = Date.now(), this.reset();
|
|
3073
3073
|
}
|
|
@@ -3095,9 +3095,9 @@ class Je {
|
|
|
3095
3095
|
this.cancel();
|
|
3096
3096
|
// First schedule using the current base (which may be 0 and should be
|
|
3097
3097
|
// honored as such).
|
|
3098
|
-
const
|
|
3098
|
+
const n = Math.floor(this.j + this.Y()), e = Math.max(0, Date.now() - this.B), r = Math.max(0, n - e);
|
|
3099
3099
|
// Guard against lastAttemptTime being in the future due to a clock change.
|
|
3100
|
-
r > 0 && p("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.j} ms, delay with jitter: ${
|
|
3100
|
+
r > 0 && p("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.j} ms, delay with jitter: ${n} ms, last attempt: ${e} ms ago)`),
|
|
3101
3101
|
this.M = this.C.enqueueAfterDelay(this.timerId, r, (() => (this.B = Date.now(),
|
|
3102
3102
|
t()))),
|
|
3103
3103
|
// Apply backoff factor to determine next delay and ensure it is within
|
|
@@ -3140,22 +3140,22 @@ class Je {
|
|
|
3140
3140
|
* An implementation of Datastore that exposes additional state for internal
|
|
3141
3141
|
* consumption.
|
|
3142
3142
|
*/
|
|
3143
|
-
class
|
|
3144
|
-
constructor(t,
|
|
3145
|
-
super(), this.authCredentials = t, this.appCheckCredentials =
|
|
3143
|
+
class Zn extends class {} {
|
|
3144
|
+
constructor(t, n, e, r) {
|
|
3145
|
+
super(), this.authCredentials = t, this.appCheckCredentials = n, this.K = e, this.q = r,
|
|
3146
3146
|
this.J = !1;
|
|
3147
3147
|
}
|
|
3148
3148
|
X() {
|
|
3149
3149
|
if (this.J) throw new U(F, "The client has already been terminated.");
|
|
3150
3150
|
}
|
|
3151
|
-
/** Invokes the provided RPC with auth and AppCheck tokens. */ m(t,
|
|
3152
|
-
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.m(t,
|
|
3151
|
+
/** Invokes the provided RPC with auth and AppCheck tokens. */ m(t, n, e) {
|
|
3152
|
+
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.m(t, n, e, r, s))).catch((t => {
|
|
3153
3153
|
throw "FirebaseError" === t.name ? (t.code === $ && (this.authCredentials.invalidateToken(),
|
|
3154
3154
|
this.appCheckCredentials.invalidateToken()), t) : new U(A, t.toString());
|
|
3155
3155
|
}));
|
|
3156
3156
|
}
|
|
3157
|
-
/** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */ T(t,
|
|
3158
|
-
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.T(t,
|
|
3157
|
+
/** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */ T(t, n, e) {
|
|
3158
|
+
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.T(t, n, e, r, s))).catch((t => {
|
|
3159
3159
|
throw "FirebaseError" === t.name ? (t.code === $ && (this.authCredentials.invalidateToken(),
|
|
3160
3160
|
this.appCheckCredentials.invalidateToken()), t) : new U(A, t.toString());
|
|
3161
3161
|
}));
|
|
@@ -3167,40 +3167,40 @@ class Xe extends class {} {
|
|
|
3167
3167
|
|
|
3168
3168
|
// TODO(firestorexp): Make sure there is only one Datastore instance per
|
|
3169
3169
|
// firestore-exp client.
|
|
3170
|
-
async function
|
|
3171
|
-
const
|
|
3172
|
-
writes:
|
|
3170
|
+
async function te(t, n) {
|
|
3171
|
+
const e = E(t), r = jn(e.q) + "/documents", s = {
|
|
3172
|
+
writes: n.map((t => zn(e.q, t)))
|
|
3173
3173
|
};
|
|
3174
|
-
await
|
|
3174
|
+
await e.m("Commit", r, s);
|
|
3175
3175
|
}
|
|
3176
3176
|
|
|
3177
|
-
async function
|
|
3178
|
-
const
|
|
3179
|
-
documents:
|
|
3180
|
-
}, i = await
|
|
3177
|
+
async function ne(t, n) {
|
|
3178
|
+
const e = E(t), r = jn(e.q) + "/documents", s = {
|
|
3179
|
+
documents: n.map((t => Ln(e.q, t)))
|
|
3180
|
+
}, i = await e.T("BatchGetDocuments", r, s), o = new Map;
|
|
3181
3181
|
i.forEach((t => {
|
|
3182
|
-
const
|
|
3183
|
-
o.set(
|
|
3182
|
+
const n = Bn(e.q, t);
|
|
3183
|
+
o.set(n.key.toString(), n);
|
|
3184
3184
|
}));
|
|
3185
3185
|
const u = [];
|
|
3186
|
-
return
|
|
3187
|
-
const
|
|
3188
|
-
b(!!
|
|
3186
|
+
return n.forEach((t => {
|
|
3187
|
+
const n = o.get(t.toString());
|
|
3188
|
+
b(!!n), u.push(n);
|
|
3189
3189
|
})), u;
|
|
3190
3190
|
}
|
|
3191
3191
|
|
|
3192
|
-
async function
|
|
3193
|
-
const
|
|
3194
|
-
return (await
|
|
3192
|
+
async function ee(t, n) {
|
|
3193
|
+
const e = E(t), r = Gn(e.q, mn(n));
|
|
3194
|
+
return (await e.T("RunQuery", r.parent, {
|
|
3195
3195
|
structuredQuery: r.structuredQuery
|
|
3196
|
-
})).filter((t => !!t.document)).map((t => function(t,
|
|
3197
|
-
const r =
|
|
3196
|
+
})).filter((t => !!t.document)).map((t => function(t, n, e) {
|
|
3197
|
+
const r = kn(t, n.name), s = On(n.updateTime), i = new Gt({
|
|
3198
3198
|
mapValue: {
|
|
3199
|
-
fields:
|
|
3199
|
+
fields: n.fields
|
|
3200
3200
|
}
|
|
3201
3201
|
}), o = Qt.newFoundDocument(r, s, i);
|
|
3202
|
-
return
|
|
3203
|
-
}(
|
|
3202
|
+
return e && o.setHasCommittedMutations(), e ? o.setHasCommittedMutations() : o;
|
|
3203
|
+
}(e.q, t.document, void 0)));
|
|
3204
3204
|
}
|
|
3205
3205
|
|
|
3206
3206
|
/**
|
|
@@ -3218,7 +3218,7 @@ async function en(t, e) {
|
|
|
3218
3218
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3219
3219
|
* See the License for the specific language governing permissions and
|
|
3220
3220
|
* limitations under the License.
|
|
3221
|
-
*/ const
|
|
3221
|
+
*/ const re = new Map;
|
|
3222
3222
|
|
|
3223
3223
|
/**
|
|
3224
3224
|
* An instance map that ensures only one Datastore exists per Firestore
|
|
@@ -3229,19 +3229,19 @@ async function en(t, e) {
|
|
|
3229
3229
|
* instance. Callers must invoke removeComponents() when the Firestore
|
|
3230
3230
|
* instance is terminated.
|
|
3231
3231
|
*/
|
|
3232
|
-
function
|
|
3232
|
+
function se(t) {
|
|
3233
3233
|
if (t._terminated) throw new U(F, "The client has already been terminated.");
|
|
3234
|
-
if (!
|
|
3234
|
+
if (!re.has(t)) {
|
|
3235
3235
|
p("ComponentProvider", "Initializing Datastore");
|
|
3236
3236
|
const i = function(t) {
|
|
3237
3237
|
return new mt(t, fetch.bind(null));
|
|
3238
|
-
}((
|
|
3239
|
-
new K(
|
|
3240
|
-
return new
|
|
3238
|
+
}((n = t._databaseId, e = t.app.options.appId || "", r = t._persistenceKey, s = t._freezeSettings(),
|
|
3239
|
+
new K(n, e, r, s.host, s.ssl, s.experimentalForceLongPolling, s.experimentalAutoDetectLongPolling, s.useFetchStreams))), o = Jn(t._databaseId), u = function(t, n, e, r) {
|
|
3240
|
+
return new Zn(t, n, e, r);
|
|
3241
3241
|
}(t._authCredentials, t._appCheckCredentials, i, o);
|
|
3242
|
-
|
|
3242
|
+
re.set(t, u);
|
|
3243
3243
|
}
|
|
3244
|
-
var
|
|
3244
|
+
var n, e, r, s;
|
|
3245
3245
|
/**
|
|
3246
3246
|
* @license
|
|
3247
3247
|
* Copyright 2018 Google LLC
|
|
@@ -3257,7 +3257,7 @@ function rn(t) {
|
|
|
3257
3257
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3258
3258
|
* See the License for the specific language governing permissions and
|
|
3259
3259
|
* limitations under the License.
|
|
3260
|
-
*/ return
|
|
3260
|
+
*/ return re.get(t);
|
|
3261
3261
|
}
|
|
3262
3262
|
|
|
3263
3263
|
/**
|
|
@@ -3269,21 +3269,21 @@ function rn(t) {
|
|
|
3269
3269
|
* user-supplied `FirestoreSettings` object. This is a separate type so that
|
|
3270
3270
|
* defaults can be supplied and the value can be checked for equality.
|
|
3271
3271
|
*/
|
|
3272
|
-
class
|
|
3272
|
+
class ie {
|
|
3273
3273
|
constructor(t) {
|
|
3274
|
-
var
|
|
3274
|
+
var n;
|
|
3275
3275
|
if (void 0 === t.host) {
|
|
3276
3276
|
if (void 0 !== t.ssl) throw new U(R, "Can't provide ssl option if host option is not set");
|
|
3277
3277
|
this.host = "firestore.googleapis.com", this.ssl = true;
|
|
3278
|
-
} else this.host = t.host, this.ssl = null === (
|
|
3278
|
+
} else this.host = t.host, this.ssl = null === (n = t.ssl) || void 0 === n || n;
|
|
3279
3279
|
if (this.credentials = t.credentials, this.ignoreUndefinedProperties = !!t.ignoreUndefinedProperties,
|
|
3280
3280
|
void 0 === t.cacheSizeBytes) this.cacheSizeBytes = 41943040; else {
|
|
3281
3281
|
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new U(R, "cacheSizeBytes must be at least 1048576");
|
|
3282
3282
|
this.cacheSizeBytes = t.cacheSizeBytes;
|
|
3283
3283
|
}
|
|
3284
3284
|
this.experimentalForceLongPolling = !!t.experimentalForceLongPolling, this.experimentalAutoDetectLongPolling = !!t.experimentalAutoDetectLongPolling,
|
|
3285
|
-
this.useFetchStreams = !!t.useFetchStreams, function(t,
|
|
3286
|
-
if (!0 ===
|
|
3285
|
+
this.useFetchStreams = !!t.useFetchStreams, function(t, n, e, r) {
|
|
3286
|
+
if (!0 === n && !0 === r) throw new U(R, `${t} and ${e} cannot be used together.`);
|
|
3287
3287
|
}("experimentalForceLongPolling", t.experimentalForceLongPolling, "experimentalAutoDetectLongPolling", t.experimentalAutoDetectLongPolling);
|
|
3288
3288
|
}
|
|
3289
3289
|
isEqual(t) {
|
|
@@ -3311,14 +3311,14 @@ class sn {
|
|
|
3311
3311
|
* The Cloud Firestore service interface.
|
|
3312
3312
|
*
|
|
3313
3313
|
* Do not call this constructor directly. Instead, use {@link getFirestore}.
|
|
3314
|
-
*/ class
|
|
3314
|
+
*/ class oe {
|
|
3315
3315
|
/** @hideconstructor */
|
|
3316
|
-
constructor(t,
|
|
3317
|
-
this._authCredentials =
|
|
3316
|
+
constructor(t, n, e) {
|
|
3317
|
+
this._authCredentials = n, this._appCheckCredentials = e,
|
|
3318
3318
|
/**
|
|
3319
3319
|
* Whether it's a Firestore or Firestore Lite instance.
|
|
3320
3320
|
*/
|
|
3321
|
-
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new
|
|
3321
|
+
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new ie({}),
|
|
3322
3322
|
this._settingsFrozen = !1, t instanceof J ? this._databaseId = t : (this._app = t,
|
|
3323
3323
|
this._databaseId = function(t) {
|
|
3324
3324
|
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new U(R, '"projectId" not provided in firebase.initializeApp.');
|
|
@@ -3351,14 +3351,14 @@ class sn {
|
|
|
3351
3351
|
}
|
|
3352
3352
|
_setSettings(t) {
|
|
3353
3353
|
if (this._settingsFrozen) throw new U(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.");
|
|
3354
|
-
this._settings = new
|
|
3354
|
+
this._settings = new ie(t), void 0 !== t.credentials && (this._authCredentials = function(t) {
|
|
3355
3355
|
if (!t) return new B;
|
|
3356
3356
|
switch (t.type) {
|
|
3357
3357
|
case "gapi":
|
|
3358
|
-
const
|
|
3358
|
+
const n = t.client;
|
|
3359
3359
|
// Make sure this really is a Gapi client.
|
|
3360
|
-
return b(!("object" != typeof
|
|
3361
|
-
new W(
|
|
3360
|
+
return b(!("object" != typeof n || null === n || !n.auth || !n.auth.getAuthHeaderValueForFirstParty)),
|
|
3361
|
+
new W(n, t.sessionIndex || "0", t.iamToken || null);
|
|
3362
3362
|
|
|
3363
3363
|
case "provider":
|
|
3364
3364
|
return t.client;
|
|
@@ -3392,17 +3392,17 @@ class sn {
|
|
|
3392
3392
|
* Only ever called once.
|
|
3393
3393
|
*/ _terminate() {
|
|
3394
3394
|
return function(t) {
|
|
3395
|
-
const
|
|
3396
|
-
|
|
3395
|
+
const n = re.get(t);
|
|
3396
|
+
n && (p("ComponentProvider", "Removing Datastore"), re.delete(t), n.terminate());
|
|
3397
3397
|
}(this), Promise.resolve();
|
|
3398
3398
|
}
|
|
3399
3399
|
}
|
|
3400
3400
|
|
|
3401
|
-
function
|
|
3402
|
-
const
|
|
3403
|
-
if (
|
|
3404
|
-
return
|
|
3405
|
-
options:
|
|
3401
|
+
function ue(t, n) {
|
|
3402
|
+
const e = _getProvider(t, "firestore/lite");
|
|
3403
|
+
if (e.isInitialized()) throw new U(F, "Firestore can only be initialized once per app.");
|
|
3404
|
+
return e.initialize({
|
|
3405
|
+
options: n
|
|
3406
3406
|
});
|
|
3407
3407
|
}
|
|
3408
3408
|
|
|
@@ -3414,8 +3414,8 @@ function un(t, e) {
|
|
|
3414
3414
|
* @param app - The {@link @firebase/app#FirebaseApp} instance that the returned `Firestore`
|
|
3415
3415
|
* instance is associated with.
|
|
3416
3416
|
* @returns The `Firestore` instance of the provided app.
|
|
3417
|
-
*/ function
|
|
3418
|
-
return _getProvider(
|
|
3417
|
+
*/ function ce(n = t()) {
|
|
3418
|
+
return _getProvider(n, "firestore/lite").getImmediate();
|
|
3419
3419
|
}
|
|
3420
3420
|
|
|
3421
3421
|
/**
|
|
@@ -3430,24 +3430,24 @@ function un(t, e) {
|
|
|
3430
3430
|
* @param port - the emulator port (ex: 9000).
|
|
3431
3431
|
* @param options.mockUserToken - the mock auth token to use for unit testing
|
|
3432
3432
|
* Security Rules.
|
|
3433
|
-
*/ function
|
|
3433
|
+
*/ function ae(t, n, e, r = {}) {
|
|
3434
3434
|
var s;
|
|
3435
|
-
const i = (t = ut(t,
|
|
3436
|
-
if ("firestore.googleapis.com" !== i.host && i.host !==
|
|
3435
|
+
const i = (t = ut(t, oe))._getSettings();
|
|
3436
|
+
if ("firestore.googleapis.com" !== i.host && i.host !== n && _("Host has been set in both settings() and useEmulator(), emulator host will be used"),
|
|
3437
3437
|
t._setSettings(Object.assign(Object.assign({}, i), {
|
|
3438
|
-
host: `${
|
|
3438
|
+
host: `${n}:${e}`,
|
|
3439
3439
|
ssl: !1
|
|
3440
3440
|
})), r.mockUserToken) {
|
|
3441
|
-
let
|
|
3442
|
-
if ("string" == typeof r.mockUserToken)
|
|
3441
|
+
let n, e;
|
|
3442
|
+
if ("string" == typeof r.mockUserToken) n = r.mockUserToken, e = f.MOCK_USER; else {
|
|
3443
3443
|
// Let createMockUserToken validate first (catches common mistakes like
|
|
3444
3444
|
// invalid field "uid" and missing field "sub" / "user_id".)
|
|
3445
|
-
|
|
3445
|
+
n = h(r.mockUserToken, null === (s = t._app) || void 0 === s ? void 0 : s.options.projectId);
|
|
3446
3446
|
const i = r.mockUserToken.sub || r.mockUserToken.user_id;
|
|
3447
3447
|
if (!i) throw new U(R, "mockUserToken must contain 'sub' or 'user_id' field!");
|
|
3448
|
-
|
|
3448
|
+
e = new f(i);
|
|
3449
3449
|
}
|
|
3450
|
-
t._authCredentials = new z(new M(
|
|
3450
|
+
t._authCredentials = new z(new M(n, e));
|
|
3451
3451
|
}
|
|
3452
3452
|
}
|
|
3453
3453
|
|
|
@@ -3470,8 +3470,8 @@ function un(t, e) {
|
|
|
3470
3470
|
* @param firestore - The `Firestore` instance to terminate.
|
|
3471
3471
|
* @returns A `Promise` that is resolved when the instance has been successfully
|
|
3472
3472
|
* terminated.
|
|
3473
|
-
*/ function
|
|
3474
|
-
return t = ut(t,
|
|
3473
|
+
*/ function he(t) {
|
|
3474
|
+
return t = ut(t, oe), n(t.app, "firestore/lite"), t._delete();
|
|
3475
3475
|
}
|
|
3476
3476
|
|
|
3477
3477
|
/**
|
|
@@ -3511,14 +3511,14 @@ function un(t, e) {
|
|
|
3511
3511
|
* and can be used to write, read, or listen to the location. The document at
|
|
3512
3512
|
* the referenced location may or may not exist.
|
|
3513
3513
|
*/
|
|
3514
|
-
class
|
|
3514
|
+
class le {
|
|
3515
3515
|
/** @hideconstructor */
|
|
3516
3516
|
constructor(t,
|
|
3517
3517
|
/**
|
|
3518
3518
|
* If provided, the `FirestoreDataConverter` associated with this instance.
|
|
3519
3519
|
*/
|
|
3520
|
-
|
|
3521
|
-
this.converter =
|
|
3520
|
+
n, e) {
|
|
3521
|
+
this.converter = n, this._key = e,
|
|
3522
3522
|
/** The type of this Firestore reference. */
|
|
3523
3523
|
this.type = "document", this.firestore = t;
|
|
3524
3524
|
}
|
|
@@ -3539,40 +3539,40 @@ class ln {
|
|
|
3539
3539
|
/**
|
|
3540
3540
|
* The collection this `DocumentReference` belongs to.
|
|
3541
3541
|
*/ get parent() {
|
|
3542
|
-
return new
|
|
3542
|
+
return new de(this.firestore, this.converter, this._key.path.popLast());
|
|
3543
3543
|
}
|
|
3544
3544
|
withConverter(t) {
|
|
3545
|
-
return new
|
|
3545
|
+
return new le(this.firestore, t, this._key);
|
|
3546
3546
|
}
|
|
3547
3547
|
}
|
|
3548
3548
|
|
|
3549
3549
|
/**
|
|
3550
3550
|
* A `Query` refers to a query which you can read or listen to. You can also
|
|
3551
3551
|
* construct refined `Query` objects by adding filters and ordering.
|
|
3552
|
-
*/ class
|
|
3552
|
+
*/ class fe {
|
|
3553
3553
|
// This is the lite version of the Query class in the main SDK.
|
|
3554
3554
|
/** @hideconstructor protected */
|
|
3555
3555
|
constructor(t,
|
|
3556
3556
|
/**
|
|
3557
3557
|
* If provided, the `FirestoreDataConverter` associated with this instance.
|
|
3558
3558
|
*/
|
|
3559
|
-
|
|
3560
|
-
this.converter =
|
|
3559
|
+
n, e) {
|
|
3560
|
+
this.converter = n, this._query = e,
|
|
3561
3561
|
/** The type of this Firestore reference. */
|
|
3562
3562
|
this.type = "query", this.firestore = t;
|
|
3563
3563
|
}
|
|
3564
3564
|
withConverter(t) {
|
|
3565
|
-
return new
|
|
3565
|
+
return new fe(this.firestore, t, this._query);
|
|
3566
3566
|
}
|
|
3567
3567
|
}
|
|
3568
3568
|
|
|
3569
3569
|
/**
|
|
3570
3570
|
* A `CollectionReference` object can be used for adding documents, getting
|
|
3571
3571
|
* document references, and querying for documents (using {@link query}).
|
|
3572
|
-
*/ class
|
|
3572
|
+
*/ class de extends fe {
|
|
3573
3573
|
/** @hideconstructor */
|
|
3574
|
-
constructor(t,
|
|
3575
|
-
super(t,
|
|
3574
|
+
constructor(t, n, e) {
|
|
3575
|
+
super(t, n, new an(e)), this._path = e,
|
|
3576
3576
|
/** The type of this Firestore reference. */
|
|
3577
3577
|
this.type = "collection";
|
|
3578
3578
|
}
|
|
@@ -3590,23 +3590,23 @@ class ln {
|
|
|
3590
3590
|
* subcollection. If this isn't a subcollection, the reference is null.
|
|
3591
3591
|
*/ get parent() {
|
|
3592
3592
|
const t = this._path.popLast();
|
|
3593
|
-
return t.isEmpty() ? null : new
|
|
3594
|
-
/* converter= */ null, new
|
|
3593
|
+
return t.isEmpty() ? null : new le(this.firestore,
|
|
3594
|
+
/* converter= */ null, new et(t));
|
|
3595
3595
|
}
|
|
3596
3596
|
withConverter(t) {
|
|
3597
|
-
return new
|
|
3597
|
+
return new de(this.firestore, t, this._path);
|
|
3598
3598
|
}
|
|
3599
3599
|
}
|
|
3600
3600
|
|
|
3601
|
-
function
|
|
3602
|
-
if (t = l(t), rt("collection", "path",
|
|
3603
|
-
const r = Z.fromString(
|
|
3604
|
-
return it(r), new
|
|
3601
|
+
function we(t, n, ...e) {
|
|
3602
|
+
if (t = l(t), rt("collection", "path", n), t instanceof oe) {
|
|
3603
|
+
const r = Z.fromString(n, ...e);
|
|
3604
|
+
return it(r), new de(t, /* converter= */ null, r);
|
|
3605
3605
|
}
|
|
3606
3606
|
{
|
|
3607
|
-
if (!(t instanceof
|
|
3608
|
-
const r = t._path.child(Z.fromString(
|
|
3609
|
-
return it(r), new
|
|
3607
|
+
if (!(t instanceof le || t instanceof de)) throw new U(R, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3608
|
+
const r = t._path.child(Z.fromString(n, ...e));
|
|
3609
|
+
return it(r), new de(t.firestore,
|
|
3610
3610
|
/* converter= */ null, r);
|
|
3611
3611
|
}
|
|
3612
3612
|
}
|
|
@@ -3623,32 +3623,32 @@ function wn(t, e, ...n) {
|
|
|
3623
3623
|
* collection or subcollection with this ID as the last segment of its path
|
|
3624
3624
|
* will be included. Cannot contain a slash.
|
|
3625
3625
|
* @returns The created `Query`.
|
|
3626
|
-
*/ function
|
|
3627
|
-
if (t = ut(t,
|
|
3628
|
-
return new
|
|
3626
|
+
*/ function me(t, n) {
|
|
3627
|
+
if (t = ut(t, oe), rt("collectionGroup", "collection id", n), n.indexOf("/") >= 0) throw new U(R, `Invalid collection ID '${n}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);
|
|
3628
|
+
return new fe(t,
|
|
3629
3629
|
/* converter= */ null,
|
|
3630
3630
|
/**
|
|
3631
3631
|
* Creates a new Query for a collection group query that matches all documents
|
|
3632
3632
|
* within the provided collection group.
|
|
3633
3633
|
*/
|
|
3634
3634
|
function(t) {
|
|
3635
|
-
return new
|
|
3636
|
-
}(
|
|
3635
|
+
return new an(Z.emptyPath(), t);
|
|
3636
|
+
}(n));
|
|
3637
3637
|
}
|
|
3638
3638
|
|
|
3639
|
-
function
|
|
3639
|
+
function pe(t, n, ...e) {
|
|
3640
3640
|
if (t = l(t),
|
|
3641
3641
|
// We allow omission of 'pathString' but explicitly prohibit passing in both
|
|
3642
3642
|
// 'undefined' and 'null'.
|
|
3643
|
-
1 === arguments.length && (
|
|
3644
|
-
const r = Z.fromString(
|
|
3645
|
-
return st(r), new
|
|
3646
|
-
/* converter= */ null, new
|
|
3643
|
+
1 === arguments.length && (n = yt.R()), rt("doc", "path", n), t instanceof oe) {
|
|
3644
|
+
const r = Z.fromString(n, ...e);
|
|
3645
|
+
return st(r), new le(t,
|
|
3646
|
+
/* converter= */ null, new et(r));
|
|
3647
3647
|
}
|
|
3648
3648
|
{
|
|
3649
|
-
if (!(t instanceof
|
|
3650
|
-
const r = t._path.child(Z.fromString(
|
|
3651
|
-
return st(r), new
|
|
3649
|
+
if (!(t instanceof le || t instanceof de)) throw new U(R, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3650
|
+
const r = t._path.child(Z.fromString(n, ...e));
|
|
3651
|
+
return st(r), new le(t.firestore, t instanceof de ? t.converter : null, new et(r));
|
|
3652
3652
|
}
|
|
3653
3653
|
}
|
|
3654
3654
|
|
|
@@ -3659,8 +3659,8 @@ function pn(t, e, ...n) {
|
|
|
3659
3659
|
* @param right - A reference to compare.
|
|
3660
3660
|
* @returns true if the references point to the same location in the same
|
|
3661
3661
|
* Firestore database.
|
|
3662
|
-
*/ function
|
|
3663
|
-
return t = l(t),
|
|
3662
|
+
*/ function ye(t, n) {
|
|
3663
|
+
return t = l(t), n = l(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);
|
|
3664
3664
|
}
|
|
3665
3665
|
|
|
3666
3666
|
/**
|
|
@@ -3671,8 +3671,8 @@ function pn(t, e, ...n) {
|
|
|
3671
3671
|
* @param right - A `Query` to compare.
|
|
3672
3672
|
* @returns true if the references point to the same location in the same
|
|
3673
3673
|
* Firestore database.
|
|
3674
|
-
*/ function
|
|
3675
|
-
return t = l(t),
|
|
3674
|
+
*/ function _e(t, n) {
|
|
3675
|
+
return t = l(t), n = l(n), t instanceof fe && n instanceof fe && (t.firestore === n.firestore && pn(t._query, n._query) && t.converter === n.converter);
|
|
3676
3676
|
}
|
|
3677
3677
|
|
|
3678
3678
|
/**
|
|
@@ -3698,7 +3698,7 @@ function pn(t, e, ...n) {
|
|
|
3698
3698
|
*
|
|
3699
3699
|
* Create a `FieldPath` by providing field names. If more than one field
|
|
3700
3700
|
* name is provided, the path will point to a nested field in a document.
|
|
3701
|
-
*/ class
|
|
3701
|
+
*/ class ge {
|
|
3702
3702
|
/**
|
|
3703
3703
|
* Creates a `FieldPath` from the provided field names. If more than one field
|
|
3704
3704
|
* name is provided, the path will point to a nested field in a document.
|
|
@@ -3706,8 +3706,8 @@ function pn(t, e, ...n) {
|
|
|
3706
3706
|
* @param fieldNames - A list of field names.
|
|
3707
3707
|
*/
|
|
3708
3708
|
constructor(...t) {
|
|
3709
|
-
for (let
|
|
3710
|
-
this._internalPath = new
|
|
3709
|
+
for (let n = 0; n < t.length; ++n) if (0 === t[n].length) throw new U(R, "Invalid field name at argument $(i + 1). Field names must not be empty.");
|
|
3710
|
+
this._internalPath = new nt(t);
|
|
3711
3711
|
}
|
|
3712
3712
|
/**
|
|
3713
3713
|
* Returns true if this `FieldPath` is equal to the provided one.
|
|
@@ -3722,8 +3722,8 @@ function pn(t, e, ...n) {
|
|
|
3722
3722
|
/**
|
|
3723
3723
|
* Returns a special sentinel `FieldPath` to refer to the ID of a document.
|
|
3724
3724
|
* It can be used in queries to sort or filter by the document ID.
|
|
3725
|
-
*/ function
|
|
3726
|
-
return new
|
|
3725
|
+
*/ function ve() {
|
|
3726
|
+
return new ge("__name__");
|
|
3727
3727
|
}
|
|
3728
3728
|
|
|
3729
3729
|
/**
|
|
@@ -3744,7 +3744,7 @@ function pn(t, e, ...n) {
|
|
|
3744
3744
|
*/
|
|
3745
3745
|
/**
|
|
3746
3746
|
* An immutable object representing an array of bytes.
|
|
3747
|
-
*/ class
|
|
3747
|
+
*/ class be {
|
|
3748
3748
|
/** @hideconstructor */
|
|
3749
3749
|
constructor(t) {
|
|
3750
3750
|
this._byteString = t;
|
|
@@ -3756,7 +3756,7 @@ function pn(t, e, ...n) {
|
|
|
3756
3756
|
* @param base64 - The Base64 string used to create the `Bytes` object.
|
|
3757
3757
|
*/ static fromBase64String(t) {
|
|
3758
3758
|
try {
|
|
3759
|
-
return new
|
|
3759
|
+
return new be(Rt.fromBase64String(t));
|
|
3760
3760
|
} catch (t) {
|
|
3761
3761
|
throw new U(R, "Failed to construct data from Base64 string: " + t);
|
|
3762
3762
|
}
|
|
@@ -3766,7 +3766,7 @@ function pn(t, e, ...n) {
|
|
|
3766
3766
|
*
|
|
3767
3767
|
* @param array - The Uint8Array used to create the `Bytes` object.
|
|
3768
3768
|
*/ static fromUint8Array(t) {
|
|
3769
|
-
return new
|
|
3769
|
+
return new be(Rt.fromUint8Array(t));
|
|
3770
3770
|
}
|
|
3771
3771
|
/**
|
|
3772
3772
|
* Returns the underlying bytes as a Base64-encoded string.
|
|
@@ -3818,7 +3818,7 @@ function pn(t, e, ...n) {
|
|
|
3818
3818
|
/**
|
|
3819
3819
|
* Sentinel values that can be used when writing document fields with `set()`
|
|
3820
3820
|
* or `update()`.
|
|
3821
|
-
*/ class
|
|
3821
|
+
*/ class Ee {
|
|
3822
3822
|
/**
|
|
3823
3823
|
* @param _methodName - The public API endpoint that returns this class.
|
|
3824
3824
|
* @hideconstructor
|
|
@@ -3850,17 +3850,17 @@ function pn(t, e, ...n) {
|
|
|
3850
3850
|
*
|
|
3851
3851
|
* Latitude values are in the range of [-90, 90].
|
|
3852
3852
|
* Longitude values are in the range of [-180, 180].
|
|
3853
|
-
*/ class
|
|
3853
|
+
*/ class Te {
|
|
3854
3854
|
/**
|
|
3855
3855
|
* Creates a new immutable `GeoPoint` object with the provided latitude and
|
|
3856
3856
|
* longitude values.
|
|
3857
3857
|
* @param latitude - The latitude as number between -90 and 90.
|
|
3858
3858
|
* @param longitude - The longitude as number between -180 and 180.
|
|
3859
3859
|
*/
|
|
3860
|
-
constructor(t,
|
|
3860
|
+
constructor(t, n) {
|
|
3861
3861
|
if (!isFinite(t) || t < -90 || t > 90) throw new U(R, "Latitude must be a number between -90 and 90, but was: " + t);
|
|
3862
|
-
if (!isFinite(
|
|
3863
|
-
this._lat = t, this._long =
|
|
3862
|
+
if (!isFinite(n) || n < -180 || n > 180) throw new U(R, "Longitude must be a number between -180 and 180, but was: " + n);
|
|
3863
|
+
this._lat = t, this._long = n;
|
|
3864
3864
|
}
|
|
3865
3865
|
/**
|
|
3866
3866
|
* The latitude of this `GeoPoint` instance.
|
|
@@ -3909,29 +3909,29 @@ function pn(t, e, ...n) {
|
|
|
3909
3909
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3910
3910
|
* See the License for the specific language governing permissions and
|
|
3911
3911
|
* limitations under the License.
|
|
3912
|
-
*/ const
|
|
3912
|
+
*/ const Ie = /^__.*__$/;
|
|
3913
3913
|
|
|
3914
|
-
/** The result of parsing document data (e.g. for a setData call). */ class
|
|
3915
|
-
constructor(t,
|
|
3916
|
-
this.data = t, this.fieldMask =
|
|
3914
|
+
/** The result of parsing document data (e.g. for a setData call). */ class Ae {
|
|
3915
|
+
constructor(t, n, e) {
|
|
3916
|
+
this.data = t, this.fieldMask = n, this.fieldTransforms = e;
|
|
3917
3917
|
}
|
|
3918
|
-
toMutation(t,
|
|
3919
|
-
return null !== this.fieldMask ? new
|
|
3918
|
+
toMutation(t, n) {
|
|
3919
|
+
return null !== this.fieldMask ? new Pn(t, this.data, this.fieldMask, n, this.fieldTransforms) : new Rn(t, this.data, n, this.fieldTransforms);
|
|
3920
3920
|
}
|
|
3921
3921
|
}
|
|
3922
3922
|
|
|
3923
|
-
/** The result of parsing "update" data (i.e. for an updateData call). */ class
|
|
3923
|
+
/** The result of parsing "update" data (i.e. for an updateData call). */ class Re {
|
|
3924
3924
|
constructor(t,
|
|
3925
3925
|
// The fieldMask does not include document transforms.
|
|
3926
|
-
|
|
3927
|
-
this.data = t, this.fieldMask =
|
|
3926
|
+
n, e) {
|
|
3927
|
+
this.data = t, this.fieldMask = n, this.fieldTransforms = e;
|
|
3928
3928
|
}
|
|
3929
|
-
toMutation(t,
|
|
3930
|
-
return new
|
|
3929
|
+
toMutation(t, n) {
|
|
3930
|
+
return new Pn(t, this.data, this.fieldMask, n, this.fieldTransforms);
|
|
3931
3931
|
}
|
|
3932
3932
|
}
|
|
3933
3933
|
|
|
3934
|
-
function
|
|
3934
|
+
function Pe(t) {
|
|
3935
3935
|
switch (t) {
|
|
3936
3936
|
case 0 /* Set */ :
|
|
3937
3937
|
// fall through
|
|
@@ -3949,7 +3949,7 @@ function Pn(t) {
|
|
|
3949
3949
|
}
|
|
3950
3950
|
}
|
|
3951
3951
|
|
|
3952
|
-
/** A "context" object passed around while parsing user data. */ class
|
|
3952
|
+
/** A "context" object passed around while parsing user data. */ class Ve {
|
|
3953
3953
|
/**
|
|
3954
3954
|
* Initializes a ParseContext with the given source and path.
|
|
3955
3955
|
*
|
|
@@ -3968,8 +3968,8 @@ function Pn(t) {
|
|
|
3968
3968
|
* which case certain features will not work and errors will be somewhat
|
|
3969
3969
|
* compromised).
|
|
3970
3970
|
*/
|
|
3971
|
-
constructor(t,
|
|
3972
|
-
this.settings = t, this.databaseId =
|
|
3971
|
+
constructor(t, n, e, r, s, i) {
|
|
3972
|
+
this.settings = t, this.databaseId = n, this.q = e, this.ignoreUndefinedProperties = r,
|
|
3973
3973
|
// Minor hack: If fieldTransforms is undefined, we assume this is an
|
|
3974
3974
|
// external call and we need to validate the entire path.
|
|
3975
3975
|
void 0 === s && this.Z(), this.fieldTransforms = s || [], this.fieldMask = i || [];
|
|
@@ -3980,21 +3980,21 @@ function Pn(t) {
|
|
|
3980
3980
|
get tt() {
|
|
3981
3981
|
return this.settings.tt;
|
|
3982
3982
|
}
|
|
3983
|
-
/** Returns a new context with the specified settings overwritten. */
|
|
3984
|
-
return new
|
|
3983
|
+
/** Returns a new context with the specified settings overwritten. */ nt(t) {
|
|
3984
|
+
return new Ve(Object.assign(Object.assign({}, this.settings), t), this.databaseId, this.q, this.ignoreUndefinedProperties, this.fieldTransforms, this.fieldMask);
|
|
3985
3985
|
}
|
|
3986
|
-
|
|
3987
|
-
var
|
|
3988
|
-
const
|
|
3989
|
-
path:
|
|
3986
|
+
et(t) {
|
|
3987
|
+
var n;
|
|
3988
|
+
const e = null === (n = this.path) || void 0 === n ? void 0 : n.child(t), r = this.nt({
|
|
3989
|
+
path: e,
|
|
3990
3990
|
rt: !1
|
|
3991
3991
|
});
|
|
3992
3992
|
return r.st(t), r;
|
|
3993
3993
|
}
|
|
3994
3994
|
it(t) {
|
|
3995
|
-
var
|
|
3996
|
-
const
|
|
3997
|
-
path:
|
|
3995
|
+
var n;
|
|
3996
|
+
const e = null === (n = this.path) || void 0 === n ? void 0 : n.child(t), r = this.nt({
|
|
3997
|
+
path: e,
|
|
3998
3998
|
rt: !1
|
|
3999
3999
|
});
|
|
4000
4000
|
return r.Z(), r;
|
|
@@ -4002,16 +4002,16 @@ function Pn(t) {
|
|
|
4002
4002
|
ot(t) {
|
|
4003
4003
|
// TODO(b/34871131): We don't support array paths right now; so make path
|
|
4004
4004
|
// undefined.
|
|
4005
|
-
return this.
|
|
4005
|
+
return this.nt({
|
|
4006
4006
|
path: void 0,
|
|
4007
4007
|
rt: !0
|
|
4008
4008
|
});
|
|
4009
4009
|
}
|
|
4010
4010
|
ut(t) {
|
|
4011
|
-
return
|
|
4011
|
+
return Ye(t, this.settings.methodName, this.settings.ct || !1, this.path, this.settings.at);
|
|
4012
4012
|
}
|
|
4013
4013
|
/** Returns 'true' if 'fieldPath' was traversed when creating this context. */ contains(t) {
|
|
4014
|
-
return void 0 !== this.fieldMask.find((
|
|
4014
|
+
return void 0 !== this.fieldMask.find((n => t.isPrefixOf(n))) || void 0 !== this.fieldTransforms.find((n => t.isPrefixOf(n.field)));
|
|
4015
4015
|
}
|
|
4016
4016
|
Z() {
|
|
4017
4017
|
// TODO(b/34871131): Remove null check once we have proper paths for fields
|
|
@@ -4020,52 +4020,52 @@ function Pn(t) {
|
|
|
4020
4020
|
}
|
|
4021
4021
|
st(t) {
|
|
4022
4022
|
if (0 === t.length) throw this.ut("Document fields must not be empty");
|
|
4023
|
-
if (
|
|
4023
|
+
if (Pe(this.tt) && Ie.test(t)) throw this.ut('Document fields cannot begin and end with "__"');
|
|
4024
4024
|
}
|
|
4025
4025
|
}
|
|
4026
4026
|
|
|
4027
4027
|
/**
|
|
4028
4028
|
* Helper for parsing raw user input (provided via the API) into internal model
|
|
4029
4029
|
* classes.
|
|
4030
|
-
*/ class
|
|
4031
|
-
constructor(t,
|
|
4032
|
-
this.databaseId = t, this.ignoreUndefinedProperties =
|
|
4030
|
+
*/ class Ne {
|
|
4031
|
+
constructor(t, n, e) {
|
|
4032
|
+
this.databaseId = t, this.ignoreUndefinedProperties = n, this.q = e || Jn(t);
|
|
4033
4033
|
}
|
|
4034
|
-
/** Creates a new top-level parse context. */ ht(t,
|
|
4035
|
-
return new
|
|
4034
|
+
/** Creates a new top-level parse context. */ ht(t, n, e, r = !1) {
|
|
4035
|
+
return new Ve({
|
|
4036
4036
|
tt: t,
|
|
4037
|
-
methodName:
|
|
4038
|
-
at:
|
|
4039
|
-
path:
|
|
4037
|
+
methodName: n,
|
|
4038
|
+
at: e,
|
|
4039
|
+
path: nt.emptyPath(),
|
|
4040
4040
|
rt: !1,
|
|
4041
4041
|
ct: r
|
|
4042
4042
|
}, this.databaseId, this.q, this.ignoreUndefinedProperties);
|
|
4043
4043
|
}
|
|
4044
4044
|
}
|
|
4045
4045
|
|
|
4046
|
-
function
|
|
4047
|
-
const
|
|
4048
|
-
return new
|
|
4046
|
+
function De(t) {
|
|
4047
|
+
const n = t._freezeSettings(), e = Jn(t._databaseId);
|
|
4048
|
+
return new Ne(t._databaseId, !!n.ignoreUndefinedProperties, e);
|
|
4049
4049
|
}
|
|
4050
4050
|
|
|
4051
|
-
/** Parse document data from a set() call. */ function $
|
|
4052
|
-
const o = t.ht(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ ,
|
|
4053
|
-
|
|
4054
|
-
const u =
|
|
4051
|
+
/** Parse document data from a set() call. */ function $e(t, n, e, r, s, i = {}) {
|
|
4052
|
+
const o = t.ht(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ , n, e, s);
|
|
4053
|
+
ze("Data must be an object, but it was:", o, r);
|
|
4054
|
+
const u = Me(r, o);
|
|
4055
4055
|
let c, a;
|
|
4056
4056
|
if (i.merge) c = new It(o.fieldMask), a = o.fieldTransforms; else if (i.mergeFields) {
|
|
4057
4057
|
const t = [];
|
|
4058
4058
|
for (const r of i.mergeFields) {
|
|
4059
|
-
const s =
|
|
4059
|
+
const s = Ge(n, r, e);
|
|
4060
4060
|
if (!o.contains(s)) throw new U(R, `Field '${s}' is specified in your field mask but missing from your input data.`);
|
|
4061
|
-
|
|
4061
|
+
He(t, s) || t.push(s);
|
|
4062
4062
|
}
|
|
4063
4063
|
c = new It(t), a = o.fieldTransforms.filter((t => c.covers(t.field)));
|
|
4064
4064
|
} else c = null, a = o.fieldTransforms;
|
|
4065
|
-
return new
|
|
4065
|
+
return new Ae(new Gt(u), c, a);
|
|
4066
4066
|
}
|
|
4067
4067
|
|
|
4068
|
-
class
|
|
4068
|
+
class Se extends Ee {
|
|
4069
4069
|
_toFieldTransform(t) {
|
|
4070
4070
|
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}`);
|
|
4071
4071
|
// No transform to add for a delete, but we need to add it to our
|
|
@@ -4073,7 +4073,7 @@ class Sn extends En {
|
|
|
4073
4073
|
return t.fieldMask.push(t.path), null;
|
|
4074
4074
|
}
|
|
4075
4075
|
isEqual(t) {
|
|
4076
|
-
return t instanceof
|
|
4076
|
+
return t instanceof Se;
|
|
4077
4077
|
}
|
|
4078
4078
|
}
|
|
4079
4079
|
|
|
@@ -4092,32 +4092,32 @@ class Sn extends En {
|
|
|
4092
4092
|
* context.
|
|
4093
4093
|
* @param context - The parent context.
|
|
4094
4094
|
* @param arrayElement - Whether or not the FieldValue has an array.
|
|
4095
|
-
*/ function
|
|
4096
|
-
return new
|
|
4095
|
+
*/ function Fe(t, n, e) {
|
|
4096
|
+
return new Ve({
|
|
4097
4097
|
tt: 3 /* Argument */ ,
|
|
4098
|
-
at:
|
|
4098
|
+
at: n.settings.at,
|
|
4099
4099
|
methodName: t._methodName,
|
|
4100
|
-
rt:
|
|
4101
|
-
},
|
|
4100
|
+
rt: e
|
|
4101
|
+
}, n.databaseId, n.q, n.ignoreUndefinedProperties);
|
|
4102
4102
|
}
|
|
4103
4103
|
|
|
4104
|
-
class
|
|
4104
|
+
class xe extends Ee {
|
|
4105
4105
|
_toFieldTransform(t) {
|
|
4106
|
-
return new
|
|
4106
|
+
return new Tn(t.path, new gn);
|
|
4107
4107
|
}
|
|
4108
4108
|
isEqual(t) {
|
|
4109
|
-
return t instanceof
|
|
4109
|
+
return t instanceof xe;
|
|
4110
4110
|
}
|
|
4111
4111
|
}
|
|
4112
4112
|
|
|
4113
|
-
class
|
|
4114
|
-
constructor(t,
|
|
4115
|
-
super(t), this.lt =
|
|
4113
|
+
class qe extends Ee {
|
|
4114
|
+
constructor(t, n) {
|
|
4115
|
+
super(t), this.lt = n;
|
|
4116
4116
|
}
|
|
4117
4117
|
_toFieldTransform(t) {
|
|
4118
|
-
const
|
|
4119
|
-
/*array=*/ !0),
|
|
4120
|
-
return new
|
|
4118
|
+
const n = Fe(this, t,
|
|
4119
|
+
/*array=*/ !0), e = this.lt.map((t => je(t, n))), r = new vn(e);
|
|
4120
|
+
return new Tn(t.path, r);
|
|
4121
4121
|
}
|
|
4122
4122
|
isEqual(t) {
|
|
4123
4123
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4125,14 +4125,14 @@ class qn extends En {
|
|
|
4125
4125
|
}
|
|
4126
4126
|
}
|
|
4127
4127
|
|
|
4128
|
-
class
|
|
4129
|
-
constructor(t,
|
|
4130
|
-
super(t), this.lt =
|
|
4128
|
+
class Oe extends Ee {
|
|
4129
|
+
constructor(t, n) {
|
|
4130
|
+
super(t), this.lt = n;
|
|
4131
4131
|
}
|
|
4132
4132
|
_toFieldTransform(t) {
|
|
4133
|
-
const
|
|
4134
|
-
/*array=*/ !0),
|
|
4135
|
-
return new
|
|
4133
|
+
const n = Fe(this, t,
|
|
4134
|
+
/*array=*/ !0), e = this.lt.map((t => je(t, n))), r = new bn(e);
|
|
4135
|
+
return new Tn(t.path, r);
|
|
4136
4136
|
}
|
|
4137
4137
|
isEqual(t) {
|
|
4138
4138
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4140,13 +4140,13 @@ class On extends En {
|
|
|
4140
4140
|
}
|
|
4141
4141
|
}
|
|
4142
4142
|
|
|
4143
|
-
class
|
|
4144
|
-
constructor(t,
|
|
4145
|
-
super(t), this.ft =
|
|
4143
|
+
class Ce extends Ee {
|
|
4144
|
+
constructor(t, n) {
|
|
4145
|
+
super(t), this.ft = n;
|
|
4146
4146
|
}
|
|
4147
4147
|
_toFieldTransform(t) {
|
|
4148
|
-
const
|
|
4149
|
-
return new
|
|
4148
|
+
const n = new En(t.q, yn(t.q, this.ft));
|
|
4149
|
+
return new Tn(t.path, n);
|
|
4150
4150
|
}
|
|
4151
4151
|
isEqual(t) {
|
|
4152
4152
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4154,50 +4154,50 @@ class Cn extends En {
|
|
|
4154
4154
|
}
|
|
4155
4155
|
}
|
|
4156
4156
|
|
|
4157
|
-
/** Parse update data from an update() call. */ function
|
|
4158
|
-
const s = t.ht(1 /* Update */ ,
|
|
4159
|
-
|
|
4157
|
+
/** Parse update data from an update() call. */ function Le(t, n, e, r) {
|
|
4158
|
+
const s = t.ht(1 /* Update */ , n, e);
|
|
4159
|
+
ze("Data must be an object, but it was:", s, r);
|
|
4160
4160
|
const i = [], o = Gt.empty();
|
|
4161
4161
|
Tt(r, ((t, r) => {
|
|
4162
|
-
const u =
|
|
4162
|
+
const u = We(n, t, e);
|
|
4163
4163
|
// For Compat types, we have to "extract" the underlying types before
|
|
4164
4164
|
// performing validation.
|
|
4165
4165
|
r = l(r);
|
|
4166
4166
|
const c = s.it(u);
|
|
4167
|
-
if (r instanceof
|
|
4167
|
+
if (r instanceof Se)
|
|
4168
4168
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4169
4169
|
i.push(u); else {
|
|
4170
|
-
const t =
|
|
4170
|
+
const t = je(r, c);
|
|
4171
4171
|
null != t && (i.push(u), o.set(u, t));
|
|
4172
4172
|
}
|
|
4173
4173
|
}));
|
|
4174
4174
|
const u = new It(i);
|
|
4175
|
-
return new
|
|
4175
|
+
return new Re(o, u, s.fieldTransforms);
|
|
4176
4176
|
}
|
|
4177
4177
|
|
|
4178
|
-
/** Parse update data from a list of field/value arguments. */ function
|
|
4179
|
-
const o = t.ht(1 /* Update */ ,
|
|
4180
|
-
if (i.length % 2 != 0) throw new U(R, `Function ${
|
|
4181
|
-
for (let t = 0; t < i.length; t += 2) u.push(
|
|
4178
|
+
/** Parse update data from a list of field/value arguments. */ function ke(t, n, e, r, s, i) {
|
|
4179
|
+
const o = t.ht(1 /* Update */ , n, e), u = [ Ge(n, r, e) ], c = [ s ];
|
|
4180
|
+
if (i.length % 2 != 0) throw new U(R, `Function ${n}() needs to be called with an even number of arguments that alternate between field names and values.`);
|
|
4181
|
+
for (let t = 0; t < i.length; t += 2) u.push(Ge(n, i[t])), c.push(i[t + 1]);
|
|
4182
4182
|
const a = [], h = Gt.empty();
|
|
4183
4183
|
// We iterate in reverse order to pick the last value for a field if the
|
|
4184
4184
|
// user specified the field multiple times.
|
|
4185
|
-
for (let t = u.length - 1; t >= 0; --t) if (!
|
|
4186
|
-
const
|
|
4187
|
-
let
|
|
4185
|
+
for (let t = u.length - 1; t >= 0; --t) if (!He(a, u[t])) {
|
|
4186
|
+
const n = u[t];
|
|
4187
|
+
let e = c[t];
|
|
4188
4188
|
// For Compat types, we have to "extract" the underlying types before
|
|
4189
4189
|
// performing validation.
|
|
4190
|
-
|
|
4191
|
-
const r = o.it(
|
|
4192
|
-
if (
|
|
4190
|
+
e = l(e);
|
|
4191
|
+
const r = o.it(n);
|
|
4192
|
+
if (e instanceof Se)
|
|
4193
4193
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4194
|
-
a.push(
|
|
4195
|
-
const t =
|
|
4196
|
-
null != t && (a.push(
|
|
4194
|
+
a.push(n); else {
|
|
4195
|
+
const t = je(e, r);
|
|
4196
|
+
null != t && (a.push(n), h.set(n, t));
|
|
4197
4197
|
}
|
|
4198
4198
|
}
|
|
4199
4199
|
const f = new It(a);
|
|
4200
|
-
return new
|
|
4200
|
+
return new Re(h, f, o.fieldTransforms);
|
|
4201
4201
|
}
|
|
4202
4202
|
|
|
4203
4203
|
/**
|
|
@@ -4206,8 +4206,8 @@ class Cn extends En {
|
|
|
4206
4206
|
*
|
|
4207
4207
|
* @param allowArrays - Whether the query value is an array that may directly
|
|
4208
4208
|
* contain additional arrays (e.g. the operand of an `in` query).
|
|
4209
|
-
*/ function
|
|
4210
|
-
return
|
|
4209
|
+
*/ function Ue(t, n, e, r = !1) {
|
|
4210
|
+
return je(e, t.ht(r ? 4 /* ArrayArgument */ : 3 /* Argument */ , n));
|
|
4211
4211
|
}
|
|
4212
4212
|
|
|
4213
4213
|
/**
|
|
@@ -4218,12 +4218,12 @@ class Cn extends En {
|
|
|
4218
4218
|
* the source of the data being parsed, etc.
|
|
4219
4219
|
* @returns The parsed value, or null if the value was a FieldValue sentinel
|
|
4220
4220
|
* that should not be included in the resulting parsed data.
|
|
4221
|
-
*/ function
|
|
4222
|
-
if (
|
|
4221
|
+
*/ function je(t, n) {
|
|
4222
|
+
if (Be(
|
|
4223
4223
|
// Unwrap the API type from the Compat SDK. This will return the API type
|
|
4224
4224
|
// from firestore-exp.
|
|
4225
|
-
t = l(t))) return
|
|
4226
|
-
if (t instanceof
|
|
4225
|
+
t = l(t))) return ze("Unsupported field value:", n, t), Me(t, n);
|
|
4226
|
+
if (t instanceof Ee)
|
|
4227
4227
|
// FieldValues usually parse into transforms (except deleteField())
|
|
4228
4228
|
// in which case we do not want to include this field in our parsed data
|
|
4229
4229
|
// (as doing so will overwrite the field directly prior to the transform
|
|
@@ -4233,19 +4233,19 @@ class Cn extends En {
|
|
|
4233
4233
|
* "Parses" the provided FieldValueImpl, adding any necessary transforms to
|
|
4234
4234
|
* context.fieldTransforms.
|
|
4235
4235
|
*/
|
|
4236
|
-
return function(t,
|
|
4236
|
+
return function(t, n) {
|
|
4237
4237
|
// Sentinels are only supported with writes, and not within arrays.
|
|
4238
|
-
if (!
|
|
4239
|
-
if (!
|
|
4240
|
-
const
|
|
4241
|
-
|
|
4238
|
+
if (!Pe(n.tt)) throw n.ut(`${t._methodName}() can only be used with update() and set()`);
|
|
4239
|
+
if (!n.path) throw n.ut(`${t._methodName}() is not currently supported inside arrays`);
|
|
4240
|
+
const e = t._toFieldTransform(n);
|
|
4241
|
+
e && n.fieldTransforms.push(e);
|
|
4242
4242
|
}
|
|
4243
4243
|
/**
|
|
4244
4244
|
* Helper to parse a scalar value (i.e. not an Object, Array, or FieldValue)
|
|
4245
4245
|
*
|
|
4246
4246
|
* @returns The parsed value
|
|
4247
|
-
*/ (t,
|
|
4248
|
-
if (void 0 === t &&
|
|
4247
|
+
*/ (t, n), null;
|
|
4248
|
+
if (void 0 === t && n.ignoreUndefinedProperties)
|
|
4249
4249
|
// If the input is undefined it can never participate in the fieldMask, so
|
|
4250
4250
|
// don't handle this below. If `ignoreUndefinedProperties` is false,
|
|
4251
4251
|
// `parseScalarValue` will reject an undefined value.
|
|
@@ -4253,38 +4253,38 @@ class Cn extends En {
|
|
|
4253
4253
|
if (
|
|
4254
4254
|
// If context.path is null we are inside an array and we don't support
|
|
4255
4255
|
// field mask paths more granular than the top-level array.
|
|
4256
|
-
|
|
4256
|
+
n.path && n.fieldMask.push(n.path), t instanceof Array) {
|
|
4257
4257
|
// TODO(b/34871131): Include the path containing the array in the error
|
|
4258
4258
|
// message.
|
|
4259
4259
|
// In the case of IN queries, the parsed data is an array (representing
|
|
4260
4260
|
// the set of values to be included for the IN query) that may directly
|
|
4261
4261
|
// contain additional arrays (each representing an individual field
|
|
4262
4262
|
// value), so we disable this validation.
|
|
4263
|
-
if (
|
|
4264
|
-
return function(t,
|
|
4265
|
-
const
|
|
4263
|
+
if (n.settings.rt && 4 /* ArrayArgument */ !== n.tt) throw n.ut("Nested arrays are not supported");
|
|
4264
|
+
return function(t, n) {
|
|
4265
|
+
const e = [];
|
|
4266
4266
|
let r = 0;
|
|
4267
4267
|
for (const s of t) {
|
|
4268
|
-
let t =
|
|
4268
|
+
let t = je(s, n.ot(r));
|
|
4269
4269
|
null == t && (
|
|
4270
4270
|
// Just include nulls in the array for fields being replaced with a
|
|
4271
4271
|
// sentinel.
|
|
4272
4272
|
t = {
|
|
4273
4273
|
nullValue: "NULL_VALUE"
|
|
4274
|
-
}),
|
|
4274
|
+
}), e.push(t), r++;
|
|
4275
4275
|
}
|
|
4276
4276
|
return {
|
|
4277
4277
|
arrayValue: {
|
|
4278
|
-
values:
|
|
4278
|
+
values: e
|
|
4279
4279
|
}
|
|
4280
4280
|
};
|
|
4281
|
-
}(t,
|
|
4281
|
+
}(t, n);
|
|
4282
4282
|
}
|
|
4283
|
-
return function(t,
|
|
4283
|
+
return function(t, n) {
|
|
4284
4284
|
if (null === (t = l(t))) return {
|
|
4285
4285
|
nullValue: "NULL_VALUE"
|
|
4286
4286
|
};
|
|
4287
|
-
if ("number" == typeof t) return
|
|
4287
|
+
if ("number" == typeof t) return yn(n.q, t);
|
|
4288
4288
|
if ("boolean" == typeof t) return {
|
|
4289
4289
|
booleanValue: t
|
|
4290
4290
|
};
|
|
@@ -4292,37 +4292,37 @@ class Cn extends En {
|
|
|
4292
4292
|
stringValue: t
|
|
4293
4293
|
};
|
|
4294
4294
|
if (t instanceof Date) {
|
|
4295
|
-
const
|
|
4295
|
+
const e = vt.fromDate(t);
|
|
4296
4296
|
return {
|
|
4297
|
-
timestampValue:
|
|
4297
|
+
timestampValue: Fn(n.q, e)
|
|
4298
4298
|
};
|
|
4299
4299
|
}
|
|
4300
4300
|
if (t instanceof vt) {
|
|
4301
4301
|
// Firestore backend truncates precision down to microseconds. To ensure
|
|
4302
4302
|
// offline mode works the same with regards to truncation, perform the
|
|
4303
4303
|
// truncation immediately without waiting for the backend to do that.
|
|
4304
|
-
const
|
|
4304
|
+
const e = new vt(t.seconds, 1e3 * Math.floor(t.nanoseconds / 1e3));
|
|
4305
4305
|
return {
|
|
4306
|
-
timestampValue:
|
|
4306
|
+
timestampValue: Fn(n.q, e)
|
|
4307
4307
|
};
|
|
4308
4308
|
}
|
|
4309
|
-
if (t instanceof
|
|
4309
|
+
if (t instanceof Te) return {
|
|
4310
4310
|
geoPointValue: {
|
|
4311
4311
|
latitude: t.latitude,
|
|
4312
4312
|
longitude: t.longitude
|
|
4313
4313
|
}
|
|
4314
4314
|
};
|
|
4315
|
-
if (t instanceof
|
|
4316
|
-
bytesValue:
|
|
4315
|
+
if (t instanceof be) return {
|
|
4316
|
+
bytesValue: xn(n.q, t._byteString)
|
|
4317
4317
|
};
|
|
4318
|
-
if (t instanceof
|
|
4319
|
-
const
|
|
4320
|
-
if (!r.isEqual(
|
|
4318
|
+
if (t instanceof le) {
|
|
4319
|
+
const e = n.databaseId, r = t.firestore._databaseId;
|
|
4320
|
+
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}`);
|
|
4321
4321
|
return {
|
|
4322
|
-
referenceValue:
|
|
4322
|
+
referenceValue: Cn(t.firestore._databaseId || n.databaseId, t._key.path)
|
|
4323
4323
|
};
|
|
4324
4324
|
}
|
|
4325
|
-
throw
|
|
4325
|
+
throw n.ut(`Unsupported field value: ${ot(t)}`);
|
|
4326
4326
|
}
|
|
4327
4327
|
/**
|
|
4328
4328
|
* Checks whether an object looks like a JSON object that should be converted
|
|
@@ -4330,56 +4330,56 @@ class Cn extends En {
|
|
|
4330
4330
|
* JSON objects since they should be converted to a struct value. Arrays, Dates,
|
|
4331
4331
|
* GeoPoints, etc. are not considered to look like JSON objects since they map
|
|
4332
4332
|
* to specific FieldValue types other than ObjectValue.
|
|
4333
|
-
*/ (t,
|
|
4333
|
+
*/ (t, n);
|
|
4334
4334
|
}
|
|
4335
4335
|
|
|
4336
|
-
function
|
|
4337
|
-
const
|
|
4336
|
+
function Me(t, n) {
|
|
4337
|
+
const e = {};
|
|
4338
4338
|
return !function(t) {
|
|
4339
|
-
for (const
|
|
4339
|
+
for (const n in t) if (Object.prototype.hasOwnProperty.call(t, n)) return !1;
|
|
4340
4340
|
return !0;
|
|
4341
4341
|
}(t) ? Tt(t, ((t, r) => {
|
|
4342
|
-
const s =
|
|
4343
|
-
null != s && (
|
|
4342
|
+
const s = je(r, n.et(t));
|
|
4343
|
+
null != s && (e[t] = s);
|
|
4344
4344
|
})) :
|
|
4345
4345
|
// If we encounter an empty object, we explicitly add it to the update
|
|
4346
4346
|
// mask to ensure that the server creates a map entry.
|
|
4347
|
-
|
|
4347
|
+
n.path && n.path.length > 0 && n.fieldMask.push(n.path), {
|
|
4348
4348
|
mapValue: {
|
|
4349
|
-
fields:
|
|
4349
|
+
fields: e
|
|
4350
4350
|
}
|
|
4351
4351
|
};
|
|
4352
4352
|
}
|
|
4353
4353
|
|
|
4354
|
-
function
|
|
4355
|
-
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof vt || t instanceof
|
|
4354
|
+
function Be(t) {
|
|
4355
|
+
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof vt || t instanceof Te || t instanceof be || t instanceof le || t instanceof Ee);
|
|
4356
4356
|
}
|
|
4357
4357
|
|
|
4358
|
-
function
|
|
4359
|
-
if (!
|
|
4358
|
+
function ze(t, n, e) {
|
|
4359
|
+
if (!Be(e) || !function(t) {
|
|
4360
4360
|
return "object" == typeof t && null !== t && (Object.getPrototypeOf(t) === Object.prototype || null === Object.getPrototypeOf(t));
|
|
4361
|
-
}(
|
|
4362
|
-
const r = ot(
|
|
4363
|
-
throw "an object" === r ?
|
|
4361
|
+
}(e)) {
|
|
4362
|
+
const r = ot(e);
|
|
4363
|
+
throw "an object" === r ? n.ut(t + " a custom object") : n.ut(t + " " + r);
|
|
4364
4364
|
}
|
|
4365
4365
|
}
|
|
4366
4366
|
|
|
4367
4367
|
/**
|
|
4368
4368
|
* Helper that calls fromDotSeparatedString() but wraps any error thrown.
|
|
4369
|
-
*/ function
|
|
4369
|
+
*/ function Ge(t, n, e) {
|
|
4370
4370
|
if ((
|
|
4371
4371
|
// If required, replace the FieldPath Compat class with with the firestore-exp
|
|
4372
4372
|
// FieldPath.
|
|
4373
|
-
|
|
4374
|
-
if ("string" == typeof
|
|
4375
|
-
throw
|
|
4373
|
+
n = l(n)) instanceof ge) return n._internalPath;
|
|
4374
|
+
if ("string" == typeof n) return We(t, n);
|
|
4375
|
+
throw Ye("Field path arguments must be of type string or ", t,
|
|
4376
4376
|
/* hasConverter= */ !1,
|
|
4377
|
-
/* path= */ void 0,
|
|
4377
|
+
/* path= */ void 0, e);
|
|
4378
4378
|
}
|
|
4379
4379
|
|
|
4380
4380
|
/**
|
|
4381
4381
|
* Matches any characters in a field path string that are reserved.
|
|
4382
|
-
*/ const
|
|
4382
|
+
*/ const Qe = new RegExp("[~\\*/\\[\\]]");
|
|
4383
4383
|
|
|
4384
4384
|
/**
|
|
4385
4385
|
* Wraps fromDotSeparatedString with an error message about the method that
|
|
@@ -4389,30 +4389,30 @@ function zn(t, e, n) {
|
|
|
4389
4389
|
* split on dots.
|
|
4390
4390
|
* @param targetDoc - The document against which the field path will be
|
|
4391
4391
|
* evaluated.
|
|
4392
|
-
*/ function
|
|
4393
|
-
if (
|
|
4392
|
+
*/ function We(t, n, e) {
|
|
4393
|
+
if (n.search(Qe) >= 0) throw Ye(`Invalid field path (${n}). Paths must not contain '~', '*', '/', '[', or ']'`, t,
|
|
4394
4394
|
/* hasConverter= */ !1,
|
|
4395
|
-
/* path= */ void 0,
|
|
4395
|
+
/* path= */ void 0, e);
|
|
4396
4396
|
try {
|
|
4397
|
-
return new
|
|
4397
|
+
return new ge(...n.split("."))._internalPath;
|
|
4398
4398
|
} catch (r) {
|
|
4399
|
-
throw
|
|
4399
|
+
throw Ye(`Invalid field path (${n}). Paths must not be empty, begin with '.', end with '.', or contain '..'`, t,
|
|
4400
4400
|
/* hasConverter= */ !1,
|
|
4401
|
-
/* path= */ void 0,
|
|
4401
|
+
/* path= */ void 0, e);
|
|
4402
4402
|
}
|
|
4403
4403
|
}
|
|
4404
4404
|
|
|
4405
|
-
function
|
|
4405
|
+
function Ye(t, n, e, r, s) {
|
|
4406
4406
|
const i = r && !r.isEmpty(), o = void 0 !== s;
|
|
4407
|
-
let u = `Function ${
|
|
4408
|
-
|
|
4407
|
+
let u = `Function ${n}() called with invalid data`;
|
|
4408
|
+
e && (u += " (via `toFirestore()`)"), u += ". ";
|
|
4409
4409
|
let c = "";
|
|
4410
4410
|
return (i || o) && (c += " (found", i && (c += ` in field ${r}`), o && (c += ` in document ${s}`),
|
|
4411
4411
|
c += ")"), new U(R, u + t + c);
|
|
4412
4412
|
}
|
|
4413
4413
|
|
|
4414
|
-
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function
|
|
4415
|
-
return t.some((t => t.isEqual(
|
|
4414
|
+
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function He(t, n) {
|
|
4415
|
+
return t.some((t => t.isEqual(n)));
|
|
4416
4416
|
}
|
|
4417
4417
|
|
|
4418
4418
|
/**
|
|
@@ -4439,14 +4439,14 @@ function Yn(t, e, n, r, s) {
|
|
|
4439
4439
|
* For a `DocumentSnapshot` that points to a non-existing document, any data
|
|
4440
4440
|
* access will return 'undefined'. You can use the `exists()` method to
|
|
4441
4441
|
* explicitly verify a document's existence.
|
|
4442
|
-
*/ class
|
|
4442
|
+
*/ class Ke {
|
|
4443
4443
|
// Note: This class is stripped down version of the DocumentSnapshot in
|
|
4444
4444
|
// the legacy SDK. The changes are:
|
|
4445
4445
|
// - No support for SnapshotMetadata.
|
|
4446
4446
|
// - No support for SnapshotOptions.
|
|
4447
4447
|
/** @hideconstructor protected */
|
|
4448
|
-
constructor(t,
|
|
4449
|
-
this._firestore = t, this._userDataWriter =
|
|
4448
|
+
constructor(t, n, e, r, s) {
|
|
4449
|
+
this._firestore = t, this._userDataWriter = n, this._key = e, this._document = r,
|
|
4450
4450
|
this._converter = s;
|
|
4451
4451
|
}
|
|
4452
4452
|
/** Property of the `DocumentSnapshot` that provides the document's ID. */ get id() {
|
|
@@ -4455,7 +4455,7 @@ function Yn(t, e, n, r, s) {
|
|
|
4455
4455
|
/**
|
|
4456
4456
|
* The `DocumentReference` for the document included in the `DocumentSnapshot`.
|
|
4457
4457
|
*/ get ref() {
|
|
4458
|
-
return new
|
|
4458
|
+
return new le(this._firestore, this._converter, this._key);
|
|
4459
4459
|
}
|
|
4460
4460
|
/**
|
|
4461
4461
|
* Signals whether or not the document at the snapshot's location exists.
|
|
@@ -4475,7 +4475,7 @@ function Yn(t, e, n, r, s) {
|
|
|
4475
4475
|
if (this._converter) {
|
|
4476
4476
|
// We only want to use the converter and create a new DocumentSnapshot
|
|
4477
4477
|
// if a converter has been provided.
|
|
4478
|
-
const t = new
|
|
4478
|
+
const t = new Je(this._firestore, this._userDataWriter, this._key, this._document,
|
|
4479
4479
|
/* converter= */ null);
|
|
4480
4480
|
return this._converter.fromFirestore(t);
|
|
4481
4481
|
}
|
|
@@ -4495,8 +4495,8 @@ function Yn(t, e, n, r, s) {
|
|
|
4495
4495
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4496
4496
|
get(t) {
|
|
4497
4497
|
if (this._document) {
|
|
4498
|
-
const
|
|
4499
|
-
if (null !==
|
|
4498
|
+
const n = this._document.data.field(tr("DocumentSnapshot.get", t));
|
|
4499
|
+
if (null !== n) return this._userDataWriter.convertValue(n);
|
|
4500
4500
|
}
|
|
4501
4501
|
}
|
|
4502
4502
|
}
|
|
@@ -4511,7 +4511,7 @@ function Yn(t, e, n, r, s) {
|
|
|
4511
4511
|
* `DocumentSnapshot`. Since query results contain only existing documents, the
|
|
4512
4512
|
* `exists` property will always be true and `data()` will never return
|
|
4513
4513
|
* 'undefined'.
|
|
4514
|
-
*/ class
|
|
4514
|
+
*/ class Je extends Ke {
|
|
4515
4515
|
/**
|
|
4516
4516
|
* Retrieves all fields in the document as an `Object`.
|
|
4517
4517
|
*
|
|
@@ -4529,10 +4529,10 @@ function Yn(t, e, n, r, s) {
|
|
|
4529
4529
|
* array via the `docs` property or enumerated using the `forEach` method. The
|
|
4530
4530
|
* number of documents can be determined via the `empty` and `size`
|
|
4531
4531
|
* properties.
|
|
4532
|
-
*/ class
|
|
4532
|
+
*/ class Xe {
|
|
4533
4533
|
/** @hideconstructor */
|
|
4534
|
-
constructor(t,
|
|
4535
|
-
this._docs =
|
|
4534
|
+
constructor(t, n) {
|
|
4535
|
+
this._docs = n, this.query = t;
|
|
4536
4536
|
}
|
|
4537
4537
|
/** An array of all the documents in the `QuerySnapshot`. */ get docs() {
|
|
4538
4538
|
return [ ...this._docs ];
|
|
@@ -4549,8 +4549,8 @@ function Yn(t, e, n, r, s) {
|
|
|
4549
4549
|
* @param callback - A callback to be called with a `QueryDocumentSnapshot` for
|
|
4550
4550
|
* each document in the snapshot.
|
|
4551
4551
|
* @param thisArg - The `this` binding for the callback.
|
|
4552
|
-
*/ forEach(t,
|
|
4553
|
-
this._docs.forEach(t,
|
|
4552
|
+
*/ forEach(t, n) {
|
|
4553
|
+
this._docs.forEach(t, n);
|
|
4554
4554
|
}
|
|
4555
4555
|
}
|
|
4556
4556
|
|
|
@@ -4560,14 +4560,14 @@ function Yn(t, e, n, r, s) {
|
|
|
4560
4560
|
* @param left - A snapshot to compare.
|
|
4561
4561
|
* @param right - A snapshot to compare.
|
|
4562
4562
|
* @returns true if the snapshots are equal.
|
|
4563
|
-
*/ function
|
|
4564
|
-
return t = l(t),
|
|
4563
|
+
*/ function Ze(t, n) {
|
|
4564
|
+
return t = l(t), n = l(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) && gt(t.docs, n.docs, Ze));
|
|
4565
4565
|
}
|
|
4566
4566
|
|
|
4567
4567
|
/**
|
|
4568
4568
|
* Helper that calls `fromDotSeparatedString()` but wraps any error thrown.
|
|
4569
|
-
*/ function tr(t,
|
|
4570
|
-
return "string" == typeof
|
|
4569
|
+
*/ function tr(t, n) {
|
|
4570
|
+
return "string" == typeof n ? We(t, n) : n instanceof ge ? n._internalPath : n._delegate._internalPath;
|
|
4571
4571
|
}
|
|
4572
4572
|
|
|
4573
4573
|
/**
|
|
@@ -4594,7 +4594,7 @@ function Yn(t, e, n, r, s) {
|
|
|
4594
4594
|
* can then be passed to {@link query} to create a new query instance that
|
|
4595
4595
|
* also contains this `QueryConstraint`.
|
|
4596
4596
|
*/
|
|
4597
|
-
class
|
|
4597
|
+
class nr {}
|
|
4598
4598
|
|
|
4599
4599
|
/**
|
|
4600
4600
|
* Creates a new immutable instance of {@link Query} that is extended to also include
|
|
@@ -4604,43 +4604,43 @@ class er {}
|
|
|
4604
4604
|
* @param queryConstraints - The list of {@link QueryConstraint}s to apply.
|
|
4605
4605
|
* @throws if any of the provided query constraints cannot be combined with the
|
|
4606
4606
|
* existing or new constraints.
|
|
4607
|
-
*/ function
|
|
4608
|
-
for (const
|
|
4607
|
+
*/ function er(t, ...n) {
|
|
4608
|
+
for (const e of n) t = e._apply(t);
|
|
4609
4609
|
return t;
|
|
4610
4610
|
}
|
|
4611
4611
|
|
|
4612
|
-
class rr extends
|
|
4613
|
-
constructor(t,
|
|
4614
|
-
super(), this.dt = t, this.wt =
|
|
4612
|
+
class rr extends nr {
|
|
4613
|
+
constructor(t, n, e) {
|
|
4614
|
+
super(), this.dt = t, this.wt = n, this.yt = e, this.type = "where";
|
|
4615
4615
|
}
|
|
4616
4616
|
_apply(t) {
|
|
4617
|
-
const
|
|
4617
|
+
const n = De(t.firestore), e = function(t, n, e, r, s, i, o) {
|
|
4618
4618
|
let u;
|
|
4619
4619
|
if (s.isKeyField()) {
|
|
4620
4620
|
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new U(R, `Invalid Query. You can't perform '${i}' queries on documentId().`);
|
|
4621
4621
|
if ("in" /* IN */ === i || "not-in" /* NOT_IN */ === i) {
|
|
4622
4622
|
_r(o, i);
|
|
4623
|
-
const
|
|
4624
|
-
for (const
|
|
4623
|
+
const n = [];
|
|
4624
|
+
for (const e of o) n.push(yr(r, t, e));
|
|
4625
4625
|
u = {
|
|
4626
4626
|
arrayValue: {
|
|
4627
|
-
values:
|
|
4627
|
+
values: n
|
|
4628
4628
|
}
|
|
4629
4629
|
};
|
|
4630
4630
|
} else u = yr(r, t, o);
|
|
4631
4631
|
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i || _r(o, i),
|
|
4632
|
-
u =
|
|
4632
|
+
u = Ue(e, n, o,
|
|
4633
4633
|
/* allowArrays= */ "in" /* IN */ === i || "not-in" /* NOT_IN */ === i);
|
|
4634
4634
|
const c = Ht.create(s, i, u);
|
|
4635
|
-
return function(t,
|
|
4636
|
-
if (
|
|
4637
|
-
const
|
|
4638
|
-
if (null !==
|
|
4639
|
-
const r =
|
|
4640
|
-
null !== r && gr(t,
|
|
4635
|
+
return function(t, n) {
|
|
4636
|
+
if (n.D()) {
|
|
4637
|
+
const e = fn(t);
|
|
4638
|
+
if (null !== e && !e.isEqual(n.field)) throw new U(R, `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()}'`);
|
|
4639
|
+
const r = ln(t);
|
|
4640
|
+
null !== r && gr(t, n.field, r);
|
|
4641
4641
|
}
|
|
4642
|
-
const
|
|
4643
|
-
for (const
|
|
4642
|
+
const e = function(t, n) {
|
|
4643
|
+
for (const e of t.filters) if (n.indexOf(e.op) >= 0) return e.op;
|
|
4644
4644
|
return null;
|
|
4645
4645
|
}(t,
|
|
4646
4646
|
/**
|
|
@@ -4675,16 +4675,16 @@ class rr extends er {
|
|
|
4675
4675
|
default:
|
|
4676
4676
|
return [];
|
|
4677
4677
|
}
|
|
4678
|
-
}(
|
|
4679
|
-
if (null !==
|
|
4678
|
+
}(n.op));
|
|
4679
|
+
if (null !== e)
|
|
4680
4680
|
// Special case when it's a duplicate op to give a slightly clearer error message.
|
|
4681
|
-
throw
|
|
4681
|
+
throw e === n.op ? new U(R, `Invalid query. You cannot use more than one '${n.op.toString()}' filter.`) : new U(R, `Invalid query. You cannot use '${n.op.toString()}' filters with '${e.toString()}' filters.`);
|
|
4682
4682
|
}(t, c), c;
|
|
4683
|
-
}(t._query, "where",
|
|
4684
|
-
return new
|
|
4685
|
-
const
|
|
4686
|
-
return new
|
|
4687
|
-
}(t._query,
|
|
4683
|
+
}(t._query, "where", n, t.firestore._databaseId, this.dt, this.wt, this.yt);
|
|
4684
|
+
return new fe(t.firestore, t.converter, function(t, n) {
|
|
4685
|
+
const e = t.filters.concat([ n ]);
|
|
4686
|
+
return new an(t.path, t.collectionGroup, t.explicitOrderBy.slice(), e, t.limit, t.limitType, t.startAt, t.endAt);
|
|
4687
|
+
}(t._query, e));
|
|
4688
4688
|
}
|
|
4689
4689
|
}
|
|
4690
4690
|
|
|
@@ -4698,25 +4698,25 @@ class rr extends er {
|
|
|
4698
4698
|
* "<=", "!=").
|
|
4699
4699
|
* @param value - The value for comparison
|
|
4700
4700
|
* @returns The created {@link Query}.
|
|
4701
|
-
*/ function sr(t,
|
|
4702
|
-
const r =
|
|
4703
|
-
return new rr(s, r,
|
|
4701
|
+
*/ function sr(t, n, e) {
|
|
4702
|
+
const r = n, s = tr("where", t);
|
|
4703
|
+
return new rr(s, r, e);
|
|
4704
4704
|
}
|
|
4705
4705
|
|
|
4706
|
-
class ir extends
|
|
4707
|
-
constructor(t,
|
|
4708
|
-
super(), this.dt = t, this._t =
|
|
4706
|
+
class ir extends nr {
|
|
4707
|
+
constructor(t, n) {
|
|
4708
|
+
super(), this.dt = t, this._t = n, this.type = "orderBy";
|
|
4709
4709
|
}
|
|
4710
4710
|
_apply(t) {
|
|
4711
|
-
const
|
|
4711
|
+
const n = function(t, n, e) {
|
|
4712
4712
|
if (null !== t.startAt) throw new U(R, "Invalid query. You must not call startAt() or startAfter() before calling orderBy().");
|
|
4713
4713
|
if (null !== t.endAt) throw new U(R, "Invalid query. You must not call endAt() or endBefore() before calling orderBy().");
|
|
4714
|
-
const r = new
|
|
4715
|
-
return function(t,
|
|
4716
|
-
if (null ===
|
|
4714
|
+
const r = new on(n, e);
|
|
4715
|
+
return function(t, n) {
|
|
4716
|
+
if (null === ln(t)) {
|
|
4717
4717
|
// This is the first order by. It must match any inequality.
|
|
4718
|
-
const
|
|
4719
|
-
null !==
|
|
4718
|
+
const e = fn(t);
|
|
4719
|
+
null !== e && gr(t, e, n.field);
|
|
4720
4720
|
}
|
|
4721
4721
|
}(t, r), r;
|
|
4722
4722
|
}
|
|
@@ -4731,11 +4731,11 @@ class ir extends er {
|
|
|
4731
4731
|
* of the query or if any of the fields in the order by are an uncommitted
|
|
4732
4732
|
* server timestamp.
|
|
4733
4733
|
*/ (t._query, this.dt, this._t);
|
|
4734
|
-
return new
|
|
4734
|
+
return new fe(t.firestore, t.converter, function(t, n) {
|
|
4735
4735
|
// TODO(dimond): validate that orderBy does not list the same key twice.
|
|
4736
|
-
const
|
|
4737
|
-
return new
|
|
4738
|
-
}(t._query,
|
|
4736
|
+
const e = t.explicitOrderBy.concat([ n ]);
|
|
4737
|
+
return new an(t.path, t.collectionGroup, e, t.filters.slice(), t.limit, t.limitType, t.startAt, t.endAt);
|
|
4738
|
+
}(t._query, n));
|
|
4739
4739
|
}
|
|
4740
4740
|
}
|
|
4741
4741
|
|
|
@@ -4747,18 +4747,18 @@ class ir extends er {
|
|
|
4747
4747
|
* @param directionStr - Optional direction to sort by ('asc' or 'desc'). If
|
|
4748
4748
|
* not specified, order will be ascending.
|
|
4749
4749
|
* @returns The created {@link Query}.
|
|
4750
|
-
*/ function or(t,
|
|
4751
|
-
const
|
|
4752
|
-
return new ir(r,
|
|
4750
|
+
*/ function or(t, n = "asc") {
|
|
4751
|
+
const e = n, r = tr("orderBy", t);
|
|
4752
|
+
return new ir(r, e);
|
|
4753
4753
|
}
|
|
4754
4754
|
|
|
4755
|
-
class ur extends
|
|
4756
|
-
constructor(t,
|
|
4757
|
-
super(), this.type = t, this.gt =
|
|
4755
|
+
class ur extends nr {
|
|
4756
|
+
constructor(t, n, e) {
|
|
4757
|
+
super(), this.type = t, this.gt = n, this.vt = e;
|
|
4758
4758
|
}
|
|
4759
4759
|
_apply(t) {
|
|
4760
|
-
return new
|
|
4761
|
-
return new
|
|
4760
|
+
return new fe(t.firestore, t.converter, function(t, n, e) {
|
|
4761
|
+
return new an(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), n, e, t.startAt, t.endAt);
|
|
4762
4762
|
}(t._query, this.gt, this.vt));
|
|
4763
4763
|
}
|
|
4764
4764
|
}
|
|
@@ -4784,15 +4784,15 @@ class ur extends er {
|
|
|
4784
4784
|
return ct("limitToLast", t), new ur("limitToLast", t, "L" /* Last */);
|
|
4785
4785
|
}
|
|
4786
4786
|
|
|
4787
|
-
class hr extends
|
|
4788
|
-
constructor(t,
|
|
4789
|
-
super(), this.type = t, this.bt =
|
|
4787
|
+
class hr extends nr {
|
|
4788
|
+
constructor(t, n, e) {
|
|
4789
|
+
super(), this.type = t, this.bt = n, this.Et = e;
|
|
4790
4790
|
}
|
|
4791
4791
|
_apply(t) {
|
|
4792
|
-
const
|
|
4793
|
-
return new
|
|
4794
|
-
return new
|
|
4795
|
-
}(t._query,
|
|
4792
|
+
const n = pr(t, this.type, this.bt, this.Et);
|
|
4793
|
+
return new fe(t.firestore, t.converter, function(t, n) {
|
|
4794
|
+
return new an(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, n, t.endAt);
|
|
4795
|
+
}(t._query, n));
|
|
4796
4796
|
}
|
|
4797
4797
|
}
|
|
4798
4798
|
|
|
@@ -4806,15 +4806,15 @@ function fr(...t) {
|
|
|
4806
4806
|
/*inclusive=*/ !1);
|
|
4807
4807
|
}
|
|
4808
4808
|
|
|
4809
|
-
class dr extends
|
|
4810
|
-
constructor(t,
|
|
4811
|
-
super(), this.type = t, this.bt =
|
|
4809
|
+
class dr extends nr {
|
|
4810
|
+
constructor(t, n, e) {
|
|
4811
|
+
super(), this.type = t, this.bt = n, this.Et = e;
|
|
4812
4812
|
}
|
|
4813
4813
|
_apply(t) {
|
|
4814
|
-
const
|
|
4815
|
-
return new
|
|
4816
|
-
return new
|
|
4817
|
-
}(t._query,
|
|
4814
|
+
const n = pr(t, this.type, this.bt, this.Et);
|
|
4815
|
+
return new fe(t.firestore, t.converter, function(t, n) {
|
|
4816
|
+
return new an(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, t.startAt, n);
|
|
4817
|
+
}(t._query, n));
|
|
4818
4818
|
}
|
|
4819
4819
|
}
|
|
4820
4820
|
|
|
@@ -4827,9 +4827,9 @@ function mr(...t) {
|
|
|
4827
4827
|
return new dr("endAt", t, /*inclusive=*/ !0);
|
|
4828
4828
|
}
|
|
4829
4829
|
|
|
4830
|
-
/** Helper function to create a bound from a document or fields */ function pr(t,
|
|
4831
|
-
if (
|
|
4832
|
-
if (!r) throw new U(V, `Can't use a DocumentSnapshot that doesn't exist for ${
|
|
4830
|
+
/** Helper function to create a bound from a document or fields */ function pr(t, n, e, r) {
|
|
4831
|
+
if (e[0] = l(e[0]), e[0] instanceof Ke) return function(t, n, e, r, s) {
|
|
4832
|
+
if (!r) throw new U(V, `Can't use a DocumentSnapshot that doesn't exist for ${e}().`);
|
|
4833
4833
|
const i = [];
|
|
4834
4834
|
// Because people expect to continue/end a query at the exact document
|
|
4835
4835
|
// provided, we need to use the implicit sort order rather than the explicit
|
|
@@ -4838,23 +4838,23 @@ function mr(...t) {
|
|
|
4838
4838
|
// the provided document. Without the key (by using the explicit sort
|
|
4839
4839
|
// orders), multiple documents could match the position, yielding duplicate
|
|
4840
4840
|
// results.
|
|
4841
|
-
for (const
|
|
4842
|
-
const t = r.data.field(
|
|
4843
|
-
if ($t(t)) throw new U(R, 'Invalid query. You are trying to start or end a query using a document for which the field "' +
|
|
4841
|
+
for (const e of wn(t)) if (e.field.isKeyField()) i.push(kt(n, r.key)); else {
|
|
4842
|
+
const t = r.data.field(e.field);
|
|
4843
|
+
if ($t(t)) throw new U(R, '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.)');
|
|
4844
4844
|
if (null === t) {
|
|
4845
|
-
const t =
|
|
4845
|
+
const t = e.field.canonicalString();
|
|
4846
4846
|
throw new U(R, `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.`);
|
|
4847
4847
|
}
|
|
4848
4848
|
i.push(t);
|
|
4849
4849
|
}
|
|
4850
|
-
return new
|
|
4850
|
+
return new sn(i, s);
|
|
4851
4851
|
}
|
|
4852
4852
|
/**
|
|
4853
4853
|
* Converts a list of field values to a `Bound` for the given query.
|
|
4854
|
-
*/ (t._query, t.firestore._databaseId,
|
|
4854
|
+
*/ (t._query, t.firestore._databaseId, n, e[0]._document, r);
|
|
4855
4855
|
{
|
|
4856
|
-
const s =
|
|
4857
|
-
return function(t,
|
|
4856
|
+
const s = De(t.firestore);
|
|
4857
|
+
return function(t, n, e, r, s, i) {
|
|
4858
4858
|
// Use explicit order by's because it has to match the query the user made
|
|
4859
4859
|
const o = t.explicitOrderBy;
|
|
4860
4860
|
if (s.length > o.length) throw new U(R, `Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);
|
|
@@ -4863,48 +4863,48 @@ function mr(...t) {
|
|
|
4863
4863
|
const c = s[i];
|
|
4864
4864
|
if (o[i].field.isKeyField()) {
|
|
4865
4865
|
if ("string" != typeof c) throw new U(R, `Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);
|
|
4866
|
-
if (!
|
|
4867
|
-
const
|
|
4868
|
-
if (!
|
|
4869
|
-
const s = new
|
|
4870
|
-
u.push(kt(
|
|
4866
|
+
if (!dn(t) && -1 !== c.indexOf("/")) throw new U(R, `Invalid query. When querying a collection and ordering by documentId(), the value passed to ${r}() must be a plain document ID, but '${c}' contains a slash.`);
|
|
4867
|
+
const e = t.path.child(Z.fromString(c));
|
|
4868
|
+
if (!et.isDocumentKey(e)) throw new U(R, `Invalid query. When querying a collection group and ordering by 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.`);
|
|
4869
|
+
const s = new et(e);
|
|
4870
|
+
u.push(kt(n, s));
|
|
4871
4871
|
} else {
|
|
4872
|
-
const t =
|
|
4872
|
+
const t = Ue(e, r, c);
|
|
4873
4873
|
u.push(t);
|
|
4874
4874
|
}
|
|
4875
4875
|
}
|
|
4876
|
-
return new
|
|
4876
|
+
return new sn(u, i);
|
|
4877
4877
|
}
|
|
4878
4878
|
/**
|
|
4879
4879
|
* Parses the given `documentIdValue` into a `ReferenceValue`, throwing
|
|
4880
4880
|
* appropriate errors if the value is anything other than a `DocumentReference`
|
|
4881
4881
|
* or `string`, or if the string is malformed.
|
|
4882
|
-
*/ (t._query, t.firestore._databaseId, s,
|
|
4882
|
+
*/ (t._query, t.firestore._databaseId, s, n, e, r);
|
|
4883
4883
|
}
|
|
4884
4884
|
}
|
|
4885
4885
|
|
|
4886
|
-
function yr(t,
|
|
4887
|
-
if ("string" == typeof (
|
|
4888
|
-
if ("" ===
|
|
4889
|
-
if (!
|
|
4890
|
-
const r =
|
|
4891
|
-
if (!
|
|
4892
|
-
return kt(t, new
|
|
4886
|
+
function yr(t, n, e) {
|
|
4887
|
+
if ("string" == typeof (e = l(e))) {
|
|
4888
|
+
if ("" === e) throw new U(R, "Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");
|
|
4889
|
+
if (!dn(n) && -1 !== e.indexOf("/")) throw new U(R, `Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${e}' contains a '/' character.`);
|
|
4890
|
+
const r = n.path.child(Z.fromString(e));
|
|
4891
|
+
if (!et.isDocumentKey(r)) throw new U(R, `Invalid query. When querying a collection group by 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}).`);
|
|
4892
|
+
return kt(t, new et(r));
|
|
4893
4893
|
}
|
|
4894
|
-
if (
|
|
4895
|
-
throw new U(R, `Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${ot(
|
|
4894
|
+
if (e instanceof le) return kt(t, e._key);
|
|
4895
|
+
throw new U(R, `Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${ot(e)}.`);
|
|
4896
4896
|
}
|
|
4897
4897
|
|
|
4898
4898
|
/**
|
|
4899
4899
|
* Validates that the value passed into a disjunctive filter satisfies all
|
|
4900
4900
|
* array requirements.
|
|
4901
|
-
*/ function _r(t,
|
|
4902
|
-
if (!Array.isArray(t) || 0 === t.length) throw new U(R, `Invalid Query. A non-empty array is required for '${
|
|
4903
|
-
if (t.length > 10) throw new U(R, `Invalid Query. '${
|
|
4901
|
+
*/ function _r(t, n) {
|
|
4902
|
+
if (!Array.isArray(t) || 0 === t.length) throw new U(R, `Invalid Query. A non-empty array is required for '${n.toString()}' filters.`);
|
|
4903
|
+
if (t.length > 10) throw new U(R, `Invalid Query. '${n.toString()}' filters support a maximum of 10 elements in the value array.`);
|
|
4904
4904
|
}
|
|
4905
4905
|
|
|
4906
|
-
function gr(t,
|
|
4907
|
-
if (!
|
|
4906
|
+
function gr(t, n, e) {
|
|
4907
|
+
if (!e.isEqual(n)) throw new U(R, `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.`);
|
|
4908
4908
|
}
|
|
4909
4909
|
|
|
4910
4910
|
/**
|
|
@@ -4954,17 +4954,17 @@ function gr(t, e, n) {
|
|
|
4954
4954
|
* their `set()` or fails due to invalid data originating from a `toFirestore()`
|
|
4955
4955
|
* call.
|
|
4956
4956
|
*/
|
|
4957
|
-
function vr(t,
|
|
4957
|
+
function vr(t, n, e) {
|
|
4958
4958
|
let r;
|
|
4959
4959
|
// Cast to `any` in order to satisfy the union type constraint on
|
|
4960
4960
|
// toFirestore().
|
|
4961
4961
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4962
|
-
return r = t ?
|
|
4962
|
+
return r = t ? e && (e.merge || e.mergeFields) ? t.toFirestore(n, e) : t.toFirestore(n) : n,
|
|
4963
4963
|
r;
|
|
4964
4964
|
}
|
|
4965
4965
|
|
|
4966
4966
|
class br extends class {
|
|
4967
|
-
convertValue(t,
|
|
4967
|
+
convertValue(t, n = "none") {
|
|
4968
4968
|
switch (xt(t)) {
|
|
4969
4969
|
case 0 /* NullValue */ :
|
|
4970
4970
|
return null;
|
|
@@ -4979,7 +4979,7 @@ class br extends class {
|
|
|
4979
4979
|
return this.convertTimestamp(t.timestampValue);
|
|
4980
4980
|
|
|
4981
4981
|
case 4 /* ServerTimestampValue */ :
|
|
4982
|
-
return this.convertServerTimestamp(t,
|
|
4982
|
+
return this.convertServerTimestamp(t, n);
|
|
4983
4983
|
|
|
4984
4984
|
case 5 /* StringValue */ :
|
|
4985
4985
|
return t.stringValue;
|
|
@@ -4994,32 +4994,32 @@ class br extends class {
|
|
|
4994
4994
|
return this.convertGeoPoint(t.geoPointValue);
|
|
4995
4995
|
|
|
4996
4996
|
case 9 /* ArrayValue */ :
|
|
4997
|
-
return this.convertArray(t.arrayValue,
|
|
4997
|
+
return this.convertArray(t.arrayValue, n);
|
|
4998
4998
|
|
|
4999
4999
|
case 10 /* ObjectValue */ :
|
|
5000
|
-
return this.convertObject(t.mapValue,
|
|
5000
|
+
return this.convertObject(t.mapValue, n);
|
|
5001
5001
|
|
|
5002
5002
|
default:
|
|
5003
5003
|
throw v();
|
|
5004
5004
|
}
|
|
5005
5005
|
}
|
|
5006
|
-
convertObject(t,
|
|
5007
|
-
const
|
|
5006
|
+
convertObject(t, n) {
|
|
5007
|
+
const e = {};
|
|
5008
5008
|
return Tt(t.fields, ((t, r) => {
|
|
5009
|
-
|
|
5010
|
-
})),
|
|
5009
|
+
e[t] = this.convertValue(r, n);
|
|
5010
|
+
})), e;
|
|
5011
5011
|
}
|
|
5012
5012
|
convertGeoPoint(t) {
|
|
5013
|
-
return new
|
|
5013
|
+
return new Te(Nt(t.latitude), Nt(t.longitude));
|
|
5014
5014
|
}
|
|
5015
|
-
convertArray(t,
|
|
5016
|
-
return (t.values || []).map((t => this.convertValue(t,
|
|
5015
|
+
convertArray(t, n) {
|
|
5016
|
+
return (t.values || []).map((t => this.convertValue(t, n)));
|
|
5017
5017
|
}
|
|
5018
|
-
convertServerTimestamp(t,
|
|
5019
|
-
switch (
|
|
5018
|
+
convertServerTimestamp(t, n) {
|
|
5019
|
+
switch (n) {
|
|
5020
5020
|
case "previous":
|
|
5021
|
-
const
|
|
5022
|
-
return null ==
|
|
5021
|
+
const e = St(t);
|
|
5022
|
+
return null == e ? null : this.convertValue(e, n);
|
|
5023
5023
|
|
|
5024
5024
|
case "estimate":
|
|
5025
5025
|
return this.convertTimestamp(Ft(t));
|
|
@@ -5029,16 +5029,16 @@ class br extends class {
|
|
|
5029
5029
|
}
|
|
5030
5030
|
}
|
|
5031
5031
|
convertTimestamp(t) {
|
|
5032
|
-
const
|
|
5033
|
-
return new vt(
|
|
5032
|
+
const n = Vt(t);
|
|
5033
|
+
return new vt(n.seconds, n.nanos);
|
|
5034
5034
|
}
|
|
5035
|
-
convertDocumentKey(t,
|
|
5036
|
-
const
|
|
5037
|
-
b(
|
|
5038
|
-
const r = new J(
|
|
5039
|
-
return r.isEqual(
|
|
5035
|
+
convertDocumentKey(t, n) {
|
|
5036
|
+
const e = Z.fromString(t);
|
|
5037
|
+
b(Kn(e));
|
|
5038
|
+
const r = new J(e.get(1), e.get(3)), s = new et(e.popFirst(5));
|
|
5039
|
+
return r.isEqual(n) ||
|
|
5040
5040
|
// TODO(b/64130202): Somehow support foreign references.
|
|
5041
|
-
y(`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 (${
|
|
5041
|
+
y(`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.`),
|
|
5042
5042
|
s;
|
|
5043
5043
|
}
|
|
5044
5044
|
} {
|
|
@@ -5046,11 +5046,11 @@ class br extends class {
|
|
|
5046
5046
|
super(), this.firestore = t;
|
|
5047
5047
|
}
|
|
5048
5048
|
convertBytes(t) {
|
|
5049
|
-
return new
|
|
5049
|
+
return new be(t);
|
|
5050
5050
|
}
|
|
5051
5051
|
convertReference(t) {
|
|
5052
|
-
const
|
|
5053
|
-
return new
|
|
5052
|
+
const n = this.convertDocumentKey(t, this.firestore._databaseId);
|
|
5053
|
+
return new le(this.firestore, /* converter= */ null, n);
|
|
5054
5054
|
}
|
|
5055
5055
|
}
|
|
5056
5056
|
|
|
@@ -5067,11 +5067,11 @@ class br extends class {
|
|
|
5067
5067
|
* @returns A Promise resolved with a `DocumentSnapshot` containing the current
|
|
5068
5068
|
* document contents.
|
|
5069
5069
|
*/ function Er(t) {
|
|
5070
|
-
const
|
|
5071
|
-
return
|
|
5072
|
-
b(1 ===
|
|
5073
|
-
const r =
|
|
5074
|
-
return new
|
|
5070
|
+
const n = se((t = ut(t, le)).firestore), e = new br(t.firestore);
|
|
5071
|
+
return ne(n, [ t._key ]).then((n => {
|
|
5072
|
+
b(1 === n.length);
|
|
5073
|
+
const r = n[0];
|
|
5074
|
+
return new Ke(t.firestore, e, t._key, r.isFoundDocument() ? r : null, t.converter);
|
|
5075
5075
|
}));
|
|
5076
5076
|
}
|
|
5077
5077
|
|
|
@@ -5088,31 +5088,31 @@ class br extends class {
|
|
|
5088
5088
|
* @returns A Promise that will be resolved with the results of the query.
|
|
5089
5089
|
*/ function Tr(t) {
|
|
5090
5090
|
!function(t) {
|
|
5091
|
-
if (
|
|
5092
|
-
}((t = ut(t,
|
|
5093
|
-
const
|
|
5094
|
-
return
|
|
5095
|
-
const r =
|
|
5096
|
-
return
|
|
5091
|
+
if (hn(t) && 0 === t.explicitOrderBy.length) throw new U(O, "limitToLast() queries require specifying at least one orderBy() clause");
|
|
5092
|
+
}((t = ut(t, fe))._query);
|
|
5093
|
+
const n = se(t.firestore), e = new br(t.firestore);
|
|
5094
|
+
return ee(n, t._query).then((n => {
|
|
5095
|
+
const r = n.map((n => new Je(t.firestore, e, n.key, n, t.converter)));
|
|
5096
|
+
return hn(t._query) &&
|
|
5097
5097
|
// Limit to last queries reverse the orderBy constraint that was
|
|
5098
5098
|
// specified by the user. As such, we need to reverse the order of the
|
|
5099
5099
|
// results to return the documents in the expected order.
|
|
5100
|
-
r.reverse(), new
|
|
5100
|
+
r.reverse(), new Xe(t, r);
|
|
5101
5101
|
}));
|
|
5102
5102
|
}
|
|
5103
5103
|
|
|
5104
|
-
function Ir(t,
|
|
5105
|
-
const r = vr((t = ut(t,
|
|
5106
|
-
return
|
|
5104
|
+
function Ir(t, n, e) {
|
|
5105
|
+
const r = vr((t = ut(t, le)).converter, n, e), s = $e(De(t.firestore), "setDoc", t._key, r, null !== t.converter, e);
|
|
5106
|
+
return te(se(t.firestore), [ s.toMutation(t._key, In.none()) ]);
|
|
5107
5107
|
}
|
|
5108
5108
|
|
|
5109
|
-
function Ar(t,
|
|
5110
|
-
const s =
|
|
5109
|
+
function Ar(t, n, e, ...r) {
|
|
5110
|
+
const s = De((t = ut(t, le)).firestore);
|
|
5111
5111
|
// For Compat types, we have to "extract" the underlying types before
|
|
5112
5112
|
// performing validation.
|
|
5113
5113
|
let i;
|
|
5114
|
-
i = "string" == typeof (
|
|
5115
|
-
return
|
|
5114
|
+
i = "string" == typeof (n = l(n)) || n instanceof ge ? ke(s, "updateDoc", t._key, n, e, r) : Le(s, "updateDoc", t._key, n);
|
|
5115
|
+
return te(se(t.firestore), [ i.toMutation(t._key, In.exists(!0)) ]);
|
|
5116
5116
|
}
|
|
5117
5117
|
|
|
5118
5118
|
/**
|
|
@@ -5127,7 +5127,7 @@ function Ar(t, e, n, ...r) {
|
|
|
5127
5127
|
* @returns A `Promise` resolved once the document has been successfully
|
|
5128
5128
|
* deleted from the backend.
|
|
5129
5129
|
*/ function Rr(t) {
|
|
5130
|
-
return
|
|
5130
|
+
return te(se((t = ut(t, le)).firestore), [ new Vn(t._key, In.none()) ]);
|
|
5131
5131
|
}
|
|
5132
5132
|
|
|
5133
5133
|
/**
|
|
@@ -5144,9 +5144,9 @@ function Ar(t, e, n, ...r) {
|
|
|
5144
5144
|
* @throws Error - If the provided input is not a valid Firestore document.
|
|
5145
5145
|
* @returns A `Promise` resolved with a `DocumentReference` pointing to the
|
|
5146
5146
|
* newly created document after it has been written to the backend.
|
|
5147
|
-
*/ function Pr(t,
|
|
5148
|
-
const
|
|
5149
|
-
return
|
|
5147
|
+
*/ function Pr(t, n) {
|
|
5148
|
+
const e = pe(t = ut(t, de)), r = vr(t.converter, n), s = $e(De(t.firestore), "addDoc", e._key, r, null !== e.converter, {});
|
|
5149
|
+
return te(se(t.firestore), [ s.toMutation(e._key, In.exists(!1)) ]).then((() => e));
|
|
5150
5150
|
}
|
|
5151
5151
|
|
|
5152
5152
|
/**
|
|
@@ -5169,14 +5169,14 @@ function Ar(t, e, n, ...r) {
|
|
|
5169
5169
|
* Returns a sentinel for use with {@link @firebase/firestore/lite#(updateDoc:1)} or
|
|
5170
5170
|
* {@link @firebase/firestore/lite#(setDoc:1)} with `{merge: true}` to mark a field for deletion.
|
|
5171
5171
|
*/ function Vr() {
|
|
5172
|
-
return new
|
|
5172
|
+
return new Se("deleteField");
|
|
5173
5173
|
}
|
|
5174
5174
|
|
|
5175
5175
|
/**
|
|
5176
5176
|
* Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
|
|
5177
5177
|
* include a server-generated timestamp in the written data.
|
|
5178
5178
|
*/ function Nr() {
|
|
5179
|
-
return new
|
|
5179
|
+
return new xe("serverTimestamp");
|
|
5180
5180
|
}
|
|
5181
5181
|
|
|
5182
5182
|
/**
|
|
@@ -5193,7 +5193,7 @@ function Ar(t, e, n, ...r) {
|
|
|
5193
5193
|
*/ function Dr(...t) {
|
|
5194
5194
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5195
5195
|
// update() since we'd need the Firestore instance to do this.
|
|
5196
|
-
return new
|
|
5196
|
+
return new qe("arrayUnion", t);
|
|
5197
5197
|
}
|
|
5198
5198
|
|
|
5199
5199
|
/**
|
|
@@ -5209,7 +5209,7 @@ function Ar(t, e, n, ...r) {
|
|
|
5209
5209
|
*/ function $r(...t) {
|
|
5210
5210
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5211
5211
|
// update() since we'd need the Firestore instance to do this.
|
|
5212
|
-
return new
|
|
5212
|
+
return new Oe("arrayRemove", t);
|
|
5213
5213
|
}
|
|
5214
5214
|
|
|
5215
5215
|
/**
|
|
@@ -5231,7 +5231,7 @@ function Ar(t, e, n, ...r) {
|
|
|
5231
5231
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5232
5232
|
* `updateDoc()`
|
|
5233
5233
|
*/ function Sr(t) {
|
|
5234
|
-
return new
|
|
5234
|
+
return new Ce("increment", t);
|
|
5235
5235
|
}
|
|
5236
5236
|
|
|
5237
5237
|
/**
|
|
@@ -5259,23 +5259,23 @@ function Ar(t, e, n, ...r) {
|
|
|
5259
5259
|
* called.
|
|
5260
5260
|
*/ class Fr {
|
|
5261
5261
|
/** @hideconstructor */
|
|
5262
|
-
constructor(t,
|
|
5263
|
-
this._firestore = t, this._commitHandler =
|
|
5264
|
-
this._dataReader =
|
|
5262
|
+
constructor(t, n) {
|
|
5263
|
+
this._firestore = t, this._commitHandler = n, this._mutations = [], this._committed = !1,
|
|
5264
|
+
this._dataReader = De(t);
|
|
5265
5265
|
}
|
|
5266
|
-
set(t,
|
|
5266
|
+
set(t, n, e) {
|
|
5267
5267
|
this._verifyNotCommitted();
|
|
5268
|
-
const r = xr(t, this._firestore), s = vr(r.converter,
|
|
5269
|
-
return this._mutations.push(i.toMutation(r._key,
|
|
5268
|
+
const r = xr(t, this._firestore), s = vr(r.converter, n, e), i = $e(this._dataReader, "WriteBatch.set", r._key, s, null !== r.converter, e);
|
|
5269
|
+
return this._mutations.push(i.toMutation(r._key, In.none())), this;
|
|
5270
5270
|
}
|
|
5271
|
-
update(t,
|
|
5271
|
+
update(t, n, e, ...r) {
|
|
5272
5272
|
this._verifyNotCommitted();
|
|
5273
5273
|
const s = xr(t, this._firestore);
|
|
5274
5274
|
// For Compat types, we have to "extract" the underlying types before
|
|
5275
5275
|
// performing validation.
|
|
5276
5276
|
let i;
|
|
5277
|
-
return i = "string" == typeof (
|
|
5278
|
-
this._mutations.push(i.toMutation(s._key,
|
|
5277
|
+
return i = "string" == typeof (n = l(n)) || n instanceof ge ? ke(this._dataReader, "WriteBatch.update", s._key, n, e, r) : Le(this._dataReader, "WriteBatch.update", s._key, n),
|
|
5278
|
+
this._mutations.push(i.toMutation(s._key, In.exists(!0))), this;
|
|
5279
5279
|
}
|
|
5280
5280
|
/**
|
|
5281
5281
|
* Deletes the document referred to by the provided {@link DocumentReference}.
|
|
@@ -5284,8 +5284,8 @@ function Ar(t, e, n, ...r) {
|
|
|
5284
5284
|
* @returns This `WriteBatch` instance. Used for chaining method calls.
|
|
5285
5285
|
*/ delete(t) {
|
|
5286
5286
|
this._verifyNotCommitted();
|
|
5287
|
-
const
|
|
5288
|
-
return this._mutations = this._mutations.concat(new
|
|
5287
|
+
const n = xr(t, this._firestore);
|
|
5288
|
+
return this._mutations = this._mutations.concat(new Vn(n._key, In.none())), this;
|
|
5289
5289
|
}
|
|
5290
5290
|
/**
|
|
5291
5291
|
* Commits all of the writes in this write batch as a single atomic unit.
|
|
@@ -5306,8 +5306,8 @@ function Ar(t, e, n, ...r) {
|
|
|
5306
5306
|
}
|
|
5307
5307
|
}
|
|
5308
5308
|
|
|
5309
|
-
function xr(t,
|
|
5310
|
-
if ((t = l(t)).firestore !==
|
|
5309
|
+
function xr(t, n) {
|
|
5310
|
+
if ((t = l(t)).firestore !== n) throw new U(R, "Provided document reference is from a different Firestore instance.");
|
|
5311
5311
|
return t;
|
|
5312
5312
|
}
|
|
5313
5313
|
|
|
@@ -5324,8 +5324,8 @@ function xr(t, e) {
|
|
|
5324
5324
|
* @returns A `WriteBatch` that can be used to atomically execute multiple
|
|
5325
5325
|
* writes.
|
|
5326
5326
|
*/ function qr(t) {
|
|
5327
|
-
const
|
|
5328
|
-
return new Fr(t, (t =>
|
|
5327
|
+
const n = se(t = ut(t, oe));
|
|
5328
|
+
return new Fr(t, (t => te(n, t)));
|
|
5329
5329
|
}
|
|
5330
5330
|
|
|
5331
5331
|
/**
|
|
@@ -5367,66 +5367,66 @@ function xr(t, e) {
|
|
|
5367
5367
|
}
|
|
5368
5368
|
async lookup(t) {
|
|
5369
5369
|
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new U(R, "Firestore transactions require all reads to be executed before all writes.");
|
|
5370
|
-
const
|
|
5371
|
-
return
|
|
5370
|
+
const n = await ne(this.datastore, t);
|
|
5371
|
+
return n.forEach((t => this.recordVersion(t))), n;
|
|
5372
5372
|
}
|
|
5373
|
-
set(t,
|
|
5374
|
-
this.write(
|
|
5373
|
+
set(t, n) {
|
|
5374
|
+
this.write(n.toMutation(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5375
5375
|
}
|
|
5376
|
-
update(t,
|
|
5376
|
+
update(t, n) {
|
|
5377
5377
|
try {
|
|
5378
|
-
this.write(
|
|
5378
|
+
this.write(n.toMutation(t, this.preconditionForUpdate(t)));
|
|
5379
5379
|
} catch (t) {
|
|
5380
5380
|
this.lastWriteError = t;
|
|
5381
5381
|
}
|
|
5382
5382
|
this.writtenDocs.add(t.toString());
|
|
5383
5383
|
}
|
|
5384
5384
|
delete(t) {
|
|
5385
|
-
this.write(new
|
|
5385
|
+
this.write(new Vn(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5386
5386
|
}
|
|
5387
5387
|
async commit() {
|
|
5388
5388
|
if (this.ensureCommitNotCalled(), this.lastWriteError) throw this.lastWriteError;
|
|
5389
5389
|
const t = this.readVersions;
|
|
5390
5390
|
// For each mutation, note that the doc was written.
|
|
5391
|
-
this.mutations.forEach((
|
|
5392
|
-
t.delete(
|
|
5391
|
+
this.mutations.forEach((n => {
|
|
5392
|
+
t.delete(n.key.toString());
|
|
5393
5393
|
})),
|
|
5394
5394
|
// For each document that was read but not written to, we want to perform
|
|
5395
5395
|
// a `verify` operation.
|
|
5396
|
-
t.forEach(((t,
|
|
5397
|
-
const
|
|
5398
|
-
this.mutations.push(new
|
|
5399
|
-
})), await
|
|
5396
|
+
t.forEach(((t, n) => {
|
|
5397
|
+
const e = et.fromPath(n);
|
|
5398
|
+
this.mutations.push(new Nn(e, this.precondition(e)));
|
|
5399
|
+
})), await te(this.datastore, this.mutations), this.committed = !0;
|
|
5400
5400
|
}
|
|
5401
5401
|
recordVersion(t) {
|
|
5402
|
-
let
|
|
5403
|
-
if (t.isFoundDocument())
|
|
5402
|
+
let n;
|
|
5403
|
+
if (t.isFoundDocument()) n = t.version; else {
|
|
5404
5404
|
if (!t.isNoDocument()) throw v();
|
|
5405
5405
|
// For deleted docs, we must use baseVersion 0 when we overwrite them.
|
|
5406
|
-
|
|
5406
|
+
n = bt.min();
|
|
5407
5407
|
}
|
|
5408
|
-
const
|
|
5409
|
-
if (
|
|
5410
|
-
if (!
|
|
5408
|
+
const e = this.readVersions.get(t.key.toString());
|
|
5409
|
+
if (e) {
|
|
5410
|
+
if (!n.isEqual(e))
|
|
5411
5411
|
// This transaction will fail no matter what.
|
|
5412
5412
|
throw new U(x, "Document version changed between two reads.");
|
|
5413
|
-
} else this.readVersions.set(t.key.toString(),
|
|
5413
|
+
} else this.readVersions.set(t.key.toString(), n);
|
|
5414
5414
|
}
|
|
5415
5415
|
/**
|
|
5416
5416
|
* Returns the version of this document when it was read in this transaction,
|
|
5417
5417
|
* as a precondition, or no precondition if it was not read.
|
|
5418
5418
|
*/ precondition(t) {
|
|
5419
|
-
const
|
|
5420
|
-
return !this.writtenDocs.has(t.toString()) &&
|
|
5419
|
+
const n = this.readVersions.get(t.toString());
|
|
5420
|
+
return !this.writtenDocs.has(t.toString()) && n ? In.updateTime(n) : In.none();
|
|
5421
5421
|
}
|
|
5422
5422
|
/**
|
|
5423
5423
|
* Returns the precondition for a document if the operation is an update.
|
|
5424
5424
|
*/ preconditionForUpdate(t) {
|
|
5425
|
-
const
|
|
5425
|
+
const n = this.readVersions.get(t.toString());
|
|
5426
5426
|
// The first time a document is written, we want to take into account the
|
|
5427
5427
|
// read time and existence
|
|
5428
|
-
if (!this.writtenDocs.has(t.toString()) &&
|
|
5429
|
-
if (
|
|
5428
|
+
if (!this.writtenDocs.has(t.toString()) && n) {
|
|
5429
|
+
if (n.isEqual(bt.min()))
|
|
5430
5430
|
// The document doesn't exist, so fail the transaction.
|
|
5431
5431
|
// This has to be validated locally because you can't send a
|
|
5432
5432
|
// precondition that a document does not exist without changing the
|
|
@@ -5438,11 +5438,11 @@ function xr(t, e) {
|
|
|
5438
5438
|
// transaction.
|
|
5439
5439
|
throw new U(R, "Can't update a document that doesn't exist.");
|
|
5440
5440
|
// Document exists, base precondition on document update time.
|
|
5441
|
-
return
|
|
5441
|
+
return In.updateTime(n);
|
|
5442
5442
|
}
|
|
5443
5443
|
// Document was not read, so we just use the preconditions for a blind
|
|
5444
5444
|
// update.
|
|
5445
|
-
return
|
|
5445
|
+
return In.exists(!0);
|
|
5446
5446
|
}
|
|
5447
5447
|
write(t) {
|
|
5448
5448
|
this.ensureCommitNotCalled(), this.mutations.push(t);
|
|
@@ -5471,19 +5471,19 @@ function xr(t, e) {
|
|
|
5471
5471
|
* with backoff.
|
|
5472
5472
|
*/
|
|
5473
5473
|
class Cr {
|
|
5474
|
-
constructor(t,
|
|
5475
|
-
this.asyncQueue = t, this.datastore =
|
|
5476
|
-
this.Tt = 5, this.It = new
|
|
5474
|
+
constructor(t, n, e, r) {
|
|
5475
|
+
this.asyncQueue = t, this.datastore = n, this.updateFunction = e, this.deferred = r,
|
|
5476
|
+
this.Tt = 5, this.It = new Xn(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
|
|
5477
5477
|
}
|
|
5478
5478
|
/** Runs the transaction and sets the result on deferred. */ run() {
|
|
5479
5479
|
this.Tt -= 1, this.At();
|
|
5480
5480
|
}
|
|
5481
5481
|
At() {
|
|
5482
5482
|
this.It.W((async () => {
|
|
5483
|
-
const t = new Or(this.datastore),
|
|
5484
|
-
|
|
5483
|
+
const t = new Or(this.datastore), n = this.Rt(t);
|
|
5484
|
+
n && n.then((n => {
|
|
5485
5485
|
this.asyncQueue.enqueueAndForget((() => t.commit().then((() => {
|
|
5486
|
-
this.deferred.resolve(
|
|
5486
|
+
this.deferred.resolve(n);
|
|
5487
5487
|
})).catch((t => {
|
|
5488
5488
|
this.Pt(t);
|
|
5489
5489
|
}))));
|
|
@@ -5494,8 +5494,8 @@ class Cr {
|
|
|
5494
5494
|
}
|
|
5495
5495
|
Rt(t) {
|
|
5496
5496
|
try {
|
|
5497
|
-
const
|
|
5498
|
-
return !at(
|
|
5497
|
+
const n = this.updateFunction(t);
|
|
5498
|
+
return !at(n) && n.catch && n.then ? n : (this.deferred.reject(Error("Transaction callback must return a Promise")),
|
|
5499
5499
|
null);
|
|
5500
5500
|
} catch (t) {
|
|
5501
5501
|
// Do not retry errors thrown by user provided updateFunction.
|
|
@@ -5510,8 +5510,8 @@ class Cr {
|
|
|
5510
5510
|
if ("FirebaseError" === t.name) {
|
|
5511
5511
|
// In transactions, the backend will fail outdated reads with FAILED_PRECONDITION and
|
|
5512
5512
|
// non-matching document versions with ABORTED. These errors should be retried.
|
|
5513
|
-
const
|
|
5514
|
-
return "aborted" ===
|
|
5513
|
+
const n = t.code;
|
|
5514
|
+
return "aborted" === n || "failed-precondition" === n || !
|
|
5515
5515
|
/**
|
|
5516
5516
|
* Determines whether an error code represents a permanent error when received
|
|
5517
5517
|
* in response to a non-write operation.
|
|
@@ -5548,7 +5548,7 @@ class Cr {
|
|
|
5548
5548
|
case k:
|
|
5549
5549
|
return !0;
|
|
5550
5550
|
}
|
|
5551
|
-
}(
|
|
5551
|
+
}(n);
|
|
5552
5552
|
}
|
|
5553
5553
|
return !1;
|
|
5554
5554
|
}
|
|
@@ -5603,8 +5603,8 @@ class Cr {
|
|
|
5603
5603
|
* in newer versions of TypeScript defines `finally`, which is not available in
|
|
5604
5604
|
* IE.
|
|
5605
5605
|
*/ class kr {
|
|
5606
|
-
constructor(t,
|
|
5607
|
-
this.asyncQueue = t, this.timerId =
|
|
5606
|
+
constructor(t, n, e, r, s) {
|
|
5607
|
+
this.asyncQueue = t, this.timerId = n, this.targetTimeMs = e, this.op = r, this.removalCallback = s,
|
|
5608
5608
|
this.deferred = new j, this.then = this.deferred.promise.then.bind(this.deferred.promise),
|
|
5609
5609
|
// It's normal for the deferred promise to be canceled (due to cancellation)
|
|
5610
5610
|
// and so we attach a dummy catch callback to avoid
|
|
@@ -5624,9 +5624,9 @@ class Cr {
|
|
|
5624
5624
|
* from its delayedOperations list.
|
|
5625
5625
|
* PORTING NOTE: This exists to prevent making removeDelayedOperation() and
|
|
5626
5626
|
* the DelayedOperation class public.
|
|
5627
|
-
*/ static createAndSchedule(t,
|
|
5628
|
-
const i = Date.now() +
|
|
5629
|
-
return o.start(
|
|
5627
|
+
*/ static createAndSchedule(t, n, e, r, s) {
|
|
5628
|
+
const i = Date.now() + e, o = new kr(t, n, i, r, s);
|
|
5629
|
+
return o.start(e), o;
|
|
5630
5630
|
}
|
|
5631
5631
|
/**
|
|
5632
5632
|
* Starts the timer. This is called immediately after construction by
|
|
@@ -5697,7 +5697,7 @@ class Cr {
|
|
|
5697
5697
|
// List of TimerIds to fast-forward delays for.
|
|
5698
5698
|
this.Ot = [],
|
|
5699
5699
|
// Backoff timer used to schedule retries for retryable operations
|
|
5700
|
-
this.It = new
|
|
5700
|
+
this.It = new Xn(this, "async_queue_retry" /* AsyncQueueRetry */),
|
|
5701
5701
|
// Visibility handler that triggers an immediate retry of all retryable
|
|
5702
5702
|
// operations. Meant to speed up recovery when we regain file system access
|
|
5703
5703
|
// after page comes into foreground.
|
|
@@ -5726,8 +5726,8 @@ class Cr {
|
|
|
5726
5726
|
enterRestrictedMode(t) {
|
|
5727
5727
|
if (!this.$t) {
|
|
5728
5728
|
this.$t = !0, this.qt = t || !1;
|
|
5729
|
-
const
|
|
5730
|
-
|
|
5729
|
+
const n = Lr();
|
|
5730
|
+
n && "function" == typeof n.removeEventListener && n.removeEventListener("visibilitychange", this.Ct);
|
|
5731
5731
|
}
|
|
5732
5732
|
}
|
|
5733
5733
|
enqueue(t) {
|
|
@@ -5737,9 +5737,9 @@ class Cr {
|
|
|
5737
5737
|
// Create a deferred Promise that we can return to the callee. This
|
|
5738
5738
|
// allows us to return a "hanging Promise" only to the callee and still
|
|
5739
5739
|
// advance the queue even when the operation is not run.
|
|
5740
|
-
const
|
|
5741
|
-
return this.kt((() => this.$t && this.qt ? Promise.resolve() : (t().then(
|
|
5742
|
-
|
|
5740
|
+
const n = new j;
|
|
5741
|
+
return this.kt((() => this.$t && this.qt ? Promise.resolve() : (t().then(n.resolve, n.reject),
|
|
5742
|
+
n.promise))).then((() => n.promise));
|
|
5743
5743
|
}
|
|
5744
5744
|
enqueueRetryable(t) {
|
|
5745
5745
|
this.enqueueAndForget((() => (this.Dt.push(t), this.Ut())));
|
|
@@ -5809,18 +5809,18 @@ class Cr {
|
|
|
5809
5809
|
}
|
|
5810
5810
|
}
|
|
5811
5811
|
kt(t) {
|
|
5812
|
-
const
|
|
5812
|
+
const n = this.Nt.then((() => (this.xt = !0, t().catch((t => {
|
|
5813
5813
|
this.Ft = t, this.xt = !1;
|
|
5814
|
-
const
|
|
5814
|
+
const n =
|
|
5815
5815
|
/**
|
|
5816
5816
|
* Chrome includes Error.message in Error.stack. Other browsers do not.
|
|
5817
5817
|
* This returns expected output of message + stack when available.
|
|
5818
5818
|
* @param error - Error or FirestoreError
|
|
5819
5819
|
*/
|
|
5820
5820
|
function(t) {
|
|
5821
|
-
let
|
|
5822
|
-
t.stack && (
|
|
5823
|
-
return
|
|
5821
|
+
let n = t.message || "";
|
|
5822
|
+
t.stack && (n = t.stack.includes(t.message) ? t.stack : t.message + "\n" + t.stack);
|
|
5823
|
+
return n;
|
|
5824
5824
|
}
|
|
5825
5825
|
/**
|
|
5826
5826
|
* @license
|
|
@@ -5850,15 +5850,15 @@ class Cr {
|
|
|
5850
5850
|
// Re-throw the error so that this.tail becomes a rejected Promise and
|
|
5851
5851
|
// all further attempts to chain (via .then) will just short-circuit
|
|
5852
5852
|
// and return the rejected Promise.
|
|
5853
|
-
throw y("INTERNAL UNHANDLED ERROR: ",
|
|
5853
|
+
throw y("INTERNAL UNHANDLED ERROR: ", n), t;
|
|
5854
5854
|
})).then((t => (this.xt = !1, t))))));
|
|
5855
|
-
return this.Nt =
|
|
5855
|
+
return this.Nt = n, n;
|
|
5856
5856
|
}
|
|
5857
|
-
enqueueAfterDelay(t,
|
|
5857
|
+
enqueueAfterDelay(t, n, e) {
|
|
5858
5858
|
this.Lt(),
|
|
5859
5859
|
// Fast-forward delays for timerIds that have been overriden.
|
|
5860
|
-
this.Ot.indexOf(t) > -1 && (
|
|
5861
|
-
const r = kr.createAndSchedule(this, t,
|
|
5860
|
+
this.Ot.indexOf(t) > -1 && (n = 0);
|
|
5861
|
+
const r = kr.createAndSchedule(this, t, n, e, (t => this.jt(t)));
|
|
5862
5862
|
return this.St.push(r), r;
|
|
5863
5863
|
}
|
|
5864
5864
|
Lt() {
|
|
@@ -5882,7 +5882,7 @@ class Cr {
|
|
|
5882
5882
|
* For Tests: Determine if a delayed operation with a particular TimerId
|
|
5883
5883
|
* exists.
|
|
5884
5884
|
*/ Bt(t) {
|
|
5885
|
-
for (const
|
|
5885
|
+
for (const n of this.St) if (n.timerId === t) return !0;
|
|
5886
5886
|
return !1;
|
|
5887
5887
|
}
|
|
5888
5888
|
/**
|
|
@@ -5895,8 +5895,8 @@ class Cr {
|
|
|
5895
5895
|
// Note that draining may generate more delayed ops, so we do that first.
|
|
5896
5896
|
return this.Mt().then((() => {
|
|
5897
5897
|
// Run ops in the same order they'd run if they ran naturally.
|
|
5898
|
-
this.St.sort(((t,
|
|
5899
|
-
for (const
|
|
5898
|
+
this.St.sort(((t, n) => t.targetTimeMs - n.targetTimeMs));
|
|
5899
|
+
for (const n of this.St) if (n.skipDelay(), "all" /* All */ !== t && n.timerId === t) break;
|
|
5900
5900
|
return this.Mt();
|
|
5901
5901
|
}));
|
|
5902
5902
|
}
|
|
@@ -5907,15 +5907,15 @@ class Cr {
|
|
|
5907
5907
|
}
|
|
5908
5908
|
/** Called once a DelayedOperation is run or canceled. */ jt(t) {
|
|
5909
5909
|
// NOTE: indexOf / slice are O(n), but delayedOperations is expected to be small.
|
|
5910
|
-
const
|
|
5911
|
-
this.St.splice(
|
|
5910
|
+
const n = this.St.indexOf(t);
|
|
5911
|
+
this.St.splice(n, 1);
|
|
5912
5912
|
}
|
|
5913
5913
|
}
|
|
5914
5914
|
|
|
5915
5915
|
class jr {
|
|
5916
5916
|
/** @hideconstructor */
|
|
5917
|
-
constructor(t,
|
|
5918
|
-
this._firestore = t, this._transaction =
|
|
5917
|
+
constructor(t, n) {
|
|
5918
|
+
this._firestore = t, this._transaction = n, this._dataReader = De(t);
|
|
5919
5919
|
}
|
|
5920
5920
|
/**
|
|
5921
5921
|
* Reads the document referenced by the provided {@link DocumentReference}.
|
|
@@ -5923,25 +5923,25 @@ class jr {
|
|
|
5923
5923
|
* @param documentRef - A reference to the document to be read.
|
|
5924
5924
|
* @returns A `DocumentSnapshot` with the read data.
|
|
5925
5925
|
*/ get(t) {
|
|
5926
|
-
const
|
|
5927
|
-
return this._transaction.lookup([
|
|
5926
|
+
const n = xr(t, this._firestore), e = new br(this._firestore);
|
|
5927
|
+
return this._transaction.lookup([ n._key ]).then((t => {
|
|
5928
5928
|
if (!t || 1 !== t.length) return v();
|
|
5929
5929
|
const r = t[0];
|
|
5930
|
-
if (r.isFoundDocument()) return new
|
|
5931
|
-
if (r.isNoDocument()) return new
|
|
5930
|
+
if (r.isFoundDocument()) return new Ke(this._firestore, e, r.key, r, n.converter);
|
|
5931
|
+
if (r.isNoDocument()) return new Ke(this._firestore, e, n._key, null, n.converter);
|
|
5932
5932
|
throw v();
|
|
5933
5933
|
}));
|
|
5934
5934
|
}
|
|
5935
|
-
set(t,
|
|
5936
|
-
const r = xr(t, this._firestore), s = vr(r.converter,
|
|
5935
|
+
set(t, n, e) {
|
|
5936
|
+
const r = xr(t, this._firestore), s = vr(r.converter, n, e), i = $e(this._dataReader, "Transaction.set", r._key, s, null !== r.converter, e);
|
|
5937
5937
|
return this._transaction.set(r._key, i), this;
|
|
5938
5938
|
}
|
|
5939
|
-
update(t,
|
|
5939
|
+
update(t, n, e, ...r) {
|
|
5940
5940
|
const s = xr(t, this._firestore);
|
|
5941
5941
|
// For Compat types, we have to "extract" the underlying types before
|
|
5942
5942
|
// performing validation.
|
|
5943
5943
|
let i;
|
|
5944
|
-
return i = "string" == typeof (
|
|
5944
|
+
return i = "string" == typeof (n = l(n)) || n instanceof ge ? ke(this._dataReader, "Transaction.update", s._key, n, e, r) : Le(this._dataReader, "Transaction.update", s._key, n),
|
|
5945
5945
|
this._transaction.update(s._key, i), this;
|
|
5946
5946
|
}
|
|
5947
5947
|
/**
|
|
@@ -5950,8 +5950,8 @@ class jr {
|
|
|
5950
5950
|
* @param documentRef - A reference to the document to be deleted.
|
|
5951
5951
|
* @returns This `Transaction` instance. Used for chaining method calls.
|
|
5952
5952
|
*/ delete(t) {
|
|
5953
|
-
const
|
|
5954
|
-
return this._transaction.delete(
|
|
5953
|
+
const n = xr(t, this._firestore);
|
|
5954
|
+
return this._transaction.delete(n._key), this;
|
|
5955
5955
|
}
|
|
5956
5956
|
}
|
|
5957
5957
|
|
|
@@ -5971,9 +5971,9 @@ class jr {
|
|
|
5971
5971
|
* (the `updateFunction` returned a failed promise), the promise returned by the
|
|
5972
5972
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
5973
5973
|
* rejected promise with the corresponding failure error is returned.
|
|
5974
|
-
*/ function Mr(t,
|
|
5975
|
-
const
|
|
5976
|
-
return new Cr(new Ur,
|
|
5974
|
+
*/ function Mr(t, n) {
|
|
5975
|
+
const e = se(t = ut(t, oe)), r = new j;
|
|
5976
|
+
return new Cr(new Ur, e, (e => n(new jr(t, e))), r).run(), r.promise;
|
|
5977
5977
|
}
|
|
5978
5978
|
|
|
5979
5979
|
/**
|
|
@@ -5985,12 +5985,12 @@ class jr {
|
|
|
5985
5985
|
* @packageDocumentation
|
|
5986
5986
|
*/ !function(t) {
|
|
5987
5987
|
d = t;
|
|
5988
|
-
}(`${s}_lite`),
|
|
5989
|
-
const
|
|
5990
|
-
return
|
|
5988
|
+
}(`${s}_lite`), e(new i("firestore/lite", ((t, {options: n}) => {
|
|
5989
|
+
const e = t.getProvider("app").getImmediate(), r = new oe(e, new G(t.getProvider("auth-internal")), new H(t.getProvider("app-check-internal")));
|
|
5990
|
+
return n && r._setSettings(n), r;
|
|
5991
5991
|
}), "PUBLIC")),
|
|
5992
5992
|
// RUNTIME_ENV and BUILD_TARGET are replaced by real values during the compilation
|
|
5993
|
-
r("firestore-lite", "3.4.
|
|
5993
|
+
r("firestore-lite", "3.4.8", "rn"), r("firestore-lite", "3.4.8", "esm2017");
|
|
5994
5994
|
|
|
5995
|
-
export {
|
|
5995
|
+
export { be as Bytes, de as CollectionReference, le as DocumentReference, Ke as DocumentSnapshot, ge as FieldPath, Ee as FieldValue, oe as Firestore, U as FirestoreError, Te as GeoPoint, fe as Query, nr as QueryConstraint, Je as QueryDocumentSnapshot, Xe as QuerySnapshot, vt as Timestamp, jr as Transaction, Fr as WriteBatch, Pr as addDoc, $r as arrayRemove, Dr as arrayUnion, we as collection, me as collectionGroup, ae as connectFirestoreEmulator, Rr 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, Sr 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, m as setLogLevel, Ze as snapshotEqual, fr as startAfter, lr as startAt, he as terminate, Ar as updateDoc, sr as where, qr as writeBatch };
|
|
5996
5996
|
//# sourceMappingURL=index.rn.esm2017.js.map
|