@firebase/firestore 3.3.0-canary.e0fe2b668 → 3.3.0-canary.e34e98e73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm2017.js +3 -3
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +3 -3
- package/dist/index.node.cjs.js +2 -2
- package/dist/index.node.mjs +2 -2
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +3 -3
- package/dist/lite/index.browser.esm2017.js +2 -2
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +2 -2
- package/dist/lite/index.node.cjs.js +2 -2
- package/dist/lite/index.node.mjs +2 -2
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +1106 -1106
- 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 e, _registerComponent as n, 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 @@ l.MOCK_USER = new l("mock-user");
|
|
|
66
66
|
* See the License for the specific language governing permissions and
|
|
67
67
|
* limitations under the License.
|
|
68
68
|
*/
|
|
69
|
-
let f = "9.4.0-canary.
|
|
69
|
+
let f = "9.4.0-canary.e34e98e73";
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* @license
|
|
@@ -102,26 +102,26 @@ const d = new o("@firebase/firestore");
|
|
|
102
102
|
d.setLogLevel(t);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
function m(t, ...
|
|
105
|
+
function m(t, ...e) {
|
|
106
106
|
if (d.logLevel <= u.DEBUG) {
|
|
107
|
-
const
|
|
108
|
-
d.debug(`Firestore (${f}): ${t}`, ...
|
|
107
|
+
const n = e.map(_);
|
|
108
|
+
d.debug(`Firestore (${f}): ${t}`, ...n);
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
function p(t, ...
|
|
112
|
+
function p(t, ...e) {
|
|
113
113
|
if (d.logLevel <= u.ERROR) {
|
|
114
|
-
const
|
|
115
|
-
d.error(`Firestore (${f}): ${t}`, ...
|
|
114
|
+
const n = e.map(_);
|
|
115
|
+
d.error(`Firestore (${f}): ${t}`, ...n);
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
120
|
* @internal
|
|
121
|
-
*/ function y(t, ...
|
|
121
|
+
*/ function y(t, ...e) {
|
|
122
122
|
if (d.logLevel <= u.WARN) {
|
|
123
|
-
const
|
|
124
|
-
d.warn(`Firestore (${f}): ${t}`, ...
|
|
123
|
+
const n = e.map(_);
|
|
124
|
+
d.warn(`Firestore (${f}): ${t}`, ...n);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|
|
@@ -130,8 +130,8 @@ function p(t, ...n) {
|
|
|
130
130
|
*/ function _(t) {
|
|
131
131
|
if ("string" == typeof t) return t;
|
|
132
132
|
try {
|
|
133
|
-
return
|
|
134
|
-
} catch (
|
|
133
|
+
return e = t, JSON.stringify(e);
|
|
134
|
+
} catch (e) {
|
|
135
135
|
// Converting to JSON failed, just log the object directly
|
|
136
136
|
return t;
|
|
137
137
|
}
|
|
@@ -152,7 +152,7 @@ function p(t, ...n) {
|
|
|
152
152
|
* limitations under the License.
|
|
153
153
|
*/
|
|
154
154
|
/** Formats an object as a JSON string, suitable for logging. */
|
|
155
|
-
var
|
|
155
|
+
var e;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
/**
|
|
@@ -181,11 +181,11 @@ function p(t, ...n) {
|
|
|
181
181
|
*/ function g(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 e = `FIRESTORE (${f}) 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 p(
|
|
188
|
+
throw p(e), new Error(e);
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
/**
|
|
@@ -193,16 +193,16 @@ function p(t, ...n) {
|
|
|
193
193
|
* given message if it did.
|
|
194
194
|
*
|
|
195
195
|
* Messages are stripped in production builds.
|
|
196
|
-
*/ function
|
|
196
|
+
*/ function v(t, e) {
|
|
197
197
|
t || g();
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
/**
|
|
201
201
|
* Casts `obj` to `T`. In non-production builds, verifies that `obj` is an
|
|
202
202
|
* instance of `T` before casting.
|
|
203
|
-
*/ function
|
|
203
|
+
*/ function b(t,
|
|
204
204
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
205
|
-
|
|
205
|
+
e) {
|
|
206
206
|
return t;
|
|
207
207
|
}
|
|
208
208
|
|
|
@@ -233,8 +233,8 @@ n) {
|
|
|
233
233
|
/**
|
|
234
234
|
* A custom error description.
|
|
235
235
|
*/
|
|
236
|
-
|
|
237
|
-
super(
|
|
236
|
+
e) {
|
|
237
|
+
super(e), this.code = t, this.message = e,
|
|
238
238
|
/** The custom name for all FirestoreErrors. */
|
|
239
239
|
this.name = "FirebaseError",
|
|
240
240
|
// HACK: We write a toString property directly because Error is not a real
|
|
@@ -261,8 +261,8 @@ n) {
|
|
|
261
261
|
* limitations under the License.
|
|
262
262
|
*/ class j {
|
|
263
263
|
constructor() {
|
|
264
|
-
this.promise = new Promise(((t,
|
|
265
|
-
this.resolve = t, this.reject =
|
|
264
|
+
this.promise = new Promise(((t, e) => {
|
|
265
|
+
this.resolve = t, this.reject = e;
|
|
266
266
|
}));
|
|
267
267
|
}
|
|
268
268
|
}
|
|
@@ -283,8 +283,8 @@ n) {
|
|
|
283
283
|
* See the License for the specific language governing permissions and
|
|
284
284
|
* limitations under the License.
|
|
285
285
|
*/ class k {
|
|
286
|
-
constructor(t,
|
|
287
|
-
this.user =
|
|
286
|
+
constructor(t, e) {
|
|
287
|
+
this.user = e, this.type = "OAuth", this.authHeaders = {},
|
|
288
288
|
// Set the headers using Object Literal notation to avoid minification
|
|
289
289
|
this.authHeaders.Authorization = `Bearer ${t}`;
|
|
290
290
|
}
|
|
@@ -298,9 +298,9 @@ n) {
|
|
|
298
298
|
return Promise.resolve(null);
|
|
299
299
|
}
|
|
300
300
|
invalidateToken() {}
|
|
301
|
-
start(t,
|
|
301
|
+
start(t, e) {
|
|
302
302
|
// Fire with initial user.
|
|
303
|
-
t.enqueueRetryable((() =>
|
|
303
|
+
t.enqueueRetryable((() => e(l.UNAUTHENTICATED)));
|
|
304
304
|
}
|
|
305
305
|
shutdown() {}
|
|
306
306
|
}
|
|
@@ -322,10 +322,10 @@ n) {
|
|
|
322
322
|
return Promise.resolve(this.token);
|
|
323
323
|
}
|
|
324
324
|
invalidateToken() {}
|
|
325
|
-
start(t,
|
|
326
|
-
this.changeListener =
|
|
325
|
+
start(t, e) {
|
|
326
|
+
this.changeListener = e,
|
|
327
327
|
// Fire with initial user.
|
|
328
|
-
t.enqueueRetryable((() =>
|
|
328
|
+
t.enqueueRetryable((() => e(this.token.user)));
|
|
329
329
|
}
|
|
330
330
|
shutdown() {
|
|
331
331
|
this.changeListener = null;
|
|
@@ -339,11 +339,11 @@ n) {
|
|
|
339
339
|
}));
|
|
340
340
|
}
|
|
341
341
|
getToken() {
|
|
342
|
-
return this.auth ? this.auth.getToken().then((t => t ? (
|
|
342
|
+
return this.auth ? this.auth.getToken().then((t => t ? (v("string" == typeof t.accessToken),
|
|
343
343
|
new k(t.accessToken, new l(this.auth.getUid()))) : null)) : Promise.resolve(null);
|
|
344
344
|
}
|
|
345
345
|
invalidateToken() {}
|
|
346
|
-
start(t,
|
|
346
|
+
start(t, e) {}
|
|
347
347
|
shutdown() {}
|
|
348
348
|
}
|
|
349
349
|
|
|
@@ -354,15 +354,15 @@ n) {
|
|
|
354
354
|
* recover from unauthenticated errors (see b/33147818 for context), but it's
|
|
355
355
|
* safer to keep the implementation as-is.
|
|
356
356
|
*/ class z {
|
|
357
|
-
constructor(t,
|
|
358
|
-
this.t = t, this.i =
|
|
357
|
+
constructor(t, e, n) {
|
|
358
|
+
this.t = t, this.i = e, this.o = n, this.type = "FirstParty", this.user = l.FIRST_PARTY;
|
|
359
359
|
}
|
|
360
360
|
get authHeaders() {
|
|
361
361
|
const t = {
|
|
362
362
|
"X-Goog-AuthUser": this.i
|
|
363
|
-
},
|
|
363
|
+
}, e = this.t.auth.getAuthHeaderValueForFirstParty([]);
|
|
364
364
|
// Use array notation to prevent minification
|
|
365
|
-
return
|
|
365
|
+
return e && (t.Authorization = e), this.o && (t["X-Goog-Iam-Authorization-Token"] = this.o),
|
|
366
366
|
t;
|
|
367
367
|
}
|
|
368
368
|
}
|
|
@@ -372,15 +372,15 @@ n) {
|
|
|
372
372
|
* to authenticate the user, using technique that is only available
|
|
373
373
|
* to applications hosted by Google.
|
|
374
374
|
*/ class W {
|
|
375
|
-
constructor(t,
|
|
376
|
-
this.t = t, this.i =
|
|
375
|
+
constructor(t, e, n) {
|
|
376
|
+
this.t = t, this.i = e, this.o = n;
|
|
377
377
|
}
|
|
378
378
|
getToken() {
|
|
379
379
|
return Promise.resolve(new z(this.t, this.i, this.o));
|
|
380
380
|
}
|
|
381
|
-
start(t,
|
|
381
|
+
start(t, e) {
|
|
382
382
|
// Fire with initial uid.
|
|
383
|
-
t.enqueueRetryable((() =>
|
|
383
|
+
t.enqueueRetryable((() => e(l.FIRST_PARTY)));
|
|
384
384
|
}
|
|
385
385
|
shutdown() {}
|
|
386
386
|
invalidateToken() {}
|
|
@@ -424,8 +424,8 @@ class G {
|
|
|
424
424
|
* @param useFetchStreams Whether to use the Fetch API instead of
|
|
425
425
|
* XMLHTTPRequest
|
|
426
426
|
*/
|
|
427
|
-
constructor(t,
|
|
428
|
-
this.databaseId = t, this.appId =
|
|
427
|
+
constructor(t, e, n, r, s, i, o, u) {
|
|
428
|
+
this.databaseId = t, this.appId = e, this.persistenceKey = n, this.host = r, this.ssl = s,
|
|
429
429
|
this.forceLongPolling = i, this.autoDetectLongPolling = o, this.useFetchStreams = u;
|
|
430
430
|
}
|
|
431
431
|
}
|
|
@@ -436,8 +436,8 @@ class G {
|
|
|
436
436
|
* @internal
|
|
437
437
|
*/
|
|
438
438
|
class H {
|
|
439
|
-
constructor(t,
|
|
440
|
-
this.projectId = t, this.database =
|
|
439
|
+
constructor(t, e) {
|
|
440
|
+
this.projectId = t, this.database = e || "(default)";
|
|
441
441
|
}
|
|
442
442
|
get isDefaultDatabase() {
|
|
443
443
|
return "(default)" === this.database;
|
|
@@ -467,9 +467,9 @@ class H {
|
|
|
467
467
|
* Path represents an ordered sequence of string segments.
|
|
468
468
|
*/
|
|
469
469
|
class Y {
|
|
470
|
-
constructor(t,
|
|
471
|
-
void 0 ===
|
|
472
|
-
this.segments = t, this.offset =
|
|
470
|
+
constructor(t, e, n) {
|
|
471
|
+
void 0 === e ? e = 0 : e > t.length && g(), void 0 === n ? n = t.length - e : n > t.length - e && g(),
|
|
472
|
+
this.segments = t, this.offset = e, this.len = n;
|
|
473
473
|
}
|
|
474
474
|
get length() {
|
|
475
475
|
return this.len;
|
|
@@ -478,10 +478,10 @@ class Y {
|
|
|
478
478
|
return 0 === Y.comparator(this, t);
|
|
479
479
|
}
|
|
480
480
|
child(t) {
|
|
481
|
-
const
|
|
481
|
+
const e = this.segments.slice(this.offset, this.limit());
|
|
482
482
|
return t instanceof Y ? t.forEach((t => {
|
|
483
|
-
|
|
484
|
-
})) :
|
|
483
|
+
e.push(t);
|
|
484
|
+
})) : e.push(t), this.construct(e);
|
|
485
485
|
}
|
|
486
486
|
/** The index of one past the last segment of the path. */ limit() {
|
|
487
487
|
return this.offset + this.length;
|
|
@@ -506,28 +506,28 @@ class Y {
|
|
|
506
506
|
}
|
|
507
507
|
isPrefixOf(t) {
|
|
508
508
|
if (t.length < this.length) return !1;
|
|
509
|
-
for (let
|
|
509
|
+
for (let e = 0; e < this.length; e++) if (this.get(e) !== t.get(e)) return !1;
|
|
510
510
|
return !0;
|
|
511
511
|
}
|
|
512
512
|
isImmediateParentOf(t) {
|
|
513
513
|
if (this.length + 1 !== t.length) return !1;
|
|
514
|
-
for (let
|
|
514
|
+
for (let e = 0; e < this.length; e++) if (this.get(e) !== t.get(e)) return !1;
|
|
515
515
|
return !0;
|
|
516
516
|
}
|
|
517
517
|
forEach(t) {
|
|
518
|
-
for (let
|
|
518
|
+
for (let e = this.offset, n = this.limit(); e < n; e++) t(this.segments[e]);
|
|
519
519
|
}
|
|
520
520
|
toArray() {
|
|
521
521
|
return this.segments.slice(this.offset, this.limit());
|
|
522
522
|
}
|
|
523
|
-
static comparator(t,
|
|
524
|
-
const
|
|
525
|
-
for (let r = 0; r <
|
|
526
|
-
const
|
|
527
|
-
if (
|
|
528
|
-
if (
|
|
523
|
+
static comparator(t, e) {
|
|
524
|
+
const n = Math.min(t.length, e.length);
|
|
525
|
+
for (let r = 0; r < n; r++) {
|
|
526
|
+
const n = t.get(r), s = e.get(r);
|
|
527
|
+
if (n < s) return -1;
|
|
528
|
+
if (n > s) return 1;
|
|
529
529
|
}
|
|
530
|
-
return t.length <
|
|
530
|
+
return t.length < e.length ? -1 : t.length > e.length ? 1 : 0;
|
|
531
531
|
}
|
|
532
532
|
}
|
|
533
533
|
|
|
@@ -537,8 +537,8 @@ class Y {
|
|
|
537
537
|
*
|
|
538
538
|
* @internal
|
|
539
539
|
*/ class K extends Y {
|
|
540
|
-
construct(t,
|
|
541
|
-
return new K(t,
|
|
540
|
+
construct(t, e, n) {
|
|
541
|
+
return new K(t, e, n);
|
|
542
542
|
}
|
|
543
543
|
canonicalString() {
|
|
544
544
|
// NOTE: The client is ignorant of any path segments containing escape
|
|
@@ -557,13 +557,13 @@ class Y {
|
|
|
557
557
|
// NOTE: The client is ignorant of any path segments containing escape
|
|
558
558
|
// sequences (e.g. __id123__) and just passes them through raw (they exist
|
|
559
559
|
// for legacy reasons and should not be used frequently).
|
|
560
|
-
const
|
|
561
|
-
for (const
|
|
562
|
-
if (
|
|
560
|
+
const e = [];
|
|
561
|
+
for (const n of t) {
|
|
562
|
+
if (n.indexOf("//") >= 0) throw new U(A, `Invalid segment (${n}). Paths must not contain // in them.`);
|
|
563
563
|
// Strip leading and traling slashed.
|
|
564
|
-
|
|
564
|
+
e.push(...n.split("/").filter((t => t.length > 0)));
|
|
565
565
|
}
|
|
566
|
-
return new K(
|
|
566
|
+
return new K(e);
|
|
567
567
|
}
|
|
568
568
|
static emptyPath() {
|
|
569
569
|
return new K([]);
|
|
@@ -576,8 +576,8 @@ const J = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
576
576
|
* A dot-separated path for navigating sub-objects within a document.
|
|
577
577
|
* @internal
|
|
578
578
|
*/ class Z extends Y {
|
|
579
|
-
construct(t,
|
|
580
|
-
return new Z(t,
|
|
579
|
+
construct(t, e, n) {
|
|
580
|
+
return new Z(t, e, n);
|
|
581
581
|
}
|
|
582
582
|
/**
|
|
583
583
|
* Returns true if the string could be used as a segment in a field path
|
|
@@ -612,24 +612,24 @@ const J = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
612
612
|
* TODO(b/37244157): we should make this more strict. Right now, it allows
|
|
613
613
|
* non-identifier path components, even if they aren't escaped.
|
|
614
614
|
*/ static fromServerFormat(t) {
|
|
615
|
-
const
|
|
616
|
-
let
|
|
615
|
+
const e = [];
|
|
616
|
+
let n = "", r = 0;
|
|
617
617
|
const s = () => {
|
|
618
|
-
if (0 ===
|
|
619
|
-
|
|
618
|
+
if (0 === n.length) throw new U(A, `Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);
|
|
619
|
+
e.push(n), n = "";
|
|
620
620
|
};
|
|
621
621
|
let i = !1;
|
|
622
622
|
for (;r < t.length; ) {
|
|
623
|
-
const
|
|
624
|
-
if ("\\" ===
|
|
623
|
+
const e = t[r];
|
|
624
|
+
if ("\\" === e) {
|
|
625
625
|
if (r + 1 === t.length) throw new U(A, "Path has trailing escape character: " + t);
|
|
626
|
-
const
|
|
627
|
-
if ("\\" !==
|
|
628
|
-
|
|
629
|
-
} else "`" ===
|
|
626
|
+
const e = t[r + 1];
|
|
627
|
+
if ("\\" !== e && "." !== e && "`" !== e) throw new U(A, "Path has invalid escape sequence: " + t);
|
|
628
|
+
n += e, r += 2;
|
|
629
|
+
} else "`" === e ? (i = !i, r++) : "." !== e || i ? (n += e, r++) : (s(), r++);
|
|
630
630
|
}
|
|
631
631
|
if (s(), i) throw new U(A, "Unterminated ` in path: " + t);
|
|
632
|
-
return new Z(
|
|
632
|
+
return new Z(e);
|
|
633
633
|
}
|
|
634
634
|
static emptyPath() {
|
|
635
635
|
return new Z([]);
|
|
@@ -673,8 +673,8 @@ const J = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
673
673
|
toString() {
|
|
674
674
|
return this.path.toString();
|
|
675
675
|
}
|
|
676
|
-
static comparator(t,
|
|
677
|
-
return K.comparator(t.path,
|
|
676
|
+
static comparator(t, e) {
|
|
677
|
+
return K.comparator(t.path, e.path);
|
|
678
678
|
}
|
|
679
679
|
static isDocumentKey(t) {
|
|
680
680
|
return t.length % 2 == 0;
|
|
@@ -704,8 +704,8 @@ const J = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
704
704
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
705
705
|
* See the License for the specific language governing permissions and
|
|
706
706
|
* limitations under the License.
|
|
707
|
-
*/ function tt(t,
|
|
708
|
-
if (!
|
|
707
|
+
*/ function tt(t, e, n) {
|
|
708
|
+
if (!n) throw new U(A, `Function ${t}() cannot be called with an empty ${e}.`);
|
|
709
709
|
}
|
|
710
710
|
|
|
711
711
|
/**
|
|
@@ -716,14 +716,14 @@ const J = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
716
716
|
* Validates that `path` refers to a document (indicated by the fact it contains
|
|
717
717
|
* an even numbers of segments).
|
|
718
718
|
*/
|
|
719
|
-
function
|
|
719
|
+
function et(t) {
|
|
720
720
|
if (!X.isDocumentKey(t)) throw new U(A, `Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`);
|
|
721
721
|
}
|
|
722
722
|
|
|
723
723
|
/**
|
|
724
724
|
* Validates that `path` refers to a collection (indicated by the fact it
|
|
725
725
|
* contains an odd numbers of segments).
|
|
726
|
-
*/ function
|
|
726
|
+
*/ function nt(t) {
|
|
727
727
|
if (X.isDocumentKey(t)) throw new U(A, `Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`);
|
|
728
728
|
}
|
|
729
729
|
|
|
@@ -741,7 +741,7 @@ function rt(t) {
|
|
|
741
741
|
if ("object" == typeof t) {
|
|
742
742
|
if (t instanceof Array) return "an array";
|
|
743
743
|
{
|
|
744
|
-
const
|
|
744
|
+
const e =
|
|
745
745
|
/** try to get the constructor name for an object. */
|
|
746
746
|
function(t) {
|
|
747
747
|
if (t.constructor) return t.constructor.name;
|
|
@@ -755,7 +755,7 @@ function rt(t) {
|
|
|
755
755
|
* arguments passed to the public API.
|
|
756
756
|
* @internal
|
|
757
757
|
*/ (t);
|
|
758
|
-
return
|
|
758
|
+
return e ? `a custom ${e} object` : "an object";
|
|
759
759
|
}
|
|
760
760
|
}
|
|
761
761
|
return "function" == typeof t ? "a function" : g();
|
|
@@ -763,22 +763,22 @@ function rt(t) {
|
|
|
763
763
|
|
|
764
764
|
function st(t,
|
|
765
765
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
766
|
-
|
|
766
|
+
e) {
|
|
767
767
|
if ("_delegate" in t && (
|
|
768
768
|
// Unwrap Compat types
|
|
769
769
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
770
|
-
t = t._delegate), !(t instanceof
|
|
771
|
-
if (
|
|
770
|
+
t = t._delegate), !(t instanceof e)) {
|
|
771
|
+
if (e.name === t.constructor.name) throw new U(A, "Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");
|
|
772
772
|
{
|
|
773
|
-
const
|
|
774
|
-
throw new U(A, `Expected type '${
|
|
773
|
+
const n = rt(t);
|
|
774
|
+
throw new U(A, `Expected type '${e.name}', but it was: ${n}`);
|
|
775
775
|
}
|
|
776
776
|
}
|
|
777
777
|
return t;
|
|
778
778
|
}
|
|
779
779
|
|
|
780
|
-
function it(t,
|
|
781
|
-
if (
|
|
780
|
+
function it(t, e) {
|
|
781
|
+
if (e <= 0) throw new U(A, `Function ${t}() requires a positive number, but it was: ${e}.`);
|
|
782
782
|
}
|
|
783
783
|
|
|
784
784
|
/**
|
|
@@ -985,58 +985,58 @@ class ft extends
|
|
|
985
985
|
class {
|
|
986
986
|
constructor(t) {
|
|
987
987
|
this.databaseInfo = t, this.databaseId = t.databaseId;
|
|
988
|
-
const
|
|
989
|
-
this.u =
|
|
988
|
+
const e = t.ssl ? "https" : "http";
|
|
989
|
+
this.u = e + "://" + t.host, this.h = "projects/" + this.databaseId.projectId + "/databases/" + this.databaseId.database + "/documents";
|
|
990
990
|
}
|
|
991
|
-
l(t,
|
|
992
|
-
const s = this.m(t,
|
|
993
|
-
m("RestConnection", "Sending: ", s,
|
|
991
|
+
l(t, e, n, r) {
|
|
992
|
+
const s = this.m(t, e);
|
|
993
|
+
m("RestConnection", "Sending: ", s, n);
|
|
994
994
|
const i = {};
|
|
995
|
-
return this.p(i, r), this.g(t, s, i,
|
|
996
|
-
t)), (
|
|
997
|
-
throw y("RestConnection", `${t} failed with error: `,
|
|
998
|
-
|
|
995
|
+
return this.p(i, r), this.g(t, s, i, n).then((t => (m("RestConnection", "Received: ", t),
|
|
996
|
+
t)), (e => {
|
|
997
|
+
throw y("RestConnection", `${t} failed with error: `, e, "url: ", s, "request:", n),
|
|
998
|
+
e;
|
|
999
999
|
}));
|
|
1000
1000
|
}
|
|
1001
|
-
v(t,
|
|
1001
|
+
v(t, e, n, r) {
|
|
1002
1002
|
// The REST API automatically aggregates all of the streamed results, so we
|
|
1003
1003
|
// can just use the normal invoke() method.
|
|
1004
|
-
return this.l(t,
|
|
1004
|
+
return this.l(t, e, n, r);
|
|
1005
1005
|
}
|
|
1006
1006
|
/**
|
|
1007
1007
|
* Modifies the headers for a request, adding any authorization token if
|
|
1008
1008
|
* present and any additional headers for the request.
|
|
1009
|
-
*/ p(t,
|
|
1009
|
+
*/ p(t, e) {
|
|
1010
1010
|
if (t["X-Goog-Api-Client"] = "gl-js/ fire/" + f,
|
|
1011
1011
|
// Content-Type: text/plain will avoid preflight requests which might
|
|
1012
1012
|
// mess with CORS and redirects by proxies. If we add custom headers
|
|
1013
1013
|
// we will need to change this code to potentially use the $httpOverwrite
|
|
1014
1014
|
// parameter supported by ESF to avoid triggering preflight requests.
|
|
1015
1015
|
t["Content-Type"] = "text/plain", this.databaseInfo.appId && (t["X-Firebase-GMPID"] = this.databaseInfo.appId),
|
|
1016
|
-
|
|
1016
|
+
e) for (const n in e.authHeaders) e.authHeaders.hasOwnProperty(n) && (t[n] = e.authHeaders[n]);
|
|
1017
1017
|
}
|
|
1018
|
-
m(t,
|
|
1019
|
-
const
|
|
1020
|
-
return `${this.u}/v1/${
|
|
1018
|
+
m(t, e) {
|
|
1019
|
+
const n = ct[t];
|
|
1020
|
+
return `${this.u}/v1/${e}:${n}`;
|
|
1021
1021
|
}
|
|
1022
1022
|
} {
|
|
1023
1023
|
/**
|
|
1024
1024
|
* @param databaseInfo - The connection info.
|
|
1025
1025
|
* @param fetchImpl - `fetch` or a Polyfill that implements the fetch API.
|
|
1026
1026
|
*/
|
|
1027
|
-
constructor(t,
|
|
1028
|
-
super(t), this.I =
|
|
1027
|
+
constructor(t, e) {
|
|
1028
|
+
super(t), this.I = e;
|
|
1029
1029
|
}
|
|
1030
|
-
T(t,
|
|
1030
|
+
T(t, e) {
|
|
1031
1031
|
throw new Error("Not supported by FetchConnection");
|
|
1032
1032
|
}
|
|
1033
|
-
async g(t,
|
|
1033
|
+
async g(t, e, n, r) {
|
|
1034
1034
|
const s = JSON.stringify(r);
|
|
1035
1035
|
let i;
|
|
1036
1036
|
try {
|
|
1037
|
-
i = await this.I(
|
|
1037
|
+
i = await this.I(e, {
|
|
1038
1038
|
method: "POST",
|
|
1039
|
-
headers:
|
|
1039
|
+
headers: n,
|
|
1040
1040
|
body: s
|
|
1041
1041
|
});
|
|
1042
1042
|
} catch (t) {
|
|
@@ -1087,13 +1087,13 @@ class {
|
|
|
1087
1087
|
*/
|
|
1088
1088
|
function dt(t) {
|
|
1089
1089
|
// Polyfills for IE and WebWorker by using `self` and `msCrypto` when `crypto` is not available.
|
|
1090
|
-
const
|
|
1090
|
+
const e =
|
|
1091
1091
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1092
|
-
"undefined" != typeof self && (self.crypto || self.msCrypto),
|
|
1093
|
-
if (
|
|
1092
|
+
"undefined" != typeof self && (self.crypto || self.msCrypto), n = new Uint8Array(t);
|
|
1093
|
+
if (e && "function" == typeof e.getRandomValues) e.getRandomValues(n); else
|
|
1094
1094
|
// Falls back to Math.random
|
|
1095
|
-
for (let
|
|
1096
|
-
return
|
|
1095
|
+
for (let e = 0; e < t; e++) n[e] = Math.floor(256 * Math.random());
|
|
1096
|
+
return n;
|
|
1097
1097
|
}
|
|
1098
1098
|
|
|
1099
1099
|
/**
|
|
@@ -1114,26 +1114,26 @@ function dt(t) {
|
|
|
1114
1114
|
*/ class wt {
|
|
1115
1115
|
static A() {
|
|
1116
1116
|
// Alphanumeric characters
|
|
1117
|
-
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
|
|
1117
|
+
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", e = Math.floor(256 / t.length) * t.length;
|
|
1118
1118
|
// The largest byte value that is a multiple of `char.length`.
|
|
1119
|
-
let
|
|
1120
|
-
for (;
|
|
1119
|
+
let n = "";
|
|
1120
|
+
for (;n.length < 20; ) {
|
|
1121
1121
|
const r = dt(40);
|
|
1122
1122
|
for (let s = 0; s < r.length; ++s)
|
|
1123
1123
|
// Only accept values that are [0, maxMultiple), this ensures they can
|
|
1124
1124
|
// be evenly mapped to indices of `chars` via a modulo operation.
|
|
1125
|
-
|
|
1125
|
+
n.length < 20 && r[s] < e && (n += t.charAt(r[s] % t.length));
|
|
1126
1126
|
}
|
|
1127
|
-
return
|
|
1127
|
+
return n;
|
|
1128
1128
|
}
|
|
1129
1129
|
}
|
|
1130
1130
|
|
|
1131
|
-
function mt(t,
|
|
1132
|
-
return t <
|
|
1131
|
+
function mt(t, e) {
|
|
1132
|
+
return t < e ? -1 : t > e ? 1 : 0;
|
|
1133
1133
|
}
|
|
1134
1134
|
|
|
1135
|
-
/** Helper to compare arrays using isEqual(). */ function pt(t,
|
|
1136
|
-
return t.length ===
|
|
1135
|
+
/** Helper to compare arrays using isEqual(). */ function pt(t, e, n) {
|
|
1136
|
+
return t.length === e.length && t.every(((t, r) => n(t, e[r])));
|
|
1137
1137
|
}
|
|
1138
1138
|
|
|
1139
1139
|
/**
|
|
@@ -1187,9 +1187,9 @@ class yt {
|
|
|
1187
1187
|
/**
|
|
1188
1188
|
* The fractions of a second at nanosecond resolution.*
|
|
1189
1189
|
*/
|
|
1190
|
-
|
|
1191
|
-
if (this.seconds = t, this.nanoseconds =
|
|
1192
|
-
if (
|
|
1190
|
+
e) {
|
|
1191
|
+
if (this.seconds = t, this.nanoseconds = e, e < 0) throw new U(A, "Timestamp nanoseconds out of range: " + e);
|
|
1192
|
+
if (e >= 1e9) throw new U(A, "Timestamp nanoseconds out of range: " + e);
|
|
1193
1193
|
if (t < -62135596800) throw new U(A, "Timestamp seconds out of range: " + t);
|
|
1194
1194
|
// This will break in the year 10,000.
|
|
1195
1195
|
if (t >= 253402300800) throw new U(A, "Timestamp seconds out of range: " + t);
|
|
@@ -1218,8 +1218,8 @@ class yt {
|
|
|
1218
1218
|
* @returns A new `Timestamp` representing the same point in time as the given
|
|
1219
1219
|
* number of milliseconds.
|
|
1220
1220
|
*/ static fromMillis(t) {
|
|
1221
|
-
const
|
|
1222
|
-
return new yt(
|
|
1221
|
+
const e = Math.floor(t / 1e3), n = Math.floor(1e6 * (t - 1e3 * e));
|
|
1222
|
+
return new yt(e, n);
|
|
1223
1223
|
}
|
|
1224
1224
|
/**
|
|
1225
1225
|
* Converts a `Timestamp` to a JavaScript `Date` object. This conversion
|
|
@@ -1341,13 +1341,13 @@ class yt {
|
|
|
1341
1341
|
* See the License for the specific language governing permissions and
|
|
1342
1342
|
* limitations under the License.
|
|
1343
1343
|
*/ function gt(t) {
|
|
1344
|
-
let
|
|
1345
|
-
for (const
|
|
1346
|
-
return
|
|
1344
|
+
let e = 0;
|
|
1345
|
+
for (const n in t) Object.prototype.hasOwnProperty.call(t, n) && e++;
|
|
1346
|
+
return e;
|
|
1347
1347
|
}
|
|
1348
1348
|
|
|
1349
|
-
function
|
|
1350
|
-
for (const
|
|
1349
|
+
function vt(t, e) {
|
|
1350
|
+
for (const n in t) Object.prototype.hasOwnProperty.call(t, n) && e(n, t[n]);
|
|
1351
1351
|
}
|
|
1352
1352
|
|
|
1353
1353
|
/**
|
|
@@ -1376,7 +1376,7 @@ function bt(t, n) {
|
|
|
1376
1376
|
* If foo is not an object, foo is replaced with an object
|
|
1377
1377
|
* containing foo
|
|
1378
1378
|
*/
|
|
1379
|
-
class
|
|
1379
|
+
class bt {
|
|
1380
1380
|
constructor(t) {
|
|
1381
1381
|
this.fields = t,
|
|
1382
1382
|
// TODO(dimond): validation of FieldMask
|
|
@@ -1389,11 +1389,11 @@ class vt {
|
|
|
1389
1389
|
*
|
|
1390
1390
|
* This is an O(n) operation, where `n` is the size of the field mask.
|
|
1391
1391
|
*/ covers(t) {
|
|
1392
|
-
for (const
|
|
1392
|
+
for (const e of this.fields) if (e.isPrefixOf(t)) return !0;
|
|
1393
1393
|
return !1;
|
|
1394
1394
|
}
|
|
1395
1395
|
isEqual(t) {
|
|
1396
|
-
return pt(this.fields, t.fields, ((t,
|
|
1396
|
+
return pt(this.fields, t.fields, ((t, e) => t.isEqual(e)));
|
|
1397
1397
|
}
|
|
1398
1398
|
}
|
|
1399
1399
|
|
|
@@ -1455,36 +1455,36 @@ class It {
|
|
|
1455
1455
|
this.binaryString = t;
|
|
1456
1456
|
}
|
|
1457
1457
|
static fromBase64String(t) {
|
|
1458
|
-
const
|
|
1459
|
-
return new It(
|
|
1458
|
+
const e = Et(t);
|
|
1459
|
+
return new It(e);
|
|
1460
1460
|
}
|
|
1461
1461
|
static fromUint8Array(t) {
|
|
1462
|
-
const
|
|
1462
|
+
const e =
|
|
1463
1463
|
/**
|
|
1464
1464
|
* Helper function to convert an Uint8array to a binary string.
|
|
1465
1465
|
*/
|
|
1466
1466
|
function(t) {
|
|
1467
|
-
let
|
|
1468
|
-
for (let
|
|
1469
|
-
return
|
|
1467
|
+
let e = "";
|
|
1468
|
+
for (let n = 0; n < t.length; ++n) e += String.fromCharCode(t[n]);
|
|
1469
|
+
return e;
|
|
1470
1470
|
}
|
|
1471
1471
|
/**
|
|
1472
1472
|
* Helper function to convert a binary string to an Uint8Array.
|
|
1473
1473
|
*/ (t);
|
|
1474
|
-
return new It(
|
|
1474
|
+
return new It(e);
|
|
1475
1475
|
}
|
|
1476
1476
|
toBase64() {
|
|
1477
1477
|
return function(t) {
|
|
1478
|
-
const
|
|
1479
|
-
for (let
|
|
1480
|
-
return c.encodeByteArray(
|
|
1478
|
+
const e = [];
|
|
1479
|
+
for (let n = 0; n < t.length; n++) e[n] = t.charCodeAt(n);
|
|
1480
|
+
return c.encodeByteArray(e, !1);
|
|
1481
1481
|
}(this.binaryString);
|
|
1482
1482
|
}
|
|
1483
1483
|
toUint8Array() {
|
|
1484
1484
|
return function(t) {
|
|
1485
|
-
const
|
|
1486
|
-
for (let
|
|
1487
|
-
return
|
|
1485
|
+
const e = new Uint8Array(t.length);
|
|
1486
|
+
for (let n = 0; n < t.length; n++) e[n] = t.charCodeAt(n);
|
|
1487
|
+
return e;
|
|
1488
1488
|
}
|
|
1489
1489
|
/**
|
|
1490
1490
|
* @license
|
|
@@ -1527,22 +1527,22 @@ const Tt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1527
1527
|
// The json interface (for the browser) will return an iso timestamp string,
|
|
1528
1528
|
// while the proto js library (for node) will return a
|
|
1529
1529
|
// google.protobuf.Timestamp instance.
|
|
1530
|
-
if (
|
|
1530
|
+
if (v(!!t), "string" == typeof t) {
|
|
1531
1531
|
// The date string can have higher precision (nanos) than the Date class
|
|
1532
1532
|
// (millis), so we do some custom parsing here.
|
|
1533
1533
|
// Parse the nanos right out of the string.
|
|
1534
|
-
let
|
|
1535
|
-
const
|
|
1536
|
-
if (
|
|
1534
|
+
let e = 0;
|
|
1535
|
+
const n = Tt.exec(t);
|
|
1536
|
+
if (v(!!n), n[1]) {
|
|
1537
1537
|
// Pad the fraction out to 9 digits (nanos).
|
|
1538
|
-
let t =
|
|
1539
|
-
t = (t + "000000000").substr(0, 9),
|
|
1538
|
+
let t = n[1];
|
|
1539
|
+
t = (t + "000000000").substr(0, 9), e = Number(t);
|
|
1540
1540
|
}
|
|
1541
1541
|
// Parse the date to get the seconds.
|
|
1542
1542
|
const r = new Date(t);
|
|
1543
1543
|
return {
|
|
1544
1544
|
seconds: Math.floor(r.getTime() / 1e3),
|
|
1545
|
-
nanos:
|
|
1545
|
+
nanos: e
|
|
1546
1546
|
};
|
|
1547
1547
|
}
|
|
1548
1548
|
return {
|
|
@@ -1597,8 +1597,8 @@ const Tt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1597
1597
|
* - With respect to other ServerTimestampValues, they sort by their
|
|
1598
1598
|
* localWriteTime.
|
|
1599
1599
|
*/ function Vt(t) {
|
|
1600
|
-
var
|
|
1601
|
-
return "server_timestamp" === (null === (
|
|
1600
|
+
var e, n;
|
|
1601
|
+
return "server_timestamp" === (null === (n = ((null === (e = null == t ? void 0 : t.mapValue) || void 0 === e ? void 0 : e.fields) || {}).__type__) || void 0 === n ? void 0 : n.stringValue);
|
|
1602
1602
|
}
|
|
1603
1603
|
|
|
1604
1604
|
/**
|
|
@@ -1607,15 +1607,15 @@ const Tt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1607
1607
|
* Preserving the previous values allows the user to display the last resoled
|
|
1608
1608
|
* value until the backend responds with the timestamp.
|
|
1609
1609
|
*/ function Nt(t) {
|
|
1610
|
-
const
|
|
1611
|
-
return Vt(
|
|
1610
|
+
const e = t.mapValue.fields.__previous_value__;
|
|
1611
|
+
return Vt(e) ? Nt(e) : e;
|
|
1612
1612
|
}
|
|
1613
1613
|
|
|
1614
1614
|
/**
|
|
1615
1615
|
* Returns the local time at which this timestamp was first set.
|
|
1616
1616
|
*/ function Dt(t) {
|
|
1617
|
-
const
|
|
1618
|
-
return new yt(
|
|
1617
|
+
const e = At(t.mapValue.fields.__local_write_time__.timestampValue);
|
|
1618
|
+
return new yt(e.seconds, e.nanos);
|
|
1619
1619
|
}
|
|
1620
1620
|
|
|
1621
1621
|
/**
|
|
@@ -1638,167 +1638,167 @@ const Tt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1638
1638
|
return "nullValue" in t ? 0 /* NullValue */ : "booleanValue" in t ? 1 /* BooleanValue */ : "integerValue" in t || "doubleValue" in t ? 2 /* NumberValue */ : "timestampValue" in t ? 3 /* TimestampValue */ : "stringValue" in t ? 5 /* StringValue */ : "bytesValue" in t ? 6 /* BlobValue */ : "referenceValue" in t ? 7 /* RefValue */ : "geoPointValue" in t ? 8 /* GeoPointValue */ : "arrayValue" in t ? 9 /* ArrayValue */ : "mapValue" in t ? Vt(t) ? 4 /* ServerTimestampValue */ : 10 /* ObjectValue */ : g();
|
|
1639
1639
|
}
|
|
1640
1640
|
|
|
1641
|
-
/** Tests `left` and `right` for equality based on the backend semantics. */ function Ft(t,
|
|
1642
|
-
const
|
|
1643
|
-
if (
|
|
1644
|
-
switch (
|
|
1641
|
+
/** Tests `left` and `right` for equality based on the backend semantics. */ function Ft(t, e) {
|
|
1642
|
+
const n = $t(t);
|
|
1643
|
+
if (n !== $t(e)) return !1;
|
|
1644
|
+
switch (n) {
|
|
1645
1645
|
case 0 /* NullValue */ :
|
|
1646
1646
|
return !0;
|
|
1647
1647
|
|
|
1648
1648
|
case 1 /* BooleanValue */ :
|
|
1649
|
-
return t.booleanValue ===
|
|
1649
|
+
return t.booleanValue === e.booleanValue;
|
|
1650
1650
|
|
|
1651
1651
|
case 4 /* ServerTimestampValue */ :
|
|
1652
|
-
return Dt(t).isEqual(Dt(
|
|
1652
|
+
return Dt(t).isEqual(Dt(e));
|
|
1653
1653
|
|
|
1654
1654
|
case 3 /* TimestampValue */ :
|
|
1655
|
-
return function(t,
|
|
1656
|
-
if ("string" == typeof t.timestampValue && "string" == typeof
|
|
1655
|
+
return function(t, e) {
|
|
1656
|
+
if ("string" == typeof t.timestampValue && "string" == typeof e.timestampValue && t.timestampValue.length === e.timestampValue.length)
|
|
1657
1657
|
// Use string equality for ISO 8601 timestamps
|
|
1658
|
-
return t.timestampValue ===
|
|
1659
|
-
const
|
|
1660
|
-
return
|
|
1661
|
-
}(t,
|
|
1658
|
+
return t.timestampValue === e.timestampValue;
|
|
1659
|
+
const n = At(t.timestampValue), r = At(e.timestampValue);
|
|
1660
|
+
return n.seconds === r.seconds && n.nanos === r.nanos;
|
|
1661
|
+
}(t, e);
|
|
1662
1662
|
|
|
1663
1663
|
case 5 /* StringValue */ :
|
|
1664
|
-
return t.stringValue ===
|
|
1664
|
+
return t.stringValue === e.stringValue;
|
|
1665
1665
|
|
|
1666
1666
|
case 6 /* BlobValue */ :
|
|
1667
|
-
return function(t,
|
|
1668
|
-
return Rt(t.bytesValue).isEqual(Rt(
|
|
1669
|
-
}(t,
|
|
1667
|
+
return function(t, e) {
|
|
1668
|
+
return Rt(t.bytesValue).isEqual(Rt(e.bytesValue));
|
|
1669
|
+
}(t, e);
|
|
1670
1670
|
|
|
1671
1671
|
case 7 /* RefValue */ :
|
|
1672
|
-
return t.referenceValue ===
|
|
1672
|
+
return t.referenceValue === e.referenceValue;
|
|
1673
1673
|
|
|
1674
1674
|
case 8 /* GeoPointValue */ :
|
|
1675
|
-
return function(t,
|
|
1676
|
-
return Pt(t.geoPointValue.latitude) === Pt(
|
|
1677
|
-
}(t,
|
|
1675
|
+
return function(t, e) {
|
|
1676
|
+
return Pt(t.geoPointValue.latitude) === Pt(e.geoPointValue.latitude) && Pt(t.geoPointValue.longitude) === Pt(e.geoPointValue.longitude);
|
|
1677
|
+
}(t, e);
|
|
1678
1678
|
|
|
1679
1679
|
case 2 /* NumberValue */ :
|
|
1680
|
-
return function(t,
|
|
1681
|
-
if ("integerValue" in t && "integerValue" in
|
|
1682
|
-
if ("doubleValue" in t && "doubleValue" in
|
|
1683
|
-
const
|
|
1684
|
-
return
|
|
1680
|
+
return function(t, e) {
|
|
1681
|
+
if ("integerValue" in t && "integerValue" in e) return Pt(t.integerValue) === Pt(e.integerValue);
|
|
1682
|
+
if ("doubleValue" in t && "doubleValue" in e) {
|
|
1683
|
+
const n = Pt(t.doubleValue), r = Pt(e.doubleValue);
|
|
1684
|
+
return n === r ? ut(n) === ut(r) : isNaN(n) && isNaN(r);
|
|
1685
1685
|
}
|
|
1686
1686
|
return !1;
|
|
1687
|
-
}(t,
|
|
1687
|
+
}(t, e);
|
|
1688
1688
|
|
|
1689
1689
|
case 9 /* ArrayValue */ :
|
|
1690
|
-
return pt(t.arrayValue.values || [],
|
|
1690
|
+
return pt(t.arrayValue.values || [], e.arrayValue.values || [], Ft);
|
|
1691
1691
|
|
|
1692
1692
|
case 10 /* ObjectValue */ :
|
|
1693
|
-
return function(t,
|
|
1694
|
-
const
|
|
1695
|
-
if (gt(
|
|
1696
|
-
for (const t in
|
|
1693
|
+
return function(t, e) {
|
|
1694
|
+
const n = t.mapValue.fields || {}, r = e.mapValue.fields || {};
|
|
1695
|
+
if (gt(n) !== gt(r)) return !1;
|
|
1696
|
+
for (const t in n) if (n.hasOwnProperty(t) && (void 0 === r[t] || !Ft(n[t], r[t]))) return !1;
|
|
1697
1697
|
return !0;
|
|
1698
1698
|
}
|
|
1699
|
-
/** Returns true if the ArrayValue contains the specified element. */ (t,
|
|
1699
|
+
/** Returns true if the ArrayValue contains the specified element. */ (t, e);
|
|
1700
1700
|
|
|
1701
1701
|
default:
|
|
1702
1702
|
return g();
|
|
1703
1703
|
}
|
|
1704
1704
|
}
|
|
1705
1705
|
|
|
1706
|
-
function St(t,
|
|
1707
|
-
return void 0 !== (t.values || []).find((t => Ft(t,
|
|
1706
|
+
function St(t, e) {
|
|
1707
|
+
return void 0 !== (t.values || []).find((t => Ft(t, e)));
|
|
1708
1708
|
}
|
|
1709
1709
|
|
|
1710
|
-
function qt(t,
|
|
1711
|
-
const
|
|
1712
|
-
if (
|
|
1713
|
-
switch (
|
|
1710
|
+
function qt(t, e) {
|
|
1711
|
+
const n = $t(t), r = $t(e);
|
|
1712
|
+
if (n !== r) return mt(n, r);
|
|
1713
|
+
switch (n) {
|
|
1714
1714
|
case 0 /* NullValue */ :
|
|
1715
1715
|
return 0;
|
|
1716
1716
|
|
|
1717
1717
|
case 1 /* BooleanValue */ :
|
|
1718
|
-
return mt(t.booleanValue,
|
|
1718
|
+
return mt(t.booleanValue, e.booleanValue);
|
|
1719
1719
|
|
|
1720
1720
|
case 2 /* NumberValue */ :
|
|
1721
|
-
return function(t,
|
|
1722
|
-
const
|
|
1723
|
-
return
|
|
1721
|
+
return function(t, e) {
|
|
1722
|
+
const n = Pt(t.integerValue || t.doubleValue), r = Pt(e.integerValue || e.doubleValue);
|
|
1723
|
+
return n < r ? -1 : n > r ? 1 : n === r ? 0 :
|
|
1724
1724
|
// one or both are NaN.
|
|
1725
|
-
isNaN(
|
|
1726
|
-
}(t,
|
|
1725
|
+
isNaN(n) ? isNaN(r) ? 0 : -1 : 1;
|
|
1726
|
+
}(t, e);
|
|
1727
1727
|
|
|
1728
1728
|
case 3 /* TimestampValue */ :
|
|
1729
|
-
return xt(t.timestampValue,
|
|
1729
|
+
return xt(t.timestampValue, e.timestampValue);
|
|
1730
1730
|
|
|
1731
1731
|
case 4 /* ServerTimestampValue */ :
|
|
1732
|
-
return xt(Dt(t), Dt(
|
|
1732
|
+
return xt(Dt(t), Dt(e));
|
|
1733
1733
|
|
|
1734
1734
|
case 5 /* StringValue */ :
|
|
1735
|
-
return mt(t.stringValue,
|
|
1735
|
+
return mt(t.stringValue, e.stringValue);
|
|
1736
1736
|
|
|
1737
1737
|
case 6 /* BlobValue */ :
|
|
1738
|
-
return function(t,
|
|
1739
|
-
const
|
|
1740
|
-
return
|
|
1741
|
-
}(t.bytesValue,
|
|
1738
|
+
return function(t, e) {
|
|
1739
|
+
const n = Rt(t), r = Rt(e);
|
|
1740
|
+
return n.compareTo(r);
|
|
1741
|
+
}(t.bytesValue, e.bytesValue);
|
|
1742
1742
|
|
|
1743
1743
|
case 7 /* RefValue */ :
|
|
1744
|
-
return function(t,
|
|
1745
|
-
const
|
|
1746
|
-
for (let t = 0; t <
|
|
1747
|
-
const
|
|
1748
|
-
if (0 !==
|
|
1744
|
+
return function(t, e) {
|
|
1745
|
+
const n = t.split("/"), r = e.split("/");
|
|
1746
|
+
for (let t = 0; t < n.length && t < r.length; t++) {
|
|
1747
|
+
const e = mt(n[t], r[t]);
|
|
1748
|
+
if (0 !== e) return e;
|
|
1749
1749
|
}
|
|
1750
|
-
return mt(
|
|
1751
|
-
}(t.referenceValue,
|
|
1750
|
+
return mt(n.length, r.length);
|
|
1751
|
+
}(t.referenceValue, e.referenceValue);
|
|
1752
1752
|
|
|
1753
1753
|
case 8 /* GeoPointValue */ :
|
|
1754
|
-
return function(t,
|
|
1755
|
-
const
|
|
1756
|
-
if (0 !==
|
|
1757
|
-
return mt(Pt(t.longitude), Pt(
|
|
1758
|
-
}(t.geoPointValue,
|
|
1754
|
+
return function(t, e) {
|
|
1755
|
+
const n = mt(Pt(t.latitude), Pt(e.latitude));
|
|
1756
|
+
if (0 !== n) return n;
|
|
1757
|
+
return mt(Pt(t.longitude), Pt(e.longitude));
|
|
1758
|
+
}(t.geoPointValue, e.geoPointValue);
|
|
1759
1759
|
|
|
1760
1760
|
case 9 /* ArrayValue */ :
|
|
1761
|
-
return function(t,
|
|
1762
|
-
const
|
|
1763
|
-
for (let t = 0; t <
|
|
1764
|
-
const
|
|
1765
|
-
if (
|
|
1761
|
+
return function(t, e) {
|
|
1762
|
+
const n = t.values || [], r = e.values || [];
|
|
1763
|
+
for (let t = 0; t < n.length && t < r.length; ++t) {
|
|
1764
|
+
const e = qt(n[t], r[t]);
|
|
1765
|
+
if (e) return e;
|
|
1766
1766
|
}
|
|
1767
|
-
return mt(
|
|
1768
|
-
}(t.arrayValue,
|
|
1767
|
+
return mt(n.length, r.length);
|
|
1768
|
+
}(t.arrayValue, e.arrayValue);
|
|
1769
1769
|
|
|
1770
1770
|
case 10 /* ObjectValue */ :
|
|
1771
|
-
return function(t,
|
|
1772
|
-
const
|
|
1771
|
+
return function(t, e) {
|
|
1772
|
+
const n = t.fields || {}, r = Object.keys(n), s = e.fields || {}, i = Object.keys(s);
|
|
1773
1773
|
// Even though MapValues are likely sorted correctly based on their insertion
|
|
1774
1774
|
// order (e.g. when received from the backend), local modifications can bring
|
|
1775
1775
|
// elements out of order. We need to re-sort the elements to ensure that
|
|
1776
1776
|
// canonical IDs are independent of insertion order.
|
|
1777
1777
|
r.sort(), i.sort();
|
|
1778
1778
|
for (let t = 0; t < r.length && t < i.length; ++t) {
|
|
1779
|
-
const
|
|
1780
|
-
if (0 !==
|
|
1781
|
-
const o = qt(
|
|
1779
|
+
const e = mt(r[t], i[t]);
|
|
1780
|
+
if (0 !== e) return e;
|
|
1781
|
+
const o = qt(n[r[t]], s[i[t]]);
|
|
1782
1782
|
if (0 !== o) return o;
|
|
1783
1783
|
}
|
|
1784
1784
|
return mt(r.length, i.length);
|
|
1785
1785
|
}
|
|
1786
|
-
/** Returns a reference value for the provided database and key. */ (t.mapValue,
|
|
1786
|
+
/** Returns a reference value for the provided database and key. */ (t.mapValue, e.mapValue);
|
|
1787
1787
|
|
|
1788
1788
|
default:
|
|
1789
1789
|
throw g();
|
|
1790
1790
|
}
|
|
1791
1791
|
}
|
|
1792
1792
|
|
|
1793
|
-
function xt(t,
|
|
1794
|
-
if ("string" == typeof t && "string" == typeof
|
|
1795
|
-
const
|
|
1796
|
-
return 0 !== s ? s : mt(
|
|
1793
|
+
function xt(t, e) {
|
|
1794
|
+
if ("string" == typeof t && "string" == typeof e && t.length === e.length) return mt(t, e);
|
|
1795
|
+
const n = At(t), r = At(e), s = mt(n.seconds, r.seconds);
|
|
1796
|
+
return 0 !== s ? s : mt(n.nanos, r.nanos);
|
|
1797
1797
|
}
|
|
1798
1798
|
|
|
1799
|
-
function Ot(t,
|
|
1799
|
+
function Ot(t, e) {
|
|
1800
1800
|
return {
|
|
1801
|
-
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${
|
|
1801
|
+
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${e.path.canonicalString()}`
|
|
1802
1802
|
};
|
|
1803
1803
|
}
|
|
1804
1804
|
|
|
@@ -1826,21 +1826,21 @@ function Ot(t, n) {
|
|
|
1826
1826
|
timestampValue: Object.assign({}, t.timestampValue)
|
|
1827
1827
|
};
|
|
1828
1828
|
if (t.mapValue) {
|
|
1829
|
-
const
|
|
1829
|
+
const e = {
|
|
1830
1830
|
mapValue: {
|
|
1831
1831
|
fields: {}
|
|
1832
1832
|
}
|
|
1833
1833
|
};
|
|
1834
|
-
return
|
|
1834
|
+
return vt(t.mapValue.fields, ((t, n) => e.mapValue.fields[t] = kt(n))), e;
|
|
1835
1835
|
}
|
|
1836
1836
|
if (t.arrayValue) {
|
|
1837
|
-
const
|
|
1837
|
+
const e = {
|
|
1838
1838
|
arrayValue: {
|
|
1839
1839
|
values: []
|
|
1840
1840
|
}
|
|
1841
1841
|
};
|
|
1842
|
-
for (let
|
|
1843
|
-
return
|
|
1842
|
+
for (let n = 0; n < (t.arrayValue.values || []).length; ++n) e.arrayValue.values[n] = kt(t.arrayValue.values[n]);
|
|
1843
|
+
return e;
|
|
1844
1844
|
}
|
|
1845
1845
|
return Object.assign({}, t);
|
|
1846
1846
|
}
|
|
@@ -1881,10 +1881,10 @@ function Ot(t, n) {
|
|
|
1881
1881
|
*/ field(t) {
|
|
1882
1882
|
if (t.isEmpty()) return this.value;
|
|
1883
1883
|
{
|
|
1884
|
-
let
|
|
1885
|
-
for (let
|
|
1886
|
-
!jt(
|
|
1887
|
-
return
|
|
1884
|
+
let e = this.value;
|
|
1885
|
+
for (let n = 0; n < t.length - 1; ++n) if (e = (e.mapValue.fields || {})[t.get(n)],
|
|
1886
|
+
!jt(e)) return null;
|
|
1887
|
+
return e = (e.mapValue.fields || {})[t.lastSegment()], e || null;
|
|
1888
1888
|
}
|
|
1889
1889
|
}
|
|
1890
1890
|
/**
|
|
@@ -1892,25 +1892,25 @@ function Ot(t, n) {
|
|
|
1892
1892
|
*
|
|
1893
1893
|
* @param path - The field path to set.
|
|
1894
1894
|
* @param value - The value to set.
|
|
1895
|
-
*/ set(t,
|
|
1896
|
-
this.getFieldsMap(t.popLast())[t.lastSegment()] = kt(
|
|
1895
|
+
*/ set(t, e) {
|
|
1896
|
+
this.getFieldsMap(t.popLast())[t.lastSegment()] = kt(e);
|
|
1897
1897
|
}
|
|
1898
1898
|
/**
|
|
1899
1899
|
* Sets the provided fields to the provided values.
|
|
1900
1900
|
*
|
|
1901
1901
|
* @param data - A map of fields to values (or null for deletes).
|
|
1902
1902
|
*/ setAll(t) {
|
|
1903
|
-
let
|
|
1903
|
+
let e = Z.emptyPath(), n = {}, r = [];
|
|
1904
1904
|
t.forEach(((t, s) => {
|
|
1905
|
-
if (!
|
|
1905
|
+
if (!e.isImmediateParentOf(s)) {
|
|
1906
1906
|
// Insert the accumulated changes at this parent location
|
|
1907
|
-
const t = this.getFieldsMap(
|
|
1908
|
-
this.applyChanges(t,
|
|
1907
|
+
const t = this.getFieldsMap(e);
|
|
1908
|
+
this.applyChanges(t, n, r), n = {}, r = [], e = s.popLast();
|
|
1909
1909
|
}
|
|
1910
|
-
t ?
|
|
1910
|
+
t ? n[s.lastSegment()] = kt(t) : r.push(s.lastSegment());
|
|
1911
1911
|
}));
|
|
1912
|
-
const s = this.getFieldsMap(
|
|
1913
|
-
this.applyChanges(s,
|
|
1912
|
+
const s = this.getFieldsMap(e);
|
|
1913
|
+
this.applyChanges(s, n, r);
|
|
1914
1914
|
}
|
|
1915
1915
|
/**
|
|
1916
1916
|
* Removes the field at the specified path. If there is no field at the
|
|
@@ -1918,8 +1918,8 @@ function Ot(t, n) {
|
|
|
1918
1918
|
*
|
|
1919
1919
|
* @param path - The field path to remove.
|
|
1920
1920
|
*/ delete(t) {
|
|
1921
|
-
const
|
|
1922
|
-
jt(
|
|
1921
|
+
const e = this.field(t.popLast());
|
|
1922
|
+
jt(e) && e.mapValue.fields && delete e.mapValue.fields[t.lastSegment()];
|
|
1923
1923
|
}
|
|
1924
1924
|
isEqual(t) {
|
|
1925
1925
|
return Ft(this.value, t.value);
|
|
@@ -1928,26 +1928,26 @@ function Ot(t, n) {
|
|
|
1928
1928
|
* Returns the map that contains the leaf element of `path`. If the parent
|
|
1929
1929
|
* entry does not yet exist, or if it is not a map, a new map will be created.
|
|
1930
1930
|
*/ getFieldsMap(t) {
|
|
1931
|
-
let
|
|
1932
|
-
|
|
1931
|
+
let e = this.value;
|
|
1932
|
+
e.mapValue.fields || (e.mapValue = {
|
|
1933
1933
|
fields: {}
|
|
1934
1934
|
});
|
|
1935
|
-
for (let
|
|
1936
|
-
let r =
|
|
1935
|
+
for (let n = 0; n < t.length; ++n) {
|
|
1936
|
+
let r = e.mapValue.fields[t.get(n)];
|
|
1937
1937
|
jt(r) && r.mapValue.fields || (r = {
|
|
1938
1938
|
mapValue: {
|
|
1939
1939
|
fields: {}
|
|
1940
1940
|
}
|
|
1941
|
-
},
|
|
1941
|
+
}, e.mapValue.fields[t.get(n)] = r), e = r;
|
|
1942
1942
|
}
|
|
1943
|
-
return
|
|
1943
|
+
return e.mapValue.fields;
|
|
1944
1944
|
}
|
|
1945
1945
|
/**
|
|
1946
1946
|
* Modifies `fieldsMap` by adding, replacing or deleting the specified
|
|
1947
1947
|
* entries.
|
|
1948
|
-
*/ applyChanges(t,
|
|
1949
|
-
|
|
1950
|
-
for (const
|
|
1948
|
+
*/ applyChanges(t, e, n) {
|
|
1949
|
+
vt(e, ((e, n) => t[e] = n));
|
|
1950
|
+
for (const e of n) delete t[e];
|
|
1951
1951
|
}
|
|
1952
1952
|
clone() {
|
|
1953
1953
|
return new Mt(kt(this.value));
|
|
@@ -1980,8 +1980,8 @@ function Ot(t, n) {
|
|
|
1980
1980
|
* applied, `isValidDocument()` returns false and the document should be removed
|
|
1981
1981
|
* from all views.
|
|
1982
1982
|
*/ class Bt {
|
|
1983
|
-
constructor(t,
|
|
1984
|
-
this.key = t, this.documentType =
|
|
1983
|
+
constructor(t, e, n, r, s) {
|
|
1984
|
+
this.key = t, this.documentType = e, this.version = n, this.data = r, this.documentState = s;
|
|
1985
1985
|
}
|
|
1986
1986
|
/**
|
|
1987
1987
|
* Creates a document with no known version or data, but which can serve as
|
|
@@ -1992,24 +1992,24 @@ function Ot(t, n) {
|
|
|
1992
1992
|
/**
|
|
1993
1993
|
* Creates a new document that is known to exist with the given data at the
|
|
1994
1994
|
* given version.
|
|
1995
|
-
*/ static newFoundDocument(t,
|
|
1996
|
-
return new Bt(t, 1 /* FOUND_DOCUMENT */ ,
|
|
1995
|
+
*/ static newFoundDocument(t, e, n) {
|
|
1996
|
+
return new Bt(t, 1 /* FOUND_DOCUMENT */ , e, n, 0 /* SYNCED */);
|
|
1997
1997
|
}
|
|
1998
|
-
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t,
|
|
1999
|
-
return new Bt(t, 2 /* NO_DOCUMENT */ ,
|
|
1998
|
+
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t, e) {
|
|
1999
|
+
return new Bt(t, 2 /* NO_DOCUMENT */ , e, Mt.empty(), 0 /* SYNCED */);
|
|
2000
2000
|
}
|
|
2001
2001
|
/**
|
|
2002
2002
|
* Creates a new document that is known to exist at the given version but
|
|
2003
2003
|
* whose data is not known (e.g. a document that was updated without a known
|
|
2004
2004
|
* base document).
|
|
2005
|
-
*/ static newUnknownDocument(t,
|
|
2006
|
-
return new Bt(t, 3 /* UNKNOWN_DOCUMENT */ ,
|
|
2005
|
+
*/ static newUnknownDocument(t, e) {
|
|
2006
|
+
return new Bt(t, 3 /* UNKNOWN_DOCUMENT */ , e, Mt.empty(), 2 /* HAS_COMMITTED_MUTATIONS */);
|
|
2007
2007
|
}
|
|
2008
2008
|
/**
|
|
2009
2009
|
* Changes the document type to indicate that it exists and that its version
|
|
2010
2010
|
* and data are known.
|
|
2011
|
-
*/ convertToFoundDocument(t,
|
|
2012
|
-
return this.version = t, this.documentType = 1 /* FOUND_DOCUMENT */ , this.data =
|
|
2011
|
+
*/ convertToFoundDocument(t, e) {
|
|
2012
|
+
return this.version = t, this.documentType = 1 /* FOUND_DOCUMENT */ , this.data = e,
|
|
2013
2013
|
this.documentState = 0 /* SYNCED */ , this;
|
|
2014
2014
|
}
|
|
2015
2015
|
/**
|
|
@@ -2083,8 +2083,8 @@ function Ot(t, n) {
|
|
|
2083
2083
|
*/
|
|
2084
2084
|
// Visible for testing
|
|
2085
2085
|
class Qt {
|
|
2086
|
-
constructor(t,
|
|
2087
|
-
this.path = t, this.collectionGroup =
|
|
2086
|
+
constructor(t, e = null, n = [], r = [], s = null, i = null, o = null) {
|
|
2087
|
+
this.path = t, this.collectionGroup = e, this.orderBy = n, this.filters = r, this.limit = s,
|
|
2088
2088
|
this.startAt = i, this.endAt = o, this.P = null;
|
|
2089
2089
|
}
|
|
2090
2090
|
}
|
|
@@ -2096,26 +2096,26 @@ class Qt {
|
|
|
2096
2096
|
* NOTE: you should always construct `Target` from `Query.toTarget` instead of
|
|
2097
2097
|
* using this factory method, because `Query` provides an implicit `orderBy`
|
|
2098
2098
|
* property.
|
|
2099
|
-
*/ function zt(t,
|
|
2100
|
-
return new Qt(t,
|
|
2099
|
+
*/ function zt(t, e = null, n = [], r = [], s = null, i = null, o = null) {
|
|
2100
|
+
return new Qt(t, e, n, r, s, i, o);
|
|
2101
2101
|
}
|
|
2102
2102
|
|
|
2103
2103
|
class Wt extends class {} {
|
|
2104
|
-
constructor(t,
|
|
2105
|
-
super(), this.field = t, this.op =
|
|
2104
|
+
constructor(t, e, n) {
|
|
2105
|
+
super(), this.field = t, this.op = e, this.value = n;
|
|
2106
2106
|
}
|
|
2107
2107
|
/**
|
|
2108
2108
|
* Creates a filter based on the provided arguments.
|
|
2109
|
-
*/ static create(t,
|
|
2110
|
-
return t.isKeyField() ? "in" /* IN */ ===
|
|
2109
|
+
*/ static create(t, e, n) {
|
|
2110
|
+
return t.isKeyField() ? "in" /* IN */ === e || "not-in" /* NOT_IN */ === e ? this.R(t, e, n) : new Gt(t, e, n) : "array-contains" /* ARRAY_CONTAINS */ === e ? new Jt(t, n) : "in" /* IN */ === e ? new Zt(t, n) : "not-in" /* NOT_IN */ === e ? new Xt(t, n) : "array-contains-any" /* ARRAY_CONTAINS_ANY */ === e ? new te(t, n) : new Wt(t, e, n);
|
|
2111
2111
|
}
|
|
2112
|
-
static R(t,
|
|
2113
|
-
return "in" /* IN */ ===
|
|
2112
|
+
static R(t, e, n) {
|
|
2113
|
+
return "in" /* IN */ === e ? new Ht(t, n) : new Yt(t, n);
|
|
2114
2114
|
}
|
|
2115
2115
|
matches(t) {
|
|
2116
|
-
const
|
|
2116
|
+
const e = t.data.field(this.field);
|
|
2117
2117
|
// Types do not have to match in NOT_EQUAL filters.
|
|
2118
|
-
return "!=" /* NOT_EQUAL */ === this.op ? null !==
|
|
2118
|
+
return "!=" /* NOT_EQUAL */ === this.op ? null !== e && this.V(qt(e, this.value)) : null !== e && $t(this.value) === $t(e) && this.V(qt(e, this.value));
|
|
2119
2119
|
// Only compare types with matching backend order (such as double and int).
|
|
2120
2120
|
}
|
|
2121
2121
|
V(t) {
|
|
@@ -2149,78 +2149,78 @@ class Wt extends class {} {
|
|
|
2149
2149
|
|
|
2150
2150
|
/** Filter that matches on key fields (i.e. '__name__'). */
|
|
2151
2151
|
class Gt extends Wt {
|
|
2152
|
-
constructor(t,
|
|
2153
|
-
super(t,
|
|
2152
|
+
constructor(t, e, n) {
|
|
2153
|
+
super(t, e, n), this.key = X.fromName(n.referenceValue);
|
|
2154
2154
|
}
|
|
2155
2155
|
matches(t) {
|
|
2156
|
-
const
|
|
2157
|
-
return this.V(
|
|
2156
|
+
const e = X.comparator(t.key, this.key);
|
|
2157
|
+
return this.V(e);
|
|
2158
2158
|
}
|
|
2159
2159
|
}
|
|
2160
2160
|
|
|
2161
2161
|
/** Filter that matches on key fields within an array. */ class Ht extends Wt {
|
|
2162
|
-
constructor(t,
|
|
2163
|
-
super(t, "in" /* IN */ ,
|
|
2162
|
+
constructor(t, e) {
|
|
2163
|
+
super(t, "in" /* IN */ , e), this.keys = Kt("in" /* IN */ , e);
|
|
2164
2164
|
}
|
|
2165
2165
|
matches(t) {
|
|
2166
|
-
return this.keys.some((
|
|
2166
|
+
return this.keys.some((e => e.isEqual(t.key)));
|
|
2167
2167
|
}
|
|
2168
2168
|
}
|
|
2169
2169
|
|
|
2170
2170
|
/** Filter that matches on key fields not present within an array. */ class Yt extends Wt {
|
|
2171
|
-
constructor(t,
|
|
2172
|
-
super(t, "not-in" /* NOT_IN */ ,
|
|
2171
|
+
constructor(t, e) {
|
|
2172
|
+
super(t, "not-in" /* NOT_IN */ , e), this.keys = Kt("not-in" /* NOT_IN */ , e);
|
|
2173
2173
|
}
|
|
2174
2174
|
matches(t) {
|
|
2175
|
-
return !this.keys.some((
|
|
2175
|
+
return !this.keys.some((e => e.isEqual(t.key)));
|
|
2176
2176
|
}
|
|
2177
2177
|
}
|
|
2178
2178
|
|
|
2179
|
-
function Kt(t,
|
|
2180
|
-
var
|
|
2181
|
-
return ((null === (
|
|
2179
|
+
function Kt(t, e) {
|
|
2180
|
+
var n;
|
|
2181
|
+
return ((null === (n = e.arrayValue) || void 0 === n ? void 0 : n.values) || []).map((t => X.fromName(t.referenceValue)));
|
|
2182
2182
|
}
|
|
2183
2183
|
|
|
2184
2184
|
/** A Filter that implements the array-contains operator. */ class Jt extends Wt {
|
|
2185
|
-
constructor(t,
|
|
2186
|
-
super(t, "array-contains" /* ARRAY_CONTAINS */ ,
|
|
2185
|
+
constructor(t, e) {
|
|
2186
|
+
super(t, "array-contains" /* ARRAY_CONTAINS */ , e);
|
|
2187
2187
|
}
|
|
2188
2188
|
matches(t) {
|
|
2189
|
-
const
|
|
2190
|
-
return Ct(
|
|
2189
|
+
const e = t.data.field(this.field);
|
|
2190
|
+
return Ct(e) && St(e.arrayValue, this.value);
|
|
2191
2191
|
}
|
|
2192
2192
|
}
|
|
2193
2193
|
|
|
2194
2194
|
/** A Filter that implements the IN operator. */ class Zt extends Wt {
|
|
2195
|
-
constructor(t,
|
|
2196
|
-
super(t, "in" /* IN */ ,
|
|
2195
|
+
constructor(t, e) {
|
|
2196
|
+
super(t, "in" /* IN */ , e);
|
|
2197
2197
|
}
|
|
2198
2198
|
matches(t) {
|
|
2199
|
-
const
|
|
2200
|
-
return null !==
|
|
2199
|
+
const e = t.data.field(this.field);
|
|
2200
|
+
return null !== e && St(this.value.arrayValue, e);
|
|
2201
2201
|
}
|
|
2202
2202
|
}
|
|
2203
2203
|
|
|
2204
2204
|
/** A Filter that implements the not-in operator. */ class Xt extends Wt {
|
|
2205
|
-
constructor(t,
|
|
2206
|
-
super(t, "not-in" /* NOT_IN */ ,
|
|
2205
|
+
constructor(t, e) {
|
|
2206
|
+
super(t, "not-in" /* NOT_IN */ , e);
|
|
2207
2207
|
}
|
|
2208
2208
|
matches(t) {
|
|
2209
2209
|
if (St(this.value.arrayValue, {
|
|
2210
2210
|
nullValue: "NULL_VALUE"
|
|
2211
2211
|
})) return !1;
|
|
2212
|
-
const
|
|
2213
|
-
return null !==
|
|
2212
|
+
const e = t.data.field(this.field);
|
|
2213
|
+
return null !== e && !St(this.value.arrayValue, e);
|
|
2214
2214
|
}
|
|
2215
2215
|
}
|
|
2216
2216
|
|
|
2217
|
-
/** A Filter that implements the array-contains-any operator. */ class
|
|
2218
|
-
constructor(t,
|
|
2219
|
-
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ ,
|
|
2217
|
+
/** A Filter that implements the array-contains-any operator. */ class te extends Wt {
|
|
2218
|
+
constructor(t, e) {
|
|
2219
|
+
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ , e);
|
|
2220
2220
|
}
|
|
2221
2221
|
matches(t) {
|
|
2222
|
-
const
|
|
2223
|
-
return !(!Ct(
|
|
2222
|
+
const e = t.data.field(this.field);
|
|
2223
|
+
return !(!Ct(e) || !e.arrayValue.values) && e.arrayValue.values.some((t => St(this.value.arrayValue, t)));
|
|
2224
2224
|
}
|
|
2225
2225
|
}
|
|
2226
2226
|
|
|
@@ -2237,30 +2237,30 @@ function Kt(t, n) {
|
|
|
2237
2237
|
* Bound provides a function to determine whether a document comes before or
|
|
2238
2238
|
* after a bound. This is influenced by whether the position is just before or
|
|
2239
2239
|
* just after the provided values.
|
|
2240
|
-
*/ class
|
|
2241
|
-
constructor(t,
|
|
2242
|
-
this.position = t, this.before =
|
|
2240
|
+
*/ class ee {
|
|
2241
|
+
constructor(t, e) {
|
|
2242
|
+
this.position = t, this.before = e;
|
|
2243
2243
|
}
|
|
2244
2244
|
}
|
|
2245
2245
|
|
|
2246
2246
|
/**
|
|
2247
2247
|
* An ordering on a field, in some Direction. Direction defaults to ASCENDING.
|
|
2248
|
-
*/ class
|
|
2249
|
-
constructor(t,
|
|
2250
|
-
this.field = t, this.dir =
|
|
2248
|
+
*/ class ne {
|
|
2249
|
+
constructor(t, e = "asc" /* ASCENDING */) {
|
|
2250
|
+
this.field = t, this.dir = e;
|
|
2251
2251
|
}
|
|
2252
2252
|
}
|
|
2253
2253
|
|
|
2254
|
-
function
|
|
2255
|
-
return t.dir ===
|
|
2254
|
+
function re(t, e) {
|
|
2255
|
+
return t.dir === e.dir && t.field.isEqual(e.field);
|
|
2256
2256
|
}
|
|
2257
2257
|
|
|
2258
|
-
function
|
|
2259
|
-
if (null === t) return null ===
|
|
2260
|
-
if (null ===
|
|
2261
|
-
if (t.before !==
|
|
2262
|
-
for (let
|
|
2263
|
-
if (!Ft(t.position[
|
|
2258
|
+
function se(t, e) {
|
|
2259
|
+
if (null === t) return null === e;
|
|
2260
|
+
if (null === e) return !1;
|
|
2261
|
+
if (t.before !== e.before || t.position.length !== e.position.length) return !1;
|
|
2262
|
+
for (let n = 0; n < t.position.length; n++) {
|
|
2263
|
+
if (!Ft(t.position[n], e.position[n])) return !1;
|
|
2264
2264
|
}
|
|
2265
2265
|
return !0;
|
|
2266
2266
|
}
|
|
@@ -2287,29 +2287,29 @@ function sn(t, n) {
|
|
|
2287
2287
|
* query the RemoteStore results.
|
|
2288
2288
|
*
|
|
2289
2289
|
* Visible for testing.
|
|
2290
|
-
*/ class
|
|
2290
|
+
*/ class ie {
|
|
2291
2291
|
/**
|
|
2292
2292
|
* Initializes a Query with a path and optional additional query constraints.
|
|
2293
2293
|
* Path must currently be empty if this is a collection group query.
|
|
2294
2294
|
*/
|
|
2295
|
-
constructor(t,
|
|
2296
|
-
this.path = t, this.collectionGroup =
|
|
2295
|
+
constructor(t, e = null, n = [], r = [], s = null, i = "F" /* First */ , o = null, u = null) {
|
|
2296
|
+
this.path = t, this.collectionGroup = e, this.explicitOrderBy = n, this.filters = r,
|
|
2297
2297
|
this.limit = s, this.limitType = i, this.startAt = o, this.endAt = u, this.D = null,
|
|
2298
2298
|
// The corresponding `Target` of this `Query` instance.
|
|
2299
2299
|
this.$ = null, this.startAt, this.endAt;
|
|
2300
2300
|
}
|
|
2301
2301
|
}
|
|
2302
2302
|
|
|
2303
|
-
/** Creates a new Query for a query that matches all documents at `path` */ function
|
|
2303
|
+
/** Creates a new Query for a query that matches all documents at `path` */ function oe(t) {
|
|
2304
2304
|
return !ot(t.limit) && "L" /* Last */ === t.limitType;
|
|
2305
2305
|
}
|
|
2306
2306
|
|
|
2307
|
-
function
|
|
2307
|
+
function ue(t) {
|
|
2308
2308
|
return t.explicitOrderBy.length > 0 ? t.explicitOrderBy[0].field : null;
|
|
2309
2309
|
}
|
|
2310
2310
|
|
|
2311
|
-
function
|
|
2312
|
-
for (const
|
|
2311
|
+
function ce(t) {
|
|
2312
|
+
for (const e of t.filters) if (e.N()) return e.field;
|
|
2313
2313
|
return null;
|
|
2314
2314
|
}
|
|
2315
2315
|
|
|
@@ -2321,7 +2321,7 @@ function an(t) {
|
|
|
2321
2321
|
* Returns whether the query matches a collection group rather than a specific
|
|
2322
2322
|
* collection.
|
|
2323
2323
|
*/
|
|
2324
|
-
function
|
|
2324
|
+
function ae(t) {
|
|
2325
2325
|
return null !== t.collectionGroup;
|
|
2326
2326
|
}
|
|
2327
2327
|
|
|
@@ -2329,59 +2329,59 @@ function hn(t) {
|
|
|
2329
2329
|
* Returns the implicit order by constraint that is used to execute the Query,
|
|
2330
2330
|
* which can be different from the order by constraints the user provided (e.g.
|
|
2331
2331
|
* the SDK and backend always orders by `__name__`).
|
|
2332
|
-
*/ function
|
|
2333
|
-
const
|
|
2334
|
-
if (null ===
|
|
2335
|
-
|
|
2336
|
-
const t =
|
|
2337
|
-
if (null !== t && null ===
|
|
2332
|
+
*/ function he(t) {
|
|
2333
|
+
const e = b(t);
|
|
2334
|
+
if (null === e.D) {
|
|
2335
|
+
e.D = [];
|
|
2336
|
+
const t = ce(e), n = ue(e);
|
|
2337
|
+
if (null !== t && null === n)
|
|
2338
2338
|
// In order to implicitly add key ordering, we must also add the
|
|
2339
2339
|
// inequality filter field for it to be a valid query.
|
|
2340
2340
|
// Note that the default inequality field and key ordering is ascending.
|
|
2341
|
-
t.isKeyField() ||
|
|
2341
|
+
t.isKeyField() || e.D.push(new ne(t)), e.D.push(new ne(Z.keyField(), "asc" /* ASCENDING */)); else {
|
|
2342
2342
|
let t = !1;
|
|
2343
|
-
for (const
|
|
2343
|
+
for (const n of e.explicitOrderBy) e.D.push(n), n.field.isKeyField() && (t = !0);
|
|
2344
2344
|
if (!t) {
|
|
2345
2345
|
// The order of the implicit key ordering always matches the last
|
|
2346
2346
|
// explicit order by
|
|
2347
|
-
const t =
|
|
2348
|
-
|
|
2347
|
+
const t = e.explicitOrderBy.length > 0 ? e.explicitOrderBy[e.explicitOrderBy.length - 1].dir : "asc" /* ASCENDING */;
|
|
2348
|
+
e.D.push(new ne(Z.keyField(), t));
|
|
2349
2349
|
}
|
|
2350
2350
|
}
|
|
2351
2351
|
}
|
|
2352
|
-
return
|
|
2352
|
+
return e.D;
|
|
2353
2353
|
}
|
|
2354
2354
|
|
|
2355
2355
|
/**
|
|
2356
2356
|
* Converts this `Query` instance to it's corresponding `Target` representation.
|
|
2357
|
-
*/ function
|
|
2358
|
-
const
|
|
2359
|
-
if (!
|
|
2357
|
+
*/ function le(t) {
|
|
2358
|
+
const e = b(t);
|
|
2359
|
+
if (!e.$) if ("F" /* First */ === e.limitType) e.$ = zt(e.path, e.collectionGroup, he(e), e.filters, e.limit, e.startAt, e.endAt); else {
|
|
2360
2360
|
// Flip the orderBy directions since we want the last results
|
|
2361
2361
|
const t = [];
|
|
2362
|
-
for (const
|
|
2363
|
-
const
|
|
2364
|
-
t.push(new
|
|
2362
|
+
for (const n of he(e)) {
|
|
2363
|
+
const e = "desc" /* DESCENDING */ === n.dir ? "asc" /* ASCENDING */ : "desc" /* DESCENDING */;
|
|
2364
|
+
t.push(new ne(n.field, e));
|
|
2365
2365
|
}
|
|
2366
2366
|
// We need to swap the cursors to match the now-flipped query ordering.
|
|
2367
|
-
const
|
|
2367
|
+
const n = e.endAt ? new ee(e.endAt.position, !e.endAt.before) : null, r = e.startAt ? new ee(e.startAt.position, !e.startAt.before) : null;
|
|
2368
2368
|
// Now return as a LimitType.First query.
|
|
2369
|
-
|
|
2369
|
+
e.$ = zt(e.path, e.collectionGroup, t, e.filters, e.limit, n, r);
|
|
2370
2370
|
}
|
|
2371
|
-
return
|
|
2371
|
+
return e.$;
|
|
2372
2372
|
}
|
|
2373
2373
|
|
|
2374
|
-
function
|
|
2375
|
-
return function(t,
|
|
2376
|
-
if (t.limit !==
|
|
2377
|
-
if (t.orderBy.length !==
|
|
2378
|
-
for (let
|
|
2379
|
-
if (t.filters.length !==
|
|
2380
|
-
for (let s = 0; s < t.filters.length; s++) if (
|
|
2381
|
-
|
|
2382
|
-
var
|
|
2383
|
-
return t.collectionGroup ===
|
|
2384
|
-
}(
|
|
2374
|
+
function fe(t, e) {
|
|
2375
|
+
return function(t, e) {
|
|
2376
|
+
if (t.limit !== e.limit) return !1;
|
|
2377
|
+
if (t.orderBy.length !== e.orderBy.length) return !1;
|
|
2378
|
+
for (let n = 0; n < t.orderBy.length; n++) if (!re(t.orderBy[n], e.orderBy[n])) return !1;
|
|
2379
|
+
if (t.filters.length !== e.filters.length) return !1;
|
|
2380
|
+
for (let s = 0; s < t.filters.length; s++) if (n = t.filters[s], r = e.filters[s],
|
|
2381
|
+
n.op !== r.op || !n.field.isEqual(r.field) || !Ft(n.value, r.value)) return !1;
|
|
2382
|
+
var n, r;
|
|
2383
|
+
return t.collectionGroup === e.collectionGroup && !!t.path.isEqual(e.path) && !!se(t.startAt, e.startAt) && se(t.endAt, e.endAt);
|
|
2384
|
+
}(le(t), le(e)) && t.limitType === e.limitType;
|
|
2385
2385
|
}
|
|
2386
2386
|
|
|
2387
2387
|
/**
|
|
@@ -2409,10 +2409,10 @@ function dn(t, n) {
|
|
|
2409
2409
|
* The return value is an IntegerValue if it can safely represent the value,
|
|
2410
2410
|
* otherwise a DoubleValue is returned.
|
|
2411
2411
|
*/
|
|
2412
|
-
function
|
|
2412
|
+
function de(t, e) {
|
|
2413
2413
|
return function(t) {
|
|
2414
2414
|
return "number" == typeof t && Number.isInteger(t) && !ut(t) && t <= Number.MAX_SAFE_INTEGER && t >= Number.MIN_SAFE_INTEGER;
|
|
2415
|
-
}(
|
|
2415
|
+
}(e) ?
|
|
2416
2416
|
/**
|
|
2417
2417
|
* Returns an IntegerValue for `value`.
|
|
2418
2418
|
*/
|
|
@@ -2420,22 +2420,22 @@ function wn(t, n) {
|
|
|
2420
2420
|
return {
|
|
2421
2421
|
integerValue: "" + t
|
|
2422
2422
|
};
|
|
2423
|
-
}(
|
|
2423
|
+
}(e) : function(t, e) {
|
|
2424
2424
|
if (t.F) {
|
|
2425
|
-
if (isNaN(
|
|
2425
|
+
if (isNaN(e)) return {
|
|
2426
2426
|
doubleValue: "NaN"
|
|
2427
2427
|
};
|
|
2428
|
-
if (
|
|
2428
|
+
if (e === 1 / 0) return {
|
|
2429
2429
|
doubleValue: "Infinity"
|
|
2430
2430
|
};
|
|
2431
|
-
if (
|
|
2431
|
+
if (e === -1 / 0) return {
|
|
2432
2432
|
doubleValue: "-Infinity"
|
|
2433
2433
|
};
|
|
2434
2434
|
}
|
|
2435
2435
|
return {
|
|
2436
|
-
doubleValue: ut(
|
|
2436
|
+
doubleValue: ut(e) ? "-0" : e
|
|
2437
2437
|
};
|
|
2438
|
-
}(t,
|
|
2438
|
+
}(t, e);
|
|
2439
2439
|
}
|
|
2440
2440
|
|
|
2441
2441
|
/**
|
|
@@ -2454,7 +2454,7 @@ function wn(t, n) {
|
|
|
2454
2454
|
* See the License for the specific language governing permissions and
|
|
2455
2455
|
* limitations under the License.
|
|
2456
2456
|
*/
|
|
2457
|
-
/** Used to represent a field transform on a mutation. */ class
|
|
2457
|
+
/** Used to represent a field transform on a mutation. */ class we {
|
|
2458
2458
|
constructor() {
|
|
2459
2459
|
// Make sure that the structural type of `TransformOperation` is unique.
|
|
2460
2460
|
// See https://github.com/microsoft/TypeScript/issues/5451
|
|
@@ -2462,15 +2462,15 @@ function wn(t, n) {
|
|
|
2462
2462
|
}
|
|
2463
2463
|
}
|
|
2464
2464
|
|
|
2465
|
-
/** Transforms a value into a server-generated timestamp. */ class
|
|
2465
|
+
/** Transforms a value into a server-generated timestamp. */ class me extends we {}
|
|
2466
2466
|
|
|
2467
|
-
/** Transforms an array value via a union operation. */ class
|
|
2467
|
+
/** Transforms an array value via a union operation. */ class pe extends we {
|
|
2468
2468
|
constructor(t) {
|
|
2469
2469
|
super(), this.elements = t;
|
|
2470
2470
|
}
|
|
2471
2471
|
}
|
|
2472
2472
|
|
|
2473
|
-
/** Transforms an array value via a remove operation. */ class
|
|
2473
|
+
/** Transforms an array value via a remove operation. */ class ye extends we {
|
|
2474
2474
|
constructor(t) {
|
|
2475
2475
|
super(), this.elements = t;
|
|
2476
2476
|
}
|
|
@@ -2481,9 +2481,9 @@ function wn(t, n) {
|
|
|
2481
2481
|
* transforms. Converts all field values to integers or doubles, but unlike the
|
|
2482
2482
|
* backend does not cap integer values at 2^63. Instead, JavaScript number
|
|
2483
2483
|
* arithmetic is used and precision loss can occur for values greater than 2^53.
|
|
2484
|
-
*/ class
|
|
2485
|
-
constructor(t,
|
|
2486
|
-
super(), this.S = t, this.q =
|
|
2484
|
+
*/ class _e extends we {
|
|
2485
|
+
constructor(t, e) {
|
|
2486
|
+
super(), this.S = t, this.q = e;
|
|
2487
2487
|
}
|
|
2488
2488
|
}
|
|
2489
2489
|
|
|
@@ -2503,9 +2503,9 @@ function wn(t, n) {
|
|
|
2503
2503
|
* See the License for the specific language governing permissions and
|
|
2504
2504
|
* limitations under the License.
|
|
2505
2505
|
*/
|
|
2506
|
-
/** A field path and the TransformOperation to perform upon it. */ class
|
|
2507
|
-
constructor(t,
|
|
2508
|
-
this.field = t, this.transform =
|
|
2506
|
+
/** A field path and the TransformOperation to perform upon it. */ class ge {
|
|
2507
|
+
constructor(t, e) {
|
|
2508
|
+
this.field = t, this.transform = e;
|
|
2509
2509
|
}
|
|
2510
2510
|
}
|
|
2511
2511
|
|
|
@@ -2513,18 +2513,18 @@ function wn(t, n) {
|
|
|
2513
2513
|
* Encodes a precondition for a mutation. This follows the model that the
|
|
2514
2514
|
* backend accepts with the special case of an explicit "empty" precondition
|
|
2515
2515
|
* (meaning no precondition).
|
|
2516
|
-
*/ class
|
|
2517
|
-
constructor(t,
|
|
2518
|
-
this.updateTime = t, this.exists =
|
|
2516
|
+
*/ class ve {
|
|
2517
|
+
constructor(t, e) {
|
|
2518
|
+
this.updateTime = t, this.exists = e;
|
|
2519
2519
|
}
|
|
2520
2520
|
/** Creates a new empty Precondition. */ static none() {
|
|
2521
|
-
return new
|
|
2521
|
+
return new ve;
|
|
2522
2522
|
}
|
|
2523
2523
|
/** Creates a new Precondition with an exists flag. */ static exists(t) {
|
|
2524
|
-
return new
|
|
2524
|
+
return new ve(void 0, t);
|
|
2525
2525
|
}
|
|
2526
2526
|
/** Creates a new Precondition based on a version a document exists at. */ static updateTime(t) {
|
|
2527
|
-
return new
|
|
2527
|
+
return new ve(t);
|
|
2528
2528
|
}
|
|
2529
2529
|
/** Returns whether this Precondition is empty. */ get isNone() {
|
|
2530
2530
|
return void 0 === this.updateTime && void 0 === this.exists;
|
|
@@ -2577,14 +2577,14 @@ function wn(t, n) {
|
|
|
2577
2577
|
* applyToLocalView() to implement the actual behavior of applying the mutation
|
|
2578
2578
|
* to some source document (see `setMutationApplyToRemoteDocument()` for an
|
|
2579
2579
|
* example).
|
|
2580
|
-
*/ class
|
|
2580
|
+
*/ class be {}
|
|
2581
2581
|
|
|
2582
2582
|
/**
|
|
2583
2583
|
* A mutation that creates or replaces the document at the given key with the
|
|
2584
2584
|
* object value contents.
|
|
2585
|
-
*/ class
|
|
2586
|
-
constructor(t,
|
|
2587
|
-
super(), this.key = t, this.value =
|
|
2585
|
+
*/ class Ee extends be {
|
|
2586
|
+
constructor(t, e, n, r = []) {
|
|
2587
|
+
super(), this.key = t, this.value = e, this.precondition = n, this.fieldTransforms = r,
|
|
2588
2588
|
this.type = 0 /* Set */;
|
|
2589
2589
|
}
|
|
2590
2590
|
}
|
|
@@ -2601,16 +2601,16 @@ function wn(t, n) {
|
|
|
2601
2601
|
* is deleted.
|
|
2602
2602
|
* * When a field is not in the mask but is in the values, the values map is
|
|
2603
2603
|
* ignored.
|
|
2604
|
-
*/ class
|
|
2605
|
-
constructor(t,
|
|
2606
|
-
super(), this.key = t, this.data =
|
|
2604
|
+
*/ class Ie extends be {
|
|
2605
|
+
constructor(t, e, n, r, s = []) {
|
|
2606
|
+
super(), this.key = t, this.data = e, this.fieldMask = n, this.precondition = r,
|
|
2607
2607
|
this.fieldTransforms = s, this.type = 1 /* Patch */;
|
|
2608
2608
|
}
|
|
2609
2609
|
}
|
|
2610
2610
|
|
|
2611
|
-
/** A mutation that deletes the document at the given key. */ class
|
|
2612
|
-
constructor(t,
|
|
2613
|
-
super(), this.key = t, this.precondition =
|
|
2611
|
+
/** A mutation that deletes the document at the given key. */ class Te extends be {
|
|
2612
|
+
constructor(t, e) {
|
|
2613
|
+
super(), this.key = t, this.precondition = e, this.type = 2 /* Delete */ , this.fieldTransforms = [];
|
|
2614
2614
|
}
|
|
2615
2615
|
}
|
|
2616
2616
|
|
|
@@ -2620,9 +2620,9 @@ function wn(t, n) {
|
|
|
2620
2620
|
*
|
|
2621
2621
|
* The `verify` operation is only used in Transactions, and this class serves
|
|
2622
2622
|
* primarily to facilitate serialization into protos.
|
|
2623
|
-
*/ class
|
|
2624
|
-
constructor(t,
|
|
2625
|
-
super(), this.key = t, this.precondition =
|
|
2623
|
+
*/ class Ae extends be {
|
|
2624
|
+
constructor(t, e) {
|
|
2625
|
+
super(), this.key = t, this.precondition = e, this.type = 3 /* Verify */ , this.fieldTransforms = [];
|
|
2626
2626
|
}
|
|
2627
2627
|
}
|
|
2628
2628
|
|
|
@@ -2641,13 +2641,13 @@ function wn(t, n) {
|
|
|
2641
2641
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2642
2642
|
* See the License for the specific language governing permissions and
|
|
2643
2643
|
* limitations under the License.
|
|
2644
|
-
*/ const
|
|
2644
|
+
*/ const Pe = (() => {
|
|
2645
2645
|
const t = {
|
|
2646
2646
|
asc: "ASCENDING",
|
|
2647
2647
|
desc: "DESCENDING"
|
|
2648
2648
|
};
|
|
2649
2649
|
return t;
|
|
2650
|
-
})(),
|
|
2650
|
+
})(), Re = (() => {
|
|
2651
2651
|
const t = {
|
|
2652
2652
|
"<": "LESS_THAN",
|
|
2653
2653
|
"<=": "LESS_THAN_OR_EQUAL",
|
|
@@ -2677,9 +2677,9 @@ function wn(t, n) {
|
|
|
2677
2677
|
* TODO(klimt): We can remove the databaseId argument if we keep the full
|
|
2678
2678
|
* resource name in documents.
|
|
2679
2679
|
*/
|
|
2680
|
-
class
|
|
2681
|
-
constructor(t,
|
|
2682
|
-
this.databaseId = t, this.F =
|
|
2680
|
+
class Ve {
|
|
2681
|
+
constructor(t, e) {
|
|
2682
|
+
this.databaseId = t, this.F = e;
|
|
2683
2683
|
}
|
|
2684
2684
|
}
|
|
2685
2685
|
|
|
@@ -2694,13 +2694,13 @@ class Nn {
|
|
|
2694
2694
|
/**
|
|
2695
2695
|
* Returns a value for a Date that's appropriate to put into a proto.
|
|
2696
2696
|
*/
|
|
2697
|
-
function
|
|
2697
|
+
function Ne(t, e) {
|
|
2698
2698
|
if (t.F) {
|
|
2699
|
-
return `${new Date(1e3 *
|
|
2699
|
+
return `${new Date(1e3 * e.seconds).toISOString().replace(/\.\d*/, "").replace("Z", "")}.${("000000000" + e.nanoseconds).slice(-9)}Z`;
|
|
2700
2700
|
}
|
|
2701
2701
|
return {
|
|
2702
|
-
seconds: "" +
|
|
2703
|
-
nanos:
|
|
2702
|
+
seconds: "" + e.seconds,
|
|
2703
|
+
nanos: e.nanoseconds
|
|
2704
2704
|
};
|
|
2705
2705
|
}
|
|
2706
2706
|
|
|
@@ -2709,202 +2709,202 @@ function Dn(t, n) {
|
|
|
2709
2709
|
*
|
|
2710
2710
|
* Visible for testing.
|
|
2711
2711
|
*/
|
|
2712
|
-
function
|
|
2713
|
-
return t.F ?
|
|
2712
|
+
function De(t, e) {
|
|
2713
|
+
return t.F ? e.toBase64() : e.toUint8Array();
|
|
2714
2714
|
}
|
|
2715
2715
|
|
|
2716
|
-
function
|
|
2717
|
-
return
|
|
2716
|
+
function $e(t, e) {
|
|
2717
|
+
return Ne(t, e.toTimestamp());
|
|
2718
2718
|
}
|
|
2719
2719
|
|
|
2720
|
-
function
|
|
2721
|
-
return
|
|
2722
|
-
const
|
|
2723
|
-
return new yt(
|
|
2720
|
+
function Fe(t) {
|
|
2721
|
+
return v(!!t), _t.fromTimestamp(function(t) {
|
|
2722
|
+
const e = At(t);
|
|
2723
|
+
return new yt(e.seconds, e.nanos);
|
|
2724
2724
|
}(t));
|
|
2725
2725
|
}
|
|
2726
2726
|
|
|
2727
|
-
function
|
|
2727
|
+
function Se(t, e) {
|
|
2728
2728
|
return function(t) {
|
|
2729
2729
|
return new K([ "projects", t.projectId, "databases", t.database ]);
|
|
2730
|
-
}(t).child("documents").child(
|
|
2730
|
+
}(t).child("documents").child(e).canonicalString();
|
|
2731
2731
|
}
|
|
2732
2732
|
|
|
2733
|
-
function
|
|
2734
|
-
return
|
|
2733
|
+
function qe(t, e) {
|
|
2734
|
+
return Se(t.databaseId, e.path);
|
|
2735
2735
|
}
|
|
2736
2736
|
|
|
2737
|
-
function
|
|
2738
|
-
const
|
|
2739
|
-
const
|
|
2740
|
-
return
|
|
2741
|
-
}(
|
|
2742
|
-
if (
|
|
2743
|
-
if (
|
|
2744
|
-
return new X((
|
|
2737
|
+
function xe(t, e) {
|
|
2738
|
+
const n = function(t) {
|
|
2739
|
+
const e = K.fromString(t);
|
|
2740
|
+
return v(Ge(e)), e;
|
|
2741
|
+
}(e);
|
|
2742
|
+
if (n.get(1) !== t.databaseId.projectId) throw new U(A, "Tried to deserialize key from different project: " + n.get(1) + " vs " + t.databaseId.projectId);
|
|
2743
|
+
if (n.get(3) !== t.databaseId.database) throw new U(A, "Tried to deserialize key from different database: " + n.get(3) + " vs " + t.databaseId.database);
|
|
2744
|
+
return new X((v((r = n).length > 4 && "documents" === r.get(4)), r.popFirst(5)));
|
|
2745
2745
|
var r;
|
|
2746
2746
|
/** Creates a Document proto from key and fields (but no create/update time) */}
|
|
2747
2747
|
|
|
2748
|
-
function
|
|
2749
|
-
return
|
|
2748
|
+
function Oe(t, e) {
|
|
2749
|
+
return Se(t.databaseId, e);
|
|
2750
2750
|
}
|
|
2751
2751
|
|
|
2752
|
-
function
|
|
2752
|
+
function Ce(t) {
|
|
2753
2753
|
return new K([ "projects", t.databaseId.projectId, "databases", t.databaseId.database ]).canonicalString();
|
|
2754
2754
|
}
|
|
2755
2755
|
|
|
2756
|
-
function
|
|
2756
|
+
function Le(t, e, n) {
|
|
2757
2757
|
return {
|
|
2758
|
-
name:
|
|
2759
|
-
fields:
|
|
2758
|
+
name: qe(t, e),
|
|
2759
|
+
fields: n.value.mapValue.fields
|
|
2760
2760
|
};
|
|
2761
2761
|
}
|
|
2762
2762
|
|
|
2763
|
-
function
|
|
2764
|
-
return "found" in
|
|
2765
|
-
|
|
2766
|
-
const
|
|
2763
|
+
function Ue(t, e) {
|
|
2764
|
+
return "found" in e ? function(t, e) {
|
|
2765
|
+
v(!!e.found), e.found.name, e.found.updateTime;
|
|
2766
|
+
const n = xe(t, e.found.name), r = Fe(e.found.updateTime), s = new Mt({
|
|
2767
2767
|
mapValue: {
|
|
2768
|
-
fields:
|
|
2768
|
+
fields: e.found.fields
|
|
2769
2769
|
}
|
|
2770
2770
|
});
|
|
2771
|
-
return Bt.newFoundDocument(
|
|
2772
|
-
}(t,
|
|
2773
|
-
|
|
2774
|
-
const
|
|
2775
|
-
return Bt.newNoDocument(
|
|
2776
|
-
}(t,
|
|
2777
|
-
}
|
|
2778
|
-
|
|
2779
|
-
function
|
|
2780
|
-
let
|
|
2781
|
-
if (
|
|
2782
|
-
update:
|
|
2783
|
-
}; else if (
|
|
2784
|
-
delete:
|
|
2785
|
-
}; else if (
|
|
2786
|
-
update:
|
|
2787
|
-
updateMask:
|
|
2771
|
+
return Bt.newFoundDocument(n, r, s);
|
|
2772
|
+
}(t, e) : "missing" in e ? function(t, e) {
|
|
2773
|
+
v(!!e.missing), v(!!e.readTime);
|
|
2774
|
+
const n = xe(t, e.missing), r = Fe(e.readTime);
|
|
2775
|
+
return Bt.newNoDocument(n, r);
|
|
2776
|
+
}(t, e) : g();
|
|
2777
|
+
}
|
|
2778
|
+
|
|
2779
|
+
function je(t, e) {
|
|
2780
|
+
let n;
|
|
2781
|
+
if (e instanceof Ee) n = {
|
|
2782
|
+
update: Le(t, e.key, e.value)
|
|
2783
|
+
}; else if (e instanceof Te) n = {
|
|
2784
|
+
delete: qe(t, e.key)
|
|
2785
|
+
}; else if (e instanceof Ie) n = {
|
|
2786
|
+
update: Le(t, e.key, e.data),
|
|
2787
|
+
updateMask: We(e.fieldMask)
|
|
2788
2788
|
}; else {
|
|
2789
|
-
if (!(
|
|
2790
|
-
|
|
2791
|
-
verify:
|
|
2789
|
+
if (!(e instanceof Ae)) return g();
|
|
2790
|
+
n = {
|
|
2791
|
+
verify: qe(t, e.key)
|
|
2792
2792
|
};
|
|
2793
2793
|
}
|
|
2794
|
-
return
|
|
2795
|
-
const
|
|
2796
|
-
if (
|
|
2797
|
-
fieldPath:
|
|
2794
|
+
return e.fieldTransforms.length > 0 && (n.updateTransforms = e.fieldTransforms.map((t => function(t, e) {
|
|
2795
|
+
const n = e.transform;
|
|
2796
|
+
if (n instanceof me) return {
|
|
2797
|
+
fieldPath: e.field.canonicalString(),
|
|
2798
2798
|
setToServerValue: "REQUEST_TIME"
|
|
2799
2799
|
};
|
|
2800
|
-
if (
|
|
2801
|
-
fieldPath:
|
|
2800
|
+
if (n instanceof pe) return {
|
|
2801
|
+
fieldPath: e.field.canonicalString(),
|
|
2802
2802
|
appendMissingElements: {
|
|
2803
|
-
values:
|
|
2803
|
+
values: n.elements
|
|
2804
2804
|
}
|
|
2805
2805
|
};
|
|
2806
|
-
if (
|
|
2807
|
-
fieldPath:
|
|
2806
|
+
if (n instanceof ye) return {
|
|
2807
|
+
fieldPath: e.field.canonicalString(),
|
|
2808
2808
|
removeAllFromArray: {
|
|
2809
|
-
values:
|
|
2809
|
+
values: n.elements
|
|
2810
2810
|
}
|
|
2811
2811
|
};
|
|
2812
|
-
if (
|
|
2813
|
-
fieldPath:
|
|
2814
|
-
increment:
|
|
2812
|
+
if (n instanceof _e) return {
|
|
2813
|
+
fieldPath: e.field.canonicalString(),
|
|
2814
|
+
increment: n.q
|
|
2815
2815
|
};
|
|
2816
2816
|
throw g();
|
|
2817
|
-
}(0, t)))),
|
|
2818
|
-
return void 0 !==
|
|
2819
|
-
updateTime:
|
|
2820
|
-
} : void 0 !==
|
|
2821
|
-
exists:
|
|
2817
|
+
}(0, t)))), e.precondition.isNone || (n.currentDocument = function(t, e) {
|
|
2818
|
+
return void 0 !== e.updateTime ? {
|
|
2819
|
+
updateTime: $e(t, e.updateTime)
|
|
2820
|
+
} : void 0 !== e.exists ? {
|
|
2821
|
+
exists: e.exists
|
|
2822
2822
|
} : g();
|
|
2823
|
-
}(t,
|
|
2823
|
+
}(t, e.precondition)), n;
|
|
2824
2824
|
}
|
|
2825
2825
|
|
|
2826
|
-
function
|
|
2826
|
+
function ke(t, e) {
|
|
2827
2827
|
// Dissect the path into parent, collectionId, and optional key filter.
|
|
2828
|
-
const
|
|
2828
|
+
const n = {
|
|
2829
2829
|
structuredQuery: {}
|
|
2830
|
-
}, r =
|
|
2831
|
-
null !==
|
|
2832
|
-
collectionId:
|
|
2830
|
+
}, r = e.path;
|
|
2831
|
+
null !== e.collectionGroup ? (n.parent = Oe(t, r), n.structuredQuery.from = [ {
|
|
2832
|
+
collectionId: e.collectionGroup,
|
|
2833
2833
|
allDescendants: !0
|
|
2834
|
-
} ]) : (
|
|
2834
|
+
} ]) : (n.parent = Oe(t, r.popLast()), n.structuredQuery.from = [ {
|
|
2835
2835
|
collectionId: r.lastSegment()
|
|
2836
2836
|
} ]);
|
|
2837
2837
|
const s = function(t) {
|
|
2838
2838
|
if (0 === t.length) return;
|
|
2839
|
-
const
|
|
2839
|
+
const e = t.map((t =>
|
|
2840
2840
|
// visible for testing
|
|
2841
2841
|
function(t) {
|
|
2842
2842
|
if ("==" /* EQUAL */ === t.op) {
|
|
2843
2843
|
if (Ut(t.value)) return {
|
|
2844
2844
|
unaryFilter: {
|
|
2845
|
-
field:
|
|
2845
|
+
field: ze(t.field),
|
|
2846
2846
|
op: "IS_NAN"
|
|
2847
2847
|
}
|
|
2848
2848
|
};
|
|
2849
2849
|
if (Lt(t.value)) return {
|
|
2850
2850
|
unaryFilter: {
|
|
2851
|
-
field:
|
|
2851
|
+
field: ze(t.field),
|
|
2852
2852
|
op: "IS_NULL"
|
|
2853
2853
|
}
|
|
2854
2854
|
};
|
|
2855
2855
|
} else if ("!=" /* NOT_EQUAL */ === t.op) {
|
|
2856
2856
|
if (Ut(t.value)) return {
|
|
2857
2857
|
unaryFilter: {
|
|
2858
|
-
field:
|
|
2858
|
+
field: ze(t.field),
|
|
2859
2859
|
op: "IS_NOT_NAN"
|
|
2860
2860
|
}
|
|
2861
2861
|
};
|
|
2862
2862
|
if (Lt(t.value)) return {
|
|
2863
2863
|
unaryFilter: {
|
|
2864
|
-
field:
|
|
2864
|
+
field: ze(t.field),
|
|
2865
2865
|
op: "IS_NOT_NULL"
|
|
2866
2866
|
}
|
|
2867
2867
|
};
|
|
2868
2868
|
}
|
|
2869
2869
|
return {
|
|
2870
2870
|
fieldFilter: {
|
|
2871
|
-
field:
|
|
2872
|
-
op:
|
|
2871
|
+
field: ze(t.field),
|
|
2872
|
+
op: Qe(t.op),
|
|
2873
2873
|
value: t.value
|
|
2874
2874
|
}
|
|
2875
2875
|
};
|
|
2876
2876
|
}(t)));
|
|
2877
|
-
if (1 ===
|
|
2877
|
+
if (1 === e.length) return e[0];
|
|
2878
2878
|
return {
|
|
2879
2879
|
compositeFilter: {
|
|
2880
2880
|
op: "AND",
|
|
2881
|
-
filters:
|
|
2881
|
+
filters: e
|
|
2882
2882
|
}
|
|
2883
2883
|
};
|
|
2884
|
-
}(
|
|
2885
|
-
s && (
|
|
2884
|
+
}(e.filters);
|
|
2885
|
+
s && (n.structuredQuery.where = s);
|
|
2886
2886
|
const i = function(t) {
|
|
2887
2887
|
if (0 === t.length) return;
|
|
2888
2888
|
return t.map((t =>
|
|
2889
2889
|
// visible for testing
|
|
2890
2890
|
function(t) {
|
|
2891
2891
|
return {
|
|
2892
|
-
field:
|
|
2893
|
-
direction:
|
|
2892
|
+
field: ze(t.field),
|
|
2893
|
+
direction: Be(t.dir)
|
|
2894
2894
|
};
|
|
2895
2895
|
}(t)));
|
|
2896
|
-
}(
|
|
2897
|
-
i && (
|
|
2898
|
-
const o = function(t,
|
|
2899
|
-
return t.F || ot(
|
|
2900
|
-
value:
|
|
2896
|
+
}(e.orderBy);
|
|
2897
|
+
i && (n.structuredQuery.orderBy = i);
|
|
2898
|
+
const o = function(t, e) {
|
|
2899
|
+
return t.F || ot(e) ? e : {
|
|
2900
|
+
value: e
|
|
2901
2901
|
};
|
|
2902
|
-
}(t,
|
|
2903
|
-
return null !== o && (
|
|
2904
|
-
|
|
2902
|
+
}(t, e.limit);
|
|
2903
|
+
return null !== o && (n.structuredQuery.limit = o), e.startAt && (n.structuredQuery.startAt = Me(e.startAt)),
|
|
2904
|
+
e.endAt && (n.structuredQuery.endAt = Me(e.endAt)), n;
|
|
2905
2905
|
}
|
|
2906
2906
|
|
|
2907
|
-
function
|
|
2907
|
+
function Me(t) {
|
|
2908
2908
|
return {
|
|
2909
2909
|
before: t.before,
|
|
2910
2910
|
values: t.position
|
|
@@ -2912,29 +2912,29 @@ function Bn(t) {
|
|
|
2912
2912
|
}
|
|
2913
2913
|
|
|
2914
2914
|
// visible for testing
|
|
2915
|
-
function
|
|
2916
|
-
return
|
|
2915
|
+
function Be(t) {
|
|
2916
|
+
return Pe[t];
|
|
2917
2917
|
}
|
|
2918
2918
|
|
|
2919
2919
|
// visible for testing
|
|
2920
|
-
function
|
|
2921
|
-
return
|
|
2920
|
+
function Qe(t) {
|
|
2921
|
+
return Re[t];
|
|
2922
2922
|
}
|
|
2923
2923
|
|
|
2924
|
-
function
|
|
2924
|
+
function ze(t) {
|
|
2925
2925
|
return {
|
|
2926
2926
|
fieldPath: t.canonicalString()
|
|
2927
2927
|
};
|
|
2928
2928
|
}
|
|
2929
2929
|
|
|
2930
|
-
function
|
|
2931
|
-
const
|
|
2932
|
-
return t.fields.forEach((t =>
|
|
2933
|
-
fieldPaths:
|
|
2930
|
+
function We(t) {
|
|
2931
|
+
const e = [];
|
|
2932
|
+
return t.fields.forEach((t => e.push(t.canonicalString()))), {
|
|
2933
|
+
fieldPaths: e
|
|
2934
2934
|
};
|
|
2935
2935
|
}
|
|
2936
2936
|
|
|
2937
|
-
function
|
|
2937
|
+
function Ge(t) {
|
|
2938
2938
|
// Resource names have at least 4 components (project ID, database ID)
|
|
2939
2939
|
return t.length >= 4 && "projects" === t.get(0) && "databases" === t.get(2);
|
|
2940
2940
|
}
|
|
@@ -2954,8 +2954,8 @@ function Hn(t) {
|
|
|
2954
2954
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2955
2955
|
* See the License for the specific language governing permissions and
|
|
2956
2956
|
* limitations under the License.
|
|
2957
|
-
*/ function
|
|
2958
|
-
return new
|
|
2957
|
+
*/ function He(t) {
|
|
2958
|
+
return new Ve(t, /* useProto3Json= */ !0);
|
|
2959
2959
|
}
|
|
2960
2960
|
|
|
2961
2961
|
/**
|
|
@@ -2983,7 +2983,7 @@ function Hn(t) {
|
|
|
2983
2983
|
* base delay. This prevents clients from accidentally synchronizing their
|
|
2984
2984
|
* delays causing spikes of load to the backend.
|
|
2985
2985
|
*/
|
|
2986
|
-
class
|
|
2986
|
+
class Ye {
|
|
2987
2987
|
constructor(
|
|
2988
2988
|
/**
|
|
2989
2989
|
* The AsyncQueue to run backoff operations on.
|
|
@@ -2992,13 +2992,13 @@ class Kn {
|
|
|
2992
2992
|
/**
|
|
2993
2993
|
* The ID to use when scheduling backoff operations on the AsyncQueue.
|
|
2994
2994
|
*/
|
|
2995
|
-
|
|
2995
|
+
e,
|
|
2996
2996
|
/**
|
|
2997
2997
|
* The initial delay (used as the base delay on the first retry attempt).
|
|
2998
2998
|
* Note that jitter will still be applied, so the actual delay could be as
|
|
2999
2999
|
* little as 0.5*initialDelayMs.
|
|
3000
3000
|
*/
|
|
3001
|
-
|
|
3001
|
+
n = 1e3
|
|
3002
3002
|
/**
|
|
3003
3003
|
* The multiplier to use to determine the extended base delay after each
|
|
3004
3004
|
* attempt.
|
|
@@ -3008,7 +3008,7 @@ class Kn {
|
|
|
3008
3008
|
* Note that jitter will still be applied, so the actual delay could be as
|
|
3009
3009
|
* much as 1.5*maxDelayMs.
|
|
3010
3010
|
*/ , s = 6e4) {
|
|
3011
|
-
this.O = t, this.timerId =
|
|
3011
|
+
this.O = t, this.timerId = e, this.C = n, this.L = r, this.U = s, this.j = 0, this.k = null,
|
|
3012
3012
|
/** The last backoff attempt, as epoch milliseconds. */
|
|
3013
3013
|
this.M = Date.now(), this.reset();
|
|
3014
3014
|
}
|
|
@@ -3036,9 +3036,9 @@ class Kn {
|
|
|
3036
3036
|
this.cancel();
|
|
3037
3037
|
// First schedule using the current base (which may be 0 and should be
|
|
3038
3038
|
// honored as such).
|
|
3039
|
-
const
|
|
3039
|
+
const e = Math.floor(this.j + this.G()), n = Math.max(0, Date.now() - this.M), r = Math.max(0, e - n);
|
|
3040
3040
|
// Guard against lastAttemptTime being in the future due to a clock change.
|
|
3041
|
-
r > 0 && m("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.j} ms, delay with jitter: ${
|
|
3041
|
+
r > 0 && m("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.j} ms, delay with jitter: ${e} ms, last attempt: ${n} ms ago)`),
|
|
3042
3042
|
this.k = this.O.enqueueAfterDelay(this.timerId, r, (() => (this.M = Date.now(),
|
|
3043
3043
|
t()))),
|
|
3044
3044
|
// Apply backoff factor to determine next delay and ensure it is within
|
|
@@ -3081,21 +3081,21 @@ class Kn {
|
|
|
3081
3081
|
* An implementation of Datastore that exposes additional state for internal
|
|
3082
3082
|
* consumption.
|
|
3083
3083
|
*/
|
|
3084
|
-
class
|
|
3085
|
-
constructor(t,
|
|
3086
|
-
super(), this.credentials = t, this.Y =
|
|
3084
|
+
class Ke extends class {} {
|
|
3085
|
+
constructor(t, e, n) {
|
|
3086
|
+
super(), this.credentials = t, this.Y = e, this.S = n, this.K = !1;
|
|
3087
3087
|
}
|
|
3088
3088
|
J() {
|
|
3089
3089
|
if (this.K) throw new U(F, "The client has already been terminated.");
|
|
3090
3090
|
}
|
|
3091
|
-
/** Gets an auth token and invokes the provided RPC. */ l(t,
|
|
3092
|
-
return this.J(), this.credentials.getToken().then((r => this.Y.l(t,
|
|
3091
|
+
/** Gets an auth token and invokes the provided RPC. */ l(t, e, n) {
|
|
3092
|
+
return this.J(), this.credentials.getToken().then((r => this.Y.l(t, e, n, r))).catch((t => {
|
|
3093
3093
|
throw "FirebaseError" === t.name ? (t.code === D && this.credentials.invalidateToken(),
|
|
3094
3094
|
t) : new U(T, t.toString());
|
|
3095
3095
|
}));
|
|
3096
3096
|
}
|
|
3097
|
-
/** Gets an auth token and invokes the provided RPC with streamed results. */ v(t,
|
|
3098
|
-
return this.J(), this.credentials.getToken().then((r => this.Y.v(t,
|
|
3097
|
+
/** Gets an auth token and invokes the provided RPC with streamed results. */ v(t, e, n) {
|
|
3098
|
+
return this.J(), this.credentials.getToken().then((r => this.Y.v(t, e, n, r))).catch((t => {
|
|
3099
3099
|
throw "FirebaseError" === t.name ? (t.code === D && this.credentials.invalidateToken(),
|
|
3100
3100
|
t) : new U(T, t.toString());
|
|
3101
3101
|
}));
|
|
@@ -3107,40 +3107,40 @@ class Jn extends class {} {
|
|
|
3107
3107
|
|
|
3108
3108
|
// TODO(firestorexp): Make sure there is only one Datastore instance per
|
|
3109
3109
|
// firestore-exp client.
|
|
3110
|
-
async function
|
|
3111
|
-
const
|
|
3112
|
-
writes:
|
|
3110
|
+
async function Je(t, e) {
|
|
3111
|
+
const n = b(t), r = Ce(n.S) + "/documents", s = {
|
|
3112
|
+
writes: e.map((t => je(n.S, t)))
|
|
3113
3113
|
};
|
|
3114
|
-
await
|
|
3114
|
+
await n.l("Commit", r, s);
|
|
3115
3115
|
}
|
|
3116
3116
|
|
|
3117
|
-
async function
|
|
3118
|
-
const
|
|
3119
|
-
documents:
|
|
3120
|
-
}, i = await
|
|
3117
|
+
async function Ze(t, e) {
|
|
3118
|
+
const n = b(t), r = Ce(n.S) + "/documents", s = {
|
|
3119
|
+
documents: e.map((t => qe(n.S, t)))
|
|
3120
|
+
}, i = await n.v("BatchGetDocuments", r, s), o = new Map;
|
|
3121
3121
|
i.forEach((t => {
|
|
3122
|
-
const
|
|
3123
|
-
o.set(
|
|
3122
|
+
const e = Ue(n.S, t);
|
|
3123
|
+
o.set(e.key.toString(), e);
|
|
3124
3124
|
}));
|
|
3125
3125
|
const u = [];
|
|
3126
|
-
return
|
|
3127
|
-
const
|
|
3128
|
-
|
|
3126
|
+
return e.forEach((t => {
|
|
3127
|
+
const e = o.get(t.toString());
|
|
3128
|
+
v(!!e), u.push(e);
|
|
3129
3129
|
})), u;
|
|
3130
3130
|
}
|
|
3131
3131
|
|
|
3132
|
-
async function
|
|
3133
|
-
const
|
|
3134
|
-
return (await
|
|
3132
|
+
async function Xe(t, e) {
|
|
3133
|
+
const n = b(t), r = ke(n.S, le(e));
|
|
3134
|
+
return (await n.v("RunQuery", r.parent, {
|
|
3135
3135
|
structuredQuery: r.structuredQuery
|
|
3136
|
-
})).filter((t => !!t.document)).map((t => function(t,
|
|
3137
|
-
const r =
|
|
3136
|
+
})).filter((t => !!t.document)).map((t => function(t, e, n) {
|
|
3137
|
+
const r = xe(t, e.name), s = Fe(e.updateTime), i = new Mt({
|
|
3138
3138
|
mapValue: {
|
|
3139
|
-
fields:
|
|
3139
|
+
fields: e.fields
|
|
3140
3140
|
}
|
|
3141
3141
|
}), o = Bt.newFoundDocument(r, s, i);
|
|
3142
|
-
return
|
|
3143
|
-
}(
|
|
3142
|
+
return n && o.setHasCommittedMutations(), n ? o.setHasCommittedMutations() : o;
|
|
3143
|
+
}(n.S, t.document, void 0)));
|
|
3144
3144
|
}
|
|
3145
3145
|
|
|
3146
3146
|
/**
|
|
@@ -3158,7 +3158,7 @@ async function te(t, n) {
|
|
|
3158
3158
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3159
3159
|
* See the License for the specific language governing permissions and
|
|
3160
3160
|
* limitations under the License.
|
|
3161
|
-
*/ const
|
|
3161
|
+
*/ const tn = new Map;
|
|
3162
3162
|
|
|
3163
3163
|
/**
|
|
3164
3164
|
* An instance map that ensures only one Datastore exists per Firestore
|
|
@@ -3169,19 +3169,19 @@ async function te(t, n) {
|
|
|
3169
3169
|
* instance. Callers must invoke removeComponents() when the Firestore
|
|
3170
3170
|
* instance is terminated.
|
|
3171
3171
|
*/
|
|
3172
|
-
function
|
|
3172
|
+
function en(t) {
|
|
3173
3173
|
if (t._terminated) throw new U(F, "The client has already been terminated.");
|
|
3174
|
-
if (!
|
|
3174
|
+
if (!tn.has(t)) {
|
|
3175
3175
|
m("ComponentProvider", "Initializing Datastore");
|
|
3176
3176
|
const i = function(t) {
|
|
3177
3177
|
return new ft(t, fetch.bind(null));
|
|
3178
|
-
}((
|
|
3179
|
-
new G(
|
|
3180
|
-
return new
|
|
3178
|
+
}((e = t._databaseId, n = t.app.options.appId || "", r = t._persistenceKey, s = t._freezeSettings(),
|
|
3179
|
+
new G(e, n, r, s.host, s.ssl, s.experimentalForceLongPolling, s.experimentalAutoDetectLongPolling, s.useFetchStreams))), o = He(t._databaseId), u = function(t, e, n) {
|
|
3180
|
+
return new Ke(t, e, n);
|
|
3181
3181
|
}(t._credentials, i, o);
|
|
3182
|
-
|
|
3182
|
+
tn.set(t, u);
|
|
3183
3183
|
}
|
|
3184
|
-
var
|
|
3184
|
+
var e, n, r, s;
|
|
3185
3185
|
/**
|
|
3186
3186
|
* @license
|
|
3187
3187
|
* Copyright 2018 Google LLC
|
|
@@ -3197,7 +3197,7 @@ function ee(t) {
|
|
|
3197
3197
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3198
3198
|
* See the License for the specific language governing permissions and
|
|
3199
3199
|
* limitations under the License.
|
|
3200
|
-
*/ return
|
|
3200
|
+
*/ return tn.get(t);
|
|
3201
3201
|
}
|
|
3202
3202
|
|
|
3203
3203
|
/**
|
|
@@ -3209,21 +3209,21 @@ function ee(t) {
|
|
|
3209
3209
|
* user-supplied `FirestoreSettings` object. This is a separate type so that
|
|
3210
3210
|
* defaults can be supplied and the value can be checked for equality.
|
|
3211
3211
|
*/
|
|
3212
|
-
class
|
|
3212
|
+
class nn {
|
|
3213
3213
|
constructor(t) {
|
|
3214
|
-
var
|
|
3214
|
+
var e;
|
|
3215
3215
|
if (void 0 === t.host) {
|
|
3216
3216
|
if (void 0 !== t.ssl) throw new U(A, "Can't provide ssl option if host option is not set");
|
|
3217
3217
|
this.host = "firestore.googleapis.com", this.ssl = true;
|
|
3218
|
-
} else this.host = t.host, this.ssl = null === (
|
|
3218
|
+
} else this.host = t.host, this.ssl = null === (e = t.ssl) || void 0 === e || e;
|
|
3219
3219
|
if (this.credentials = t.credentials, this.ignoreUndefinedProperties = !!t.ignoreUndefinedProperties,
|
|
3220
3220
|
void 0 === t.cacheSizeBytes) this.cacheSizeBytes = 41943040; else {
|
|
3221
3221
|
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new U(A, "cacheSizeBytes must be at least 1048576");
|
|
3222
3222
|
this.cacheSizeBytes = t.cacheSizeBytes;
|
|
3223
3223
|
}
|
|
3224
3224
|
this.experimentalForceLongPolling = !!t.experimentalForceLongPolling, this.experimentalAutoDetectLongPolling = !!t.experimentalAutoDetectLongPolling,
|
|
3225
|
-
this.useFetchStreams = !!t.useFetchStreams, function(t,
|
|
3226
|
-
if (!0 ===
|
|
3225
|
+
this.useFetchStreams = !!t.useFetchStreams, function(t, e, n, r) {
|
|
3226
|
+
if (!0 === e && !0 === r) throw new U(A, `${t} and ${n} cannot be used together.`);
|
|
3227
3227
|
}("experimentalForceLongPolling", t.experimentalForceLongPolling, "experimentalAutoDetectLongPolling", t.experimentalAutoDetectLongPolling);
|
|
3228
3228
|
}
|
|
3229
3229
|
isEqual(t) {
|
|
@@ -3251,14 +3251,14 @@ class re {
|
|
|
3251
3251
|
* The Cloud Firestore service interface.
|
|
3252
3252
|
*
|
|
3253
3253
|
* Do not call this constructor directly. Instead, use {@link getFirestore}.
|
|
3254
|
-
*/ class
|
|
3254
|
+
*/ class rn {
|
|
3255
3255
|
/** @hideconstructor */
|
|
3256
|
-
constructor(t,
|
|
3257
|
-
this._credentials =
|
|
3256
|
+
constructor(t, e) {
|
|
3257
|
+
this._credentials = e,
|
|
3258
3258
|
/**
|
|
3259
3259
|
* Whether it's a Firestore or Firestore Lite instance.
|
|
3260
3260
|
*/
|
|
3261
|
-
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new
|
|
3261
|
+
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new nn({}),
|
|
3262
3262
|
this._settingsFrozen = !1, t instanceof H ? this._databaseId = t : (this._app = t,
|
|
3263
3263
|
this._databaseId = function(t) {
|
|
3264
3264
|
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new U(A, '"projectId" not provided in firebase.initializeApp.');
|
|
@@ -3291,14 +3291,14 @@ class re {
|
|
|
3291
3291
|
}
|
|
3292
3292
|
_setSettings(t) {
|
|
3293
3293
|
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.");
|
|
3294
|
-
this._settings = new
|
|
3294
|
+
this._settings = new nn(t), void 0 !== t.credentials && (this._credentials = function(t) {
|
|
3295
3295
|
if (!t) return new M;
|
|
3296
3296
|
switch (t.type) {
|
|
3297
3297
|
case "gapi":
|
|
3298
|
-
const
|
|
3298
|
+
const e = t.client;
|
|
3299
3299
|
// Make sure this really is a Gapi client.
|
|
3300
|
-
return
|
|
3301
|
-
new W(
|
|
3300
|
+
return v(!("object" != typeof e || null === e || !e.auth || !e.auth.getAuthHeaderValueForFirstParty)),
|
|
3301
|
+
new W(e, t.sessionIndex || "0", t.iamToken || null);
|
|
3302
3302
|
|
|
3303
3303
|
case "provider":
|
|
3304
3304
|
return t.client;
|
|
@@ -3332,17 +3332,17 @@ class re {
|
|
|
3332
3332
|
* Only ever called once.
|
|
3333
3333
|
*/ _terminate() {
|
|
3334
3334
|
return function(t) {
|
|
3335
|
-
const
|
|
3336
|
-
|
|
3335
|
+
const e = tn.get(t);
|
|
3336
|
+
e && (m("ComponentProvider", "Removing Datastore"), tn.delete(t), e.terminate());
|
|
3337
3337
|
}(this), Promise.resolve();
|
|
3338
3338
|
}
|
|
3339
3339
|
}
|
|
3340
3340
|
|
|
3341
|
-
function
|
|
3342
|
-
const
|
|
3343
|
-
if (
|
|
3344
|
-
return
|
|
3345
|
-
options:
|
|
3341
|
+
function sn(t, e) {
|
|
3342
|
+
const n = _getProvider(t, "firestore/lite");
|
|
3343
|
+
if (n.isInitialized()) throw new U(F, "Firestore can only be initialized once per app.");
|
|
3344
|
+
return n.initialize({
|
|
3345
|
+
options: e
|
|
3346
3346
|
});
|
|
3347
3347
|
}
|
|
3348
3348
|
|
|
@@ -3354,8 +3354,8 @@ function ie(t, n) {
|
|
|
3354
3354
|
* @param app - The {@link @firebase/app#FirebaseApp} instance that the returned `Firestore`
|
|
3355
3355
|
* instance is associated with.
|
|
3356
3356
|
* @returns The `Firestore` instance of the provided app.
|
|
3357
|
-
*/ function
|
|
3358
|
-
return _getProvider(
|
|
3357
|
+
*/ function on(e = t()) {
|
|
3358
|
+
return _getProvider(e, "firestore/lite").getImmediate();
|
|
3359
3359
|
}
|
|
3360
3360
|
|
|
3361
3361
|
/**
|
|
@@ -3370,24 +3370,24 @@ function ie(t, n) {
|
|
|
3370
3370
|
* @param port - the emulator port (ex: 9000).
|
|
3371
3371
|
* @param options.mockUserToken - the mock auth token to use for unit testing
|
|
3372
3372
|
* Security Rules.
|
|
3373
|
-
*/ function
|
|
3373
|
+
*/ function un(t, e, n, r = {}) {
|
|
3374
3374
|
var s;
|
|
3375
|
-
const i = (t = st(t,
|
|
3376
|
-
if ("firestore.googleapis.com" !== i.host && i.host !==
|
|
3375
|
+
const i = (t = st(t, rn))._getSettings();
|
|
3376
|
+
if ("firestore.googleapis.com" !== i.host && i.host !== e && y("Host has been set in both settings() and useEmulator(), emulator host will be used"),
|
|
3377
3377
|
t._setSettings(Object.assign(Object.assign({}, i), {
|
|
3378
|
-
host: `${
|
|
3378
|
+
host: `${e}:${n}`,
|
|
3379
3379
|
ssl: !1
|
|
3380
3380
|
})), r.mockUserToken) {
|
|
3381
|
-
let
|
|
3382
|
-
if ("string" == typeof r.mockUserToken)
|
|
3381
|
+
let e, n;
|
|
3382
|
+
if ("string" == typeof r.mockUserToken) e = r.mockUserToken, n = l.MOCK_USER; else {
|
|
3383
3383
|
// Let createMockUserToken validate first (catches common mistakes like
|
|
3384
3384
|
// invalid field "uid" and missing field "sub" / "user_id".)
|
|
3385
|
-
|
|
3385
|
+
e = a(r.mockUserToken, null === (s = t._app) || void 0 === s ? void 0 : s.options.projectId);
|
|
3386
3386
|
const i = r.mockUserToken.sub || r.mockUserToken.user_id;
|
|
3387
3387
|
if (!i) throw new U(A, "mockUserToken must contain 'sub' or 'user_id' field!");
|
|
3388
|
-
|
|
3388
|
+
n = new l(i);
|
|
3389
3389
|
}
|
|
3390
|
-
t._credentials = new B(new k(
|
|
3390
|
+
t._credentials = new B(new k(e, n));
|
|
3391
3391
|
}
|
|
3392
3392
|
}
|
|
3393
3393
|
|
|
@@ -3410,8 +3410,8 @@ function ie(t, n) {
|
|
|
3410
3410
|
* @param firestore - The `Firestore` instance to terminate.
|
|
3411
3411
|
* @returns A `Promise` that is resolved when the instance has been successfully
|
|
3412
3412
|
* terminated.
|
|
3413
|
-
*/ function
|
|
3414
|
-
return t = st(t,
|
|
3413
|
+
*/ function cn(t) {
|
|
3414
|
+
return t = st(t, rn), e(t.app, "firestore/lite"), t._delete();
|
|
3415
3415
|
}
|
|
3416
3416
|
|
|
3417
3417
|
/**
|
|
@@ -3451,14 +3451,14 @@ function ie(t, n) {
|
|
|
3451
3451
|
* and can be used to write, read, or listen to the location. The document at
|
|
3452
3452
|
* the referenced location may or may not exist.
|
|
3453
3453
|
*/
|
|
3454
|
-
class
|
|
3454
|
+
class an {
|
|
3455
3455
|
/** @hideconstructor */
|
|
3456
3456
|
constructor(t,
|
|
3457
3457
|
/**
|
|
3458
3458
|
* If provided, the `FirestoreDataConverter` associated with this instance.
|
|
3459
3459
|
*/
|
|
3460
|
-
|
|
3461
|
-
this.converter =
|
|
3460
|
+
e, n) {
|
|
3461
|
+
this.converter = e, this._key = n,
|
|
3462
3462
|
/** The type of this Firestore reference. */
|
|
3463
3463
|
this.type = "document", this.firestore = t;
|
|
3464
3464
|
}
|
|
@@ -3479,40 +3479,40 @@ class ae {
|
|
|
3479
3479
|
/**
|
|
3480
3480
|
* The collection this `DocumentReference` belongs to.
|
|
3481
3481
|
*/ get parent() {
|
|
3482
|
-
return new
|
|
3482
|
+
return new ln(this.firestore, this.converter, this._key.path.popLast());
|
|
3483
3483
|
}
|
|
3484
3484
|
withConverter(t) {
|
|
3485
|
-
return new
|
|
3485
|
+
return new an(this.firestore, t, this._key);
|
|
3486
3486
|
}
|
|
3487
3487
|
}
|
|
3488
3488
|
|
|
3489
3489
|
/**
|
|
3490
3490
|
* A `Query` refers to a query which you can read or listen to. You can also
|
|
3491
3491
|
* construct refined `Query` objects by adding filters and ordering.
|
|
3492
|
-
*/ class
|
|
3492
|
+
*/ class hn {
|
|
3493
3493
|
// This is the lite version of the Query class in the main SDK.
|
|
3494
3494
|
/** @hideconstructor protected */
|
|
3495
3495
|
constructor(t,
|
|
3496
3496
|
/**
|
|
3497
3497
|
* If provided, the `FirestoreDataConverter` associated with this instance.
|
|
3498
3498
|
*/
|
|
3499
|
-
|
|
3500
|
-
this.converter =
|
|
3499
|
+
e, n) {
|
|
3500
|
+
this.converter = e, this._query = n,
|
|
3501
3501
|
/** The type of this Firestore reference. */
|
|
3502
3502
|
this.type = "query", this.firestore = t;
|
|
3503
3503
|
}
|
|
3504
3504
|
withConverter(t) {
|
|
3505
|
-
return new
|
|
3505
|
+
return new hn(this.firestore, t, this._query);
|
|
3506
3506
|
}
|
|
3507
3507
|
}
|
|
3508
3508
|
|
|
3509
3509
|
/**
|
|
3510
3510
|
* A `CollectionReference` object can be used for adding documents, getting
|
|
3511
3511
|
* document references, and querying for documents (using {@link query}).
|
|
3512
|
-
*/ class
|
|
3512
|
+
*/ class ln extends hn {
|
|
3513
3513
|
/** @hideconstructor */
|
|
3514
|
-
constructor(t,
|
|
3515
|
-
super(t,
|
|
3514
|
+
constructor(t, e, n) {
|
|
3515
|
+
super(t, e, new ie(n)), this._path = n,
|
|
3516
3516
|
/** The type of this Firestore reference. */
|
|
3517
3517
|
this.type = "collection";
|
|
3518
3518
|
}
|
|
@@ -3530,23 +3530,23 @@ class ae {
|
|
|
3530
3530
|
* subcollection. If this isn't a subcollection, the reference is null.
|
|
3531
3531
|
*/ get parent() {
|
|
3532
3532
|
const t = this._path.popLast();
|
|
3533
|
-
return t.isEmpty() ? null : new
|
|
3533
|
+
return t.isEmpty() ? null : new an(this.firestore,
|
|
3534
3534
|
/* converter= */ null, new X(t));
|
|
3535
3535
|
}
|
|
3536
3536
|
withConverter(t) {
|
|
3537
|
-
return new
|
|
3537
|
+
return new ln(this.firestore, t, this._path);
|
|
3538
3538
|
}
|
|
3539
3539
|
}
|
|
3540
3540
|
|
|
3541
|
-
function
|
|
3542
|
-
if (t = h(t), tt("collection", "path",
|
|
3543
|
-
const r = K.fromString(
|
|
3544
|
-
return
|
|
3541
|
+
function fn(t, e, ...n) {
|
|
3542
|
+
if (t = h(t), tt("collection", "path", e), t instanceof rn) {
|
|
3543
|
+
const r = K.fromString(e, ...n);
|
|
3544
|
+
return nt(r), new ln(t, /* converter= */ null, r);
|
|
3545
3545
|
}
|
|
3546
3546
|
{
|
|
3547
|
-
if (!(t instanceof
|
|
3548
|
-
const r = t._path.child(K.fromString(
|
|
3549
|
-
return
|
|
3547
|
+
if (!(t instanceof an || t instanceof ln)) throw new U(A, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3548
|
+
const r = t._path.child(K.fromString(e, ...n));
|
|
3549
|
+
return nt(r), new ln(t.firestore,
|
|
3550
3550
|
/* converter= */ null, r);
|
|
3551
3551
|
}
|
|
3552
3552
|
}
|
|
@@ -3563,32 +3563,32 @@ function fe(t, n, ...e) {
|
|
|
3563
3563
|
* collection or subcollection with this ID as the last segment of its path
|
|
3564
3564
|
* will be included. Cannot contain a slash.
|
|
3565
3565
|
* @returns The created `Query`.
|
|
3566
|
-
*/ function
|
|
3567
|
-
if (t = st(t,
|
|
3568
|
-
return new
|
|
3566
|
+
*/ function dn(t, e) {
|
|
3567
|
+
if (t = st(t, rn), tt("collectionGroup", "collection id", e), e.indexOf("/") >= 0) throw new U(A, `Invalid collection ID '${e}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);
|
|
3568
|
+
return new hn(t,
|
|
3569
3569
|
/* converter= */ null,
|
|
3570
3570
|
/**
|
|
3571
3571
|
* Creates a new Query for a collection group query that matches all documents
|
|
3572
3572
|
* within the provided collection group.
|
|
3573
3573
|
*/
|
|
3574
3574
|
function(t) {
|
|
3575
|
-
return new
|
|
3576
|
-
}(
|
|
3575
|
+
return new ie(K.emptyPath(), t);
|
|
3576
|
+
}(e));
|
|
3577
3577
|
}
|
|
3578
3578
|
|
|
3579
|
-
function
|
|
3579
|
+
function wn(t, e, ...n) {
|
|
3580
3580
|
if (t = h(t),
|
|
3581
3581
|
// We allow omission of 'pathString' but explicitly prohibit passing in both
|
|
3582
3582
|
// 'undefined' and 'null'.
|
|
3583
|
-
1 === arguments.length && (
|
|
3584
|
-
const r = K.fromString(
|
|
3585
|
-
return
|
|
3583
|
+
1 === arguments.length && (e = wt.A()), tt("doc", "path", e), t instanceof rn) {
|
|
3584
|
+
const r = K.fromString(e, ...n);
|
|
3585
|
+
return et(r), new an(t,
|
|
3586
3586
|
/* converter= */ null, new X(r));
|
|
3587
3587
|
}
|
|
3588
3588
|
{
|
|
3589
|
-
if (!(t instanceof
|
|
3590
|
-
const r = t._path.child(K.fromString(
|
|
3591
|
-
return
|
|
3589
|
+
if (!(t instanceof an || t instanceof ln)) throw new U(A, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3590
|
+
const r = t._path.child(K.fromString(e, ...n));
|
|
3591
|
+
return et(r), new an(t.firestore, t instanceof ln ? t.converter : null, new X(r));
|
|
3592
3592
|
}
|
|
3593
3593
|
}
|
|
3594
3594
|
|
|
@@ -3599,8 +3599,8 @@ function we(t, n, ...e) {
|
|
|
3599
3599
|
* @param right - A reference to compare.
|
|
3600
3600
|
* @returns true if the references point to the same location in the same
|
|
3601
3601
|
* Firestore database.
|
|
3602
|
-
*/ function
|
|
3603
|
-
return t = h(t),
|
|
3602
|
+
*/ function mn(t, e) {
|
|
3603
|
+
return t = h(t), e = h(e), (t instanceof an || t instanceof ln) && (e instanceof an || e instanceof ln) && (t.firestore === e.firestore && t.path === e.path && t.converter === e.converter);
|
|
3604
3604
|
}
|
|
3605
3605
|
|
|
3606
3606
|
/**
|
|
@@ -3611,8 +3611,8 @@ function we(t, n, ...e) {
|
|
|
3611
3611
|
* @param right - A `Query` to compare.
|
|
3612
3612
|
* @returns true if the references point to the same location in the same
|
|
3613
3613
|
* Firestore database.
|
|
3614
|
-
*/ function
|
|
3615
|
-
return t = h(t),
|
|
3614
|
+
*/ function pn(t, e) {
|
|
3615
|
+
return t = h(t), e = h(e), t instanceof hn && e instanceof hn && (t.firestore === e.firestore && fe(t._query, e._query) && t.converter === e.converter);
|
|
3616
3616
|
}
|
|
3617
3617
|
|
|
3618
3618
|
/**
|
|
@@ -3638,7 +3638,7 @@ function we(t, n, ...e) {
|
|
|
3638
3638
|
*
|
|
3639
3639
|
* Create a `FieldPath` by providing field names. If more than one field
|
|
3640
3640
|
* name is provided, the path will point to a nested field in a document.
|
|
3641
|
-
*/ class
|
|
3641
|
+
*/ class yn {
|
|
3642
3642
|
/**
|
|
3643
3643
|
* Creates a `FieldPath` from the provided field names. If more than one field
|
|
3644
3644
|
* name is provided, the path will point to a nested field in a document.
|
|
@@ -3646,7 +3646,7 @@ function we(t, n, ...e) {
|
|
|
3646
3646
|
* @param fieldNames - A list of field names.
|
|
3647
3647
|
*/
|
|
3648
3648
|
constructor(...t) {
|
|
3649
|
-
for (let
|
|
3649
|
+
for (let e = 0; e < t.length; ++e) if (0 === t[e].length) throw new U(A, "Invalid field name at argument $(i + 1). Field names must not be empty.");
|
|
3650
3650
|
this._internalPath = new Z(t);
|
|
3651
3651
|
}
|
|
3652
3652
|
/**
|
|
@@ -3662,8 +3662,8 @@ function we(t, n, ...e) {
|
|
|
3662
3662
|
/**
|
|
3663
3663
|
* Returns a special sentinel `FieldPath` to refer to the ID of a document.
|
|
3664
3664
|
* It can be used in queries to sort or filter by the document ID.
|
|
3665
|
-
*/ function
|
|
3666
|
-
return new
|
|
3665
|
+
*/ function _n() {
|
|
3666
|
+
return new yn("__name__");
|
|
3667
3667
|
}
|
|
3668
3668
|
|
|
3669
3669
|
/**
|
|
@@ -3684,7 +3684,7 @@ function we(t, n, ...e) {
|
|
|
3684
3684
|
*/
|
|
3685
3685
|
/**
|
|
3686
3686
|
* An immutable object representing an array of bytes.
|
|
3687
|
-
*/ class
|
|
3687
|
+
*/ class gn {
|
|
3688
3688
|
/** @hideconstructor */
|
|
3689
3689
|
constructor(t) {
|
|
3690
3690
|
this._byteString = t;
|
|
@@ -3696,7 +3696,7 @@ function we(t, n, ...e) {
|
|
|
3696
3696
|
* @param base64 - The Base64 string used to create the `Bytes` object.
|
|
3697
3697
|
*/ static fromBase64String(t) {
|
|
3698
3698
|
try {
|
|
3699
|
-
return new
|
|
3699
|
+
return new gn(It.fromBase64String(t));
|
|
3700
3700
|
} catch (t) {
|
|
3701
3701
|
throw new U(A, "Failed to construct data from Base64 string: " + t);
|
|
3702
3702
|
}
|
|
@@ -3706,7 +3706,7 @@ function we(t, n, ...e) {
|
|
|
3706
3706
|
*
|
|
3707
3707
|
* @param array - The Uint8Array used to create the `Bytes` object.
|
|
3708
3708
|
*/ static fromUint8Array(t) {
|
|
3709
|
-
return new
|
|
3709
|
+
return new gn(It.fromUint8Array(t));
|
|
3710
3710
|
}
|
|
3711
3711
|
/**
|
|
3712
3712
|
* Returns the underlying bytes as a Base64-encoded string.
|
|
@@ -3758,7 +3758,7 @@ function we(t, n, ...e) {
|
|
|
3758
3758
|
/**
|
|
3759
3759
|
* Sentinel values that can be used when writing document fields with `set()`
|
|
3760
3760
|
* or `update()`.
|
|
3761
|
-
*/ class
|
|
3761
|
+
*/ class vn {
|
|
3762
3762
|
/**
|
|
3763
3763
|
* @param _methodName - The public API endpoint that returns this class.
|
|
3764
3764
|
* @hideconstructor
|
|
@@ -3790,17 +3790,17 @@ function we(t, n, ...e) {
|
|
|
3790
3790
|
*
|
|
3791
3791
|
* Latitude values are in the range of [-90, 90].
|
|
3792
3792
|
* Longitude values are in the range of [-180, 180].
|
|
3793
|
-
*/ class
|
|
3793
|
+
*/ class bn {
|
|
3794
3794
|
/**
|
|
3795
3795
|
* Creates a new immutable `GeoPoint` object with the provided latitude and
|
|
3796
3796
|
* longitude values.
|
|
3797
3797
|
* @param latitude - The latitude as number between -90 and 90.
|
|
3798
3798
|
* @param longitude - The longitude as number between -180 and 180.
|
|
3799
3799
|
*/
|
|
3800
|
-
constructor(t,
|
|
3800
|
+
constructor(t, e) {
|
|
3801
3801
|
if (!isFinite(t) || t < -90 || t > 90) throw new U(A, "Latitude must be a number between -90 and 90, but was: " + t);
|
|
3802
|
-
if (!isFinite(
|
|
3803
|
-
this._lat = t, this._long =
|
|
3802
|
+
if (!isFinite(e) || e < -180 || e > 180) throw new U(A, "Longitude must be a number between -180 and 180, but was: " + e);
|
|
3803
|
+
this._lat = t, this._long = e;
|
|
3804
3804
|
}
|
|
3805
3805
|
/**
|
|
3806
3806
|
* The latitude of this `GeoPoint` instance.
|
|
@@ -3849,29 +3849,29 @@ function we(t, n, ...e) {
|
|
|
3849
3849
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3850
3850
|
* See the License for the specific language governing permissions and
|
|
3851
3851
|
* limitations under the License.
|
|
3852
|
-
*/ const
|
|
3852
|
+
*/ const En = /^__.*__$/;
|
|
3853
3853
|
|
|
3854
|
-
/** The result of parsing document data (e.g. for a setData call). */ class
|
|
3855
|
-
constructor(t,
|
|
3856
|
-
this.data = t, this.fieldMask =
|
|
3854
|
+
/** The result of parsing document data (e.g. for a setData call). */ class In {
|
|
3855
|
+
constructor(t, e, n) {
|
|
3856
|
+
this.data = t, this.fieldMask = e, this.fieldTransforms = n;
|
|
3857
3857
|
}
|
|
3858
|
-
toMutation(t,
|
|
3859
|
-
return null !== this.fieldMask ? new
|
|
3858
|
+
toMutation(t, e) {
|
|
3859
|
+
return null !== this.fieldMask ? new Ie(t, this.data, this.fieldMask, e, this.fieldTransforms) : new Ee(t, this.data, e, this.fieldTransforms);
|
|
3860
3860
|
}
|
|
3861
3861
|
}
|
|
3862
3862
|
|
|
3863
|
-
/** The result of parsing "update" data (i.e. for an updateData call). */ class
|
|
3863
|
+
/** The result of parsing "update" data (i.e. for an updateData call). */ class Tn {
|
|
3864
3864
|
constructor(t,
|
|
3865
3865
|
// The fieldMask does not include document transforms.
|
|
3866
|
-
|
|
3867
|
-
this.data = t, this.fieldMask =
|
|
3866
|
+
e, n) {
|
|
3867
|
+
this.data = t, this.fieldMask = e, this.fieldTransforms = n;
|
|
3868
3868
|
}
|
|
3869
|
-
toMutation(t,
|
|
3870
|
-
return new
|
|
3869
|
+
toMutation(t, e) {
|
|
3870
|
+
return new Ie(t, this.data, this.fieldMask, e, this.fieldTransforms);
|
|
3871
3871
|
}
|
|
3872
3872
|
}
|
|
3873
3873
|
|
|
3874
|
-
function
|
|
3874
|
+
function An(t) {
|
|
3875
3875
|
switch (t) {
|
|
3876
3876
|
case 0 /* Set */ :
|
|
3877
3877
|
// fall through
|
|
@@ -3889,7 +3889,7 @@ function Ae(t) {
|
|
|
3889
3889
|
}
|
|
3890
3890
|
}
|
|
3891
3891
|
|
|
3892
|
-
/** A "context" object passed around while parsing user data. */ class
|
|
3892
|
+
/** A "context" object passed around while parsing user data. */ class Pn {
|
|
3893
3893
|
/**
|
|
3894
3894
|
* Initializes a ParseContext with the given source and path.
|
|
3895
3895
|
*
|
|
@@ -3908,8 +3908,8 @@ function Ae(t) {
|
|
|
3908
3908
|
* which case certain features will not work and errors will be somewhat
|
|
3909
3909
|
* compromised).
|
|
3910
3910
|
*/
|
|
3911
|
-
constructor(t,
|
|
3912
|
-
this.settings = t, this.databaseId =
|
|
3911
|
+
constructor(t, e, n, r, s, i) {
|
|
3912
|
+
this.settings = t, this.databaseId = e, this.S = n, this.ignoreUndefinedProperties = r,
|
|
3913
3913
|
// Minor hack: If fieldTransforms is undefined, we assume this is an
|
|
3914
3914
|
// external call and we need to validate the entire path.
|
|
3915
3915
|
void 0 === s && this.Z(), this.fieldTransforms = s || [], this.fieldMask = i || [];
|
|
@@ -3921,21 +3921,21 @@ function Ae(t) {
|
|
|
3921
3921
|
return this.settings.X;
|
|
3922
3922
|
}
|
|
3923
3923
|
/** Returns a new context with the specified settings overwritten. */ tt(t) {
|
|
3924
|
-
return new
|
|
3924
|
+
return new Pn(Object.assign(Object.assign({}, this.settings), t), this.databaseId, this.S, this.ignoreUndefinedProperties, this.fieldTransforms, this.fieldMask);
|
|
3925
3925
|
}
|
|
3926
|
-
|
|
3927
|
-
var
|
|
3928
|
-
const
|
|
3929
|
-
path:
|
|
3930
|
-
|
|
3926
|
+
et(t) {
|
|
3927
|
+
var e;
|
|
3928
|
+
const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), r = this.tt({
|
|
3929
|
+
path: n,
|
|
3930
|
+
nt: !1
|
|
3931
3931
|
});
|
|
3932
3932
|
return r.rt(t), r;
|
|
3933
3933
|
}
|
|
3934
3934
|
st(t) {
|
|
3935
|
-
var
|
|
3936
|
-
const
|
|
3937
|
-
path:
|
|
3938
|
-
|
|
3935
|
+
var e;
|
|
3936
|
+
const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), r = this.tt({
|
|
3937
|
+
path: n,
|
|
3938
|
+
nt: !1
|
|
3939
3939
|
});
|
|
3940
3940
|
return r.Z(), r;
|
|
3941
3941
|
}
|
|
@@ -3944,14 +3944,14 @@ function Ae(t) {
|
|
|
3944
3944
|
// undefined.
|
|
3945
3945
|
return this.tt({
|
|
3946
3946
|
path: void 0,
|
|
3947
|
-
|
|
3947
|
+
nt: !0
|
|
3948
3948
|
});
|
|
3949
3949
|
}
|
|
3950
3950
|
ot(t) {
|
|
3951
|
-
return
|
|
3951
|
+
return Wn(t, this.settings.methodName, this.settings.ut || !1, this.path, this.settings.ct);
|
|
3952
3952
|
}
|
|
3953
3953
|
/** Returns 'true' if 'fieldPath' was traversed when creating this context. */ contains(t) {
|
|
3954
|
-
return void 0 !== this.fieldMask.find((
|
|
3954
|
+
return void 0 !== this.fieldMask.find((e => t.isPrefixOf(e))) || void 0 !== this.fieldTransforms.find((e => t.isPrefixOf(e.field)));
|
|
3955
3955
|
}
|
|
3956
3956
|
Z() {
|
|
3957
3957
|
// TODO(b/34871131): Remove null check once we have proper paths for fields
|
|
@@ -3960,52 +3960,52 @@ function Ae(t) {
|
|
|
3960
3960
|
}
|
|
3961
3961
|
rt(t) {
|
|
3962
3962
|
if (0 === t.length) throw this.ot("Document fields must not be empty");
|
|
3963
|
-
if (
|
|
3963
|
+
if (An(this.X) && En.test(t)) throw this.ot('Document fields cannot begin and end with "__"');
|
|
3964
3964
|
}
|
|
3965
3965
|
}
|
|
3966
3966
|
|
|
3967
3967
|
/**
|
|
3968
3968
|
* Helper for parsing raw user input (provided via the API) into internal model
|
|
3969
3969
|
* classes.
|
|
3970
|
-
*/ class
|
|
3971
|
-
constructor(t,
|
|
3972
|
-
this.databaseId = t, this.ignoreUndefinedProperties =
|
|
3970
|
+
*/ class Rn {
|
|
3971
|
+
constructor(t, e, n) {
|
|
3972
|
+
this.databaseId = t, this.ignoreUndefinedProperties = e, this.S = n || He(t);
|
|
3973
3973
|
}
|
|
3974
|
-
/** Creates a new top-level parse context. */ at(t,
|
|
3975
|
-
return new
|
|
3974
|
+
/** Creates a new top-level parse context. */ at(t, e, n, r = !1) {
|
|
3975
|
+
return new Pn({
|
|
3976
3976
|
X: t,
|
|
3977
|
-
methodName:
|
|
3978
|
-
ct:
|
|
3977
|
+
methodName: e,
|
|
3978
|
+
ct: n,
|
|
3979
3979
|
path: Z.emptyPath(),
|
|
3980
|
-
|
|
3980
|
+
nt: !1,
|
|
3981
3981
|
ut: r
|
|
3982
3982
|
}, this.databaseId, this.S, this.ignoreUndefinedProperties);
|
|
3983
3983
|
}
|
|
3984
3984
|
}
|
|
3985
3985
|
|
|
3986
|
-
function
|
|
3987
|
-
const
|
|
3988
|
-
return new
|
|
3986
|
+
function Vn(t) {
|
|
3987
|
+
const e = t._freezeSettings(), n = He(t._databaseId);
|
|
3988
|
+
return new Rn(t._databaseId, !!e.ignoreUndefinedProperties, n);
|
|
3989
3989
|
}
|
|
3990
3990
|
|
|
3991
|
-
/** Parse document data from a set() call. */ function
|
|
3992
|
-
const o = t.at(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ ,
|
|
3993
|
-
|
|
3994
|
-
const u =
|
|
3991
|
+
/** Parse document data from a set() call. */ function Nn(t, e, n, r, s, i = {}) {
|
|
3992
|
+
const o = t.at(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ , e, n, s);
|
|
3993
|
+
Mn("Data must be an object, but it was:", o, r);
|
|
3994
|
+
const u = jn(r, o);
|
|
3995
3995
|
let c, a;
|
|
3996
|
-
if (i.merge) c = new
|
|
3996
|
+
if (i.merge) c = new bt(o.fieldMask), a = o.fieldTransforms; else if (i.mergeFields) {
|
|
3997
3997
|
const t = [];
|
|
3998
3998
|
for (const r of i.mergeFields) {
|
|
3999
|
-
const s =
|
|
3999
|
+
const s = Bn(e, r, n);
|
|
4000
4000
|
if (!o.contains(s)) throw new U(A, `Field '${s}' is specified in your field mask but missing from your input data.`);
|
|
4001
|
-
|
|
4001
|
+
Gn(t, s) || t.push(s);
|
|
4002
4002
|
}
|
|
4003
|
-
c = new
|
|
4003
|
+
c = new bt(t), a = o.fieldTransforms.filter((t => c.covers(t.field)));
|
|
4004
4004
|
} else c = null, a = o.fieldTransforms;
|
|
4005
|
-
return new
|
|
4005
|
+
return new In(new Mt(u), c, a);
|
|
4006
4006
|
}
|
|
4007
4007
|
|
|
4008
|
-
class
|
|
4008
|
+
class Dn extends vn {
|
|
4009
4009
|
_toFieldTransform(t) {
|
|
4010
4010
|
if (2 /* MergeSet */ !== t.X) throw 1 /* Update */ === t.X ? t.ot(`${this._methodName}() can only appear at the top level of your update data`) : t.ot(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);
|
|
4011
4011
|
// No transform to add for a delete, but we need to add it to our
|
|
@@ -4013,7 +4013,7 @@ class De extends be {
|
|
|
4013
4013
|
return t.fieldMask.push(t.path), null;
|
|
4014
4014
|
}
|
|
4015
4015
|
isEqual(t) {
|
|
4016
|
-
return t instanceof
|
|
4016
|
+
return t instanceof Dn;
|
|
4017
4017
|
}
|
|
4018
4018
|
}
|
|
4019
4019
|
|
|
@@ -4032,32 +4032,32 @@ class De extends be {
|
|
|
4032
4032
|
* context.
|
|
4033
4033
|
* @param context - The parent context.
|
|
4034
4034
|
* @param arrayElement - Whether or not the FieldValue has an array.
|
|
4035
|
-
*/ function $
|
|
4036
|
-
return new
|
|
4035
|
+
*/ function $n(t, e, n) {
|
|
4036
|
+
return new Pn({
|
|
4037
4037
|
X: 3 /* Argument */ ,
|
|
4038
|
-
ct:
|
|
4038
|
+
ct: e.settings.ct,
|
|
4039
4039
|
methodName: t._methodName,
|
|
4040
|
-
|
|
4041
|
-
},
|
|
4040
|
+
nt: n
|
|
4041
|
+
}, e.databaseId, e.S, e.ignoreUndefinedProperties);
|
|
4042
4042
|
}
|
|
4043
4043
|
|
|
4044
|
-
class
|
|
4044
|
+
class Fn extends vn {
|
|
4045
4045
|
_toFieldTransform(t) {
|
|
4046
|
-
return new
|
|
4046
|
+
return new ge(t.path, new me);
|
|
4047
4047
|
}
|
|
4048
4048
|
isEqual(t) {
|
|
4049
|
-
return t instanceof
|
|
4049
|
+
return t instanceof Fn;
|
|
4050
4050
|
}
|
|
4051
4051
|
}
|
|
4052
4052
|
|
|
4053
|
-
class
|
|
4054
|
-
constructor(t,
|
|
4055
|
-
super(t), this.ht =
|
|
4053
|
+
class Sn extends vn {
|
|
4054
|
+
constructor(t, e) {
|
|
4055
|
+
super(t), this.ht = e;
|
|
4056
4056
|
}
|
|
4057
4057
|
_toFieldTransform(t) {
|
|
4058
|
-
const
|
|
4059
|
-
/*array=*/ !0),
|
|
4060
|
-
return new
|
|
4058
|
+
const e = $n(this, t,
|
|
4059
|
+
/*array=*/ !0), n = this.ht.map((t => Un(t, e))), r = new pe(n);
|
|
4060
|
+
return new ge(t.path, r);
|
|
4061
4061
|
}
|
|
4062
4062
|
isEqual(t) {
|
|
4063
4063
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4065,14 +4065,14 @@ class Se extends be {
|
|
|
4065
4065
|
}
|
|
4066
4066
|
}
|
|
4067
4067
|
|
|
4068
|
-
class
|
|
4069
|
-
constructor(t,
|
|
4070
|
-
super(t), this.ht =
|
|
4068
|
+
class qn extends vn {
|
|
4069
|
+
constructor(t, e) {
|
|
4070
|
+
super(t), this.ht = e;
|
|
4071
4071
|
}
|
|
4072
4072
|
_toFieldTransform(t) {
|
|
4073
|
-
const
|
|
4074
|
-
/*array=*/ !0),
|
|
4075
|
-
return new
|
|
4073
|
+
const e = $n(this, t,
|
|
4074
|
+
/*array=*/ !0), n = this.ht.map((t => Un(t, e))), r = new ye(n);
|
|
4075
|
+
return new ge(t.path, r);
|
|
4076
4076
|
}
|
|
4077
4077
|
isEqual(t) {
|
|
4078
4078
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4080,13 +4080,13 @@ class qe extends be {
|
|
|
4080
4080
|
}
|
|
4081
4081
|
}
|
|
4082
4082
|
|
|
4083
|
-
class
|
|
4084
|
-
constructor(t,
|
|
4085
|
-
super(t), this.lt =
|
|
4083
|
+
class xn extends vn {
|
|
4084
|
+
constructor(t, e) {
|
|
4085
|
+
super(t), this.lt = e;
|
|
4086
4086
|
}
|
|
4087
4087
|
_toFieldTransform(t) {
|
|
4088
|
-
const
|
|
4089
|
-
return new
|
|
4088
|
+
const e = new _e(t.S, de(t.S, this.lt));
|
|
4089
|
+
return new ge(t.path, e);
|
|
4090
4090
|
}
|
|
4091
4091
|
isEqual(t) {
|
|
4092
4092
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4094,50 +4094,50 @@ class xe extends be {
|
|
|
4094
4094
|
}
|
|
4095
4095
|
}
|
|
4096
4096
|
|
|
4097
|
-
/** Parse update data from an update() call. */ function
|
|
4098
|
-
const s = t.at(1 /* Update */ ,
|
|
4099
|
-
|
|
4097
|
+
/** Parse update data from an update() call. */ function On(t, e, n, r) {
|
|
4098
|
+
const s = t.at(1 /* Update */ , e, n);
|
|
4099
|
+
Mn("Data must be an object, but it was:", s, r);
|
|
4100
4100
|
const i = [], o = Mt.empty();
|
|
4101
|
-
|
|
4102
|
-
const u =
|
|
4101
|
+
vt(r, ((t, r) => {
|
|
4102
|
+
const u = zn(e, t, n);
|
|
4103
4103
|
// For Compat types, we have to "extract" the underlying types before
|
|
4104
4104
|
// performing validation.
|
|
4105
4105
|
r = h(r);
|
|
4106
4106
|
const c = s.st(u);
|
|
4107
|
-
if (r instanceof
|
|
4107
|
+
if (r instanceof Dn)
|
|
4108
4108
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4109
4109
|
i.push(u); else {
|
|
4110
|
-
const t =
|
|
4110
|
+
const t = Un(r, c);
|
|
4111
4111
|
null != t && (i.push(u), o.set(u, t));
|
|
4112
4112
|
}
|
|
4113
4113
|
}));
|
|
4114
|
-
const u = new
|
|
4115
|
-
return new
|
|
4114
|
+
const u = new bt(i);
|
|
4115
|
+
return new Tn(o, u, s.fieldTransforms);
|
|
4116
4116
|
}
|
|
4117
4117
|
|
|
4118
|
-
/** Parse update data from a list of field/value arguments. */ function
|
|
4119
|
-
const o = t.at(1 /* Update */ ,
|
|
4120
|
-
if (i.length % 2 != 0) throw new U(A, `Function ${
|
|
4121
|
-
for (let t = 0; t < i.length; t += 2) u.push(
|
|
4118
|
+
/** Parse update data from a list of field/value arguments. */ function Cn(t, e, n, r, s, i) {
|
|
4119
|
+
const o = t.at(1 /* Update */ , e, n), u = [ Bn(e, r, n) ], c = [ s ];
|
|
4120
|
+
if (i.length % 2 != 0) throw new U(A, `Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);
|
|
4121
|
+
for (let t = 0; t < i.length; t += 2) u.push(Bn(e, i[t])), c.push(i[t + 1]);
|
|
4122
4122
|
const a = [], l = Mt.empty();
|
|
4123
4123
|
// We iterate in reverse order to pick the last value for a field if the
|
|
4124
4124
|
// user specified the field multiple times.
|
|
4125
|
-
for (let t = u.length - 1; t >= 0; --t) if (!
|
|
4126
|
-
const
|
|
4127
|
-
let
|
|
4125
|
+
for (let t = u.length - 1; t >= 0; --t) if (!Gn(a, u[t])) {
|
|
4126
|
+
const e = u[t];
|
|
4127
|
+
let n = c[t];
|
|
4128
4128
|
// For Compat types, we have to "extract" the underlying types before
|
|
4129
4129
|
// performing validation.
|
|
4130
|
-
|
|
4131
|
-
const r = o.st(
|
|
4132
|
-
if (
|
|
4130
|
+
n = h(n);
|
|
4131
|
+
const r = o.st(e);
|
|
4132
|
+
if (n instanceof Dn)
|
|
4133
4133
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4134
|
-
a.push(
|
|
4135
|
-
const t =
|
|
4136
|
-
null != t && (a.push(
|
|
4134
|
+
a.push(e); else {
|
|
4135
|
+
const t = Un(n, r);
|
|
4136
|
+
null != t && (a.push(e), l.set(e, t));
|
|
4137
4137
|
}
|
|
4138
4138
|
}
|
|
4139
|
-
const f = new
|
|
4140
|
-
return new
|
|
4139
|
+
const f = new bt(a);
|
|
4140
|
+
return new Tn(l, f, o.fieldTransforms);
|
|
4141
4141
|
}
|
|
4142
4142
|
|
|
4143
4143
|
/**
|
|
@@ -4146,8 +4146,8 @@ class xe extends be {
|
|
|
4146
4146
|
*
|
|
4147
4147
|
* @param allowArrays - Whether the query value is an array that may directly
|
|
4148
4148
|
* contain additional arrays (e.g. the operand of an `in` query).
|
|
4149
|
-
*/ function
|
|
4150
|
-
return
|
|
4149
|
+
*/ function Ln(t, e, n, r = !1) {
|
|
4150
|
+
return Un(n, t.at(r ? 4 /* ArrayArgument */ : 3 /* Argument */ , e));
|
|
4151
4151
|
}
|
|
4152
4152
|
|
|
4153
4153
|
/**
|
|
@@ -4158,12 +4158,12 @@ class xe extends be {
|
|
|
4158
4158
|
* the source of the data being parsed, etc.
|
|
4159
4159
|
* @returns The parsed value, or null if the value was a FieldValue sentinel
|
|
4160
4160
|
* that should not be included in the resulting parsed data.
|
|
4161
|
-
*/ function
|
|
4162
|
-
if (
|
|
4161
|
+
*/ function Un(t, e) {
|
|
4162
|
+
if (kn(
|
|
4163
4163
|
// Unwrap the API type from the Compat SDK. This will return the API type
|
|
4164
4164
|
// from firestore-exp.
|
|
4165
|
-
t = h(t))) return
|
|
4166
|
-
if (t instanceof
|
|
4165
|
+
t = h(t))) return Mn("Unsupported field value:", e, t), jn(t, e);
|
|
4166
|
+
if (t instanceof vn)
|
|
4167
4167
|
// FieldValues usually parse into transforms (except FieldValue.delete())
|
|
4168
4168
|
// in which case we do not want to include this field in our parsed data
|
|
4169
4169
|
// (as doing so will overwrite the field directly prior to the transform
|
|
@@ -4173,19 +4173,19 @@ class xe extends be {
|
|
|
4173
4173
|
* "Parses" the provided FieldValueImpl, adding any necessary transforms to
|
|
4174
4174
|
* context.fieldTransforms.
|
|
4175
4175
|
*/
|
|
4176
|
-
return function(t,
|
|
4176
|
+
return function(t, e) {
|
|
4177
4177
|
// Sentinels are only supported with writes, and not within arrays.
|
|
4178
|
-
if (!
|
|
4179
|
-
if (!
|
|
4180
|
-
const
|
|
4181
|
-
|
|
4178
|
+
if (!An(e.X)) throw e.ot(`${t._methodName}() can only be used with update() and set()`);
|
|
4179
|
+
if (!e.path) throw e.ot(`${t._methodName}() is not currently supported inside arrays`);
|
|
4180
|
+
const n = t._toFieldTransform(e);
|
|
4181
|
+
n && e.fieldTransforms.push(n);
|
|
4182
4182
|
}
|
|
4183
4183
|
/**
|
|
4184
4184
|
* Helper to parse a scalar value (i.e. not an Object, Array, or FieldValue)
|
|
4185
4185
|
*
|
|
4186
4186
|
* @returns The parsed value
|
|
4187
|
-
*/ (t,
|
|
4188
|
-
if (void 0 === t &&
|
|
4187
|
+
*/ (t, e), null;
|
|
4188
|
+
if (void 0 === t && e.ignoreUndefinedProperties)
|
|
4189
4189
|
// If the input is undefined it can never participate in the fieldMask, so
|
|
4190
4190
|
// don't handle this below. If `ignoreUndefinedProperties` is false,
|
|
4191
4191
|
// `parseScalarValue` will reject an undefined value.
|
|
@@ -4193,38 +4193,38 @@ class xe extends be {
|
|
|
4193
4193
|
if (
|
|
4194
4194
|
// If context.path is null we are inside an array and we don't support
|
|
4195
4195
|
// field mask paths more granular than the top-level array.
|
|
4196
|
-
|
|
4196
|
+
e.path && e.fieldMask.push(e.path), t instanceof Array) {
|
|
4197
4197
|
// TODO(b/34871131): Include the path containing the array in the error
|
|
4198
4198
|
// message.
|
|
4199
4199
|
// In the case of IN queries, the parsed data is an array (representing
|
|
4200
4200
|
// the set of values to be included for the IN query) that may directly
|
|
4201
4201
|
// contain additional arrays (each representing an individual field
|
|
4202
4202
|
// value), so we disable this validation.
|
|
4203
|
-
if (
|
|
4204
|
-
return function(t,
|
|
4205
|
-
const
|
|
4203
|
+
if (e.settings.nt && 4 /* ArrayArgument */ !== e.X) throw e.ot("Nested arrays are not supported");
|
|
4204
|
+
return function(t, e) {
|
|
4205
|
+
const n = [];
|
|
4206
4206
|
let r = 0;
|
|
4207
4207
|
for (const s of t) {
|
|
4208
|
-
let t =
|
|
4208
|
+
let t = Un(s, e.it(r));
|
|
4209
4209
|
null == t && (
|
|
4210
4210
|
// Just include nulls in the array for fields being replaced with a
|
|
4211
4211
|
// sentinel.
|
|
4212
4212
|
t = {
|
|
4213
4213
|
nullValue: "NULL_VALUE"
|
|
4214
|
-
}),
|
|
4214
|
+
}), n.push(t), r++;
|
|
4215
4215
|
}
|
|
4216
4216
|
return {
|
|
4217
4217
|
arrayValue: {
|
|
4218
|
-
values:
|
|
4218
|
+
values: n
|
|
4219
4219
|
}
|
|
4220
4220
|
};
|
|
4221
|
-
}(t,
|
|
4221
|
+
}(t, e);
|
|
4222
4222
|
}
|
|
4223
|
-
return function(t,
|
|
4223
|
+
return function(t, e) {
|
|
4224
4224
|
if (null === (t = h(t))) return {
|
|
4225
4225
|
nullValue: "NULL_VALUE"
|
|
4226
4226
|
};
|
|
4227
|
-
if ("number" == typeof t) return
|
|
4227
|
+
if ("number" == typeof t) return de(e.S, t);
|
|
4228
4228
|
if ("boolean" == typeof t) return {
|
|
4229
4229
|
booleanValue: t
|
|
4230
4230
|
};
|
|
@@ -4232,37 +4232,37 @@ class xe extends be {
|
|
|
4232
4232
|
stringValue: t
|
|
4233
4233
|
};
|
|
4234
4234
|
if (t instanceof Date) {
|
|
4235
|
-
const
|
|
4235
|
+
const n = yt.fromDate(t);
|
|
4236
4236
|
return {
|
|
4237
|
-
timestampValue:
|
|
4237
|
+
timestampValue: Ne(e.S, n)
|
|
4238
4238
|
};
|
|
4239
4239
|
}
|
|
4240
4240
|
if (t instanceof yt) {
|
|
4241
4241
|
// Firestore backend truncates precision down to microseconds. To ensure
|
|
4242
4242
|
// offline mode works the same with regards to truncation, perform the
|
|
4243
4243
|
// truncation immediately without waiting for the backend to do that.
|
|
4244
|
-
const
|
|
4244
|
+
const n = new yt(t.seconds, 1e3 * Math.floor(t.nanoseconds / 1e3));
|
|
4245
4245
|
return {
|
|
4246
|
-
timestampValue:
|
|
4246
|
+
timestampValue: Ne(e.S, n)
|
|
4247
4247
|
};
|
|
4248
4248
|
}
|
|
4249
|
-
if (t instanceof
|
|
4249
|
+
if (t instanceof bn) return {
|
|
4250
4250
|
geoPointValue: {
|
|
4251
4251
|
latitude: t.latitude,
|
|
4252
4252
|
longitude: t.longitude
|
|
4253
4253
|
}
|
|
4254
4254
|
};
|
|
4255
|
-
if (t instanceof
|
|
4256
|
-
bytesValue:
|
|
4255
|
+
if (t instanceof gn) return {
|
|
4256
|
+
bytesValue: De(e.S, t._byteString)
|
|
4257
4257
|
};
|
|
4258
|
-
if (t instanceof
|
|
4259
|
-
const
|
|
4260
|
-
if (!r.isEqual(
|
|
4258
|
+
if (t instanceof an) {
|
|
4259
|
+
const n = e.databaseId, r = t.firestore._databaseId;
|
|
4260
|
+
if (!r.isEqual(n)) throw e.ot(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);
|
|
4261
4261
|
return {
|
|
4262
|
-
referenceValue:
|
|
4262
|
+
referenceValue: Se(t.firestore._databaseId || e.databaseId, t._key.path)
|
|
4263
4263
|
};
|
|
4264
4264
|
}
|
|
4265
|
-
throw
|
|
4265
|
+
throw e.ot(`Unsupported field value: ${rt(t)}`);
|
|
4266
4266
|
}
|
|
4267
4267
|
/**
|
|
4268
4268
|
* Checks whether an object looks like a JSON object that should be converted
|
|
@@ -4270,56 +4270,56 @@ class xe extends be {
|
|
|
4270
4270
|
* JSON objects since they should be converted to a struct value. Arrays, Dates,
|
|
4271
4271
|
* GeoPoints, etc. are not considered to look like JSON objects since they map
|
|
4272
4272
|
* to specific FieldValue types other than ObjectValue.
|
|
4273
|
-
*/ (t,
|
|
4273
|
+
*/ (t, e);
|
|
4274
4274
|
}
|
|
4275
4275
|
|
|
4276
|
-
function
|
|
4277
|
-
const
|
|
4276
|
+
function jn(t, e) {
|
|
4277
|
+
const n = {};
|
|
4278
4278
|
return !function(t) {
|
|
4279
|
-
for (const
|
|
4279
|
+
for (const e in t) if (Object.prototype.hasOwnProperty.call(t, e)) return !1;
|
|
4280
4280
|
return !0;
|
|
4281
|
-
}(t) ?
|
|
4282
|
-
const s =
|
|
4283
|
-
null != s && (
|
|
4281
|
+
}(t) ? vt(t, ((t, r) => {
|
|
4282
|
+
const s = Un(r, e.et(t));
|
|
4283
|
+
null != s && (n[t] = s);
|
|
4284
4284
|
})) :
|
|
4285
4285
|
// If we encounter an empty object, we explicitly add it to the update
|
|
4286
4286
|
// mask to ensure that the server creates a map entry.
|
|
4287
|
-
|
|
4287
|
+
e.path && e.path.length > 0 && e.fieldMask.push(e.path), {
|
|
4288
4288
|
mapValue: {
|
|
4289
|
-
fields:
|
|
4289
|
+
fields: n
|
|
4290
4290
|
}
|
|
4291
4291
|
};
|
|
4292
4292
|
}
|
|
4293
4293
|
|
|
4294
|
-
function
|
|
4295
|
-
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof yt || t instanceof
|
|
4294
|
+
function kn(t) {
|
|
4295
|
+
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof yt || t instanceof bn || t instanceof gn || t instanceof an || t instanceof vn);
|
|
4296
4296
|
}
|
|
4297
4297
|
|
|
4298
|
-
function
|
|
4299
|
-
if (!
|
|
4298
|
+
function Mn(t, e, n) {
|
|
4299
|
+
if (!kn(n) || !function(t) {
|
|
4300
4300
|
return "object" == typeof t && null !== t && (Object.getPrototypeOf(t) === Object.prototype || null === Object.getPrototypeOf(t));
|
|
4301
|
-
}(
|
|
4302
|
-
const r = rt(
|
|
4303
|
-
throw "an object" === r ?
|
|
4301
|
+
}(n)) {
|
|
4302
|
+
const r = rt(n);
|
|
4303
|
+
throw "an object" === r ? e.ot(t + " a custom object") : e.ot(t + " " + r);
|
|
4304
4304
|
}
|
|
4305
4305
|
}
|
|
4306
4306
|
|
|
4307
4307
|
/**
|
|
4308
4308
|
* Helper that calls fromDotSeparatedString() but wraps any error thrown.
|
|
4309
|
-
*/ function
|
|
4309
|
+
*/ function Bn(t, e, n) {
|
|
4310
4310
|
if ((
|
|
4311
4311
|
// If required, replace the FieldPath Compat class with with the firestore-exp
|
|
4312
4312
|
// FieldPath.
|
|
4313
|
-
|
|
4314
|
-
if ("string" == typeof
|
|
4315
|
-
throw
|
|
4313
|
+
e = h(e)) instanceof yn) return e._internalPath;
|
|
4314
|
+
if ("string" == typeof e) return zn(t, e);
|
|
4315
|
+
throw Wn("Field path arguments must be of type string or FieldPath.", t,
|
|
4316
4316
|
/* hasConverter= */ !1,
|
|
4317
|
-
/* path= */ void 0,
|
|
4317
|
+
/* path= */ void 0, n);
|
|
4318
4318
|
}
|
|
4319
4319
|
|
|
4320
4320
|
/**
|
|
4321
4321
|
* Matches any characters in a field path string that are reserved.
|
|
4322
|
-
*/ const
|
|
4322
|
+
*/ const Qn = new RegExp("[~\\*/\\[\\]]");
|
|
4323
4323
|
|
|
4324
4324
|
/**
|
|
4325
4325
|
* Wraps fromDotSeparatedString with an error message about the method that
|
|
@@ -4329,30 +4329,30 @@ function Me(t, n, e) {
|
|
|
4329
4329
|
* split on dots.
|
|
4330
4330
|
* @param targetDoc - The document against which the field path will be
|
|
4331
4331
|
* evaluated.
|
|
4332
|
-
*/ function
|
|
4333
|
-
if (
|
|
4332
|
+
*/ function zn(t, e, n) {
|
|
4333
|
+
if (e.search(Qn) >= 0) throw Wn(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`, t,
|
|
4334
4334
|
/* hasConverter= */ !1,
|
|
4335
|
-
/* path= */ void 0,
|
|
4335
|
+
/* path= */ void 0, n);
|
|
4336
4336
|
try {
|
|
4337
|
-
return new
|
|
4337
|
+
return new yn(...e.split("."))._internalPath;
|
|
4338
4338
|
} catch (r) {
|
|
4339
|
-
throw
|
|
4339
|
+
throw Wn(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`, t,
|
|
4340
4340
|
/* hasConverter= */ !1,
|
|
4341
|
-
/* path= */ void 0,
|
|
4341
|
+
/* path= */ void 0, n);
|
|
4342
4342
|
}
|
|
4343
4343
|
}
|
|
4344
4344
|
|
|
4345
|
-
function
|
|
4345
|
+
function Wn(t, e, n, r, s) {
|
|
4346
4346
|
const i = r && !r.isEmpty(), o = void 0 !== s;
|
|
4347
|
-
let u = `Function ${
|
|
4348
|
-
|
|
4347
|
+
let u = `Function ${e}() called with invalid data`;
|
|
4348
|
+
n && (u += " (via `toFirestore()`)"), u += ". ";
|
|
4349
4349
|
let c = "";
|
|
4350
4350
|
return (i || o) && (c += " (found", i && (c += ` in field ${r}`), o && (c += ` in document ${s}`),
|
|
4351
4351
|
c += ")"), new U(A, u + t + c);
|
|
4352
4352
|
}
|
|
4353
4353
|
|
|
4354
|
-
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function
|
|
4355
|
-
return t.some((t => t.isEqual(
|
|
4354
|
+
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function Gn(t, e) {
|
|
4355
|
+
return t.some((t => t.isEqual(e)));
|
|
4356
4356
|
}
|
|
4357
4357
|
|
|
4358
4358
|
/**
|
|
@@ -4379,14 +4379,14 @@ function We(t, n, e, r, s) {
|
|
|
4379
4379
|
* For a `DocumentSnapshot` that points to a non-existing document, any data
|
|
4380
4380
|
* access will return 'undefined'. You can use the `exists()` method to
|
|
4381
4381
|
* explicitly verify a document's existence.
|
|
4382
|
-
*/ class
|
|
4382
|
+
*/ class Hn {
|
|
4383
4383
|
// Note: This class is stripped down version of the DocumentSnapshot in
|
|
4384
4384
|
// the legacy SDK. The changes are:
|
|
4385
4385
|
// - No support for SnapshotMetadata.
|
|
4386
4386
|
// - No support for SnapshotOptions.
|
|
4387
4387
|
/** @hideconstructor protected */
|
|
4388
|
-
constructor(t,
|
|
4389
|
-
this._firestore = t, this._userDataWriter =
|
|
4388
|
+
constructor(t, e, n, r, s) {
|
|
4389
|
+
this._firestore = t, this._userDataWriter = e, this._key = n, this._document = r,
|
|
4390
4390
|
this._converter = s;
|
|
4391
4391
|
}
|
|
4392
4392
|
/** Property of the `DocumentSnapshot` that provides the document's ID. */ get id() {
|
|
@@ -4395,7 +4395,7 @@ function We(t, n, e, r, s) {
|
|
|
4395
4395
|
/**
|
|
4396
4396
|
* The `DocumentReference` for the document included in the `DocumentSnapshot`.
|
|
4397
4397
|
*/ get ref() {
|
|
4398
|
-
return new
|
|
4398
|
+
return new an(this._firestore, this._converter, this._key);
|
|
4399
4399
|
}
|
|
4400
4400
|
/**
|
|
4401
4401
|
* Signals whether or not the document at the snapshot's location exists.
|
|
@@ -4415,7 +4415,7 @@ function We(t, n, e, r, s) {
|
|
|
4415
4415
|
if (this._converter) {
|
|
4416
4416
|
// We only want to use the converter and create a new DocumentSnapshot
|
|
4417
4417
|
// if a converter has been provided.
|
|
4418
|
-
const t = new
|
|
4418
|
+
const t = new Yn(this._firestore, this._userDataWriter, this._key, this._document,
|
|
4419
4419
|
/* converter= */ null);
|
|
4420
4420
|
return this._converter.fromFirestore(t);
|
|
4421
4421
|
}
|
|
@@ -4435,8 +4435,8 @@ function We(t, n, e, r, s) {
|
|
|
4435
4435
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4436
4436
|
get(t) {
|
|
4437
4437
|
if (this._document) {
|
|
4438
|
-
const
|
|
4439
|
-
if (null !==
|
|
4438
|
+
const e = this._document.data.field(Zn("DocumentSnapshot.get", t));
|
|
4439
|
+
if (null !== e) return this._userDataWriter.convertValue(e);
|
|
4440
4440
|
}
|
|
4441
4441
|
}
|
|
4442
4442
|
}
|
|
@@ -4451,7 +4451,7 @@ function We(t, n, e, r, s) {
|
|
|
4451
4451
|
* `DocumentSnapshot`. Since query results contain only existing documents, the
|
|
4452
4452
|
* `exists` property will always be true and `data()` will never return
|
|
4453
4453
|
* 'undefined'.
|
|
4454
|
-
*/ class
|
|
4454
|
+
*/ class Yn extends Hn {
|
|
4455
4455
|
/**
|
|
4456
4456
|
* Retrieves all fields in the document as an `Object`.
|
|
4457
4457
|
*
|
|
@@ -4469,10 +4469,10 @@ function We(t, n, e, r, s) {
|
|
|
4469
4469
|
* array via the `docs` property or enumerated using the `forEach` method. The
|
|
4470
4470
|
* number of documents can be determined via the `empty` and `size`
|
|
4471
4471
|
* properties.
|
|
4472
|
-
*/ class
|
|
4472
|
+
*/ class Kn {
|
|
4473
4473
|
/** @hideconstructor */
|
|
4474
|
-
constructor(t,
|
|
4475
|
-
this._docs =
|
|
4474
|
+
constructor(t, e) {
|
|
4475
|
+
this._docs = e, this.query = t;
|
|
4476
4476
|
}
|
|
4477
4477
|
/** An array of all the documents in the `QuerySnapshot`. */ get docs() {
|
|
4478
4478
|
return [ ...this._docs ];
|
|
@@ -4489,8 +4489,8 @@ function We(t, n, e, r, s) {
|
|
|
4489
4489
|
* @param callback - A callback to be called with a `QueryDocumentSnapshot` for
|
|
4490
4490
|
* each document in the snapshot.
|
|
4491
4491
|
* @param thisArg - The `this` binding for the callback.
|
|
4492
|
-
*/ forEach(t,
|
|
4493
|
-
this._docs.forEach(t,
|
|
4492
|
+
*/ forEach(t, e) {
|
|
4493
|
+
this._docs.forEach(t, e);
|
|
4494
4494
|
}
|
|
4495
4495
|
}
|
|
4496
4496
|
|
|
@@ -4500,14 +4500,14 @@ function We(t, n, e, r, s) {
|
|
|
4500
4500
|
* @param left - A snapshot to compare.
|
|
4501
4501
|
* @param right - A snapshot to compare.
|
|
4502
4502
|
* @returns true if the snapshots are equal.
|
|
4503
|
-
*/ function
|
|
4504
|
-
return t = h(t),
|
|
4503
|
+
*/ function Jn(t, e) {
|
|
4504
|
+
return t = h(t), e = h(e), t instanceof Hn && e instanceof Hn ? t._firestore === e._firestore && t._key.isEqual(e._key) && (null === t._document ? null === e._document : t._document.isEqual(e._document)) && t._converter === e._converter : t instanceof Kn && e instanceof Kn && (pn(t.query, e.query) && pt(t.docs, e.docs, Jn));
|
|
4505
4505
|
}
|
|
4506
4506
|
|
|
4507
4507
|
/**
|
|
4508
4508
|
* Helper that calls `fromDotSeparatedString()` but wraps any error thrown.
|
|
4509
|
-
*/ function
|
|
4510
|
-
return "string" == typeof
|
|
4509
|
+
*/ function Zn(t, e) {
|
|
4510
|
+
return "string" == typeof e ? zn(t, e) : e instanceof yn ? e._internalPath : e._delegate._internalPath;
|
|
4511
4511
|
}
|
|
4512
4512
|
|
|
4513
4513
|
/**
|
|
@@ -4534,7 +4534,7 @@ function We(t, n, e, r, s) {
|
|
|
4534
4534
|
* can then be passed to {@link query} to create a new query instance that
|
|
4535
4535
|
* also contains this `QueryConstraint`.
|
|
4536
4536
|
*/
|
|
4537
|
-
class
|
|
4537
|
+
class Xn {}
|
|
4538
4538
|
|
|
4539
4539
|
/**
|
|
4540
4540
|
* Creates a new immutable instance of {@link Query} that is extended to also include
|
|
@@ -4544,43 +4544,43 @@ class Xe {}
|
|
|
4544
4544
|
* @param queryConstraints - The list of {@link QueryConstraint}s to apply.
|
|
4545
4545
|
* @throws if any of the provided query constraints cannot be combined with the
|
|
4546
4546
|
* existing or new constraints.
|
|
4547
|
-
*/ function tr(t, ...
|
|
4548
|
-
for (const
|
|
4547
|
+
*/ function tr(t, ...e) {
|
|
4548
|
+
for (const n of e) t = n._apply(t);
|
|
4549
4549
|
return t;
|
|
4550
4550
|
}
|
|
4551
4551
|
|
|
4552
|
-
class
|
|
4553
|
-
constructor(t,
|
|
4554
|
-
super(), this.ft = t, this.dt =
|
|
4552
|
+
class er extends Xn {
|
|
4553
|
+
constructor(t, e, n) {
|
|
4554
|
+
super(), this.ft = t, this.dt = e, this.wt = n, this.type = "where";
|
|
4555
4555
|
}
|
|
4556
4556
|
_apply(t) {
|
|
4557
|
-
const
|
|
4557
|
+
const e = Vn(t.firestore), n = function(t, e, n, r, s, i, o) {
|
|
4558
4558
|
let u;
|
|
4559
4559
|
if (s.isKeyField()) {
|
|
4560
4560
|
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new U(A, `Invalid Query. You can't perform '${i}' queries on FieldPath.documentId().`);
|
|
4561
4561
|
if ("in" /* IN */ === i || "not-in" /* NOT_IN */ === i) {
|
|
4562
4562
|
pr(o, i);
|
|
4563
|
-
const
|
|
4564
|
-
for (const
|
|
4563
|
+
const e = [];
|
|
4564
|
+
for (const n of o) e.push(mr(r, t, n));
|
|
4565
4565
|
u = {
|
|
4566
4566
|
arrayValue: {
|
|
4567
|
-
values:
|
|
4567
|
+
values: e
|
|
4568
4568
|
}
|
|
4569
4569
|
};
|
|
4570
4570
|
} else u = mr(r, t, o);
|
|
4571
4571
|
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i || pr(o, i),
|
|
4572
|
-
u =
|
|
4572
|
+
u = Ln(n, e, o,
|
|
4573
4573
|
/* allowArrays= */ "in" /* IN */ === i || "not-in" /* NOT_IN */ === i);
|
|
4574
4574
|
const c = Wt.create(s, i, u);
|
|
4575
|
-
return function(t,
|
|
4576
|
-
if (
|
|
4577
|
-
const
|
|
4578
|
-
if (null !==
|
|
4579
|
-
const r =
|
|
4580
|
-
null !== r && yr(t,
|
|
4575
|
+
return function(t, e) {
|
|
4576
|
+
if (e.N()) {
|
|
4577
|
+
const n = ce(t);
|
|
4578
|
+
if (null !== n && !n.isEqual(e.field)) throw new U(A, `Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '${n.toString()}' and '${e.field.toString()}'`);
|
|
4579
|
+
const r = ue(t);
|
|
4580
|
+
null !== r && yr(t, e.field, r);
|
|
4581
4581
|
}
|
|
4582
|
-
const
|
|
4583
|
-
for (const
|
|
4582
|
+
const n = function(t, e) {
|
|
4583
|
+
for (const n of t.filters) if (e.indexOf(n.op) >= 0) return n.op;
|
|
4584
4584
|
return null;
|
|
4585
4585
|
}(t,
|
|
4586
4586
|
/**
|
|
@@ -4615,16 +4615,16 @@ class nr extends Xe {
|
|
|
4615
4615
|
default:
|
|
4616
4616
|
return [];
|
|
4617
4617
|
}
|
|
4618
|
-
}(
|
|
4619
|
-
if (null !==
|
|
4618
|
+
}(e.op));
|
|
4619
|
+
if (null !== n)
|
|
4620
4620
|
// Special case when it's a duplicate op to give a slightly clearer error message.
|
|
4621
|
-
throw
|
|
4621
|
+
throw n === e.op ? new U(A, `Invalid query. You cannot use more than one '${e.op.toString()}' filter.`) : new U(A, `Invalid query. You cannot use '${e.op.toString()}' filters with '${n.toString()}' filters.`);
|
|
4622
4622
|
}(t, c), c;
|
|
4623
|
-
}(t._query, "where",
|
|
4624
|
-
return new
|
|
4625
|
-
const
|
|
4626
|
-
return new
|
|
4627
|
-
}(t._query,
|
|
4623
|
+
}(t._query, "where", e, t.firestore._databaseId, this.ft, this.dt, this.wt);
|
|
4624
|
+
return new hn(t.firestore, t.converter, function(t, e) {
|
|
4625
|
+
const n = t.filters.concat([ e ]);
|
|
4626
|
+
return new ie(t.path, t.collectionGroup, t.explicitOrderBy.slice(), n, t.limit, t.limitType, t.startAt, t.endAt);
|
|
4627
|
+
}(t._query, n));
|
|
4628
4628
|
}
|
|
4629
4629
|
}
|
|
4630
4630
|
|
|
@@ -4638,25 +4638,25 @@ class nr extends Xe {
|
|
|
4638
4638
|
* "<=", "!=").
|
|
4639
4639
|
* @param value - The value for comparison
|
|
4640
4640
|
* @returns The created {@link Query}.
|
|
4641
|
-
*/ function
|
|
4642
|
-
const r =
|
|
4643
|
-
return new
|
|
4641
|
+
*/ function nr(t, e, n) {
|
|
4642
|
+
const r = e, s = Zn("where", t);
|
|
4643
|
+
return new er(s, r, n);
|
|
4644
4644
|
}
|
|
4645
4645
|
|
|
4646
|
-
class rr extends
|
|
4647
|
-
constructor(t,
|
|
4648
|
-
super(), this.ft = t, this.yt =
|
|
4646
|
+
class rr extends Xn {
|
|
4647
|
+
constructor(t, e) {
|
|
4648
|
+
super(), this.ft = t, this.yt = e, this.type = "orderBy";
|
|
4649
4649
|
}
|
|
4650
4650
|
_apply(t) {
|
|
4651
|
-
const
|
|
4651
|
+
const e = function(t, e, n) {
|
|
4652
4652
|
if (null !== t.startAt) throw new U(A, "Invalid query. You must not call startAt() or startAfter() before calling orderBy().");
|
|
4653
4653
|
if (null !== t.endAt) throw new U(A, "Invalid query. You must not call endAt() or endBefore() before calling orderBy().");
|
|
4654
|
-
const r = new
|
|
4655
|
-
return function(t,
|
|
4656
|
-
if (null ===
|
|
4654
|
+
const r = new ne(e, n);
|
|
4655
|
+
return function(t, e) {
|
|
4656
|
+
if (null === ue(t)) {
|
|
4657
4657
|
// This is the first order by. It must match any inequality.
|
|
4658
|
-
const
|
|
4659
|
-
null !==
|
|
4658
|
+
const n = ce(t);
|
|
4659
|
+
null !== n && yr(t, n, e.field);
|
|
4660
4660
|
}
|
|
4661
4661
|
}(t, r), r;
|
|
4662
4662
|
}
|
|
@@ -4671,11 +4671,11 @@ class rr extends Xe {
|
|
|
4671
4671
|
* of the query or if any of the fields in the order by are an uncommitted
|
|
4672
4672
|
* server timestamp.
|
|
4673
4673
|
*/ (t._query, this.ft, this.yt);
|
|
4674
|
-
return new
|
|
4674
|
+
return new hn(t.firestore, t.converter, function(t, e) {
|
|
4675
4675
|
// TODO(dimond): validate that orderBy does not list the same key twice.
|
|
4676
|
-
const
|
|
4677
|
-
return new
|
|
4678
|
-
}(t._query,
|
|
4676
|
+
const n = t.explicitOrderBy.concat([ e ]);
|
|
4677
|
+
return new ie(t.path, t.collectionGroup, n, t.filters.slice(), t.limit, t.limitType, t.startAt, t.endAt);
|
|
4678
|
+
}(t._query, e));
|
|
4679
4679
|
}
|
|
4680
4680
|
}
|
|
4681
4681
|
|
|
@@ -4687,18 +4687,18 @@ class rr extends Xe {
|
|
|
4687
4687
|
* @param directionStr - Optional direction to sort by ('asc' or 'desc'). If
|
|
4688
4688
|
* not specified, order will be ascending.
|
|
4689
4689
|
* @returns The created {@link Query}.
|
|
4690
|
-
*/ function sr(t,
|
|
4691
|
-
const
|
|
4692
|
-
return new rr(r,
|
|
4690
|
+
*/ function sr(t, e = "asc") {
|
|
4691
|
+
const n = e, r = Zn("orderBy", t);
|
|
4692
|
+
return new rr(r, n);
|
|
4693
4693
|
}
|
|
4694
4694
|
|
|
4695
|
-
class ir extends
|
|
4696
|
-
constructor(t,
|
|
4697
|
-
super(), this.type = t, this._t =
|
|
4695
|
+
class ir extends Xn {
|
|
4696
|
+
constructor(t, e, n) {
|
|
4697
|
+
super(), this.type = t, this._t = e, this.gt = n;
|
|
4698
4698
|
}
|
|
4699
4699
|
_apply(t) {
|
|
4700
|
-
return new
|
|
4701
|
-
return new
|
|
4700
|
+
return new hn(t.firestore, t.converter, function(t, e, n) {
|
|
4701
|
+
return new ie(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), e, n, t.startAt, t.endAt);
|
|
4702
4702
|
}(t._query, this._t, this.gt));
|
|
4703
4703
|
}
|
|
4704
4704
|
}
|
|
@@ -4724,15 +4724,15 @@ class ir extends Xe {
|
|
|
4724
4724
|
return it("limitToLast", t), new ir("limitToLast", t, "L" /* Last */);
|
|
4725
4725
|
}
|
|
4726
4726
|
|
|
4727
|
-
class cr extends
|
|
4728
|
-
constructor(t,
|
|
4729
|
-
super(), this.type = t, this.
|
|
4727
|
+
class cr extends Xn {
|
|
4728
|
+
constructor(t, e, n) {
|
|
4729
|
+
super(), this.type = t, this.vt = e, this.bt = n;
|
|
4730
4730
|
}
|
|
4731
4731
|
_apply(t) {
|
|
4732
|
-
const
|
|
4733
|
-
return new
|
|
4734
|
-
return new
|
|
4735
|
-
}(t._query,
|
|
4732
|
+
const e = wr(t, this.type, this.vt, this.bt);
|
|
4733
|
+
return new hn(t.firestore, t.converter, function(t, e) {
|
|
4734
|
+
return new ie(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, e, t.endAt);
|
|
4735
|
+
}(t._query, e));
|
|
4736
4736
|
}
|
|
4737
4737
|
}
|
|
4738
4738
|
|
|
@@ -4745,15 +4745,15 @@ function hr(...t) {
|
|
|
4745
4745
|
/*before=*/ !1);
|
|
4746
4746
|
}
|
|
4747
4747
|
|
|
4748
|
-
class lr extends
|
|
4749
|
-
constructor(t,
|
|
4750
|
-
super(), this.type = t, this.
|
|
4748
|
+
class lr extends Xn {
|
|
4749
|
+
constructor(t, e, n) {
|
|
4750
|
+
super(), this.type = t, this.vt = e, this.bt = n;
|
|
4751
4751
|
}
|
|
4752
4752
|
_apply(t) {
|
|
4753
|
-
const
|
|
4754
|
-
return new
|
|
4755
|
-
return new
|
|
4756
|
-
}(t._query,
|
|
4753
|
+
const e = wr(t, this.type, this.vt, this.bt);
|
|
4754
|
+
return new hn(t.firestore, t.converter, function(t, e) {
|
|
4755
|
+
return new ie(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, t.startAt, e);
|
|
4756
|
+
}(t._query, e));
|
|
4757
4757
|
}
|
|
4758
4758
|
}
|
|
4759
4759
|
|
|
@@ -4765,9 +4765,9 @@ function dr(...t) {
|
|
|
4765
4765
|
return new lr("endAt", t, /*before=*/ !1);
|
|
4766
4766
|
}
|
|
4767
4767
|
|
|
4768
|
-
/** Helper function to create a bound from a document or fields */ function wr(t,
|
|
4769
|
-
if (
|
|
4770
|
-
if (!r) throw new U(R, `Can't use a DocumentSnapshot that doesn't exist for ${
|
|
4768
|
+
/** Helper function to create a bound from a document or fields */ function wr(t, e, n, r) {
|
|
4769
|
+
if (n[0] = h(n[0]), n[0] instanceof Hn) return function(t, e, n, r, s) {
|
|
4770
|
+
if (!r) throw new U(R, `Can't use a DocumentSnapshot that doesn't exist for ${n}().`);
|
|
4771
4771
|
const i = [];
|
|
4772
4772
|
// Because people expect to continue/end a query at the exact document
|
|
4773
4773
|
// provided, we need to use the implicit sort order rather than the explicit
|
|
@@ -4776,23 +4776,23 @@ function dr(...t) {
|
|
|
4776
4776
|
// the provided document. Without the key (by using the explicit sort
|
|
4777
4777
|
// orders), multiple documents could match the position, yielding duplicate
|
|
4778
4778
|
// results.
|
|
4779
|
-
for (const
|
|
4780
|
-
const t = r.data.field(
|
|
4781
|
-
if (Vt(t)) throw new U(A, 'Invalid query. You are trying to start or end a query using a document for which the field "' +
|
|
4779
|
+
for (const n of he(t)) if (n.field.isKeyField()) i.push(Ot(e, r.key)); else {
|
|
4780
|
+
const t = r.data.field(n.field);
|
|
4781
|
+
if (Vt(t)) throw new U(A, 'Invalid query. You are trying to start or end a query using a document for which the field "' + n.field + '" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');
|
|
4782
4782
|
if (null === t) {
|
|
4783
|
-
const t =
|
|
4783
|
+
const t = n.field.canonicalString();
|
|
4784
4784
|
throw new U(A, `Invalid query. You are trying to start or end a query using a document for which the field '${t}' (used as the orderBy) does not exist.`);
|
|
4785
4785
|
}
|
|
4786
4786
|
i.push(t);
|
|
4787
4787
|
}
|
|
4788
|
-
return new
|
|
4788
|
+
return new ee(i, s);
|
|
4789
4789
|
}
|
|
4790
4790
|
/**
|
|
4791
4791
|
* Converts a list of field values to a `Bound` for the given query.
|
|
4792
|
-
*/ (t._query, t.firestore._databaseId,
|
|
4792
|
+
*/ (t._query, t.firestore._databaseId, e, n[0]._document, r);
|
|
4793
4793
|
{
|
|
4794
|
-
const s =
|
|
4795
|
-
return function(t,
|
|
4794
|
+
const s = Vn(t.firestore);
|
|
4795
|
+
return function(t, e, n, r, s, i) {
|
|
4796
4796
|
// Use explicit order by's because it has to match the query the user made
|
|
4797
4797
|
const o = t.explicitOrderBy;
|
|
4798
4798
|
if (s.length > o.length) throw new U(A, `Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);
|
|
@@ -4801,48 +4801,48 @@ function dr(...t) {
|
|
|
4801
4801
|
const c = s[i];
|
|
4802
4802
|
if (o[i].field.isKeyField()) {
|
|
4803
4803
|
if ("string" != typeof c) throw new U(A, `Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);
|
|
4804
|
-
if (!
|
|
4805
|
-
const
|
|
4806
|
-
if (!X.isDocumentKey(
|
|
4807
|
-
const s = new X(
|
|
4808
|
-
u.push(Ot(
|
|
4804
|
+
if (!ae(t) && -1 !== c.indexOf("/")) throw new U(A, `Invalid query. When querying a collection and ordering by FieldPath.documentId(), the value passed to ${r}() must be a plain document ID, but '${c}' contains a slash.`);
|
|
4805
|
+
const n = t.path.child(K.fromString(c));
|
|
4806
|
+
if (!X.isDocumentKey(n)) throw new U(A, `Invalid query. When querying a collection group and ordering by FieldPath.documentId(), the value passed to ${r}() must result in a valid document path, but '${n}' is not because it contains an odd number of segments.`);
|
|
4807
|
+
const s = new X(n);
|
|
4808
|
+
u.push(Ot(e, s));
|
|
4809
4809
|
} else {
|
|
4810
|
-
const t =
|
|
4810
|
+
const t = Ln(n, r, c);
|
|
4811
4811
|
u.push(t);
|
|
4812
4812
|
}
|
|
4813
4813
|
}
|
|
4814
|
-
return new
|
|
4814
|
+
return new ee(u, i);
|
|
4815
4815
|
}
|
|
4816
4816
|
/**
|
|
4817
4817
|
* Parses the given `documentIdValue` into a `ReferenceValue`, throwing
|
|
4818
4818
|
* appropriate errors if the value is anything other than a `DocumentReference`
|
|
4819
4819
|
* or `string`, or if the string is malformed.
|
|
4820
|
-
*/ (t._query, t.firestore._databaseId, s,
|
|
4820
|
+
*/ (t._query, t.firestore._databaseId, s, e, n, r);
|
|
4821
4821
|
}
|
|
4822
4822
|
}
|
|
4823
4823
|
|
|
4824
|
-
function mr(t,
|
|
4825
|
-
if ("string" == typeof (
|
|
4826
|
-
if ("" ===
|
|
4827
|
-
if (!
|
|
4828
|
-
const r =
|
|
4824
|
+
function mr(t, e, n) {
|
|
4825
|
+
if ("string" == typeof (n = h(n))) {
|
|
4826
|
+
if ("" === n) throw new U(A, "Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.");
|
|
4827
|
+
if (!ae(e) && -1 !== n.indexOf("/")) throw new U(A, `Invalid query. When querying a collection by FieldPath.documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);
|
|
4828
|
+
const r = e.path.child(K.fromString(n));
|
|
4829
4829
|
if (!X.isDocumentKey(r)) throw new U(A, `Invalid query. When querying a collection group by FieldPath.documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);
|
|
4830
4830
|
return Ot(t, new X(r));
|
|
4831
4831
|
}
|
|
4832
|
-
if (
|
|
4833
|
-
throw new U(A, `Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: ${rt(
|
|
4832
|
+
if (n instanceof an) return Ot(t, n._key);
|
|
4833
|
+
throw new U(A, `Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: ${rt(n)}.`);
|
|
4834
4834
|
}
|
|
4835
4835
|
|
|
4836
4836
|
/**
|
|
4837
4837
|
* Validates that the value passed into a disjunctive filter satisfies all
|
|
4838
4838
|
* array requirements.
|
|
4839
|
-
*/ function pr(t,
|
|
4840
|
-
if (!Array.isArray(t) || 0 === t.length) throw new U(A, `Invalid Query. A non-empty array is required for '${
|
|
4841
|
-
if (t.length > 10) throw new U(A, `Invalid Query. '${
|
|
4839
|
+
*/ function pr(t, e) {
|
|
4840
|
+
if (!Array.isArray(t) || 0 === t.length) throw new U(A, `Invalid Query. A non-empty array is required for '${e.toString()}' filters.`);
|
|
4841
|
+
if (t.length > 10) throw new U(A, `Invalid Query. '${e.toString()}' filters support a maximum of 10 elements in the value array.`);
|
|
4842
4842
|
}
|
|
4843
4843
|
|
|
4844
|
-
function yr(t,
|
|
4845
|
-
if (!
|
|
4844
|
+
function yr(t, e, n) {
|
|
4845
|
+
if (!n.isEqual(e)) throw new U(A, `Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '${e.toString()}' and so you must also use '${e.toString()}' as your first argument to orderBy(), but your first orderBy() is on field '${n.toString()}' instead.`);
|
|
4846
4846
|
}
|
|
4847
4847
|
|
|
4848
4848
|
/**
|
|
@@ -4892,17 +4892,17 @@ function yr(t, n, e) {
|
|
|
4892
4892
|
* their `set()` or fails due to invalid data originating from a `toFirestore()`
|
|
4893
4893
|
* call.
|
|
4894
4894
|
*/
|
|
4895
|
-
function _r(t,
|
|
4895
|
+
function _r(t, e, n) {
|
|
4896
4896
|
let r;
|
|
4897
4897
|
// Cast to `any` in order to satisfy the union type constraint on
|
|
4898
4898
|
// toFirestore().
|
|
4899
4899
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4900
|
-
return r = t ?
|
|
4900
|
+
return r = t ? n && (n.merge || n.mergeFields) ? t.toFirestore(e, n) : t.toFirestore(e) : e,
|
|
4901
4901
|
r;
|
|
4902
4902
|
}
|
|
4903
4903
|
|
|
4904
4904
|
class gr extends class {
|
|
4905
|
-
convertValue(t,
|
|
4905
|
+
convertValue(t, e = "none") {
|
|
4906
4906
|
switch ($t(t)) {
|
|
4907
4907
|
case 0 /* NullValue */ :
|
|
4908
4908
|
return null;
|
|
@@ -4917,7 +4917,7 @@ class gr extends class {
|
|
|
4917
4917
|
return this.convertTimestamp(t.timestampValue);
|
|
4918
4918
|
|
|
4919
4919
|
case 4 /* ServerTimestampValue */ :
|
|
4920
|
-
return this.convertServerTimestamp(t,
|
|
4920
|
+
return this.convertServerTimestamp(t, e);
|
|
4921
4921
|
|
|
4922
4922
|
case 5 /* StringValue */ :
|
|
4923
4923
|
return t.stringValue;
|
|
@@ -4932,32 +4932,32 @@ class gr extends class {
|
|
|
4932
4932
|
return this.convertGeoPoint(t.geoPointValue);
|
|
4933
4933
|
|
|
4934
4934
|
case 9 /* ArrayValue */ :
|
|
4935
|
-
return this.convertArray(t.arrayValue,
|
|
4935
|
+
return this.convertArray(t.arrayValue, e);
|
|
4936
4936
|
|
|
4937
4937
|
case 10 /* ObjectValue */ :
|
|
4938
|
-
return this.convertObject(t.mapValue,
|
|
4938
|
+
return this.convertObject(t.mapValue, e);
|
|
4939
4939
|
|
|
4940
4940
|
default:
|
|
4941
4941
|
throw g();
|
|
4942
4942
|
}
|
|
4943
4943
|
}
|
|
4944
|
-
convertObject(t,
|
|
4945
|
-
const
|
|
4946
|
-
return
|
|
4947
|
-
|
|
4948
|
-
})),
|
|
4944
|
+
convertObject(t, e) {
|
|
4945
|
+
const n = {};
|
|
4946
|
+
return vt(t.fields, ((t, r) => {
|
|
4947
|
+
n[t] = this.convertValue(r, e);
|
|
4948
|
+
})), n;
|
|
4949
4949
|
}
|
|
4950
4950
|
convertGeoPoint(t) {
|
|
4951
|
-
return new
|
|
4951
|
+
return new bn(Pt(t.latitude), Pt(t.longitude));
|
|
4952
4952
|
}
|
|
4953
|
-
convertArray(t,
|
|
4954
|
-
return (t.values || []).map((t => this.convertValue(t,
|
|
4953
|
+
convertArray(t, e) {
|
|
4954
|
+
return (t.values || []).map((t => this.convertValue(t, e)));
|
|
4955
4955
|
}
|
|
4956
|
-
convertServerTimestamp(t,
|
|
4957
|
-
switch (
|
|
4956
|
+
convertServerTimestamp(t, e) {
|
|
4957
|
+
switch (e) {
|
|
4958
4958
|
case "previous":
|
|
4959
|
-
const
|
|
4960
|
-
return null ==
|
|
4959
|
+
const n = Nt(t);
|
|
4960
|
+
return null == n ? null : this.convertValue(n, e);
|
|
4961
4961
|
|
|
4962
4962
|
case "estimate":
|
|
4963
4963
|
return this.convertTimestamp(Dt(t));
|
|
@@ -4967,16 +4967,16 @@ class gr extends class {
|
|
|
4967
4967
|
}
|
|
4968
4968
|
}
|
|
4969
4969
|
convertTimestamp(t) {
|
|
4970
|
-
const
|
|
4971
|
-
return new yt(
|
|
4970
|
+
const e = At(t);
|
|
4971
|
+
return new yt(e.seconds, e.nanos);
|
|
4972
4972
|
}
|
|
4973
|
-
convertDocumentKey(t,
|
|
4974
|
-
const
|
|
4975
|
-
|
|
4976
|
-
const r = new H(
|
|
4977
|
-
return r.isEqual(
|
|
4973
|
+
convertDocumentKey(t, e) {
|
|
4974
|
+
const n = K.fromString(t);
|
|
4975
|
+
v(Ge(n));
|
|
4976
|
+
const r = new H(n.get(1), n.get(3)), s = new X(n.popFirst(5));
|
|
4977
|
+
return r.isEqual(e) ||
|
|
4978
4978
|
// TODO(b/64130202): Somehow support foreign references.
|
|
4979
|
-
p(`Document ${s} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${
|
|
4979
|
+
p(`Document ${s} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${e.projectId}/${e.database}) instead.`),
|
|
4980
4980
|
s;
|
|
4981
4981
|
}
|
|
4982
4982
|
} {
|
|
@@ -4984,11 +4984,11 @@ class gr extends class {
|
|
|
4984
4984
|
super(), this.firestore = t;
|
|
4985
4985
|
}
|
|
4986
4986
|
convertBytes(t) {
|
|
4987
|
-
return new
|
|
4987
|
+
return new gn(t);
|
|
4988
4988
|
}
|
|
4989
4989
|
convertReference(t) {
|
|
4990
|
-
const
|
|
4991
|
-
return new
|
|
4990
|
+
const e = this.convertDocumentKey(t, this.firestore._databaseId);
|
|
4991
|
+
return new an(this.firestore, /* converter= */ null, e);
|
|
4992
4992
|
}
|
|
4993
4993
|
}
|
|
4994
4994
|
|
|
@@ -5004,12 +5004,12 @@ class gr extends class {
|
|
|
5004
5004
|
* @param reference - The reference of the document to fetch.
|
|
5005
5005
|
* @returns A Promise resolved with a `DocumentSnapshot` containing the current
|
|
5006
5006
|
* document contents.
|
|
5007
|
-
*/ function
|
|
5008
|
-
const
|
|
5009
|
-
return
|
|
5010
|
-
|
|
5011
|
-
const r =
|
|
5012
|
-
return new
|
|
5007
|
+
*/ function vr(t) {
|
|
5008
|
+
const e = en((t = st(t, an)).firestore), n = new gr(t.firestore);
|
|
5009
|
+
return Ze(e, [ t._key ]).then((e => {
|
|
5010
|
+
v(1 === e.length);
|
|
5011
|
+
const r = e[0];
|
|
5012
|
+
return new Hn(t.firestore, n, t._key, r.isFoundDocument() ? r : null, t.converter);
|
|
5013
5013
|
}));
|
|
5014
5014
|
}
|
|
5015
5015
|
|
|
@@ -5024,33 +5024,33 @@ class gr extends class {
|
|
|
5024
5024
|
*
|
|
5025
5025
|
* @param query - The `Query` to execute.
|
|
5026
5026
|
* @returns A Promise that will be resolved with the results of the query.
|
|
5027
|
-
*/ function
|
|
5027
|
+
*/ function br(t) {
|
|
5028
5028
|
!function(t) {
|
|
5029
|
-
if (
|
|
5030
|
-
}((t = st(t,
|
|
5031
|
-
const
|
|
5032
|
-
return
|
|
5033
|
-
const r =
|
|
5034
|
-
return
|
|
5029
|
+
if (oe(t) && 0 === t.explicitOrderBy.length) throw new U(x, "limitToLast() queries require specifying at least one orderBy() clause");
|
|
5030
|
+
}((t = st(t, hn))._query);
|
|
5031
|
+
const e = en(t.firestore), n = new gr(t.firestore);
|
|
5032
|
+
return Xe(e, t._query).then((e => {
|
|
5033
|
+
const r = e.map((e => new Yn(t.firestore, n, e.key, e, t.converter)));
|
|
5034
|
+
return oe(t._query) &&
|
|
5035
5035
|
// Limit to last queries reverse the orderBy constraint that was
|
|
5036
5036
|
// specified by the user. As such, we need to reverse the order of the
|
|
5037
5037
|
// results to return the documents in the expected order.
|
|
5038
|
-
r.reverse(), new
|
|
5038
|
+
r.reverse(), new Kn(t, r);
|
|
5039
5039
|
}));
|
|
5040
5040
|
}
|
|
5041
5041
|
|
|
5042
|
-
function Er(t,
|
|
5043
|
-
const r = _r((t = st(t,
|
|
5044
|
-
return
|
|
5042
|
+
function Er(t, e, n) {
|
|
5043
|
+
const r = _r((t = st(t, an)).converter, e, n), s = Nn(Vn(t.firestore), "setDoc", t._key, r, null !== t.converter, n);
|
|
5044
|
+
return Je(en(t.firestore), [ s.toMutation(t._key, ve.none()) ]);
|
|
5045
5045
|
}
|
|
5046
5046
|
|
|
5047
|
-
function Ir(t,
|
|
5048
|
-
const s =
|
|
5047
|
+
function Ir(t, e, n, ...r) {
|
|
5048
|
+
const s = Vn((t = st(t, an)).firestore);
|
|
5049
5049
|
// For Compat types, we have to "extract" the underlying types before
|
|
5050
5050
|
// performing validation.
|
|
5051
5051
|
let i;
|
|
5052
|
-
i = "string" == typeof (
|
|
5053
|
-
return
|
|
5052
|
+
i = "string" == typeof (e = h(e)) || e instanceof yn ? Cn(s, "updateDoc", t._key, e, n, r) : On(s, "updateDoc", t._key, e);
|
|
5053
|
+
return Je(en(t.firestore), [ i.toMutation(t._key, ve.exists(!0)) ]);
|
|
5054
5054
|
}
|
|
5055
5055
|
|
|
5056
5056
|
/**
|
|
@@ -5065,7 +5065,7 @@ function Ir(t, n, e, ...r) {
|
|
|
5065
5065
|
* @returns A `Promise` resolved once the document has been successfully
|
|
5066
5066
|
* deleted from the backend.
|
|
5067
5067
|
*/ function Tr(t) {
|
|
5068
|
-
return
|
|
5068
|
+
return Je(en((t = st(t, an)).firestore), [ new Te(t._key, ve.none()) ]);
|
|
5069
5069
|
}
|
|
5070
5070
|
|
|
5071
5071
|
/**
|
|
@@ -5081,9 +5081,9 @@ function Ir(t, n, e, ...r) {
|
|
|
5081
5081
|
* @param data - An Object containing the data for the new document.
|
|
5082
5082
|
* @returns A `Promise` resolved with a `DocumentReference` pointing to the
|
|
5083
5083
|
* newly created document after it has been written to the backend.
|
|
5084
|
-
*/ function Ar(t,
|
|
5085
|
-
const
|
|
5086
|
-
return
|
|
5084
|
+
*/ function Ar(t, e) {
|
|
5085
|
+
const n = wn(t = st(t, ln)), r = _r(t.converter, e), s = Nn(Vn(t.firestore), "addDoc", n._key, r, null !== n.converter, {});
|
|
5086
|
+
return Je(en(t.firestore), [ s.toMutation(n._key, ve.exists(!1)) ]).then((() => n));
|
|
5087
5087
|
}
|
|
5088
5088
|
|
|
5089
5089
|
/**
|
|
@@ -5106,14 +5106,14 @@ function Ir(t, n, e, ...r) {
|
|
|
5106
5106
|
* Returns a sentinel for use with {@link @firebase/firestore/lite#(updateDoc:1)} or
|
|
5107
5107
|
* {@link @firebase/firestore/lite#(setDoc:1)} with `{merge: true}` to mark a field for deletion.
|
|
5108
5108
|
*/ function Pr() {
|
|
5109
|
-
return new
|
|
5109
|
+
return new Dn("deleteField");
|
|
5110
5110
|
}
|
|
5111
5111
|
|
|
5112
5112
|
/**
|
|
5113
5113
|
* Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
|
|
5114
5114
|
* include a server-generated timestamp in the written data.
|
|
5115
5115
|
*/ function Rr() {
|
|
5116
|
-
return new
|
|
5116
|
+
return new Fn("serverTimestamp");
|
|
5117
5117
|
}
|
|
5118
5118
|
|
|
5119
5119
|
/**
|
|
@@ -5130,7 +5130,7 @@ function Ir(t, n, e, ...r) {
|
|
|
5130
5130
|
*/ function Vr(...t) {
|
|
5131
5131
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5132
5132
|
// update() since we'd need the Firestore instance to do this.
|
|
5133
|
-
return new
|
|
5133
|
+
return new Sn("arrayUnion", t);
|
|
5134
5134
|
}
|
|
5135
5135
|
|
|
5136
5136
|
/**
|
|
@@ -5146,7 +5146,7 @@ function Ir(t, n, e, ...r) {
|
|
|
5146
5146
|
*/ function Nr(...t) {
|
|
5147
5147
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5148
5148
|
// update() since we'd need the Firestore instance to do this.
|
|
5149
|
-
return new
|
|
5149
|
+
return new qn("arrayRemove", t);
|
|
5150
5150
|
}
|
|
5151
5151
|
|
|
5152
5152
|
/**
|
|
@@ -5168,7 +5168,7 @@ function Ir(t, n, e, ...r) {
|
|
|
5168
5168
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5169
5169
|
* `updateDoc()`
|
|
5170
5170
|
*/ function Dr(t) {
|
|
5171
|
-
return new
|
|
5171
|
+
return new xn("increment", t);
|
|
5172
5172
|
}
|
|
5173
5173
|
|
|
5174
5174
|
/**
|
|
@@ -5196,23 +5196,23 @@ function Ir(t, n, e, ...r) {
|
|
|
5196
5196
|
* called.
|
|
5197
5197
|
*/ class $r {
|
|
5198
5198
|
/** @hideconstructor */
|
|
5199
|
-
constructor(t,
|
|
5200
|
-
this._firestore = t, this._commitHandler =
|
|
5201
|
-
this._dataReader =
|
|
5199
|
+
constructor(t, e) {
|
|
5200
|
+
this._firestore = t, this._commitHandler = e, this._mutations = [], this._committed = !1,
|
|
5201
|
+
this._dataReader = Vn(t);
|
|
5202
5202
|
}
|
|
5203
|
-
set(t,
|
|
5203
|
+
set(t, e, n) {
|
|
5204
5204
|
this._verifyNotCommitted();
|
|
5205
|
-
const r = Fr(t, this._firestore), s = _r(r.converter,
|
|
5206
|
-
return this._mutations.push(i.toMutation(r._key,
|
|
5205
|
+
const r = Fr(t, this._firestore), s = _r(r.converter, e, n), i = Nn(this._dataReader, "WriteBatch.set", r._key, s, null !== r.converter, n);
|
|
5206
|
+
return this._mutations.push(i.toMutation(r._key, ve.none())), this;
|
|
5207
5207
|
}
|
|
5208
|
-
update(t,
|
|
5208
|
+
update(t, e, n, ...r) {
|
|
5209
5209
|
this._verifyNotCommitted();
|
|
5210
5210
|
const s = Fr(t, this._firestore);
|
|
5211
5211
|
// For Compat types, we have to "extract" the underlying types before
|
|
5212
5212
|
// performing validation.
|
|
5213
5213
|
let i;
|
|
5214
|
-
return i = "string" == typeof (
|
|
5215
|
-
this._mutations.push(i.toMutation(s._key,
|
|
5214
|
+
return i = "string" == typeof (e = h(e)) || e instanceof yn ? Cn(this._dataReader, "WriteBatch.update", s._key, e, n, r) : On(this._dataReader, "WriteBatch.update", s._key, e),
|
|
5215
|
+
this._mutations.push(i.toMutation(s._key, ve.exists(!0))), this;
|
|
5216
5216
|
}
|
|
5217
5217
|
/**
|
|
5218
5218
|
* Deletes the document referred to by the provided {@link DocumentReference}.
|
|
@@ -5221,8 +5221,8 @@ function Ir(t, n, e, ...r) {
|
|
|
5221
5221
|
* @returns This `WriteBatch` instance. Used for chaining method calls.
|
|
5222
5222
|
*/ delete(t) {
|
|
5223
5223
|
this._verifyNotCommitted();
|
|
5224
|
-
const
|
|
5225
|
-
return this._mutations = this._mutations.concat(new
|
|
5224
|
+
const e = Fr(t, this._firestore);
|
|
5225
|
+
return this._mutations = this._mutations.concat(new Te(e._key, ve.none())), this;
|
|
5226
5226
|
}
|
|
5227
5227
|
/**
|
|
5228
5228
|
* Commits all of the writes in this write batch as a single atomic unit.
|
|
@@ -5243,8 +5243,8 @@ function Ir(t, n, e, ...r) {
|
|
|
5243
5243
|
}
|
|
5244
5244
|
}
|
|
5245
5245
|
|
|
5246
|
-
function Fr(t,
|
|
5247
|
-
if ((t = h(t)).firestore !==
|
|
5246
|
+
function Fr(t, e) {
|
|
5247
|
+
if ((t = h(t)).firestore !== e) throw new U(A, "Provided document reference is from a different Firestore instance.");
|
|
5248
5248
|
return t;
|
|
5249
5249
|
}
|
|
5250
5250
|
|
|
@@ -5261,8 +5261,8 @@ function Fr(t, n) {
|
|
|
5261
5261
|
* @returns A `WriteBatch` that can be used to atomically execute multiple
|
|
5262
5262
|
* writes.
|
|
5263
5263
|
*/ function Sr(t) {
|
|
5264
|
-
const
|
|
5265
|
-
return new $r(t, (t =>
|
|
5264
|
+
const e = en(t = st(t, rn));
|
|
5265
|
+
return new $r(t, (t => Je(e, t)));
|
|
5266
5266
|
}
|
|
5267
5267
|
|
|
5268
5268
|
/**
|
|
@@ -5304,66 +5304,66 @@ function Fr(t, n) {
|
|
|
5304
5304
|
}
|
|
5305
5305
|
async lookup(t) {
|
|
5306
5306
|
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new U(A, "Firestore transactions require all reads to be executed before all writes.");
|
|
5307
|
-
const
|
|
5308
|
-
return
|
|
5307
|
+
const e = await Ze(this.datastore, t);
|
|
5308
|
+
return e.forEach((t => this.recordVersion(t))), e;
|
|
5309
5309
|
}
|
|
5310
|
-
set(t,
|
|
5311
|
-
this.write(
|
|
5310
|
+
set(t, e) {
|
|
5311
|
+
this.write(e.toMutation(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5312
5312
|
}
|
|
5313
|
-
update(t,
|
|
5313
|
+
update(t, e) {
|
|
5314
5314
|
try {
|
|
5315
|
-
this.write(
|
|
5315
|
+
this.write(e.toMutation(t, this.preconditionForUpdate(t)));
|
|
5316
5316
|
} catch (t) {
|
|
5317
5317
|
this.lastWriteError = t;
|
|
5318
5318
|
}
|
|
5319
5319
|
this.writtenDocs.add(t.toString());
|
|
5320
5320
|
}
|
|
5321
5321
|
delete(t) {
|
|
5322
|
-
this.write(new
|
|
5322
|
+
this.write(new Te(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5323
5323
|
}
|
|
5324
5324
|
async commit() {
|
|
5325
5325
|
if (this.ensureCommitNotCalled(), this.lastWriteError) throw this.lastWriteError;
|
|
5326
5326
|
const t = this.readVersions;
|
|
5327
5327
|
// For each mutation, note that the doc was written.
|
|
5328
|
-
this.mutations.forEach((
|
|
5329
|
-
t.delete(
|
|
5328
|
+
this.mutations.forEach((e => {
|
|
5329
|
+
t.delete(e.key.toString());
|
|
5330
5330
|
})),
|
|
5331
5331
|
// For each document that was read but not written to, we want to perform
|
|
5332
5332
|
// a `verify` operation.
|
|
5333
|
-
t.forEach(((t,
|
|
5334
|
-
const
|
|
5335
|
-
this.mutations.push(new
|
|
5336
|
-
})), await
|
|
5333
|
+
t.forEach(((t, e) => {
|
|
5334
|
+
const n = X.fromPath(e);
|
|
5335
|
+
this.mutations.push(new Ae(n, this.precondition(n)));
|
|
5336
|
+
})), await Je(this.datastore, this.mutations), this.committed = !0;
|
|
5337
5337
|
}
|
|
5338
5338
|
recordVersion(t) {
|
|
5339
|
-
let
|
|
5340
|
-
if (t.isFoundDocument())
|
|
5339
|
+
let e;
|
|
5340
|
+
if (t.isFoundDocument()) e = t.version; else {
|
|
5341
5341
|
if (!t.isNoDocument()) throw g();
|
|
5342
5342
|
// For deleted docs, we must use baseVersion 0 when we overwrite them.
|
|
5343
|
-
|
|
5343
|
+
e = _t.min();
|
|
5344
5344
|
}
|
|
5345
|
-
const
|
|
5346
|
-
if (
|
|
5347
|
-
if (!
|
|
5345
|
+
const n = this.readVersions.get(t.key.toString());
|
|
5346
|
+
if (n) {
|
|
5347
|
+
if (!e.isEqual(n))
|
|
5348
5348
|
// This transaction will fail no matter what.
|
|
5349
5349
|
throw new U(S, "Document version changed between two reads.");
|
|
5350
|
-
} else this.readVersions.set(t.key.toString(),
|
|
5350
|
+
} else this.readVersions.set(t.key.toString(), e);
|
|
5351
5351
|
}
|
|
5352
5352
|
/**
|
|
5353
5353
|
* Returns the version of this document when it was read in this transaction,
|
|
5354
5354
|
* as a precondition, or no precondition if it was not read.
|
|
5355
5355
|
*/ precondition(t) {
|
|
5356
|
-
const
|
|
5357
|
-
return !this.writtenDocs.has(t.toString()) &&
|
|
5356
|
+
const e = this.readVersions.get(t.toString());
|
|
5357
|
+
return !this.writtenDocs.has(t.toString()) && e ? ve.updateTime(e) : ve.none();
|
|
5358
5358
|
}
|
|
5359
5359
|
/**
|
|
5360
5360
|
* Returns the precondition for a document if the operation is an update.
|
|
5361
5361
|
*/ preconditionForUpdate(t) {
|
|
5362
|
-
const
|
|
5362
|
+
const e = this.readVersions.get(t.toString());
|
|
5363
5363
|
// The first time a document is written, we want to take into account the
|
|
5364
5364
|
// read time and existence
|
|
5365
|
-
if (!this.writtenDocs.has(t.toString()) &&
|
|
5366
|
-
if (
|
|
5365
|
+
if (!this.writtenDocs.has(t.toString()) && e) {
|
|
5366
|
+
if (e.isEqual(_t.min()))
|
|
5367
5367
|
// The document doesn't exist, so fail the transaction.
|
|
5368
5368
|
// This has to be validated locally because you can't send a
|
|
5369
5369
|
// precondition that a document does not exist without changing the
|
|
@@ -5375,11 +5375,11 @@ function Fr(t, n) {
|
|
|
5375
5375
|
// transaction.
|
|
5376
5376
|
throw new U(A, "Can't update a document that doesn't exist.");
|
|
5377
5377
|
// Document exists, base precondition on document update time.
|
|
5378
|
-
return
|
|
5378
|
+
return ve.updateTime(e);
|
|
5379
5379
|
}
|
|
5380
5380
|
// Document was not read, so we just use the preconditions for a blind
|
|
5381
5381
|
// update.
|
|
5382
|
-
return
|
|
5382
|
+
return ve.exists(!0);
|
|
5383
5383
|
}
|
|
5384
5384
|
write(t) {
|
|
5385
5385
|
this.ensureCommitNotCalled(), this.mutations.push(t);
|
|
@@ -5408,19 +5408,19 @@ function Fr(t, n) {
|
|
|
5408
5408
|
* with backoff.
|
|
5409
5409
|
*/
|
|
5410
5410
|
class xr {
|
|
5411
|
-
constructor(t,
|
|
5412
|
-
this.asyncQueue = t, this.datastore =
|
|
5413
|
-
this.Et = 5, this.It = new
|
|
5411
|
+
constructor(t, e, n, r) {
|
|
5412
|
+
this.asyncQueue = t, this.datastore = e, this.updateFunction = n, this.deferred = r,
|
|
5413
|
+
this.Et = 5, this.It = new Ye(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
|
|
5414
5414
|
}
|
|
5415
5415
|
/** Runs the transaction and sets the result on deferred. */ run() {
|
|
5416
5416
|
this.Et -= 1, this.Tt();
|
|
5417
5417
|
}
|
|
5418
5418
|
Tt() {
|
|
5419
5419
|
this.It.W((async () => {
|
|
5420
|
-
const t = new qr(this.datastore),
|
|
5421
|
-
|
|
5420
|
+
const t = new qr(this.datastore), e = this.At(t);
|
|
5421
|
+
e && e.then((e => {
|
|
5422
5422
|
this.asyncQueue.enqueueAndForget((() => t.commit().then((() => {
|
|
5423
|
-
this.deferred.resolve(
|
|
5423
|
+
this.deferred.resolve(e);
|
|
5424
5424
|
})).catch((t => {
|
|
5425
5425
|
this.Pt(t);
|
|
5426
5426
|
}))));
|
|
@@ -5431,8 +5431,8 @@ class xr {
|
|
|
5431
5431
|
}
|
|
5432
5432
|
At(t) {
|
|
5433
5433
|
try {
|
|
5434
|
-
const
|
|
5435
|
-
return !ot(
|
|
5434
|
+
const e = this.updateFunction(t);
|
|
5435
|
+
return !ot(e) && e.catch && e.then ? e : (this.deferred.reject(Error("Transaction callback must return a Promise")),
|
|
5436
5436
|
null);
|
|
5437
5437
|
} catch (t) {
|
|
5438
5438
|
// Do not retry errors thrown by user provided updateFunction.
|
|
@@ -5447,8 +5447,8 @@ class xr {
|
|
|
5447
5447
|
if ("FirebaseError" === t.name) {
|
|
5448
5448
|
// In transactions, the backend will fail outdated reads with FAILED_PRECONDITION and
|
|
5449
5449
|
// non-matching document versions with ABORTED. These errors should be retried.
|
|
5450
|
-
const
|
|
5451
|
-
return "aborted" ===
|
|
5450
|
+
const e = t.code;
|
|
5451
|
+
return "aborted" === e || "failed-precondition" === e || !
|
|
5452
5452
|
/**
|
|
5453
5453
|
* Determines whether an error code represents a permanent error when received
|
|
5454
5454
|
* in response to a non-write operation.
|
|
@@ -5485,7 +5485,7 @@ class xr {
|
|
|
5485
5485
|
case L:
|
|
5486
5486
|
return !0;
|
|
5487
5487
|
}
|
|
5488
|
-
}(
|
|
5488
|
+
}(e);
|
|
5489
5489
|
}
|
|
5490
5490
|
return !1;
|
|
5491
5491
|
}
|
|
@@ -5540,8 +5540,8 @@ class xr {
|
|
|
5540
5540
|
* in newer versions of TypeScript defines `finally`, which is not available in
|
|
5541
5541
|
* IE.
|
|
5542
5542
|
*/ class Cr {
|
|
5543
|
-
constructor(t,
|
|
5544
|
-
this.asyncQueue = t, this.timerId =
|
|
5543
|
+
constructor(t, e, n, r, s) {
|
|
5544
|
+
this.asyncQueue = t, this.timerId = e, this.targetTimeMs = n, this.op = r, this.removalCallback = s,
|
|
5545
5545
|
this.deferred = new j, this.then = this.deferred.promise.then.bind(this.deferred.promise),
|
|
5546
5546
|
// It's normal for the deferred promise to be canceled (due to cancellation)
|
|
5547
5547
|
// and so we attach a dummy catch callback to avoid
|
|
@@ -5561,9 +5561,9 @@ class xr {
|
|
|
5561
5561
|
* from its delayedOperations list.
|
|
5562
5562
|
* PORTING NOTE: This exists to prevent making removeDelayedOperation() and
|
|
5563
5563
|
* the DelayedOperation class public.
|
|
5564
|
-
*/ static createAndSchedule(t,
|
|
5565
|
-
const i = Date.now() +
|
|
5566
|
-
return o.start(
|
|
5564
|
+
*/ static createAndSchedule(t, e, n, r, s) {
|
|
5565
|
+
const i = Date.now() + n, o = new Cr(t, e, i, r, s);
|
|
5566
|
+
return o.start(n), o;
|
|
5567
5567
|
}
|
|
5568
5568
|
/**
|
|
5569
5569
|
* Starts the timer. This is called immediately after construction by
|
|
@@ -5634,7 +5634,7 @@ class xr {
|
|
|
5634
5634
|
// List of TimerIds to fast-forward delays for.
|
|
5635
5635
|
this.xt = [],
|
|
5636
5636
|
// Backoff timer used to schedule retries for retryable operations
|
|
5637
|
-
this.It = new
|
|
5637
|
+
this.It = new Ye(this, "async_queue_retry" /* AsyncQueueRetry */),
|
|
5638
5638
|
// Visibility handler that triggers an immediate retry of all retryable
|
|
5639
5639
|
// operations. Meant to speed up recovery when we regain file system access
|
|
5640
5640
|
// after page comes into foreground.
|
|
@@ -5663,8 +5663,8 @@ class xr {
|
|
|
5663
5663
|
enterRestrictedMode(t) {
|
|
5664
5664
|
if (!this.Dt) {
|
|
5665
5665
|
this.Dt = !0, this.qt = t || !1;
|
|
5666
|
-
const
|
|
5667
|
-
|
|
5666
|
+
const e = Or();
|
|
5667
|
+
e && "function" == typeof e.removeEventListener && e.removeEventListener("visibilitychange", this.Ot);
|
|
5668
5668
|
}
|
|
5669
5669
|
}
|
|
5670
5670
|
enqueue(t) {
|
|
@@ -5674,9 +5674,9 @@ class xr {
|
|
|
5674
5674
|
// Create a deferred Promise that we can return to the callee. This
|
|
5675
5675
|
// allows us to return a "hanging Promise" only to the callee and still
|
|
5676
5676
|
// advance the queue even when the operation is not run.
|
|
5677
|
-
const
|
|
5678
|
-
return this.Lt((() => this.Dt && this.qt ? Promise.resolve() : (t().then(
|
|
5679
|
-
|
|
5677
|
+
const e = new j;
|
|
5678
|
+
return this.Lt((() => this.Dt && this.qt ? Promise.resolve() : (t().then(e.resolve, e.reject),
|
|
5679
|
+
e.promise))).then((() => e.promise));
|
|
5680
5680
|
}
|
|
5681
5681
|
enqueueRetryable(t) {
|
|
5682
5682
|
this.enqueueAndForget((() => (this.Nt.push(t), this.Ut())));
|
|
@@ -5746,18 +5746,18 @@ class xr {
|
|
|
5746
5746
|
}
|
|
5747
5747
|
}
|
|
5748
5748
|
Lt(t) {
|
|
5749
|
-
const
|
|
5749
|
+
const e = this.Vt.then((() => (this.St = !0, t().catch((t => {
|
|
5750
5750
|
this.Ft = t, this.St = !1;
|
|
5751
|
-
const
|
|
5751
|
+
const e =
|
|
5752
5752
|
/**
|
|
5753
5753
|
* Chrome includes Error.message in Error.stack. Other browsers do not.
|
|
5754
5754
|
* This returns expected output of message + stack when available.
|
|
5755
5755
|
* @param error - Error or FirestoreError
|
|
5756
5756
|
*/
|
|
5757
5757
|
function(t) {
|
|
5758
|
-
let
|
|
5759
|
-
t.stack && (
|
|
5760
|
-
return
|
|
5758
|
+
let e = t.message || "";
|
|
5759
|
+
t.stack && (e = t.stack.includes(t.message) ? t.stack : t.message + "\n" + t.stack);
|
|
5760
|
+
return e;
|
|
5761
5761
|
}
|
|
5762
5762
|
/**
|
|
5763
5763
|
* @license
|
|
@@ -5787,15 +5787,15 @@ class xr {
|
|
|
5787
5787
|
// Re-throw the error so that this.tail becomes a rejected Promise and
|
|
5788
5788
|
// all further attempts to chain (via .then) will just short-circuit
|
|
5789
5789
|
// and return the rejected Promise.
|
|
5790
|
-
throw p("INTERNAL UNHANDLED ERROR: ",
|
|
5790
|
+
throw p("INTERNAL UNHANDLED ERROR: ", e), t;
|
|
5791
5791
|
})).then((t => (this.St = !1, t))))));
|
|
5792
|
-
return this.Vt =
|
|
5792
|
+
return this.Vt = e, e;
|
|
5793
5793
|
}
|
|
5794
|
-
enqueueAfterDelay(t,
|
|
5794
|
+
enqueueAfterDelay(t, e, n) {
|
|
5795
5795
|
this.Ct(),
|
|
5796
5796
|
// Fast-forward delays for timerIds that have been overriden.
|
|
5797
|
-
this.xt.indexOf(t) > -1 && (
|
|
5798
|
-
const r = Cr.createAndSchedule(this, t,
|
|
5797
|
+
this.xt.indexOf(t) > -1 && (e = 0);
|
|
5798
|
+
const r = Cr.createAndSchedule(this, t, e, n, (t => this.jt(t)));
|
|
5799
5799
|
return this.$t.push(r), r;
|
|
5800
5800
|
}
|
|
5801
5801
|
Ct() {
|
|
@@ -5819,7 +5819,7 @@ class xr {
|
|
|
5819
5819
|
* For Tests: Determine if a delayed operation with a particular TimerId
|
|
5820
5820
|
* exists.
|
|
5821
5821
|
*/ Mt(t) {
|
|
5822
|
-
for (const
|
|
5822
|
+
for (const e of this.$t) if (e.timerId === t) return !0;
|
|
5823
5823
|
return !1;
|
|
5824
5824
|
}
|
|
5825
5825
|
/**
|
|
@@ -5832,8 +5832,8 @@ class xr {
|
|
|
5832
5832
|
// Note that draining may generate more delayed ops, so we do that first.
|
|
5833
5833
|
return this.kt().then((() => {
|
|
5834
5834
|
// Run ops in the same order they'd run if they ran naturally.
|
|
5835
|
-
this.$t.sort(((t,
|
|
5836
|
-
for (const
|
|
5835
|
+
this.$t.sort(((t, e) => t.targetTimeMs - e.targetTimeMs));
|
|
5836
|
+
for (const e of this.$t) if (e.skipDelay(), "all" /* All */ !== t && e.timerId === t) break;
|
|
5837
5837
|
return this.kt();
|
|
5838
5838
|
}));
|
|
5839
5839
|
}
|
|
@@ -5844,15 +5844,15 @@ class xr {
|
|
|
5844
5844
|
}
|
|
5845
5845
|
/** Called once a DelayedOperation is run or canceled. */ jt(t) {
|
|
5846
5846
|
// NOTE: indexOf / slice are O(n), but delayedOperations is expected to be small.
|
|
5847
|
-
const
|
|
5848
|
-
this.$t.splice(
|
|
5847
|
+
const e = this.$t.indexOf(t);
|
|
5848
|
+
this.$t.splice(e, 1);
|
|
5849
5849
|
}
|
|
5850
5850
|
}
|
|
5851
5851
|
|
|
5852
5852
|
class Ur {
|
|
5853
5853
|
/** @hideconstructor */
|
|
5854
|
-
constructor(t,
|
|
5855
|
-
this._firestore = t, this._transaction =
|
|
5854
|
+
constructor(t, e) {
|
|
5855
|
+
this._firestore = t, this._transaction = e, this._dataReader = Vn(t);
|
|
5856
5856
|
}
|
|
5857
5857
|
/**
|
|
5858
5858
|
* Reads the document referenced by the provided {@link DocumentReference}.
|
|
@@ -5860,25 +5860,25 @@ class Ur {
|
|
|
5860
5860
|
* @param documentRef - A reference to the document to be read.
|
|
5861
5861
|
* @returns A `DocumentSnapshot` with the read data.
|
|
5862
5862
|
*/ get(t) {
|
|
5863
|
-
const
|
|
5864
|
-
return this._transaction.lookup([
|
|
5863
|
+
const e = Fr(t, this._firestore), n = new gr(this._firestore);
|
|
5864
|
+
return this._transaction.lookup([ e._key ]).then((t => {
|
|
5865
5865
|
if (!t || 1 !== t.length) return g();
|
|
5866
5866
|
const r = t[0];
|
|
5867
|
-
if (r.isFoundDocument()) return new
|
|
5868
|
-
if (r.isNoDocument()) return new
|
|
5867
|
+
if (r.isFoundDocument()) return new Hn(this._firestore, n, r.key, r, e.converter);
|
|
5868
|
+
if (r.isNoDocument()) return new Hn(this._firestore, n, e._key, null, e.converter);
|
|
5869
5869
|
throw g();
|
|
5870
5870
|
}));
|
|
5871
5871
|
}
|
|
5872
|
-
set(t,
|
|
5873
|
-
const r = Fr(t, this._firestore), s = _r(r.converter,
|
|
5872
|
+
set(t, e, n) {
|
|
5873
|
+
const r = Fr(t, this._firestore), s = _r(r.converter, e, n), i = Nn(this._dataReader, "Transaction.set", r._key, s, null !== r.converter, n);
|
|
5874
5874
|
return this._transaction.set(r._key, i), this;
|
|
5875
5875
|
}
|
|
5876
|
-
update(t,
|
|
5876
|
+
update(t, e, n, ...r) {
|
|
5877
5877
|
const s = Fr(t, this._firestore);
|
|
5878
5878
|
// For Compat types, we have to "extract" the underlying types before
|
|
5879
5879
|
// performing validation.
|
|
5880
5880
|
let i;
|
|
5881
|
-
return i = "string" == typeof (
|
|
5881
|
+
return i = "string" == typeof (e = h(e)) || e instanceof yn ? Cn(this._dataReader, "Transaction.update", s._key, e, n, r) : On(this._dataReader, "Transaction.update", s._key, e),
|
|
5882
5882
|
this._transaction.update(s._key, i), this;
|
|
5883
5883
|
}
|
|
5884
5884
|
/**
|
|
@@ -5887,8 +5887,8 @@ class Ur {
|
|
|
5887
5887
|
* @param documentRef - A reference to the document to be deleted.
|
|
5888
5888
|
* @returns This `Transaction` instance. Used for chaining method calls.
|
|
5889
5889
|
*/ delete(t) {
|
|
5890
|
-
const
|
|
5891
|
-
return this._transaction.delete(
|
|
5890
|
+
const e = Fr(t, this._firestore);
|
|
5891
|
+
return this._transaction.delete(e._key), this;
|
|
5892
5892
|
}
|
|
5893
5893
|
}
|
|
5894
5894
|
|
|
@@ -5908,9 +5908,9 @@ class Ur {
|
|
|
5908
5908
|
* (the `updateFunction` returned a failed promise), the promise returned by the
|
|
5909
5909
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
5910
5910
|
* rejected promise with the corresponding failure error is returned.
|
|
5911
|
-
*/ function jr(t,
|
|
5912
|
-
const
|
|
5913
|
-
return new xr(new Lr,
|
|
5911
|
+
*/ function jr(t, e) {
|
|
5912
|
+
const n = en(t = st(t, rn)), r = new j;
|
|
5913
|
+
return new xr(new Lr, n, (n => e(new Ur(t, n))), r).run(), r.promise;
|
|
5914
5914
|
}
|
|
5915
5915
|
|
|
5916
5916
|
/**
|
|
@@ -5922,12 +5922,12 @@ class Ur {
|
|
|
5922
5922
|
* @packageDocumentation
|
|
5923
5923
|
*/ !function(t) {
|
|
5924
5924
|
f = t;
|
|
5925
|
-
}(`${s}_lite`),
|
|
5926
|
-
const
|
|
5927
|
-
return
|
|
5925
|
+
}(`${s}_lite`), n(new i("firestore/lite", ((t, {options: e}) => {
|
|
5926
|
+
const n = t.getProvider("app").getImmediate(), r = new rn(n, new Q(t.getProvider("auth-internal")));
|
|
5927
|
+
return e && r._setSettings(e), r;
|
|
5928
5928
|
}), "PUBLIC" /* PUBLIC */)),
|
|
5929
5929
|
// RUNTIME_ENV and BUILD_TARGET are replaced by real values during the compilation
|
|
5930
|
-
r("firestore-lite", "3.3.0-canary.
|
|
5930
|
+
r("firestore-lite", "3.3.0-canary.e34e98e73", "rn"), r("firestore-lite", "3.3.0-canary.e34e98e73", "esm2017");
|
|
5931
5931
|
|
|
5932
|
-
export {
|
|
5932
|
+
export { gn as Bytes, ln as CollectionReference, an as DocumentReference, Hn as DocumentSnapshot, yn as FieldPath, vn as FieldValue, rn as Firestore, U as FirestoreError, bn as GeoPoint, hn as Query, Xn as QueryConstraint, Yn as QueryDocumentSnapshot, Kn as QuerySnapshot, yt as Timestamp, Ur as Transaction, $r as WriteBatch, Ar as addDoc, Nr as arrayRemove, Vr as arrayUnion, fn as collection, dn as collectionGroup, un as connectFirestoreEmulator, Tr as deleteDoc, Pr as deleteField, wn as doc, _n as documentId, dr as endAt, fr as endBefore, vr as getDoc, br as getDocs, on as getFirestore, Dr as increment, sn as initializeFirestore, or as limit, ur as limitToLast, sr as orderBy, tr as query, pn as queryEqual, mn as refEqual, jr as runTransaction, Rr as serverTimestamp, Er as setDoc, w as setLogLevel, Jn as snapshotEqual, hr as startAfter, ar as startAt, cn as terminate, Ir as updateDoc, nr as where, Sr as writeBatch };
|
|
5933
5933
|
//# sourceMappingURL=index.rn.esm2017.js.map
|