@firebase/firestore 3.1.0-2021822203916 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -6
- package/dist/firestore/src/util/input_validation.d.ts +1 -1
- package/dist/index.esm2017.js +4 -7
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +4 -8
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.esm2017.js +4 -8
- package/dist/index.node.cjs.esm2017.js.map +1 -1
- package/dist/index.node.cjs.js +4 -8
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.rn.js +4 -7
- package/dist/index.rn.js.map +1 -1
- package/dist/lite/firestore/src/util/input_validation.d.ts +1 -1
- package/dist/lite/index.browser.esm2017.js +1085 -1088
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +12 -16
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.node.cjs.js +4 -8
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.esm2017.js +4 -8
- package/dist/lite/index.node.esm2017.js.map +1 -1
- package/dist/lite/index.rn.esm2017.js +4 -7
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +109 -109
- package/dist/lite/packages/firestore/src/util/input_validation.d.ts +1 -1
- package/dist/packages/firestore/src/util/input_validation.d.ts +1 -1
- 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 @@ h.MOCK_USER = new h("mock-user");
|
|
|
66
66
|
* See the License for the specific language governing permissions and
|
|
67
67
|
* limitations under the License.
|
|
68
68
|
*/
|
|
69
|
-
let l = "9.1.0
|
|
69
|
+
let l = "9.1.0";
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* @license
|
|
@@ -102,26 +102,26 @@ const f = new o("@firebase/firestore");
|
|
|
102
102
|
f.setLogLevel(t);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
function w(t, ...
|
|
105
|
+
function w(t, ...e) {
|
|
106
106
|
if (f.logLevel <= u.DEBUG) {
|
|
107
|
-
const
|
|
108
|
-
f.debug(`Firestore (${l}): ${t}`, ...
|
|
107
|
+
const n = e.map(y);
|
|
108
|
+
f.debug(`Firestore (${l}): ${t}`, ...n);
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
function m(t, ...
|
|
112
|
+
function m(t, ...e) {
|
|
113
113
|
if (f.logLevel <= u.ERROR) {
|
|
114
|
-
const
|
|
115
|
-
f.error(`Firestore (${l}): ${t}`, ...
|
|
114
|
+
const n = e.map(y);
|
|
115
|
+
f.error(`Firestore (${l}): ${t}`, ...n);
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
120
|
* @internal
|
|
121
|
-
*/ function p(t, ...
|
|
121
|
+
*/ function p(t, ...e) {
|
|
122
122
|
if (f.logLevel <= u.WARN) {
|
|
123
|
-
const
|
|
124
|
-
f.warn(`Firestore (${l}): ${t}`, ...
|
|
123
|
+
const n = e.map(y);
|
|
124
|
+
f.warn(`Firestore (${l}): ${t}`, ...n);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|
|
@@ -130,8 +130,8 @@ function m(t, ...n) {
|
|
|
130
130
|
*/ function y(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 m(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 m(t, ...n) {
|
|
|
181
181
|
*/ function _(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 (${l}) 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 m(
|
|
188
|
+
throw m(e), new Error(e);
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
/**
|
|
@@ -193,7 +193,7 @@ function m(t, ...n) {
|
|
|
193
193
|
* given message if it did.
|
|
194
194
|
*
|
|
195
195
|
* Messages are stripped in production builds.
|
|
196
|
-
*/ function g(t,
|
|
196
|
+
*/ function g(t, e) {
|
|
197
197
|
t || _();
|
|
198
198
|
}
|
|
199
199
|
|
|
@@ -202,7 +202,7 @@ function m(t, ...n) {
|
|
|
202
202
|
* instance of `T` before casting.
|
|
203
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 U {
|
|
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 j {
|
|
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(h.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;
|
|
@@ -343,7 +343,7 @@ n) {
|
|
|
343
343
|
new j(t.accessToken, new h(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 Q {
|
|
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 = h.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 z {
|
|
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 Q(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(h.FIRST_PARTY)));
|
|
384
384
|
}
|
|
385
385
|
shutdown() {}
|
|
386
386
|
invalidateToken() {}
|
|
@@ -424,8 +424,8 @@ class W {
|
|
|
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 W {
|
|
|
436
436
|
* @internal
|
|
437
437
|
*/
|
|
438
438
|
class G {
|
|
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 G {
|
|
|
467
467
|
* Path represents an ordered sequence of string segments.
|
|
468
468
|
*/
|
|
469
469
|
class H {
|
|
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 && _(), void 0 === n ? n = t.length - e : n > t.length - e && _(),
|
|
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 H {
|
|
|
478
478
|
return 0 === H.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 H ? 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 H {
|
|
|
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 H {
|
|
|
537
537
|
*
|
|
538
538
|
* @internal
|
|
539
539
|
*/ class Y extends H {
|
|
540
|
-
construct(t,
|
|
541
|
-
return new Y(t,
|
|
540
|
+
construct(t, e, n) {
|
|
541
|
+
return new Y(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 H {
|
|
|
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 L(T, `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 Y(
|
|
566
|
+
return new Y(e);
|
|
567
567
|
}
|
|
568
568
|
static emptyPath() {
|
|
569
569
|
return new Y([]);
|
|
@@ -576,8 +576,8 @@ const K = /^[_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 J extends H {
|
|
579
|
-
construct(t,
|
|
580
|
-
return new J(t,
|
|
579
|
+
construct(t, e, n) {
|
|
580
|
+
return new J(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 K = /^[_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 L(T, `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 L(T, "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 L(T, "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 L(T, "Unterminated ` in path: " + t);
|
|
632
|
-
return new J(
|
|
632
|
+
return new J(e);
|
|
633
633
|
}
|
|
634
634
|
static emptyPath() {
|
|
635
635
|
return new J([]);
|
|
@@ -673,8 +673,8 @@ const K = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
673
673
|
toString() {
|
|
674
674
|
return this.path.toString();
|
|
675
675
|
}
|
|
676
|
-
static comparator(t,
|
|
677
|
-
return Y.comparator(t.path,
|
|
676
|
+
static comparator(t, e) {
|
|
677
|
+
return Y.comparator(t.path, e.path);
|
|
678
678
|
}
|
|
679
679
|
static isDocumentKey(t) {
|
|
680
680
|
return t.length % 2 == 0;
|
|
@@ -704,8 +704,8 @@ const K = /^[_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 X(t,
|
|
708
|
-
if (!
|
|
707
|
+
*/ function X(t, e, n) {
|
|
708
|
+
if (!n) throw new L(T, `Function ${t}() cannot be called with an empty ${e}.`);
|
|
709
709
|
}
|
|
710
710
|
|
|
711
711
|
/**
|
|
@@ -723,7 +723,7 @@ function tt(t) {
|
|
|
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 et(t) {
|
|
727
727
|
if (Z.isDocumentKey(t)) throw new L(T, `Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`);
|
|
728
728
|
}
|
|
729
729
|
|
|
@@ -732,7 +732,7 @@ function tt(t) {
|
|
|
732
732
|
* (i.e. excludes Array, Date, etc.).
|
|
733
733
|
*/
|
|
734
734
|
/** Returns a string describing the type / value of the provided input. */
|
|
735
|
-
function
|
|
735
|
+
function nt(t) {
|
|
736
736
|
if (void 0 === t) return "undefined";
|
|
737
737
|
if (null === t) return "null";
|
|
738
738
|
if ("string" == typeof t) return t.length > 20 && (t = `${t.substring(0, 20)}...`),
|
|
@@ -741,13 +741,10 @@ function et(t) {
|
|
|
741
741
|
if ("object" == typeof t) {
|
|
742
742
|
if (t instanceof Array) return "an array";
|
|
743
743
|
{
|
|
744
|
-
const
|
|
745
|
-
/**
|
|
744
|
+
const e =
|
|
745
|
+
/** try to get the constructor name for an object. */
|
|
746
746
|
function(t) {
|
|
747
|
-
if (t.constructor)
|
|
748
|
-
const n = /function\s+([^\s(]+)\s*\(/.exec(t.constructor.toString());
|
|
749
|
-
if (n && n.length > 1) return n[1];
|
|
750
|
-
}
|
|
747
|
+
if (t.constructor) return t.constructor.name;
|
|
751
748
|
return null;
|
|
752
749
|
}
|
|
753
750
|
/**
|
|
@@ -758,7 +755,7 @@ function et(t) {
|
|
|
758
755
|
* arguments passed to the public API.
|
|
759
756
|
* @internal
|
|
760
757
|
*/ (t);
|
|
761
|
-
return
|
|
758
|
+
return e ? `a custom ${e} object` : "an object";
|
|
762
759
|
}
|
|
763
760
|
}
|
|
764
761
|
return "function" == typeof t ? "a function" : _();
|
|
@@ -766,22 +763,22 @@ function et(t) {
|
|
|
766
763
|
|
|
767
764
|
function rt(t,
|
|
768
765
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
769
|
-
|
|
766
|
+
e) {
|
|
770
767
|
if ("_delegate" in t && (
|
|
771
768
|
// Unwrap Compat types
|
|
772
769
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
773
|
-
t = t._delegate), !(t instanceof
|
|
774
|
-
if (
|
|
770
|
+
t = t._delegate), !(t instanceof e)) {
|
|
771
|
+
if (e.name === t.constructor.name) throw new L(T, "Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");
|
|
775
772
|
{
|
|
776
|
-
const
|
|
777
|
-
throw new L(T, `Expected type '${
|
|
773
|
+
const n = nt(t);
|
|
774
|
+
throw new L(T, `Expected type '${e.name}', but it was: ${n}`);
|
|
778
775
|
}
|
|
779
776
|
}
|
|
780
777
|
return t;
|
|
781
778
|
}
|
|
782
779
|
|
|
783
|
-
function st(t,
|
|
784
|
-
if (
|
|
780
|
+
function st(t, e) {
|
|
781
|
+
if (e <= 0) throw new L(T, `Function ${t}() requires a positive number, but it was: ${e}.`);
|
|
785
782
|
}
|
|
786
783
|
|
|
787
784
|
/**
|
|
@@ -988,58 +985,58 @@ class lt extends
|
|
|
988
985
|
class {
|
|
989
986
|
constructor(t) {
|
|
990
987
|
this.databaseInfo = t, this.databaseId = t.databaseId;
|
|
991
|
-
const
|
|
992
|
-
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";
|
|
993
990
|
}
|
|
994
|
-
l(t,
|
|
995
|
-
const s = this.m(t,
|
|
996
|
-
w("RestConnection", "Sending: ", s,
|
|
991
|
+
l(t, e, n, r) {
|
|
992
|
+
const s = this.m(t, e);
|
|
993
|
+
w("RestConnection", "Sending: ", s, n);
|
|
997
994
|
const i = {};
|
|
998
|
-
return this.p(i, r), this.g(t, s, i,
|
|
999
|
-
t)), (
|
|
1000
|
-
throw p("RestConnection", `${t} failed with error: `,
|
|
1001
|
-
|
|
995
|
+
return this.p(i, r), this.g(t, s, i, n).then((t => (w("RestConnection", "Received: ", t),
|
|
996
|
+
t)), (e => {
|
|
997
|
+
throw p("RestConnection", `${t} failed with error: `, e, "url: ", s, "request:", n),
|
|
998
|
+
e;
|
|
1002
999
|
}));
|
|
1003
1000
|
}
|
|
1004
|
-
v(t,
|
|
1001
|
+
v(t, e, n, r) {
|
|
1005
1002
|
// The REST API automatically aggregates all of the streamed results, so we
|
|
1006
1003
|
// can just use the normal invoke() method.
|
|
1007
|
-
return this.l(t,
|
|
1004
|
+
return this.l(t, e, n, r);
|
|
1008
1005
|
}
|
|
1009
1006
|
/**
|
|
1010
1007
|
* Modifies the headers for a request, adding any authorization token if
|
|
1011
1008
|
* present and any additional headers for the request.
|
|
1012
|
-
*/ p(t,
|
|
1009
|
+
*/ p(t, e) {
|
|
1013
1010
|
if (t["X-Goog-Api-Client"] = "gl-js/ fire/" + l,
|
|
1014
1011
|
// Content-Type: text/plain will avoid preflight requests which might
|
|
1015
1012
|
// mess with CORS and redirects by proxies. If we add custom headers
|
|
1016
1013
|
// we will need to change this code to potentially use the $httpOverwrite
|
|
1017
1014
|
// parameter supported by ESF to avoid triggering preflight requests.
|
|
1018
1015
|
t["Content-Type"] = "text/plain", this.databaseInfo.appId && (t["X-Firebase-GMPID"] = this.databaseInfo.appId),
|
|
1019
|
-
|
|
1016
|
+
e) for (const n in e.authHeaders) e.authHeaders.hasOwnProperty(n) && (t[n] = e.authHeaders[n]);
|
|
1020
1017
|
}
|
|
1021
|
-
m(t,
|
|
1022
|
-
const
|
|
1023
|
-
return `${this.u}/v1/${
|
|
1018
|
+
m(t, e) {
|
|
1019
|
+
const n = ut[t];
|
|
1020
|
+
return `${this.u}/v1/${e}:${n}`;
|
|
1024
1021
|
}
|
|
1025
1022
|
} {
|
|
1026
1023
|
/**
|
|
1027
1024
|
* @param databaseInfo - The connection info.
|
|
1028
1025
|
* @param fetchImpl - `fetch` or a Polyfill that implements the fetch API.
|
|
1029
1026
|
*/
|
|
1030
|
-
constructor(t,
|
|
1031
|
-
super(t), this.I =
|
|
1027
|
+
constructor(t, e) {
|
|
1028
|
+
super(t), this.I = e;
|
|
1032
1029
|
}
|
|
1033
|
-
T(t,
|
|
1030
|
+
T(t, e) {
|
|
1034
1031
|
throw new Error("Not supported by FetchConnection");
|
|
1035
1032
|
}
|
|
1036
|
-
async g(t,
|
|
1033
|
+
async g(t, e, n, r) {
|
|
1037
1034
|
const s = JSON.stringify(r);
|
|
1038
1035
|
let i;
|
|
1039
1036
|
try {
|
|
1040
|
-
i = await this.I(
|
|
1037
|
+
i = await this.I(e, {
|
|
1041
1038
|
method: "POST",
|
|
1042
|
-
headers:
|
|
1039
|
+
headers: n,
|
|
1043
1040
|
body: s
|
|
1044
1041
|
});
|
|
1045
1042
|
} catch (t) {
|
|
@@ -1090,13 +1087,13 @@ class {
|
|
|
1090
1087
|
*/
|
|
1091
1088
|
function ft(t) {
|
|
1092
1089
|
// Polyfills for IE and WebWorker by using `self` and `msCrypto` when `crypto` is not available.
|
|
1093
|
-
const
|
|
1090
|
+
const e =
|
|
1094
1091
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1095
|
-
"undefined" != typeof self && (self.crypto || self.msCrypto),
|
|
1096
|
-
if (
|
|
1092
|
+
"undefined" != typeof self && (self.crypto || self.msCrypto), n = new Uint8Array(t);
|
|
1093
|
+
if (e && "function" == typeof e.getRandomValues) e.getRandomValues(n); else
|
|
1097
1094
|
// Falls back to Math.random
|
|
1098
|
-
for (let
|
|
1099
|
-
return
|
|
1095
|
+
for (let e = 0; e < t; e++) n[e] = Math.floor(256 * Math.random());
|
|
1096
|
+
return n;
|
|
1100
1097
|
}
|
|
1101
1098
|
|
|
1102
1099
|
/**
|
|
@@ -1117,26 +1114,26 @@ function ft(t) {
|
|
|
1117
1114
|
*/ class dt {
|
|
1118
1115
|
static A() {
|
|
1119
1116
|
// Alphanumeric characters
|
|
1120
|
-
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
|
|
1117
|
+
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", e = Math.floor(256 / t.length) * t.length;
|
|
1121
1118
|
// The largest byte value that is a multiple of `char.length`.
|
|
1122
|
-
let
|
|
1123
|
-
for (;
|
|
1119
|
+
let n = "";
|
|
1120
|
+
for (;n.length < 20; ) {
|
|
1124
1121
|
const r = ft(40);
|
|
1125
1122
|
for (let s = 0; s < r.length; ++s)
|
|
1126
1123
|
// Only accept values that are [0, maxMultiple), this ensures they can
|
|
1127
1124
|
// be evenly mapped to indices of `chars` via a modulo operation.
|
|
1128
|
-
|
|
1125
|
+
n.length < 20 && r[s] < e && (n += t.charAt(r[s] % t.length));
|
|
1129
1126
|
}
|
|
1130
|
-
return
|
|
1127
|
+
return n;
|
|
1131
1128
|
}
|
|
1132
1129
|
}
|
|
1133
1130
|
|
|
1134
|
-
function wt(t,
|
|
1135
|
-
return t <
|
|
1131
|
+
function wt(t, e) {
|
|
1132
|
+
return t < e ? -1 : t > e ? 1 : 0;
|
|
1136
1133
|
}
|
|
1137
1134
|
|
|
1138
|
-
/** Helper to compare arrays using isEqual(). */ function mt(t,
|
|
1139
|
-
return t.length ===
|
|
1135
|
+
/** Helper to compare arrays using isEqual(). */ function mt(t, e, n) {
|
|
1136
|
+
return t.length === e.length && t.every(((t, r) => n(t, e[r])));
|
|
1140
1137
|
}
|
|
1141
1138
|
|
|
1142
1139
|
/**
|
|
@@ -1190,9 +1187,9 @@ class pt {
|
|
|
1190
1187
|
/**
|
|
1191
1188
|
* The fractions of a second at nanosecond resolution.*
|
|
1192
1189
|
*/
|
|
1193
|
-
|
|
1194
|
-
if (this.seconds = t, this.nanoseconds =
|
|
1195
|
-
if (
|
|
1190
|
+
e) {
|
|
1191
|
+
if (this.seconds = t, this.nanoseconds = e, e < 0) throw new L(T, "Timestamp nanoseconds out of range: " + e);
|
|
1192
|
+
if (e >= 1e9) throw new L(T, "Timestamp nanoseconds out of range: " + e);
|
|
1196
1193
|
if (t < -62135596800) throw new L(T, "Timestamp seconds out of range: " + t);
|
|
1197
1194
|
// This will break in the year 10,000.
|
|
1198
1195
|
if (t >= 253402300800) throw new L(T, "Timestamp seconds out of range: " + t);
|
|
@@ -1221,8 +1218,8 @@ class pt {
|
|
|
1221
1218
|
* @returns A new `Timestamp` representing the same point in time as the given
|
|
1222
1219
|
* number of milliseconds.
|
|
1223
1220
|
*/ static fromMillis(t) {
|
|
1224
|
-
const
|
|
1225
|
-
return new pt(
|
|
1221
|
+
const e = Math.floor(t / 1e3), n = Math.floor(1e6 * (t - 1e3 * e));
|
|
1222
|
+
return new pt(e, n);
|
|
1226
1223
|
}
|
|
1227
1224
|
/**
|
|
1228
1225
|
* Converts a `Timestamp` to a JavaScript `Date` object. This conversion
|
|
@@ -1344,13 +1341,13 @@ class pt {
|
|
|
1344
1341
|
* See the License for the specific language governing permissions and
|
|
1345
1342
|
* limitations under the License.
|
|
1346
1343
|
*/ function _t(t) {
|
|
1347
|
-
let
|
|
1348
|
-
for (const
|
|
1349
|
-
return
|
|
1344
|
+
let e = 0;
|
|
1345
|
+
for (const n in t) Object.prototype.hasOwnProperty.call(t, n) && e++;
|
|
1346
|
+
return e;
|
|
1350
1347
|
}
|
|
1351
1348
|
|
|
1352
|
-
function gt(t,
|
|
1353
|
-
for (const
|
|
1349
|
+
function gt(t, e) {
|
|
1350
|
+
for (const n in t) Object.prototype.hasOwnProperty.call(t, n) && e(n, t[n]);
|
|
1354
1351
|
}
|
|
1355
1352
|
|
|
1356
1353
|
/**
|
|
@@ -1392,11 +1389,11 @@ class bt {
|
|
|
1392
1389
|
*
|
|
1393
1390
|
* This is an O(n) operation, where `n` is the size of the field mask.
|
|
1394
1391
|
*/ covers(t) {
|
|
1395
|
-
for (const
|
|
1392
|
+
for (const e of this.fields) if (e.isPrefixOf(t)) return !0;
|
|
1396
1393
|
return !1;
|
|
1397
1394
|
}
|
|
1398
1395
|
isEqual(t) {
|
|
1399
|
-
return mt(this.fields, t.fields, ((t,
|
|
1396
|
+
return mt(this.fields, t.fields, ((t, e) => t.isEqual(e)));
|
|
1400
1397
|
}
|
|
1401
1398
|
}
|
|
1402
1399
|
|
|
@@ -1447,23 +1444,23 @@ class vt {
|
|
|
1447
1444
|
this.binaryString = t;
|
|
1448
1445
|
}
|
|
1449
1446
|
static fromBase64String(t) {
|
|
1450
|
-
const
|
|
1451
|
-
return new vt(
|
|
1447
|
+
const e = atob(t);
|
|
1448
|
+
return new vt(e);
|
|
1452
1449
|
}
|
|
1453
1450
|
static fromUint8Array(t) {
|
|
1454
|
-
const
|
|
1451
|
+
const e =
|
|
1455
1452
|
/**
|
|
1456
1453
|
* Helper function to convert an Uint8array to a binary string.
|
|
1457
1454
|
*/
|
|
1458
1455
|
function(t) {
|
|
1459
|
-
let
|
|
1460
|
-
for (let
|
|
1461
|
-
return
|
|
1456
|
+
let e = "";
|
|
1457
|
+
for (let n = 0; n < t.length; ++n) e += String.fromCharCode(t[n]);
|
|
1458
|
+
return e;
|
|
1462
1459
|
}
|
|
1463
1460
|
/**
|
|
1464
1461
|
* Helper function to convert a binary string to an Uint8Array.
|
|
1465
1462
|
*/ (t);
|
|
1466
|
-
return new vt(
|
|
1463
|
+
return new vt(e);
|
|
1467
1464
|
}
|
|
1468
1465
|
toBase64() {
|
|
1469
1466
|
return t = this.binaryString, btoa(t);
|
|
@@ -1472,9 +1469,9 @@ class vt {
|
|
|
1472
1469
|
}
|
|
1473
1470
|
toUint8Array() {
|
|
1474
1471
|
return function(t) {
|
|
1475
|
-
const
|
|
1476
|
-
for (let
|
|
1477
|
-
return
|
|
1472
|
+
const e = new Uint8Array(t.length);
|
|
1473
|
+
for (let n = 0; n < t.length; n++) e[n] = t.charCodeAt(n);
|
|
1474
|
+
return e;
|
|
1478
1475
|
}
|
|
1479
1476
|
/**
|
|
1480
1477
|
* @license
|
|
@@ -1521,18 +1518,18 @@ const Et = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1521
1518
|
// The date string can have higher precision (nanos) than the Date class
|
|
1522
1519
|
// (millis), so we do some custom parsing here.
|
|
1523
1520
|
// Parse the nanos right out of the string.
|
|
1524
|
-
let
|
|
1525
|
-
const
|
|
1526
|
-
if (g(!!
|
|
1521
|
+
let e = 0;
|
|
1522
|
+
const n = Et.exec(t);
|
|
1523
|
+
if (g(!!n), n[1]) {
|
|
1527
1524
|
// Pad the fraction out to 9 digits (nanos).
|
|
1528
|
-
let t =
|
|
1529
|
-
t = (t + "000000000").substr(0, 9),
|
|
1525
|
+
let t = n[1];
|
|
1526
|
+
t = (t + "000000000").substr(0, 9), e = Number(t);
|
|
1530
1527
|
}
|
|
1531
1528
|
// Parse the date to get the seconds.
|
|
1532
1529
|
const r = new Date(t);
|
|
1533
1530
|
return {
|
|
1534
1531
|
seconds: Math.floor(r.getTime() / 1e3),
|
|
1535
|
-
nanos:
|
|
1532
|
+
nanos: e
|
|
1536
1533
|
};
|
|
1537
1534
|
}
|
|
1538
1535
|
return {
|
|
@@ -1587,8 +1584,8 @@ const Et = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1587
1584
|
* - With respect to other ServerTimestampValues, they sort by their
|
|
1588
1585
|
* localWriteTime.
|
|
1589
1586
|
*/ function Pt(t) {
|
|
1590
|
-
var
|
|
1591
|
-
return "server_timestamp" === (null === (
|
|
1587
|
+
var e, n;
|
|
1588
|
+
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);
|
|
1592
1589
|
}
|
|
1593
1590
|
|
|
1594
1591
|
/**
|
|
@@ -1597,15 +1594,15 @@ const Et = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1597
1594
|
* Preserving the previous values allows the user to display the last resoled
|
|
1598
1595
|
* value until the backend responds with the timestamp.
|
|
1599
1596
|
*/ function Rt(t) {
|
|
1600
|
-
const
|
|
1601
|
-
return Pt(
|
|
1597
|
+
const e = t.mapValue.fields.__previous_value__;
|
|
1598
|
+
return Pt(e) ? Rt(e) : e;
|
|
1602
1599
|
}
|
|
1603
1600
|
|
|
1604
1601
|
/**
|
|
1605
1602
|
* Returns the local time at which this timestamp was first set.
|
|
1606
1603
|
*/ function Vt(t) {
|
|
1607
|
-
const
|
|
1608
|
-
return new pt(
|
|
1604
|
+
const e = It(t.mapValue.fields.__local_write_time__.timestampValue);
|
|
1605
|
+
return new pt(e.seconds, e.nanos);
|
|
1609
1606
|
}
|
|
1610
1607
|
|
|
1611
1608
|
/**
|
|
@@ -1628,167 +1625,167 @@ const Et = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1628
1625
|
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 ? Pt(t) ? 4 /* ServerTimestampValue */ : 10 /* ObjectValue */ : _();
|
|
1629
1626
|
}
|
|
1630
1627
|
|
|
1631
|
-
/** Tests `left` and `right` for equality based on the backend semantics. */ function Dt(t,
|
|
1632
|
-
const
|
|
1633
|
-
if (
|
|
1634
|
-
switch (
|
|
1628
|
+
/** Tests `left` and `right` for equality based on the backend semantics. */ function Dt(t, e) {
|
|
1629
|
+
const n = Nt(t);
|
|
1630
|
+
if (n !== Nt(e)) return !1;
|
|
1631
|
+
switch (n) {
|
|
1635
1632
|
case 0 /* NullValue */ :
|
|
1636
1633
|
return !0;
|
|
1637
1634
|
|
|
1638
1635
|
case 1 /* BooleanValue */ :
|
|
1639
|
-
return t.booleanValue ===
|
|
1636
|
+
return t.booleanValue === e.booleanValue;
|
|
1640
1637
|
|
|
1641
1638
|
case 4 /* ServerTimestampValue */ :
|
|
1642
|
-
return Vt(t).isEqual(Vt(
|
|
1639
|
+
return Vt(t).isEqual(Vt(e));
|
|
1643
1640
|
|
|
1644
1641
|
case 3 /* TimestampValue */ :
|
|
1645
|
-
return function(t,
|
|
1646
|
-
if ("string" == typeof t.timestampValue && "string" == typeof
|
|
1642
|
+
return function(t, e) {
|
|
1643
|
+
if ("string" == typeof t.timestampValue && "string" == typeof e.timestampValue && t.timestampValue.length === e.timestampValue.length)
|
|
1647
1644
|
// Use string equality for ISO 8601 timestamps
|
|
1648
|
-
return t.timestampValue ===
|
|
1649
|
-
const
|
|
1650
|
-
return
|
|
1651
|
-
}(t,
|
|
1645
|
+
return t.timestampValue === e.timestampValue;
|
|
1646
|
+
const n = It(t.timestampValue), r = It(e.timestampValue);
|
|
1647
|
+
return n.seconds === r.seconds && n.nanos === r.nanos;
|
|
1648
|
+
}(t, e);
|
|
1652
1649
|
|
|
1653
1650
|
case 5 /* StringValue */ :
|
|
1654
|
-
return t.stringValue ===
|
|
1651
|
+
return t.stringValue === e.stringValue;
|
|
1655
1652
|
|
|
1656
1653
|
case 6 /* BlobValue */ :
|
|
1657
|
-
return function(t,
|
|
1658
|
-
return At(t.bytesValue).isEqual(At(
|
|
1659
|
-
}(t,
|
|
1654
|
+
return function(t, e) {
|
|
1655
|
+
return At(t.bytesValue).isEqual(At(e.bytesValue));
|
|
1656
|
+
}(t, e);
|
|
1660
1657
|
|
|
1661
1658
|
case 7 /* RefValue */ :
|
|
1662
|
-
return t.referenceValue ===
|
|
1659
|
+
return t.referenceValue === e.referenceValue;
|
|
1663
1660
|
|
|
1664
1661
|
case 8 /* GeoPointValue */ :
|
|
1665
|
-
return function(t,
|
|
1666
|
-
return Tt(t.geoPointValue.latitude) === Tt(
|
|
1667
|
-
}(t,
|
|
1662
|
+
return function(t, e) {
|
|
1663
|
+
return Tt(t.geoPointValue.latitude) === Tt(e.geoPointValue.latitude) && Tt(t.geoPointValue.longitude) === Tt(e.geoPointValue.longitude);
|
|
1664
|
+
}(t, e);
|
|
1668
1665
|
|
|
1669
1666
|
case 2 /* NumberValue */ :
|
|
1670
|
-
return function(t,
|
|
1671
|
-
if ("integerValue" in t && "integerValue" in
|
|
1672
|
-
if ("doubleValue" in t && "doubleValue" in
|
|
1673
|
-
const
|
|
1674
|
-
return
|
|
1667
|
+
return function(t, e) {
|
|
1668
|
+
if ("integerValue" in t && "integerValue" in e) return Tt(t.integerValue) === Tt(e.integerValue);
|
|
1669
|
+
if ("doubleValue" in t && "doubleValue" in e) {
|
|
1670
|
+
const n = Tt(t.doubleValue), r = Tt(e.doubleValue);
|
|
1671
|
+
return n === r ? ot(n) === ot(r) : isNaN(n) && isNaN(r);
|
|
1675
1672
|
}
|
|
1676
1673
|
return !1;
|
|
1677
|
-
}(t,
|
|
1674
|
+
}(t, e);
|
|
1678
1675
|
|
|
1679
1676
|
case 9 /* ArrayValue */ :
|
|
1680
|
-
return mt(t.arrayValue.values || [],
|
|
1677
|
+
return mt(t.arrayValue.values || [], e.arrayValue.values || [], Dt);
|
|
1681
1678
|
|
|
1682
1679
|
case 10 /* ObjectValue */ :
|
|
1683
|
-
return function(t,
|
|
1684
|
-
const
|
|
1685
|
-
if (_t(
|
|
1686
|
-
for (const t in
|
|
1680
|
+
return function(t, e) {
|
|
1681
|
+
const n = t.mapValue.fields || {}, r = e.mapValue.fields || {};
|
|
1682
|
+
if (_t(n) !== _t(r)) return !1;
|
|
1683
|
+
for (const t in n) if (n.hasOwnProperty(t) && (void 0 === r[t] || !Dt(n[t], r[t]))) return !1;
|
|
1687
1684
|
return !0;
|
|
1688
1685
|
}
|
|
1689
|
-
/** Returns true if the ArrayValue contains the specified element. */ (t,
|
|
1686
|
+
/** Returns true if the ArrayValue contains the specified element. */ (t, e);
|
|
1690
1687
|
|
|
1691
1688
|
default:
|
|
1692
1689
|
return _();
|
|
1693
1690
|
}
|
|
1694
1691
|
}
|
|
1695
1692
|
|
|
1696
|
-
function $t(t,
|
|
1697
|
-
return void 0 !== (t.values || []).find((t => Dt(t,
|
|
1693
|
+
function $t(t, e) {
|
|
1694
|
+
return void 0 !== (t.values || []).find((t => Dt(t, e)));
|
|
1698
1695
|
}
|
|
1699
1696
|
|
|
1700
|
-
function Ft(t,
|
|
1701
|
-
const
|
|
1702
|
-
if (
|
|
1703
|
-
switch (
|
|
1697
|
+
function Ft(t, e) {
|
|
1698
|
+
const n = Nt(t), r = Nt(e);
|
|
1699
|
+
if (n !== r) return wt(n, r);
|
|
1700
|
+
switch (n) {
|
|
1704
1701
|
case 0 /* NullValue */ :
|
|
1705
1702
|
return 0;
|
|
1706
1703
|
|
|
1707
1704
|
case 1 /* BooleanValue */ :
|
|
1708
|
-
return wt(t.booleanValue,
|
|
1705
|
+
return wt(t.booleanValue, e.booleanValue);
|
|
1709
1706
|
|
|
1710
1707
|
case 2 /* NumberValue */ :
|
|
1711
|
-
return function(t,
|
|
1712
|
-
const
|
|
1713
|
-
return
|
|
1708
|
+
return function(t, e) {
|
|
1709
|
+
const n = Tt(t.integerValue || t.doubleValue), r = Tt(e.integerValue || e.doubleValue);
|
|
1710
|
+
return n < r ? -1 : n > r ? 1 : n === r ? 0 :
|
|
1714
1711
|
// one or both are NaN.
|
|
1715
|
-
isNaN(
|
|
1716
|
-
}(t,
|
|
1712
|
+
isNaN(n) ? isNaN(r) ? 0 : -1 : 1;
|
|
1713
|
+
}(t, e);
|
|
1717
1714
|
|
|
1718
1715
|
case 3 /* TimestampValue */ :
|
|
1719
|
-
return St(t.timestampValue,
|
|
1716
|
+
return St(t.timestampValue, e.timestampValue);
|
|
1720
1717
|
|
|
1721
1718
|
case 4 /* ServerTimestampValue */ :
|
|
1722
|
-
return St(Vt(t), Vt(
|
|
1719
|
+
return St(Vt(t), Vt(e));
|
|
1723
1720
|
|
|
1724
1721
|
case 5 /* StringValue */ :
|
|
1725
|
-
return wt(t.stringValue,
|
|
1722
|
+
return wt(t.stringValue, e.stringValue);
|
|
1726
1723
|
|
|
1727
1724
|
case 6 /* BlobValue */ :
|
|
1728
|
-
return function(t,
|
|
1729
|
-
const
|
|
1730
|
-
return
|
|
1731
|
-
}(t.bytesValue,
|
|
1725
|
+
return function(t, e) {
|
|
1726
|
+
const n = At(t), r = At(e);
|
|
1727
|
+
return n.compareTo(r);
|
|
1728
|
+
}(t.bytesValue, e.bytesValue);
|
|
1732
1729
|
|
|
1733
1730
|
case 7 /* RefValue */ :
|
|
1734
|
-
return function(t,
|
|
1735
|
-
const
|
|
1736
|
-
for (let t = 0; t <
|
|
1737
|
-
const
|
|
1738
|
-
if (0 !==
|
|
1731
|
+
return function(t, e) {
|
|
1732
|
+
const n = t.split("/"), r = e.split("/");
|
|
1733
|
+
for (let t = 0; t < n.length && t < r.length; t++) {
|
|
1734
|
+
const e = wt(n[t], r[t]);
|
|
1735
|
+
if (0 !== e) return e;
|
|
1739
1736
|
}
|
|
1740
|
-
return wt(
|
|
1741
|
-
}(t.referenceValue,
|
|
1737
|
+
return wt(n.length, r.length);
|
|
1738
|
+
}(t.referenceValue, e.referenceValue);
|
|
1742
1739
|
|
|
1743
1740
|
case 8 /* GeoPointValue */ :
|
|
1744
|
-
return function(t,
|
|
1745
|
-
const
|
|
1746
|
-
if (0 !==
|
|
1747
|
-
return wt(Tt(t.longitude), Tt(
|
|
1748
|
-
}(t.geoPointValue,
|
|
1741
|
+
return function(t, e) {
|
|
1742
|
+
const n = wt(Tt(t.latitude), Tt(e.latitude));
|
|
1743
|
+
if (0 !== n) return n;
|
|
1744
|
+
return wt(Tt(t.longitude), Tt(e.longitude));
|
|
1745
|
+
}(t.geoPointValue, e.geoPointValue);
|
|
1749
1746
|
|
|
1750
1747
|
case 9 /* ArrayValue */ :
|
|
1751
|
-
return function(t,
|
|
1752
|
-
const
|
|
1753
|
-
for (let t = 0; t <
|
|
1754
|
-
const
|
|
1755
|
-
if (
|
|
1748
|
+
return function(t, e) {
|
|
1749
|
+
const n = t.values || [], r = e.values || [];
|
|
1750
|
+
for (let t = 0; t < n.length && t < r.length; ++t) {
|
|
1751
|
+
const e = Ft(n[t], r[t]);
|
|
1752
|
+
if (e) return e;
|
|
1756
1753
|
}
|
|
1757
|
-
return wt(
|
|
1758
|
-
}(t.arrayValue,
|
|
1754
|
+
return wt(n.length, r.length);
|
|
1755
|
+
}(t.arrayValue, e.arrayValue);
|
|
1759
1756
|
|
|
1760
1757
|
case 10 /* ObjectValue */ :
|
|
1761
|
-
return function(t,
|
|
1762
|
-
const
|
|
1758
|
+
return function(t, e) {
|
|
1759
|
+
const n = t.fields || {}, r = Object.keys(n), s = e.fields || {}, i = Object.keys(s);
|
|
1763
1760
|
// Even though MapValues are likely sorted correctly based on their insertion
|
|
1764
1761
|
// order (e.g. when received from the backend), local modifications can bring
|
|
1765
1762
|
// elements out of order. We need to re-sort the elements to ensure that
|
|
1766
1763
|
// canonical IDs are independent of insertion order.
|
|
1767
1764
|
r.sort(), i.sort();
|
|
1768
1765
|
for (let t = 0; t < r.length && t < i.length; ++t) {
|
|
1769
|
-
const
|
|
1770
|
-
if (0 !==
|
|
1771
|
-
const o = Ft(
|
|
1766
|
+
const e = wt(r[t], i[t]);
|
|
1767
|
+
if (0 !== e) return e;
|
|
1768
|
+
const o = Ft(n[r[t]], s[i[t]]);
|
|
1772
1769
|
if (0 !== o) return o;
|
|
1773
1770
|
}
|
|
1774
1771
|
return wt(r.length, i.length);
|
|
1775
1772
|
}
|
|
1776
|
-
/** Returns a reference value for the provided database and key. */ (t.mapValue,
|
|
1773
|
+
/** Returns a reference value for the provided database and key. */ (t.mapValue, e.mapValue);
|
|
1777
1774
|
|
|
1778
1775
|
default:
|
|
1779
1776
|
throw _();
|
|
1780
1777
|
}
|
|
1781
1778
|
}
|
|
1782
1779
|
|
|
1783
|
-
function St(t,
|
|
1784
|
-
if ("string" == typeof t && "string" == typeof
|
|
1785
|
-
const
|
|
1786
|
-
return 0 !== s ? s : wt(
|
|
1780
|
+
function St(t, e) {
|
|
1781
|
+
if ("string" == typeof t && "string" == typeof e && t.length === e.length) return wt(t, e);
|
|
1782
|
+
const n = It(t), r = It(e), s = wt(n.seconds, r.seconds);
|
|
1783
|
+
return 0 !== s ? s : wt(n.nanos, r.nanos);
|
|
1787
1784
|
}
|
|
1788
1785
|
|
|
1789
|
-
function qt(t,
|
|
1786
|
+
function qt(t, e) {
|
|
1790
1787
|
return {
|
|
1791
|
-
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${
|
|
1788
|
+
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${e.path.canonicalString()}`
|
|
1792
1789
|
};
|
|
1793
1790
|
}
|
|
1794
1791
|
|
|
@@ -1816,21 +1813,21 @@ function qt(t, n) {
|
|
|
1816
1813
|
timestampValue: Object.assign({}, t.timestampValue)
|
|
1817
1814
|
};
|
|
1818
1815
|
if (t.mapValue) {
|
|
1819
|
-
const
|
|
1816
|
+
const e = {
|
|
1820
1817
|
mapValue: {
|
|
1821
1818
|
fields: {}
|
|
1822
1819
|
}
|
|
1823
1820
|
};
|
|
1824
|
-
return gt(t.mapValue.fields, ((t,
|
|
1821
|
+
return gt(t.mapValue.fields, ((t, n) => e.mapValue.fields[t] = Ut(n))), e;
|
|
1825
1822
|
}
|
|
1826
1823
|
if (t.arrayValue) {
|
|
1827
|
-
const
|
|
1824
|
+
const e = {
|
|
1828
1825
|
arrayValue: {
|
|
1829
1826
|
values: []
|
|
1830
1827
|
}
|
|
1831
1828
|
};
|
|
1832
|
-
for (let
|
|
1833
|
-
return
|
|
1829
|
+
for (let n = 0; n < (t.arrayValue.values || []).length; ++n) e.arrayValue.values[n] = Ut(t.arrayValue.values[n]);
|
|
1830
|
+
return e;
|
|
1834
1831
|
}
|
|
1835
1832
|
return Object.assign({}, t);
|
|
1836
1833
|
}
|
|
@@ -1871,10 +1868,10 @@ function qt(t, n) {
|
|
|
1871
1868
|
*/ field(t) {
|
|
1872
1869
|
if (t.isEmpty()) return this.value;
|
|
1873
1870
|
{
|
|
1874
|
-
let
|
|
1875
|
-
for (let
|
|
1876
|
-
!Lt(
|
|
1877
|
-
return
|
|
1871
|
+
let e = this.value;
|
|
1872
|
+
for (let n = 0; n < t.length - 1; ++n) if (e = (e.mapValue.fields || {})[t.get(n)],
|
|
1873
|
+
!Lt(e)) return null;
|
|
1874
|
+
return e = (e.mapValue.fields || {})[t.lastSegment()], e || null;
|
|
1878
1875
|
}
|
|
1879
1876
|
}
|
|
1880
1877
|
/**
|
|
@@ -1882,25 +1879,25 @@ function qt(t, n) {
|
|
|
1882
1879
|
*
|
|
1883
1880
|
* @param path - The field path to set.
|
|
1884
1881
|
* @param value - The value to set.
|
|
1885
|
-
*/ set(t,
|
|
1886
|
-
this.getFieldsMap(t.popLast())[t.lastSegment()] = Ut(
|
|
1882
|
+
*/ set(t, e) {
|
|
1883
|
+
this.getFieldsMap(t.popLast())[t.lastSegment()] = Ut(e);
|
|
1887
1884
|
}
|
|
1888
1885
|
/**
|
|
1889
1886
|
* Sets the provided fields to the provided values.
|
|
1890
1887
|
*
|
|
1891
1888
|
* @param data - A map of fields to values (or null for deletes).
|
|
1892
1889
|
*/ setAll(t) {
|
|
1893
|
-
let
|
|
1890
|
+
let e = J.emptyPath(), n = {}, r = [];
|
|
1894
1891
|
t.forEach(((t, s) => {
|
|
1895
|
-
if (!
|
|
1892
|
+
if (!e.isImmediateParentOf(s)) {
|
|
1896
1893
|
// Insert the accumulated changes at this parent location
|
|
1897
|
-
const t = this.getFieldsMap(
|
|
1898
|
-
this.applyChanges(t,
|
|
1894
|
+
const t = this.getFieldsMap(e);
|
|
1895
|
+
this.applyChanges(t, n, r), n = {}, r = [], e = s.popLast();
|
|
1899
1896
|
}
|
|
1900
|
-
t ?
|
|
1897
|
+
t ? n[s.lastSegment()] = Ut(t) : r.push(s.lastSegment());
|
|
1901
1898
|
}));
|
|
1902
|
-
const s = this.getFieldsMap(
|
|
1903
|
-
this.applyChanges(s,
|
|
1899
|
+
const s = this.getFieldsMap(e);
|
|
1900
|
+
this.applyChanges(s, n, r);
|
|
1904
1901
|
}
|
|
1905
1902
|
/**
|
|
1906
1903
|
* Removes the field at the specified path. If there is no field at the
|
|
@@ -1908,8 +1905,8 @@ function qt(t, n) {
|
|
|
1908
1905
|
*
|
|
1909
1906
|
* @param path - The field path to remove.
|
|
1910
1907
|
*/ delete(t) {
|
|
1911
|
-
const
|
|
1912
|
-
Lt(
|
|
1908
|
+
const e = this.field(t.popLast());
|
|
1909
|
+
Lt(e) && e.mapValue.fields && delete e.mapValue.fields[t.lastSegment()];
|
|
1913
1910
|
}
|
|
1914
1911
|
isEqual(t) {
|
|
1915
1912
|
return Dt(this.value, t.value);
|
|
@@ -1918,26 +1915,26 @@ function qt(t, n) {
|
|
|
1918
1915
|
* Returns the map that contains the leaf element of `path`. If the parent
|
|
1919
1916
|
* entry does not yet exist, or if it is not a map, a new map will be created.
|
|
1920
1917
|
*/ getFieldsMap(t) {
|
|
1921
|
-
let
|
|
1922
|
-
|
|
1918
|
+
let e = this.value;
|
|
1919
|
+
e.mapValue.fields || (e.mapValue = {
|
|
1923
1920
|
fields: {}
|
|
1924
1921
|
});
|
|
1925
|
-
for (let
|
|
1926
|
-
let r =
|
|
1922
|
+
for (let n = 0; n < t.length; ++n) {
|
|
1923
|
+
let r = e.mapValue.fields[t.get(n)];
|
|
1927
1924
|
Lt(r) && r.mapValue.fields || (r = {
|
|
1928
1925
|
mapValue: {
|
|
1929
1926
|
fields: {}
|
|
1930
1927
|
}
|
|
1931
|
-
},
|
|
1928
|
+
}, e.mapValue.fields[t.get(n)] = r), e = r;
|
|
1932
1929
|
}
|
|
1933
|
-
return
|
|
1930
|
+
return e.mapValue.fields;
|
|
1934
1931
|
}
|
|
1935
1932
|
/**
|
|
1936
1933
|
* Modifies `fieldsMap` by adding, replacing or deleting the specified
|
|
1937
1934
|
* entries.
|
|
1938
|
-
*/ applyChanges(t,
|
|
1939
|
-
gt(
|
|
1940
|
-
for (const
|
|
1935
|
+
*/ applyChanges(t, e, n) {
|
|
1936
|
+
gt(e, ((e, n) => t[e] = n));
|
|
1937
|
+
for (const e of n) delete t[e];
|
|
1941
1938
|
}
|
|
1942
1939
|
clone() {
|
|
1943
1940
|
return new jt(Ut(this.value));
|
|
@@ -1970,8 +1967,8 @@ function qt(t, n) {
|
|
|
1970
1967
|
* applied, `isValidDocument()` returns false and the document should be removed
|
|
1971
1968
|
* from all views.
|
|
1972
1969
|
*/ class kt {
|
|
1973
|
-
constructor(t,
|
|
1974
|
-
this.key = t, this.documentType =
|
|
1970
|
+
constructor(t, e, n, r, s) {
|
|
1971
|
+
this.key = t, this.documentType = e, this.version = n, this.data = r, this.documentState = s;
|
|
1975
1972
|
}
|
|
1976
1973
|
/**
|
|
1977
1974
|
* Creates a document with no known version or data, but which can serve as
|
|
@@ -1982,24 +1979,24 @@ function qt(t, n) {
|
|
|
1982
1979
|
/**
|
|
1983
1980
|
* Creates a new document that is known to exist with the given data at the
|
|
1984
1981
|
* given version.
|
|
1985
|
-
*/ static newFoundDocument(t,
|
|
1986
|
-
return new kt(t, 1 /* FOUND_DOCUMENT */ ,
|
|
1982
|
+
*/ static newFoundDocument(t, e, n) {
|
|
1983
|
+
return new kt(t, 1 /* FOUND_DOCUMENT */ , e, n, 0 /* SYNCED */);
|
|
1987
1984
|
}
|
|
1988
|
-
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t,
|
|
1989
|
-
return new kt(t, 2 /* NO_DOCUMENT */ ,
|
|
1985
|
+
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t, e) {
|
|
1986
|
+
return new kt(t, 2 /* NO_DOCUMENT */ , e, jt.empty(), 0 /* SYNCED */);
|
|
1990
1987
|
}
|
|
1991
1988
|
/**
|
|
1992
1989
|
* Creates a new document that is known to exist at the given version but
|
|
1993
1990
|
* whose data is not known (e.g. a document that was updated without a known
|
|
1994
1991
|
* base document).
|
|
1995
|
-
*/ static newUnknownDocument(t,
|
|
1996
|
-
return new kt(t, 3 /* UNKNOWN_DOCUMENT */ ,
|
|
1992
|
+
*/ static newUnknownDocument(t, e) {
|
|
1993
|
+
return new kt(t, 3 /* UNKNOWN_DOCUMENT */ , e, jt.empty(), 2 /* HAS_COMMITTED_MUTATIONS */);
|
|
1997
1994
|
}
|
|
1998
1995
|
/**
|
|
1999
1996
|
* Changes the document type to indicate that it exists and that its version
|
|
2000
1997
|
* and data are known.
|
|
2001
|
-
*/ convertToFoundDocument(t,
|
|
2002
|
-
return this.version = t, this.documentType = 1 /* FOUND_DOCUMENT */ , this.data =
|
|
1998
|
+
*/ convertToFoundDocument(t, e) {
|
|
1999
|
+
return this.version = t, this.documentType = 1 /* FOUND_DOCUMENT */ , this.data = e,
|
|
2003
2000
|
this.documentState = 0 /* SYNCED */ , this;
|
|
2004
2001
|
}
|
|
2005
2002
|
/**
|
|
@@ -2073,8 +2070,8 @@ function qt(t, n) {
|
|
|
2073
2070
|
*/
|
|
2074
2071
|
// Visible for testing
|
|
2075
2072
|
class Mt {
|
|
2076
|
-
constructor(t,
|
|
2077
|
-
this.path = t, this.collectionGroup =
|
|
2073
|
+
constructor(t, e = null, n = [], r = [], s = null, i = null, o = null) {
|
|
2074
|
+
this.path = t, this.collectionGroup = e, this.orderBy = n, this.filters = r, this.limit = s,
|
|
2078
2075
|
this.startAt = i, this.endAt = o, this.P = null;
|
|
2079
2076
|
}
|
|
2080
2077
|
}
|
|
@@ -2086,26 +2083,26 @@ class Mt {
|
|
|
2086
2083
|
* NOTE: you should always construct `Target` from `Query.toTarget` instead of
|
|
2087
2084
|
* using this factory method, because `Query` provides an implicit `orderBy`
|
|
2088
2085
|
* property.
|
|
2089
|
-
*/ function Bt(t,
|
|
2090
|
-
return new Mt(t,
|
|
2086
|
+
*/ function Bt(t, e = null, n = [], r = [], s = null, i = null, o = null) {
|
|
2087
|
+
return new Mt(t, e, n, r, s, i, o);
|
|
2091
2088
|
}
|
|
2092
2089
|
|
|
2093
2090
|
class Qt extends class {} {
|
|
2094
|
-
constructor(t,
|
|
2095
|
-
super(), this.field = t, this.op =
|
|
2091
|
+
constructor(t, e, n) {
|
|
2092
|
+
super(), this.field = t, this.op = e, this.value = n;
|
|
2096
2093
|
}
|
|
2097
2094
|
/**
|
|
2098
2095
|
* Creates a filter based on the provided arguments.
|
|
2099
|
-
*/ static create(t,
|
|
2100
|
-
return t.isKeyField() ? "in" /* IN */ ===
|
|
2096
|
+
*/ static create(t, e, n) {
|
|
2097
|
+
return t.isKeyField() ? "in" /* IN */ === e || "not-in" /* NOT_IN */ === e ? this.R(t, e, n) : new zt(t, e, n) : "array-contains" /* ARRAY_CONTAINS */ === e ? new Yt(t, n) : "in" /* IN */ === e ? new Kt(t, n) : "not-in" /* NOT_IN */ === e ? new Jt(t, n) : "array-contains-any" /* ARRAY_CONTAINS_ANY */ === e ? new Zt(t, n) : new Qt(t, e, n);
|
|
2101
2098
|
}
|
|
2102
|
-
static R(t,
|
|
2103
|
-
return "in" /* IN */ ===
|
|
2099
|
+
static R(t, e, n) {
|
|
2100
|
+
return "in" /* IN */ === e ? new Wt(t, n) : new Gt(t, n);
|
|
2104
2101
|
}
|
|
2105
2102
|
matches(t) {
|
|
2106
|
-
const
|
|
2103
|
+
const e = t.data.field(this.field);
|
|
2107
2104
|
// Types do not have to match in NOT_EQUAL filters.
|
|
2108
|
-
return "!=" /* NOT_EQUAL */ === this.op ? null !==
|
|
2105
|
+
return "!=" /* NOT_EQUAL */ === this.op ? null !== e && this.V(Ft(e, this.value)) : null !== e && Nt(this.value) === Nt(e) && this.V(Ft(e, this.value));
|
|
2109
2106
|
// Only compare types with matching backend order (such as double and int).
|
|
2110
2107
|
}
|
|
2111
2108
|
V(t) {
|
|
@@ -2139,78 +2136,78 @@ class Qt extends class {} {
|
|
|
2139
2136
|
|
|
2140
2137
|
/** Filter that matches on key fields (i.e. '__name__'). */
|
|
2141
2138
|
class zt extends Qt {
|
|
2142
|
-
constructor(t,
|
|
2143
|
-
super(t,
|
|
2139
|
+
constructor(t, e, n) {
|
|
2140
|
+
super(t, e, n), this.key = Z.fromName(n.referenceValue);
|
|
2144
2141
|
}
|
|
2145
2142
|
matches(t) {
|
|
2146
|
-
const
|
|
2147
|
-
return this.V(
|
|
2143
|
+
const e = Z.comparator(t.key, this.key);
|
|
2144
|
+
return this.V(e);
|
|
2148
2145
|
}
|
|
2149
2146
|
}
|
|
2150
2147
|
|
|
2151
2148
|
/** Filter that matches on key fields within an array. */ class Wt extends Qt {
|
|
2152
|
-
constructor(t,
|
|
2153
|
-
super(t, "in" /* IN */ ,
|
|
2149
|
+
constructor(t, e) {
|
|
2150
|
+
super(t, "in" /* IN */ , e), this.keys = Ht("in" /* IN */ , e);
|
|
2154
2151
|
}
|
|
2155
2152
|
matches(t) {
|
|
2156
|
-
return this.keys.some((
|
|
2153
|
+
return this.keys.some((e => e.isEqual(t.key)));
|
|
2157
2154
|
}
|
|
2158
2155
|
}
|
|
2159
2156
|
|
|
2160
2157
|
/** Filter that matches on key fields not present within an array. */ class Gt extends Qt {
|
|
2161
|
-
constructor(t,
|
|
2162
|
-
super(t, "not-in" /* NOT_IN */ ,
|
|
2158
|
+
constructor(t, e) {
|
|
2159
|
+
super(t, "not-in" /* NOT_IN */ , e), this.keys = Ht("not-in" /* NOT_IN */ , e);
|
|
2163
2160
|
}
|
|
2164
2161
|
matches(t) {
|
|
2165
|
-
return !this.keys.some((
|
|
2162
|
+
return !this.keys.some((e => e.isEqual(t.key)));
|
|
2166
2163
|
}
|
|
2167
2164
|
}
|
|
2168
2165
|
|
|
2169
|
-
function Ht(t,
|
|
2170
|
-
var
|
|
2171
|
-
return ((null === (
|
|
2166
|
+
function Ht(t, e) {
|
|
2167
|
+
var n;
|
|
2168
|
+
return ((null === (n = e.arrayValue) || void 0 === n ? void 0 : n.values) || []).map((t => Z.fromName(t.referenceValue)));
|
|
2172
2169
|
}
|
|
2173
2170
|
|
|
2174
2171
|
/** A Filter that implements the array-contains operator. */ class Yt extends Qt {
|
|
2175
|
-
constructor(t,
|
|
2176
|
-
super(t, "array-contains" /* ARRAY_CONTAINS */ ,
|
|
2172
|
+
constructor(t, e) {
|
|
2173
|
+
super(t, "array-contains" /* ARRAY_CONTAINS */ , e);
|
|
2177
2174
|
}
|
|
2178
2175
|
matches(t) {
|
|
2179
|
-
const
|
|
2180
|
-
return xt(
|
|
2176
|
+
const e = t.data.field(this.field);
|
|
2177
|
+
return xt(e) && $t(e.arrayValue, this.value);
|
|
2181
2178
|
}
|
|
2182
2179
|
}
|
|
2183
2180
|
|
|
2184
2181
|
/** A Filter that implements the IN operator. */ class Kt extends Qt {
|
|
2185
|
-
constructor(t,
|
|
2186
|
-
super(t, "in" /* IN */ ,
|
|
2182
|
+
constructor(t, e) {
|
|
2183
|
+
super(t, "in" /* IN */ , e);
|
|
2187
2184
|
}
|
|
2188
2185
|
matches(t) {
|
|
2189
|
-
const
|
|
2190
|
-
return null !==
|
|
2186
|
+
const e = t.data.field(this.field);
|
|
2187
|
+
return null !== e && $t(this.value.arrayValue, e);
|
|
2191
2188
|
}
|
|
2192
2189
|
}
|
|
2193
2190
|
|
|
2194
2191
|
/** A Filter that implements the not-in operator. */ class Jt extends Qt {
|
|
2195
|
-
constructor(t,
|
|
2196
|
-
super(t, "not-in" /* NOT_IN */ ,
|
|
2192
|
+
constructor(t, e) {
|
|
2193
|
+
super(t, "not-in" /* NOT_IN */ , e);
|
|
2197
2194
|
}
|
|
2198
2195
|
matches(t) {
|
|
2199
2196
|
if ($t(this.value.arrayValue, {
|
|
2200
2197
|
nullValue: "NULL_VALUE"
|
|
2201
2198
|
})) return !1;
|
|
2202
|
-
const
|
|
2203
|
-
return null !==
|
|
2199
|
+
const e = t.data.field(this.field);
|
|
2200
|
+
return null !== e && !$t(this.value.arrayValue, e);
|
|
2204
2201
|
}
|
|
2205
2202
|
}
|
|
2206
2203
|
|
|
2207
2204
|
/** A Filter that implements the array-contains-any operator. */ class Zt extends Qt {
|
|
2208
|
-
constructor(t,
|
|
2209
|
-
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ ,
|
|
2205
|
+
constructor(t, e) {
|
|
2206
|
+
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ , e);
|
|
2210
2207
|
}
|
|
2211
2208
|
matches(t) {
|
|
2212
|
-
const
|
|
2213
|
-
return !(!xt(
|
|
2209
|
+
const e = t.data.field(this.field);
|
|
2210
|
+
return !(!xt(e) || !e.arrayValue.values) && e.arrayValue.values.some((t => $t(this.value.arrayValue, t)));
|
|
2214
2211
|
}
|
|
2215
2212
|
}
|
|
2216
2213
|
|
|
@@ -2228,29 +2225,29 @@ function Ht(t, n) {
|
|
|
2228
2225
|
* after a bound. This is influenced by whether the position is just before or
|
|
2229
2226
|
* just after the provided values.
|
|
2230
2227
|
*/ class Xt {
|
|
2231
|
-
constructor(t,
|
|
2232
|
-
this.position = t, this.before =
|
|
2228
|
+
constructor(t, e) {
|
|
2229
|
+
this.position = t, this.before = e;
|
|
2233
2230
|
}
|
|
2234
2231
|
}
|
|
2235
2232
|
|
|
2236
2233
|
/**
|
|
2237
2234
|
* An ordering on a field, in some Direction. Direction defaults to ASCENDING.
|
|
2238
|
-
*/ class
|
|
2239
|
-
constructor(t,
|
|
2240
|
-
this.field = t, this.dir =
|
|
2235
|
+
*/ class te {
|
|
2236
|
+
constructor(t, e = "asc" /* ASCENDING */) {
|
|
2237
|
+
this.field = t, this.dir = e;
|
|
2241
2238
|
}
|
|
2242
2239
|
}
|
|
2243
2240
|
|
|
2244
|
-
function
|
|
2245
|
-
return t.dir ===
|
|
2241
|
+
function ee(t, e) {
|
|
2242
|
+
return t.dir === e.dir && t.field.isEqual(e.field);
|
|
2246
2243
|
}
|
|
2247
2244
|
|
|
2248
|
-
function
|
|
2249
|
-
if (null === t) return null ===
|
|
2250
|
-
if (null ===
|
|
2251
|
-
if (t.before !==
|
|
2252
|
-
for (let
|
|
2253
|
-
if (!Dt(t.position[
|
|
2245
|
+
function ne(t, e) {
|
|
2246
|
+
if (null === t) return null === e;
|
|
2247
|
+
if (null === e) return !1;
|
|
2248
|
+
if (t.before !== e.before || t.position.length !== e.position.length) return !1;
|
|
2249
|
+
for (let n = 0; n < t.position.length; n++) {
|
|
2250
|
+
if (!Dt(t.position[n], e.position[n])) return !1;
|
|
2254
2251
|
}
|
|
2255
2252
|
return !0;
|
|
2256
2253
|
}
|
|
@@ -2277,29 +2274,29 @@ function en(t, n) {
|
|
|
2277
2274
|
* query the RemoteStore results.
|
|
2278
2275
|
*
|
|
2279
2276
|
* Visible for testing.
|
|
2280
|
-
*/ class
|
|
2277
|
+
*/ class re {
|
|
2281
2278
|
/**
|
|
2282
2279
|
* Initializes a Query with a path and optional additional query constraints.
|
|
2283
2280
|
* Path must currently be empty if this is a collection group query.
|
|
2284
2281
|
*/
|
|
2285
|
-
constructor(t,
|
|
2286
|
-
this.path = t, this.collectionGroup =
|
|
2282
|
+
constructor(t, e = null, n = [], r = [], s = null, i = "F" /* First */ , o = null, u = null) {
|
|
2283
|
+
this.path = t, this.collectionGroup = e, this.explicitOrderBy = n, this.filters = r,
|
|
2287
2284
|
this.limit = s, this.limitType = i, this.startAt = o, this.endAt = u, this.D = null,
|
|
2288
2285
|
// The corresponding `Target` of this `Query` instance.
|
|
2289
2286
|
this.$ = null, this.startAt, this.endAt;
|
|
2290
2287
|
}
|
|
2291
2288
|
}
|
|
2292
2289
|
|
|
2293
|
-
/** Creates a new Query for a query that matches all documents at `path` */ function
|
|
2290
|
+
/** Creates a new Query for a query that matches all documents at `path` */ function se(t) {
|
|
2294
2291
|
return !it(t.limit) && "L" /* Last */ === t.limitType;
|
|
2295
2292
|
}
|
|
2296
2293
|
|
|
2297
|
-
function
|
|
2294
|
+
function ie(t) {
|
|
2298
2295
|
return t.explicitOrderBy.length > 0 ? t.explicitOrderBy[0].field : null;
|
|
2299
2296
|
}
|
|
2300
2297
|
|
|
2301
|
-
function
|
|
2302
|
-
for (const
|
|
2298
|
+
function oe(t) {
|
|
2299
|
+
for (const e of t.filters) if (e.N()) return e.field;
|
|
2303
2300
|
return null;
|
|
2304
2301
|
}
|
|
2305
2302
|
|
|
@@ -2311,7 +2308,7 @@ function un(t) {
|
|
|
2311
2308
|
* Returns whether the query matches a collection group rather than a specific
|
|
2312
2309
|
* collection.
|
|
2313
2310
|
*/
|
|
2314
|
-
function
|
|
2311
|
+
function ue(t) {
|
|
2315
2312
|
return null !== t.collectionGroup;
|
|
2316
2313
|
}
|
|
2317
2314
|
|
|
@@ -2319,59 +2316,59 @@ function cn(t) {
|
|
|
2319
2316
|
* Returns the implicit order by constraint that is used to execute the Query,
|
|
2320
2317
|
* which can be different from the order by constraints the user provided (e.g.
|
|
2321
2318
|
* the SDK and backend always orders by `__name__`).
|
|
2322
|
-
*/ function
|
|
2323
|
-
const
|
|
2324
|
-
if (null ===
|
|
2325
|
-
|
|
2326
|
-
const t =
|
|
2327
|
-
if (null !== t && null ===
|
|
2319
|
+
*/ function ce(t) {
|
|
2320
|
+
const e = b(t);
|
|
2321
|
+
if (null === e.D) {
|
|
2322
|
+
e.D = [];
|
|
2323
|
+
const t = oe(e), n = ie(e);
|
|
2324
|
+
if (null !== t && null === n)
|
|
2328
2325
|
// In order to implicitly add key ordering, we must also add the
|
|
2329
2326
|
// inequality filter field for it to be a valid query.
|
|
2330
2327
|
// Note that the default inequality field and key ordering is ascending.
|
|
2331
|
-
t.isKeyField() ||
|
|
2328
|
+
t.isKeyField() || e.D.push(new te(t)), e.D.push(new te(J.keyField(), "asc" /* ASCENDING */)); else {
|
|
2332
2329
|
let t = !1;
|
|
2333
|
-
for (const
|
|
2330
|
+
for (const n of e.explicitOrderBy) e.D.push(n), n.field.isKeyField() && (t = !0);
|
|
2334
2331
|
if (!t) {
|
|
2335
2332
|
// The order of the implicit key ordering always matches the last
|
|
2336
2333
|
// explicit order by
|
|
2337
|
-
const t =
|
|
2338
|
-
|
|
2334
|
+
const t = e.explicitOrderBy.length > 0 ? e.explicitOrderBy[e.explicitOrderBy.length - 1].dir : "asc" /* ASCENDING */;
|
|
2335
|
+
e.D.push(new te(J.keyField(), t));
|
|
2339
2336
|
}
|
|
2340
2337
|
}
|
|
2341
2338
|
}
|
|
2342
|
-
return
|
|
2339
|
+
return e.D;
|
|
2343
2340
|
}
|
|
2344
2341
|
|
|
2345
2342
|
/**
|
|
2346
2343
|
* Converts this `Query` instance to it's corresponding `Target` representation.
|
|
2347
|
-
*/ function
|
|
2348
|
-
const
|
|
2349
|
-
if (!
|
|
2344
|
+
*/ function ae(t) {
|
|
2345
|
+
const e = b(t);
|
|
2346
|
+
if (!e.$) if ("F" /* First */ === e.limitType) e.$ = Bt(e.path, e.collectionGroup, ce(e), e.filters, e.limit, e.startAt, e.endAt); else {
|
|
2350
2347
|
// Flip the orderBy directions since we want the last results
|
|
2351
2348
|
const t = [];
|
|
2352
|
-
for (const
|
|
2353
|
-
const
|
|
2354
|
-
t.push(new
|
|
2349
|
+
for (const n of ce(e)) {
|
|
2350
|
+
const e = "desc" /* DESCENDING */ === n.dir ? "asc" /* ASCENDING */ : "desc" /* DESCENDING */;
|
|
2351
|
+
t.push(new te(n.field, e));
|
|
2355
2352
|
}
|
|
2356
2353
|
// We need to swap the cursors to match the now-flipped query ordering.
|
|
2357
|
-
const
|
|
2354
|
+
const n = e.endAt ? new Xt(e.endAt.position, !e.endAt.before) : null, r = e.startAt ? new Xt(e.startAt.position, !e.startAt.before) : null;
|
|
2358
2355
|
// Now return as a LimitType.First query.
|
|
2359
|
-
|
|
2356
|
+
e.$ = Bt(e.path, e.collectionGroup, t, e.filters, e.limit, n, r);
|
|
2360
2357
|
}
|
|
2361
|
-
return
|
|
2358
|
+
return e.$;
|
|
2362
2359
|
}
|
|
2363
2360
|
|
|
2364
|
-
function
|
|
2365
|
-
return function(t,
|
|
2366
|
-
if (t.limit !==
|
|
2367
|
-
if (t.orderBy.length !==
|
|
2368
|
-
for (let
|
|
2369
|
-
if (t.filters.length !==
|
|
2370
|
-
for (let s = 0; s < t.filters.length; s++) if (
|
|
2371
|
-
|
|
2372
|
-
var
|
|
2373
|
-
return t.collectionGroup ===
|
|
2374
|
-
}(
|
|
2361
|
+
function he(t, e) {
|
|
2362
|
+
return function(t, e) {
|
|
2363
|
+
if (t.limit !== e.limit) return !1;
|
|
2364
|
+
if (t.orderBy.length !== e.orderBy.length) return !1;
|
|
2365
|
+
for (let n = 0; n < t.orderBy.length; n++) if (!ee(t.orderBy[n], e.orderBy[n])) return !1;
|
|
2366
|
+
if (t.filters.length !== e.filters.length) return !1;
|
|
2367
|
+
for (let s = 0; s < t.filters.length; s++) if (n = t.filters[s], r = e.filters[s],
|
|
2368
|
+
n.op !== r.op || !n.field.isEqual(r.field) || !Dt(n.value, r.value)) return !1;
|
|
2369
|
+
var n, r;
|
|
2370
|
+
return t.collectionGroup === e.collectionGroup && !!t.path.isEqual(e.path) && !!ne(t.startAt, e.startAt) && ne(t.endAt, e.endAt);
|
|
2371
|
+
}(ae(t), ae(e)) && t.limitType === e.limitType;
|
|
2375
2372
|
}
|
|
2376
2373
|
|
|
2377
2374
|
/**
|
|
@@ -2399,10 +2396,10 @@ function ln(t, n) {
|
|
|
2399
2396
|
* The return value is an IntegerValue if it can safely represent the value,
|
|
2400
2397
|
* otherwise a DoubleValue is returned.
|
|
2401
2398
|
*/
|
|
2402
|
-
function
|
|
2399
|
+
function le(t, e) {
|
|
2403
2400
|
return function(t) {
|
|
2404
2401
|
return "number" == typeof t && Number.isInteger(t) && !ot(t) && t <= Number.MAX_SAFE_INTEGER && t >= Number.MIN_SAFE_INTEGER;
|
|
2405
|
-
}(
|
|
2402
|
+
}(e) ?
|
|
2406
2403
|
/**
|
|
2407
2404
|
* Returns an IntegerValue for `value`.
|
|
2408
2405
|
*/
|
|
@@ -2410,22 +2407,22 @@ function fn(t, n) {
|
|
|
2410
2407
|
return {
|
|
2411
2408
|
integerValue: "" + t
|
|
2412
2409
|
};
|
|
2413
|
-
}(
|
|
2410
|
+
}(e) : function(t, e) {
|
|
2414
2411
|
if (t.F) {
|
|
2415
|
-
if (isNaN(
|
|
2412
|
+
if (isNaN(e)) return {
|
|
2416
2413
|
doubleValue: "NaN"
|
|
2417
2414
|
};
|
|
2418
|
-
if (
|
|
2415
|
+
if (e === 1 / 0) return {
|
|
2419
2416
|
doubleValue: "Infinity"
|
|
2420
2417
|
};
|
|
2421
|
-
if (
|
|
2418
|
+
if (e === -1 / 0) return {
|
|
2422
2419
|
doubleValue: "-Infinity"
|
|
2423
2420
|
};
|
|
2424
2421
|
}
|
|
2425
2422
|
return {
|
|
2426
|
-
doubleValue: ot(
|
|
2423
|
+
doubleValue: ot(e) ? "-0" : e
|
|
2427
2424
|
};
|
|
2428
|
-
}(t,
|
|
2425
|
+
}(t, e);
|
|
2429
2426
|
}
|
|
2430
2427
|
|
|
2431
2428
|
/**
|
|
@@ -2444,7 +2441,7 @@ function fn(t, n) {
|
|
|
2444
2441
|
* See the License for the specific language governing permissions and
|
|
2445
2442
|
* limitations under the License.
|
|
2446
2443
|
*/
|
|
2447
|
-
/** Used to represent a field transform on a mutation. */ class
|
|
2444
|
+
/** Used to represent a field transform on a mutation. */ class fe {
|
|
2448
2445
|
constructor() {
|
|
2449
2446
|
// Make sure that the structural type of `TransformOperation` is unique.
|
|
2450
2447
|
// See https://github.com/microsoft/TypeScript/issues/5451
|
|
@@ -2452,15 +2449,15 @@ function fn(t, n) {
|
|
|
2452
2449
|
}
|
|
2453
2450
|
}
|
|
2454
2451
|
|
|
2455
|
-
/** Transforms a value into a server-generated timestamp. */ class
|
|
2452
|
+
/** Transforms a value into a server-generated timestamp. */ class de extends fe {}
|
|
2456
2453
|
|
|
2457
|
-
/** Transforms an array value via a union operation. */ class
|
|
2454
|
+
/** Transforms an array value via a union operation. */ class we extends fe {
|
|
2458
2455
|
constructor(t) {
|
|
2459
2456
|
super(), this.elements = t;
|
|
2460
2457
|
}
|
|
2461
2458
|
}
|
|
2462
2459
|
|
|
2463
|
-
/** Transforms an array value via a remove operation. */ class
|
|
2460
|
+
/** Transforms an array value via a remove operation. */ class me extends fe {
|
|
2464
2461
|
constructor(t) {
|
|
2465
2462
|
super(), this.elements = t;
|
|
2466
2463
|
}
|
|
@@ -2471,9 +2468,9 @@ function fn(t, n) {
|
|
|
2471
2468
|
* transforms. Converts all field values to integers or doubles, but unlike the
|
|
2472
2469
|
* backend does not cap integer values at 2^63. Instead, JavaScript number
|
|
2473
2470
|
* arithmetic is used and precision loss can occur for values greater than 2^53.
|
|
2474
|
-
*/ class
|
|
2475
|
-
constructor(t,
|
|
2476
|
-
super(), this.S = t, this.q =
|
|
2471
|
+
*/ class pe extends fe {
|
|
2472
|
+
constructor(t, e) {
|
|
2473
|
+
super(), this.S = t, this.q = e;
|
|
2477
2474
|
}
|
|
2478
2475
|
}
|
|
2479
2476
|
|
|
@@ -2493,9 +2490,9 @@ function fn(t, n) {
|
|
|
2493
2490
|
* See the License for the specific language governing permissions and
|
|
2494
2491
|
* limitations under the License.
|
|
2495
2492
|
*/
|
|
2496
|
-
/** A field path and the TransformOperation to perform upon it. */ class
|
|
2497
|
-
constructor(t,
|
|
2498
|
-
this.field = t, this.transform =
|
|
2493
|
+
/** A field path and the TransformOperation to perform upon it. */ class ye {
|
|
2494
|
+
constructor(t, e) {
|
|
2495
|
+
this.field = t, this.transform = e;
|
|
2499
2496
|
}
|
|
2500
2497
|
}
|
|
2501
2498
|
|
|
@@ -2503,18 +2500,18 @@ function fn(t, n) {
|
|
|
2503
2500
|
* Encodes a precondition for a mutation. This follows the model that the
|
|
2504
2501
|
* backend accepts with the special case of an explicit "empty" precondition
|
|
2505
2502
|
* (meaning no precondition).
|
|
2506
|
-
*/ class
|
|
2507
|
-
constructor(t,
|
|
2508
|
-
this.updateTime = t, this.exists =
|
|
2503
|
+
*/ class _e {
|
|
2504
|
+
constructor(t, e) {
|
|
2505
|
+
this.updateTime = t, this.exists = e;
|
|
2509
2506
|
}
|
|
2510
2507
|
/** Creates a new empty Precondition. */ static none() {
|
|
2511
|
-
return new
|
|
2508
|
+
return new _e;
|
|
2512
2509
|
}
|
|
2513
2510
|
/** Creates a new Precondition with an exists flag. */ static exists(t) {
|
|
2514
|
-
return new
|
|
2511
|
+
return new _e(void 0, t);
|
|
2515
2512
|
}
|
|
2516
2513
|
/** Creates a new Precondition based on a version a document exists at. */ static updateTime(t) {
|
|
2517
|
-
return new
|
|
2514
|
+
return new _e(t);
|
|
2518
2515
|
}
|
|
2519
2516
|
/** Returns whether this Precondition is empty. */ get isNone() {
|
|
2520
2517
|
return void 0 === this.updateTime && void 0 === this.exists;
|
|
@@ -2567,14 +2564,14 @@ function fn(t, n) {
|
|
|
2567
2564
|
* applyToLocalView() to implement the actual behavior of applying the mutation
|
|
2568
2565
|
* to some source document (see `setMutationApplyToRemoteDocument()` for an
|
|
2569
2566
|
* example).
|
|
2570
|
-
*/ class
|
|
2567
|
+
*/ class ge {}
|
|
2571
2568
|
|
|
2572
2569
|
/**
|
|
2573
2570
|
* A mutation that creates or replaces the document at the given key with the
|
|
2574
2571
|
* object value contents.
|
|
2575
|
-
*/ class
|
|
2576
|
-
constructor(t,
|
|
2577
|
-
super(), this.key = t, this.value =
|
|
2572
|
+
*/ class be extends ge {
|
|
2573
|
+
constructor(t, e, n, r = []) {
|
|
2574
|
+
super(), this.key = t, this.value = e, this.precondition = n, this.fieldTransforms = r,
|
|
2578
2575
|
this.type = 0 /* Set */;
|
|
2579
2576
|
}
|
|
2580
2577
|
}
|
|
@@ -2591,16 +2588,16 @@ function fn(t, n) {
|
|
|
2591
2588
|
* is deleted.
|
|
2592
2589
|
* * When a field is not in the mask but is in the values, the values map is
|
|
2593
2590
|
* ignored.
|
|
2594
|
-
*/ class
|
|
2595
|
-
constructor(t,
|
|
2596
|
-
super(), this.key = t, this.data =
|
|
2591
|
+
*/ class ve extends ge {
|
|
2592
|
+
constructor(t, e, n, r, s = []) {
|
|
2593
|
+
super(), this.key = t, this.data = e, this.fieldMask = n, this.precondition = r,
|
|
2597
2594
|
this.fieldTransforms = s, this.type = 1 /* Patch */;
|
|
2598
2595
|
}
|
|
2599
2596
|
}
|
|
2600
2597
|
|
|
2601
|
-
/** A mutation that deletes the document at the given key. */ class
|
|
2602
|
-
constructor(t,
|
|
2603
|
-
super(), this.key = t, this.precondition =
|
|
2598
|
+
/** A mutation that deletes the document at the given key. */ class Ee extends ge {
|
|
2599
|
+
constructor(t, e) {
|
|
2600
|
+
super(), this.key = t, this.precondition = e, this.type = 2 /* Delete */ , this.fieldTransforms = [];
|
|
2604
2601
|
}
|
|
2605
2602
|
}
|
|
2606
2603
|
|
|
@@ -2610,9 +2607,9 @@ function fn(t, n) {
|
|
|
2610
2607
|
*
|
|
2611
2608
|
* The `verify` operation is only used in Transactions, and this class serves
|
|
2612
2609
|
* primarily to facilitate serialization into protos.
|
|
2613
|
-
*/ class
|
|
2614
|
-
constructor(t,
|
|
2615
|
-
super(), this.key = t, this.precondition =
|
|
2610
|
+
*/ class Ie extends ge {
|
|
2611
|
+
constructor(t, e) {
|
|
2612
|
+
super(), this.key = t, this.precondition = e, this.type = 3 /* Verify */ , this.fieldTransforms = [];
|
|
2616
2613
|
}
|
|
2617
2614
|
}
|
|
2618
2615
|
|
|
@@ -2631,13 +2628,13 @@ function fn(t, n) {
|
|
|
2631
2628
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2632
2629
|
* See the License for the specific language governing permissions and
|
|
2633
2630
|
* limitations under the License.
|
|
2634
|
-
*/ const
|
|
2631
|
+
*/ const Te = (() => {
|
|
2635
2632
|
const t = {
|
|
2636
2633
|
asc: "ASCENDING",
|
|
2637
2634
|
desc: "DESCENDING"
|
|
2638
2635
|
};
|
|
2639
2636
|
return t;
|
|
2640
|
-
})(),
|
|
2637
|
+
})(), Ae = (() => {
|
|
2641
2638
|
const t = {
|
|
2642
2639
|
"<": "LESS_THAN",
|
|
2643
2640
|
"<=": "LESS_THAN_OR_EQUAL",
|
|
@@ -2667,9 +2664,9 @@ function fn(t, n) {
|
|
|
2667
2664
|
* TODO(klimt): We can remove the databaseId argument if we keep the full
|
|
2668
2665
|
* resource name in documents.
|
|
2669
2666
|
*/
|
|
2670
|
-
class
|
|
2671
|
-
constructor(t,
|
|
2672
|
-
this.databaseId = t, this.F =
|
|
2667
|
+
class Pe {
|
|
2668
|
+
constructor(t, e) {
|
|
2669
|
+
this.databaseId = t, this.F = e;
|
|
2673
2670
|
}
|
|
2674
2671
|
}
|
|
2675
2672
|
|
|
@@ -2684,13 +2681,13 @@ class Rn {
|
|
|
2684
2681
|
/**
|
|
2685
2682
|
* Returns a value for a Date that's appropriate to put into a proto.
|
|
2686
2683
|
*/
|
|
2687
|
-
function
|
|
2684
|
+
function Re(t, e) {
|
|
2688
2685
|
if (t.F) {
|
|
2689
|
-
return `${new Date(1e3 *
|
|
2686
|
+
return `${new Date(1e3 * e.seconds).toISOString().replace(/\.\d*/, "").replace("Z", "")}.${("000000000" + e.nanoseconds).slice(-9)}Z`;
|
|
2690
2687
|
}
|
|
2691
2688
|
return {
|
|
2692
|
-
seconds: "" +
|
|
2693
|
-
nanos:
|
|
2689
|
+
seconds: "" + e.seconds,
|
|
2690
|
+
nanos: e.nanoseconds
|
|
2694
2691
|
};
|
|
2695
2692
|
}
|
|
2696
2693
|
|
|
@@ -2699,202 +2696,202 @@ function Vn(t, n) {
|
|
|
2699
2696
|
*
|
|
2700
2697
|
* Visible for testing.
|
|
2701
2698
|
*/
|
|
2702
|
-
function
|
|
2703
|
-
return t.F ?
|
|
2699
|
+
function Ve(t, e) {
|
|
2700
|
+
return t.F ? e.toBase64() : e.toUint8Array();
|
|
2704
2701
|
}
|
|
2705
2702
|
|
|
2706
|
-
function
|
|
2707
|
-
return
|
|
2703
|
+
function Ne(t, e) {
|
|
2704
|
+
return Re(t, e.toTimestamp());
|
|
2708
2705
|
}
|
|
2709
2706
|
|
|
2710
|
-
function
|
|
2707
|
+
function De(t) {
|
|
2711
2708
|
return g(!!t), yt.fromTimestamp(function(t) {
|
|
2712
|
-
const
|
|
2713
|
-
return new pt(
|
|
2709
|
+
const e = It(t);
|
|
2710
|
+
return new pt(e.seconds, e.nanos);
|
|
2714
2711
|
}(t));
|
|
2715
2712
|
}
|
|
2716
2713
|
|
|
2717
|
-
function
|
|
2714
|
+
function $e(t, e) {
|
|
2718
2715
|
return function(t) {
|
|
2719
2716
|
return new Y([ "projects", t.projectId, "databases", t.database ]);
|
|
2720
|
-
}(t).child("documents").child(
|
|
2717
|
+
}(t).child("documents").child(e).canonicalString();
|
|
2721
2718
|
}
|
|
2722
2719
|
|
|
2723
|
-
function
|
|
2724
|
-
return
|
|
2720
|
+
function Fe(t, e) {
|
|
2721
|
+
return $e(t.databaseId, e.path);
|
|
2725
2722
|
}
|
|
2726
2723
|
|
|
2727
|
-
function
|
|
2728
|
-
const
|
|
2729
|
-
const
|
|
2730
|
-
return g(
|
|
2731
|
-
}(
|
|
2732
|
-
if (
|
|
2733
|
-
if (
|
|
2734
|
-
return new Z((g((r =
|
|
2724
|
+
function Se(t, e) {
|
|
2725
|
+
const n = function(t) {
|
|
2726
|
+
const e = Y.fromString(t);
|
|
2727
|
+
return g(ze(e)), e;
|
|
2728
|
+
}(e);
|
|
2729
|
+
if (n.get(1) !== t.databaseId.projectId) throw new L(T, "Tried to deserialize key from different project: " + n.get(1) + " vs " + t.databaseId.projectId);
|
|
2730
|
+
if (n.get(3) !== t.databaseId.database) throw new L(T, "Tried to deserialize key from different database: " + n.get(3) + " vs " + t.databaseId.database);
|
|
2731
|
+
return new Z((g((r = n).length > 4 && "documents" === r.get(4)), r.popFirst(5)));
|
|
2735
2732
|
var r;
|
|
2736
2733
|
/** Creates a Document proto from key and fields (but no create/update time) */}
|
|
2737
2734
|
|
|
2738
|
-
function
|
|
2739
|
-
return
|
|
2735
|
+
function qe(t, e) {
|
|
2736
|
+
return $e(t.databaseId, e);
|
|
2740
2737
|
}
|
|
2741
2738
|
|
|
2742
|
-
function
|
|
2739
|
+
function xe(t) {
|
|
2743
2740
|
return new Y([ "projects", t.databaseId.projectId, "databases", t.databaseId.database ]).canonicalString();
|
|
2744
2741
|
}
|
|
2745
2742
|
|
|
2746
|
-
function
|
|
2743
|
+
function Oe(t, e, n) {
|
|
2747
2744
|
return {
|
|
2748
|
-
name:
|
|
2749
|
-
fields:
|
|
2745
|
+
name: Fe(t, e),
|
|
2746
|
+
fields: n.value.mapValue.fields
|
|
2750
2747
|
};
|
|
2751
2748
|
}
|
|
2752
2749
|
|
|
2753
|
-
function
|
|
2754
|
-
return "found" in
|
|
2755
|
-
g(!!
|
|
2756
|
-
const
|
|
2750
|
+
function Ce(t, e) {
|
|
2751
|
+
return "found" in e ? function(t, e) {
|
|
2752
|
+
g(!!e.found), e.found.name, e.found.updateTime;
|
|
2753
|
+
const n = Se(t, e.found.name), r = De(e.found.updateTime), s = new jt({
|
|
2757
2754
|
mapValue: {
|
|
2758
|
-
fields:
|
|
2755
|
+
fields: e.found.fields
|
|
2759
2756
|
}
|
|
2760
2757
|
});
|
|
2761
|
-
return kt.newFoundDocument(
|
|
2762
|
-
}(t,
|
|
2763
|
-
g(!!
|
|
2764
|
-
const
|
|
2765
|
-
return kt.newNoDocument(
|
|
2766
|
-
}(t,
|
|
2767
|
-
}
|
|
2768
|
-
|
|
2769
|
-
function
|
|
2770
|
-
let
|
|
2771
|
-
if (
|
|
2772
|
-
update:
|
|
2773
|
-
}; else if (
|
|
2774
|
-
delete:
|
|
2775
|
-
}; else if (
|
|
2776
|
-
update:
|
|
2777
|
-
updateMask:
|
|
2758
|
+
return kt.newFoundDocument(n, r, s);
|
|
2759
|
+
}(t, e) : "missing" in e ? function(t, e) {
|
|
2760
|
+
g(!!e.missing), g(!!e.readTime);
|
|
2761
|
+
const n = Se(t, e.missing), r = De(e.readTime);
|
|
2762
|
+
return kt.newNoDocument(n, r);
|
|
2763
|
+
}(t, e) : _();
|
|
2764
|
+
}
|
|
2765
|
+
|
|
2766
|
+
function Le(t, e) {
|
|
2767
|
+
let n;
|
|
2768
|
+
if (e instanceof be) n = {
|
|
2769
|
+
update: Oe(t, e.key, e.value)
|
|
2770
|
+
}; else if (e instanceof Ee) n = {
|
|
2771
|
+
delete: Fe(t, e.key)
|
|
2772
|
+
}; else if (e instanceof ve) n = {
|
|
2773
|
+
update: Oe(t, e.key, e.data),
|
|
2774
|
+
updateMask: Qe(e.fieldMask)
|
|
2778
2775
|
}; else {
|
|
2779
|
-
if (!(
|
|
2780
|
-
|
|
2781
|
-
verify:
|
|
2776
|
+
if (!(e instanceof Ie)) return _();
|
|
2777
|
+
n = {
|
|
2778
|
+
verify: Fe(t, e.key)
|
|
2782
2779
|
};
|
|
2783
2780
|
}
|
|
2784
|
-
return
|
|
2785
|
-
const
|
|
2786
|
-
if (
|
|
2787
|
-
fieldPath:
|
|
2781
|
+
return e.fieldTransforms.length > 0 && (n.updateTransforms = e.fieldTransforms.map((t => function(t, e) {
|
|
2782
|
+
const n = e.transform;
|
|
2783
|
+
if (n instanceof de) return {
|
|
2784
|
+
fieldPath: e.field.canonicalString(),
|
|
2788
2785
|
setToServerValue: "REQUEST_TIME"
|
|
2789
2786
|
};
|
|
2790
|
-
if (
|
|
2791
|
-
fieldPath:
|
|
2787
|
+
if (n instanceof we) return {
|
|
2788
|
+
fieldPath: e.field.canonicalString(),
|
|
2792
2789
|
appendMissingElements: {
|
|
2793
|
-
values:
|
|
2790
|
+
values: n.elements
|
|
2794
2791
|
}
|
|
2795
2792
|
};
|
|
2796
|
-
if (
|
|
2797
|
-
fieldPath:
|
|
2793
|
+
if (n instanceof me) return {
|
|
2794
|
+
fieldPath: e.field.canonicalString(),
|
|
2798
2795
|
removeAllFromArray: {
|
|
2799
|
-
values:
|
|
2796
|
+
values: n.elements
|
|
2800
2797
|
}
|
|
2801
2798
|
};
|
|
2802
|
-
if (
|
|
2803
|
-
fieldPath:
|
|
2804
|
-
increment:
|
|
2799
|
+
if (n instanceof pe) return {
|
|
2800
|
+
fieldPath: e.field.canonicalString(),
|
|
2801
|
+
increment: n.q
|
|
2805
2802
|
};
|
|
2806
2803
|
throw _();
|
|
2807
|
-
}(0, t)))),
|
|
2808
|
-
return void 0 !==
|
|
2809
|
-
updateTime:
|
|
2810
|
-
} : void 0 !==
|
|
2811
|
-
exists:
|
|
2804
|
+
}(0, t)))), e.precondition.isNone || (n.currentDocument = function(t, e) {
|
|
2805
|
+
return void 0 !== e.updateTime ? {
|
|
2806
|
+
updateTime: Ne(t, e.updateTime)
|
|
2807
|
+
} : void 0 !== e.exists ? {
|
|
2808
|
+
exists: e.exists
|
|
2812
2809
|
} : _();
|
|
2813
|
-
}(t,
|
|
2810
|
+
}(t, e.precondition)), n;
|
|
2814
2811
|
}
|
|
2815
2812
|
|
|
2816
|
-
function
|
|
2813
|
+
function Ue(t, e) {
|
|
2817
2814
|
// Dissect the path into parent, collectionId, and optional key filter.
|
|
2818
|
-
const
|
|
2815
|
+
const n = {
|
|
2819
2816
|
structuredQuery: {}
|
|
2820
|
-
}, r =
|
|
2821
|
-
null !==
|
|
2822
|
-
collectionId:
|
|
2817
|
+
}, r = e.path;
|
|
2818
|
+
null !== e.collectionGroup ? (n.parent = qe(t, r), n.structuredQuery.from = [ {
|
|
2819
|
+
collectionId: e.collectionGroup,
|
|
2823
2820
|
allDescendants: !0
|
|
2824
|
-
} ]) : (
|
|
2821
|
+
} ]) : (n.parent = qe(t, r.popLast()), n.structuredQuery.from = [ {
|
|
2825
2822
|
collectionId: r.lastSegment()
|
|
2826
2823
|
} ]);
|
|
2827
2824
|
const s = function(t) {
|
|
2828
2825
|
if (0 === t.length) return;
|
|
2829
|
-
const
|
|
2826
|
+
const e = t.map((t =>
|
|
2830
2827
|
// visible for testing
|
|
2831
2828
|
function(t) {
|
|
2832
2829
|
if ("==" /* EQUAL */ === t.op) {
|
|
2833
2830
|
if (Ct(t.value)) return {
|
|
2834
2831
|
unaryFilter: {
|
|
2835
|
-
field:
|
|
2832
|
+
field: Be(t.field),
|
|
2836
2833
|
op: "IS_NAN"
|
|
2837
2834
|
}
|
|
2838
2835
|
};
|
|
2839
2836
|
if (Ot(t.value)) return {
|
|
2840
2837
|
unaryFilter: {
|
|
2841
|
-
field:
|
|
2838
|
+
field: Be(t.field),
|
|
2842
2839
|
op: "IS_NULL"
|
|
2843
2840
|
}
|
|
2844
2841
|
};
|
|
2845
2842
|
} else if ("!=" /* NOT_EQUAL */ === t.op) {
|
|
2846
2843
|
if (Ct(t.value)) return {
|
|
2847
2844
|
unaryFilter: {
|
|
2848
|
-
field:
|
|
2845
|
+
field: Be(t.field),
|
|
2849
2846
|
op: "IS_NOT_NAN"
|
|
2850
2847
|
}
|
|
2851
2848
|
};
|
|
2852
2849
|
if (Ot(t.value)) return {
|
|
2853
2850
|
unaryFilter: {
|
|
2854
|
-
field:
|
|
2851
|
+
field: Be(t.field),
|
|
2855
2852
|
op: "IS_NOT_NULL"
|
|
2856
2853
|
}
|
|
2857
2854
|
};
|
|
2858
2855
|
}
|
|
2859
2856
|
return {
|
|
2860
2857
|
fieldFilter: {
|
|
2861
|
-
field:
|
|
2862
|
-
op:
|
|
2858
|
+
field: Be(t.field),
|
|
2859
|
+
op: Me(t.op),
|
|
2863
2860
|
value: t.value
|
|
2864
2861
|
}
|
|
2865
2862
|
};
|
|
2866
2863
|
}(t)));
|
|
2867
|
-
if (1 ===
|
|
2864
|
+
if (1 === e.length) return e[0];
|
|
2868
2865
|
return {
|
|
2869
2866
|
compositeFilter: {
|
|
2870
2867
|
op: "AND",
|
|
2871
|
-
filters:
|
|
2868
|
+
filters: e
|
|
2872
2869
|
}
|
|
2873
2870
|
};
|
|
2874
|
-
}(
|
|
2875
|
-
s && (
|
|
2871
|
+
}(e.filters);
|
|
2872
|
+
s && (n.structuredQuery.where = s);
|
|
2876
2873
|
const i = function(t) {
|
|
2877
2874
|
if (0 === t.length) return;
|
|
2878
2875
|
return t.map((t =>
|
|
2879
2876
|
// visible for testing
|
|
2880
2877
|
function(t) {
|
|
2881
2878
|
return {
|
|
2882
|
-
field:
|
|
2883
|
-
direction:
|
|
2879
|
+
field: Be(t.field),
|
|
2880
|
+
direction: ke(t.dir)
|
|
2884
2881
|
};
|
|
2885
2882
|
}(t)));
|
|
2886
|
-
}(
|
|
2887
|
-
i && (
|
|
2888
|
-
const o = function(t,
|
|
2889
|
-
return t.F || it(
|
|
2890
|
-
value:
|
|
2883
|
+
}(e.orderBy);
|
|
2884
|
+
i && (n.structuredQuery.orderBy = i);
|
|
2885
|
+
const o = function(t, e) {
|
|
2886
|
+
return t.F || it(e) ? e : {
|
|
2887
|
+
value: e
|
|
2891
2888
|
};
|
|
2892
|
-
}(t,
|
|
2893
|
-
return null !== o && (
|
|
2894
|
-
|
|
2889
|
+
}(t, e.limit);
|
|
2890
|
+
return null !== o && (n.structuredQuery.limit = o), e.startAt && (n.structuredQuery.startAt = je(e.startAt)),
|
|
2891
|
+
e.endAt && (n.structuredQuery.endAt = je(e.endAt)), n;
|
|
2895
2892
|
}
|
|
2896
2893
|
|
|
2897
|
-
function
|
|
2894
|
+
function je(t) {
|
|
2898
2895
|
return {
|
|
2899
2896
|
before: t.before,
|
|
2900
2897
|
values: t.position
|
|
@@ -2902,29 +2899,29 @@ function kn(t) {
|
|
|
2902
2899
|
}
|
|
2903
2900
|
|
|
2904
2901
|
// visible for testing
|
|
2905
|
-
function
|
|
2906
|
-
return
|
|
2902
|
+
function ke(t) {
|
|
2903
|
+
return Te[t];
|
|
2907
2904
|
}
|
|
2908
2905
|
|
|
2909
2906
|
// visible for testing
|
|
2910
|
-
function
|
|
2911
|
-
return
|
|
2907
|
+
function Me(t) {
|
|
2908
|
+
return Ae[t];
|
|
2912
2909
|
}
|
|
2913
2910
|
|
|
2914
|
-
function
|
|
2911
|
+
function Be(t) {
|
|
2915
2912
|
return {
|
|
2916
2913
|
fieldPath: t.canonicalString()
|
|
2917
2914
|
};
|
|
2918
2915
|
}
|
|
2919
2916
|
|
|
2920
|
-
function
|
|
2921
|
-
const
|
|
2922
|
-
return t.fields.forEach((t =>
|
|
2923
|
-
fieldPaths:
|
|
2917
|
+
function Qe(t) {
|
|
2918
|
+
const e = [];
|
|
2919
|
+
return t.fields.forEach((t => e.push(t.canonicalString()))), {
|
|
2920
|
+
fieldPaths: e
|
|
2924
2921
|
};
|
|
2925
2922
|
}
|
|
2926
2923
|
|
|
2927
|
-
function
|
|
2924
|
+
function ze(t) {
|
|
2928
2925
|
// Resource names have at least 4 components (project ID, database ID)
|
|
2929
2926
|
return t.length >= 4 && "projects" === t.get(0) && "databases" === t.get(2);
|
|
2930
2927
|
}
|
|
@@ -2944,8 +2941,8 @@ function Wn(t) {
|
|
|
2944
2941
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2945
2942
|
* See the License for the specific language governing permissions and
|
|
2946
2943
|
* limitations under the License.
|
|
2947
|
-
*/ function
|
|
2948
|
-
return new
|
|
2944
|
+
*/ function We(t) {
|
|
2945
|
+
return new Pe(t, /* useProto3Json= */ !0);
|
|
2949
2946
|
}
|
|
2950
2947
|
|
|
2951
2948
|
/**
|
|
@@ -2973,7 +2970,7 @@ function Wn(t) {
|
|
|
2973
2970
|
* base delay. This prevents clients from accidentally synchronizing their
|
|
2974
2971
|
* delays causing spikes of load to the backend.
|
|
2975
2972
|
*/
|
|
2976
|
-
class
|
|
2973
|
+
class Ge {
|
|
2977
2974
|
constructor(
|
|
2978
2975
|
/**
|
|
2979
2976
|
* The AsyncQueue to run backoff operations on.
|
|
@@ -2982,13 +2979,13 @@ class Hn {
|
|
|
2982
2979
|
/**
|
|
2983
2980
|
* The ID to use when scheduling backoff operations on the AsyncQueue.
|
|
2984
2981
|
*/
|
|
2985
|
-
|
|
2982
|
+
e,
|
|
2986
2983
|
/**
|
|
2987
2984
|
* The initial delay (used as the base delay on the first retry attempt).
|
|
2988
2985
|
* Note that jitter will still be applied, so the actual delay could be as
|
|
2989
2986
|
* little as 0.5*initialDelayMs.
|
|
2990
2987
|
*/
|
|
2991
|
-
|
|
2988
|
+
n = 1e3
|
|
2992
2989
|
/**
|
|
2993
2990
|
* The multiplier to use to determine the extended base delay after each
|
|
2994
2991
|
* attempt.
|
|
@@ -2998,7 +2995,7 @@ class Hn {
|
|
|
2998
2995
|
* Note that jitter will still be applied, so the actual delay could be as
|
|
2999
2996
|
* much as 1.5*maxDelayMs.
|
|
3000
2997
|
*/ , s = 6e4) {
|
|
3001
|
-
this.O = t, this.timerId =
|
|
2998
|
+
this.O = t, this.timerId = e, this.C = n, this.L = r, this.U = s, this.j = 0, this.k = null,
|
|
3002
2999
|
/** The last backoff attempt, as epoch milliseconds. */
|
|
3003
3000
|
this.M = Date.now(), this.reset();
|
|
3004
3001
|
}
|
|
@@ -3026,9 +3023,9 @@ class Hn {
|
|
|
3026
3023
|
this.cancel();
|
|
3027
3024
|
// First schedule using the current base (which may be 0 and should be
|
|
3028
3025
|
// honored as such).
|
|
3029
|
-
const
|
|
3026
|
+
const e = Math.floor(this.j + this.G()), n = Math.max(0, Date.now() - this.M), r = Math.max(0, e - n);
|
|
3030
3027
|
// Guard against lastAttemptTime being in the future due to a clock change.
|
|
3031
|
-
r > 0 && w("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.j} ms, delay with jitter: ${
|
|
3028
|
+
r > 0 && w("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.j} ms, delay with jitter: ${e} ms, last attempt: ${n} ms ago)`),
|
|
3032
3029
|
this.k = this.O.enqueueAfterDelay(this.timerId, r, (() => (this.M = Date.now(),
|
|
3033
3030
|
t()))),
|
|
3034
3031
|
// Apply backoff factor to determine next delay and ensure it is within
|
|
@@ -3071,21 +3068,21 @@ class Hn {
|
|
|
3071
3068
|
* An implementation of Datastore that exposes additional state for internal
|
|
3072
3069
|
* consumption.
|
|
3073
3070
|
*/
|
|
3074
|
-
class
|
|
3075
|
-
constructor(t,
|
|
3076
|
-
super(), this.credentials = t, this.Y =
|
|
3071
|
+
class He extends class {} {
|
|
3072
|
+
constructor(t, e, n) {
|
|
3073
|
+
super(), this.credentials = t, this.Y = e, this.S = n, this.K = !1;
|
|
3077
3074
|
}
|
|
3078
3075
|
J() {
|
|
3079
3076
|
if (this.K) throw new L($, "The client has already been terminated.");
|
|
3080
3077
|
}
|
|
3081
|
-
/** Gets an auth token and invokes the provided RPC. */ l(t,
|
|
3082
|
-
return this.J(), this.credentials.getToken().then((r => this.Y.l(t,
|
|
3078
|
+
/** Gets an auth token and invokes the provided RPC. */ l(t, e, n) {
|
|
3079
|
+
return this.J(), this.credentials.getToken().then((r => this.Y.l(t, e, n, r))).catch((t => {
|
|
3083
3080
|
throw "FirebaseError" === t.name ? (t.code === N && this.credentials.invalidateToken(),
|
|
3084
3081
|
t) : new L(I, t.toString());
|
|
3085
3082
|
}));
|
|
3086
3083
|
}
|
|
3087
|
-
/** Gets an auth token and invokes the provided RPC with streamed results. */ v(t,
|
|
3088
|
-
return this.J(), this.credentials.getToken().then((r => this.Y.v(t,
|
|
3084
|
+
/** Gets an auth token and invokes the provided RPC with streamed results. */ v(t, e, n) {
|
|
3085
|
+
return this.J(), this.credentials.getToken().then((r => this.Y.v(t, e, n, r))).catch((t => {
|
|
3089
3086
|
throw "FirebaseError" === t.name ? (t.code === N && this.credentials.invalidateToken(),
|
|
3090
3087
|
t) : new L(I, t.toString());
|
|
3091
3088
|
}));
|
|
@@ -3097,40 +3094,40 @@ class Yn extends class {} {
|
|
|
3097
3094
|
|
|
3098
3095
|
// TODO(firestorexp): Make sure there is only one Datastore instance per
|
|
3099
3096
|
// firestore-exp client.
|
|
3100
|
-
async function
|
|
3101
|
-
const
|
|
3102
|
-
writes:
|
|
3097
|
+
async function Ye(t, e) {
|
|
3098
|
+
const n = b(t), r = xe(n.S) + "/documents", s = {
|
|
3099
|
+
writes: e.map((t => Le(n.S, t)))
|
|
3103
3100
|
};
|
|
3104
|
-
await
|
|
3101
|
+
await n.l("Commit", r, s);
|
|
3105
3102
|
}
|
|
3106
3103
|
|
|
3107
|
-
async function
|
|
3108
|
-
const
|
|
3109
|
-
documents:
|
|
3110
|
-
}, i = await
|
|
3104
|
+
async function Ke(t, e) {
|
|
3105
|
+
const n = b(t), r = xe(n.S) + "/documents", s = {
|
|
3106
|
+
documents: e.map((t => Fe(n.S, t)))
|
|
3107
|
+
}, i = await n.v("BatchGetDocuments", r, s), o = new Map;
|
|
3111
3108
|
i.forEach((t => {
|
|
3112
|
-
const
|
|
3113
|
-
o.set(
|
|
3109
|
+
const e = Ce(n.S, t);
|
|
3110
|
+
o.set(e.key.toString(), e);
|
|
3114
3111
|
}));
|
|
3115
3112
|
const u = [];
|
|
3116
|
-
return
|
|
3117
|
-
const
|
|
3118
|
-
g(!!
|
|
3113
|
+
return e.forEach((t => {
|
|
3114
|
+
const e = o.get(t.toString());
|
|
3115
|
+
g(!!e), u.push(e);
|
|
3119
3116
|
})), u;
|
|
3120
3117
|
}
|
|
3121
3118
|
|
|
3122
|
-
async function
|
|
3123
|
-
const
|
|
3124
|
-
return (await
|
|
3119
|
+
async function Je(t, e) {
|
|
3120
|
+
const n = b(t), r = Ue(n.S, ae(e));
|
|
3121
|
+
return (await n.v("RunQuery", r.parent, {
|
|
3125
3122
|
structuredQuery: r.structuredQuery
|
|
3126
|
-
})).filter((t => !!t.document)).map((t => function(t,
|
|
3127
|
-
const r =
|
|
3123
|
+
})).filter((t => !!t.document)).map((t => function(t, e, n) {
|
|
3124
|
+
const r = Se(t, e.name), s = De(e.updateTime), i = new jt({
|
|
3128
3125
|
mapValue: {
|
|
3129
|
-
fields:
|
|
3126
|
+
fields: e.fields
|
|
3130
3127
|
}
|
|
3131
3128
|
}), o = kt.newFoundDocument(r, s, i);
|
|
3132
|
-
return
|
|
3133
|
-
}(
|
|
3129
|
+
return n && o.setHasCommittedMutations(), n ? o.setHasCommittedMutations() : o;
|
|
3130
|
+
}(n.S, t.document, void 0)));
|
|
3134
3131
|
}
|
|
3135
3132
|
|
|
3136
3133
|
/**
|
|
@@ -3148,7 +3145,7 @@ async function Zn(t, n) {
|
|
|
3148
3145
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3149
3146
|
* See the License for the specific language governing permissions and
|
|
3150
3147
|
* limitations under the License.
|
|
3151
|
-
*/ const
|
|
3148
|
+
*/ const Ze = new Map;
|
|
3152
3149
|
|
|
3153
3150
|
/**
|
|
3154
3151
|
* An instance map that ensures only one Datastore exists per Firestore
|
|
@@ -3159,19 +3156,19 @@ async function Zn(t, n) {
|
|
|
3159
3156
|
* instance. Callers must invoke removeComponents() when the Firestore
|
|
3160
3157
|
* instance is terminated.
|
|
3161
3158
|
*/
|
|
3162
|
-
function
|
|
3159
|
+
function Xe(t) {
|
|
3163
3160
|
if (t._terminated) throw new L($, "The client has already been terminated.");
|
|
3164
|
-
if (!
|
|
3161
|
+
if (!Ze.has(t)) {
|
|
3165
3162
|
w("ComponentProvider", "Initializing Datastore");
|
|
3166
3163
|
const i = function(t) {
|
|
3167
3164
|
return new lt(t, fetch.bind(null));
|
|
3168
|
-
}((
|
|
3169
|
-
new W(
|
|
3170
|
-
return new
|
|
3165
|
+
}((e = t._databaseId, n = t.app.options.appId || "", r = t._persistenceKey, s = t._freezeSettings(),
|
|
3166
|
+
new W(e, n, r, s.host, s.ssl, s.experimentalForceLongPolling, s.experimentalAutoDetectLongPolling, s.useFetchStreams))), o = We(t._databaseId), u = function(t, e, n) {
|
|
3167
|
+
return new He(t, e, n);
|
|
3171
3168
|
}(t._credentials, i, o);
|
|
3172
|
-
|
|
3169
|
+
Ze.set(t, u);
|
|
3173
3170
|
}
|
|
3174
|
-
var
|
|
3171
|
+
var e, n, r, s;
|
|
3175
3172
|
/**
|
|
3176
3173
|
* @license
|
|
3177
3174
|
* Copyright 2018 Google LLC
|
|
@@ -3187,7 +3184,7 @@ function te(t) {
|
|
|
3187
3184
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3188
3185
|
* See the License for the specific language governing permissions and
|
|
3189
3186
|
* limitations under the License.
|
|
3190
|
-
*/ return
|
|
3187
|
+
*/ return Ze.get(t);
|
|
3191
3188
|
}
|
|
3192
3189
|
|
|
3193
3190
|
/**
|
|
@@ -3199,21 +3196,21 @@ function te(t) {
|
|
|
3199
3196
|
* user-supplied `FirestoreSettings` object. This is a separate type so that
|
|
3200
3197
|
* defaults can be supplied and the value can be checked for equality.
|
|
3201
3198
|
*/
|
|
3202
|
-
class
|
|
3199
|
+
class tn {
|
|
3203
3200
|
constructor(t) {
|
|
3204
|
-
var
|
|
3201
|
+
var e;
|
|
3205
3202
|
if (void 0 === t.host) {
|
|
3206
3203
|
if (void 0 !== t.ssl) throw new L(T, "Can't provide ssl option if host option is not set");
|
|
3207
3204
|
this.host = "firestore.googleapis.com", this.ssl = true;
|
|
3208
|
-
} else this.host = t.host, this.ssl = null === (
|
|
3205
|
+
} else this.host = t.host, this.ssl = null === (e = t.ssl) || void 0 === e || e;
|
|
3209
3206
|
if (this.credentials = t.credentials, this.ignoreUndefinedProperties = !!t.ignoreUndefinedProperties,
|
|
3210
3207
|
void 0 === t.cacheSizeBytes) this.cacheSizeBytes = 41943040; else {
|
|
3211
3208
|
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new L(T, "cacheSizeBytes must be at least 1048576");
|
|
3212
3209
|
this.cacheSizeBytes = t.cacheSizeBytes;
|
|
3213
3210
|
}
|
|
3214
3211
|
this.experimentalForceLongPolling = !!t.experimentalForceLongPolling, this.experimentalAutoDetectLongPolling = !!t.experimentalAutoDetectLongPolling,
|
|
3215
|
-
this.useFetchStreams = !!t.useFetchStreams, function(t,
|
|
3216
|
-
if (!0 ===
|
|
3212
|
+
this.useFetchStreams = !!t.useFetchStreams, function(t, e, n, r) {
|
|
3213
|
+
if (!0 === e && !0 === r) throw new L(T, `${t} and ${n} cannot be used together.`);
|
|
3217
3214
|
}("experimentalForceLongPolling", t.experimentalForceLongPolling, "experimentalAutoDetectLongPolling", t.experimentalAutoDetectLongPolling);
|
|
3218
3215
|
}
|
|
3219
3216
|
isEqual(t) {
|
|
@@ -3241,14 +3238,14 @@ class ne {
|
|
|
3241
3238
|
* The Cloud Firestore service interface.
|
|
3242
3239
|
*
|
|
3243
3240
|
* Do not call this constructor directly. Instead, use {@link getFirestore}.
|
|
3244
|
-
*/ class
|
|
3241
|
+
*/ class en {
|
|
3245
3242
|
/** @hideconstructor */
|
|
3246
|
-
constructor(t,
|
|
3247
|
-
this._credentials =
|
|
3243
|
+
constructor(t, e) {
|
|
3244
|
+
this._credentials = e,
|
|
3248
3245
|
/**
|
|
3249
3246
|
* Whether it's a Firestore or Firestore Lite instance.
|
|
3250
3247
|
*/
|
|
3251
|
-
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new
|
|
3248
|
+
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new tn({}),
|
|
3252
3249
|
this._settingsFrozen = !1, t instanceof G ? this._databaseId = t : (this._app = t,
|
|
3253
3250
|
this._databaseId = function(t) {
|
|
3254
3251
|
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new L(T, '"projectId" not provided in firebase.initializeApp.');
|
|
@@ -3281,14 +3278,14 @@ class ne {
|
|
|
3281
3278
|
}
|
|
3282
3279
|
_setSettings(t) {
|
|
3283
3280
|
if (this._settingsFrozen) throw new L($, "Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");
|
|
3284
|
-
this._settings = new
|
|
3281
|
+
this._settings = new tn(t), void 0 !== t.credentials && (this._credentials = function(t) {
|
|
3285
3282
|
if (!t) return new k;
|
|
3286
3283
|
switch (t.type) {
|
|
3287
3284
|
case "gapi":
|
|
3288
|
-
const
|
|
3285
|
+
const e = t.client;
|
|
3289
3286
|
// Make sure this really is a Gapi client.
|
|
3290
|
-
return g(!("object" != typeof
|
|
3291
|
-
new z(
|
|
3287
|
+
return g(!("object" != typeof e || null === e || !e.auth || !e.auth.getAuthHeaderValueForFirstParty)),
|
|
3288
|
+
new z(e, t.sessionIndex || "0", t.iamToken || null);
|
|
3292
3289
|
|
|
3293
3290
|
case "provider":
|
|
3294
3291
|
return t.client;
|
|
@@ -3322,17 +3319,17 @@ class ne {
|
|
|
3322
3319
|
* Only ever called once.
|
|
3323
3320
|
*/ _terminate() {
|
|
3324
3321
|
return function(t) {
|
|
3325
|
-
const
|
|
3326
|
-
|
|
3322
|
+
const e = Ze.get(t);
|
|
3323
|
+
e && (w("ComponentProvider", "Removing Datastore"), Ze.delete(t), e.terminate());
|
|
3327
3324
|
}(this), Promise.resolve();
|
|
3328
3325
|
}
|
|
3329
3326
|
}
|
|
3330
3327
|
|
|
3331
|
-
function
|
|
3332
|
-
const
|
|
3333
|
-
if (
|
|
3334
|
-
return
|
|
3335
|
-
options:
|
|
3328
|
+
function nn(t, e) {
|
|
3329
|
+
const n = _getProvider(t, "firestore/lite");
|
|
3330
|
+
if (n.isInitialized()) throw new L($, "Firestore can only be initialized once per app.");
|
|
3331
|
+
return n.initialize({
|
|
3332
|
+
options: e
|
|
3336
3333
|
});
|
|
3337
3334
|
}
|
|
3338
3335
|
|
|
@@ -3344,8 +3341,8 @@ function re(t, n) {
|
|
|
3344
3341
|
* @param app - The {@link @firebase/app#FirebaseApp} instance that the returned `Firestore`
|
|
3345
3342
|
* instance is associated with.
|
|
3346
3343
|
* @returns The `Firestore` instance of the provided app.
|
|
3347
|
-
*/ function
|
|
3348
|
-
return _getProvider(
|
|
3344
|
+
*/ function rn(e = t()) {
|
|
3345
|
+
return _getProvider(e, "firestore/lite").getImmediate();
|
|
3349
3346
|
}
|
|
3350
3347
|
|
|
3351
3348
|
/**
|
|
@@ -3360,24 +3357,24 @@ function re(t, n) {
|
|
|
3360
3357
|
* @param port - the emulator port (ex: 9000).
|
|
3361
3358
|
* @param options.mockUserToken - the mock auth token to use for unit testing
|
|
3362
3359
|
* Security Rules.
|
|
3363
|
-
*/ function
|
|
3360
|
+
*/ function sn(t, e, n, r = {}) {
|
|
3364
3361
|
var s;
|
|
3365
|
-
const i = (t = rt(t,
|
|
3366
|
-
if ("firestore.googleapis.com" !== i.host && i.host !==
|
|
3362
|
+
const i = (t = rt(t, en))._getSettings();
|
|
3363
|
+
if ("firestore.googleapis.com" !== i.host && i.host !== e && p("Host has been set in both settings() and useEmulator(), emulator host will be used"),
|
|
3367
3364
|
t._setSettings(Object.assign(Object.assign({}, i), {
|
|
3368
|
-
host: `${
|
|
3365
|
+
host: `${e}:${n}`,
|
|
3369
3366
|
ssl: !1
|
|
3370
3367
|
})), r.mockUserToken) {
|
|
3371
|
-
let
|
|
3372
|
-
if ("string" == typeof r.mockUserToken)
|
|
3368
|
+
let e, n;
|
|
3369
|
+
if ("string" == typeof r.mockUserToken) e = r.mockUserToken, n = h.MOCK_USER; else {
|
|
3373
3370
|
// Let createMockUserToken validate first (catches common mistakes like
|
|
3374
3371
|
// invalid field "uid" and missing field "sub" / "user_id".)
|
|
3375
|
-
|
|
3372
|
+
e = c(r.mockUserToken, null === (s = t._app) || void 0 === s ? void 0 : s.options.projectId);
|
|
3376
3373
|
const i = r.mockUserToken.sub || r.mockUserToken.user_id;
|
|
3377
3374
|
if (!i) throw new L(T, "mockUserToken must contain 'sub' or 'user_id' field!");
|
|
3378
|
-
|
|
3375
|
+
n = new h(i);
|
|
3379
3376
|
}
|
|
3380
|
-
t._credentials = new M(new j(
|
|
3377
|
+
t._credentials = new M(new j(e, n));
|
|
3381
3378
|
}
|
|
3382
3379
|
}
|
|
3383
3380
|
|
|
@@ -3400,8 +3397,8 @@ function re(t, n) {
|
|
|
3400
3397
|
* @param firestore - The `Firestore` instance to terminate.
|
|
3401
3398
|
* @returns A `Promise` that is resolved when the instance has been successfully
|
|
3402
3399
|
* terminated.
|
|
3403
|
-
*/ function
|
|
3404
|
-
return t = rt(t,
|
|
3400
|
+
*/ function on(t) {
|
|
3401
|
+
return t = rt(t, en), e(t.app, "firestore/lite"), t._delete();
|
|
3405
3402
|
}
|
|
3406
3403
|
|
|
3407
3404
|
/**
|
|
@@ -3441,14 +3438,14 @@ function re(t, n) {
|
|
|
3441
3438
|
* and can be used to write, read, or listen to the location. The document at
|
|
3442
3439
|
* the referenced location may or may not exist.
|
|
3443
3440
|
*/
|
|
3444
|
-
class
|
|
3441
|
+
class un {
|
|
3445
3442
|
/** @hideconstructor */
|
|
3446
3443
|
constructor(t,
|
|
3447
3444
|
/**
|
|
3448
3445
|
* If provided, the `FirestoreDataConverter` associated with this instance.
|
|
3449
3446
|
*/
|
|
3450
|
-
|
|
3451
|
-
this.converter =
|
|
3447
|
+
e, n) {
|
|
3448
|
+
this.converter = e, this._key = n,
|
|
3452
3449
|
/** The type of this Firestore reference. */
|
|
3453
3450
|
this.type = "document", this.firestore = t;
|
|
3454
3451
|
}
|
|
@@ -3469,40 +3466,40 @@ class ue {
|
|
|
3469
3466
|
/**
|
|
3470
3467
|
* The collection this `DocumentReference` belongs to.
|
|
3471
3468
|
*/ get parent() {
|
|
3472
|
-
return new
|
|
3469
|
+
return new an(this.firestore, this.converter, this._key.path.popLast());
|
|
3473
3470
|
}
|
|
3474
3471
|
withConverter(t) {
|
|
3475
|
-
return new
|
|
3472
|
+
return new un(this.firestore, t, this._key);
|
|
3476
3473
|
}
|
|
3477
3474
|
}
|
|
3478
3475
|
|
|
3479
3476
|
/**
|
|
3480
3477
|
* A `Query` refers to a query which you can read or listen to. You can also
|
|
3481
3478
|
* construct refined `Query` objects by adding filters and ordering.
|
|
3482
|
-
*/ class
|
|
3479
|
+
*/ class cn {
|
|
3483
3480
|
// This is the lite version of the Query class in the main SDK.
|
|
3484
3481
|
/** @hideconstructor protected */
|
|
3485
3482
|
constructor(t,
|
|
3486
3483
|
/**
|
|
3487
3484
|
* If provided, the `FirestoreDataConverter` associated with this instance.
|
|
3488
3485
|
*/
|
|
3489
|
-
|
|
3490
|
-
this.converter =
|
|
3486
|
+
e, n) {
|
|
3487
|
+
this.converter = e, this._query = n,
|
|
3491
3488
|
/** The type of this Firestore reference. */
|
|
3492
3489
|
this.type = "query", this.firestore = t;
|
|
3493
3490
|
}
|
|
3494
3491
|
withConverter(t) {
|
|
3495
|
-
return new
|
|
3492
|
+
return new cn(this.firestore, t, this._query);
|
|
3496
3493
|
}
|
|
3497
3494
|
}
|
|
3498
3495
|
|
|
3499
3496
|
/**
|
|
3500
3497
|
* A `CollectionReference` object can be used for adding documents, getting
|
|
3501
3498
|
* document references, and querying for documents (using {@link query}).
|
|
3502
|
-
*/ class
|
|
3499
|
+
*/ class an extends cn {
|
|
3503
3500
|
/** @hideconstructor */
|
|
3504
|
-
constructor(t,
|
|
3505
|
-
super(t,
|
|
3501
|
+
constructor(t, e, n) {
|
|
3502
|
+
super(t, e, new re(n)), this._path = n,
|
|
3506
3503
|
/** The type of this Firestore reference. */
|
|
3507
3504
|
this.type = "collection";
|
|
3508
3505
|
}
|
|
@@ -3520,23 +3517,23 @@ class ue {
|
|
|
3520
3517
|
* subcollection. If this isn't a subcollection, the reference is null.
|
|
3521
3518
|
*/ get parent() {
|
|
3522
3519
|
const t = this._path.popLast();
|
|
3523
|
-
return t.isEmpty() ? null : new
|
|
3520
|
+
return t.isEmpty() ? null : new un(this.firestore,
|
|
3524
3521
|
/* converter= */ null, new Z(t));
|
|
3525
3522
|
}
|
|
3526
3523
|
withConverter(t) {
|
|
3527
|
-
return new
|
|
3524
|
+
return new an(this.firestore, t, this._path);
|
|
3528
3525
|
}
|
|
3529
3526
|
}
|
|
3530
3527
|
|
|
3531
|
-
function
|
|
3532
|
-
if (t = a(t), X("collection", "path",
|
|
3533
|
-
const r = Y.fromString(
|
|
3534
|
-
return
|
|
3528
|
+
function hn(t, e, ...n) {
|
|
3529
|
+
if (t = a(t), X("collection", "path", e), t instanceof en) {
|
|
3530
|
+
const r = Y.fromString(e, ...n);
|
|
3531
|
+
return et(r), new an(t, /* converter= */ null, r);
|
|
3535
3532
|
}
|
|
3536
3533
|
{
|
|
3537
|
-
if (!(t instanceof
|
|
3538
|
-
const r = t._path.child(Y.fromString(
|
|
3539
|
-
return
|
|
3534
|
+
if (!(t instanceof un || t instanceof an)) throw new L(T, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3535
|
+
const r = t._path.child(Y.fromString(e, ...n));
|
|
3536
|
+
return et(r), new an(t.firestore,
|
|
3540
3537
|
/* converter= */ null, r);
|
|
3541
3538
|
}
|
|
3542
3539
|
}
|
|
@@ -3553,32 +3550,32 @@ function he(t, n, ...e) {
|
|
|
3553
3550
|
* collection or subcollection with this ID as the last segment of its path
|
|
3554
3551
|
* will be included. Cannot contain a slash.
|
|
3555
3552
|
* @returns The created `Query`.
|
|
3556
|
-
*/ function
|
|
3557
|
-
if (t = rt(t,
|
|
3558
|
-
return new
|
|
3553
|
+
*/ function ln(t, e) {
|
|
3554
|
+
if (t = rt(t, en), X("collectionGroup", "collection id", e), e.indexOf("/") >= 0) throw new L(T, `Invalid collection ID '${e}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);
|
|
3555
|
+
return new cn(t,
|
|
3559
3556
|
/* converter= */ null,
|
|
3560
3557
|
/**
|
|
3561
3558
|
* Creates a new Query for a collection group query that matches all documents
|
|
3562
3559
|
* within the provided collection group.
|
|
3563
3560
|
*/
|
|
3564
3561
|
function(t) {
|
|
3565
|
-
return new
|
|
3566
|
-
}(
|
|
3562
|
+
return new re(Y.emptyPath(), t);
|
|
3563
|
+
}(e));
|
|
3567
3564
|
}
|
|
3568
3565
|
|
|
3569
|
-
function
|
|
3566
|
+
function fn(t, e, ...n) {
|
|
3570
3567
|
if (t = a(t),
|
|
3571
3568
|
// We allow omission of 'pathString' but explicitly prohibit passing in both
|
|
3572
3569
|
// 'undefined' and 'null'.
|
|
3573
|
-
1 === arguments.length && (
|
|
3574
|
-
const r = Y.fromString(
|
|
3575
|
-
return tt(r), new
|
|
3570
|
+
1 === arguments.length && (e = dt.A()), X("doc", "path", e), t instanceof en) {
|
|
3571
|
+
const r = Y.fromString(e, ...n);
|
|
3572
|
+
return tt(r), new un(t,
|
|
3576
3573
|
/* converter= */ null, new Z(r));
|
|
3577
3574
|
}
|
|
3578
3575
|
{
|
|
3579
|
-
if (!(t instanceof
|
|
3580
|
-
const r = t._path.child(Y.fromString(
|
|
3581
|
-
return tt(r), new
|
|
3576
|
+
if (!(t instanceof un || t instanceof an)) throw new L(T, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3577
|
+
const r = t._path.child(Y.fromString(e, ...n));
|
|
3578
|
+
return tt(r), new un(t.firestore, t instanceof an ? t.converter : null, new Z(r));
|
|
3582
3579
|
}
|
|
3583
3580
|
}
|
|
3584
3581
|
|
|
@@ -3589,8 +3586,8 @@ function fe(t, n, ...e) {
|
|
|
3589
3586
|
* @param right - A reference to compare.
|
|
3590
3587
|
* @returns true if the references point to the same location in the same
|
|
3591
3588
|
* Firestore database.
|
|
3592
|
-
*/ function
|
|
3593
|
-
return t = a(t),
|
|
3589
|
+
*/ function dn(t, e) {
|
|
3590
|
+
return t = a(t), e = a(e), (t instanceof un || t instanceof an) && (e instanceof un || e instanceof an) && (t.firestore === e.firestore && t.path === e.path && t.converter === e.converter);
|
|
3594
3591
|
}
|
|
3595
3592
|
|
|
3596
3593
|
/**
|
|
@@ -3601,8 +3598,8 @@ function fe(t, n, ...e) {
|
|
|
3601
3598
|
* @param right - A `Query` to compare.
|
|
3602
3599
|
* @returns true if the references point to the same location in the same
|
|
3603
3600
|
* Firestore database.
|
|
3604
|
-
*/ function
|
|
3605
|
-
return t = a(t),
|
|
3601
|
+
*/ function wn(t, e) {
|
|
3602
|
+
return t = a(t), e = a(e), t instanceof cn && e instanceof cn && (t.firestore === e.firestore && he(t._query, e._query) && t.converter === e.converter);
|
|
3606
3603
|
}
|
|
3607
3604
|
|
|
3608
3605
|
/**
|
|
@@ -3628,7 +3625,7 @@ function fe(t, n, ...e) {
|
|
|
3628
3625
|
*
|
|
3629
3626
|
* Create a `FieldPath` by providing field names. If more than one field
|
|
3630
3627
|
* name is provided, the path will point to a nested field in a document.
|
|
3631
|
-
*/ class
|
|
3628
|
+
*/ class mn {
|
|
3632
3629
|
/**
|
|
3633
3630
|
* Creates a `FieldPath` from the provided field names. If more than one field
|
|
3634
3631
|
* name is provided, the path will point to a nested field in a document.
|
|
@@ -3636,7 +3633,7 @@ function fe(t, n, ...e) {
|
|
|
3636
3633
|
* @param fieldNames - A list of field names.
|
|
3637
3634
|
*/
|
|
3638
3635
|
constructor(...t) {
|
|
3639
|
-
for (let
|
|
3636
|
+
for (let e = 0; e < t.length; ++e) if (0 === t[e].length) throw new L(T, "Invalid field name at argument $(i + 1). Field names must not be empty.");
|
|
3640
3637
|
this._internalPath = new J(t);
|
|
3641
3638
|
}
|
|
3642
3639
|
/**
|
|
@@ -3652,8 +3649,8 @@ function fe(t, n, ...e) {
|
|
|
3652
3649
|
/**
|
|
3653
3650
|
* Returns a special sentinel `FieldPath` to refer to the ID of a document.
|
|
3654
3651
|
* It can be used in queries to sort or filter by the document ID.
|
|
3655
|
-
*/ function
|
|
3656
|
-
return new
|
|
3652
|
+
*/ function pn() {
|
|
3653
|
+
return new mn("__name__");
|
|
3657
3654
|
}
|
|
3658
3655
|
|
|
3659
3656
|
/**
|
|
@@ -3674,7 +3671,7 @@ function fe(t, n, ...e) {
|
|
|
3674
3671
|
*/
|
|
3675
3672
|
/**
|
|
3676
3673
|
* An immutable object representing an array of bytes.
|
|
3677
|
-
*/ class
|
|
3674
|
+
*/ class yn {
|
|
3678
3675
|
/** @hideconstructor */
|
|
3679
3676
|
constructor(t) {
|
|
3680
3677
|
this._byteString = t;
|
|
@@ -3686,7 +3683,7 @@ function fe(t, n, ...e) {
|
|
|
3686
3683
|
* @param base64 - The Base64 string used to create the `Bytes` object.
|
|
3687
3684
|
*/ static fromBase64String(t) {
|
|
3688
3685
|
try {
|
|
3689
|
-
return new
|
|
3686
|
+
return new yn(vt.fromBase64String(t));
|
|
3690
3687
|
} catch (t) {
|
|
3691
3688
|
throw new L(T, "Failed to construct data from Base64 string: " + t);
|
|
3692
3689
|
}
|
|
@@ -3696,7 +3693,7 @@ function fe(t, n, ...e) {
|
|
|
3696
3693
|
*
|
|
3697
3694
|
* @param array - The Uint8Array used to create the `Bytes` object.
|
|
3698
3695
|
*/ static fromUint8Array(t) {
|
|
3699
|
-
return new
|
|
3696
|
+
return new yn(vt.fromUint8Array(t));
|
|
3700
3697
|
}
|
|
3701
3698
|
/**
|
|
3702
3699
|
* Returns the underlying bytes as a Base64-encoded string.
|
|
@@ -3748,7 +3745,7 @@ function fe(t, n, ...e) {
|
|
|
3748
3745
|
/**
|
|
3749
3746
|
* Sentinel values that can be used when writing document fields with `set()`
|
|
3750
3747
|
* or `update()`.
|
|
3751
|
-
*/ class
|
|
3748
|
+
*/ class _n {
|
|
3752
3749
|
/**
|
|
3753
3750
|
* @param _methodName - The public API endpoint that returns this class.
|
|
3754
3751
|
* @hideconstructor
|
|
@@ -3780,17 +3777,17 @@ function fe(t, n, ...e) {
|
|
|
3780
3777
|
*
|
|
3781
3778
|
* Latitude values are in the range of [-90, 90].
|
|
3782
3779
|
* Longitude values are in the range of [-180, 180].
|
|
3783
|
-
*/ class
|
|
3780
|
+
*/ class gn {
|
|
3784
3781
|
/**
|
|
3785
3782
|
* Creates a new immutable `GeoPoint` object with the provided latitude and
|
|
3786
3783
|
* longitude values.
|
|
3787
3784
|
* @param latitude - The latitude as number between -90 and 90.
|
|
3788
3785
|
* @param longitude - The longitude as number between -180 and 180.
|
|
3789
3786
|
*/
|
|
3790
|
-
constructor(t,
|
|
3787
|
+
constructor(t, e) {
|
|
3791
3788
|
if (!isFinite(t) || t < -90 || t > 90) throw new L(T, "Latitude must be a number between -90 and 90, but was: " + t);
|
|
3792
|
-
if (!isFinite(
|
|
3793
|
-
this._lat = t, this._long =
|
|
3789
|
+
if (!isFinite(e) || e < -180 || e > 180) throw new L(T, "Longitude must be a number between -180 and 180, but was: " + e);
|
|
3790
|
+
this._lat = t, this._long = e;
|
|
3794
3791
|
}
|
|
3795
3792
|
/**
|
|
3796
3793
|
* The latitude of this `GeoPoint` instance.
|
|
@@ -3839,29 +3836,29 @@ function fe(t, n, ...e) {
|
|
|
3839
3836
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3840
3837
|
* See the License for the specific language governing permissions and
|
|
3841
3838
|
* limitations under the License.
|
|
3842
|
-
*/ const
|
|
3839
|
+
*/ const bn = /^__.*__$/;
|
|
3843
3840
|
|
|
3844
|
-
/** The result of parsing document data (e.g. for a setData call). */ class
|
|
3845
|
-
constructor(t,
|
|
3846
|
-
this.data = t, this.fieldMask =
|
|
3841
|
+
/** The result of parsing document data (e.g. for a setData call). */ class vn {
|
|
3842
|
+
constructor(t, e, n) {
|
|
3843
|
+
this.data = t, this.fieldMask = e, this.fieldTransforms = n;
|
|
3847
3844
|
}
|
|
3848
|
-
toMutation(t,
|
|
3849
|
-
return null !== this.fieldMask ? new
|
|
3845
|
+
toMutation(t, e) {
|
|
3846
|
+
return null !== this.fieldMask ? new ve(t, this.data, this.fieldMask, e, this.fieldTransforms) : new be(t, this.data, e, this.fieldTransforms);
|
|
3850
3847
|
}
|
|
3851
3848
|
}
|
|
3852
3849
|
|
|
3853
|
-
/** The result of parsing "update" data (i.e. for an updateData call). */ class
|
|
3850
|
+
/** The result of parsing "update" data (i.e. for an updateData call). */ class En {
|
|
3854
3851
|
constructor(t,
|
|
3855
3852
|
// The fieldMask does not include document transforms.
|
|
3856
|
-
|
|
3857
|
-
this.data = t, this.fieldMask =
|
|
3853
|
+
e, n) {
|
|
3854
|
+
this.data = t, this.fieldMask = e, this.fieldTransforms = n;
|
|
3858
3855
|
}
|
|
3859
|
-
toMutation(t,
|
|
3860
|
-
return new
|
|
3856
|
+
toMutation(t, e) {
|
|
3857
|
+
return new ve(t, this.data, this.fieldMask, e, this.fieldTransforms);
|
|
3861
3858
|
}
|
|
3862
3859
|
}
|
|
3863
3860
|
|
|
3864
|
-
function
|
|
3861
|
+
function In(t) {
|
|
3865
3862
|
switch (t) {
|
|
3866
3863
|
case 0 /* Set */ :
|
|
3867
3864
|
// fall through
|
|
@@ -3879,7 +3876,7 @@ function Ie(t) {
|
|
|
3879
3876
|
}
|
|
3880
3877
|
}
|
|
3881
3878
|
|
|
3882
|
-
/** A "context" object passed around while parsing user data. */ class
|
|
3879
|
+
/** A "context" object passed around while parsing user data. */ class Tn {
|
|
3883
3880
|
/**
|
|
3884
3881
|
* Initializes a ParseContext with the given source and path.
|
|
3885
3882
|
*
|
|
@@ -3898,8 +3895,8 @@ function Ie(t) {
|
|
|
3898
3895
|
* which case certain features will not work and errors will be somewhat
|
|
3899
3896
|
* compromised).
|
|
3900
3897
|
*/
|
|
3901
|
-
constructor(t,
|
|
3902
|
-
this.settings = t, this.databaseId =
|
|
3898
|
+
constructor(t, e, n, r, s, i) {
|
|
3899
|
+
this.settings = t, this.databaseId = e, this.S = n, this.ignoreUndefinedProperties = r,
|
|
3903
3900
|
// Minor hack: If fieldTransforms is undefined, we assume this is an
|
|
3904
3901
|
// external call and we need to validate the entire path.
|
|
3905
3902
|
void 0 === s && this.Z(), this.fieldTransforms = s || [], this.fieldMask = i || [];
|
|
@@ -3911,21 +3908,21 @@ function Ie(t) {
|
|
|
3911
3908
|
return this.settings.X;
|
|
3912
3909
|
}
|
|
3913
3910
|
/** Returns a new context with the specified settings overwritten. */ tt(t) {
|
|
3914
|
-
return new
|
|
3911
|
+
return new Tn(Object.assign(Object.assign({}, this.settings), t), this.databaseId, this.S, this.ignoreUndefinedProperties, this.fieldTransforms, this.fieldMask);
|
|
3915
3912
|
}
|
|
3916
|
-
|
|
3917
|
-
var
|
|
3918
|
-
const
|
|
3919
|
-
path:
|
|
3920
|
-
|
|
3913
|
+
et(t) {
|
|
3914
|
+
var e;
|
|
3915
|
+
const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), r = this.tt({
|
|
3916
|
+
path: n,
|
|
3917
|
+
nt: !1
|
|
3921
3918
|
});
|
|
3922
3919
|
return r.rt(t), r;
|
|
3923
3920
|
}
|
|
3924
3921
|
st(t) {
|
|
3925
|
-
var
|
|
3926
|
-
const
|
|
3927
|
-
path:
|
|
3928
|
-
|
|
3922
|
+
var e;
|
|
3923
|
+
const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), r = this.tt({
|
|
3924
|
+
path: n,
|
|
3925
|
+
nt: !1
|
|
3929
3926
|
});
|
|
3930
3927
|
return r.Z(), r;
|
|
3931
3928
|
}
|
|
@@ -3934,14 +3931,14 @@ function Ie(t) {
|
|
|
3934
3931
|
// undefined.
|
|
3935
3932
|
return this.tt({
|
|
3936
3933
|
path: void 0,
|
|
3937
|
-
|
|
3934
|
+
nt: !0
|
|
3938
3935
|
});
|
|
3939
3936
|
}
|
|
3940
3937
|
ot(t) {
|
|
3941
|
-
return
|
|
3938
|
+
return Qn(t, this.settings.methodName, this.settings.ut || !1, this.path, this.settings.ct);
|
|
3942
3939
|
}
|
|
3943
3940
|
/** Returns 'true' if 'fieldPath' was traversed when creating this context. */ contains(t) {
|
|
3944
|
-
return void 0 !== this.fieldMask.find((
|
|
3941
|
+
return void 0 !== this.fieldMask.find((e => t.isPrefixOf(e))) || void 0 !== this.fieldTransforms.find((e => t.isPrefixOf(e.field)));
|
|
3945
3942
|
}
|
|
3946
3943
|
Z() {
|
|
3947
3944
|
// TODO(b/34871131): Remove null check once we have proper paths for fields
|
|
@@ -3950,52 +3947,52 @@ function Ie(t) {
|
|
|
3950
3947
|
}
|
|
3951
3948
|
rt(t) {
|
|
3952
3949
|
if (0 === t.length) throw this.ot("Document fields must not be empty");
|
|
3953
|
-
if (
|
|
3950
|
+
if (In(this.X) && bn.test(t)) throw this.ot('Document fields cannot begin and end with "__"');
|
|
3954
3951
|
}
|
|
3955
3952
|
}
|
|
3956
3953
|
|
|
3957
3954
|
/**
|
|
3958
3955
|
* Helper for parsing raw user input (provided via the API) into internal model
|
|
3959
3956
|
* classes.
|
|
3960
|
-
*/ class
|
|
3961
|
-
constructor(t,
|
|
3962
|
-
this.databaseId = t, this.ignoreUndefinedProperties =
|
|
3957
|
+
*/ class An {
|
|
3958
|
+
constructor(t, e, n) {
|
|
3959
|
+
this.databaseId = t, this.ignoreUndefinedProperties = e, this.S = n || We(t);
|
|
3963
3960
|
}
|
|
3964
|
-
/** Creates a new top-level parse context. */ at(t,
|
|
3965
|
-
return new
|
|
3961
|
+
/** Creates a new top-level parse context. */ at(t, e, n, r = !1) {
|
|
3962
|
+
return new Tn({
|
|
3966
3963
|
X: t,
|
|
3967
|
-
methodName:
|
|
3968
|
-
ct:
|
|
3964
|
+
methodName: e,
|
|
3965
|
+
ct: n,
|
|
3969
3966
|
path: J.emptyPath(),
|
|
3970
|
-
|
|
3967
|
+
nt: !1,
|
|
3971
3968
|
ut: r
|
|
3972
3969
|
}, this.databaseId, this.S, this.ignoreUndefinedProperties);
|
|
3973
3970
|
}
|
|
3974
3971
|
}
|
|
3975
3972
|
|
|
3976
|
-
function
|
|
3977
|
-
const
|
|
3978
|
-
return new
|
|
3973
|
+
function Pn(t) {
|
|
3974
|
+
const e = t._freezeSettings(), n = We(t._databaseId);
|
|
3975
|
+
return new An(t._databaseId, !!e.ignoreUndefinedProperties, n);
|
|
3979
3976
|
}
|
|
3980
3977
|
|
|
3981
|
-
/** Parse document data from a set() call. */ function
|
|
3982
|
-
const o = t.at(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ ,
|
|
3983
|
-
|
|
3984
|
-
const u =
|
|
3978
|
+
/** Parse document data from a set() call. */ function Rn(t, e, n, r, s, i = {}) {
|
|
3979
|
+
const o = t.at(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ , e, n, s);
|
|
3980
|
+
jn("Data must be an object, but it was:", o, r);
|
|
3981
|
+
const u = Ln(r, o);
|
|
3985
3982
|
let c, a;
|
|
3986
3983
|
if (i.merge) c = new bt(o.fieldMask), a = o.fieldTransforms; else if (i.mergeFields) {
|
|
3987
3984
|
const t = [];
|
|
3988
3985
|
for (const r of i.mergeFields) {
|
|
3989
|
-
const s =
|
|
3986
|
+
const s = kn(e, r, n);
|
|
3990
3987
|
if (!o.contains(s)) throw new L(T, `Field '${s}' is specified in your field mask but missing from your input data.`);
|
|
3991
|
-
|
|
3988
|
+
zn(t, s) || t.push(s);
|
|
3992
3989
|
}
|
|
3993
3990
|
c = new bt(t), a = o.fieldTransforms.filter((t => c.covers(t.field)));
|
|
3994
3991
|
} else c = null, a = o.fieldTransforms;
|
|
3995
|
-
return new
|
|
3992
|
+
return new vn(new jt(u), c, a);
|
|
3996
3993
|
}
|
|
3997
3994
|
|
|
3998
|
-
class
|
|
3995
|
+
class Vn extends _n {
|
|
3999
3996
|
_toFieldTransform(t) {
|
|
4000
3997
|
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}`);
|
|
4001
3998
|
// No transform to add for a delete, but we need to add it to our
|
|
@@ -4003,7 +4000,7 @@ class Ve extends _e {
|
|
|
4003
4000
|
return t.fieldMask.push(t.path), null;
|
|
4004
4001
|
}
|
|
4005
4002
|
isEqual(t) {
|
|
4006
|
-
return t instanceof
|
|
4003
|
+
return t instanceof Vn;
|
|
4007
4004
|
}
|
|
4008
4005
|
}
|
|
4009
4006
|
|
|
@@ -4022,32 +4019,32 @@ class Ve extends _e {
|
|
|
4022
4019
|
* context.
|
|
4023
4020
|
* @param context - The parent context.
|
|
4024
4021
|
* @param arrayElement - Whether or not the FieldValue has an array.
|
|
4025
|
-
*/ function
|
|
4026
|
-
return new
|
|
4022
|
+
*/ function Nn(t, e, n) {
|
|
4023
|
+
return new Tn({
|
|
4027
4024
|
X: 3 /* Argument */ ,
|
|
4028
|
-
ct:
|
|
4025
|
+
ct: e.settings.ct,
|
|
4029
4026
|
methodName: t._methodName,
|
|
4030
|
-
|
|
4031
|
-
},
|
|
4027
|
+
nt: n
|
|
4028
|
+
}, e.databaseId, e.S, e.ignoreUndefinedProperties);
|
|
4032
4029
|
}
|
|
4033
4030
|
|
|
4034
|
-
class
|
|
4031
|
+
class Dn extends _n {
|
|
4035
4032
|
_toFieldTransform(t) {
|
|
4036
|
-
return new
|
|
4033
|
+
return new ye(t.path, new de);
|
|
4037
4034
|
}
|
|
4038
4035
|
isEqual(t) {
|
|
4039
|
-
return t instanceof
|
|
4036
|
+
return t instanceof Dn;
|
|
4040
4037
|
}
|
|
4041
4038
|
}
|
|
4042
4039
|
|
|
4043
|
-
class $
|
|
4044
|
-
constructor(t,
|
|
4045
|
-
super(t), this.ht =
|
|
4040
|
+
class $n extends _n {
|
|
4041
|
+
constructor(t, e) {
|
|
4042
|
+
super(t), this.ht = e;
|
|
4046
4043
|
}
|
|
4047
4044
|
_toFieldTransform(t) {
|
|
4048
|
-
const
|
|
4049
|
-
/*array=*/ !0),
|
|
4050
|
-
return new
|
|
4045
|
+
const e = Nn(this, t,
|
|
4046
|
+
/*array=*/ !0), n = this.ht.map((t => Cn(t, e))), r = new we(n);
|
|
4047
|
+
return new ye(t.path, r);
|
|
4051
4048
|
}
|
|
4052
4049
|
isEqual(t) {
|
|
4053
4050
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4055,14 +4052,14 @@ class $e extends _e {
|
|
|
4055
4052
|
}
|
|
4056
4053
|
}
|
|
4057
4054
|
|
|
4058
|
-
class
|
|
4059
|
-
constructor(t,
|
|
4060
|
-
super(t), this.ht =
|
|
4055
|
+
class Fn extends _n {
|
|
4056
|
+
constructor(t, e) {
|
|
4057
|
+
super(t), this.ht = e;
|
|
4061
4058
|
}
|
|
4062
4059
|
_toFieldTransform(t) {
|
|
4063
|
-
const
|
|
4064
|
-
/*array=*/ !0),
|
|
4065
|
-
return new
|
|
4060
|
+
const e = Nn(this, t,
|
|
4061
|
+
/*array=*/ !0), n = this.ht.map((t => Cn(t, e))), r = new me(n);
|
|
4062
|
+
return new ye(t.path, r);
|
|
4066
4063
|
}
|
|
4067
4064
|
isEqual(t) {
|
|
4068
4065
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4070,13 +4067,13 @@ class Fe extends _e {
|
|
|
4070
4067
|
}
|
|
4071
4068
|
}
|
|
4072
4069
|
|
|
4073
|
-
class
|
|
4074
|
-
constructor(t,
|
|
4075
|
-
super(t), this.lt =
|
|
4070
|
+
class Sn extends _n {
|
|
4071
|
+
constructor(t, e) {
|
|
4072
|
+
super(t), this.lt = e;
|
|
4076
4073
|
}
|
|
4077
4074
|
_toFieldTransform(t) {
|
|
4078
|
-
const
|
|
4079
|
-
return new
|
|
4075
|
+
const e = new pe(t.S, le(t.S, this.lt));
|
|
4076
|
+
return new ye(t.path, e);
|
|
4080
4077
|
}
|
|
4081
4078
|
isEqual(t) {
|
|
4082
4079
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4084,50 +4081,50 @@ class Se extends _e {
|
|
|
4084
4081
|
}
|
|
4085
4082
|
}
|
|
4086
4083
|
|
|
4087
|
-
/** Parse update data from an update() call. */ function
|
|
4088
|
-
const s = t.at(1 /* Update */ ,
|
|
4089
|
-
|
|
4084
|
+
/** Parse update data from an update() call. */ function qn(t, e, n, r) {
|
|
4085
|
+
const s = t.at(1 /* Update */ , e, n);
|
|
4086
|
+
jn("Data must be an object, but it was:", s, r);
|
|
4090
4087
|
const i = [], o = jt.empty();
|
|
4091
4088
|
gt(r, ((t, r) => {
|
|
4092
|
-
const u =
|
|
4089
|
+
const u = Bn(e, t, n);
|
|
4093
4090
|
// For Compat types, we have to "extract" the underlying types before
|
|
4094
4091
|
// performing validation.
|
|
4095
4092
|
r = a(r);
|
|
4096
4093
|
const c = s.st(u);
|
|
4097
|
-
if (r instanceof
|
|
4094
|
+
if (r instanceof Vn)
|
|
4098
4095
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4099
4096
|
i.push(u); else {
|
|
4100
|
-
const t =
|
|
4097
|
+
const t = Cn(r, c);
|
|
4101
4098
|
null != t && (i.push(u), o.set(u, t));
|
|
4102
4099
|
}
|
|
4103
4100
|
}));
|
|
4104
4101
|
const u = new bt(i);
|
|
4105
|
-
return new
|
|
4102
|
+
return new En(o, u, s.fieldTransforms);
|
|
4106
4103
|
}
|
|
4107
4104
|
|
|
4108
|
-
/** Parse update data from a list of field/value arguments. */ function
|
|
4109
|
-
const o = t.at(1 /* Update */ ,
|
|
4110
|
-
if (i.length % 2 != 0) throw new L(T, `Function ${
|
|
4111
|
-
for (let t = 0; t < i.length; t += 2) u.push(
|
|
4105
|
+
/** Parse update data from a list of field/value arguments. */ function xn(t, e, n, r, s, i) {
|
|
4106
|
+
const o = t.at(1 /* Update */ , e, n), u = [ kn(e, r, n) ], c = [ s ];
|
|
4107
|
+
if (i.length % 2 != 0) throw new L(T, `Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);
|
|
4108
|
+
for (let t = 0; t < i.length; t += 2) u.push(kn(e, i[t])), c.push(i[t + 1]);
|
|
4112
4109
|
const h = [], l = jt.empty();
|
|
4113
4110
|
// We iterate in reverse order to pick the last value for a field if the
|
|
4114
4111
|
// user specified the field multiple times.
|
|
4115
|
-
for (let t = u.length - 1; t >= 0; --t) if (!
|
|
4116
|
-
const
|
|
4117
|
-
let
|
|
4112
|
+
for (let t = u.length - 1; t >= 0; --t) if (!zn(h, u[t])) {
|
|
4113
|
+
const e = u[t];
|
|
4114
|
+
let n = c[t];
|
|
4118
4115
|
// For Compat types, we have to "extract" the underlying types before
|
|
4119
4116
|
// performing validation.
|
|
4120
|
-
|
|
4121
|
-
const r = o.st(
|
|
4122
|
-
if (
|
|
4117
|
+
n = a(n);
|
|
4118
|
+
const r = o.st(e);
|
|
4119
|
+
if (n instanceof Vn)
|
|
4123
4120
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4124
|
-
h.push(
|
|
4125
|
-
const t =
|
|
4126
|
-
null != t && (h.push(
|
|
4121
|
+
h.push(e); else {
|
|
4122
|
+
const t = Cn(n, r);
|
|
4123
|
+
null != t && (h.push(e), l.set(e, t));
|
|
4127
4124
|
}
|
|
4128
4125
|
}
|
|
4129
4126
|
const f = new bt(h);
|
|
4130
|
-
return new
|
|
4127
|
+
return new En(l, f, o.fieldTransforms);
|
|
4131
4128
|
}
|
|
4132
4129
|
|
|
4133
4130
|
/**
|
|
@@ -4136,8 +4133,8 @@ class Se extends _e {
|
|
|
4136
4133
|
*
|
|
4137
4134
|
* @param allowArrays - Whether the query value is an array that may directly
|
|
4138
4135
|
* contain additional arrays (e.g. the operand of an `in` query).
|
|
4139
|
-
*/ function
|
|
4140
|
-
return
|
|
4136
|
+
*/ function On(t, e, n, r = !1) {
|
|
4137
|
+
return Cn(n, t.at(r ? 4 /* ArrayArgument */ : 3 /* Argument */ , e));
|
|
4141
4138
|
}
|
|
4142
4139
|
|
|
4143
4140
|
/**
|
|
@@ -4148,12 +4145,12 @@ class Se extends _e {
|
|
|
4148
4145
|
* the source of the data being parsed, etc.
|
|
4149
4146
|
* @returns The parsed value, or null if the value was a FieldValue sentinel
|
|
4150
4147
|
* that should not be included in the resulting parsed data.
|
|
4151
|
-
*/ function
|
|
4152
|
-
if (
|
|
4148
|
+
*/ function Cn(t, e) {
|
|
4149
|
+
if (Un(
|
|
4153
4150
|
// Unwrap the API type from the Compat SDK. This will return the API type
|
|
4154
4151
|
// from firestore-exp.
|
|
4155
|
-
t = a(t))) return
|
|
4156
|
-
if (t instanceof
|
|
4152
|
+
t = a(t))) return jn("Unsupported field value:", e, t), Ln(t, e);
|
|
4153
|
+
if (t instanceof _n)
|
|
4157
4154
|
// FieldValues usually parse into transforms (except FieldValue.delete())
|
|
4158
4155
|
// in which case we do not want to include this field in our parsed data
|
|
4159
4156
|
// (as doing so will overwrite the field directly prior to the transform
|
|
@@ -4163,19 +4160,19 @@ class Se extends _e {
|
|
|
4163
4160
|
* "Parses" the provided FieldValueImpl, adding any necessary transforms to
|
|
4164
4161
|
* context.fieldTransforms.
|
|
4165
4162
|
*/
|
|
4166
|
-
return function(t,
|
|
4163
|
+
return function(t, e) {
|
|
4167
4164
|
// Sentinels are only supported with writes, and not within arrays.
|
|
4168
|
-
if (!
|
|
4169
|
-
if (!
|
|
4170
|
-
const
|
|
4171
|
-
|
|
4165
|
+
if (!In(e.X)) throw e.ot(`${t._methodName}() can only be used with update() and set()`);
|
|
4166
|
+
if (!e.path) throw e.ot(`${t._methodName}() is not currently supported inside arrays`);
|
|
4167
|
+
const n = t._toFieldTransform(e);
|
|
4168
|
+
n && e.fieldTransforms.push(n);
|
|
4172
4169
|
}
|
|
4173
4170
|
/**
|
|
4174
4171
|
* Helper to parse a scalar value (i.e. not an Object, Array, or FieldValue)
|
|
4175
4172
|
*
|
|
4176
4173
|
* @returns The parsed value
|
|
4177
|
-
*/ (t,
|
|
4178
|
-
if (void 0 === t &&
|
|
4174
|
+
*/ (t, e), null;
|
|
4175
|
+
if (void 0 === t && e.ignoreUndefinedProperties)
|
|
4179
4176
|
// If the input is undefined it can never participate in the fieldMask, so
|
|
4180
4177
|
// don't handle this below. If `ignoreUndefinedProperties` is false,
|
|
4181
4178
|
// `parseScalarValue` will reject an undefined value.
|
|
@@ -4183,38 +4180,38 @@ class Se extends _e {
|
|
|
4183
4180
|
if (
|
|
4184
4181
|
// If context.path is null we are inside an array and we don't support
|
|
4185
4182
|
// field mask paths more granular than the top-level array.
|
|
4186
|
-
|
|
4183
|
+
e.path && e.fieldMask.push(e.path), t instanceof Array) {
|
|
4187
4184
|
// TODO(b/34871131): Include the path containing the array in the error
|
|
4188
4185
|
// message.
|
|
4189
4186
|
// In the case of IN queries, the parsed data is an array (representing
|
|
4190
4187
|
// the set of values to be included for the IN query) that may directly
|
|
4191
4188
|
// contain additional arrays (each representing an individual field
|
|
4192
4189
|
// value), so we disable this validation.
|
|
4193
|
-
if (
|
|
4194
|
-
return function(t,
|
|
4195
|
-
const
|
|
4190
|
+
if (e.settings.nt && 4 /* ArrayArgument */ !== e.X) throw e.ot("Nested arrays are not supported");
|
|
4191
|
+
return function(t, e) {
|
|
4192
|
+
const n = [];
|
|
4196
4193
|
let r = 0;
|
|
4197
4194
|
for (const s of t) {
|
|
4198
|
-
let t =
|
|
4195
|
+
let t = Cn(s, e.it(r));
|
|
4199
4196
|
null == t && (
|
|
4200
4197
|
// Just include nulls in the array for fields being replaced with a
|
|
4201
4198
|
// sentinel.
|
|
4202
4199
|
t = {
|
|
4203
4200
|
nullValue: "NULL_VALUE"
|
|
4204
|
-
}),
|
|
4201
|
+
}), n.push(t), r++;
|
|
4205
4202
|
}
|
|
4206
4203
|
return {
|
|
4207
4204
|
arrayValue: {
|
|
4208
|
-
values:
|
|
4205
|
+
values: n
|
|
4209
4206
|
}
|
|
4210
4207
|
};
|
|
4211
|
-
}(t,
|
|
4208
|
+
}(t, e);
|
|
4212
4209
|
}
|
|
4213
|
-
return function(t,
|
|
4210
|
+
return function(t, e) {
|
|
4214
4211
|
if (null === (t = a(t))) return {
|
|
4215
4212
|
nullValue: "NULL_VALUE"
|
|
4216
4213
|
};
|
|
4217
|
-
if ("number" == typeof t) return
|
|
4214
|
+
if ("number" == typeof t) return le(e.S, t);
|
|
4218
4215
|
if ("boolean" == typeof t) return {
|
|
4219
4216
|
booleanValue: t
|
|
4220
4217
|
};
|
|
@@ -4222,37 +4219,37 @@ class Se extends _e {
|
|
|
4222
4219
|
stringValue: t
|
|
4223
4220
|
};
|
|
4224
4221
|
if (t instanceof Date) {
|
|
4225
|
-
const
|
|
4222
|
+
const n = pt.fromDate(t);
|
|
4226
4223
|
return {
|
|
4227
|
-
timestampValue:
|
|
4224
|
+
timestampValue: Re(e.S, n)
|
|
4228
4225
|
};
|
|
4229
4226
|
}
|
|
4230
4227
|
if (t instanceof pt) {
|
|
4231
4228
|
// Firestore backend truncates precision down to microseconds. To ensure
|
|
4232
4229
|
// offline mode works the same with regards to truncation, perform the
|
|
4233
4230
|
// truncation immediately without waiting for the backend to do that.
|
|
4234
|
-
const
|
|
4231
|
+
const n = new pt(t.seconds, 1e3 * Math.floor(t.nanoseconds / 1e3));
|
|
4235
4232
|
return {
|
|
4236
|
-
timestampValue:
|
|
4233
|
+
timestampValue: Re(e.S, n)
|
|
4237
4234
|
};
|
|
4238
4235
|
}
|
|
4239
|
-
if (t instanceof
|
|
4236
|
+
if (t instanceof gn) return {
|
|
4240
4237
|
geoPointValue: {
|
|
4241
4238
|
latitude: t.latitude,
|
|
4242
4239
|
longitude: t.longitude
|
|
4243
4240
|
}
|
|
4244
4241
|
};
|
|
4245
|
-
if (t instanceof
|
|
4246
|
-
bytesValue:
|
|
4242
|
+
if (t instanceof yn) return {
|
|
4243
|
+
bytesValue: Ve(e.S, t._byteString)
|
|
4247
4244
|
};
|
|
4248
|
-
if (t instanceof
|
|
4249
|
-
const
|
|
4250
|
-
if (!r.isEqual(
|
|
4245
|
+
if (t instanceof un) {
|
|
4246
|
+
const n = e.databaseId, r = t.firestore._databaseId;
|
|
4247
|
+
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}`);
|
|
4251
4248
|
return {
|
|
4252
|
-
referenceValue:
|
|
4249
|
+
referenceValue: $e(t.firestore._databaseId || e.databaseId, t._key.path)
|
|
4253
4250
|
};
|
|
4254
4251
|
}
|
|
4255
|
-
throw
|
|
4252
|
+
throw e.ot(`Unsupported field value: ${nt(t)}`);
|
|
4256
4253
|
}
|
|
4257
4254
|
/**
|
|
4258
4255
|
* Checks whether an object looks like a JSON object that should be converted
|
|
@@ -4260,56 +4257,56 @@ class Se extends _e {
|
|
|
4260
4257
|
* JSON objects since they should be converted to a struct value. Arrays, Dates,
|
|
4261
4258
|
* GeoPoints, etc. are not considered to look like JSON objects since they map
|
|
4262
4259
|
* to specific FieldValue types other than ObjectValue.
|
|
4263
|
-
*/ (t,
|
|
4260
|
+
*/ (t, e);
|
|
4264
4261
|
}
|
|
4265
4262
|
|
|
4266
|
-
function
|
|
4267
|
-
const
|
|
4263
|
+
function Ln(t, e) {
|
|
4264
|
+
const n = {};
|
|
4268
4265
|
return !function(t) {
|
|
4269
|
-
for (const
|
|
4266
|
+
for (const e in t) if (Object.prototype.hasOwnProperty.call(t, e)) return !1;
|
|
4270
4267
|
return !0;
|
|
4271
4268
|
}(t) ? gt(t, ((t, r) => {
|
|
4272
|
-
const s =
|
|
4273
|
-
null != s && (
|
|
4269
|
+
const s = Cn(r, e.et(t));
|
|
4270
|
+
null != s && (n[t] = s);
|
|
4274
4271
|
})) :
|
|
4275
4272
|
// If we encounter an empty object, we explicitly add it to the update
|
|
4276
4273
|
// mask to ensure that the server creates a map entry.
|
|
4277
|
-
|
|
4274
|
+
e.path && e.path.length > 0 && e.fieldMask.push(e.path), {
|
|
4278
4275
|
mapValue: {
|
|
4279
|
-
fields:
|
|
4276
|
+
fields: n
|
|
4280
4277
|
}
|
|
4281
4278
|
};
|
|
4282
4279
|
}
|
|
4283
4280
|
|
|
4284
|
-
function
|
|
4285
|
-
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof pt || t instanceof
|
|
4281
|
+
function Un(t) {
|
|
4282
|
+
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof pt || t instanceof gn || t instanceof yn || t instanceof un || t instanceof _n);
|
|
4286
4283
|
}
|
|
4287
4284
|
|
|
4288
|
-
function
|
|
4289
|
-
if (!
|
|
4285
|
+
function jn(t, e, n) {
|
|
4286
|
+
if (!Un(n) || !function(t) {
|
|
4290
4287
|
return "object" == typeof t && null !== t && (Object.getPrototypeOf(t) === Object.prototype || null === Object.getPrototypeOf(t));
|
|
4291
|
-
}(
|
|
4292
|
-
const r =
|
|
4293
|
-
throw "an object" === r ?
|
|
4288
|
+
}(n)) {
|
|
4289
|
+
const r = nt(n);
|
|
4290
|
+
throw "an object" === r ? e.ot(t + " a custom object") : e.ot(t + " " + r);
|
|
4294
4291
|
}
|
|
4295
4292
|
}
|
|
4296
4293
|
|
|
4297
4294
|
/**
|
|
4298
4295
|
* Helper that calls fromDotSeparatedString() but wraps any error thrown.
|
|
4299
|
-
*/ function
|
|
4296
|
+
*/ function kn(t, e, n) {
|
|
4300
4297
|
if ((
|
|
4301
4298
|
// If required, replace the FieldPath Compat class with with the firestore-exp
|
|
4302
4299
|
// FieldPath.
|
|
4303
|
-
|
|
4304
|
-
if ("string" == typeof
|
|
4305
|
-
throw
|
|
4300
|
+
e = a(e)) instanceof mn) return e._internalPath;
|
|
4301
|
+
if ("string" == typeof e) return Bn(t, e);
|
|
4302
|
+
throw Qn("Field path arguments must be of type string or FieldPath.", t,
|
|
4306
4303
|
/* hasConverter= */ !1,
|
|
4307
|
-
/* path= */ void 0,
|
|
4304
|
+
/* path= */ void 0, n);
|
|
4308
4305
|
}
|
|
4309
4306
|
|
|
4310
4307
|
/**
|
|
4311
4308
|
* Matches any characters in a field path string that are reserved.
|
|
4312
|
-
*/ const
|
|
4309
|
+
*/ const Mn = new RegExp("[~\\*/\\[\\]]");
|
|
4313
4310
|
|
|
4314
4311
|
/**
|
|
4315
4312
|
* Wraps fromDotSeparatedString with an error message about the method that
|
|
@@ -4319,30 +4316,30 @@ function je(t, n, e) {
|
|
|
4319
4316
|
* split on dots.
|
|
4320
4317
|
* @param targetDoc - The document against which the field path will be
|
|
4321
4318
|
* evaluated.
|
|
4322
|
-
*/ function
|
|
4323
|
-
if (
|
|
4319
|
+
*/ function Bn(t, e, n) {
|
|
4320
|
+
if (e.search(Mn) >= 0) throw Qn(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`, t,
|
|
4324
4321
|
/* hasConverter= */ !1,
|
|
4325
|
-
/* path= */ void 0,
|
|
4322
|
+
/* path= */ void 0, n);
|
|
4326
4323
|
try {
|
|
4327
|
-
return new
|
|
4324
|
+
return new mn(...e.split("."))._internalPath;
|
|
4328
4325
|
} catch (r) {
|
|
4329
|
-
throw
|
|
4326
|
+
throw Qn(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`, t,
|
|
4330
4327
|
/* hasConverter= */ !1,
|
|
4331
|
-
/* path= */ void 0,
|
|
4328
|
+
/* path= */ void 0, n);
|
|
4332
4329
|
}
|
|
4333
4330
|
}
|
|
4334
4331
|
|
|
4335
|
-
function
|
|
4332
|
+
function Qn(t, e, n, r, s) {
|
|
4336
4333
|
const i = r && !r.isEmpty(), o = void 0 !== s;
|
|
4337
|
-
let u = `Function ${
|
|
4338
|
-
|
|
4334
|
+
let u = `Function ${e}() called with invalid data`;
|
|
4335
|
+
n && (u += " (via `toFirestore()`)"), u += ". ";
|
|
4339
4336
|
let c = "";
|
|
4340
4337
|
return (i || o) && (c += " (found", i && (c += ` in field ${r}`), o && (c += ` in document ${s}`),
|
|
4341
4338
|
c += ")"), new L(T, u + t + c);
|
|
4342
4339
|
}
|
|
4343
4340
|
|
|
4344
|
-
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function
|
|
4345
|
-
return t.some((t => t.isEqual(
|
|
4341
|
+
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function zn(t, e) {
|
|
4342
|
+
return t.some((t => t.isEqual(e)));
|
|
4346
4343
|
}
|
|
4347
4344
|
|
|
4348
4345
|
/**
|
|
@@ -4369,14 +4366,14 @@ function Qe(t, n, e, r, s) {
|
|
|
4369
4366
|
* For a `DocumentSnapshot` that points to a non-existing document, any data
|
|
4370
4367
|
* access will return 'undefined'. You can use the `exists()` method to
|
|
4371
4368
|
* explicitly verify a document's existence.
|
|
4372
|
-
*/ class
|
|
4369
|
+
*/ class Wn {
|
|
4373
4370
|
// Note: This class is stripped down version of the DocumentSnapshot in
|
|
4374
4371
|
// the legacy SDK. The changes are:
|
|
4375
4372
|
// - No support for SnapshotMetadata.
|
|
4376
4373
|
// - No support for SnapshotOptions.
|
|
4377
4374
|
/** @hideconstructor protected */
|
|
4378
|
-
constructor(t,
|
|
4379
|
-
this._firestore = t, this._userDataWriter =
|
|
4375
|
+
constructor(t, e, n, r, s) {
|
|
4376
|
+
this._firestore = t, this._userDataWriter = e, this._key = n, this._document = r,
|
|
4380
4377
|
this._converter = s;
|
|
4381
4378
|
}
|
|
4382
4379
|
/** Property of the `DocumentSnapshot` that provides the document's ID. */ get id() {
|
|
@@ -4385,7 +4382,7 @@ function Qe(t, n, e, r, s) {
|
|
|
4385
4382
|
/**
|
|
4386
4383
|
* The `DocumentReference` for the document included in the `DocumentSnapshot`.
|
|
4387
4384
|
*/ get ref() {
|
|
4388
|
-
return new
|
|
4385
|
+
return new un(this._firestore, this._converter, this._key);
|
|
4389
4386
|
}
|
|
4390
4387
|
/**
|
|
4391
4388
|
* Signals whether or not the document at the snapshot's location exists.
|
|
@@ -4405,7 +4402,7 @@ function Qe(t, n, e, r, s) {
|
|
|
4405
4402
|
if (this._converter) {
|
|
4406
4403
|
// We only want to use the converter and create a new DocumentSnapshot
|
|
4407
4404
|
// if a converter has been provided.
|
|
4408
|
-
const t = new
|
|
4405
|
+
const t = new Gn(this._firestore, this._userDataWriter, this._key, this._document,
|
|
4409
4406
|
/* converter= */ null);
|
|
4410
4407
|
return this._converter.fromFirestore(t);
|
|
4411
4408
|
}
|
|
@@ -4425,8 +4422,8 @@ function Qe(t, n, e, r, s) {
|
|
|
4425
4422
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4426
4423
|
get(t) {
|
|
4427
4424
|
if (this._document) {
|
|
4428
|
-
const
|
|
4429
|
-
if (null !==
|
|
4425
|
+
const e = this._document.data.field(Kn("DocumentSnapshot.get", t));
|
|
4426
|
+
if (null !== e) return this._userDataWriter.convertValue(e);
|
|
4430
4427
|
}
|
|
4431
4428
|
}
|
|
4432
4429
|
}
|
|
@@ -4441,7 +4438,7 @@ function Qe(t, n, e, r, s) {
|
|
|
4441
4438
|
* `DocumentSnapshot`. Since query results contain only existing documents, the
|
|
4442
4439
|
* `exists` property will always be true and `data()` will never return
|
|
4443
4440
|
* 'undefined'.
|
|
4444
|
-
*/ class
|
|
4441
|
+
*/ class Gn extends Wn {
|
|
4445
4442
|
/**
|
|
4446
4443
|
* Retrieves all fields in the document as an `Object`.
|
|
4447
4444
|
*
|
|
@@ -4459,10 +4456,10 @@ function Qe(t, n, e, r, s) {
|
|
|
4459
4456
|
* array via the `docs` property or enumerated using the `forEach` method. The
|
|
4460
4457
|
* number of documents can be determined via the `empty` and `size`
|
|
4461
4458
|
* properties.
|
|
4462
|
-
*/ class
|
|
4459
|
+
*/ class Hn {
|
|
4463
4460
|
/** @hideconstructor */
|
|
4464
|
-
constructor(t,
|
|
4465
|
-
this._docs =
|
|
4461
|
+
constructor(t, e) {
|
|
4462
|
+
this._docs = e, this.query = t;
|
|
4466
4463
|
}
|
|
4467
4464
|
/** An array of all the documents in the `QuerySnapshot`. */ get docs() {
|
|
4468
4465
|
return [ ...this._docs ];
|
|
@@ -4479,8 +4476,8 @@ function Qe(t, n, e, r, s) {
|
|
|
4479
4476
|
* @param callback - A callback to be called with a `QueryDocumentSnapshot` for
|
|
4480
4477
|
* each document in the snapshot.
|
|
4481
4478
|
* @param thisArg - The `this` binding for the callback.
|
|
4482
|
-
*/ forEach(t,
|
|
4483
|
-
this._docs.forEach(t,
|
|
4479
|
+
*/ forEach(t, e) {
|
|
4480
|
+
this._docs.forEach(t, e);
|
|
4484
4481
|
}
|
|
4485
4482
|
}
|
|
4486
4483
|
|
|
@@ -4490,14 +4487,14 @@ function Qe(t, n, e, r, s) {
|
|
|
4490
4487
|
* @param left - A snapshot to compare.
|
|
4491
4488
|
* @param right - A snapshot to compare.
|
|
4492
4489
|
* @returns true if the snapshots are equal.
|
|
4493
|
-
*/ function
|
|
4494
|
-
return t = a(t),
|
|
4490
|
+
*/ function Yn(t, e) {
|
|
4491
|
+
return t = a(t), e = a(e), t instanceof Wn && e instanceof Wn ? 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 Hn && e instanceof Hn && (wn(t.query, e.query) && mt(t.docs, e.docs, Yn));
|
|
4495
4492
|
}
|
|
4496
4493
|
|
|
4497
4494
|
/**
|
|
4498
4495
|
* Helper that calls `fromDotSeparatedString()` but wraps any error thrown.
|
|
4499
|
-
*/ function
|
|
4500
|
-
return "string" == typeof
|
|
4496
|
+
*/ function Kn(t, e) {
|
|
4497
|
+
return "string" == typeof e ? Bn(t, e) : e instanceof mn ? e._internalPath : e._delegate._internalPath;
|
|
4501
4498
|
}
|
|
4502
4499
|
|
|
4503
4500
|
/**
|
|
@@ -4524,7 +4521,7 @@ function Qe(t, n, e, r, s) {
|
|
|
4524
4521
|
* can then be passed to {@link query} to create a new query instance that
|
|
4525
4522
|
* also contains this `QueryConstraint`.
|
|
4526
4523
|
*/
|
|
4527
|
-
class
|
|
4524
|
+
class Jn {}
|
|
4528
4525
|
|
|
4529
4526
|
/**
|
|
4530
4527
|
* Creates a new immutable instance of {@link Query} that is extended to also include
|
|
@@ -4534,43 +4531,43 @@ class Je {}
|
|
|
4534
4531
|
* @param queryConstraints - The list of {@link QueryConstraint}s to apply.
|
|
4535
4532
|
* @throws if any of the provided query constraints cannot be combined with the
|
|
4536
4533
|
* existing or new constraints.
|
|
4537
|
-
*/ function
|
|
4538
|
-
for (const
|
|
4534
|
+
*/ function Zn(t, ...e) {
|
|
4535
|
+
for (const n of e) t = n._apply(t);
|
|
4539
4536
|
return t;
|
|
4540
4537
|
}
|
|
4541
4538
|
|
|
4542
|
-
class
|
|
4543
|
-
constructor(t,
|
|
4544
|
-
super(), this.ft = t, this.dt =
|
|
4539
|
+
class Xn extends Jn {
|
|
4540
|
+
constructor(t, e, n) {
|
|
4541
|
+
super(), this.ft = t, this.dt = e, this.wt = n, this.type = "where";
|
|
4545
4542
|
}
|
|
4546
4543
|
_apply(t) {
|
|
4547
|
-
const
|
|
4544
|
+
const e = Pn(t.firestore), n = function(t, e, n, r, s, i, o) {
|
|
4548
4545
|
let u;
|
|
4549
4546
|
if (s.isKeyField()) {
|
|
4550
4547
|
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new L(T, `Invalid Query. You can't perform '${i}' queries on FieldPath.documentId().`);
|
|
4551
4548
|
if ("in" /* IN */ === i || "not-in" /* NOT_IN */ === i) {
|
|
4552
4549
|
wr(o, i);
|
|
4553
|
-
const
|
|
4554
|
-
for (const
|
|
4550
|
+
const e = [];
|
|
4551
|
+
for (const n of o) e.push(dr(r, t, n));
|
|
4555
4552
|
u = {
|
|
4556
4553
|
arrayValue: {
|
|
4557
|
-
values:
|
|
4554
|
+
values: e
|
|
4558
4555
|
}
|
|
4559
4556
|
};
|
|
4560
4557
|
} else u = dr(r, t, o);
|
|
4561
4558
|
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i || wr(o, i),
|
|
4562
|
-
u =
|
|
4559
|
+
u = On(n, e, o,
|
|
4563
4560
|
/* allowArrays= */ "in" /* IN */ === i || "not-in" /* NOT_IN */ === i);
|
|
4564
4561
|
const c = Qt.create(s, i, u);
|
|
4565
|
-
return function(t,
|
|
4566
|
-
if (
|
|
4567
|
-
const
|
|
4568
|
-
if (null !==
|
|
4569
|
-
const r =
|
|
4570
|
-
null !== r && mr(t,
|
|
4562
|
+
return function(t, e) {
|
|
4563
|
+
if (e.N()) {
|
|
4564
|
+
const n = oe(t);
|
|
4565
|
+
if (null !== n && !n.isEqual(e.field)) throw new L(T, `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()}'`);
|
|
4566
|
+
const r = ie(t);
|
|
4567
|
+
null !== r && mr(t, e.field, r);
|
|
4571
4568
|
}
|
|
4572
|
-
const
|
|
4573
|
-
for (const
|
|
4569
|
+
const n = function(t, e) {
|
|
4570
|
+
for (const n of t.filters) if (e.indexOf(n.op) >= 0) return n.op;
|
|
4574
4571
|
return null;
|
|
4575
4572
|
}(t,
|
|
4576
4573
|
/**
|
|
@@ -4605,16 +4602,16 @@ class Xe extends Je {
|
|
|
4605
4602
|
default:
|
|
4606
4603
|
return [];
|
|
4607
4604
|
}
|
|
4608
|
-
}(
|
|
4609
|
-
if (null !==
|
|
4605
|
+
}(e.op));
|
|
4606
|
+
if (null !== n)
|
|
4610
4607
|
// Special case when it's a duplicate op to give a slightly clearer error message.
|
|
4611
|
-
throw
|
|
4608
|
+
throw n === e.op ? new L(T, `Invalid query. You cannot use more than one '${e.op.toString()}' filter.`) : new L(T, `Invalid query. You cannot use '${e.op.toString()}' filters with '${n.toString()}' filters.`);
|
|
4612
4609
|
}(t, c), c;
|
|
4613
|
-
}(t._query, "where",
|
|
4614
|
-
return new
|
|
4615
|
-
const
|
|
4616
|
-
return new
|
|
4617
|
-
}(t._query,
|
|
4610
|
+
}(t._query, "where", e, t.firestore._databaseId, this.ft, this.dt, this.wt);
|
|
4611
|
+
return new cn(t.firestore, t.converter, function(t, e) {
|
|
4612
|
+
const n = t.filters.concat([ e ]);
|
|
4613
|
+
return new re(t.path, t.collectionGroup, t.explicitOrderBy.slice(), n, t.limit, t.limitType, t.startAt, t.endAt);
|
|
4614
|
+
}(t._query, n));
|
|
4618
4615
|
}
|
|
4619
4616
|
}
|
|
4620
4617
|
|
|
@@ -4628,25 +4625,25 @@ class Xe extends Je {
|
|
|
4628
4625
|
* "<=", "!=").
|
|
4629
4626
|
* @param value - The value for comparison
|
|
4630
4627
|
* @returns The created {@link Query}.
|
|
4631
|
-
*/ function tr(t,
|
|
4632
|
-
const r =
|
|
4633
|
-
return new
|
|
4628
|
+
*/ function tr(t, e, n) {
|
|
4629
|
+
const r = e, s = Kn("where", t);
|
|
4630
|
+
return new Xn(s, r, n);
|
|
4634
4631
|
}
|
|
4635
4632
|
|
|
4636
|
-
class
|
|
4637
|
-
constructor(t,
|
|
4638
|
-
super(), this.ft = t, this.yt =
|
|
4633
|
+
class er extends Jn {
|
|
4634
|
+
constructor(t, e) {
|
|
4635
|
+
super(), this.ft = t, this.yt = e, this.type = "orderBy";
|
|
4639
4636
|
}
|
|
4640
4637
|
_apply(t) {
|
|
4641
|
-
const
|
|
4638
|
+
const e = function(t, e, n) {
|
|
4642
4639
|
if (null !== t.startAt) throw new L(T, "Invalid query. You must not call startAt() or startAfter() before calling orderBy().");
|
|
4643
4640
|
if (null !== t.endAt) throw new L(T, "Invalid query. You must not call endAt() or endBefore() before calling orderBy().");
|
|
4644
|
-
const r = new
|
|
4645
|
-
return function(t,
|
|
4646
|
-
if (null ===
|
|
4641
|
+
const r = new te(e, n);
|
|
4642
|
+
return function(t, e) {
|
|
4643
|
+
if (null === ie(t)) {
|
|
4647
4644
|
// This is the first order by. It must match any inequality.
|
|
4648
|
-
const
|
|
4649
|
-
null !==
|
|
4645
|
+
const n = oe(t);
|
|
4646
|
+
null !== n && mr(t, n, e.field);
|
|
4650
4647
|
}
|
|
4651
4648
|
}(t, r), r;
|
|
4652
4649
|
}
|
|
@@ -4661,11 +4658,11 @@ class nr extends Je {
|
|
|
4661
4658
|
* of the query or if any of the fields in the order by are an uncommitted
|
|
4662
4659
|
* server timestamp.
|
|
4663
4660
|
*/ (t._query, this.ft, this.yt);
|
|
4664
|
-
return new
|
|
4661
|
+
return new cn(t.firestore, t.converter, function(t, e) {
|
|
4665
4662
|
// TODO(dimond): validate that orderBy does not list the same key twice.
|
|
4666
|
-
const
|
|
4667
|
-
return new
|
|
4668
|
-
}(t._query,
|
|
4663
|
+
const n = t.explicitOrderBy.concat([ e ]);
|
|
4664
|
+
return new re(t.path, t.collectionGroup, n, t.filters.slice(), t.limit, t.limitType, t.startAt, t.endAt);
|
|
4665
|
+
}(t._query, e));
|
|
4669
4666
|
}
|
|
4670
4667
|
}
|
|
4671
4668
|
|
|
@@ -4677,18 +4674,18 @@ class nr extends Je {
|
|
|
4677
4674
|
* @param directionStr - Optional direction to sort by ('asc' or 'desc'). If
|
|
4678
4675
|
* not specified, order will be ascending.
|
|
4679
4676
|
* @returns The created {@link Query}.
|
|
4680
|
-
*/ function
|
|
4681
|
-
const
|
|
4682
|
-
return new
|
|
4677
|
+
*/ function nr(t, e = "asc") {
|
|
4678
|
+
const n = e, r = Kn("orderBy", t);
|
|
4679
|
+
return new er(r, n);
|
|
4683
4680
|
}
|
|
4684
4681
|
|
|
4685
|
-
class rr extends
|
|
4686
|
-
constructor(t,
|
|
4687
|
-
super(), this.type = t, this._t =
|
|
4682
|
+
class rr extends Jn {
|
|
4683
|
+
constructor(t, e, n) {
|
|
4684
|
+
super(), this.type = t, this._t = e, this.gt = n;
|
|
4688
4685
|
}
|
|
4689
4686
|
_apply(t) {
|
|
4690
|
-
return new
|
|
4691
|
-
return new
|
|
4687
|
+
return new cn(t.firestore, t.converter, function(t, e, n) {
|
|
4688
|
+
return new re(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), e, n, t.startAt, t.endAt);
|
|
4692
4689
|
}(t._query, this._t, this.gt));
|
|
4693
4690
|
}
|
|
4694
4691
|
}
|
|
@@ -4714,15 +4711,15 @@ class rr extends Je {
|
|
|
4714
4711
|
return st("limitToLast", t), new rr("limitToLast", t, "L" /* Last */);
|
|
4715
4712
|
}
|
|
4716
4713
|
|
|
4717
|
-
class or extends
|
|
4718
|
-
constructor(t,
|
|
4719
|
-
super(), this.type = t, this.bt =
|
|
4714
|
+
class or extends Jn {
|
|
4715
|
+
constructor(t, e, n) {
|
|
4716
|
+
super(), this.type = t, this.bt = e, this.vt = n;
|
|
4720
4717
|
}
|
|
4721
4718
|
_apply(t) {
|
|
4722
|
-
const
|
|
4723
|
-
return new
|
|
4724
|
-
return new
|
|
4725
|
-
}(t._query,
|
|
4719
|
+
const e = fr(t, this.type, this.bt, this.vt);
|
|
4720
|
+
return new cn(t.firestore, t.converter, function(t, e) {
|
|
4721
|
+
return new re(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, e, t.endAt);
|
|
4722
|
+
}(t._query, e));
|
|
4726
4723
|
}
|
|
4727
4724
|
}
|
|
4728
4725
|
|
|
@@ -4735,15 +4732,15 @@ function cr(...t) {
|
|
|
4735
4732
|
/*before=*/ !1);
|
|
4736
4733
|
}
|
|
4737
4734
|
|
|
4738
|
-
class ar extends
|
|
4739
|
-
constructor(t,
|
|
4740
|
-
super(), this.type = t, this.bt =
|
|
4735
|
+
class ar extends Jn {
|
|
4736
|
+
constructor(t, e, n) {
|
|
4737
|
+
super(), this.type = t, this.bt = e, this.vt = n;
|
|
4741
4738
|
}
|
|
4742
4739
|
_apply(t) {
|
|
4743
|
-
const
|
|
4744
|
-
return new
|
|
4745
|
-
return new
|
|
4746
|
-
}(t._query,
|
|
4740
|
+
const e = fr(t, this.type, this.bt, this.vt);
|
|
4741
|
+
return new cn(t.firestore, t.converter, function(t, e) {
|
|
4742
|
+
return new re(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, t.startAt, e);
|
|
4743
|
+
}(t._query, e));
|
|
4747
4744
|
}
|
|
4748
4745
|
}
|
|
4749
4746
|
|
|
@@ -4755,9 +4752,9 @@ function lr(...t) {
|
|
|
4755
4752
|
return new ar("endAt", t, /*before=*/ !1);
|
|
4756
4753
|
}
|
|
4757
4754
|
|
|
4758
|
-
/** Helper function to create a bound from a document or fields */ function fr(t,
|
|
4759
|
-
if (
|
|
4760
|
-
if (!r) throw new L(P, `Can't use a DocumentSnapshot that doesn't exist for ${
|
|
4755
|
+
/** Helper function to create a bound from a document or fields */ function fr(t, e, n, r) {
|
|
4756
|
+
if (n[0] = a(n[0]), n[0] instanceof Wn) return function(t, e, n, r, s) {
|
|
4757
|
+
if (!r) throw new L(P, `Can't use a DocumentSnapshot that doesn't exist for ${n}().`);
|
|
4761
4758
|
const i = [];
|
|
4762
4759
|
// Because people expect to continue/end a query at the exact document
|
|
4763
4760
|
// provided, we need to use the implicit sort order rather than the explicit
|
|
@@ -4766,11 +4763,11 @@ function lr(...t) {
|
|
|
4766
4763
|
// the provided document. Without the key (by using the explicit sort
|
|
4767
4764
|
// orders), multiple documents could match the position, yielding duplicate
|
|
4768
4765
|
// results.
|
|
4769
|
-
for (const
|
|
4770
|
-
const t = r.data.field(
|
|
4771
|
-
if (Pt(t)) throw new L(T, 'Invalid query. You are trying to start or end a query using a document for which the field "' +
|
|
4766
|
+
for (const n of ce(t)) if (n.field.isKeyField()) i.push(qt(e, r.key)); else {
|
|
4767
|
+
const t = r.data.field(n.field);
|
|
4768
|
+
if (Pt(t)) throw new L(T, '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.)');
|
|
4772
4769
|
if (null === t) {
|
|
4773
|
-
const t =
|
|
4770
|
+
const t = n.field.canonicalString();
|
|
4774
4771
|
throw new L(T, `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.`);
|
|
4775
4772
|
}
|
|
4776
4773
|
i.push(t);
|
|
@@ -4779,10 +4776,10 @@ function lr(...t) {
|
|
|
4779
4776
|
}
|
|
4780
4777
|
/**
|
|
4781
4778
|
* Converts a list of field values to a `Bound` for the given query.
|
|
4782
|
-
*/ (t._query, t.firestore._databaseId,
|
|
4779
|
+
*/ (t._query, t.firestore._databaseId, e, n[0]._document, r);
|
|
4783
4780
|
{
|
|
4784
|
-
const s =
|
|
4785
|
-
return function(t,
|
|
4781
|
+
const s = Pn(t.firestore);
|
|
4782
|
+
return function(t, e, n, r, s, i) {
|
|
4786
4783
|
// Use explicit order by's because it has to match the query the user made
|
|
4787
4784
|
const o = t.explicitOrderBy;
|
|
4788
4785
|
if (s.length > o.length) throw new L(T, `Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);
|
|
@@ -4791,13 +4788,13 @@ function lr(...t) {
|
|
|
4791
4788
|
const c = s[i];
|
|
4792
4789
|
if (o[i].field.isKeyField()) {
|
|
4793
4790
|
if ("string" != typeof c) throw new L(T, `Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);
|
|
4794
|
-
if (!
|
|
4795
|
-
const
|
|
4796
|
-
if (!Z.isDocumentKey(
|
|
4797
|
-
const s = new Z(
|
|
4798
|
-
u.push(qt(
|
|
4791
|
+
if (!ue(t) && -1 !== c.indexOf("/")) throw new L(T, `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.`);
|
|
4792
|
+
const n = t.path.child(Y.fromString(c));
|
|
4793
|
+
if (!Z.isDocumentKey(n)) throw new L(T, `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.`);
|
|
4794
|
+
const s = new Z(n);
|
|
4795
|
+
u.push(qt(e, s));
|
|
4799
4796
|
} else {
|
|
4800
|
-
const t =
|
|
4797
|
+
const t = On(n, r, c);
|
|
4801
4798
|
u.push(t);
|
|
4802
4799
|
}
|
|
4803
4800
|
}
|
|
@@ -4807,32 +4804,32 @@ function lr(...t) {
|
|
|
4807
4804
|
* Parses the given `documentIdValue` into a `ReferenceValue`, throwing
|
|
4808
4805
|
* appropriate errors if the value is anything other than a `DocumentReference`
|
|
4809
4806
|
* or `string`, or if the string is malformed.
|
|
4810
|
-
*/ (t._query, t.firestore._databaseId, s,
|
|
4807
|
+
*/ (t._query, t.firestore._databaseId, s, e, n, r);
|
|
4811
4808
|
}
|
|
4812
4809
|
}
|
|
4813
4810
|
|
|
4814
|
-
function dr(t,
|
|
4815
|
-
if ("string" == typeof (
|
|
4816
|
-
if ("" ===
|
|
4817
|
-
if (!
|
|
4818
|
-
const r =
|
|
4811
|
+
function dr(t, e, n) {
|
|
4812
|
+
if ("string" == typeof (n = a(n))) {
|
|
4813
|
+
if ("" === n) throw new L(T, "Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.");
|
|
4814
|
+
if (!ue(e) && -1 !== n.indexOf("/")) throw new L(T, `Invalid query. When querying a collection by FieldPath.documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);
|
|
4815
|
+
const r = e.path.child(Y.fromString(n));
|
|
4819
4816
|
if (!Z.isDocumentKey(r)) throw new L(T, `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}).`);
|
|
4820
4817
|
return qt(t, new Z(r));
|
|
4821
4818
|
}
|
|
4822
|
-
if (
|
|
4823
|
-
throw new L(T, `Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: ${
|
|
4819
|
+
if (n instanceof un) return qt(t, n._key);
|
|
4820
|
+
throw new L(T, `Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: ${nt(n)}.`);
|
|
4824
4821
|
}
|
|
4825
4822
|
|
|
4826
4823
|
/**
|
|
4827
4824
|
* Validates that the value passed into a disjunctive filter satisfies all
|
|
4828
4825
|
* array requirements.
|
|
4829
|
-
*/ function wr(t,
|
|
4830
|
-
if (!Array.isArray(t) || 0 === t.length) throw new L(T, `Invalid Query. A non-empty array is required for '${
|
|
4831
|
-
if (t.length > 10) throw new L(T, `Invalid Query. '${
|
|
4826
|
+
*/ function wr(t, e) {
|
|
4827
|
+
if (!Array.isArray(t) || 0 === t.length) throw new L(T, `Invalid Query. A non-empty array is required for '${e.toString()}' filters.`);
|
|
4828
|
+
if (t.length > 10) throw new L(T, `Invalid Query. '${e.toString()}' filters support a maximum of 10 elements in the value array.`);
|
|
4832
4829
|
}
|
|
4833
4830
|
|
|
4834
|
-
function mr(t,
|
|
4835
|
-
if (!
|
|
4831
|
+
function mr(t, e, n) {
|
|
4832
|
+
if (!n.isEqual(e)) throw new L(T, `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.`);
|
|
4836
4833
|
}
|
|
4837
4834
|
|
|
4838
4835
|
/**
|
|
@@ -4882,17 +4879,17 @@ function mr(t, n, e) {
|
|
|
4882
4879
|
* their `set()` or fails due to invalid data originating from a `toFirestore()`
|
|
4883
4880
|
* call.
|
|
4884
4881
|
*/
|
|
4885
|
-
function pr(t,
|
|
4882
|
+
function pr(t, e, n) {
|
|
4886
4883
|
let r;
|
|
4887
4884
|
// Cast to `any` in order to satisfy the union type constraint on
|
|
4888
4885
|
// toFirestore().
|
|
4889
4886
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4890
|
-
return r = t ?
|
|
4887
|
+
return r = t ? n && (n.merge || n.mergeFields) ? t.toFirestore(e, n) : t.toFirestore(e) : e,
|
|
4891
4888
|
r;
|
|
4892
4889
|
}
|
|
4893
4890
|
|
|
4894
4891
|
class yr extends class {
|
|
4895
|
-
convertValue(t,
|
|
4892
|
+
convertValue(t, e = "none") {
|
|
4896
4893
|
switch (Nt(t)) {
|
|
4897
4894
|
case 0 /* NullValue */ :
|
|
4898
4895
|
return null;
|
|
@@ -4907,7 +4904,7 @@ class yr extends class {
|
|
|
4907
4904
|
return this.convertTimestamp(t.timestampValue);
|
|
4908
4905
|
|
|
4909
4906
|
case 4 /* ServerTimestampValue */ :
|
|
4910
|
-
return this.convertServerTimestamp(t,
|
|
4907
|
+
return this.convertServerTimestamp(t, e);
|
|
4911
4908
|
|
|
4912
4909
|
case 5 /* StringValue */ :
|
|
4913
4910
|
return t.stringValue;
|
|
@@ -4922,32 +4919,32 @@ class yr extends class {
|
|
|
4922
4919
|
return this.convertGeoPoint(t.geoPointValue);
|
|
4923
4920
|
|
|
4924
4921
|
case 9 /* ArrayValue */ :
|
|
4925
|
-
return this.convertArray(t.arrayValue,
|
|
4922
|
+
return this.convertArray(t.arrayValue, e);
|
|
4926
4923
|
|
|
4927
4924
|
case 10 /* ObjectValue */ :
|
|
4928
|
-
return this.convertObject(t.mapValue,
|
|
4925
|
+
return this.convertObject(t.mapValue, e);
|
|
4929
4926
|
|
|
4930
4927
|
default:
|
|
4931
4928
|
throw _();
|
|
4932
4929
|
}
|
|
4933
4930
|
}
|
|
4934
|
-
convertObject(t,
|
|
4935
|
-
const
|
|
4931
|
+
convertObject(t, e) {
|
|
4932
|
+
const n = {};
|
|
4936
4933
|
return gt(t.fields, ((t, r) => {
|
|
4937
|
-
|
|
4938
|
-
})),
|
|
4934
|
+
n[t] = this.convertValue(r, e);
|
|
4935
|
+
})), n;
|
|
4939
4936
|
}
|
|
4940
4937
|
convertGeoPoint(t) {
|
|
4941
|
-
return new
|
|
4938
|
+
return new gn(Tt(t.latitude), Tt(t.longitude));
|
|
4942
4939
|
}
|
|
4943
|
-
convertArray(t,
|
|
4944
|
-
return (t.values || []).map((t => this.convertValue(t,
|
|
4940
|
+
convertArray(t, e) {
|
|
4941
|
+
return (t.values || []).map((t => this.convertValue(t, e)));
|
|
4945
4942
|
}
|
|
4946
|
-
convertServerTimestamp(t,
|
|
4947
|
-
switch (
|
|
4943
|
+
convertServerTimestamp(t, e) {
|
|
4944
|
+
switch (e) {
|
|
4948
4945
|
case "previous":
|
|
4949
|
-
const
|
|
4950
|
-
return null ==
|
|
4946
|
+
const n = Rt(t);
|
|
4947
|
+
return null == n ? null : this.convertValue(n, e);
|
|
4951
4948
|
|
|
4952
4949
|
case "estimate":
|
|
4953
4950
|
return this.convertTimestamp(Vt(t));
|
|
@@ -4957,16 +4954,16 @@ class yr extends class {
|
|
|
4957
4954
|
}
|
|
4958
4955
|
}
|
|
4959
4956
|
convertTimestamp(t) {
|
|
4960
|
-
const
|
|
4961
|
-
return new pt(
|
|
4957
|
+
const e = It(t);
|
|
4958
|
+
return new pt(e.seconds, e.nanos);
|
|
4962
4959
|
}
|
|
4963
|
-
convertDocumentKey(t,
|
|
4964
|
-
const
|
|
4965
|
-
g(
|
|
4966
|
-
const r = new G(
|
|
4967
|
-
return r.isEqual(
|
|
4960
|
+
convertDocumentKey(t, e) {
|
|
4961
|
+
const n = Y.fromString(t);
|
|
4962
|
+
g(ze(n));
|
|
4963
|
+
const r = new G(n.get(1), n.get(3)), s = new Z(n.popFirst(5));
|
|
4964
|
+
return r.isEqual(e) ||
|
|
4968
4965
|
// TODO(b/64130202): Somehow support foreign references.
|
|
4969
|
-
m(`Document ${s} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${
|
|
4966
|
+
m(`Document ${s} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${e.projectId}/${e.database}) instead.`),
|
|
4970
4967
|
s;
|
|
4971
4968
|
}
|
|
4972
4969
|
} {
|
|
@@ -4974,11 +4971,11 @@ class yr extends class {
|
|
|
4974
4971
|
super(), this.firestore = t;
|
|
4975
4972
|
}
|
|
4976
4973
|
convertBytes(t) {
|
|
4977
|
-
return new
|
|
4974
|
+
return new yn(t);
|
|
4978
4975
|
}
|
|
4979
4976
|
convertReference(t) {
|
|
4980
|
-
const
|
|
4981
|
-
return new
|
|
4977
|
+
const e = this.convertDocumentKey(t, this.firestore._databaseId);
|
|
4978
|
+
return new un(this.firestore, /* converter= */ null, e);
|
|
4982
4979
|
}
|
|
4983
4980
|
}
|
|
4984
4981
|
|
|
@@ -4995,11 +4992,11 @@ class yr extends class {
|
|
|
4995
4992
|
* @returns A Promise resolved with a `DocumentSnapshot` containing the current
|
|
4996
4993
|
* document contents.
|
|
4997
4994
|
*/ function _r(t) {
|
|
4998
|
-
const
|
|
4999
|
-
return
|
|
5000
|
-
g(1 ===
|
|
5001
|
-
const r =
|
|
5002
|
-
return new
|
|
4995
|
+
const e = Xe((t = rt(t, un)).firestore), n = new yr(t.firestore);
|
|
4996
|
+
return Ke(e, [ t._key ]).then((e => {
|
|
4997
|
+
g(1 === e.length);
|
|
4998
|
+
const r = e[0];
|
|
4999
|
+
return new Wn(t.firestore, n, t._key, r.isFoundDocument() ? r : null, t.converter);
|
|
5003
5000
|
}));
|
|
5004
5001
|
}
|
|
5005
5002
|
|
|
@@ -5016,31 +5013,31 @@ class yr extends class {
|
|
|
5016
5013
|
* @returns A Promise that will be resolved with the results of the query.
|
|
5017
5014
|
*/ function gr(t) {
|
|
5018
5015
|
!function(t) {
|
|
5019
|
-
if (
|
|
5020
|
-
}((t = rt(t,
|
|
5021
|
-
const
|
|
5022
|
-
return
|
|
5023
|
-
const r =
|
|
5024
|
-
return
|
|
5016
|
+
if (se(t) && 0 === t.explicitOrderBy.length) throw new L(q, "limitToLast() queries require specifying at least one orderBy() clause");
|
|
5017
|
+
}((t = rt(t, cn))._query);
|
|
5018
|
+
const e = Xe(t.firestore), n = new yr(t.firestore);
|
|
5019
|
+
return Je(e, t._query).then((e => {
|
|
5020
|
+
const r = e.map((e => new Gn(t.firestore, n, e.key, e, t.converter)));
|
|
5021
|
+
return se(t._query) &&
|
|
5025
5022
|
// Limit to last queries reverse the orderBy constraint that was
|
|
5026
5023
|
// specified by the user. As such, we need to reverse the order of the
|
|
5027
5024
|
// results to return the documents in the expected order.
|
|
5028
|
-
r.reverse(), new
|
|
5025
|
+
r.reverse(), new Hn(t, r);
|
|
5029
5026
|
}));
|
|
5030
5027
|
}
|
|
5031
5028
|
|
|
5032
|
-
function br(t,
|
|
5033
|
-
const r = pr((t = rt(t,
|
|
5034
|
-
return
|
|
5029
|
+
function br(t, e, n) {
|
|
5030
|
+
const r = pr((t = rt(t, un)).converter, e, n), s = Rn(Pn(t.firestore), "setDoc", t._key, r, null !== t.converter, n);
|
|
5031
|
+
return Ye(Xe(t.firestore), [ s.toMutation(t._key, _e.none()) ]);
|
|
5035
5032
|
}
|
|
5036
5033
|
|
|
5037
|
-
function vr(t,
|
|
5038
|
-
const s =
|
|
5034
|
+
function vr(t, e, n, ...r) {
|
|
5035
|
+
const s = Pn((t = rt(t, un)).firestore);
|
|
5039
5036
|
// For Compat types, we have to "extract" the underlying types before
|
|
5040
5037
|
// performing validation.
|
|
5041
5038
|
let i;
|
|
5042
|
-
i = "string" == typeof (
|
|
5043
|
-
return
|
|
5039
|
+
i = "string" == typeof (e = a(e)) || e instanceof mn ? xn(s, "updateDoc", t._key, e, n, r) : qn(s, "updateDoc", t._key, e);
|
|
5040
|
+
return Ye(Xe(t.firestore), [ i.toMutation(t._key, _e.exists(!0)) ]);
|
|
5044
5041
|
}
|
|
5045
5042
|
|
|
5046
5043
|
/**
|
|
@@ -5055,7 +5052,7 @@ function vr(t, n, e, ...r) {
|
|
|
5055
5052
|
* @returns A `Promise` resolved once the document has been successfully
|
|
5056
5053
|
* deleted from the backend.
|
|
5057
5054
|
*/ function Er(t) {
|
|
5058
|
-
return
|
|
5055
|
+
return Ye(Xe((t = rt(t, un)).firestore), [ new Ee(t._key, _e.none()) ]);
|
|
5059
5056
|
}
|
|
5060
5057
|
|
|
5061
5058
|
/**
|
|
@@ -5071,9 +5068,9 @@ function vr(t, n, e, ...r) {
|
|
|
5071
5068
|
* @param data - An Object containing the data for the new document.
|
|
5072
5069
|
* @returns A `Promise` resolved with a `DocumentReference` pointing to the
|
|
5073
5070
|
* newly created document after it has been written to the backend.
|
|
5074
|
-
*/ function Ir(t,
|
|
5075
|
-
const
|
|
5076
|
-
return
|
|
5071
|
+
*/ function Ir(t, e) {
|
|
5072
|
+
const n = fn(t = rt(t, an)), r = pr(t.converter, e), s = Rn(Pn(t.firestore), "addDoc", n._key, r, null !== n.converter, {});
|
|
5073
|
+
return Ye(Xe(t.firestore), [ s.toMutation(n._key, _e.exists(!1)) ]).then((() => n));
|
|
5077
5074
|
}
|
|
5078
5075
|
|
|
5079
5076
|
/**
|
|
@@ -5096,14 +5093,14 @@ function vr(t, n, e, ...r) {
|
|
|
5096
5093
|
* Returns a sentinel for use with {@link @firebase/firestore/lite#(updateDoc:1)} or
|
|
5097
5094
|
* {@link @firebase/firestore/lite#(setDoc:1)} with `{merge: true}` to mark a field for deletion.
|
|
5098
5095
|
*/ function Tr() {
|
|
5099
|
-
return new
|
|
5096
|
+
return new Vn("deleteField");
|
|
5100
5097
|
}
|
|
5101
5098
|
|
|
5102
5099
|
/**
|
|
5103
5100
|
* Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
|
|
5104
5101
|
* include a server-generated timestamp in the written data.
|
|
5105
5102
|
*/ function Ar() {
|
|
5106
|
-
return new
|
|
5103
|
+
return new Dn("serverTimestamp");
|
|
5107
5104
|
}
|
|
5108
5105
|
|
|
5109
5106
|
/**
|
|
@@ -5120,7 +5117,7 @@ function vr(t, n, e, ...r) {
|
|
|
5120
5117
|
*/ function Pr(...t) {
|
|
5121
5118
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5122
5119
|
// update() since we'd need the Firestore instance to do this.
|
|
5123
|
-
return new $
|
|
5120
|
+
return new $n("arrayUnion", t);
|
|
5124
5121
|
}
|
|
5125
5122
|
|
|
5126
5123
|
/**
|
|
@@ -5136,7 +5133,7 @@ function vr(t, n, e, ...r) {
|
|
|
5136
5133
|
*/ function Rr(...t) {
|
|
5137
5134
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5138
5135
|
// update() since we'd need the Firestore instance to do this.
|
|
5139
|
-
return new
|
|
5136
|
+
return new Fn("arrayRemove", t);
|
|
5140
5137
|
}
|
|
5141
5138
|
|
|
5142
5139
|
/**
|
|
@@ -5158,7 +5155,7 @@ function vr(t, n, e, ...r) {
|
|
|
5158
5155
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5159
5156
|
* `updateDoc()`
|
|
5160
5157
|
*/ function Vr(t) {
|
|
5161
|
-
return new
|
|
5158
|
+
return new Sn("increment", t);
|
|
5162
5159
|
}
|
|
5163
5160
|
|
|
5164
5161
|
/**
|
|
@@ -5186,23 +5183,23 @@ function vr(t, n, e, ...r) {
|
|
|
5186
5183
|
* called.
|
|
5187
5184
|
*/ class Nr {
|
|
5188
5185
|
/** @hideconstructor */
|
|
5189
|
-
constructor(t,
|
|
5190
|
-
this._firestore = t, this._commitHandler =
|
|
5191
|
-
this._dataReader =
|
|
5186
|
+
constructor(t, e) {
|
|
5187
|
+
this._firestore = t, this._commitHandler = e, this._mutations = [], this._committed = !1,
|
|
5188
|
+
this._dataReader = Pn(t);
|
|
5192
5189
|
}
|
|
5193
|
-
set(t,
|
|
5190
|
+
set(t, e, n) {
|
|
5194
5191
|
this._verifyNotCommitted();
|
|
5195
|
-
const r = Dr(t, this._firestore), s = pr(r.converter,
|
|
5196
|
-
return this._mutations.push(i.toMutation(r._key,
|
|
5192
|
+
const r = Dr(t, this._firestore), s = pr(r.converter, e, n), i = Rn(this._dataReader, "WriteBatch.set", r._key, s, null !== r.converter, n);
|
|
5193
|
+
return this._mutations.push(i.toMutation(r._key, _e.none())), this;
|
|
5197
5194
|
}
|
|
5198
|
-
update(t,
|
|
5195
|
+
update(t, e, n, ...r) {
|
|
5199
5196
|
this._verifyNotCommitted();
|
|
5200
5197
|
const s = Dr(t, this._firestore);
|
|
5201
5198
|
// For Compat types, we have to "extract" the underlying types before
|
|
5202
5199
|
// performing validation.
|
|
5203
5200
|
let i;
|
|
5204
|
-
return i = "string" == typeof (
|
|
5205
|
-
this._mutations.push(i.toMutation(s._key,
|
|
5201
|
+
return i = "string" == typeof (e = a(e)) || e instanceof mn ? xn(this._dataReader, "WriteBatch.update", s._key, e, n, r) : qn(this._dataReader, "WriteBatch.update", s._key, e),
|
|
5202
|
+
this._mutations.push(i.toMutation(s._key, _e.exists(!0))), this;
|
|
5206
5203
|
}
|
|
5207
5204
|
/**
|
|
5208
5205
|
* Deletes the document referred to by the provided {@link DocumentReference}.
|
|
@@ -5211,8 +5208,8 @@ function vr(t, n, e, ...r) {
|
|
|
5211
5208
|
* @returns This `WriteBatch` instance. Used for chaining method calls.
|
|
5212
5209
|
*/ delete(t) {
|
|
5213
5210
|
this._verifyNotCommitted();
|
|
5214
|
-
const
|
|
5215
|
-
return this._mutations = this._mutations.concat(new
|
|
5211
|
+
const e = Dr(t, this._firestore);
|
|
5212
|
+
return this._mutations = this._mutations.concat(new Ee(e._key, _e.none())), this;
|
|
5216
5213
|
}
|
|
5217
5214
|
/**
|
|
5218
5215
|
* Commits all of the writes in this write batch as a single atomic unit.
|
|
@@ -5233,8 +5230,8 @@ function vr(t, n, e, ...r) {
|
|
|
5233
5230
|
}
|
|
5234
5231
|
}
|
|
5235
5232
|
|
|
5236
|
-
function Dr(t,
|
|
5237
|
-
if ((t = a(t)).firestore !==
|
|
5233
|
+
function Dr(t, e) {
|
|
5234
|
+
if ((t = a(t)).firestore !== e) throw new L(T, "Provided document reference is from a different Firestore instance.");
|
|
5238
5235
|
return t;
|
|
5239
5236
|
}
|
|
5240
5237
|
|
|
@@ -5251,8 +5248,8 @@ function Dr(t, n) {
|
|
|
5251
5248
|
* @returns A `WriteBatch` that can be used to atomically execute multiple
|
|
5252
5249
|
* writes.
|
|
5253
5250
|
*/ function $r(t) {
|
|
5254
|
-
const
|
|
5255
|
-
return new Nr(t, (t =>
|
|
5251
|
+
const e = Xe(t = rt(t, en));
|
|
5252
|
+
return new Nr(t, (t => Ye(e, t)));
|
|
5256
5253
|
}
|
|
5257
5254
|
|
|
5258
5255
|
/**
|
|
@@ -5294,66 +5291,66 @@ function Dr(t, n) {
|
|
|
5294
5291
|
}
|
|
5295
5292
|
async lookup(t) {
|
|
5296
5293
|
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new L(T, "Firestore transactions require all reads to be executed before all writes.");
|
|
5297
|
-
const
|
|
5298
|
-
return
|
|
5294
|
+
const e = await Ke(this.datastore, t);
|
|
5295
|
+
return e.forEach((t => this.recordVersion(t))), e;
|
|
5299
5296
|
}
|
|
5300
|
-
set(t,
|
|
5301
|
-
this.write(
|
|
5297
|
+
set(t, e) {
|
|
5298
|
+
this.write(e.toMutation(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5302
5299
|
}
|
|
5303
|
-
update(t,
|
|
5300
|
+
update(t, e) {
|
|
5304
5301
|
try {
|
|
5305
|
-
this.write(
|
|
5302
|
+
this.write(e.toMutation(t, this.preconditionForUpdate(t)));
|
|
5306
5303
|
} catch (t) {
|
|
5307
5304
|
this.lastWriteError = t;
|
|
5308
5305
|
}
|
|
5309
5306
|
this.writtenDocs.add(t.toString());
|
|
5310
5307
|
}
|
|
5311
5308
|
delete(t) {
|
|
5312
|
-
this.write(new
|
|
5309
|
+
this.write(new Ee(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5313
5310
|
}
|
|
5314
5311
|
async commit() {
|
|
5315
5312
|
if (this.ensureCommitNotCalled(), this.lastWriteError) throw this.lastWriteError;
|
|
5316
5313
|
const t = this.readVersions;
|
|
5317
5314
|
// For each mutation, note that the doc was written.
|
|
5318
|
-
this.mutations.forEach((
|
|
5319
|
-
t.delete(
|
|
5315
|
+
this.mutations.forEach((e => {
|
|
5316
|
+
t.delete(e.key.toString());
|
|
5320
5317
|
})),
|
|
5321
5318
|
// For each document that was read but not written to, we want to perform
|
|
5322
5319
|
// a `verify` operation.
|
|
5323
|
-
t.forEach(((t,
|
|
5324
|
-
const
|
|
5325
|
-
this.mutations.push(new
|
|
5326
|
-
})), await
|
|
5320
|
+
t.forEach(((t, e) => {
|
|
5321
|
+
const n = Z.fromPath(e);
|
|
5322
|
+
this.mutations.push(new Ie(n, this.precondition(n)));
|
|
5323
|
+
})), await Ye(this.datastore, this.mutations), this.committed = !0;
|
|
5327
5324
|
}
|
|
5328
5325
|
recordVersion(t) {
|
|
5329
|
-
let
|
|
5330
|
-
if (t.isFoundDocument())
|
|
5326
|
+
let e;
|
|
5327
|
+
if (t.isFoundDocument()) e = t.version; else {
|
|
5331
5328
|
if (!t.isNoDocument()) throw _();
|
|
5332
5329
|
// For deleted docs, we must use baseVersion 0 when we overwrite them.
|
|
5333
|
-
|
|
5330
|
+
e = yt.min();
|
|
5334
5331
|
}
|
|
5335
|
-
const
|
|
5336
|
-
if (
|
|
5337
|
-
if (!
|
|
5332
|
+
const n = this.readVersions.get(t.key.toString());
|
|
5333
|
+
if (n) {
|
|
5334
|
+
if (!e.isEqual(n))
|
|
5338
5335
|
// This transaction will fail no matter what.
|
|
5339
5336
|
throw new L(F, "Document version changed between two reads.");
|
|
5340
|
-
} else this.readVersions.set(t.key.toString(),
|
|
5337
|
+
} else this.readVersions.set(t.key.toString(), e);
|
|
5341
5338
|
}
|
|
5342
5339
|
/**
|
|
5343
5340
|
* Returns the version of this document when it was read in this transaction,
|
|
5344
5341
|
* as a precondition, or no precondition if it was not read.
|
|
5345
5342
|
*/ precondition(t) {
|
|
5346
|
-
const
|
|
5347
|
-
return !this.writtenDocs.has(t.toString()) &&
|
|
5343
|
+
const e = this.readVersions.get(t.toString());
|
|
5344
|
+
return !this.writtenDocs.has(t.toString()) && e ? _e.updateTime(e) : _e.none();
|
|
5348
5345
|
}
|
|
5349
5346
|
/**
|
|
5350
5347
|
* Returns the precondition for a document if the operation is an update.
|
|
5351
5348
|
*/ preconditionForUpdate(t) {
|
|
5352
|
-
const
|
|
5349
|
+
const e = this.readVersions.get(t.toString());
|
|
5353
5350
|
// The first time a document is written, we want to take into account the
|
|
5354
5351
|
// read time and existence
|
|
5355
|
-
if (!this.writtenDocs.has(t.toString()) &&
|
|
5356
|
-
if (
|
|
5352
|
+
if (!this.writtenDocs.has(t.toString()) && e) {
|
|
5353
|
+
if (e.isEqual(yt.min()))
|
|
5357
5354
|
// The document doesn't exist, so fail the transaction.
|
|
5358
5355
|
// This has to be validated locally because you can't send a
|
|
5359
5356
|
// precondition that a document does not exist without changing the
|
|
@@ -5365,11 +5362,11 @@ function Dr(t, n) {
|
|
|
5365
5362
|
// transaction.
|
|
5366
5363
|
throw new L(T, "Can't update a document that doesn't exist.");
|
|
5367
5364
|
// Document exists, base precondition on document update time.
|
|
5368
|
-
return
|
|
5365
|
+
return _e.updateTime(e);
|
|
5369
5366
|
}
|
|
5370
5367
|
// Document was not read, so we just use the preconditions for a blind
|
|
5371
5368
|
// update.
|
|
5372
|
-
return
|
|
5369
|
+
return _e.exists(!0);
|
|
5373
5370
|
}
|
|
5374
5371
|
write(t) {
|
|
5375
5372
|
this.ensureCommitNotCalled(), this.mutations.push(t);
|
|
@@ -5398,19 +5395,19 @@ function Dr(t, n) {
|
|
|
5398
5395
|
* with backoff.
|
|
5399
5396
|
*/
|
|
5400
5397
|
class Sr {
|
|
5401
|
-
constructor(t,
|
|
5402
|
-
this.asyncQueue = t, this.datastore =
|
|
5403
|
-
this.Et = 5, this.It = new
|
|
5398
|
+
constructor(t, e, n, r) {
|
|
5399
|
+
this.asyncQueue = t, this.datastore = e, this.updateFunction = n, this.deferred = r,
|
|
5400
|
+
this.Et = 5, this.It = new Ge(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
|
|
5404
5401
|
}
|
|
5405
5402
|
/** Runs the transaction and sets the result on deferred. */ run() {
|
|
5406
5403
|
this.Et -= 1, this.Tt();
|
|
5407
5404
|
}
|
|
5408
5405
|
Tt() {
|
|
5409
5406
|
this.It.W((async () => {
|
|
5410
|
-
const t = new Fr(this.datastore),
|
|
5411
|
-
|
|
5407
|
+
const t = new Fr(this.datastore), e = this.At(t);
|
|
5408
|
+
e && e.then((e => {
|
|
5412
5409
|
this.asyncQueue.enqueueAndForget((() => t.commit().then((() => {
|
|
5413
|
-
this.deferred.resolve(
|
|
5410
|
+
this.deferred.resolve(e);
|
|
5414
5411
|
})).catch((t => {
|
|
5415
5412
|
this.Pt(t);
|
|
5416
5413
|
}))));
|
|
@@ -5421,8 +5418,8 @@ class Sr {
|
|
|
5421
5418
|
}
|
|
5422
5419
|
At(t) {
|
|
5423
5420
|
try {
|
|
5424
|
-
const
|
|
5425
|
-
return !it(
|
|
5421
|
+
const e = this.updateFunction(t);
|
|
5422
|
+
return !it(e) && e.catch && e.then ? e : (this.deferred.reject(Error("Transaction callback must return a Promise")),
|
|
5426
5423
|
null);
|
|
5427
5424
|
} catch (t) {
|
|
5428
5425
|
// Do not retry errors thrown by user provided updateFunction.
|
|
@@ -5437,8 +5434,8 @@ class Sr {
|
|
|
5437
5434
|
if ("FirebaseError" === t.name) {
|
|
5438
5435
|
// In transactions, the backend will fail outdated reads with FAILED_PRECONDITION and
|
|
5439
5436
|
// non-matching document versions with ABORTED. These errors should be retried.
|
|
5440
|
-
const
|
|
5441
|
-
return "aborted" ===
|
|
5437
|
+
const e = t.code;
|
|
5438
|
+
return "aborted" === e || "failed-precondition" === e || !
|
|
5442
5439
|
/**
|
|
5443
5440
|
* Determines whether an error code represents a permanent error when received
|
|
5444
5441
|
* in response to a non-write operation.
|
|
@@ -5478,7 +5475,7 @@ class Sr {
|
|
|
5478
5475
|
default:
|
|
5479
5476
|
return _();
|
|
5480
5477
|
}
|
|
5481
|
-
}(
|
|
5478
|
+
}(e);
|
|
5482
5479
|
}
|
|
5483
5480
|
return !1;
|
|
5484
5481
|
}
|
|
@@ -5533,8 +5530,8 @@ class Sr {
|
|
|
5533
5530
|
* in newer versions of TypeScript defines `finally`, which is not available in
|
|
5534
5531
|
* IE.
|
|
5535
5532
|
*/ class xr {
|
|
5536
|
-
constructor(t,
|
|
5537
|
-
this.asyncQueue = t, this.timerId =
|
|
5533
|
+
constructor(t, e, n, r, s) {
|
|
5534
|
+
this.asyncQueue = t, this.timerId = e, this.targetTimeMs = n, this.op = r, this.removalCallback = s,
|
|
5538
5535
|
this.deferred = new U, this.then = this.deferred.promise.then.bind(this.deferred.promise),
|
|
5539
5536
|
// It's normal for the deferred promise to be canceled (due to cancellation)
|
|
5540
5537
|
// and so we attach a dummy catch callback to avoid
|
|
@@ -5554,9 +5551,9 @@ class Sr {
|
|
|
5554
5551
|
* from its delayedOperations list.
|
|
5555
5552
|
* PORTING NOTE: This exists to prevent making removeDelayedOperation() and
|
|
5556
5553
|
* the DelayedOperation class public.
|
|
5557
|
-
*/ static createAndSchedule(t,
|
|
5558
|
-
const i = Date.now() +
|
|
5559
|
-
return o.start(
|
|
5554
|
+
*/ static createAndSchedule(t, e, n, r, s) {
|
|
5555
|
+
const i = Date.now() + n, o = new xr(t, e, i, r, s);
|
|
5556
|
+
return o.start(n), o;
|
|
5560
5557
|
}
|
|
5561
5558
|
/**
|
|
5562
5559
|
* Starts the timer. This is called immediately after construction by
|
|
@@ -5627,7 +5624,7 @@ class Sr {
|
|
|
5627
5624
|
// List of TimerIds to fast-forward delays for.
|
|
5628
5625
|
this.xt = [],
|
|
5629
5626
|
// Backoff timer used to schedule retries for retryable operations
|
|
5630
|
-
this.It = new
|
|
5627
|
+
this.It = new Ge(this, "async_queue_retry" /* AsyncQueueRetry */),
|
|
5631
5628
|
// Visibility handler that triggers an immediate retry of all retryable
|
|
5632
5629
|
// operations. Meant to speed up recovery when we regain file system access
|
|
5633
5630
|
// after page comes into foreground.
|
|
@@ -5656,8 +5653,8 @@ class Sr {
|
|
|
5656
5653
|
enterRestrictedMode(t) {
|
|
5657
5654
|
if (!this.Dt) {
|
|
5658
5655
|
this.Dt = !0, this.qt = t || !1;
|
|
5659
|
-
const
|
|
5660
|
-
|
|
5656
|
+
const e = qr();
|
|
5657
|
+
e && "function" == typeof e.removeEventListener && e.removeEventListener("visibilitychange", this.Ot);
|
|
5661
5658
|
}
|
|
5662
5659
|
}
|
|
5663
5660
|
enqueue(t) {
|
|
@@ -5667,9 +5664,9 @@ class Sr {
|
|
|
5667
5664
|
// Create a deferred Promise that we can return to the callee. This
|
|
5668
5665
|
// allows us to return a "hanging Promise" only to the callee and still
|
|
5669
5666
|
// advance the queue even when the operation is not run.
|
|
5670
|
-
const
|
|
5671
|
-
return this.Lt((() => this.Dt && this.qt ? Promise.resolve() : (t().then(
|
|
5672
|
-
|
|
5667
|
+
const e = new U;
|
|
5668
|
+
return this.Lt((() => this.Dt && this.qt ? Promise.resolve() : (t().then(e.resolve, e.reject),
|
|
5669
|
+
e.promise))).then((() => e.promise));
|
|
5673
5670
|
}
|
|
5674
5671
|
enqueueRetryable(t) {
|
|
5675
5672
|
this.enqueueAndForget((() => (this.Nt.push(t), this.Ut())));
|
|
@@ -5739,7 +5736,7 @@ class Sr {
|
|
|
5739
5736
|
}
|
|
5740
5737
|
}
|
|
5741
5738
|
Lt(t) {
|
|
5742
|
-
const
|
|
5739
|
+
const e = this.Vt.then((() => (this.St = !0, t().catch((t => {
|
|
5743
5740
|
this.Ft = t, this.St = !1;
|
|
5744
5741
|
// Re-throw the error so that this.tail becomes a rejected Promise and
|
|
5745
5742
|
// all further attempts to chain (via .then) will just short-circuit
|
|
@@ -5751,9 +5748,9 @@ class Sr {
|
|
|
5751
5748
|
* @param error - Error or FirestoreError
|
|
5752
5749
|
*/
|
|
5753
5750
|
function(t) {
|
|
5754
|
-
let
|
|
5755
|
-
t.stack && (
|
|
5756
|
-
return
|
|
5751
|
+
let e = t.message || "";
|
|
5752
|
+
t.stack && (e = t.stack.includes(t.message) ? t.stack : t.message + "\n" + t.stack);
|
|
5753
|
+
return e;
|
|
5757
5754
|
}
|
|
5758
5755
|
/**
|
|
5759
5756
|
* @license
|
|
@@ -5781,13 +5778,13 @@ class Sr {
|
|
|
5781
5778
|
* {@link runTransaction}.
|
|
5782
5779
|
*/ (t)), t;
|
|
5783
5780
|
})).then((t => (this.St = !1, t))))));
|
|
5784
|
-
return this.Vt =
|
|
5781
|
+
return this.Vt = e, e;
|
|
5785
5782
|
}
|
|
5786
|
-
enqueueAfterDelay(t,
|
|
5783
|
+
enqueueAfterDelay(t, e, n) {
|
|
5787
5784
|
this.Ct(),
|
|
5788
5785
|
// Fast-forward delays for timerIds that have been overriden.
|
|
5789
|
-
this.xt.indexOf(t) > -1 && (
|
|
5790
|
-
const r = xr.createAndSchedule(this, t,
|
|
5786
|
+
this.xt.indexOf(t) > -1 && (e = 0);
|
|
5787
|
+
const r = xr.createAndSchedule(this, t, e, n, (t => this.jt(t)));
|
|
5791
5788
|
return this.$t.push(r), r;
|
|
5792
5789
|
}
|
|
5793
5790
|
Ct() {
|
|
@@ -5811,7 +5808,7 @@ class Sr {
|
|
|
5811
5808
|
* For Tests: Determine if a delayed operation with a particular TimerId
|
|
5812
5809
|
* exists.
|
|
5813
5810
|
*/ Mt(t) {
|
|
5814
|
-
for (const
|
|
5811
|
+
for (const e of this.$t) if (e.timerId === t) return !0;
|
|
5815
5812
|
return !1;
|
|
5816
5813
|
}
|
|
5817
5814
|
/**
|
|
@@ -5824,8 +5821,8 @@ class Sr {
|
|
|
5824
5821
|
// Note that draining may generate more delayed ops, so we do that first.
|
|
5825
5822
|
return this.kt().then((() => {
|
|
5826
5823
|
// Run ops in the same order they'd run if they ran naturally.
|
|
5827
|
-
this.$t.sort(((t,
|
|
5828
|
-
for (const
|
|
5824
|
+
this.$t.sort(((t, e) => t.targetTimeMs - e.targetTimeMs));
|
|
5825
|
+
for (const e of this.$t) if (e.skipDelay(), "all" /* All */ !== t && e.timerId === t) break;
|
|
5829
5826
|
return this.kt();
|
|
5830
5827
|
}));
|
|
5831
5828
|
}
|
|
@@ -5836,15 +5833,15 @@ class Sr {
|
|
|
5836
5833
|
}
|
|
5837
5834
|
/** Called once a DelayedOperation is run or canceled. */ jt(t) {
|
|
5838
5835
|
// NOTE: indexOf / slice are O(n), but delayedOperations is expected to be small.
|
|
5839
|
-
const
|
|
5840
|
-
this.$t.splice(
|
|
5836
|
+
const e = this.$t.indexOf(t);
|
|
5837
|
+
this.$t.splice(e, 1);
|
|
5841
5838
|
}
|
|
5842
5839
|
}
|
|
5843
5840
|
|
|
5844
5841
|
class Cr {
|
|
5845
5842
|
/** @hideconstructor */
|
|
5846
|
-
constructor(t,
|
|
5847
|
-
this._firestore = t, this._transaction =
|
|
5843
|
+
constructor(t, e) {
|
|
5844
|
+
this._firestore = t, this._transaction = e, this._dataReader = Pn(t);
|
|
5848
5845
|
}
|
|
5849
5846
|
/**
|
|
5850
5847
|
* Reads the document referenced by the provided {@link DocumentReference}.
|
|
@@ -5852,25 +5849,25 @@ class Cr {
|
|
|
5852
5849
|
* @param documentRef - A reference to the document to be read.
|
|
5853
5850
|
* @returns A `DocumentSnapshot` with the read data.
|
|
5854
5851
|
*/ get(t) {
|
|
5855
|
-
const
|
|
5856
|
-
return this._transaction.lookup([
|
|
5852
|
+
const e = Dr(t, this._firestore), n = new yr(this._firestore);
|
|
5853
|
+
return this._transaction.lookup([ e._key ]).then((t => {
|
|
5857
5854
|
if (!t || 1 !== t.length) return _();
|
|
5858
5855
|
const r = t[0];
|
|
5859
|
-
if (r.isFoundDocument()) return new
|
|
5860
|
-
if (r.isNoDocument()) return new
|
|
5856
|
+
if (r.isFoundDocument()) return new Wn(this._firestore, n, r.key, r, e.converter);
|
|
5857
|
+
if (r.isNoDocument()) return new Wn(this._firestore, n, e._key, null, e.converter);
|
|
5861
5858
|
throw _();
|
|
5862
5859
|
}));
|
|
5863
5860
|
}
|
|
5864
|
-
set(t,
|
|
5865
|
-
const r = Dr(t, this._firestore), s = pr(r.converter,
|
|
5861
|
+
set(t, e, n) {
|
|
5862
|
+
const r = Dr(t, this._firestore), s = pr(r.converter, e, n), i = Rn(this._dataReader, "Transaction.set", r._key, s, null !== r.converter, n);
|
|
5866
5863
|
return this._transaction.set(r._key, i), this;
|
|
5867
5864
|
}
|
|
5868
|
-
update(t,
|
|
5865
|
+
update(t, e, n, ...r) {
|
|
5869
5866
|
const s = Dr(t, this._firestore);
|
|
5870
5867
|
// For Compat types, we have to "extract" the underlying types before
|
|
5871
5868
|
// performing validation.
|
|
5872
5869
|
let i;
|
|
5873
|
-
return i = "string" == typeof (
|
|
5870
|
+
return i = "string" == typeof (e = a(e)) || e instanceof mn ? xn(this._dataReader, "Transaction.update", s._key, e, n, r) : qn(this._dataReader, "Transaction.update", s._key, e),
|
|
5874
5871
|
this._transaction.update(s._key, i), this;
|
|
5875
5872
|
}
|
|
5876
5873
|
/**
|
|
@@ -5879,8 +5876,8 @@ class Cr {
|
|
|
5879
5876
|
* @param documentRef - A reference to the document to be deleted.
|
|
5880
5877
|
* @returns This `Transaction` instance. Used for chaining method calls.
|
|
5881
5878
|
*/ delete(t) {
|
|
5882
|
-
const
|
|
5883
|
-
return this._transaction.delete(
|
|
5879
|
+
const e = Dr(t, this._firestore);
|
|
5880
|
+
return this._transaction.delete(e._key), this;
|
|
5884
5881
|
}
|
|
5885
5882
|
}
|
|
5886
5883
|
|
|
@@ -5900,9 +5897,9 @@ class Cr {
|
|
|
5900
5897
|
* (the `updateFunction` returned a failed promise), the promise returned by the
|
|
5901
5898
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
5902
5899
|
* rejected promise with the corresponding failure error is returned.
|
|
5903
|
-
*/ function Lr(t,
|
|
5904
|
-
const
|
|
5905
|
-
return new Sr(new Or,
|
|
5900
|
+
*/ function Lr(t, e) {
|
|
5901
|
+
const n = Xe(t = rt(t, en)), r = new U;
|
|
5902
|
+
return new Sr(new Or, n, (n => e(new Cr(t, n))), r).run(), r.promise;
|
|
5906
5903
|
}
|
|
5907
5904
|
|
|
5908
5905
|
/**
|
|
@@ -5914,10 +5911,10 @@ class Cr {
|
|
|
5914
5911
|
* @packageDocumentation
|
|
5915
5912
|
*/ !function(t) {
|
|
5916
5913
|
l = t;
|
|
5917
|
-
}(`${s}_lite`),
|
|
5918
|
-
const
|
|
5919
|
-
return
|
|
5920
|
-
}), "PUBLIC" /* PUBLIC */)), r("firestore-lite", "3.1.0
|
|
5914
|
+
}(`${s}_lite`), n(new i("firestore/lite", ((t, {options: e}) => {
|
|
5915
|
+
const n = t.getProvider("app").getImmediate(), r = new en(n, new B(t.getProvider("auth-internal")));
|
|
5916
|
+
return e && r._setSettings(e), r;
|
|
5917
|
+
}), "PUBLIC" /* PUBLIC */)), r("firestore-lite", "3.1.0", "node");
|
|
5921
5918
|
|
|
5922
|
-
export {
|
|
5919
|
+
export { yn as Bytes, an as CollectionReference, un as DocumentReference, Wn as DocumentSnapshot, mn as FieldPath, _n as FieldValue, en as Firestore, L as FirestoreError, gn as GeoPoint, cn as Query, Jn as QueryConstraint, Gn as QueryDocumentSnapshot, Hn as QuerySnapshot, pt as Timestamp, Cr as Transaction, Nr as WriteBatch, Ir as addDoc, Rr as arrayRemove, Pr as arrayUnion, hn as collection, ln as collectionGroup, sn as connectFirestoreEmulator, Er as deleteDoc, Tr as deleteField, fn as doc, pn as documentId, lr as endAt, hr as endBefore, _r as getDoc, gr as getDocs, rn as getFirestore, Vr as increment, nn as initializeFirestore, sr as limit, ir as limitToLast, nr as orderBy, Zn as query, wn as queryEqual, dn as refEqual, Lr as runTransaction, Ar as serverTimestamp, br as setDoc, d as setLogLevel, Yn as snapshotEqual, cr as startAfter, ur as startAt, on as terminate, vr as updateDoc, tr as where, $r as writeBatch };
|
|
5923
5920
|
//# sourceMappingURL=index.browser.esm2017.js.map
|