@firebase/firestore 3.4.8-canary.aa41fd662 → 3.4.8-canary.d8be8bf1c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/firestore/src/core/target.d.ts +4 -4
- package/dist/firestore/src/local/indexeddb_index_manager.d.ts +0 -5
- package/dist/firestore/src/model/values.d.ts +14 -2
- package/dist/index.esm2017.js +1278 -1261
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +2298 -2282
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +46 -55
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +46 -55
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +1315 -1298
- package/dist/index.rn.js.map +1 -1
- package/dist/lite/firestore/src/core/target.d.ts +4 -4
- package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +0 -5
- package/dist/lite/firestore/src/model/values.d.ts +14 -2
- package/dist/lite/index.browser.esm2017.js +509 -499
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +547 -537
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.node.cjs.js +21 -5
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +21 -5
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +1216 -1206
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +97 -97
- package/dist/lite/packages/firestore/src/core/target.d.ts +4 -4
- package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +0 -5
- package/dist/lite/packages/firestore/src/model/values.d.ts +14 -2
- package/dist/packages/firestore/dist/index.esm2017.d.ts +50 -50
- package/dist/packages/firestore/src/core/target.d.ts +4 -4
- package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +0 -5
- package/dist/packages/firestore/src/model/values.d.ts +14 -2
- 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 @@ f.MOCK_USER = new f("mock-user");
|
|
|
66
66
|
* See the License for the specific language governing permissions and
|
|
67
67
|
* limitations under the License.
|
|
68
68
|
*/
|
|
69
|
-
let d = "9.6.11-canary.
|
|
69
|
+
let d = "9.6.11-canary.d8be8bf1c";
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* @license
|
|
@@ -102,26 +102,26 @@ const w = new o("@firebase/firestore");
|
|
|
102
102
|
w.setLogLevel(t);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
function p(t, ...
|
|
105
|
+
function p(t, ...e) {
|
|
106
106
|
if (w.logLevel <= u.DEBUG) {
|
|
107
|
-
const
|
|
108
|
-
w.debug(`Firestore (${d}): ${t}`, ...
|
|
107
|
+
const n = e.map(g);
|
|
108
|
+
w.debug(`Firestore (${d}): ${t}`, ...n);
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
function y(t, ...
|
|
112
|
+
function y(t, ...e) {
|
|
113
113
|
if (w.logLevel <= u.ERROR) {
|
|
114
|
-
const
|
|
115
|
-
w.error(`Firestore (${d}): ${t}`, ...
|
|
114
|
+
const n = e.map(g);
|
|
115
|
+
w.error(`Firestore (${d}): ${t}`, ...n);
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
120
|
* @internal
|
|
121
|
-
*/ function _(t, ...
|
|
121
|
+
*/ function _(t, ...e) {
|
|
122
122
|
if (w.logLevel <= u.WARN) {
|
|
123
|
-
const
|
|
124
|
-
w.warn(`Firestore (${d}): ${t}`, ...
|
|
123
|
+
const n = e.map(g);
|
|
124
|
+
w.warn(`Firestore (${d}): ${t}`, ...n);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|
|
@@ -130,8 +130,8 @@ function y(t, ...n) {
|
|
|
130
130
|
*/ function g(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 y(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
|
/**
|
|
@@ -178,14 +178,14 @@ function y(t, ...n) {
|
|
|
178
178
|
* Returns `never` and can be used in expressions:
|
|
179
179
|
* @example
|
|
180
180
|
* let futureVar = fail('not implemented yet');
|
|
181
|
-
*/ function
|
|
181
|
+
*/ function b(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 (${d}) INTERNAL ASSERTION FAILED: ` + t;
|
|
185
185
|
// NOTE: We don't use FirestoreError here because these are internal failures
|
|
186
186
|
// that cannot be handled by the user. (Also it would create a circular
|
|
187
187
|
// dependency between the error and assert modules which doesn't work.)
|
|
188
|
-
throw y(
|
|
188
|
+
throw y(e), new Error(e);
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
/**
|
|
@@ -193,8 +193,8 @@ function y(t, ...n) {
|
|
|
193
193
|
* given message if it did.
|
|
194
194
|
*
|
|
195
195
|
* Messages are stripped in production builds.
|
|
196
|
-
*/ function
|
|
197
|
-
t ||
|
|
196
|
+
*/ function v(t, e) {
|
|
197
|
+
t || b();
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
/**
|
|
@@ -202,7 +202,7 @@ function y(t, ...n) {
|
|
|
202
202
|
* instance of `T` before casting.
|
|
203
203
|
*/ function E(t,
|
|
204
204
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
205
|
-
|
|
205
|
+
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(t,
|
|
236
|
+
e) {
|
|
237
|
+
super(t, e), this.code = t, this.message = e,
|
|
238
238
|
// HACK: We write a toString property directly because Error is not a real
|
|
239
239
|
// class and so inheritance does not work correctly. We could alternatively
|
|
240
240
|
// do the same "back-door inheritance" trick that FirebaseError does.
|
|
@@ -259,8 +259,8 @@ n) {
|
|
|
259
259
|
* limitations under the License.
|
|
260
260
|
*/ class j {
|
|
261
261
|
constructor() {
|
|
262
|
-
this.promise = new Promise(((t,
|
|
263
|
-
this.resolve = t, this.reject =
|
|
262
|
+
this.promise = new Promise(((t, e) => {
|
|
263
|
+
this.resolve = t, this.reject = e;
|
|
264
264
|
}));
|
|
265
265
|
}
|
|
266
266
|
}
|
|
@@ -281,8 +281,8 @@ n) {
|
|
|
281
281
|
* See the License for the specific language governing permissions and
|
|
282
282
|
* limitations under the License.
|
|
283
283
|
*/ class M {
|
|
284
|
-
constructor(t,
|
|
285
|
-
this.user =
|
|
284
|
+
constructor(t, e) {
|
|
285
|
+
this.user = e, this.type = "OAuth", this.headers = new Map, this.headers.set("Authorization", `Bearer ${t}`);
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
|
|
@@ -294,9 +294,9 @@ n) {
|
|
|
294
294
|
return Promise.resolve(null);
|
|
295
295
|
}
|
|
296
296
|
invalidateToken() {}
|
|
297
|
-
start(t,
|
|
297
|
+
start(t, e) {
|
|
298
298
|
// Fire with initial user.
|
|
299
|
-
t.enqueueRetryable((() =>
|
|
299
|
+
t.enqueueRetryable((() => e(f.UNAUTHENTICATED)));
|
|
300
300
|
}
|
|
301
301
|
shutdown() {}
|
|
302
302
|
}
|
|
@@ -318,10 +318,10 @@ n) {
|
|
|
318
318
|
return Promise.resolve(this.token);
|
|
319
319
|
}
|
|
320
320
|
invalidateToken() {}
|
|
321
|
-
start(t,
|
|
322
|
-
this.changeListener =
|
|
321
|
+
start(t, e) {
|
|
322
|
+
this.changeListener = e,
|
|
323
323
|
// Fire with initial user.
|
|
324
|
-
t.enqueueRetryable((() =>
|
|
324
|
+
t.enqueueRetryable((() => e(this.token.user)));
|
|
325
325
|
}
|
|
326
326
|
shutdown() {
|
|
327
327
|
this.changeListener = null;
|
|
@@ -335,11 +335,11 @@ n) {
|
|
|
335
335
|
}));
|
|
336
336
|
}
|
|
337
337
|
getToken() {
|
|
338
|
-
return this.auth ? this.auth.getToken().then((t => t ? (
|
|
338
|
+
return this.auth ? this.auth.getToken().then((t => t ? (v("string" == typeof t.accessToken),
|
|
339
339
|
new M(t.accessToken, new f(this.auth.getUid()))) : null)) : Promise.resolve(null);
|
|
340
340
|
}
|
|
341
341
|
invalidateToken() {}
|
|
342
|
-
start(t,
|
|
342
|
+
start(t, e) {}
|
|
343
343
|
shutdown() {}
|
|
344
344
|
}
|
|
345
345
|
|
|
@@ -350,10 +350,10 @@ n) {
|
|
|
350
350
|
* recover from unauthenticated errors (see b/33147818 for context), but it's
|
|
351
351
|
* safer to keep the implementation as-is.
|
|
352
352
|
*/ class Q {
|
|
353
|
-
constructor(t,
|
|
354
|
-
this.type = "FirstParty", this.user = f.FIRST_PARTY, this.headers = new Map, this.headers.set("X-Goog-AuthUser",
|
|
353
|
+
constructor(t, e, n) {
|
|
354
|
+
this.type = "FirstParty", this.user = f.FIRST_PARTY, this.headers = new Map, this.headers.set("X-Goog-AuthUser", e);
|
|
355
355
|
const r = t.auth.getAuthHeaderValueForFirstParty([]);
|
|
356
|
-
r && this.headers.set("Authorization", r),
|
|
356
|
+
r && this.headers.set("Authorization", r), n && this.headers.set("X-Goog-Iam-Authorization-Token", n);
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
359
|
|
|
@@ -362,15 +362,15 @@ n) {
|
|
|
362
362
|
* to authenticate the user, using technique that is only available
|
|
363
363
|
* to applications hosted by Google.
|
|
364
364
|
*/ class W {
|
|
365
|
-
constructor(t,
|
|
366
|
-
this.t = t, this.i =
|
|
365
|
+
constructor(t, e, n) {
|
|
366
|
+
this.t = t, this.i = e, this.o = n;
|
|
367
367
|
}
|
|
368
368
|
getToken() {
|
|
369
369
|
return Promise.resolve(new Q(this.t, this.i, this.o));
|
|
370
370
|
}
|
|
371
|
-
start(t,
|
|
371
|
+
start(t, e) {
|
|
372
372
|
// Fire with initial uid.
|
|
373
|
-
t.enqueueRetryable((() =>
|
|
373
|
+
t.enqueueRetryable((() => e(f.FIRST_PARTY)));
|
|
374
374
|
}
|
|
375
375
|
shutdown() {}
|
|
376
376
|
invalidateToken() {}
|
|
@@ -389,11 +389,11 @@ class Y {
|
|
|
389
389
|
}));
|
|
390
390
|
}
|
|
391
391
|
getToken() {
|
|
392
|
-
return this.appCheck ? this.appCheck.getToken().then((t => t ? (
|
|
392
|
+
return this.appCheck ? this.appCheck.getToken().then((t => t ? (v("string" == typeof t.token),
|
|
393
393
|
new Y(t.token)) : null)) : Promise.resolve(null);
|
|
394
394
|
}
|
|
395
395
|
invalidateToken() {}
|
|
396
|
-
start(t,
|
|
396
|
+
start(t, e) {}
|
|
397
397
|
shutdown() {}
|
|
398
398
|
}
|
|
399
399
|
|
|
@@ -435,8 +435,8 @@ class K {
|
|
|
435
435
|
* @param useFetchStreams Whether to use the Fetch API instead of
|
|
436
436
|
* XMLHTTPRequest
|
|
437
437
|
*/
|
|
438
|
-
constructor(t,
|
|
439
|
-
this.databaseId = t, this.appId =
|
|
438
|
+
constructor(t, e, n, r, s, i, o, u) {
|
|
439
|
+
this.databaseId = t, this.appId = e, this.persistenceKey = n, this.host = r, this.ssl = s,
|
|
440
440
|
this.forceLongPolling = i, this.autoDetectLongPolling = o, this.useFetchStreams = u;
|
|
441
441
|
}
|
|
442
442
|
}
|
|
@@ -447,8 +447,8 @@ class K {
|
|
|
447
447
|
* @internal
|
|
448
448
|
*/
|
|
449
449
|
class J {
|
|
450
|
-
constructor(t,
|
|
451
|
-
this.projectId = t, this.database =
|
|
450
|
+
constructor(t, e) {
|
|
451
|
+
this.projectId = t, this.database = e || "(default)";
|
|
452
452
|
}
|
|
453
453
|
static empty() {
|
|
454
454
|
return new J("", "");
|
|
@@ -481,9 +481,9 @@ class J {
|
|
|
481
481
|
* Path represents an ordered sequence of string segments.
|
|
482
482
|
*/
|
|
483
483
|
class X {
|
|
484
|
-
constructor(t,
|
|
485
|
-
void 0 ===
|
|
486
|
-
this.segments = t, this.offset =
|
|
484
|
+
constructor(t, e, n) {
|
|
485
|
+
void 0 === e ? e = 0 : e > t.length && b(), void 0 === n ? n = t.length - e : n > t.length - e && b(),
|
|
486
|
+
this.segments = t, this.offset = e, this.len = n;
|
|
487
487
|
}
|
|
488
488
|
get length() {
|
|
489
489
|
return this.len;
|
|
@@ -492,10 +492,10 @@ class X {
|
|
|
492
492
|
return 0 === X.comparator(this, t);
|
|
493
493
|
}
|
|
494
494
|
child(t) {
|
|
495
|
-
const
|
|
495
|
+
const e = this.segments.slice(this.offset, this.limit());
|
|
496
496
|
return t instanceof X ? t.forEach((t => {
|
|
497
|
-
|
|
498
|
-
})) :
|
|
497
|
+
e.push(t);
|
|
498
|
+
})) : e.push(t), this.construct(e);
|
|
499
499
|
}
|
|
500
500
|
/** The index of one past the last segment of the path. */ limit() {
|
|
501
501
|
return this.offset + this.length;
|
|
@@ -520,28 +520,28 @@ class X {
|
|
|
520
520
|
}
|
|
521
521
|
isPrefixOf(t) {
|
|
522
522
|
if (t.length < this.length) return !1;
|
|
523
|
-
for (let
|
|
523
|
+
for (let e = 0; e < this.length; e++) if (this.get(e) !== t.get(e)) return !1;
|
|
524
524
|
return !0;
|
|
525
525
|
}
|
|
526
526
|
isImmediateParentOf(t) {
|
|
527
527
|
if (this.length + 1 !== t.length) return !1;
|
|
528
|
-
for (let
|
|
528
|
+
for (let e = 0; e < this.length; e++) if (this.get(e) !== t.get(e)) return !1;
|
|
529
529
|
return !0;
|
|
530
530
|
}
|
|
531
531
|
forEach(t) {
|
|
532
|
-
for (let
|
|
532
|
+
for (let e = this.offset, n = this.limit(); e < n; e++) t(this.segments[e]);
|
|
533
533
|
}
|
|
534
534
|
toArray() {
|
|
535
535
|
return this.segments.slice(this.offset, this.limit());
|
|
536
536
|
}
|
|
537
|
-
static comparator(t,
|
|
538
|
-
const
|
|
539
|
-
for (let r = 0; r <
|
|
540
|
-
const
|
|
541
|
-
if (
|
|
542
|
-
if (
|
|
537
|
+
static comparator(t, e) {
|
|
538
|
+
const n = Math.min(t.length, e.length);
|
|
539
|
+
for (let r = 0; r < n; r++) {
|
|
540
|
+
const n = t.get(r), s = e.get(r);
|
|
541
|
+
if (n < s) return -1;
|
|
542
|
+
if (n > s) return 1;
|
|
543
543
|
}
|
|
544
|
-
return t.length <
|
|
544
|
+
return t.length < e.length ? -1 : t.length > e.length ? 1 : 0;
|
|
545
545
|
}
|
|
546
546
|
}
|
|
547
547
|
|
|
@@ -551,8 +551,8 @@ class X {
|
|
|
551
551
|
*
|
|
552
552
|
* @internal
|
|
553
553
|
*/ class Z extends X {
|
|
554
|
-
construct(t,
|
|
555
|
-
return new Z(t,
|
|
554
|
+
construct(t, e, n) {
|
|
555
|
+
return new Z(t, e, n);
|
|
556
556
|
}
|
|
557
557
|
canonicalString() {
|
|
558
558
|
// NOTE: The client is ignorant of any path segments containing escape
|
|
@@ -571,13 +571,13 @@ class X {
|
|
|
571
571
|
// NOTE: The client is ignorant of any path segments containing escape
|
|
572
572
|
// sequences (e.g. __id123__) and just passes them through raw (they exist
|
|
573
573
|
// for legacy reasons and should not be used frequently).
|
|
574
|
-
const
|
|
575
|
-
for (const
|
|
576
|
-
if (
|
|
574
|
+
const e = [];
|
|
575
|
+
for (const n of t) {
|
|
576
|
+
if (n.indexOf("//") >= 0) throw new U(R, `Invalid segment (${n}). Paths must not contain // in them.`);
|
|
577
577
|
// Strip leading and traling slashed.
|
|
578
|
-
|
|
578
|
+
e.push(...n.split("/").filter((t => t.length > 0)));
|
|
579
579
|
}
|
|
580
|
-
return new Z(
|
|
580
|
+
return new Z(e);
|
|
581
581
|
}
|
|
582
582
|
static emptyPath() {
|
|
583
583
|
return new Z([]);
|
|
@@ -589,9 +589,9 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
589
589
|
/**
|
|
590
590
|
* A dot-separated path for navigating sub-objects within a document.
|
|
591
591
|
* @internal
|
|
592
|
-
*/ class
|
|
593
|
-
construct(t,
|
|
594
|
-
return new
|
|
592
|
+
*/ class et extends X {
|
|
593
|
+
construct(t, e, n) {
|
|
594
|
+
return new et(t, e, n);
|
|
595
595
|
}
|
|
596
596
|
/**
|
|
597
597
|
* Returns true if the string could be used as a segment in a field path
|
|
@@ -601,7 +601,7 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
601
601
|
}
|
|
602
602
|
canonicalString() {
|
|
603
603
|
return this.toArray().map((t => (t = t.replace(/\\/g, "\\\\").replace(/`/g, "\\`"),
|
|
604
|
-
|
|
604
|
+
et.isValidIdentifier(t) || (t = "`" + t + "`"), t))).join(".");
|
|
605
605
|
}
|
|
606
606
|
toString() {
|
|
607
607
|
return this.canonicalString();
|
|
@@ -614,7 +614,7 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
614
614
|
/**
|
|
615
615
|
* The field designating the key of a document.
|
|
616
616
|
*/ static keyField() {
|
|
617
|
-
return new
|
|
617
|
+
return new et([ "__name__" ]);
|
|
618
618
|
}
|
|
619
619
|
/**
|
|
620
620
|
* Parses a field string from the given server-formatted string.
|
|
@@ -626,27 +626,27 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
626
626
|
* TODO(b/37244157): we should make this more strict. Right now, it allows
|
|
627
627
|
* non-identifier path components, even if they aren't escaped.
|
|
628
628
|
*/ static fromServerFormat(t) {
|
|
629
|
-
const
|
|
630
|
-
let
|
|
629
|
+
const e = [];
|
|
630
|
+
let n = "", r = 0;
|
|
631
631
|
const s = () => {
|
|
632
|
-
if (0 ===
|
|
633
|
-
|
|
632
|
+
if (0 === n.length) throw new U(R, `Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);
|
|
633
|
+
e.push(n), n = "";
|
|
634
634
|
};
|
|
635
635
|
let i = !1;
|
|
636
636
|
for (;r < t.length; ) {
|
|
637
|
-
const
|
|
638
|
-
if ("\\" ===
|
|
637
|
+
const e = t[r];
|
|
638
|
+
if ("\\" === e) {
|
|
639
639
|
if (r + 1 === t.length) throw new U(R, "Path has trailing escape character: " + t);
|
|
640
|
-
const
|
|
641
|
-
if ("\\" !==
|
|
642
|
-
|
|
643
|
-
} else "`" ===
|
|
640
|
+
const e = t[r + 1];
|
|
641
|
+
if ("\\" !== e && "." !== e && "`" !== e) throw new U(R, "Path has invalid escape sequence: " + t);
|
|
642
|
+
n += e, r += 2;
|
|
643
|
+
} else "`" === e ? (i = !i, r++) : "." !== e || i ? (n += e, r++) : (s(), r++);
|
|
644
644
|
}
|
|
645
645
|
if (s(), i) throw new U(R, "Unterminated ` in path: " + t);
|
|
646
|
-
return new
|
|
646
|
+
return new et(e);
|
|
647
647
|
}
|
|
648
648
|
static emptyPath() {
|
|
649
|
-
return new
|
|
649
|
+
return new et([]);
|
|
650
650
|
}
|
|
651
651
|
}
|
|
652
652
|
|
|
@@ -668,18 +668,18 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
668
668
|
*/
|
|
669
669
|
/**
|
|
670
670
|
* @internal
|
|
671
|
-
*/ class
|
|
671
|
+
*/ class nt {
|
|
672
672
|
constructor(t) {
|
|
673
673
|
this.path = t;
|
|
674
674
|
}
|
|
675
675
|
static fromPath(t) {
|
|
676
|
-
return new
|
|
676
|
+
return new nt(Z.fromString(t));
|
|
677
677
|
}
|
|
678
678
|
static fromName(t) {
|
|
679
|
-
return new
|
|
679
|
+
return new nt(Z.fromString(t).popFirst(5));
|
|
680
680
|
}
|
|
681
681
|
static empty() {
|
|
682
|
-
return new
|
|
682
|
+
return new nt(Z.emptyPath());
|
|
683
683
|
}
|
|
684
684
|
get collectionGroup() {
|
|
685
685
|
return this.path.popLast().lastSegment();
|
|
@@ -699,8 +699,8 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
699
699
|
toString() {
|
|
700
700
|
return this.path.toString();
|
|
701
701
|
}
|
|
702
|
-
static comparator(t,
|
|
703
|
-
return Z.comparator(t.path,
|
|
702
|
+
static comparator(t, e) {
|
|
703
|
+
return Z.comparator(t.path, e.path);
|
|
704
704
|
}
|
|
705
705
|
static isDocumentKey(t) {
|
|
706
706
|
return t.length % 2 == 0;
|
|
@@ -711,7 +711,7 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
711
711
|
* @param segments - The segments of the path to the document
|
|
712
712
|
* @returns A new instance of DocumentKey
|
|
713
713
|
*/ static fromSegments(t) {
|
|
714
|
-
return new
|
|
714
|
+
return new nt(new Z(t.slice()));
|
|
715
715
|
}
|
|
716
716
|
}
|
|
717
717
|
|
|
@@ -730,8 +730,8 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
730
730
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
731
731
|
* See the License for the specific language governing permissions and
|
|
732
732
|
* limitations under the License.
|
|
733
|
-
*/ function rt(t,
|
|
734
|
-
if (!
|
|
733
|
+
*/ function rt(t, e, n) {
|
|
734
|
+
if (!n) throw new U(R, `Function ${t}() cannot be called with an empty ${e}.`);
|
|
735
735
|
}
|
|
736
736
|
|
|
737
737
|
/**
|
|
@@ -743,14 +743,14 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
743
743
|
* an even numbers of segments).
|
|
744
744
|
*/
|
|
745
745
|
function st(t) {
|
|
746
|
-
if (!
|
|
746
|
+
if (!nt.isDocumentKey(t)) throw new U(R, `Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`);
|
|
747
747
|
}
|
|
748
748
|
|
|
749
749
|
/**
|
|
750
750
|
* Validates that `path` refers to a collection (indicated by the fact it
|
|
751
751
|
* contains an odd numbers of segments).
|
|
752
752
|
*/ function it(t) {
|
|
753
|
-
if (
|
|
753
|
+
if (nt.isDocumentKey(t)) throw new U(R, `Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`);
|
|
754
754
|
}
|
|
755
755
|
|
|
756
756
|
/**
|
|
@@ -767,7 +767,7 @@ function ot(t) {
|
|
|
767
767
|
if ("object" == typeof t) {
|
|
768
768
|
if (t instanceof Array) return "an array";
|
|
769
769
|
{
|
|
770
|
-
const
|
|
770
|
+
const e =
|
|
771
771
|
/** try to get the constructor name for an object. */
|
|
772
772
|
function(t) {
|
|
773
773
|
if (t.constructor) return t.constructor.name;
|
|
@@ -781,30 +781,30 @@ function ot(t) {
|
|
|
781
781
|
* arguments passed to the public API.
|
|
782
782
|
* @internal
|
|
783
783
|
*/ (t);
|
|
784
|
-
return
|
|
784
|
+
return e ? `a custom ${e} object` : "an object";
|
|
785
785
|
}
|
|
786
786
|
}
|
|
787
|
-
return "function" == typeof t ? "a function" :
|
|
787
|
+
return "function" == typeof t ? "a function" : b();
|
|
788
788
|
}
|
|
789
789
|
|
|
790
790
|
function ut(t,
|
|
791
791
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
792
|
-
|
|
792
|
+
e) {
|
|
793
793
|
if ("_delegate" in t && (
|
|
794
794
|
// Unwrap Compat types
|
|
795
795
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
796
|
-
t = t._delegate), !(t instanceof
|
|
797
|
-
if (
|
|
796
|
+
t = t._delegate), !(t instanceof e)) {
|
|
797
|
+
if (e.name === t.constructor.name) throw new U(R, "Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");
|
|
798
798
|
{
|
|
799
|
-
const
|
|
800
|
-
throw new U(R, `Expected type '${
|
|
799
|
+
const n = ot(t);
|
|
800
|
+
throw new U(R, `Expected type '${e.name}', but it was: ${n}`);
|
|
801
801
|
}
|
|
802
802
|
}
|
|
803
803
|
return t;
|
|
804
804
|
}
|
|
805
805
|
|
|
806
|
-
function ct(t,
|
|
807
|
-
if (
|
|
806
|
+
function ct(t, e) {
|
|
807
|
+
if (e <= 0) throw new U(R, `Function ${t}() requires a positive number, but it was: ${e}.`);
|
|
808
808
|
}
|
|
809
809
|
|
|
810
810
|
/**
|
|
@@ -1011,58 +1011,58 @@ class mt extends
|
|
|
1011
1011
|
class {
|
|
1012
1012
|
constructor(t) {
|
|
1013
1013
|
this.databaseInfo = t, this.databaseId = t.databaseId;
|
|
1014
|
-
const
|
|
1015
|
-
this.h =
|
|
1014
|
+
const e = t.ssl ? "https" : "http";
|
|
1015
|
+
this.h = e + "://" + t.host, this.l = "projects/" + this.databaseId.projectId + "/databases/" + this.databaseId.database + "/documents";
|
|
1016
1016
|
}
|
|
1017
|
-
m(t,
|
|
1018
|
-
const i = this.p(t,
|
|
1019
|
-
p("RestConnection", "Sending: ", i,
|
|
1017
|
+
m(t, e, n, r, s) {
|
|
1018
|
+
const i = this.p(t, e);
|
|
1019
|
+
p("RestConnection", "Sending: ", i, n);
|
|
1020
1020
|
const o = {};
|
|
1021
|
-
return this.g(o, r, s), this.v(t, i, o,
|
|
1022
|
-
t)), (
|
|
1023
|
-
throw _("RestConnection", `${t} failed with error: `,
|
|
1024
|
-
|
|
1021
|
+
return this.g(o, r, s), this.v(t, i, o, n).then((t => (p("RestConnection", "Received: ", t),
|
|
1022
|
+
t)), (e => {
|
|
1023
|
+
throw _("RestConnection", `${t} failed with error: `, e, "url: ", i, "request:", n),
|
|
1024
|
+
e;
|
|
1025
1025
|
}));
|
|
1026
1026
|
}
|
|
1027
|
-
T(t,
|
|
1027
|
+
T(t, e, n, r, s) {
|
|
1028
1028
|
// The REST API automatically aggregates all of the streamed results, so we
|
|
1029
1029
|
// can just use the normal invoke() method.
|
|
1030
|
-
return this.m(t,
|
|
1030
|
+
return this.m(t, e, n, r, s);
|
|
1031
1031
|
}
|
|
1032
1032
|
/**
|
|
1033
1033
|
* Modifies the headers for a request, adding any authorization token if
|
|
1034
1034
|
* present and any additional headers for the request.
|
|
1035
|
-
*/ g(t,
|
|
1035
|
+
*/ g(t, e, n) {
|
|
1036
1036
|
t["X-Goog-Api-Client"] = "gl-js/ fire/" + d,
|
|
1037
1037
|
// Content-Type: text/plain will avoid preflight requests which might
|
|
1038
1038
|
// mess with CORS and redirects by proxies. If we add custom headers
|
|
1039
1039
|
// we will need to change this code to potentially use the $httpOverwrite
|
|
1040
1040
|
// parameter supported by ESF to avoid triggering preflight requests.
|
|
1041
1041
|
t["Content-Type"] = "text/plain", this.databaseInfo.appId && (t["X-Firebase-GMPID"] = this.databaseInfo.appId),
|
|
1042
|
-
|
|
1042
|
+
e && e.headers.forEach(((e, n) => t[n] = e)), n && n.headers.forEach(((e, n) => t[n] = e));
|
|
1043
1043
|
}
|
|
1044
|
-
p(t,
|
|
1045
|
-
const
|
|
1046
|
-
return `${this.h}/v1/${
|
|
1044
|
+
p(t, e) {
|
|
1045
|
+
const n = lt[t];
|
|
1046
|
+
return `${this.h}/v1/${e}:${n}`;
|
|
1047
1047
|
}
|
|
1048
1048
|
} {
|
|
1049
1049
|
/**
|
|
1050
1050
|
* @param databaseInfo - The connection info.
|
|
1051
1051
|
* @param fetchImpl - `fetch` or a Polyfill that implements the fetch API.
|
|
1052
1052
|
*/
|
|
1053
|
-
constructor(t,
|
|
1054
|
-
super(t), this.I =
|
|
1053
|
+
constructor(t, e) {
|
|
1054
|
+
super(t), this.I = e;
|
|
1055
1055
|
}
|
|
1056
|
-
A(t,
|
|
1056
|
+
A(t, e) {
|
|
1057
1057
|
throw new Error("Not supported by FetchConnection");
|
|
1058
1058
|
}
|
|
1059
|
-
async v(t,
|
|
1059
|
+
async v(t, e, n, r) {
|
|
1060
1060
|
const s = JSON.stringify(r);
|
|
1061
1061
|
let i;
|
|
1062
1062
|
try {
|
|
1063
|
-
i = await this.I(
|
|
1063
|
+
i = await this.I(e, {
|
|
1064
1064
|
method: "POST",
|
|
1065
|
-
headers:
|
|
1065
|
+
headers: n,
|
|
1066
1066
|
body: s
|
|
1067
1067
|
});
|
|
1068
1068
|
} catch (t) {
|
|
@@ -1113,13 +1113,13 @@ class {
|
|
|
1113
1113
|
*/
|
|
1114
1114
|
function pt(t) {
|
|
1115
1115
|
// Polyfills for IE and WebWorker by using `self` and `msCrypto` when `crypto` is not available.
|
|
1116
|
-
const
|
|
1116
|
+
const e =
|
|
1117
1117
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1118
|
-
"undefined" != typeof self && (self.crypto || self.msCrypto),
|
|
1119
|
-
if (
|
|
1118
|
+
"undefined" != typeof self && (self.crypto || self.msCrypto), n = new Uint8Array(t);
|
|
1119
|
+
if (e && "function" == typeof e.getRandomValues) e.getRandomValues(n); else
|
|
1120
1120
|
// Falls back to Math.random
|
|
1121
|
-
for (let
|
|
1122
|
-
return
|
|
1121
|
+
for (let e = 0; e < t; e++) n[e] = Math.floor(256 * Math.random());
|
|
1122
|
+
return n;
|
|
1123
1123
|
}
|
|
1124
1124
|
|
|
1125
1125
|
/**
|
|
@@ -1140,26 +1140,26 @@ function pt(t) {
|
|
|
1140
1140
|
*/ class yt {
|
|
1141
1141
|
static R() {
|
|
1142
1142
|
// Alphanumeric characters
|
|
1143
|
-
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
|
|
1143
|
+
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", e = Math.floor(256 / t.length) * t.length;
|
|
1144
1144
|
// The largest byte value that is a multiple of `char.length`.
|
|
1145
|
-
let
|
|
1146
|
-
for (;
|
|
1145
|
+
let n = "";
|
|
1146
|
+
for (;n.length < 20; ) {
|
|
1147
1147
|
const r = pt(40);
|
|
1148
1148
|
for (let s = 0; s < r.length; ++s)
|
|
1149
1149
|
// Only accept values that are [0, maxMultiple), this ensures they can
|
|
1150
1150
|
// be evenly mapped to indices of `chars` via a modulo operation.
|
|
1151
|
-
|
|
1151
|
+
n.length < 20 && r[s] < e && (n += t.charAt(r[s] % t.length));
|
|
1152
1152
|
}
|
|
1153
|
-
return
|
|
1153
|
+
return n;
|
|
1154
1154
|
}
|
|
1155
1155
|
}
|
|
1156
1156
|
|
|
1157
|
-
function _t(t,
|
|
1158
|
-
return t <
|
|
1157
|
+
function _t(t, e) {
|
|
1158
|
+
return t < e ? -1 : t > e ? 1 : 0;
|
|
1159
1159
|
}
|
|
1160
1160
|
|
|
1161
|
-
/** Helper to compare arrays using isEqual(). */ function gt(t,
|
|
1162
|
-
return t.length ===
|
|
1161
|
+
/** Helper to compare arrays using isEqual(). */ function gt(t, e, n) {
|
|
1162
|
+
return t.length === e.length && t.every(((t, r) => n(t, e[r])));
|
|
1163
1163
|
}
|
|
1164
1164
|
|
|
1165
1165
|
/**
|
|
@@ -1193,7 +1193,7 @@ function _t(t, n) {
|
|
|
1193
1193
|
* For examples and further specifications, refer to the
|
|
1194
1194
|
* {@link https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto | Timestamp definition}.
|
|
1195
1195
|
*/
|
|
1196
|
-
class
|
|
1196
|
+
class bt {
|
|
1197
1197
|
/**
|
|
1198
1198
|
* Creates a new timestamp.
|
|
1199
1199
|
*
|
|
@@ -1213,9 +1213,9 @@ class vt {
|
|
|
1213
1213
|
/**
|
|
1214
1214
|
* The fractions of a second at nanosecond resolution.*
|
|
1215
1215
|
*/
|
|
1216
|
-
|
|
1217
|
-
if (this.seconds = t, this.nanoseconds =
|
|
1218
|
-
if (
|
|
1216
|
+
e) {
|
|
1217
|
+
if (this.seconds = t, this.nanoseconds = e, e < 0) throw new U(R, "Timestamp nanoseconds out of range: " + e);
|
|
1218
|
+
if (e >= 1e9) throw new U(R, "Timestamp nanoseconds out of range: " + e);
|
|
1219
1219
|
if (t < -62135596800) throw new U(R, "Timestamp seconds out of range: " + t);
|
|
1220
1220
|
// This will break in the year 10,000.
|
|
1221
1221
|
if (t >= 253402300800) throw new U(R, "Timestamp seconds out of range: " + t);
|
|
@@ -1225,7 +1225,7 @@ class vt {
|
|
|
1225
1225
|
*
|
|
1226
1226
|
* @returns a new timestamp representing the current date.
|
|
1227
1227
|
*/ static now() {
|
|
1228
|
-
return
|
|
1228
|
+
return bt.fromMillis(Date.now());
|
|
1229
1229
|
}
|
|
1230
1230
|
/**
|
|
1231
1231
|
* Creates a new timestamp from the given date.
|
|
@@ -1234,7 +1234,7 @@ class vt {
|
|
|
1234
1234
|
* @returns A new `Timestamp` representing the same point in time as the given
|
|
1235
1235
|
* date.
|
|
1236
1236
|
*/ static fromDate(t) {
|
|
1237
|
-
return
|
|
1237
|
+
return bt.fromMillis(t.getTime());
|
|
1238
1238
|
}
|
|
1239
1239
|
/**
|
|
1240
1240
|
* Creates a new timestamp from the given number of milliseconds.
|
|
@@ -1244,8 +1244,8 @@ class vt {
|
|
|
1244
1244
|
* @returns A new `Timestamp` representing the same point in time as the given
|
|
1245
1245
|
* number of milliseconds.
|
|
1246
1246
|
*/ static fromMillis(t) {
|
|
1247
|
-
const
|
|
1248
|
-
return new
|
|
1247
|
+
const e = Math.floor(t / 1e3), n = Math.floor(1e6 * (t - 1e3 * e));
|
|
1248
|
+
return new bt(e, n);
|
|
1249
1249
|
}
|
|
1250
1250
|
/**
|
|
1251
1251
|
* Converts a `Timestamp` to a JavaScript `Date` object. This conversion
|
|
@@ -1323,18 +1323,18 @@ class vt {
|
|
|
1323
1323
|
/**
|
|
1324
1324
|
* A version of a document in Firestore. This corresponds to the version
|
|
1325
1325
|
* timestamp, such as update_time or read_time.
|
|
1326
|
-
*/ class
|
|
1326
|
+
*/ class vt {
|
|
1327
1327
|
constructor(t) {
|
|
1328
1328
|
this.timestamp = t;
|
|
1329
1329
|
}
|
|
1330
1330
|
static fromTimestamp(t) {
|
|
1331
|
-
return new
|
|
1331
|
+
return new vt(t);
|
|
1332
1332
|
}
|
|
1333
1333
|
static min() {
|
|
1334
|
-
return new
|
|
1334
|
+
return new vt(new bt(0, 0));
|
|
1335
1335
|
}
|
|
1336
1336
|
static max() {
|
|
1337
|
-
return new
|
|
1337
|
+
return new vt(new bt(253402300799, 999999999));
|
|
1338
1338
|
}
|
|
1339
1339
|
compareTo(t) {
|
|
1340
1340
|
return this.timestamp._compareTo(t.timestamp);
|
|
@@ -1370,13 +1370,13 @@ class vt {
|
|
|
1370
1370
|
* See the License for the specific language governing permissions and
|
|
1371
1371
|
* limitations under the License.
|
|
1372
1372
|
*/ function Et(t) {
|
|
1373
|
-
let
|
|
1374
|
-
for (const
|
|
1375
|
-
return
|
|
1373
|
+
let e = 0;
|
|
1374
|
+
for (const n in t) Object.prototype.hasOwnProperty.call(t, n) && e++;
|
|
1375
|
+
return e;
|
|
1376
1376
|
}
|
|
1377
1377
|
|
|
1378
|
-
function Tt(t,
|
|
1379
|
-
for (const
|
|
1378
|
+
function Tt(t, e) {
|
|
1379
|
+
for (const n in t) Object.prototype.hasOwnProperty.call(t, n) && e(n, t[n]);
|
|
1380
1380
|
}
|
|
1381
1381
|
|
|
1382
1382
|
/**
|
|
@@ -1410,7 +1410,7 @@ class It {
|
|
|
1410
1410
|
this.fields = t,
|
|
1411
1411
|
// TODO(dimond): validation of FieldMask
|
|
1412
1412
|
// Sort the field mask to support `FieldMask.isEqual()` and assert below.
|
|
1413
|
-
t.sort(
|
|
1413
|
+
t.sort(et.comparator);
|
|
1414
1414
|
}
|
|
1415
1415
|
/**
|
|
1416
1416
|
* Verifies that `fieldPath` is included by at least one field in this field
|
|
@@ -1418,11 +1418,11 @@ class It {
|
|
|
1418
1418
|
*
|
|
1419
1419
|
* This is an O(n) operation, where `n` is the size of the field mask.
|
|
1420
1420
|
*/ covers(t) {
|
|
1421
|
-
for (const
|
|
1421
|
+
for (const e of this.fields) if (e.isPrefixOf(t)) return !0;
|
|
1422
1422
|
return !1;
|
|
1423
1423
|
}
|
|
1424
1424
|
isEqual(t) {
|
|
1425
|
-
return gt(this.fields, t.fields, ((t,
|
|
1425
|
+
return gt(this.fields, t.fields, ((t, e) => t.isEqual(e)));
|
|
1426
1426
|
}
|
|
1427
1427
|
}
|
|
1428
1428
|
|
|
@@ -1484,25 +1484,25 @@ class Rt {
|
|
|
1484
1484
|
this.binaryString = t;
|
|
1485
1485
|
}
|
|
1486
1486
|
static fromBase64String(t) {
|
|
1487
|
-
const
|
|
1488
|
-
return new Rt(
|
|
1487
|
+
const e = At(t);
|
|
1488
|
+
return new Rt(e);
|
|
1489
1489
|
}
|
|
1490
1490
|
static fromUint8Array(t) {
|
|
1491
1491
|
// TODO(indexing); Remove the copy of the byte string here as this method
|
|
1492
1492
|
// is frequently called during indexing.
|
|
1493
|
-
const
|
|
1493
|
+
const e =
|
|
1494
1494
|
/**
|
|
1495
1495
|
* Helper function to convert an Uint8array to a binary string.
|
|
1496
1496
|
*/
|
|
1497
1497
|
function(t) {
|
|
1498
|
-
let
|
|
1499
|
-
for (let
|
|
1500
|
-
return
|
|
1498
|
+
let e = "";
|
|
1499
|
+
for (let n = 0; n < t.length; ++n) e += String.fromCharCode(t[n]);
|
|
1500
|
+
return e;
|
|
1501
1501
|
}
|
|
1502
1502
|
/**
|
|
1503
1503
|
* Helper function to convert a binary string to an Uint8Array.
|
|
1504
1504
|
*/ (t);
|
|
1505
|
-
return new Rt(
|
|
1505
|
+
return new Rt(e);
|
|
1506
1506
|
}
|
|
1507
1507
|
[Symbol.iterator]() {
|
|
1508
1508
|
let t = 0;
|
|
@@ -1518,16 +1518,16 @@ class Rt {
|
|
|
1518
1518
|
}
|
|
1519
1519
|
toBase64() {
|
|
1520
1520
|
return function(t) {
|
|
1521
|
-
const
|
|
1522
|
-
for (let
|
|
1523
|
-
return a.encodeByteArray(
|
|
1521
|
+
const e = [];
|
|
1522
|
+
for (let n = 0; n < t.length; n++) e[n] = t.charCodeAt(n);
|
|
1523
|
+
return a.encodeByteArray(e, !1);
|
|
1524
1524
|
}(this.binaryString);
|
|
1525
1525
|
}
|
|
1526
1526
|
toUint8Array() {
|
|
1527
1527
|
return function(t) {
|
|
1528
|
-
const
|
|
1529
|
-
for (let
|
|
1530
|
-
return
|
|
1528
|
+
const e = new Uint8Array(t.length);
|
|
1529
|
+
for (let n = 0; n < t.length; n++) e[n] = t.charCodeAt(n);
|
|
1530
|
+
return e;
|
|
1531
1531
|
}
|
|
1532
1532
|
/**
|
|
1533
1533
|
* @license
|
|
@@ -1570,22 +1570,22 @@ const Pt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1570
1570
|
// The json interface (for the browser) will return an iso timestamp string,
|
|
1571
1571
|
// while the proto js library (for node) will return a
|
|
1572
1572
|
// google.protobuf.Timestamp instance.
|
|
1573
|
-
if (
|
|
1573
|
+
if (v(!!t), "string" == typeof t) {
|
|
1574
1574
|
// The date string can have higher precision (nanos) than the Date class
|
|
1575
1575
|
// (millis), so we do some custom parsing here.
|
|
1576
1576
|
// Parse the nanos right out of the string.
|
|
1577
|
-
let
|
|
1578
|
-
const
|
|
1579
|
-
if (
|
|
1577
|
+
let e = 0;
|
|
1578
|
+
const n = Pt.exec(t);
|
|
1579
|
+
if (v(!!n), n[1]) {
|
|
1580
1580
|
// Pad the fraction out to 9 digits (nanos).
|
|
1581
|
-
let t =
|
|
1582
|
-
t = (t + "000000000").substr(0, 9),
|
|
1581
|
+
let t = n[1];
|
|
1582
|
+
t = (t + "000000000").substr(0, 9), e = Number(t);
|
|
1583
1583
|
}
|
|
1584
1584
|
// Parse the date to get the seconds.
|
|
1585
1585
|
const r = new Date(t);
|
|
1586
1586
|
return {
|
|
1587
1587
|
seconds: Math.floor(r.getTime() / 1e3),
|
|
1588
|
-
nanos:
|
|
1588
|
+
nanos: e
|
|
1589
1589
|
};
|
|
1590
1590
|
}
|
|
1591
1591
|
return {
|
|
@@ -1640,8 +1640,8 @@ const Pt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1640
1640
|
* - With respect to other ServerTimestampValues, they sort by their
|
|
1641
1641
|
* localWriteTime.
|
|
1642
1642
|
*/ function $t(t) {
|
|
1643
|
-
var
|
|
1644
|
-
return "server_timestamp" === (null === (
|
|
1643
|
+
var e, n;
|
|
1644
|
+
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);
|
|
1645
1645
|
}
|
|
1646
1646
|
|
|
1647
1647
|
/**
|
|
@@ -1650,15 +1650,15 @@ const Pt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1650
1650
|
* Preserving the previous values allows the user to display the last resoled
|
|
1651
1651
|
* value until the backend responds with the timestamp.
|
|
1652
1652
|
*/ function St(t) {
|
|
1653
|
-
const
|
|
1654
|
-
return $t(
|
|
1653
|
+
const e = t.mapValue.fields.__previous_value__;
|
|
1654
|
+
return $t(e) ? St(e) : e;
|
|
1655
1655
|
}
|
|
1656
1656
|
|
|
1657
1657
|
/**
|
|
1658
1658
|
* Returns the local time at which this timestamp was first set.
|
|
1659
1659
|
*/ function Ft(t) {
|
|
1660
|
-
const
|
|
1661
|
-
return new
|
|
1660
|
+
const e = Vt(t.mapValue.fields.__local_write_time__.timestampValue);
|
|
1661
|
+
return new bt(e.seconds, e.nanos);
|
|
1662
1662
|
}
|
|
1663
1663
|
|
|
1664
1664
|
/**
|
|
@@ -1676,9 +1676,16 @@ const Pt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1676
1676
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1677
1677
|
* See the License for the specific language governing permissions and
|
|
1678
1678
|
* limitations under the License.
|
|
1679
|
-
*/
|
|
1679
|
+
*/ const xt = {
|
|
1680
|
+
fields: {
|
|
1681
|
+
__type__: {
|
|
1682
|
+
stringValue: "__max__"
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
};
|
|
1686
|
+
|
|
1680
1687
|
/** Extracts the backend's type order for the provided value. */
|
|
1681
|
-
function
|
|
1688
|
+
function qt(t) {
|
|
1682
1689
|
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 ? $t(t) ? 4 /* ServerTimestampValue */ :
|
|
1683
1690
|
/** Returns true if the Value represents the canonical {@link #MAX_VALUE} . */
|
|
1684
1691
|
function(t) {
|
|
@@ -1703,194 +1710,197 @@ function xt(t) {
|
|
|
1703
1710
|
/**
|
|
1704
1711
|
* An ObjectValue represents a MapValue in the Firestore Proto and offers the
|
|
1705
1712
|
* ability to add and remove fields (via the ObjectValueBuilder).
|
|
1706
|
-
*/ (t) ?
|
|
1713
|
+
*/ (t) ? 9007199254740991 /* MaxValue */ : 10 /* ObjectValue */ : b();
|
|
1707
1714
|
}
|
|
1708
1715
|
|
|
1709
|
-
/** Tests `left` and `right` for equality based on the backend semantics. */ function
|
|
1710
|
-
if (t ===
|
|
1711
|
-
const
|
|
1712
|
-
if (
|
|
1713
|
-
switch (
|
|
1716
|
+
/** Tests `left` and `right` for equality based on the backend semantics. */ function Ot(t, e) {
|
|
1717
|
+
if (t === e) return !0;
|
|
1718
|
+
const n = qt(t);
|
|
1719
|
+
if (n !== qt(e)) return !1;
|
|
1720
|
+
switch (n) {
|
|
1714
1721
|
case 0 /* NullValue */ :
|
|
1715
1722
|
case 9007199254740991 /* MaxValue */ :
|
|
1716
1723
|
return !0;
|
|
1717
1724
|
|
|
1718
1725
|
case 1 /* BooleanValue */ :
|
|
1719
|
-
return t.booleanValue ===
|
|
1726
|
+
return t.booleanValue === e.booleanValue;
|
|
1720
1727
|
|
|
1721
1728
|
case 4 /* ServerTimestampValue */ :
|
|
1722
|
-
return Ft(t).isEqual(Ft(
|
|
1729
|
+
return Ft(t).isEqual(Ft(e));
|
|
1723
1730
|
|
|
1724
1731
|
case 3 /* TimestampValue */ :
|
|
1725
|
-
return function(t,
|
|
1726
|
-
if ("string" == typeof t.timestampValue && "string" == typeof
|
|
1732
|
+
return function(t, e) {
|
|
1733
|
+
if ("string" == typeof t.timestampValue && "string" == typeof e.timestampValue && t.timestampValue.length === e.timestampValue.length)
|
|
1727
1734
|
// Use string equality for ISO 8601 timestamps
|
|
1728
|
-
return t.timestampValue ===
|
|
1729
|
-
const
|
|
1730
|
-
return
|
|
1731
|
-
}(t,
|
|
1735
|
+
return t.timestampValue === e.timestampValue;
|
|
1736
|
+
const n = Vt(t.timestampValue), r = Vt(e.timestampValue);
|
|
1737
|
+
return n.seconds === r.seconds && n.nanos === r.nanos;
|
|
1738
|
+
}(t, e);
|
|
1732
1739
|
|
|
1733
1740
|
case 5 /* StringValue */ :
|
|
1734
|
-
return t.stringValue ===
|
|
1741
|
+
return t.stringValue === e.stringValue;
|
|
1735
1742
|
|
|
1736
1743
|
case 6 /* BlobValue */ :
|
|
1737
|
-
return function(t,
|
|
1738
|
-
return Dt(t.bytesValue).isEqual(Dt(
|
|
1739
|
-
}(t,
|
|
1744
|
+
return function(t, e) {
|
|
1745
|
+
return Dt(t.bytesValue).isEqual(Dt(e.bytesValue));
|
|
1746
|
+
}(t, e);
|
|
1740
1747
|
|
|
1741
1748
|
case 7 /* RefValue */ :
|
|
1742
|
-
return t.referenceValue ===
|
|
1749
|
+
return t.referenceValue === e.referenceValue;
|
|
1743
1750
|
|
|
1744
1751
|
case 8 /* GeoPointValue */ :
|
|
1745
|
-
return function(t,
|
|
1746
|
-
return Nt(t.geoPointValue.latitude) === Nt(
|
|
1747
|
-
}(t,
|
|
1752
|
+
return function(t, e) {
|
|
1753
|
+
return Nt(t.geoPointValue.latitude) === Nt(e.geoPointValue.latitude) && Nt(t.geoPointValue.longitude) === Nt(e.geoPointValue.longitude);
|
|
1754
|
+
}(t, e);
|
|
1748
1755
|
|
|
1749
1756
|
case 2 /* NumberValue */ :
|
|
1750
|
-
return function(t,
|
|
1751
|
-
if ("integerValue" in t && "integerValue" in
|
|
1752
|
-
if ("doubleValue" in t && "doubleValue" in
|
|
1753
|
-
const
|
|
1754
|
-
return
|
|
1757
|
+
return function(t, e) {
|
|
1758
|
+
if ("integerValue" in t && "integerValue" in e) return Nt(t.integerValue) === Nt(e.integerValue);
|
|
1759
|
+
if ("doubleValue" in t && "doubleValue" in e) {
|
|
1760
|
+
const n = Nt(t.doubleValue), r = Nt(e.doubleValue);
|
|
1761
|
+
return n === r ? ht(n) === ht(r) : isNaN(n) && isNaN(r);
|
|
1755
1762
|
}
|
|
1756
1763
|
return !1;
|
|
1757
|
-
}(t,
|
|
1764
|
+
}(t, e);
|
|
1758
1765
|
|
|
1759
1766
|
case 9 /* ArrayValue */ :
|
|
1760
|
-
return gt(t.arrayValue.values || [],
|
|
1767
|
+
return gt(t.arrayValue.values || [], e.arrayValue.values || [], Ot);
|
|
1761
1768
|
|
|
1762
1769
|
case 10 /* ObjectValue */ :
|
|
1763
|
-
return function(t,
|
|
1764
|
-
const
|
|
1765
|
-
if (Et(
|
|
1766
|
-
for (const t in
|
|
1770
|
+
return function(t, e) {
|
|
1771
|
+
const n = t.mapValue.fields || {}, r = e.mapValue.fields || {};
|
|
1772
|
+
if (Et(n) !== Et(r)) return !1;
|
|
1773
|
+
for (const t in n) if (n.hasOwnProperty(t) && (void 0 === r[t] || !Ot(n[t], r[t]))) return !1;
|
|
1767
1774
|
return !0;
|
|
1768
1775
|
}
|
|
1769
|
-
/** Returns true if the ArrayValue contains the specified element. */ (t,
|
|
1776
|
+
/** Returns true if the ArrayValue contains the specified element. */ (t, e);
|
|
1770
1777
|
|
|
1771
1778
|
default:
|
|
1772
|
-
return
|
|
1779
|
+
return b();
|
|
1773
1780
|
}
|
|
1774
1781
|
}
|
|
1775
1782
|
|
|
1776
|
-
function
|
|
1777
|
-
return void 0 !== (t.values || []).find((t =>
|
|
1783
|
+
function Ct(t, e) {
|
|
1784
|
+
return void 0 !== (t.values || []).find((t => Ot(t, e)));
|
|
1778
1785
|
}
|
|
1779
1786
|
|
|
1780
|
-
function
|
|
1781
|
-
if (t ===
|
|
1782
|
-
const
|
|
1783
|
-
if (
|
|
1784
|
-
switch (
|
|
1787
|
+
function Lt(t, e) {
|
|
1788
|
+
if (t === e) return 0;
|
|
1789
|
+
const n = qt(t), r = qt(e);
|
|
1790
|
+
if (n !== r) return _t(n, r);
|
|
1791
|
+
switch (n) {
|
|
1785
1792
|
case 0 /* NullValue */ :
|
|
1786
1793
|
case 9007199254740991 /* MaxValue */ :
|
|
1787
1794
|
return 0;
|
|
1788
1795
|
|
|
1789
1796
|
case 1 /* BooleanValue */ :
|
|
1790
|
-
return _t(t.booleanValue,
|
|
1797
|
+
return _t(t.booleanValue, e.booleanValue);
|
|
1791
1798
|
|
|
1792
1799
|
case 2 /* NumberValue */ :
|
|
1793
|
-
return function(t,
|
|
1794
|
-
const
|
|
1795
|
-
return
|
|
1800
|
+
return function(t, e) {
|
|
1801
|
+
const n = Nt(t.integerValue || t.doubleValue), r = Nt(e.integerValue || e.doubleValue);
|
|
1802
|
+
return n < r ? -1 : n > r ? 1 : n === r ? 0 :
|
|
1796
1803
|
// one or both are NaN.
|
|
1797
|
-
isNaN(
|
|
1798
|
-
}(t,
|
|
1804
|
+
isNaN(n) ? isNaN(r) ? 0 : -1 : 1;
|
|
1805
|
+
}(t, e);
|
|
1799
1806
|
|
|
1800
1807
|
case 3 /* TimestampValue */ :
|
|
1801
|
-
return
|
|
1808
|
+
return kt(t.timestampValue, e.timestampValue);
|
|
1802
1809
|
|
|
1803
1810
|
case 4 /* ServerTimestampValue */ :
|
|
1804
|
-
return
|
|
1811
|
+
return kt(Ft(t), Ft(e));
|
|
1805
1812
|
|
|
1806
1813
|
case 5 /* StringValue */ :
|
|
1807
|
-
return _t(t.stringValue,
|
|
1814
|
+
return _t(t.stringValue, e.stringValue);
|
|
1808
1815
|
|
|
1809
1816
|
case 6 /* BlobValue */ :
|
|
1810
|
-
return function(t,
|
|
1811
|
-
const
|
|
1812
|
-
return
|
|
1813
|
-
}(t.bytesValue,
|
|
1817
|
+
return function(t, e) {
|
|
1818
|
+
const n = Dt(t), r = Dt(e);
|
|
1819
|
+
return n.compareTo(r);
|
|
1820
|
+
}(t.bytesValue, e.bytesValue);
|
|
1814
1821
|
|
|
1815
1822
|
case 7 /* RefValue */ :
|
|
1816
|
-
return function(t,
|
|
1817
|
-
const
|
|
1818
|
-
for (let t = 0; t <
|
|
1819
|
-
const
|
|
1820
|
-
if (0 !==
|
|
1823
|
+
return function(t, e) {
|
|
1824
|
+
const n = t.split("/"), r = e.split("/");
|
|
1825
|
+
for (let t = 0; t < n.length && t < r.length; t++) {
|
|
1826
|
+
const e = _t(n[t], r[t]);
|
|
1827
|
+
if (0 !== e) return e;
|
|
1821
1828
|
}
|
|
1822
|
-
return _t(
|
|
1823
|
-
}(t.referenceValue,
|
|
1829
|
+
return _t(n.length, r.length);
|
|
1830
|
+
}(t.referenceValue, e.referenceValue);
|
|
1824
1831
|
|
|
1825
1832
|
case 8 /* GeoPointValue */ :
|
|
1826
|
-
return function(t,
|
|
1827
|
-
const
|
|
1828
|
-
if (0 !==
|
|
1829
|
-
return _t(Nt(t.longitude), Nt(
|
|
1830
|
-
}(t.geoPointValue,
|
|
1833
|
+
return function(t, e) {
|
|
1834
|
+
const n = _t(Nt(t.latitude), Nt(e.latitude));
|
|
1835
|
+
if (0 !== n) return n;
|
|
1836
|
+
return _t(Nt(t.longitude), Nt(e.longitude));
|
|
1837
|
+
}(t.geoPointValue, e.geoPointValue);
|
|
1831
1838
|
|
|
1832
1839
|
case 9 /* ArrayValue */ :
|
|
1833
|
-
return function(t,
|
|
1834
|
-
const
|
|
1835
|
-
for (let t = 0; t <
|
|
1836
|
-
const
|
|
1837
|
-
if (
|
|
1840
|
+
return function(t, e) {
|
|
1841
|
+
const n = t.values || [], r = e.values || [];
|
|
1842
|
+
for (let t = 0; t < n.length && t < r.length; ++t) {
|
|
1843
|
+
const e = Lt(n[t], r[t]);
|
|
1844
|
+
if (e) return e;
|
|
1838
1845
|
}
|
|
1839
|
-
return _t(
|
|
1840
|
-
}(t.arrayValue,
|
|
1846
|
+
return _t(n.length, r.length);
|
|
1847
|
+
}(t.arrayValue, e.arrayValue);
|
|
1841
1848
|
|
|
1842
1849
|
case 10 /* ObjectValue */ :
|
|
1843
|
-
return function(t,
|
|
1844
|
-
|
|
1850
|
+
return function(t, e) {
|
|
1851
|
+
if (t === xt && e === xt) return 0;
|
|
1852
|
+
if (t === xt) return 1;
|
|
1853
|
+
if (e === xt) return -1;
|
|
1854
|
+
const n = t.fields || {}, r = Object.keys(n), s = e.fields || {}, i = Object.keys(s);
|
|
1845
1855
|
// Even though MapValues are likely sorted correctly based on their insertion
|
|
1846
1856
|
// order (e.g. when received from the backend), local modifications can bring
|
|
1847
1857
|
// elements out of order. We need to re-sort the elements to ensure that
|
|
1848
1858
|
// canonical IDs are independent of insertion order.
|
|
1849
1859
|
r.sort(), i.sort();
|
|
1850
1860
|
for (let t = 0; t < r.length && t < i.length; ++t) {
|
|
1851
|
-
const
|
|
1852
|
-
if (0 !==
|
|
1853
|
-
const o =
|
|
1861
|
+
const e = _t(r[t], i[t]);
|
|
1862
|
+
if (0 !== e) return e;
|
|
1863
|
+
const o = Lt(n[r[t]], s[i[t]]);
|
|
1854
1864
|
if (0 !== o) return o;
|
|
1855
1865
|
}
|
|
1856
1866
|
return _t(r.length, i.length);
|
|
1857
1867
|
}
|
|
1858
|
-
/** Returns a reference value for the provided database and key. */ (t.mapValue,
|
|
1868
|
+
/** Returns a reference value for the provided database and key. */ (t.mapValue, e.mapValue);
|
|
1859
1869
|
|
|
1860
1870
|
default:
|
|
1861
|
-
throw
|
|
1871
|
+
throw b();
|
|
1862
1872
|
}
|
|
1863
1873
|
}
|
|
1864
1874
|
|
|
1865
|
-
function
|
|
1866
|
-
if ("string" == typeof t && "string" == typeof
|
|
1867
|
-
const
|
|
1868
|
-
return 0 !== s ? s : _t(
|
|
1875
|
+
function kt(t, e) {
|
|
1876
|
+
if ("string" == typeof t && "string" == typeof e && t.length === e.length) return _t(t, e);
|
|
1877
|
+
const n = Vt(t), r = Vt(e), s = _t(n.seconds, r.seconds);
|
|
1878
|
+
return 0 !== s ? s : _t(n.nanos, r.nanos);
|
|
1869
1879
|
}
|
|
1870
1880
|
|
|
1871
|
-
function
|
|
1881
|
+
function Ut(t, e) {
|
|
1872
1882
|
return {
|
|
1873
|
-
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${
|
|
1883
|
+
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${e.path.canonicalString()}`
|
|
1874
1884
|
};
|
|
1875
1885
|
}
|
|
1876
1886
|
|
|
1877
|
-
/** Returns true if `value` is an ArrayValue. */ function
|
|
1887
|
+
/** Returns true if `value` is an ArrayValue. */ function jt(t) {
|
|
1878
1888
|
return !!t && "arrayValue" in t;
|
|
1879
1889
|
}
|
|
1880
1890
|
|
|
1881
|
-
/** Returns true if `value` is a NullValue. */ function
|
|
1891
|
+
/** Returns true if `value` is a NullValue. */ function Mt(t) {
|
|
1882
1892
|
return !!t && "nullValue" in t;
|
|
1883
1893
|
}
|
|
1884
1894
|
|
|
1885
|
-
/** Returns true if `value` is NaN. */ function
|
|
1895
|
+
/** Returns true if `value` is NaN. */ function Bt(t) {
|
|
1886
1896
|
return !!t && "doubleValue" in t && isNaN(Number(t.doubleValue));
|
|
1887
1897
|
}
|
|
1888
1898
|
|
|
1889
|
-
/** Returns true if `value` is a MapValue. */ function
|
|
1899
|
+
/** Returns true if `value` is a MapValue. */ function zt(t) {
|
|
1890
1900
|
return !!t && "mapValue" in t;
|
|
1891
1901
|
}
|
|
1892
1902
|
|
|
1893
|
-
/** Creates a deep copy of `source`. */ function
|
|
1903
|
+
/** Creates a deep copy of `source`. */ function Gt(t) {
|
|
1894
1904
|
if (t.geoPointValue) return {
|
|
1895
1905
|
geoPointValue: Object.assign({}, t.geoPointValue)
|
|
1896
1906
|
};
|
|
@@ -1898,31 +1908,31 @@ function kt(t, n) {
|
|
|
1898
1908
|
timestampValue: Object.assign({}, t.timestampValue)
|
|
1899
1909
|
};
|
|
1900
1910
|
if (t.mapValue) {
|
|
1901
|
-
const
|
|
1911
|
+
const e = {
|
|
1902
1912
|
mapValue: {
|
|
1903
1913
|
fields: {}
|
|
1904
1914
|
}
|
|
1905
1915
|
};
|
|
1906
|
-
return Tt(t.mapValue.fields, ((t,
|
|
1916
|
+
return Tt(t.mapValue.fields, ((t, n) => e.mapValue.fields[t] = Gt(n))), e;
|
|
1907
1917
|
}
|
|
1908
1918
|
if (t.arrayValue) {
|
|
1909
|
-
const
|
|
1919
|
+
const e = {
|
|
1910
1920
|
arrayValue: {
|
|
1911
1921
|
values: []
|
|
1912
1922
|
}
|
|
1913
1923
|
};
|
|
1914
|
-
for (let
|
|
1915
|
-
return
|
|
1924
|
+
for (let n = 0; n < (t.arrayValue.values || []).length; ++n) e.arrayValue.values[n] = Gt(t.arrayValue.values[n]);
|
|
1925
|
+
return e;
|
|
1916
1926
|
}
|
|
1917
1927
|
return Object.assign({}, t);
|
|
1918
1928
|
}
|
|
1919
1929
|
|
|
1920
|
-
class
|
|
1930
|
+
class Qt {
|
|
1921
1931
|
constructor(t) {
|
|
1922
1932
|
this.value = t;
|
|
1923
1933
|
}
|
|
1924
1934
|
static empty() {
|
|
1925
|
-
return new
|
|
1935
|
+
return new Qt({
|
|
1926
1936
|
mapValue: {}
|
|
1927
1937
|
});
|
|
1928
1938
|
}
|
|
@@ -1934,10 +1944,10 @@ class Gt {
|
|
|
1934
1944
|
*/ field(t) {
|
|
1935
1945
|
if (t.isEmpty()) return this.value;
|
|
1936
1946
|
{
|
|
1937
|
-
let
|
|
1938
|
-
for (let
|
|
1939
|
-
!
|
|
1940
|
-
return
|
|
1947
|
+
let e = this.value;
|
|
1948
|
+
for (let n = 0; n < t.length - 1; ++n) if (e = (e.mapValue.fields || {})[t.get(n)],
|
|
1949
|
+
!zt(e)) return null;
|
|
1950
|
+
return e = (e.mapValue.fields || {})[t.lastSegment()], e || null;
|
|
1941
1951
|
}
|
|
1942
1952
|
}
|
|
1943
1953
|
/**
|
|
@@ -1945,25 +1955,25 @@ class Gt {
|
|
|
1945
1955
|
*
|
|
1946
1956
|
* @param path - The field path to set.
|
|
1947
1957
|
* @param value - The value to set.
|
|
1948
|
-
*/ set(t,
|
|
1949
|
-
this.getFieldsMap(t.popLast())[t.lastSegment()] =
|
|
1958
|
+
*/ set(t, e) {
|
|
1959
|
+
this.getFieldsMap(t.popLast())[t.lastSegment()] = Gt(e);
|
|
1950
1960
|
}
|
|
1951
1961
|
/**
|
|
1952
1962
|
* Sets the provided fields to the provided values.
|
|
1953
1963
|
*
|
|
1954
1964
|
* @param data - A map of fields to values (or null for deletes).
|
|
1955
1965
|
*/ setAll(t) {
|
|
1956
|
-
let
|
|
1966
|
+
let e = et.emptyPath(), n = {}, r = [];
|
|
1957
1967
|
t.forEach(((t, s) => {
|
|
1958
|
-
if (!
|
|
1968
|
+
if (!e.isImmediateParentOf(s)) {
|
|
1959
1969
|
// Insert the accumulated changes at this parent location
|
|
1960
|
-
const t = this.getFieldsMap(
|
|
1961
|
-
this.applyChanges(t,
|
|
1970
|
+
const t = this.getFieldsMap(e);
|
|
1971
|
+
this.applyChanges(t, n, r), n = {}, r = [], e = s.popLast();
|
|
1962
1972
|
}
|
|
1963
|
-
t ?
|
|
1973
|
+
t ? n[s.lastSegment()] = Gt(t) : r.push(s.lastSegment());
|
|
1964
1974
|
}));
|
|
1965
|
-
const s = this.getFieldsMap(
|
|
1966
|
-
this.applyChanges(s,
|
|
1975
|
+
const s = this.getFieldsMap(e);
|
|
1976
|
+
this.applyChanges(s, n, r);
|
|
1967
1977
|
}
|
|
1968
1978
|
/**
|
|
1969
1979
|
* Removes the field at the specified path. If there is no field at the
|
|
@@ -1971,39 +1981,39 @@ class Gt {
|
|
|
1971
1981
|
*
|
|
1972
1982
|
* @param path - The field path to remove.
|
|
1973
1983
|
*/ delete(t) {
|
|
1974
|
-
const
|
|
1975
|
-
|
|
1984
|
+
const e = this.field(t.popLast());
|
|
1985
|
+
zt(e) && e.mapValue.fields && delete e.mapValue.fields[t.lastSegment()];
|
|
1976
1986
|
}
|
|
1977
1987
|
isEqual(t) {
|
|
1978
|
-
return
|
|
1988
|
+
return Ot(this.value, t.value);
|
|
1979
1989
|
}
|
|
1980
1990
|
/**
|
|
1981
1991
|
* Returns the map that contains the leaf element of `path`. If the parent
|
|
1982
1992
|
* entry does not yet exist, or if it is not a map, a new map will be created.
|
|
1983
1993
|
*/ getFieldsMap(t) {
|
|
1984
|
-
let
|
|
1985
|
-
|
|
1994
|
+
let e = this.value;
|
|
1995
|
+
e.mapValue.fields || (e.mapValue = {
|
|
1986
1996
|
fields: {}
|
|
1987
1997
|
});
|
|
1988
|
-
for (let
|
|
1989
|
-
let r =
|
|
1990
|
-
|
|
1998
|
+
for (let n = 0; n < t.length; ++n) {
|
|
1999
|
+
let r = e.mapValue.fields[t.get(n)];
|
|
2000
|
+
zt(r) && r.mapValue.fields || (r = {
|
|
1991
2001
|
mapValue: {
|
|
1992
2002
|
fields: {}
|
|
1993
2003
|
}
|
|
1994
|
-
},
|
|
2004
|
+
}, e.mapValue.fields[t.get(n)] = r), e = r;
|
|
1995
2005
|
}
|
|
1996
|
-
return
|
|
2006
|
+
return e.mapValue.fields;
|
|
1997
2007
|
}
|
|
1998
2008
|
/**
|
|
1999
2009
|
* Modifies `fieldsMap` by adding, replacing or deleting the specified
|
|
2000
2010
|
* entries.
|
|
2001
|
-
*/ applyChanges(t,
|
|
2002
|
-
Tt(
|
|
2003
|
-
for (const
|
|
2011
|
+
*/ applyChanges(t, e, n) {
|
|
2012
|
+
Tt(e, ((e, n) => t[e] = n));
|
|
2013
|
+
for (const e of n) delete t[e];
|
|
2004
2014
|
}
|
|
2005
2015
|
clone() {
|
|
2006
|
-
return new Gt(
|
|
2016
|
+
return new Qt(Gt(this.value));
|
|
2007
2017
|
}
|
|
2008
2018
|
}
|
|
2009
2019
|
|
|
@@ -2032,45 +2042,45 @@ class Gt {
|
|
|
2032
2042
|
* not transition to one of these states even after all mutations have been
|
|
2033
2043
|
* applied, `isValidDocument()` returns false and the document should be removed
|
|
2034
2044
|
* from all views.
|
|
2035
|
-
*/ class
|
|
2036
|
-
constructor(t,
|
|
2037
|
-
this.key = t, this.documentType =
|
|
2045
|
+
*/ class Wt {
|
|
2046
|
+
constructor(t, e, n, r, s, i) {
|
|
2047
|
+
this.key = t, this.documentType = e, this.version = n, this.readTime = r, this.data = s,
|
|
2038
2048
|
this.documentState = i;
|
|
2039
2049
|
}
|
|
2040
2050
|
/**
|
|
2041
2051
|
* Creates a document with no known version or data, but which can serve as
|
|
2042
2052
|
* base document for mutations.
|
|
2043
2053
|
*/ static newInvalidDocument(t) {
|
|
2044
|
-
return new
|
|
2054
|
+
return new Wt(t, 0 /* INVALID */ , vt.min(), vt.min(), Qt.empty(), 0 /* SYNCED */);
|
|
2045
2055
|
}
|
|
2046
2056
|
/**
|
|
2047
2057
|
* Creates a new document that is known to exist with the given data at the
|
|
2048
2058
|
* given version.
|
|
2049
|
-
*/ static newFoundDocument(t,
|
|
2050
|
-
return new
|
|
2059
|
+
*/ static newFoundDocument(t, e, n) {
|
|
2060
|
+
return new Wt(t, 1 /* FOUND_DOCUMENT */ , e, vt.min(), n, 0 /* SYNCED */);
|
|
2051
2061
|
}
|
|
2052
|
-
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t,
|
|
2053
|
-
return new
|
|
2062
|
+
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t, e) {
|
|
2063
|
+
return new Wt(t, 2 /* NO_DOCUMENT */ , e, vt.min(), Qt.empty(), 0 /* SYNCED */);
|
|
2054
2064
|
}
|
|
2055
2065
|
/**
|
|
2056
2066
|
* Creates a new document that is known to exist at the given version but
|
|
2057
2067
|
* whose data is not known (e.g. a document that was updated without a known
|
|
2058
2068
|
* base document).
|
|
2059
|
-
*/ static newUnknownDocument(t,
|
|
2060
|
-
return new
|
|
2069
|
+
*/ static newUnknownDocument(t, e) {
|
|
2070
|
+
return new Wt(t, 3 /* UNKNOWN_DOCUMENT */ , e, vt.min(), Qt.empty(), 2 /* HAS_COMMITTED_MUTATIONS */);
|
|
2061
2071
|
}
|
|
2062
2072
|
/**
|
|
2063
2073
|
* Changes the document type to indicate that it exists and that its version
|
|
2064
2074
|
* and data are known.
|
|
2065
|
-
*/ convertToFoundDocument(t,
|
|
2066
|
-
return this.version = t, this.documentType = 1 /* FOUND_DOCUMENT */ , this.data =
|
|
2075
|
+
*/ convertToFoundDocument(t, e) {
|
|
2076
|
+
return this.version = t, this.documentType = 1 /* FOUND_DOCUMENT */ , this.data = e,
|
|
2067
2077
|
this.documentState = 0 /* SYNCED */ , this;
|
|
2068
2078
|
}
|
|
2069
2079
|
/**
|
|
2070
2080
|
* Changes the document type to indicate that it doesn't exist at the given
|
|
2071
2081
|
* version.
|
|
2072
2082
|
*/ convertToNoDocument(t) {
|
|
2073
|
-
return this.version = t, this.documentType = 2 /* NO_DOCUMENT */ , this.data =
|
|
2083
|
+
return this.version = t, this.documentType = 2 /* NO_DOCUMENT */ , this.data = Qt.empty(),
|
|
2074
2084
|
this.documentState = 0 /* SYNCED */ , this;
|
|
2075
2085
|
}
|
|
2076
2086
|
/**
|
|
@@ -2078,7 +2088,7 @@ class Gt {
|
|
|
2078
2088
|
* that its data is not known (e.g. a document that was updated without a known
|
|
2079
2089
|
* base document).
|
|
2080
2090
|
*/ convertToUnknownDocument(t) {
|
|
2081
|
-
return this.version = t, this.documentType = 3 /* UNKNOWN_DOCUMENT */ , this.data =
|
|
2091
|
+
return this.version = t, this.documentType = 3 /* UNKNOWN_DOCUMENT */ , this.data = Qt.empty(),
|
|
2082
2092
|
this.documentState = 2 /* HAS_COMMITTED_MUTATIONS */ , this;
|
|
2083
2093
|
}
|
|
2084
2094
|
setHasCommittedMutations() {
|
|
@@ -2112,10 +2122,10 @@ class Gt {
|
|
|
2112
2122
|
return 3 /* UNKNOWN_DOCUMENT */ === this.documentType;
|
|
2113
2123
|
}
|
|
2114
2124
|
isEqual(t) {
|
|
2115
|
-
return t instanceof
|
|
2125
|
+
return t instanceof Wt && this.key.isEqual(t.key) && this.version.isEqual(t.version) && this.documentType === t.documentType && this.documentState === t.documentState && this.data.isEqual(t.data);
|
|
2116
2126
|
}
|
|
2117
2127
|
mutableCopy() {
|
|
2118
|
-
return new
|
|
2128
|
+
return new Wt(this.key, this.documentType, this.version, this.readTime, this.data.clone(), this.documentState);
|
|
2119
2129
|
}
|
|
2120
2130
|
toString() {
|
|
2121
2131
|
return `Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`;
|
|
@@ -2139,9 +2149,9 @@ class Gt {
|
|
|
2139
2149
|
* limitations under the License.
|
|
2140
2150
|
*/
|
|
2141
2151
|
// Visible for testing
|
|
2142
|
-
class
|
|
2143
|
-
constructor(t,
|
|
2144
|
-
this.path = t, this.collectionGroup =
|
|
2152
|
+
class Yt {
|
|
2153
|
+
constructor(t, e = null, n = [], r = [], s = null, i = null, o = null) {
|
|
2154
|
+
this.path = t, this.collectionGroup = e, this.orderBy = n, this.filters = r, this.limit = s,
|
|
2145
2155
|
this.startAt = i, this.endAt = o, this.P = null;
|
|
2146
2156
|
}
|
|
2147
2157
|
}
|
|
@@ -2153,26 +2163,26 @@ class Wt {
|
|
|
2153
2163
|
* NOTE: you should always construct `Target` from `Query.toTarget` instead of
|
|
2154
2164
|
* using this factory method, because `Query` provides an implicit `orderBy`
|
|
2155
2165
|
* property.
|
|
2156
|
-
*/ function
|
|
2157
|
-
return new
|
|
2166
|
+
*/ function Ht(t, e = null, n = [], r = [], s = null, i = null, o = null) {
|
|
2167
|
+
return new Yt(t, e, n, r, s, i, o);
|
|
2158
2168
|
}
|
|
2159
2169
|
|
|
2160
|
-
class
|
|
2161
|
-
constructor(t,
|
|
2162
|
-
super(), this.field = t, this.op =
|
|
2170
|
+
class Kt extends class {} {
|
|
2171
|
+
constructor(t, e, n) {
|
|
2172
|
+
super(), this.field = t, this.op = e, this.value = n;
|
|
2163
2173
|
}
|
|
2164
2174
|
/**
|
|
2165
2175
|
* Creates a filter based on the provided arguments.
|
|
2166
|
-
*/ static create(t,
|
|
2167
|
-
return t.isKeyField() ? "in" /* IN */ ===
|
|
2176
|
+
*/ static create(t, e, n) {
|
|
2177
|
+
return t.isKeyField() ? "in" /* IN */ === e || "not-in" /* NOT_IN */ === e ? this.V(t, e, n) : new Jt(t, e, n) : "array-contains" /* ARRAY_CONTAINS */ === e ? new ee(t, n) : "in" /* IN */ === e ? new ne(t, n) : "not-in" /* NOT_IN */ === e ? new re(t, n) : "array-contains-any" /* ARRAY_CONTAINS_ANY */ === e ? new se(t, n) : new Kt(t, e, n);
|
|
2168
2178
|
}
|
|
2169
|
-
static V(t,
|
|
2170
|
-
return "in" /* IN */ ===
|
|
2179
|
+
static V(t, e, n) {
|
|
2180
|
+
return "in" /* IN */ === e ? new Xt(t, n) : new Zt(t, n);
|
|
2171
2181
|
}
|
|
2172
2182
|
matches(t) {
|
|
2173
|
-
const
|
|
2183
|
+
const e = t.data.field(this.field);
|
|
2174
2184
|
// Types do not have to match in NOT_EQUAL filters.
|
|
2175
|
-
return "!=" /* NOT_EQUAL */ === this.op ? null !==
|
|
2185
|
+
return "!=" /* NOT_EQUAL */ === this.op ? null !== e && this.N(Lt(e, this.value)) : null !== e && qt(this.value) === qt(e) && this.N(Lt(e, this.value));
|
|
2176
2186
|
// Only compare types with matching backend order (such as double and int).
|
|
2177
2187
|
}
|
|
2178
2188
|
N(t) {
|
|
@@ -2196,7 +2206,7 @@ class Ht extends class {} {
|
|
|
2196
2206
|
return t >= 0;
|
|
2197
2207
|
|
|
2198
2208
|
default:
|
|
2199
|
-
return
|
|
2209
|
+
return b();
|
|
2200
2210
|
}
|
|
2201
2211
|
}
|
|
2202
2212
|
D() {
|
|
@@ -2205,79 +2215,79 @@ class Ht extends class {} {
|
|
|
2205
2215
|
}
|
|
2206
2216
|
|
|
2207
2217
|
/** Filter that matches on key fields (i.e. '__name__'). */
|
|
2208
|
-
class
|
|
2209
|
-
constructor(t,
|
|
2210
|
-
super(t,
|
|
2218
|
+
class Jt extends Kt {
|
|
2219
|
+
constructor(t, e, n) {
|
|
2220
|
+
super(t, e, n), this.key = nt.fromName(n.referenceValue);
|
|
2211
2221
|
}
|
|
2212
2222
|
matches(t) {
|
|
2213
|
-
const
|
|
2214
|
-
return this.N(
|
|
2223
|
+
const e = nt.comparator(t.key, this.key);
|
|
2224
|
+
return this.N(e);
|
|
2215
2225
|
}
|
|
2216
2226
|
}
|
|
2217
2227
|
|
|
2218
|
-
/** Filter that matches on key fields within an array. */ class
|
|
2219
|
-
constructor(t,
|
|
2220
|
-
super(t, "in" /* IN */ ,
|
|
2228
|
+
/** Filter that matches on key fields within an array. */ class Xt extends Kt {
|
|
2229
|
+
constructor(t, e) {
|
|
2230
|
+
super(t, "in" /* IN */ , e), this.keys = te("in" /* IN */ , e);
|
|
2221
2231
|
}
|
|
2222
2232
|
matches(t) {
|
|
2223
|
-
return this.keys.some((
|
|
2233
|
+
return this.keys.some((e => e.isEqual(t.key)));
|
|
2224
2234
|
}
|
|
2225
2235
|
}
|
|
2226
2236
|
|
|
2227
|
-
/** Filter that matches on key fields not present within an array. */ class
|
|
2228
|
-
constructor(t,
|
|
2229
|
-
super(t, "not-in" /* NOT_IN */ ,
|
|
2237
|
+
/** Filter that matches on key fields not present within an array. */ class Zt extends Kt {
|
|
2238
|
+
constructor(t, e) {
|
|
2239
|
+
super(t, "not-in" /* NOT_IN */ , e), this.keys = te("not-in" /* NOT_IN */ , e);
|
|
2230
2240
|
}
|
|
2231
2241
|
matches(t) {
|
|
2232
|
-
return !this.keys.some((
|
|
2242
|
+
return !this.keys.some((e => e.isEqual(t.key)));
|
|
2233
2243
|
}
|
|
2234
2244
|
}
|
|
2235
2245
|
|
|
2236
|
-
function
|
|
2237
|
-
var
|
|
2238
|
-
return ((null === (
|
|
2246
|
+
function te(t, e) {
|
|
2247
|
+
var n;
|
|
2248
|
+
return ((null === (n = e.arrayValue) || void 0 === n ? void 0 : n.values) || []).map((t => nt.fromName(t.referenceValue)));
|
|
2239
2249
|
}
|
|
2240
2250
|
|
|
2241
|
-
/** A Filter that implements the array-contains operator. */ class
|
|
2242
|
-
constructor(t,
|
|
2243
|
-
super(t, "array-contains" /* ARRAY_CONTAINS */ ,
|
|
2251
|
+
/** A Filter that implements the array-contains operator. */ class ee extends Kt {
|
|
2252
|
+
constructor(t, e) {
|
|
2253
|
+
super(t, "array-contains" /* ARRAY_CONTAINS */ , e);
|
|
2244
2254
|
}
|
|
2245
2255
|
matches(t) {
|
|
2246
|
-
const
|
|
2247
|
-
return
|
|
2256
|
+
const e = t.data.field(this.field);
|
|
2257
|
+
return jt(e) && Ct(e.arrayValue, this.value);
|
|
2248
2258
|
}
|
|
2249
2259
|
}
|
|
2250
2260
|
|
|
2251
|
-
/** A Filter that implements the IN operator. */ class
|
|
2252
|
-
constructor(t,
|
|
2253
|
-
super(t, "in" /* IN */ ,
|
|
2261
|
+
/** A Filter that implements the IN operator. */ class ne extends Kt {
|
|
2262
|
+
constructor(t, e) {
|
|
2263
|
+
super(t, "in" /* IN */ , e);
|
|
2254
2264
|
}
|
|
2255
2265
|
matches(t) {
|
|
2256
|
-
const
|
|
2257
|
-
return null !==
|
|
2266
|
+
const e = t.data.field(this.field);
|
|
2267
|
+
return null !== e && Ct(this.value.arrayValue, e);
|
|
2258
2268
|
}
|
|
2259
2269
|
}
|
|
2260
2270
|
|
|
2261
|
-
/** A Filter that implements the not-in operator. */ class
|
|
2262
|
-
constructor(t,
|
|
2263
|
-
super(t, "not-in" /* NOT_IN */ ,
|
|
2271
|
+
/** A Filter that implements the not-in operator. */ class re extends Kt {
|
|
2272
|
+
constructor(t, e) {
|
|
2273
|
+
super(t, "not-in" /* NOT_IN */ , e);
|
|
2264
2274
|
}
|
|
2265
2275
|
matches(t) {
|
|
2266
|
-
if (
|
|
2276
|
+
if (Ct(this.value.arrayValue, {
|
|
2267
2277
|
nullValue: "NULL_VALUE"
|
|
2268
2278
|
})) return !1;
|
|
2269
|
-
const
|
|
2270
|
-
return null !==
|
|
2279
|
+
const e = t.data.field(this.field);
|
|
2280
|
+
return null !== e && !Ct(this.value.arrayValue, e);
|
|
2271
2281
|
}
|
|
2272
2282
|
}
|
|
2273
2283
|
|
|
2274
|
-
/** A Filter that implements the array-contains-any operator. */ class
|
|
2275
|
-
constructor(t,
|
|
2276
|
-
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ ,
|
|
2284
|
+
/** A Filter that implements the array-contains-any operator. */ class se extends Kt {
|
|
2285
|
+
constructor(t, e) {
|
|
2286
|
+
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ , e);
|
|
2277
2287
|
}
|
|
2278
2288
|
matches(t) {
|
|
2279
|
-
const
|
|
2280
|
-
return !(!
|
|
2289
|
+
const e = t.data.field(this.field);
|
|
2290
|
+
return !(!jt(e) || !e.arrayValue.values) && e.arrayValue.values.some((t => Ct(this.value.arrayValue, t)));
|
|
2281
2291
|
}
|
|
2282
2292
|
}
|
|
2283
2293
|
|
|
@@ -2294,30 +2304,30 @@ function Zt(t, n) {
|
|
|
2294
2304
|
* Bound provides a function to determine whether a document comes before or
|
|
2295
2305
|
* after a bound. This is influenced by whether the position is just before or
|
|
2296
2306
|
* just after the provided values.
|
|
2297
|
-
*/ class
|
|
2298
|
-
constructor(t,
|
|
2299
|
-
this.position = t, this.inclusive =
|
|
2307
|
+
*/ class ie {
|
|
2308
|
+
constructor(t, e) {
|
|
2309
|
+
this.position = t, this.inclusive = e;
|
|
2300
2310
|
}
|
|
2301
2311
|
}
|
|
2302
2312
|
|
|
2303
2313
|
/**
|
|
2304
2314
|
* An ordering on a field, in some Direction. Direction defaults to ASCENDING.
|
|
2305
|
-
*/ class
|
|
2306
|
-
constructor(t,
|
|
2307
|
-
this.field = t, this.dir =
|
|
2315
|
+
*/ class oe {
|
|
2316
|
+
constructor(t, e = "asc" /* ASCENDING */) {
|
|
2317
|
+
this.field = t, this.dir = e;
|
|
2308
2318
|
}
|
|
2309
2319
|
}
|
|
2310
2320
|
|
|
2311
|
-
function
|
|
2312
|
-
return t.dir ===
|
|
2321
|
+
function ue(t, e) {
|
|
2322
|
+
return t.dir === e.dir && t.field.isEqual(e.field);
|
|
2313
2323
|
}
|
|
2314
2324
|
|
|
2315
|
-
function
|
|
2316
|
-
if (null === t) return null ===
|
|
2317
|
-
if (null ===
|
|
2318
|
-
if (t.inclusive !==
|
|
2319
|
-
for (let
|
|
2320
|
-
if (!
|
|
2325
|
+
function ce(t, e) {
|
|
2326
|
+
if (null === t) return null === e;
|
|
2327
|
+
if (null === e) return !1;
|
|
2328
|
+
if (t.inclusive !== e.inclusive || t.position.length !== e.position.length) return !1;
|
|
2329
|
+
for (let n = 0; n < t.position.length; n++) {
|
|
2330
|
+
if (!Ot(t.position[n], e.position[n])) return !1;
|
|
2321
2331
|
}
|
|
2322
2332
|
return !0;
|
|
2323
2333
|
}
|
|
@@ -2344,25 +2354,25 @@ function cn(t, n) {
|
|
|
2344
2354
|
* query the RemoteStore results.
|
|
2345
2355
|
*
|
|
2346
2356
|
* Visible for testing.
|
|
2347
|
-
*/ class
|
|
2357
|
+
*/ class ae {
|
|
2348
2358
|
/**
|
|
2349
2359
|
* Initializes a Query with a path and optional additional query constraints.
|
|
2350
2360
|
* Path must currently be empty if this is a collection group query.
|
|
2351
2361
|
*/
|
|
2352
|
-
constructor(t,
|
|
2353
|
-
this.path = t, this.collectionGroup =
|
|
2362
|
+
constructor(t, e = null, n = [], r = [], s = null, i = "F" /* First */ , o = null, u = null) {
|
|
2363
|
+
this.path = t, this.collectionGroup = e, this.explicitOrderBy = n, this.filters = r,
|
|
2354
2364
|
this.limit = s, this.limitType = i, this.startAt = o, this.endAt = u, this.$ = null,
|
|
2355
2365
|
// The corresponding `Target` of this `Query` instance.
|
|
2356
2366
|
this.S = null, this.startAt, this.endAt;
|
|
2357
2367
|
}
|
|
2358
2368
|
}
|
|
2359
2369
|
|
|
2360
|
-
/** Creates a new Query for a query that matches all documents at `path` */ function
|
|
2370
|
+
/** Creates a new Query for a query that matches all documents at `path` */ function he(t) {
|
|
2361
2371
|
return t.explicitOrderBy.length > 0 ? t.explicitOrderBy[0].field : null;
|
|
2362
2372
|
}
|
|
2363
2373
|
|
|
2364
|
-
function
|
|
2365
|
-
for (const
|
|
2374
|
+
function le(t) {
|
|
2375
|
+
for (const e of t.filters) if (e.D()) return e.field;
|
|
2366
2376
|
return null;
|
|
2367
2377
|
}
|
|
2368
2378
|
|
|
@@ -2374,7 +2384,7 @@ function ln(t) {
|
|
|
2374
2384
|
* Returns whether the query matches a collection group rather than a specific
|
|
2375
2385
|
* collection.
|
|
2376
2386
|
*/
|
|
2377
|
-
function
|
|
2387
|
+
function fe(t) {
|
|
2378
2388
|
return null !== t.collectionGroup;
|
|
2379
2389
|
}
|
|
2380
2390
|
|
|
@@ -2382,59 +2392,59 @@ function fn(t) {
|
|
|
2382
2392
|
* Returns the implicit order by constraint that is used to execute the Query,
|
|
2383
2393
|
* which can be different from the order by constraints the user provided (e.g.
|
|
2384
2394
|
* the SDK and backend always orders by `__name__`).
|
|
2385
|
-
*/ function
|
|
2386
|
-
const
|
|
2387
|
-
if (null ===
|
|
2388
|
-
|
|
2389
|
-
const t =
|
|
2390
|
-
if (null !== t && null ===
|
|
2395
|
+
*/ function de(t) {
|
|
2396
|
+
const e = E(t);
|
|
2397
|
+
if (null === e.$) {
|
|
2398
|
+
e.$ = [];
|
|
2399
|
+
const t = le(e), n = he(e);
|
|
2400
|
+
if (null !== t && null === n)
|
|
2391
2401
|
// In order to implicitly add key ordering, we must also add the
|
|
2392
2402
|
// inequality filter field for it to be a valid query.
|
|
2393
2403
|
// Note that the default inequality field and key ordering is ascending.
|
|
2394
|
-
t.isKeyField() ||
|
|
2404
|
+
t.isKeyField() || e.$.push(new oe(t)), e.$.push(new oe(et.keyField(), "asc" /* ASCENDING */)); else {
|
|
2395
2405
|
let t = !1;
|
|
2396
|
-
for (const
|
|
2406
|
+
for (const n of e.explicitOrderBy) e.$.push(n), n.field.isKeyField() && (t = !0);
|
|
2397
2407
|
if (!t) {
|
|
2398
2408
|
// The order of the implicit key ordering always matches the last
|
|
2399
2409
|
// explicit order by
|
|
2400
|
-
const t =
|
|
2401
|
-
|
|
2410
|
+
const t = e.explicitOrderBy.length > 0 ? e.explicitOrderBy[e.explicitOrderBy.length - 1].dir : "asc" /* ASCENDING */;
|
|
2411
|
+
e.$.push(new oe(et.keyField(), t));
|
|
2402
2412
|
}
|
|
2403
2413
|
}
|
|
2404
2414
|
}
|
|
2405
|
-
return
|
|
2415
|
+
return e.$;
|
|
2406
2416
|
}
|
|
2407
2417
|
|
|
2408
2418
|
/**
|
|
2409
2419
|
* Converts this `Query` instance to it's corresponding `Target` representation.
|
|
2410
|
-
*/ function
|
|
2411
|
-
const
|
|
2412
|
-
if (!
|
|
2420
|
+
*/ function we(t) {
|
|
2421
|
+
const e = E(t);
|
|
2422
|
+
if (!e.S) if ("F" /* First */ === e.limitType) e.S = Ht(e.path, e.collectionGroup, de(e), e.filters, e.limit, e.startAt, e.endAt); else {
|
|
2413
2423
|
// Flip the orderBy directions since we want the last results
|
|
2414
2424
|
const t = [];
|
|
2415
|
-
for (const
|
|
2416
|
-
const
|
|
2417
|
-
t.push(new
|
|
2425
|
+
for (const n of de(e)) {
|
|
2426
|
+
const e = "desc" /* DESCENDING */ === n.dir ? "asc" /* ASCENDING */ : "desc" /* DESCENDING */;
|
|
2427
|
+
t.push(new oe(n.field, e));
|
|
2418
2428
|
}
|
|
2419
2429
|
// We need to swap the cursors to match the now-flipped query ordering.
|
|
2420
|
-
const
|
|
2430
|
+
const n = e.endAt ? new ie(e.endAt.position, e.endAt.inclusive) : null, r = e.startAt ? new ie(e.startAt.position, e.startAt.inclusive) : null;
|
|
2421
2431
|
// Now return as a LimitType.First query.
|
|
2422
|
-
|
|
2432
|
+
e.S = Ht(e.path, e.collectionGroup, t, e.filters, e.limit, n, r);
|
|
2423
2433
|
}
|
|
2424
|
-
return
|
|
2434
|
+
return e.S;
|
|
2425
2435
|
}
|
|
2426
2436
|
|
|
2427
|
-
function
|
|
2428
|
-
return function(t,
|
|
2429
|
-
if (t.limit !==
|
|
2430
|
-
if (t.orderBy.length !==
|
|
2431
|
-
for (let
|
|
2432
|
-
if (t.filters.length !==
|
|
2433
|
-
for (let s = 0; s < t.filters.length; s++) if (
|
|
2434
|
-
|
|
2435
|
-
var
|
|
2436
|
-
return t.collectionGroup ===
|
|
2437
|
-
}(
|
|
2437
|
+
function me(t, e) {
|
|
2438
|
+
return function(t, e) {
|
|
2439
|
+
if (t.limit !== e.limit) return !1;
|
|
2440
|
+
if (t.orderBy.length !== e.orderBy.length) return !1;
|
|
2441
|
+
for (let n = 0; n < t.orderBy.length; n++) if (!ue(t.orderBy[n], e.orderBy[n])) return !1;
|
|
2442
|
+
if (t.filters.length !== e.filters.length) return !1;
|
|
2443
|
+
for (let s = 0; s < t.filters.length; s++) if (n = t.filters[s], r = e.filters[s],
|
|
2444
|
+
n.op !== r.op || !n.field.isEqual(r.field) || !Ot(n.value, r.value)) return !1;
|
|
2445
|
+
var n, r;
|
|
2446
|
+
return t.collectionGroup === e.collectionGroup && !!t.path.isEqual(e.path) && !!ce(t.startAt, e.startAt) && ce(t.endAt, e.endAt);
|
|
2447
|
+
}(we(t), we(e)) && t.limitType === e.limitType;
|
|
2438
2448
|
}
|
|
2439
2449
|
|
|
2440
2450
|
/**
|
|
@@ -2462,10 +2472,10 @@ function mn(t, n) {
|
|
|
2462
2472
|
* The return value is an IntegerValue if it can safely represent the value,
|
|
2463
2473
|
* otherwise a DoubleValue is returned.
|
|
2464
2474
|
*/
|
|
2465
|
-
function
|
|
2475
|
+
function pe(t, e) {
|
|
2466
2476
|
return function(t) {
|
|
2467
2477
|
return "number" == typeof t && Number.isInteger(t) && !ht(t) && t <= Number.MAX_SAFE_INTEGER && t >= Number.MIN_SAFE_INTEGER;
|
|
2468
|
-
}(
|
|
2478
|
+
}(e) ?
|
|
2469
2479
|
/**
|
|
2470
2480
|
* Returns an IntegerValue for `value`.
|
|
2471
2481
|
*/
|
|
@@ -2473,22 +2483,22 @@ function pn(t, n) {
|
|
|
2473
2483
|
return {
|
|
2474
2484
|
integerValue: "" + t
|
|
2475
2485
|
};
|
|
2476
|
-
}(
|
|
2486
|
+
}(e) : function(t, e) {
|
|
2477
2487
|
if (t.F) {
|
|
2478
|
-
if (isNaN(
|
|
2488
|
+
if (isNaN(e)) return {
|
|
2479
2489
|
doubleValue: "NaN"
|
|
2480
2490
|
};
|
|
2481
|
-
if (
|
|
2491
|
+
if (e === 1 / 0) return {
|
|
2482
2492
|
doubleValue: "Infinity"
|
|
2483
2493
|
};
|
|
2484
|
-
if (
|
|
2494
|
+
if (e === -1 / 0) return {
|
|
2485
2495
|
doubleValue: "-Infinity"
|
|
2486
2496
|
};
|
|
2487
2497
|
}
|
|
2488
2498
|
return {
|
|
2489
|
-
doubleValue: ht(
|
|
2499
|
+
doubleValue: ht(e) ? "-0" : e
|
|
2490
2500
|
};
|
|
2491
|
-
}(t,
|
|
2501
|
+
}(t, e);
|
|
2492
2502
|
}
|
|
2493
2503
|
|
|
2494
2504
|
/**
|
|
@@ -2507,7 +2517,7 @@ function pn(t, n) {
|
|
|
2507
2517
|
* See the License for the specific language governing permissions and
|
|
2508
2518
|
* limitations under the License.
|
|
2509
2519
|
*/
|
|
2510
|
-
/** Used to represent a field transform on a mutation. */ class
|
|
2520
|
+
/** Used to represent a field transform on a mutation. */ class ye {
|
|
2511
2521
|
constructor() {
|
|
2512
2522
|
// Make sure that the structural type of `TransformOperation` is unique.
|
|
2513
2523
|
// See https://github.com/microsoft/TypeScript/issues/5451
|
|
@@ -2515,15 +2525,15 @@ function pn(t, n) {
|
|
|
2515
2525
|
}
|
|
2516
2526
|
}
|
|
2517
2527
|
|
|
2518
|
-
/** Transforms a value into a server-generated timestamp. */ class
|
|
2528
|
+
/** Transforms a value into a server-generated timestamp. */ class _e extends ye {}
|
|
2519
2529
|
|
|
2520
|
-
/** Transforms an array value via a union operation. */ class
|
|
2530
|
+
/** Transforms an array value via a union operation. */ class ge extends ye {
|
|
2521
2531
|
constructor(t) {
|
|
2522
2532
|
super(), this.elements = t;
|
|
2523
2533
|
}
|
|
2524
2534
|
}
|
|
2525
2535
|
|
|
2526
|
-
/** Transforms an array value via a remove operation. */ class
|
|
2536
|
+
/** Transforms an array value via a remove operation. */ class be extends ye {
|
|
2527
2537
|
constructor(t) {
|
|
2528
2538
|
super(), this.elements = t;
|
|
2529
2539
|
}
|
|
@@ -2534,9 +2544,9 @@ function pn(t, n) {
|
|
|
2534
2544
|
* transforms. Converts all field values to integers or doubles, but unlike the
|
|
2535
2545
|
* backend does not cap integer values at 2^63. Instead, JavaScript number
|
|
2536
2546
|
* arithmetic is used and precision loss can occur for values greater than 2^53.
|
|
2537
|
-
*/ class
|
|
2538
|
-
constructor(t,
|
|
2539
|
-
super(), this.q = t, this.O =
|
|
2547
|
+
*/ class ve extends ye {
|
|
2548
|
+
constructor(t, e) {
|
|
2549
|
+
super(), this.q = t, this.O = e;
|
|
2540
2550
|
}
|
|
2541
2551
|
}
|
|
2542
2552
|
|
|
@@ -2556,9 +2566,9 @@ function pn(t, n) {
|
|
|
2556
2566
|
* See the License for the specific language governing permissions and
|
|
2557
2567
|
* limitations under the License.
|
|
2558
2568
|
*/
|
|
2559
|
-
/** A field path and the TransformOperation to perform upon it. */ class
|
|
2560
|
-
constructor(t,
|
|
2561
|
-
this.field = t, this.transform =
|
|
2569
|
+
/** A field path and the TransformOperation to perform upon it. */ class Ee {
|
|
2570
|
+
constructor(t, e) {
|
|
2571
|
+
this.field = t, this.transform = e;
|
|
2562
2572
|
}
|
|
2563
2573
|
}
|
|
2564
2574
|
|
|
@@ -2566,18 +2576,18 @@ function pn(t, n) {
|
|
|
2566
2576
|
* Encodes a precondition for a mutation. This follows the model that the
|
|
2567
2577
|
* backend accepts with the special case of an explicit "empty" precondition
|
|
2568
2578
|
* (meaning no precondition).
|
|
2569
|
-
*/ class
|
|
2570
|
-
constructor(t,
|
|
2571
|
-
this.updateTime = t, this.exists =
|
|
2579
|
+
*/ class Te {
|
|
2580
|
+
constructor(t, e) {
|
|
2581
|
+
this.updateTime = t, this.exists = e;
|
|
2572
2582
|
}
|
|
2573
2583
|
/** Creates a new empty Precondition. */ static none() {
|
|
2574
|
-
return new
|
|
2584
|
+
return new Te;
|
|
2575
2585
|
}
|
|
2576
2586
|
/** Creates a new Precondition with an exists flag. */ static exists(t) {
|
|
2577
|
-
return new
|
|
2587
|
+
return new Te(void 0, t);
|
|
2578
2588
|
}
|
|
2579
2589
|
/** Creates a new Precondition based on a version a document exists at. */ static updateTime(t) {
|
|
2580
|
-
return new
|
|
2590
|
+
return new Te(t);
|
|
2581
2591
|
}
|
|
2582
2592
|
/** Returns whether this Precondition is empty. */ get isNone() {
|
|
2583
2593
|
return void 0 === this.updateTime && void 0 === this.exists;
|
|
@@ -2630,14 +2640,14 @@ function pn(t, n) {
|
|
|
2630
2640
|
* applyToLocalView() to implement the actual behavior of applying the mutation
|
|
2631
2641
|
* to some source document (see `setMutationApplyToRemoteDocument()` for an
|
|
2632
2642
|
* example).
|
|
2633
|
-
*/ class
|
|
2643
|
+
*/ class Ie {}
|
|
2634
2644
|
|
|
2635
2645
|
/**
|
|
2636
2646
|
* A mutation that creates or replaces the document at the given key with the
|
|
2637
2647
|
* object value contents.
|
|
2638
|
-
*/ class
|
|
2639
|
-
constructor(t,
|
|
2640
|
-
super(), this.key = t, this.value =
|
|
2648
|
+
*/ class Ae extends Ie {
|
|
2649
|
+
constructor(t, e, n, r = []) {
|
|
2650
|
+
super(), this.key = t, this.value = e, this.precondition = n, this.fieldTransforms = r,
|
|
2641
2651
|
this.type = 0 /* Set */;
|
|
2642
2652
|
}
|
|
2643
2653
|
}
|
|
@@ -2654,16 +2664,16 @@ function pn(t, n) {
|
|
|
2654
2664
|
* is deleted.
|
|
2655
2665
|
* * When a field is not in the mask but is in the values, the values map is
|
|
2656
2666
|
* ignored.
|
|
2657
|
-
*/ class
|
|
2658
|
-
constructor(t,
|
|
2659
|
-
super(), this.key = t, this.data =
|
|
2667
|
+
*/ class Re extends Ie {
|
|
2668
|
+
constructor(t, e, n, r, s = []) {
|
|
2669
|
+
super(), this.key = t, this.data = e, this.fieldMask = n, this.precondition = r,
|
|
2660
2670
|
this.fieldTransforms = s, this.type = 1 /* Patch */;
|
|
2661
2671
|
}
|
|
2662
2672
|
}
|
|
2663
2673
|
|
|
2664
|
-
/** A mutation that deletes the document at the given key. */ class
|
|
2665
|
-
constructor(t,
|
|
2666
|
-
super(), this.key = t, this.precondition =
|
|
2674
|
+
/** A mutation that deletes the document at the given key. */ class Pe extends Ie {
|
|
2675
|
+
constructor(t, e) {
|
|
2676
|
+
super(), this.key = t, this.precondition = e, this.type = 2 /* Delete */ , this.fieldTransforms = [];
|
|
2667
2677
|
}
|
|
2668
2678
|
}
|
|
2669
2679
|
|
|
@@ -2673,9 +2683,9 @@ function pn(t, n) {
|
|
|
2673
2683
|
*
|
|
2674
2684
|
* The `verify` operation is only used in Transactions, and this class serves
|
|
2675
2685
|
* primarily to facilitate serialization into protos.
|
|
2676
|
-
*/ class
|
|
2677
|
-
constructor(t,
|
|
2678
|
-
super(), this.key = t, this.precondition =
|
|
2686
|
+
*/ class Ve extends Ie {
|
|
2687
|
+
constructor(t, e) {
|
|
2688
|
+
super(), this.key = t, this.precondition = e, this.type = 3 /* Verify */ , this.fieldTransforms = [];
|
|
2679
2689
|
}
|
|
2680
2690
|
}
|
|
2681
2691
|
|
|
@@ -2694,13 +2704,13 @@ function pn(t, n) {
|
|
|
2694
2704
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2695
2705
|
* See the License for the specific language governing permissions and
|
|
2696
2706
|
* limitations under the License.
|
|
2697
|
-
*/ const
|
|
2707
|
+
*/ const Ne = (() => {
|
|
2698
2708
|
const t = {
|
|
2699
2709
|
asc: "ASCENDING",
|
|
2700
2710
|
desc: "DESCENDING"
|
|
2701
2711
|
};
|
|
2702
2712
|
return t;
|
|
2703
|
-
})(),
|
|
2713
|
+
})(), De = (() => {
|
|
2704
2714
|
const t = {
|
|
2705
2715
|
"<": "LESS_THAN",
|
|
2706
2716
|
"<=": "LESS_THAN_OR_EQUAL",
|
|
@@ -2730,9 +2740,9 @@ function pn(t, n) {
|
|
|
2730
2740
|
* TODO(klimt): We can remove the databaseId argument if we keep the full
|
|
2731
2741
|
* resource name in documents.
|
|
2732
2742
|
*/
|
|
2733
|
-
class $
|
|
2734
|
-
constructor(t,
|
|
2735
|
-
this.databaseId = t, this.F =
|
|
2743
|
+
class $e {
|
|
2744
|
+
constructor(t, e) {
|
|
2745
|
+
this.databaseId = t, this.F = e;
|
|
2736
2746
|
}
|
|
2737
2747
|
}
|
|
2738
2748
|
|
|
@@ -2747,13 +2757,13 @@ class $n {
|
|
|
2747
2757
|
/**
|
|
2748
2758
|
* Returns a value for a Date that's appropriate to put into a proto.
|
|
2749
2759
|
*/
|
|
2750
|
-
function
|
|
2760
|
+
function Se(t, e) {
|
|
2751
2761
|
if (t.F) {
|
|
2752
|
-
return `${new Date(1e3 *
|
|
2762
|
+
return `${new Date(1e3 * e.seconds).toISOString().replace(/\.\d*/, "").replace("Z", "")}.${("000000000" + e.nanoseconds).slice(-9)}Z`;
|
|
2753
2763
|
}
|
|
2754
2764
|
return {
|
|
2755
|
-
seconds: "" +
|
|
2756
|
-
nanos:
|
|
2765
|
+
seconds: "" + e.seconds,
|
|
2766
|
+
nanos: e.nanoseconds
|
|
2757
2767
|
};
|
|
2758
2768
|
}
|
|
2759
2769
|
|
|
@@ -2762,234 +2772,234 @@ function Sn(t, n) {
|
|
|
2762
2772
|
*
|
|
2763
2773
|
* Visible for testing.
|
|
2764
2774
|
*/
|
|
2765
|
-
function
|
|
2766
|
-
return t.F ?
|
|
2775
|
+
function Fe(t, e) {
|
|
2776
|
+
return t.F ? e.toBase64() : e.toUint8Array();
|
|
2767
2777
|
}
|
|
2768
2778
|
|
|
2769
|
-
function
|
|
2770
|
-
return
|
|
2779
|
+
function xe(t, e) {
|
|
2780
|
+
return Se(t, e.toTimestamp());
|
|
2771
2781
|
}
|
|
2772
2782
|
|
|
2773
|
-
function
|
|
2774
|
-
return
|
|
2775
|
-
const
|
|
2776
|
-
return new
|
|
2783
|
+
function qe(t) {
|
|
2784
|
+
return v(!!t), vt.fromTimestamp(function(t) {
|
|
2785
|
+
const e = Vt(t);
|
|
2786
|
+
return new bt(e.seconds, e.nanos);
|
|
2777
2787
|
}(t));
|
|
2778
2788
|
}
|
|
2779
2789
|
|
|
2780
|
-
function
|
|
2790
|
+
function Oe(t, e) {
|
|
2781
2791
|
return function(t) {
|
|
2782
2792
|
return new Z([ "projects", t.projectId, "databases", t.database ]);
|
|
2783
|
-
}(t).child("documents").child(
|
|
2793
|
+
}(t).child("documents").child(e).canonicalString();
|
|
2784
2794
|
}
|
|
2785
2795
|
|
|
2786
|
-
function
|
|
2787
|
-
return
|
|
2796
|
+
function Ce(t, e) {
|
|
2797
|
+
return Oe(t.databaseId, e.path);
|
|
2788
2798
|
}
|
|
2789
2799
|
|
|
2790
|
-
function
|
|
2791
|
-
const
|
|
2792
|
-
const
|
|
2793
|
-
return
|
|
2794
|
-
}(
|
|
2795
|
-
if (
|
|
2796
|
-
if (
|
|
2797
|
-
return new
|
|
2800
|
+
function Le(t, e) {
|
|
2801
|
+
const n = function(t) {
|
|
2802
|
+
const e = Z.fromString(t);
|
|
2803
|
+
return v(He(e)), e;
|
|
2804
|
+
}(e);
|
|
2805
|
+
if (n.get(1) !== t.databaseId.projectId) throw new U(R, "Tried to deserialize key from different project: " + n.get(1) + " vs " + t.databaseId.projectId);
|
|
2806
|
+
if (n.get(3) !== t.databaseId.database) throw new U(R, "Tried to deserialize key from different database: " + n.get(3) + " vs " + t.databaseId.database);
|
|
2807
|
+
return new nt((v((r = n).length > 4 && "documents" === r.get(4)), r.popFirst(5)));
|
|
2798
2808
|
var r;
|
|
2799
2809
|
/** Creates a Document proto from key and fields (but no create/update time) */}
|
|
2800
2810
|
|
|
2801
|
-
function
|
|
2802
|
-
return
|
|
2811
|
+
function ke(t, e) {
|
|
2812
|
+
return Oe(t.databaseId, e);
|
|
2803
2813
|
}
|
|
2804
2814
|
|
|
2805
|
-
function
|
|
2815
|
+
function Ue(t) {
|
|
2806
2816
|
return new Z([ "projects", t.databaseId.projectId, "databases", t.databaseId.database ]).canonicalString();
|
|
2807
2817
|
}
|
|
2808
2818
|
|
|
2809
|
-
function
|
|
2819
|
+
function je(t, e, n) {
|
|
2810
2820
|
return {
|
|
2811
|
-
name:
|
|
2812
|
-
fields:
|
|
2821
|
+
name: Ce(t, e),
|
|
2822
|
+
fields: n.value.mapValue.fields
|
|
2813
2823
|
};
|
|
2814
2824
|
}
|
|
2815
2825
|
|
|
2816
|
-
function
|
|
2817
|
-
return "found" in
|
|
2818
|
-
|
|
2819
|
-
const
|
|
2826
|
+
function Me(t, e) {
|
|
2827
|
+
return "found" in e ? function(t, e) {
|
|
2828
|
+
v(!!e.found), e.found.name, e.found.updateTime;
|
|
2829
|
+
const n = Le(t, e.found.name), r = qe(e.found.updateTime), s = new Qt({
|
|
2820
2830
|
mapValue: {
|
|
2821
|
-
fields:
|
|
2831
|
+
fields: e.found.fields
|
|
2822
2832
|
}
|
|
2823
2833
|
});
|
|
2824
|
-
return
|
|
2825
|
-
}(t,
|
|
2826
|
-
|
|
2827
|
-
const
|
|
2828
|
-
return
|
|
2829
|
-
}(t,
|
|
2830
|
-
}
|
|
2831
|
-
|
|
2832
|
-
function
|
|
2833
|
-
let
|
|
2834
|
-
if (
|
|
2835
|
-
update:
|
|
2836
|
-
}; else if (
|
|
2837
|
-
delete:
|
|
2838
|
-
}; else if (
|
|
2839
|
-
update:
|
|
2840
|
-
updateMask:
|
|
2834
|
+
return Wt.newFoundDocument(n, r, s);
|
|
2835
|
+
}(t, e) : "missing" in e ? function(t, e) {
|
|
2836
|
+
v(!!e.missing), v(!!e.readTime);
|
|
2837
|
+
const n = Le(t, e.missing), r = qe(e.readTime);
|
|
2838
|
+
return Wt.newNoDocument(n, r);
|
|
2839
|
+
}(t, e) : b();
|
|
2840
|
+
}
|
|
2841
|
+
|
|
2842
|
+
function Be(t, e) {
|
|
2843
|
+
let n;
|
|
2844
|
+
if (e instanceof Ae) n = {
|
|
2845
|
+
update: je(t, e.key, e.value)
|
|
2846
|
+
}; else if (e instanceof Pe) n = {
|
|
2847
|
+
delete: Ce(t, e.key)
|
|
2848
|
+
}; else if (e instanceof Re) n = {
|
|
2849
|
+
update: je(t, e.key, e.data),
|
|
2850
|
+
updateMask: Ye(e.fieldMask)
|
|
2841
2851
|
}; else {
|
|
2842
|
-
if (!(
|
|
2843
|
-
|
|
2844
|
-
verify:
|
|
2852
|
+
if (!(e instanceof Ve)) return b();
|
|
2853
|
+
n = {
|
|
2854
|
+
verify: Ce(t, e.key)
|
|
2845
2855
|
};
|
|
2846
2856
|
}
|
|
2847
|
-
return
|
|
2848
|
-
const
|
|
2849
|
-
if (
|
|
2850
|
-
fieldPath:
|
|
2857
|
+
return e.fieldTransforms.length > 0 && (n.updateTransforms = e.fieldTransforms.map((t => function(t, e) {
|
|
2858
|
+
const n = e.transform;
|
|
2859
|
+
if (n instanceof _e) return {
|
|
2860
|
+
fieldPath: e.field.canonicalString(),
|
|
2851
2861
|
setToServerValue: "REQUEST_TIME"
|
|
2852
2862
|
};
|
|
2853
|
-
if (
|
|
2854
|
-
fieldPath:
|
|
2863
|
+
if (n instanceof ge) return {
|
|
2864
|
+
fieldPath: e.field.canonicalString(),
|
|
2855
2865
|
appendMissingElements: {
|
|
2856
|
-
values:
|
|
2866
|
+
values: n.elements
|
|
2857
2867
|
}
|
|
2858
2868
|
};
|
|
2859
|
-
if (
|
|
2860
|
-
fieldPath:
|
|
2869
|
+
if (n instanceof be) return {
|
|
2870
|
+
fieldPath: e.field.canonicalString(),
|
|
2861
2871
|
removeAllFromArray: {
|
|
2862
|
-
values:
|
|
2872
|
+
values: n.elements
|
|
2863
2873
|
}
|
|
2864
2874
|
};
|
|
2865
|
-
if (
|
|
2866
|
-
fieldPath:
|
|
2867
|
-
increment:
|
|
2875
|
+
if (n instanceof ve) return {
|
|
2876
|
+
fieldPath: e.field.canonicalString(),
|
|
2877
|
+
increment: n.O
|
|
2868
2878
|
};
|
|
2869
|
-
throw
|
|
2870
|
-
}(0, t)))),
|
|
2871
|
-
return void 0 !==
|
|
2872
|
-
updateTime:
|
|
2873
|
-
} : void 0 !==
|
|
2874
|
-
exists:
|
|
2875
|
-
} :
|
|
2876
|
-
}(t,
|
|
2879
|
+
throw b();
|
|
2880
|
+
}(0, t)))), e.precondition.isNone || (n.currentDocument = function(t, e) {
|
|
2881
|
+
return void 0 !== e.updateTime ? {
|
|
2882
|
+
updateTime: xe(t, e.updateTime)
|
|
2883
|
+
} : void 0 !== e.exists ? {
|
|
2884
|
+
exists: e.exists
|
|
2885
|
+
} : b();
|
|
2886
|
+
}(t, e.precondition)), n;
|
|
2877
2887
|
}
|
|
2878
2888
|
|
|
2879
|
-
function
|
|
2889
|
+
function ze(t, e) {
|
|
2880
2890
|
// Dissect the path into parent, collectionId, and optional key filter.
|
|
2881
|
-
const
|
|
2891
|
+
const n = {
|
|
2882
2892
|
structuredQuery: {}
|
|
2883
|
-
}, r =
|
|
2884
|
-
null !==
|
|
2885
|
-
collectionId:
|
|
2893
|
+
}, r = e.path;
|
|
2894
|
+
null !== e.collectionGroup ? (n.parent = ke(t, r), n.structuredQuery.from = [ {
|
|
2895
|
+
collectionId: e.collectionGroup,
|
|
2886
2896
|
allDescendants: !0
|
|
2887
|
-
} ]) : (
|
|
2897
|
+
} ]) : (n.parent = ke(t, r.popLast()), n.structuredQuery.from = [ {
|
|
2888
2898
|
collectionId: r.lastSegment()
|
|
2889
2899
|
} ]);
|
|
2890
2900
|
const s = function(t) {
|
|
2891
2901
|
if (0 === t.length) return;
|
|
2892
|
-
const
|
|
2902
|
+
const e = t.map((t =>
|
|
2893
2903
|
// visible for testing
|
|
2894
2904
|
function(t) {
|
|
2895
2905
|
if ("==" /* EQUAL */ === t.op) {
|
|
2896
|
-
if (
|
|
2906
|
+
if (Bt(t.value)) return {
|
|
2897
2907
|
unaryFilter: {
|
|
2898
|
-
field:
|
|
2908
|
+
field: We(t.field),
|
|
2899
2909
|
op: "IS_NAN"
|
|
2900
2910
|
}
|
|
2901
2911
|
};
|
|
2902
|
-
if (
|
|
2912
|
+
if (Mt(t.value)) return {
|
|
2903
2913
|
unaryFilter: {
|
|
2904
|
-
field:
|
|
2914
|
+
field: We(t.field),
|
|
2905
2915
|
op: "IS_NULL"
|
|
2906
2916
|
}
|
|
2907
2917
|
};
|
|
2908
2918
|
} else if ("!=" /* NOT_EQUAL */ === t.op) {
|
|
2909
|
-
if (
|
|
2919
|
+
if (Bt(t.value)) return {
|
|
2910
2920
|
unaryFilter: {
|
|
2911
|
-
field:
|
|
2921
|
+
field: We(t.field),
|
|
2912
2922
|
op: "IS_NOT_NAN"
|
|
2913
2923
|
}
|
|
2914
2924
|
};
|
|
2915
|
-
if (
|
|
2925
|
+
if (Mt(t.value)) return {
|
|
2916
2926
|
unaryFilter: {
|
|
2917
|
-
field:
|
|
2927
|
+
field: We(t.field),
|
|
2918
2928
|
op: "IS_NOT_NULL"
|
|
2919
2929
|
}
|
|
2920
2930
|
};
|
|
2921
2931
|
}
|
|
2922
2932
|
return {
|
|
2923
2933
|
fieldFilter: {
|
|
2924
|
-
field:
|
|
2925
|
-
op:
|
|
2934
|
+
field: We(t.field),
|
|
2935
|
+
op: Qe(t.op),
|
|
2926
2936
|
value: t.value
|
|
2927
2937
|
}
|
|
2928
2938
|
};
|
|
2929
2939
|
}(t)));
|
|
2930
|
-
if (1 ===
|
|
2940
|
+
if (1 === e.length) return e[0];
|
|
2931
2941
|
return {
|
|
2932
2942
|
compositeFilter: {
|
|
2933
2943
|
op: "AND",
|
|
2934
|
-
filters:
|
|
2944
|
+
filters: e
|
|
2935
2945
|
}
|
|
2936
2946
|
};
|
|
2937
|
-
}(
|
|
2938
|
-
s && (
|
|
2947
|
+
}(e.filters);
|
|
2948
|
+
s && (n.structuredQuery.where = s);
|
|
2939
2949
|
const i = function(t) {
|
|
2940
2950
|
if (0 === t.length) return;
|
|
2941
2951
|
return t.map((t =>
|
|
2942
2952
|
// visible for testing
|
|
2943
2953
|
function(t) {
|
|
2944
2954
|
return {
|
|
2945
|
-
field:
|
|
2946
|
-
direction:
|
|
2955
|
+
field: We(t.field),
|
|
2956
|
+
direction: Ge(t.dir)
|
|
2947
2957
|
};
|
|
2948
2958
|
}(t)));
|
|
2949
|
-
}(
|
|
2950
|
-
i && (
|
|
2951
|
-
const o = function(t,
|
|
2952
|
-
return t.F || at(
|
|
2953
|
-
value:
|
|
2959
|
+
}(e.orderBy);
|
|
2960
|
+
i && (n.structuredQuery.orderBy = i);
|
|
2961
|
+
const o = function(t, e) {
|
|
2962
|
+
return t.F || at(e) ? e : {
|
|
2963
|
+
value: e
|
|
2954
2964
|
};
|
|
2955
|
-
}(t,
|
|
2965
|
+
}(t, e.limit);
|
|
2956
2966
|
var u;
|
|
2957
|
-
return null !== o && (
|
|
2958
|
-
before: (u =
|
|
2967
|
+
return null !== o && (n.structuredQuery.limit = o), e.startAt && (n.structuredQuery.startAt = {
|
|
2968
|
+
before: (u = e.startAt).inclusive,
|
|
2959
2969
|
values: u.position
|
|
2960
|
-
}),
|
|
2970
|
+
}), e.endAt && (n.structuredQuery.endAt = function(t) {
|
|
2961
2971
|
return {
|
|
2962
2972
|
before: !t.inclusive,
|
|
2963
2973
|
values: t.position
|
|
2964
2974
|
};
|
|
2965
2975
|
}
|
|
2966
2976
|
// visible for testing
|
|
2967
|
-
(
|
|
2977
|
+
(e.endAt)), n;
|
|
2968
2978
|
}
|
|
2969
2979
|
|
|
2970
|
-
function
|
|
2971
|
-
return
|
|
2980
|
+
function Ge(t) {
|
|
2981
|
+
return Ne[t];
|
|
2972
2982
|
}
|
|
2973
2983
|
|
|
2974
2984
|
// visible for testing
|
|
2975
|
-
function
|
|
2976
|
-
return
|
|
2985
|
+
function Qe(t) {
|
|
2986
|
+
return De[t];
|
|
2977
2987
|
}
|
|
2978
2988
|
|
|
2979
|
-
function
|
|
2989
|
+
function We(t) {
|
|
2980
2990
|
return {
|
|
2981
2991
|
fieldPath: t.canonicalString()
|
|
2982
2992
|
};
|
|
2983
2993
|
}
|
|
2984
2994
|
|
|
2985
|
-
function
|
|
2986
|
-
const
|
|
2987
|
-
return t.fields.forEach((t =>
|
|
2988
|
-
fieldPaths:
|
|
2995
|
+
function Ye(t) {
|
|
2996
|
+
const e = [];
|
|
2997
|
+
return t.fields.forEach((t => e.push(t.canonicalString()))), {
|
|
2998
|
+
fieldPaths: e
|
|
2989
2999
|
};
|
|
2990
3000
|
}
|
|
2991
3001
|
|
|
2992
|
-
function
|
|
3002
|
+
function He(t) {
|
|
2993
3003
|
// Resource names have at least 4 components (project ID, database ID)
|
|
2994
3004
|
return t.length >= 4 && "projects" === t.get(0) && "databases" === t.get(2);
|
|
2995
3005
|
}
|
|
@@ -3009,8 +3019,8 @@ function Hn(t) {
|
|
|
3009
3019
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3010
3020
|
* See the License for the specific language governing permissions and
|
|
3011
3021
|
* limitations under the License.
|
|
3012
|
-
*/ function
|
|
3013
|
-
return new $
|
|
3022
|
+
*/ function Ke(t) {
|
|
3023
|
+
return new $e(t, /* useProto3Json= */ !0);
|
|
3014
3024
|
}
|
|
3015
3025
|
|
|
3016
3026
|
/**
|
|
@@ -3038,7 +3048,7 @@ function Hn(t) {
|
|
|
3038
3048
|
* base delay. This prevents clients from accidentally synchronizing their
|
|
3039
3049
|
* delays causing spikes of load to the backend.
|
|
3040
3050
|
*/
|
|
3041
|
-
class
|
|
3051
|
+
class Je {
|
|
3042
3052
|
constructor(
|
|
3043
3053
|
/**
|
|
3044
3054
|
* The AsyncQueue to run backoff operations on.
|
|
@@ -3047,13 +3057,13 @@ class Jn {
|
|
|
3047
3057
|
/**
|
|
3048
3058
|
* The ID to use when scheduling backoff operations on the AsyncQueue.
|
|
3049
3059
|
*/
|
|
3050
|
-
|
|
3060
|
+
e,
|
|
3051
3061
|
/**
|
|
3052
3062
|
* The initial delay (used as the base delay on the first retry attempt).
|
|
3053
3063
|
* Note that jitter will still be applied, so the actual delay could be as
|
|
3054
3064
|
* little as 0.5*initialDelayMs.
|
|
3055
3065
|
*/
|
|
3056
|
-
|
|
3066
|
+
n = 1e3
|
|
3057
3067
|
/**
|
|
3058
3068
|
* The multiplier to use to determine the extended base delay after each
|
|
3059
3069
|
* attempt.
|
|
@@ -3063,7 +3073,7 @@ class Jn {
|
|
|
3063
3073
|
* Note that jitter will still be applied, so the actual delay could be as
|
|
3064
3074
|
* much as 1.5*maxDelayMs.
|
|
3065
3075
|
*/ , s = 6e4) {
|
|
3066
|
-
this.C = t, this.timerId =
|
|
3076
|
+
this.C = t, this.timerId = e, this.L = n, this.k = r, this.U = s, this.j = 0, this.M = null,
|
|
3067
3077
|
/** The last backoff attempt, as epoch milliseconds. */
|
|
3068
3078
|
this.B = Date.now(), this.reset();
|
|
3069
3079
|
}
|
|
@@ -3091,9 +3101,9 @@ class Jn {
|
|
|
3091
3101
|
this.cancel();
|
|
3092
3102
|
// First schedule using the current base (which may be 0 and should be
|
|
3093
3103
|
// honored as such).
|
|
3094
|
-
const
|
|
3104
|
+
const e = Math.floor(this.j + this.Y()), n = Math.max(0, Date.now() - this.B), r = Math.max(0, e - n);
|
|
3095
3105
|
// Guard against lastAttemptTime being in the future due to a clock change.
|
|
3096
|
-
r > 0 && p("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.j} ms, delay with jitter: ${
|
|
3106
|
+
r > 0 && p("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.j} ms, delay with jitter: ${e} ms, last attempt: ${n} ms ago)`),
|
|
3097
3107
|
this.M = this.C.enqueueAfterDelay(this.timerId, r, (() => (this.B = Date.now(),
|
|
3098
3108
|
t()))),
|
|
3099
3109
|
// Apply backoff factor to determine next delay and ensure it is within
|
|
@@ -3136,22 +3146,22 @@ class Jn {
|
|
|
3136
3146
|
* An implementation of Datastore that exposes additional state for internal
|
|
3137
3147
|
* consumption.
|
|
3138
3148
|
*/
|
|
3139
|
-
class
|
|
3140
|
-
constructor(t,
|
|
3141
|
-
super(), this.authCredentials = t, this.appCheckCredentials =
|
|
3149
|
+
class Xe extends class {} {
|
|
3150
|
+
constructor(t, e, n, r) {
|
|
3151
|
+
super(), this.authCredentials = t, this.appCheckCredentials = e, this.K = n, this.q = r,
|
|
3142
3152
|
this.J = !1;
|
|
3143
3153
|
}
|
|
3144
3154
|
X() {
|
|
3145
3155
|
if (this.J) throw new U(F, "The client has already been terminated.");
|
|
3146
3156
|
}
|
|
3147
|
-
/** Invokes the provided RPC with auth and AppCheck tokens. */ m(t,
|
|
3148
|
-
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.m(t,
|
|
3157
|
+
/** Invokes the provided RPC with auth and AppCheck tokens. */ m(t, e, n) {
|
|
3158
|
+
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.m(t, e, n, r, s))).catch((t => {
|
|
3149
3159
|
throw "FirebaseError" === t.name ? (t.code === $ && (this.authCredentials.invalidateToken(),
|
|
3150
3160
|
this.appCheckCredentials.invalidateToken()), t) : new U(A, t.toString());
|
|
3151
3161
|
}));
|
|
3152
3162
|
}
|
|
3153
|
-
/** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */ T(t,
|
|
3154
|
-
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.T(t,
|
|
3163
|
+
/** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */ T(t, e, n) {
|
|
3164
|
+
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.T(t, e, n, r, s))).catch((t => {
|
|
3155
3165
|
throw "FirebaseError" === t.name ? (t.code === $ && (this.authCredentials.invalidateToken(),
|
|
3156
3166
|
this.appCheckCredentials.invalidateToken()), t) : new U(A, t.toString());
|
|
3157
3167
|
}));
|
|
@@ -3163,40 +3173,40 @@ class Xn extends class {} {
|
|
|
3163
3173
|
|
|
3164
3174
|
// TODO(firestorexp): Make sure there is only one Datastore instance per
|
|
3165
3175
|
// firestore-exp client.
|
|
3166
|
-
async function
|
|
3167
|
-
const
|
|
3168
|
-
writes:
|
|
3176
|
+
async function Ze(t, e) {
|
|
3177
|
+
const n = E(t), r = Ue(n.q) + "/documents", s = {
|
|
3178
|
+
writes: e.map((t => Be(n.q, t)))
|
|
3169
3179
|
};
|
|
3170
|
-
await
|
|
3180
|
+
await n.m("Commit", r, s);
|
|
3171
3181
|
}
|
|
3172
3182
|
|
|
3173
|
-
async function
|
|
3174
|
-
const
|
|
3175
|
-
documents:
|
|
3176
|
-
}, i = await
|
|
3183
|
+
async function tn(t, e) {
|
|
3184
|
+
const n = E(t), r = Ue(n.q) + "/documents", s = {
|
|
3185
|
+
documents: e.map((t => Ce(n.q, t)))
|
|
3186
|
+
}, i = await n.T("BatchGetDocuments", r, s), o = new Map;
|
|
3177
3187
|
i.forEach((t => {
|
|
3178
|
-
const
|
|
3179
|
-
o.set(
|
|
3188
|
+
const e = Me(n.q, t);
|
|
3189
|
+
o.set(e.key.toString(), e);
|
|
3180
3190
|
}));
|
|
3181
3191
|
const u = [];
|
|
3182
|
-
return
|
|
3183
|
-
const
|
|
3184
|
-
|
|
3192
|
+
return e.forEach((t => {
|
|
3193
|
+
const e = o.get(t.toString());
|
|
3194
|
+
v(!!e), u.push(e);
|
|
3185
3195
|
})), u;
|
|
3186
3196
|
}
|
|
3187
3197
|
|
|
3188
|
-
async function
|
|
3189
|
-
const
|
|
3190
|
-
return (await
|
|
3198
|
+
async function en(t, e) {
|
|
3199
|
+
const n = E(t), r = ze(n.q, we(e));
|
|
3200
|
+
return (await n.T("RunQuery", r.parent, {
|
|
3191
3201
|
structuredQuery: r.structuredQuery
|
|
3192
|
-
})).filter((t => !!t.document)).map((t => function(t,
|
|
3193
|
-
const r =
|
|
3202
|
+
})).filter((t => !!t.document)).map((t => function(t, e, n) {
|
|
3203
|
+
const r = Le(t, e.name), s = qe(e.updateTime), i = new Qt({
|
|
3194
3204
|
mapValue: {
|
|
3195
|
-
fields:
|
|
3205
|
+
fields: e.fields
|
|
3196
3206
|
}
|
|
3197
|
-
}), o =
|
|
3198
|
-
return
|
|
3199
|
-
}(
|
|
3207
|
+
}), o = Wt.newFoundDocument(r, s, i);
|
|
3208
|
+
return n && o.setHasCommittedMutations(), n ? o.setHasCommittedMutations() : o;
|
|
3209
|
+
}(n.q, t.document, void 0)));
|
|
3200
3210
|
}
|
|
3201
3211
|
|
|
3202
3212
|
/**
|
|
@@ -3214,7 +3224,7 @@ async function ne(t, n) {
|
|
|
3214
3224
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3215
3225
|
* See the License for the specific language governing permissions and
|
|
3216
3226
|
* limitations under the License.
|
|
3217
|
-
*/ const
|
|
3227
|
+
*/ const nn = new Map;
|
|
3218
3228
|
|
|
3219
3229
|
/**
|
|
3220
3230
|
* An instance map that ensures only one Datastore exists per Firestore
|
|
@@ -3225,19 +3235,19 @@ async function ne(t, n) {
|
|
|
3225
3235
|
* instance. Callers must invoke removeComponents() when the Firestore
|
|
3226
3236
|
* instance is terminated.
|
|
3227
3237
|
*/
|
|
3228
|
-
function
|
|
3238
|
+
function rn(t) {
|
|
3229
3239
|
if (t._terminated) throw new U(F, "The client has already been terminated.");
|
|
3230
|
-
if (!
|
|
3240
|
+
if (!nn.has(t)) {
|
|
3231
3241
|
p("ComponentProvider", "Initializing Datastore");
|
|
3232
3242
|
const i = function(t) {
|
|
3233
3243
|
return new mt(t, fetch.bind(null));
|
|
3234
|
-
}((
|
|
3235
|
-
new K(
|
|
3236
|
-
return new
|
|
3244
|
+
}((e = t._databaseId, n = t.app.options.appId || "", r = t._persistenceKey, s = t._freezeSettings(),
|
|
3245
|
+
new K(e, n, r, s.host, s.ssl, s.experimentalForceLongPolling, s.experimentalAutoDetectLongPolling, s.useFetchStreams))), o = Ke(t._databaseId), u = function(t, e, n, r) {
|
|
3246
|
+
return new Xe(t, e, n, r);
|
|
3237
3247
|
}(t._authCredentials, t._appCheckCredentials, i, o);
|
|
3238
|
-
|
|
3248
|
+
nn.set(t, u);
|
|
3239
3249
|
}
|
|
3240
|
-
var
|
|
3250
|
+
var e, n, r, s;
|
|
3241
3251
|
/**
|
|
3242
3252
|
* @license
|
|
3243
3253
|
* Copyright 2018 Google LLC
|
|
@@ -3253,7 +3263,7 @@ function re(t) {
|
|
|
3253
3263
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3254
3264
|
* See the License for the specific language governing permissions and
|
|
3255
3265
|
* limitations under the License.
|
|
3256
|
-
*/ return
|
|
3266
|
+
*/ return nn.get(t);
|
|
3257
3267
|
}
|
|
3258
3268
|
|
|
3259
3269
|
/**
|
|
@@ -3265,21 +3275,21 @@ function re(t) {
|
|
|
3265
3275
|
* user-supplied `FirestoreSettings` object. This is a separate type so that
|
|
3266
3276
|
* defaults can be supplied and the value can be checked for equality.
|
|
3267
3277
|
*/
|
|
3268
|
-
class
|
|
3278
|
+
class sn {
|
|
3269
3279
|
constructor(t) {
|
|
3270
|
-
var
|
|
3280
|
+
var e;
|
|
3271
3281
|
if (void 0 === t.host) {
|
|
3272
3282
|
if (void 0 !== t.ssl) throw new U(R, "Can't provide ssl option if host option is not set");
|
|
3273
3283
|
this.host = "firestore.googleapis.com", this.ssl = true;
|
|
3274
|
-
} else this.host = t.host, this.ssl = null === (
|
|
3284
|
+
} else this.host = t.host, this.ssl = null === (e = t.ssl) || void 0 === e || e;
|
|
3275
3285
|
if (this.credentials = t.credentials, this.ignoreUndefinedProperties = !!t.ignoreUndefinedProperties,
|
|
3276
3286
|
void 0 === t.cacheSizeBytes) this.cacheSizeBytes = 41943040; else {
|
|
3277
3287
|
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new U(R, "cacheSizeBytes must be at least 1048576");
|
|
3278
3288
|
this.cacheSizeBytes = t.cacheSizeBytes;
|
|
3279
3289
|
}
|
|
3280
3290
|
this.experimentalForceLongPolling = !!t.experimentalForceLongPolling, this.experimentalAutoDetectLongPolling = !!t.experimentalAutoDetectLongPolling,
|
|
3281
|
-
this.useFetchStreams = !!t.useFetchStreams, function(t,
|
|
3282
|
-
if (!0 ===
|
|
3291
|
+
this.useFetchStreams = !!t.useFetchStreams, function(t, e, n, r) {
|
|
3292
|
+
if (!0 === e && !0 === r) throw new U(R, `${t} and ${n} cannot be used together.`);
|
|
3283
3293
|
}("experimentalForceLongPolling", t.experimentalForceLongPolling, "experimentalAutoDetectLongPolling", t.experimentalAutoDetectLongPolling);
|
|
3284
3294
|
}
|
|
3285
3295
|
isEqual(t) {
|
|
@@ -3307,14 +3317,14 @@ class se {
|
|
|
3307
3317
|
* The Cloud Firestore service interface.
|
|
3308
3318
|
*
|
|
3309
3319
|
* Do not call this constructor directly. Instead, use {@link getFirestore}.
|
|
3310
|
-
*/ class
|
|
3320
|
+
*/ class on {
|
|
3311
3321
|
/** @hideconstructor */
|
|
3312
|
-
constructor(t,
|
|
3313
|
-
this._authCredentials =
|
|
3322
|
+
constructor(t, e, n) {
|
|
3323
|
+
this._authCredentials = e, this._appCheckCredentials = n,
|
|
3314
3324
|
/**
|
|
3315
3325
|
* Whether it's a Firestore or Firestore Lite instance.
|
|
3316
3326
|
*/
|
|
3317
|
-
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new
|
|
3327
|
+
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new sn({}),
|
|
3318
3328
|
this._settingsFrozen = !1, t instanceof J ? this._databaseId = t : (this._app = t,
|
|
3319
3329
|
this._databaseId = function(t) {
|
|
3320
3330
|
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new U(R, '"projectId" not provided in firebase.initializeApp.');
|
|
@@ -3347,14 +3357,14 @@ class se {
|
|
|
3347
3357
|
}
|
|
3348
3358
|
_setSettings(t) {
|
|
3349
3359
|
if (this._settingsFrozen) throw new U(F, "Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");
|
|
3350
|
-
this._settings = new
|
|
3360
|
+
this._settings = new sn(t), void 0 !== t.credentials && (this._authCredentials = function(t) {
|
|
3351
3361
|
if (!t) return new B;
|
|
3352
3362
|
switch (t.type) {
|
|
3353
3363
|
case "gapi":
|
|
3354
|
-
const
|
|
3364
|
+
const e = t.client;
|
|
3355
3365
|
// Make sure this really is a Gapi client.
|
|
3356
|
-
return
|
|
3357
|
-
new W(
|
|
3366
|
+
return v(!("object" != typeof e || null === e || !e.auth || !e.auth.getAuthHeaderValueForFirstParty)),
|
|
3367
|
+
new W(e, t.sessionIndex || "0", t.iamToken || null);
|
|
3358
3368
|
|
|
3359
3369
|
case "provider":
|
|
3360
3370
|
return t.client;
|
|
@@ -3388,17 +3398,17 @@ class se {
|
|
|
3388
3398
|
* Only ever called once.
|
|
3389
3399
|
*/ _terminate() {
|
|
3390
3400
|
return function(t) {
|
|
3391
|
-
const
|
|
3392
|
-
|
|
3401
|
+
const e = nn.get(t);
|
|
3402
|
+
e && (p("ComponentProvider", "Removing Datastore"), nn.delete(t), e.terminate());
|
|
3393
3403
|
}(this), Promise.resolve();
|
|
3394
3404
|
}
|
|
3395
3405
|
}
|
|
3396
3406
|
|
|
3397
|
-
function
|
|
3398
|
-
const
|
|
3399
|
-
if (
|
|
3400
|
-
return
|
|
3401
|
-
options:
|
|
3407
|
+
function un(t, e) {
|
|
3408
|
+
const n = _getProvider(t, "firestore/lite");
|
|
3409
|
+
if (n.isInitialized()) throw new U(F, "Firestore can only be initialized once per app.");
|
|
3410
|
+
return n.initialize({
|
|
3411
|
+
options: e
|
|
3402
3412
|
});
|
|
3403
3413
|
}
|
|
3404
3414
|
|
|
@@ -3410,8 +3420,8 @@ function oe(t, n) {
|
|
|
3410
3420
|
* @param app - The {@link @firebase/app#FirebaseApp} instance that the returned `Firestore`
|
|
3411
3421
|
* instance is associated with.
|
|
3412
3422
|
* @returns The `Firestore` instance of the provided app.
|
|
3413
|
-
*/ function
|
|
3414
|
-
return _getProvider(
|
|
3423
|
+
*/ function cn(e = t()) {
|
|
3424
|
+
return _getProvider(e, "firestore/lite").getImmediate();
|
|
3415
3425
|
}
|
|
3416
3426
|
|
|
3417
3427
|
/**
|
|
@@ -3426,24 +3436,24 @@ function oe(t, n) {
|
|
|
3426
3436
|
* @param port - the emulator port (ex: 9000).
|
|
3427
3437
|
* @param options.mockUserToken - the mock auth token to use for unit testing
|
|
3428
3438
|
* Security Rules.
|
|
3429
|
-
*/ function
|
|
3439
|
+
*/ function an(t, e, n, r = {}) {
|
|
3430
3440
|
var s;
|
|
3431
|
-
const i = (t = ut(t,
|
|
3432
|
-
if ("firestore.googleapis.com" !== i.host && i.host !==
|
|
3441
|
+
const i = (t = ut(t, on))._getSettings();
|
|
3442
|
+
if ("firestore.googleapis.com" !== i.host && i.host !== e && _("Host has been set in both settings() and useEmulator(), emulator host will be used"),
|
|
3433
3443
|
t._setSettings(Object.assign(Object.assign({}, i), {
|
|
3434
|
-
host: `${
|
|
3444
|
+
host: `${e}:${n}`,
|
|
3435
3445
|
ssl: !1
|
|
3436
3446
|
})), r.mockUserToken) {
|
|
3437
|
-
let
|
|
3438
|
-
if ("string" == typeof r.mockUserToken)
|
|
3447
|
+
let e, n;
|
|
3448
|
+
if ("string" == typeof r.mockUserToken) e = r.mockUserToken, n = f.MOCK_USER; else {
|
|
3439
3449
|
// Let createMockUserToken validate first (catches common mistakes like
|
|
3440
3450
|
// invalid field "uid" and missing field "sub" / "user_id".)
|
|
3441
|
-
|
|
3451
|
+
e = h(r.mockUserToken, null === (s = t._app) || void 0 === s ? void 0 : s.options.projectId);
|
|
3442
3452
|
const i = r.mockUserToken.sub || r.mockUserToken.user_id;
|
|
3443
3453
|
if (!i) throw new U(R, "mockUserToken must contain 'sub' or 'user_id' field!");
|
|
3444
|
-
|
|
3454
|
+
n = new f(i);
|
|
3445
3455
|
}
|
|
3446
|
-
t._authCredentials = new z(new M(
|
|
3456
|
+
t._authCredentials = new z(new M(e, n));
|
|
3447
3457
|
}
|
|
3448
3458
|
}
|
|
3449
3459
|
|
|
@@ -3466,8 +3476,8 @@ function oe(t, n) {
|
|
|
3466
3476
|
* @param firestore - The `Firestore` instance to terminate.
|
|
3467
3477
|
* @returns A `Promise` that is resolved when the instance has been successfully
|
|
3468
3478
|
* terminated.
|
|
3469
|
-
*/ function
|
|
3470
|
-
return t = ut(t,
|
|
3479
|
+
*/ function hn(t) {
|
|
3480
|
+
return t = ut(t, on), e(t.app, "firestore/lite"), t._delete();
|
|
3471
3481
|
}
|
|
3472
3482
|
|
|
3473
3483
|
/**
|
|
@@ -3507,14 +3517,14 @@ function oe(t, n) {
|
|
|
3507
3517
|
* and can be used to write, read, or listen to the location. The document at
|
|
3508
3518
|
* the referenced location may or may not exist.
|
|
3509
3519
|
*/
|
|
3510
|
-
class
|
|
3520
|
+
class ln {
|
|
3511
3521
|
/** @hideconstructor */
|
|
3512
3522
|
constructor(t,
|
|
3513
3523
|
/**
|
|
3514
3524
|
* If provided, the `FirestoreDataConverter` associated with this instance.
|
|
3515
3525
|
*/
|
|
3516
|
-
|
|
3517
|
-
this.converter =
|
|
3526
|
+
e, n) {
|
|
3527
|
+
this.converter = e, this._key = n,
|
|
3518
3528
|
/** The type of this Firestore reference. */
|
|
3519
3529
|
this.type = "document", this.firestore = t;
|
|
3520
3530
|
}
|
|
@@ -3535,40 +3545,40 @@ class he {
|
|
|
3535
3545
|
/**
|
|
3536
3546
|
* The collection this `DocumentReference` belongs to.
|
|
3537
3547
|
*/ get parent() {
|
|
3538
|
-
return new
|
|
3548
|
+
return new dn(this.firestore, this.converter, this._key.path.popLast());
|
|
3539
3549
|
}
|
|
3540
3550
|
withConverter(t) {
|
|
3541
|
-
return new
|
|
3551
|
+
return new ln(this.firestore, t, this._key);
|
|
3542
3552
|
}
|
|
3543
3553
|
}
|
|
3544
3554
|
|
|
3545
3555
|
/**
|
|
3546
3556
|
* A `Query` refers to a query which you can read or listen to. You can also
|
|
3547
3557
|
* construct refined `Query` objects by adding filters and ordering.
|
|
3548
|
-
*/ class
|
|
3558
|
+
*/ class fn {
|
|
3549
3559
|
// This is the lite version of the Query class in the main SDK.
|
|
3550
3560
|
/** @hideconstructor protected */
|
|
3551
3561
|
constructor(t,
|
|
3552
3562
|
/**
|
|
3553
3563
|
* If provided, the `FirestoreDataConverter` associated with this instance.
|
|
3554
3564
|
*/
|
|
3555
|
-
|
|
3556
|
-
this.converter =
|
|
3565
|
+
e, n) {
|
|
3566
|
+
this.converter = e, this._query = n,
|
|
3557
3567
|
/** The type of this Firestore reference. */
|
|
3558
3568
|
this.type = "query", this.firestore = t;
|
|
3559
3569
|
}
|
|
3560
3570
|
withConverter(t) {
|
|
3561
|
-
return new
|
|
3571
|
+
return new fn(this.firestore, t, this._query);
|
|
3562
3572
|
}
|
|
3563
3573
|
}
|
|
3564
3574
|
|
|
3565
3575
|
/**
|
|
3566
3576
|
* A `CollectionReference` object can be used for adding documents, getting
|
|
3567
3577
|
* document references, and querying for documents (using {@link query}).
|
|
3568
|
-
*/ class
|
|
3578
|
+
*/ class dn extends fn {
|
|
3569
3579
|
/** @hideconstructor */
|
|
3570
|
-
constructor(t,
|
|
3571
|
-
super(t,
|
|
3580
|
+
constructor(t, e, n) {
|
|
3581
|
+
super(t, e, new ae(n)), this._path = n,
|
|
3572
3582
|
/** The type of this Firestore reference. */
|
|
3573
3583
|
this.type = "collection";
|
|
3574
3584
|
}
|
|
@@ -3586,23 +3596,23 @@ class he {
|
|
|
3586
3596
|
* subcollection. If this isn't a subcollection, the reference is null.
|
|
3587
3597
|
*/ get parent() {
|
|
3588
3598
|
const t = this._path.popLast();
|
|
3589
|
-
return t.isEmpty() ? null : new
|
|
3590
|
-
/* converter= */ null, new
|
|
3599
|
+
return t.isEmpty() ? null : new ln(this.firestore,
|
|
3600
|
+
/* converter= */ null, new nt(t));
|
|
3591
3601
|
}
|
|
3592
3602
|
withConverter(t) {
|
|
3593
|
-
return new
|
|
3603
|
+
return new dn(this.firestore, t, this._path);
|
|
3594
3604
|
}
|
|
3595
3605
|
}
|
|
3596
3606
|
|
|
3597
|
-
function
|
|
3598
|
-
if (t = l(t), rt("collection", "path",
|
|
3599
|
-
const r = Z.fromString(
|
|
3600
|
-
return it(r), new
|
|
3607
|
+
function wn(t, e, ...n) {
|
|
3608
|
+
if (t = l(t), rt("collection", "path", e), t instanceof on) {
|
|
3609
|
+
const r = Z.fromString(e, ...n);
|
|
3610
|
+
return it(r), new dn(t, /* converter= */ null, r);
|
|
3601
3611
|
}
|
|
3602
3612
|
{
|
|
3603
|
-
if (!(t instanceof
|
|
3604
|
-
const r = t._path.child(Z.fromString(
|
|
3605
|
-
return it(r), new
|
|
3613
|
+
if (!(t instanceof ln || t instanceof dn)) throw new U(R, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3614
|
+
const r = t._path.child(Z.fromString(e, ...n));
|
|
3615
|
+
return it(r), new dn(t.firestore,
|
|
3606
3616
|
/* converter= */ null, r);
|
|
3607
3617
|
}
|
|
3608
3618
|
}
|
|
@@ -3619,32 +3629,32 @@ function de(t, n, ...e) {
|
|
|
3619
3629
|
* collection or subcollection with this ID as the last segment of its path
|
|
3620
3630
|
* will be included. Cannot contain a slash.
|
|
3621
3631
|
* @returns The created `Query`.
|
|
3622
|
-
*/ function
|
|
3623
|
-
if (t = ut(t,
|
|
3624
|
-
return new
|
|
3632
|
+
*/ function mn(t, e) {
|
|
3633
|
+
if (t = ut(t, on), rt("collectionGroup", "collection id", e), e.indexOf("/") >= 0) throw new U(R, `Invalid collection ID '${e}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);
|
|
3634
|
+
return new fn(t,
|
|
3625
3635
|
/* converter= */ null,
|
|
3626
3636
|
/**
|
|
3627
3637
|
* Creates a new Query for a collection group query that matches all documents
|
|
3628
3638
|
* within the provided collection group.
|
|
3629
3639
|
*/
|
|
3630
3640
|
function(t) {
|
|
3631
|
-
return new
|
|
3632
|
-
}(
|
|
3641
|
+
return new ae(Z.emptyPath(), t);
|
|
3642
|
+
}(e));
|
|
3633
3643
|
}
|
|
3634
3644
|
|
|
3635
|
-
function
|
|
3645
|
+
function pn(t, e, ...n) {
|
|
3636
3646
|
if (t = l(t),
|
|
3637
3647
|
// We allow omission of 'pathString' but explicitly prohibit passing in both
|
|
3638
3648
|
// 'undefined' and 'null'.
|
|
3639
|
-
1 === arguments.length && (
|
|
3640
|
-
const r = Z.fromString(
|
|
3641
|
-
return st(r), new
|
|
3642
|
-
/* converter= */ null, new
|
|
3649
|
+
1 === arguments.length && (e = yt.R()), rt("doc", "path", e), t instanceof on) {
|
|
3650
|
+
const r = Z.fromString(e, ...n);
|
|
3651
|
+
return st(r), new ln(t,
|
|
3652
|
+
/* converter= */ null, new nt(r));
|
|
3643
3653
|
}
|
|
3644
3654
|
{
|
|
3645
|
-
if (!(t instanceof
|
|
3646
|
-
const r = t._path.child(Z.fromString(
|
|
3647
|
-
return st(r), new
|
|
3655
|
+
if (!(t instanceof ln || t instanceof dn)) throw new U(R, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3656
|
+
const r = t._path.child(Z.fromString(e, ...n));
|
|
3657
|
+
return st(r), new ln(t.firestore, t instanceof dn ? t.converter : null, new nt(r));
|
|
3648
3658
|
}
|
|
3649
3659
|
}
|
|
3650
3660
|
|
|
@@ -3655,8 +3665,8 @@ function me(t, n, ...e) {
|
|
|
3655
3665
|
* @param right - A reference to compare.
|
|
3656
3666
|
* @returns true if the references point to the same location in the same
|
|
3657
3667
|
* Firestore database.
|
|
3658
|
-
*/ function
|
|
3659
|
-
return t = l(t),
|
|
3668
|
+
*/ function yn(t, e) {
|
|
3669
|
+
return t = l(t), e = l(e), (t instanceof ln || t instanceof dn) && (e instanceof ln || e instanceof dn) && (t.firestore === e.firestore && t.path === e.path && t.converter === e.converter);
|
|
3660
3670
|
}
|
|
3661
3671
|
|
|
3662
3672
|
/**
|
|
@@ -3667,8 +3677,8 @@ function me(t, n, ...e) {
|
|
|
3667
3677
|
* @param right - A `Query` to compare.
|
|
3668
3678
|
* @returns true if the references point to the same location in the same
|
|
3669
3679
|
* Firestore database.
|
|
3670
|
-
*/ function
|
|
3671
|
-
return t = l(t),
|
|
3680
|
+
*/ function _n(t, e) {
|
|
3681
|
+
return t = l(t), e = l(e), t instanceof fn && e instanceof fn && (t.firestore === e.firestore && me(t._query, e._query) && t.converter === e.converter);
|
|
3672
3682
|
}
|
|
3673
3683
|
|
|
3674
3684
|
/**
|
|
@@ -3694,7 +3704,7 @@ function me(t, n, ...e) {
|
|
|
3694
3704
|
*
|
|
3695
3705
|
* Create a `FieldPath` by providing field names. If more than one field
|
|
3696
3706
|
* name is provided, the path will point to a nested field in a document.
|
|
3697
|
-
*/ class
|
|
3707
|
+
*/ class gn {
|
|
3698
3708
|
/**
|
|
3699
3709
|
* Creates a `FieldPath` from the provided field names. If more than one field
|
|
3700
3710
|
* name is provided, the path will point to a nested field in a document.
|
|
@@ -3702,8 +3712,8 @@ function me(t, n, ...e) {
|
|
|
3702
3712
|
* @param fieldNames - A list of field names.
|
|
3703
3713
|
*/
|
|
3704
3714
|
constructor(...t) {
|
|
3705
|
-
for (let
|
|
3706
|
-
this._internalPath = new
|
|
3715
|
+
for (let e = 0; e < t.length; ++e) if (0 === t[e].length) throw new U(R, "Invalid field name at argument $(i + 1). Field names must not be empty.");
|
|
3716
|
+
this._internalPath = new et(t);
|
|
3707
3717
|
}
|
|
3708
3718
|
/**
|
|
3709
3719
|
* Returns true if this `FieldPath` is equal to the provided one.
|
|
@@ -3718,8 +3728,8 @@ function me(t, n, ...e) {
|
|
|
3718
3728
|
/**
|
|
3719
3729
|
* Returns a special sentinel `FieldPath` to refer to the ID of a document.
|
|
3720
3730
|
* It can be used in queries to sort or filter by the document ID.
|
|
3721
|
-
*/ function
|
|
3722
|
-
return new
|
|
3731
|
+
*/ function bn() {
|
|
3732
|
+
return new gn("__name__");
|
|
3723
3733
|
}
|
|
3724
3734
|
|
|
3725
3735
|
/**
|
|
@@ -3740,7 +3750,7 @@ function me(t, n, ...e) {
|
|
|
3740
3750
|
*/
|
|
3741
3751
|
/**
|
|
3742
3752
|
* An immutable object representing an array of bytes.
|
|
3743
|
-
*/ class
|
|
3753
|
+
*/ class vn {
|
|
3744
3754
|
/** @hideconstructor */
|
|
3745
3755
|
constructor(t) {
|
|
3746
3756
|
this._byteString = t;
|
|
@@ -3752,7 +3762,7 @@ function me(t, n, ...e) {
|
|
|
3752
3762
|
* @param base64 - The Base64 string used to create the `Bytes` object.
|
|
3753
3763
|
*/ static fromBase64String(t) {
|
|
3754
3764
|
try {
|
|
3755
|
-
return new
|
|
3765
|
+
return new vn(Rt.fromBase64String(t));
|
|
3756
3766
|
} catch (t) {
|
|
3757
3767
|
throw new U(R, "Failed to construct data from Base64 string: " + t);
|
|
3758
3768
|
}
|
|
@@ -3762,7 +3772,7 @@ function me(t, n, ...e) {
|
|
|
3762
3772
|
*
|
|
3763
3773
|
* @param array - The Uint8Array used to create the `Bytes` object.
|
|
3764
3774
|
*/ static fromUint8Array(t) {
|
|
3765
|
-
return new
|
|
3775
|
+
return new vn(Rt.fromUint8Array(t));
|
|
3766
3776
|
}
|
|
3767
3777
|
/**
|
|
3768
3778
|
* Returns the underlying bytes as a Base64-encoded string.
|
|
@@ -3814,7 +3824,7 @@ function me(t, n, ...e) {
|
|
|
3814
3824
|
/**
|
|
3815
3825
|
* Sentinel values that can be used when writing document fields with `set()`
|
|
3816
3826
|
* or `update()`.
|
|
3817
|
-
*/ class
|
|
3827
|
+
*/ class En {
|
|
3818
3828
|
/**
|
|
3819
3829
|
* @param _methodName - The public API endpoint that returns this class.
|
|
3820
3830
|
* @hideconstructor
|
|
@@ -3846,17 +3856,17 @@ function me(t, n, ...e) {
|
|
|
3846
3856
|
*
|
|
3847
3857
|
* Latitude values are in the range of [-90, 90].
|
|
3848
3858
|
* Longitude values are in the range of [-180, 180].
|
|
3849
|
-
*/ class
|
|
3859
|
+
*/ class Tn {
|
|
3850
3860
|
/**
|
|
3851
3861
|
* Creates a new immutable `GeoPoint` object with the provided latitude and
|
|
3852
3862
|
* longitude values.
|
|
3853
3863
|
* @param latitude - The latitude as number between -90 and 90.
|
|
3854
3864
|
* @param longitude - The longitude as number between -180 and 180.
|
|
3855
3865
|
*/
|
|
3856
|
-
constructor(t,
|
|
3866
|
+
constructor(t, e) {
|
|
3857
3867
|
if (!isFinite(t) || t < -90 || t > 90) throw new U(R, "Latitude must be a number between -90 and 90, but was: " + t);
|
|
3858
|
-
if (!isFinite(
|
|
3859
|
-
this._lat = t, this._long =
|
|
3868
|
+
if (!isFinite(e) || e < -180 || e > 180) throw new U(R, "Longitude must be a number between -180 and 180, but was: " + e);
|
|
3869
|
+
this._lat = t, this._long = e;
|
|
3860
3870
|
}
|
|
3861
3871
|
/**
|
|
3862
3872
|
* The latitude of this `GeoPoint` instance.
|
|
@@ -3905,29 +3915,29 @@ function me(t, n, ...e) {
|
|
|
3905
3915
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3906
3916
|
* See the License for the specific language governing permissions and
|
|
3907
3917
|
* limitations under the License.
|
|
3908
|
-
*/ const
|
|
3918
|
+
*/ const In = /^__.*__$/;
|
|
3909
3919
|
|
|
3910
|
-
/** The result of parsing document data (e.g. for a setData call). */ class
|
|
3911
|
-
constructor(t,
|
|
3912
|
-
this.data = t, this.fieldMask =
|
|
3920
|
+
/** The result of parsing document data (e.g. for a setData call). */ class An {
|
|
3921
|
+
constructor(t, e, n) {
|
|
3922
|
+
this.data = t, this.fieldMask = e, this.fieldTransforms = n;
|
|
3913
3923
|
}
|
|
3914
|
-
toMutation(t,
|
|
3915
|
-
return null !== this.fieldMask ? new
|
|
3924
|
+
toMutation(t, e) {
|
|
3925
|
+
return null !== this.fieldMask ? new Re(t, this.data, this.fieldMask, e, this.fieldTransforms) : new Ae(t, this.data, e, this.fieldTransforms);
|
|
3916
3926
|
}
|
|
3917
3927
|
}
|
|
3918
3928
|
|
|
3919
|
-
/** The result of parsing "update" data (i.e. for an updateData call). */ class
|
|
3929
|
+
/** The result of parsing "update" data (i.e. for an updateData call). */ class Rn {
|
|
3920
3930
|
constructor(t,
|
|
3921
3931
|
// The fieldMask does not include document transforms.
|
|
3922
|
-
|
|
3923
|
-
this.data = t, this.fieldMask =
|
|
3932
|
+
e, n) {
|
|
3933
|
+
this.data = t, this.fieldMask = e, this.fieldTransforms = n;
|
|
3924
3934
|
}
|
|
3925
|
-
toMutation(t,
|
|
3926
|
-
return new
|
|
3935
|
+
toMutation(t, e) {
|
|
3936
|
+
return new Re(t, this.data, this.fieldMask, e, this.fieldTransforms);
|
|
3927
3937
|
}
|
|
3928
3938
|
}
|
|
3929
3939
|
|
|
3930
|
-
function
|
|
3940
|
+
function Pn(t) {
|
|
3931
3941
|
switch (t) {
|
|
3932
3942
|
case 0 /* Set */ :
|
|
3933
3943
|
// fall through
|
|
@@ -3941,11 +3951,11 @@ function Re(t) {
|
|
|
3941
3951
|
return !1;
|
|
3942
3952
|
|
|
3943
3953
|
default:
|
|
3944
|
-
throw
|
|
3954
|
+
throw b();
|
|
3945
3955
|
}
|
|
3946
3956
|
}
|
|
3947
3957
|
|
|
3948
|
-
/** A "context" object passed around while parsing user data. */ class
|
|
3958
|
+
/** A "context" object passed around while parsing user data. */ class Vn {
|
|
3949
3959
|
/**
|
|
3950
3960
|
* Initializes a ParseContext with the given source and path.
|
|
3951
3961
|
*
|
|
@@ -3964,8 +3974,8 @@ function Re(t) {
|
|
|
3964
3974
|
* which case certain features will not work and errors will be somewhat
|
|
3965
3975
|
* compromised).
|
|
3966
3976
|
*/
|
|
3967
|
-
constructor(t,
|
|
3968
|
-
this.settings = t, this.databaseId =
|
|
3977
|
+
constructor(t, e, n, r, s, i) {
|
|
3978
|
+
this.settings = t, this.databaseId = e, this.q = n, this.ignoreUndefinedProperties = r,
|
|
3969
3979
|
// Minor hack: If fieldTransforms is undefined, we assume this is an
|
|
3970
3980
|
// external call and we need to validate the entire path.
|
|
3971
3981
|
void 0 === s && this.Z(), this.fieldTransforms = s || [], this.fieldMask = i || [];
|
|
@@ -3976,21 +3986,21 @@ function Re(t) {
|
|
|
3976
3986
|
get tt() {
|
|
3977
3987
|
return this.settings.tt;
|
|
3978
3988
|
}
|
|
3979
|
-
/** Returns a new context with the specified settings overwritten. */
|
|
3980
|
-
return new
|
|
3989
|
+
/** Returns a new context with the specified settings overwritten. */ et(t) {
|
|
3990
|
+
return new Vn(Object.assign(Object.assign({}, this.settings), t), this.databaseId, this.q, this.ignoreUndefinedProperties, this.fieldTransforms, this.fieldMask);
|
|
3981
3991
|
}
|
|
3982
|
-
|
|
3983
|
-
var
|
|
3984
|
-
const
|
|
3985
|
-
path:
|
|
3992
|
+
nt(t) {
|
|
3993
|
+
var e;
|
|
3994
|
+
const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), r = this.et({
|
|
3995
|
+
path: n,
|
|
3986
3996
|
rt: !1
|
|
3987
3997
|
});
|
|
3988
3998
|
return r.st(t), r;
|
|
3989
3999
|
}
|
|
3990
4000
|
it(t) {
|
|
3991
|
-
var
|
|
3992
|
-
const
|
|
3993
|
-
path:
|
|
4001
|
+
var e;
|
|
4002
|
+
const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), r = this.et({
|
|
4003
|
+
path: n,
|
|
3994
4004
|
rt: !1
|
|
3995
4005
|
});
|
|
3996
4006
|
return r.Z(), r;
|
|
@@ -3998,16 +4008,16 @@ function Re(t) {
|
|
|
3998
4008
|
ot(t) {
|
|
3999
4009
|
// TODO(b/34871131): We don't support array paths right now; so make path
|
|
4000
4010
|
// undefined.
|
|
4001
|
-
return this.
|
|
4011
|
+
return this.et({
|
|
4002
4012
|
path: void 0,
|
|
4003
4013
|
rt: !0
|
|
4004
4014
|
});
|
|
4005
4015
|
}
|
|
4006
4016
|
ut(t) {
|
|
4007
|
-
return
|
|
4017
|
+
return Yn(t, this.settings.methodName, this.settings.ct || !1, this.path, this.settings.at);
|
|
4008
4018
|
}
|
|
4009
4019
|
/** Returns 'true' if 'fieldPath' was traversed when creating this context. */ contains(t) {
|
|
4010
|
-
return void 0 !== this.fieldMask.find((
|
|
4020
|
+
return void 0 !== this.fieldMask.find((e => t.isPrefixOf(e))) || void 0 !== this.fieldTransforms.find((e => t.isPrefixOf(e.field)));
|
|
4011
4021
|
}
|
|
4012
4022
|
Z() {
|
|
4013
4023
|
// TODO(b/34871131): Remove null check once we have proper paths for fields
|
|
@@ -4016,52 +4026,52 @@ function Re(t) {
|
|
|
4016
4026
|
}
|
|
4017
4027
|
st(t) {
|
|
4018
4028
|
if (0 === t.length) throw this.ut("Document fields must not be empty");
|
|
4019
|
-
if (
|
|
4029
|
+
if (Pn(this.tt) && In.test(t)) throw this.ut('Document fields cannot begin and end with "__"');
|
|
4020
4030
|
}
|
|
4021
4031
|
}
|
|
4022
4032
|
|
|
4023
4033
|
/**
|
|
4024
4034
|
* Helper for parsing raw user input (provided via the API) into internal model
|
|
4025
4035
|
* classes.
|
|
4026
|
-
*/ class
|
|
4027
|
-
constructor(t,
|
|
4028
|
-
this.databaseId = t, this.ignoreUndefinedProperties =
|
|
4036
|
+
*/ class Nn {
|
|
4037
|
+
constructor(t, e, n) {
|
|
4038
|
+
this.databaseId = t, this.ignoreUndefinedProperties = e, this.q = n || Ke(t);
|
|
4029
4039
|
}
|
|
4030
|
-
/** Creates a new top-level parse context. */ ht(t,
|
|
4031
|
-
return new
|
|
4040
|
+
/** Creates a new top-level parse context. */ ht(t, e, n, r = !1) {
|
|
4041
|
+
return new Vn({
|
|
4032
4042
|
tt: t,
|
|
4033
|
-
methodName:
|
|
4034
|
-
at:
|
|
4035
|
-
path:
|
|
4043
|
+
methodName: e,
|
|
4044
|
+
at: n,
|
|
4045
|
+
path: et.emptyPath(),
|
|
4036
4046
|
rt: !1,
|
|
4037
4047
|
ct: r
|
|
4038
4048
|
}, this.databaseId, this.q, this.ignoreUndefinedProperties);
|
|
4039
4049
|
}
|
|
4040
4050
|
}
|
|
4041
4051
|
|
|
4042
|
-
function
|
|
4043
|
-
const
|
|
4044
|
-
return new
|
|
4052
|
+
function Dn(t) {
|
|
4053
|
+
const e = t._freezeSettings(), n = Ke(t._databaseId);
|
|
4054
|
+
return new Nn(t._databaseId, !!e.ignoreUndefinedProperties, n);
|
|
4045
4055
|
}
|
|
4046
4056
|
|
|
4047
|
-
/** Parse document data from a set() call. */ function
|
|
4048
|
-
const o = t.ht(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ ,
|
|
4049
|
-
|
|
4050
|
-
const u =
|
|
4057
|
+
/** Parse document data from a set() call. */ function $n(t, e, n, r, s, i = {}) {
|
|
4058
|
+
const o = t.ht(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ , e, n, s);
|
|
4059
|
+
zn("Data must be an object, but it was:", o, r);
|
|
4060
|
+
const u = Mn(r, o);
|
|
4051
4061
|
let c, a;
|
|
4052
4062
|
if (i.merge) c = new It(o.fieldMask), a = o.fieldTransforms; else if (i.mergeFields) {
|
|
4053
4063
|
const t = [];
|
|
4054
4064
|
for (const r of i.mergeFields) {
|
|
4055
|
-
const s =
|
|
4065
|
+
const s = Gn(e, r, n);
|
|
4056
4066
|
if (!o.contains(s)) throw new U(R, `Field '${s}' is specified in your field mask but missing from your input data.`);
|
|
4057
|
-
|
|
4067
|
+
Hn(t, s) || t.push(s);
|
|
4058
4068
|
}
|
|
4059
4069
|
c = new It(t), a = o.fieldTransforms.filter((t => c.covers(t.field)));
|
|
4060
4070
|
} else c = null, a = o.fieldTransforms;
|
|
4061
|
-
return new
|
|
4071
|
+
return new An(new Qt(u), c, a);
|
|
4062
4072
|
}
|
|
4063
4073
|
|
|
4064
|
-
class
|
|
4074
|
+
class Sn extends En {
|
|
4065
4075
|
_toFieldTransform(t) {
|
|
4066
4076
|
if (2 /* MergeSet */ !== t.tt) throw 1 /* Update */ === t.tt ? t.ut(`${this._methodName}() can only appear at the top level of your update data`) : t.ut(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);
|
|
4067
4077
|
// No transform to add for a delete, but we need to add it to our
|
|
@@ -4069,7 +4079,7 @@ class $e extends be {
|
|
|
4069
4079
|
return t.fieldMask.push(t.path), null;
|
|
4070
4080
|
}
|
|
4071
4081
|
isEqual(t) {
|
|
4072
|
-
return t instanceof
|
|
4082
|
+
return t instanceof Sn;
|
|
4073
4083
|
}
|
|
4074
4084
|
}
|
|
4075
4085
|
|
|
@@ -4088,32 +4098,32 @@ class $e extends be {
|
|
|
4088
4098
|
* context.
|
|
4089
4099
|
* @param context - The parent context.
|
|
4090
4100
|
* @param arrayElement - Whether or not the FieldValue has an array.
|
|
4091
|
-
*/ function
|
|
4092
|
-
return new
|
|
4101
|
+
*/ function Fn(t, e, n) {
|
|
4102
|
+
return new Vn({
|
|
4093
4103
|
tt: 3 /* Argument */ ,
|
|
4094
|
-
at:
|
|
4104
|
+
at: e.settings.at,
|
|
4095
4105
|
methodName: t._methodName,
|
|
4096
|
-
rt:
|
|
4097
|
-
},
|
|
4106
|
+
rt: n
|
|
4107
|
+
}, e.databaseId, e.q, e.ignoreUndefinedProperties);
|
|
4098
4108
|
}
|
|
4099
4109
|
|
|
4100
|
-
class
|
|
4110
|
+
class xn extends En {
|
|
4101
4111
|
_toFieldTransform(t) {
|
|
4102
|
-
return new
|
|
4112
|
+
return new Ee(t.path, new _e);
|
|
4103
4113
|
}
|
|
4104
4114
|
isEqual(t) {
|
|
4105
|
-
return t instanceof
|
|
4115
|
+
return t instanceof xn;
|
|
4106
4116
|
}
|
|
4107
4117
|
}
|
|
4108
4118
|
|
|
4109
|
-
class
|
|
4110
|
-
constructor(t,
|
|
4111
|
-
super(t), this.lt =
|
|
4119
|
+
class qn extends En {
|
|
4120
|
+
constructor(t, e) {
|
|
4121
|
+
super(t), this.lt = e;
|
|
4112
4122
|
}
|
|
4113
4123
|
_toFieldTransform(t) {
|
|
4114
|
-
const
|
|
4115
|
-
/*array=*/ !0),
|
|
4116
|
-
return new
|
|
4124
|
+
const e = Fn(this, t,
|
|
4125
|
+
/*array=*/ !0), n = this.lt.map((t => jn(t, e))), r = new ge(n);
|
|
4126
|
+
return new Ee(t.path, r);
|
|
4117
4127
|
}
|
|
4118
4128
|
isEqual(t) {
|
|
4119
4129
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4121,14 +4131,14 @@ class xe extends be {
|
|
|
4121
4131
|
}
|
|
4122
4132
|
}
|
|
4123
4133
|
|
|
4124
|
-
class
|
|
4125
|
-
constructor(t,
|
|
4126
|
-
super(t), this.lt =
|
|
4134
|
+
class On extends En {
|
|
4135
|
+
constructor(t, e) {
|
|
4136
|
+
super(t), this.lt = e;
|
|
4127
4137
|
}
|
|
4128
4138
|
_toFieldTransform(t) {
|
|
4129
|
-
const
|
|
4130
|
-
/*array=*/ !0),
|
|
4131
|
-
return new
|
|
4139
|
+
const e = Fn(this, t,
|
|
4140
|
+
/*array=*/ !0), n = this.lt.map((t => jn(t, e))), r = new be(n);
|
|
4141
|
+
return new Ee(t.path, r);
|
|
4132
4142
|
}
|
|
4133
4143
|
isEqual(t) {
|
|
4134
4144
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4136,13 +4146,13 @@ class qe extends be {
|
|
|
4136
4146
|
}
|
|
4137
4147
|
}
|
|
4138
4148
|
|
|
4139
|
-
class
|
|
4140
|
-
constructor(t,
|
|
4141
|
-
super(t), this.ft =
|
|
4149
|
+
class Cn extends En {
|
|
4150
|
+
constructor(t, e) {
|
|
4151
|
+
super(t), this.ft = e;
|
|
4142
4152
|
}
|
|
4143
4153
|
_toFieldTransform(t) {
|
|
4144
|
-
const
|
|
4145
|
-
return new
|
|
4154
|
+
const e = new ve(t.q, pe(t.q, this.ft));
|
|
4155
|
+
return new Ee(t.path, e);
|
|
4146
4156
|
}
|
|
4147
4157
|
isEqual(t) {
|
|
4148
4158
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4150,50 +4160,50 @@ class Oe extends be {
|
|
|
4150
4160
|
}
|
|
4151
4161
|
}
|
|
4152
4162
|
|
|
4153
|
-
/** Parse update data from an update() call. */ function
|
|
4154
|
-
const s = t.ht(1 /* Update */ ,
|
|
4155
|
-
|
|
4156
|
-
const i = [], o =
|
|
4163
|
+
/** Parse update data from an update() call. */ function Ln(t, e, n, r) {
|
|
4164
|
+
const s = t.ht(1 /* Update */ , e, n);
|
|
4165
|
+
zn("Data must be an object, but it was:", s, r);
|
|
4166
|
+
const i = [], o = Qt.empty();
|
|
4157
4167
|
Tt(r, ((t, r) => {
|
|
4158
|
-
const u =
|
|
4168
|
+
const u = Wn(e, t, n);
|
|
4159
4169
|
// For Compat types, we have to "extract" the underlying types before
|
|
4160
4170
|
// performing validation.
|
|
4161
4171
|
r = l(r);
|
|
4162
4172
|
const c = s.it(u);
|
|
4163
|
-
if (r instanceof
|
|
4173
|
+
if (r instanceof Sn)
|
|
4164
4174
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4165
4175
|
i.push(u); else {
|
|
4166
|
-
const t =
|
|
4176
|
+
const t = jn(r, c);
|
|
4167
4177
|
null != t && (i.push(u), o.set(u, t));
|
|
4168
4178
|
}
|
|
4169
4179
|
}));
|
|
4170
4180
|
const u = new It(i);
|
|
4171
|
-
return new
|
|
4181
|
+
return new Rn(o, u, s.fieldTransforms);
|
|
4172
4182
|
}
|
|
4173
4183
|
|
|
4174
|
-
/** Parse update data from a list of field/value arguments. */ function
|
|
4175
|
-
const o = t.ht(1 /* Update */ ,
|
|
4176
|
-
if (i.length % 2 != 0) throw new U(R, `Function ${
|
|
4177
|
-
for (let t = 0; t < i.length; t += 2) u.push(
|
|
4178
|
-
const a = [], h =
|
|
4184
|
+
/** Parse update data from a list of field/value arguments. */ function kn(t, e, n, r, s, i) {
|
|
4185
|
+
const o = t.ht(1 /* Update */ , e, n), u = [ Gn(e, r, n) ], c = [ s ];
|
|
4186
|
+
if (i.length % 2 != 0) throw new U(R, `Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);
|
|
4187
|
+
for (let t = 0; t < i.length; t += 2) u.push(Gn(e, i[t])), c.push(i[t + 1]);
|
|
4188
|
+
const a = [], h = Qt.empty();
|
|
4179
4189
|
// We iterate in reverse order to pick the last value for a field if the
|
|
4180
4190
|
// user specified the field multiple times.
|
|
4181
|
-
for (let t = u.length - 1; t >= 0; --t) if (!
|
|
4182
|
-
const
|
|
4183
|
-
let
|
|
4191
|
+
for (let t = u.length - 1; t >= 0; --t) if (!Hn(a, u[t])) {
|
|
4192
|
+
const e = u[t];
|
|
4193
|
+
let n = c[t];
|
|
4184
4194
|
// For Compat types, we have to "extract" the underlying types before
|
|
4185
4195
|
// performing validation.
|
|
4186
|
-
|
|
4187
|
-
const r = o.it(
|
|
4188
|
-
if (
|
|
4196
|
+
n = l(n);
|
|
4197
|
+
const r = o.it(e);
|
|
4198
|
+
if (n instanceof Sn)
|
|
4189
4199
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4190
|
-
a.push(
|
|
4191
|
-
const t =
|
|
4192
|
-
null != t && (a.push(
|
|
4200
|
+
a.push(e); else {
|
|
4201
|
+
const t = jn(n, r);
|
|
4202
|
+
null != t && (a.push(e), h.set(e, t));
|
|
4193
4203
|
}
|
|
4194
4204
|
}
|
|
4195
4205
|
const f = new It(a);
|
|
4196
|
-
return new
|
|
4206
|
+
return new Rn(h, f, o.fieldTransforms);
|
|
4197
4207
|
}
|
|
4198
4208
|
|
|
4199
4209
|
/**
|
|
@@ -4202,8 +4212,8 @@ class Oe extends be {
|
|
|
4202
4212
|
*
|
|
4203
4213
|
* @param allowArrays - Whether the query value is an array that may directly
|
|
4204
4214
|
* contain additional arrays (e.g. the operand of an `in` query).
|
|
4205
|
-
*/ function
|
|
4206
|
-
return
|
|
4215
|
+
*/ function Un(t, e, n, r = !1) {
|
|
4216
|
+
return jn(n, t.ht(r ? 4 /* ArrayArgument */ : 3 /* Argument */ , e));
|
|
4207
4217
|
}
|
|
4208
4218
|
|
|
4209
4219
|
/**
|
|
@@ -4214,12 +4224,12 @@ class Oe extends be {
|
|
|
4214
4224
|
* the source of the data being parsed, etc.
|
|
4215
4225
|
* @returns The parsed value, or null if the value was a FieldValue sentinel
|
|
4216
4226
|
* that should not be included in the resulting parsed data.
|
|
4217
|
-
*/ function
|
|
4218
|
-
if (
|
|
4227
|
+
*/ function jn(t, e) {
|
|
4228
|
+
if (Bn(
|
|
4219
4229
|
// Unwrap the API type from the Compat SDK. This will return the API type
|
|
4220
4230
|
// from firestore-exp.
|
|
4221
|
-
t = l(t))) return
|
|
4222
|
-
if (t instanceof
|
|
4231
|
+
t = l(t))) return zn("Unsupported field value:", e, t), Mn(t, e);
|
|
4232
|
+
if (t instanceof En)
|
|
4223
4233
|
// FieldValues usually parse into transforms (except deleteField())
|
|
4224
4234
|
// in which case we do not want to include this field in our parsed data
|
|
4225
4235
|
// (as doing so will overwrite the field directly prior to the transform
|
|
@@ -4229,19 +4239,19 @@ class Oe extends be {
|
|
|
4229
4239
|
* "Parses" the provided FieldValueImpl, adding any necessary transforms to
|
|
4230
4240
|
* context.fieldTransforms.
|
|
4231
4241
|
*/
|
|
4232
|
-
return function(t,
|
|
4242
|
+
return function(t, e) {
|
|
4233
4243
|
// Sentinels are only supported with writes, and not within arrays.
|
|
4234
|
-
if (!
|
|
4235
|
-
if (!
|
|
4236
|
-
const
|
|
4237
|
-
|
|
4244
|
+
if (!Pn(e.tt)) throw e.ut(`${t._methodName}() can only be used with update() and set()`);
|
|
4245
|
+
if (!e.path) throw e.ut(`${t._methodName}() is not currently supported inside arrays`);
|
|
4246
|
+
const n = t._toFieldTransform(e);
|
|
4247
|
+
n && e.fieldTransforms.push(n);
|
|
4238
4248
|
}
|
|
4239
4249
|
/**
|
|
4240
4250
|
* Helper to parse a scalar value (i.e. not an Object, Array, or FieldValue)
|
|
4241
4251
|
*
|
|
4242
4252
|
* @returns The parsed value
|
|
4243
|
-
*/ (t,
|
|
4244
|
-
if (void 0 === t &&
|
|
4253
|
+
*/ (t, e), null;
|
|
4254
|
+
if (void 0 === t && e.ignoreUndefinedProperties)
|
|
4245
4255
|
// If the input is undefined it can never participate in the fieldMask, so
|
|
4246
4256
|
// don't handle this below. If `ignoreUndefinedProperties` is false,
|
|
4247
4257
|
// `parseScalarValue` will reject an undefined value.
|
|
@@ -4249,38 +4259,38 @@ class Oe extends be {
|
|
|
4249
4259
|
if (
|
|
4250
4260
|
// If context.path is null we are inside an array and we don't support
|
|
4251
4261
|
// field mask paths more granular than the top-level array.
|
|
4252
|
-
|
|
4262
|
+
e.path && e.fieldMask.push(e.path), t instanceof Array) {
|
|
4253
4263
|
// TODO(b/34871131): Include the path containing the array in the error
|
|
4254
4264
|
// message.
|
|
4255
4265
|
// In the case of IN queries, the parsed data is an array (representing
|
|
4256
4266
|
// the set of values to be included for the IN query) that may directly
|
|
4257
4267
|
// contain additional arrays (each representing an individual field
|
|
4258
4268
|
// value), so we disable this validation.
|
|
4259
|
-
if (
|
|
4260
|
-
return function(t,
|
|
4261
|
-
const
|
|
4269
|
+
if (e.settings.rt && 4 /* ArrayArgument */ !== e.tt) throw e.ut("Nested arrays are not supported");
|
|
4270
|
+
return function(t, e) {
|
|
4271
|
+
const n = [];
|
|
4262
4272
|
let r = 0;
|
|
4263
4273
|
for (const s of t) {
|
|
4264
|
-
let t =
|
|
4274
|
+
let t = jn(s, e.ot(r));
|
|
4265
4275
|
null == t && (
|
|
4266
4276
|
// Just include nulls in the array for fields being replaced with a
|
|
4267
4277
|
// sentinel.
|
|
4268
4278
|
t = {
|
|
4269
4279
|
nullValue: "NULL_VALUE"
|
|
4270
|
-
}),
|
|
4280
|
+
}), n.push(t), r++;
|
|
4271
4281
|
}
|
|
4272
4282
|
return {
|
|
4273
4283
|
arrayValue: {
|
|
4274
|
-
values:
|
|
4284
|
+
values: n
|
|
4275
4285
|
}
|
|
4276
4286
|
};
|
|
4277
|
-
}(t,
|
|
4287
|
+
}(t, e);
|
|
4278
4288
|
}
|
|
4279
|
-
return function(t,
|
|
4289
|
+
return function(t, e) {
|
|
4280
4290
|
if (null === (t = l(t))) return {
|
|
4281
4291
|
nullValue: "NULL_VALUE"
|
|
4282
4292
|
};
|
|
4283
|
-
if ("number" == typeof t) return
|
|
4293
|
+
if ("number" == typeof t) return pe(e.q, t);
|
|
4284
4294
|
if ("boolean" == typeof t) return {
|
|
4285
4295
|
booleanValue: t
|
|
4286
4296
|
};
|
|
@@ -4288,37 +4298,37 @@ class Oe extends be {
|
|
|
4288
4298
|
stringValue: t
|
|
4289
4299
|
};
|
|
4290
4300
|
if (t instanceof Date) {
|
|
4291
|
-
const
|
|
4301
|
+
const n = bt.fromDate(t);
|
|
4292
4302
|
return {
|
|
4293
|
-
timestampValue:
|
|
4303
|
+
timestampValue: Se(e.q, n)
|
|
4294
4304
|
};
|
|
4295
4305
|
}
|
|
4296
|
-
if (t instanceof
|
|
4306
|
+
if (t instanceof bt) {
|
|
4297
4307
|
// Firestore backend truncates precision down to microseconds. To ensure
|
|
4298
4308
|
// offline mode works the same with regards to truncation, perform the
|
|
4299
4309
|
// truncation immediately without waiting for the backend to do that.
|
|
4300
|
-
const
|
|
4310
|
+
const n = new bt(t.seconds, 1e3 * Math.floor(t.nanoseconds / 1e3));
|
|
4301
4311
|
return {
|
|
4302
|
-
timestampValue:
|
|
4312
|
+
timestampValue: Se(e.q, n)
|
|
4303
4313
|
};
|
|
4304
4314
|
}
|
|
4305
|
-
if (t instanceof
|
|
4315
|
+
if (t instanceof Tn) return {
|
|
4306
4316
|
geoPointValue: {
|
|
4307
4317
|
latitude: t.latitude,
|
|
4308
4318
|
longitude: t.longitude
|
|
4309
4319
|
}
|
|
4310
4320
|
};
|
|
4311
|
-
if (t instanceof
|
|
4312
|
-
bytesValue:
|
|
4321
|
+
if (t instanceof vn) return {
|
|
4322
|
+
bytesValue: Fe(e.q, t._byteString)
|
|
4313
4323
|
};
|
|
4314
|
-
if (t instanceof
|
|
4315
|
-
const
|
|
4316
|
-
if (!r.isEqual(
|
|
4324
|
+
if (t instanceof ln) {
|
|
4325
|
+
const n = e.databaseId, r = t.firestore._databaseId;
|
|
4326
|
+
if (!r.isEqual(n)) throw e.ut(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);
|
|
4317
4327
|
return {
|
|
4318
|
-
referenceValue:
|
|
4328
|
+
referenceValue: Oe(t.firestore._databaseId || e.databaseId, t._key.path)
|
|
4319
4329
|
};
|
|
4320
4330
|
}
|
|
4321
|
-
throw
|
|
4331
|
+
throw e.ut(`Unsupported field value: ${ot(t)}`);
|
|
4322
4332
|
}
|
|
4323
4333
|
/**
|
|
4324
4334
|
* Checks whether an object looks like a JSON object that should be converted
|
|
@@ -4326,56 +4336,56 @@ class Oe extends be {
|
|
|
4326
4336
|
* JSON objects since they should be converted to a struct value. Arrays, Dates,
|
|
4327
4337
|
* GeoPoints, etc. are not considered to look like JSON objects since they map
|
|
4328
4338
|
* to specific FieldValue types other than ObjectValue.
|
|
4329
|
-
*/ (t,
|
|
4339
|
+
*/ (t, e);
|
|
4330
4340
|
}
|
|
4331
4341
|
|
|
4332
|
-
function
|
|
4333
|
-
const
|
|
4342
|
+
function Mn(t, e) {
|
|
4343
|
+
const n = {};
|
|
4334
4344
|
return !function(t) {
|
|
4335
|
-
for (const
|
|
4345
|
+
for (const e in t) if (Object.prototype.hasOwnProperty.call(t, e)) return !1;
|
|
4336
4346
|
return !0;
|
|
4337
4347
|
}(t) ? Tt(t, ((t, r) => {
|
|
4338
|
-
const s =
|
|
4339
|
-
null != s && (
|
|
4348
|
+
const s = jn(r, e.nt(t));
|
|
4349
|
+
null != s && (n[t] = s);
|
|
4340
4350
|
})) :
|
|
4341
4351
|
// If we encounter an empty object, we explicitly add it to the update
|
|
4342
4352
|
// mask to ensure that the server creates a map entry.
|
|
4343
|
-
|
|
4353
|
+
e.path && e.path.length > 0 && e.fieldMask.push(e.path), {
|
|
4344
4354
|
mapValue: {
|
|
4345
|
-
fields:
|
|
4355
|
+
fields: n
|
|
4346
4356
|
}
|
|
4347
4357
|
};
|
|
4348
4358
|
}
|
|
4349
4359
|
|
|
4350
|
-
function
|
|
4351
|
-
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof
|
|
4360
|
+
function Bn(t) {
|
|
4361
|
+
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof bt || t instanceof Tn || t instanceof vn || t instanceof ln || t instanceof En);
|
|
4352
4362
|
}
|
|
4353
4363
|
|
|
4354
|
-
function
|
|
4355
|
-
if (!
|
|
4364
|
+
function zn(t, e, n) {
|
|
4365
|
+
if (!Bn(n) || !function(t) {
|
|
4356
4366
|
return "object" == typeof t && null !== t && (Object.getPrototypeOf(t) === Object.prototype || null === Object.getPrototypeOf(t));
|
|
4357
|
-
}(
|
|
4358
|
-
const r = ot(
|
|
4359
|
-
throw "an object" === r ?
|
|
4367
|
+
}(n)) {
|
|
4368
|
+
const r = ot(n);
|
|
4369
|
+
throw "an object" === r ? e.ut(t + " a custom object") : e.ut(t + " " + r);
|
|
4360
4370
|
}
|
|
4361
4371
|
}
|
|
4362
4372
|
|
|
4363
4373
|
/**
|
|
4364
4374
|
* Helper that calls fromDotSeparatedString() but wraps any error thrown.
|
|
4365
|
-
*/ function
|
|
4375
|
+
*/ function Gn(t, e, n) {
|
|
4366
4376
|
if ((
|
|
4367
4377
|
// If required, replace the FieldPath Compat class with with the firestore-exp
|
|
4368
4378
|
// FieldPath.
|
|
4369
|
-
|
|
4370
|
-
if ("string" == typeof
|
|
4371
|
-
throw
|
|
4379
|
+
e = l(e)) instanceof gn) return e._internalPath;
|
|
4380
|
+
if ("string" == typeof e) return Wn(t, e);
|
|
4381
|
+
throw Yn("Field path arguments must be of type string or ", t,
|
|
4372
4382
|
/* hasConverter= */ !1,
|
|
4373
|
-
/* path= */ void 0,
|
|
4383
|
+
/* path= */ void 0, n);
|
|
4374
4384
|
}
|
|
4375
4385
|
|
|
4376
4386
|
/**
|
|
4377
4387
|
* Matches any characters in a field path string that are reserved.
|
|
4378
|
-
*/ const
|
|
4388
|
+
*/ const Qn = new RegExp("[~\\*/\\[\\]]");
|
|
4379
4389
|
|
|
4380
4390
|
/**
|
|
4381
4391
|
* Wraps fromDotSeparatedString with an error message about the method that
|
|
@@ -4385,30 +4395,30 @@ function Be(t, n, e) {
|
|
|
4385
4395
|
* split on dots.
|
|
4386
4396
|
* @param targetDoc - The document against which the field path will be
|
|
4387
4397
|
* evaluated.
|
|
4388
|
-
*/ function
|
|
4389
|
-
if (
|
|
4398
|
+
*/ function Wn(t, e, n) {
|
|
4399
|
+
if (e.search(Qn) >= 0) throw Yn(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`, t,
|
|
4390
4400
|
/* hasConverter= */ !1,
|
|
4391
|
-
/* path= */ void 0,
|
|
4401
|
+
/* path= */ void 0, n);
|
|
4392
4402
|
try {
|
|
4393
|
-
return new
|
|
4403
|
+
return new gn(...e.split("."))._internalPath;
|
|
4394
4404
|
} catch (r) {
|
|
4395
|
-
throw
|
|
4405
|
+
throw Yn(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`, t,
|
|
4396
4406
|
/* hasConverter= */ !1,
|
|
4397
|
-
/* path= */ void 0,
|
|
4407
|
+
/* path= */ void 0, n);
|
|
4398
4408
|
}
|
|
4399
4409
|
}
|
|
4400
4410
|
|
|
4401
|
-
function
|
|
4411
|
+
function Yn(t, e, n, r, s) {
|
|
4402
4412
|
const i = r && !r.isEmpty(), o = void 0 !== s;
|
|
4403
|
-
let u = `Function ${
|
|
4404
|
-
|
|
4413
|
+
let u = `Function ${e}() called with invalid data`;
|
|
4414
|
+
n && (u += " (via `toFirestore()`)"), u += ". ";
|
|
4405
4415
|
let c = "";
|
|
4406
4416
|
return (i || o) && (c += " (found", i && (c += ` in field ${r}`), o && (c += ` in document ${s}`),
|
|
4407
4417
|
c += ")"), new U(R, u + t + c);
|
|
4408
4418
|
}
|
|
4409
4419
|
|
|
4410
|
-
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function
|
|
4411
|
-
return t.some((t => t.isEqual(
|
|
4420
|
+
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function Hn(t, e) {
|
|
4421
|
+
return t.some((t => t.isEqual(e)));
|
|
4412
4422
|
}
|
|
4413
4423
|
|
|
4414
4424
|
/**
|
|
@@ -4435,14 +4445,14 @@ function We(t, n, e, r, s) {
|
|
|
4435
4445
|
* For a `DocumentSnapshot` that points to a non-existing document, any data
|
|
4436
4446
|
* access will return 'undefined'. You can use the `exists()` method to
|
|
4437
4447
|
* explicitly verify a document's existence.
|
|
4438
|
-
*/ class
|
|
4448
|
+
*/ class Kn {
|
|
4439
4449
|
// Note: This class is stripped down version of the DocumentSnapshot in
|
|
4440
4450
|
// the legacy SDK. The changes are:
|
|
4441
4451
|
// - No support for SnapshotMetadata.
|
|
4442
4452
|
// - No support for SnapshotOptions.
|
|
4443
4453
|
/** @hideconstructor protected */
|
|
4444
|
-
constructor(t,
|
|
4445
|
-
this._firestore = t, this._userDataWriter =
|
|
4454
|
+
constructor(t, e, n, r, s) {
|
|
4455
|
+
this._firestore = t, this._userDataWriter = e, this._key = n, this._document = r,
|
|
4446
4456
|
this._converter = s;
|
|
4447
4457
|
}
|
|
4448
4458
|
/** Property of the `DocumentSnapshot` that provides the document's ID. */ get id() {
|
|
@@ -4451,7 +4461,7 @@ function We(t, n, e, r, s) {
|
|
|
4451
4461
|
/**
|
|
4452
4462
|
* The `DocumentReference` for the document included in the `DocumentSnapshot`.
|
|
4453
4463
|
*/ get ref() {
|
|
4454
|
-
return new
|
|
4464
|
+
return new ln(this._firestore, this._converter, this._key);
|
|
4455
4465
|
}
|
|
4456
4466
|
/**
|
|
4457
4467
|
* Signals whether or not the document at the snapshot's location exists.
|
|
@@ -4471,7 +4481,7 @@ function We(t, n, e, r, s) {
|
|
|
4471
4481
|
if (this._converter) {
|
|
4472
4482
|
// We only want to use the converter and create a new DocumentSnapshot
|
|
4473
4483
|
// if a converter has been provided.
|
|
4474
|
-
const t = new
|
|
4484
|
+
const t = new Jn(this._firestore, this._userDataWriter, this._key, this._document,
|
|
4475
4485
|
/* converter= */ null);
|
|
4476
4486
|
return this._converter.fromFirestore(t);
|
|
4477
4487
|
}
|
|
@@ -4491,8 +4501,8 @@ function We(t, n, e, r, s) {
|
|
|
4491
4501
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4492
4502
|
get(t) {
|
|
4493
4503
|
if (this._document) {
|
|
4494
|
-
const
|
|
4495
|
-
if (null !==
|
|
4504
|
+
const e = this._document.data.field(tr("DocumentSnapshot.get", t));
|
|
4505
|
+
if (null !== e) return this._userDataWriter.convertValue(e);
|
|
4496
4506
|
}
|
|
4497
4507
|
}
|
|
4498
4508
|
}
|
|
@@ -4507,7 +4517,7 @@ function We(t, n, e, r, s) {
|
|
|
4507
4517
|
* `DocumentSnapshot`. Since query results contain only existing documents, the
|
|
4508
4518
|
* `exists` property will always be true and `data()` will never return
|
|
4509
4519
|
* 'undefined'.
|
|
4510
|
-
*/ class
|
|
4520
|
+
*/ class Jn extends Kn {
|
|
4511
4521
|
/**
|
|
4512
4522
|
* Retrieves all fields in the document as an `Object`.
|
|
4513
4523
|
*
|
|
@@ -4525,10 +4535,10 @@ function We(t, n, e, r, s) {
|
|
|
4525
4535
|
* array via the `docs` property or enumerated using the `forEach` method. The
|
|
4526
4536
|
* number of documents can be determined via the `empty` and `size`
|
|
4527
4537
|
* properties.
|
|
4528
|
-
*/ class
|
|
4538
|
+
*/ class Xn {
|
|
4529
4539
|
/** @hideconstructor */
|
|
4530
|
-
constructor(t,
|
|
4531
|
-
this._docs =
|
|
4540
|
+
constructor(t, e) {
|
|
4541
|
+
this._docs = e, this.query = t;
|
|
4532
4542
|
}
|
|
4533
4543
|
/** An array of all the documents in the `QuerySnapshot`. */ get docs() {
|
|
4534
4544
|
return [ ...this._docs ];
|
|
@@ -4545,8 +4555,8 @@ function We(t, n, e, r, s) {
|
|
|
4545
4555
|
* @param callback - A callback to be called with a `QueryDocumentSnapshot` for
|
|
4546
4556
|
* each document in the snapshot.
|
|
4547
4557
|
* @param thisArg - The `this` binding for the callback.
|
|
4548
|
-
*/ forEach(t,
|
|
4549
|
-
this._docs.forEach(t,
|
|
4558
|
+
*/ forEach(t, e) {
|
|
4559
|
+
this._docs.forEach(t, e);
|
|
4550
4560
|
}
|
|
4551
4561
|
}
|
|
4552
4562
|
|
|
@@ -4556,14 +4566,14 @@ function We(t, n, e, r, s) {
|
|
|
4556
4566
|
* @param left - A snapshot to compare.
|
|
4557
4567
|
* @param right - A snapshot to compare.
|
|
4558
4568
|
* @returns true if the snapshots are equal.
|
|
4559
|
-
*/ function
|
|
4560
|
-
return t = l(t),
|
|
4569
|
+
*/ function Zn(t, e) {
|
|
4570
|
+
return t = l(t), e = l(e), t instanceof Kn && e instanceof Kn ? 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 Xn && e instanceof Xn && (_n(t.query, e.query) && gt(t.docs, e.docs, Zn));
|
|
4561
4571
|
}
|
|
4562
4572
|
|
|
4563
4573
|
/**
|
|
4564
4574
|
* Helper that calls `fromDotSeparatedString()` but wraps any error thrown.
|
|
4565
|
-
*/ function
|
|
4566
|
-
return "string" == typeof
|
|
4575
|
+
*/ function tr(t, e) {
|
|
4576
|
+
return "string" == typeof e ? Wn(t, e) : e instanceof gn ? e._internalPath : e._delegate._internalPath;
|
|
4567
4577
|
}
|
|
4568
4578
|
|
|
4569
4579
|
/**
|
|
@@ -4590,7 +4600,7 @@ function We(t, n, e, r, s) {
|
|
|
4590
4600
|
* can then be passed to {@link query} to create a new query instance that
|
|
4591
4601
|
* also contains this `QueryConstraint`.
|
|
4592
4602
|
*/
|
|
4593
|
-
class
|
|
4603
|
+
class er {}
|
|
4594
4604
|
|
|
4595
4605
|
/**
|
|
4596
4606
|
* Creates a new immutable instance of {@link Query} that is extended to also include
|
|
@@ -4600,43 +4610,43 @@ class tr {}
|
|
|
4600
4610
|
* @param queryConstraints - The list of {@link QueryConstraint}s to apply.
|
|
4601
4611
|
* @throws if any of the provided query constraints cannot be combined with the
|
|
4602
4612
|
* existing or new constraints.
|
|
4603
|
-
*/ function nr(t, ...
|
|
4604
|
-
for (const
|
|
4613
|
+
*/ function nr(t, ...e) {
|
|
4614
|
+
for (const n of e) t = n._apply(t);
|
|
4605
4615
|
return t;
|
|
4606
4616
|
}
|
|
4607
4617
|
|
|
4608
|
-
class
|
|
4609
|
-
constructor(t,
|
|
4610
|
-
super(), this.dt = t, this.wt =
|
|
4618
|
+
class rr extends er {
|
|
4619
|
+
constructor(t, e, n) {
|
|
4620
|
+
super(), this.dt = t, this.wt = e, this.yt = n, this.type = "where";
|
|
4611
4621
|
}
|
|
4612
4622
|
_apply(t) {
|
|
4613
|
-
const
|
|
4623
|
+
const e = Dn(t.firestore), n = function(t, e, n, r, s, i, o) {
|
|
4614
4624
|
let u;
|
|
4615
4625
|
if (s.isKeyField()) {
|
|
4616
4626
|
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new U(R, `Invalid Query. You can't perform '${i}' queries on documentId().`);
|
|
4617
4627
|
if ("in" /* IN */ === i || "not-in" /* NOT_IN */ === i) {
|
|
4618
|
-
|
|
4619
|
-
const
|
|
4620
|
-
for (const
|
|
4628
|
+
_r(o, i);
|
|
4629
|
+
const e = [];
|
|
4630
|
+
for (const n of o) e.push(yr(r, t, n));
|
|
4621
4631
|
u = {
|
|
4622
4632
|
arrayValue: {
|
|
4623
|
-
values:
|
|
4633
|
+
values: e
|
|
4624
4634
|
}
|
|
4625
4635
|
};
|
|
4626
|
-
} else u =
|
|
4627
|
-
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i ||
|
|
4628
|
-
u =
|
|
4636
|
+
} else u = yr(r, t, o);
|
|
4637
|
+
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i || _r(o, i),
|
|
4638
|
+
u = Un(n, e, o,
|
|
4629
4639
|
/* allowArrays= */ "in" /* IN */ === i || "not-in" /* NOT_IN */ === i);
|
|
4630
|
-
const c =
|
|
4631
|
-
return function(t,
|
|
4632
|
-
if (
|
|
4633
|
-
const
|
|
4634
|
-
if (null !==
|
|
4635
|
-
const r =
|
|
4636
|
-
null !== r &&
|
|
4640
|
+
const c = Kt.create(s, i, u);
|
|
4641
|
+
return function(t, e) {
|
|
4642
|
+
if (e.D()) {
|
|
4643
|
+
const n = le(t);
|
|
4644
|
+
if (null !== n && !n.isEqual(e.field)) throw new U(R, `Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '${n.toString()}' and '${e.field.toString()}'`);
|
|
4645
|
+
const r = he(t);
|
|
4646
|
+
null !== r && gr(t, e.field, r);
|
|
4637
4647
|
}
|
|
4638
|
-
const
|
|
4639
|
-
for (const
|
|
4648
|
+
const n = function(t, e) {
|
|
4649
|
+
for (const n of t.filters) if (e.indexOf(n.op) >= 0) return n.op;
|
|
4640
4650
|
return null;
|
|
4641
4651
|
}(t,
|
|
4642
4652
|
/**
|
|
@@ -4671,16 +4681,16 @@ class er extends tr {
|
|
|
4671
4681
|
default:
|
|
4672
4682
|
return [];
|
|
4673
4683
|
}
|
|
4674
|
-
}(
|
|
4675
|
-
if (null !==
|
|
4684
|
+
}(e.op));
|
|
4685
|
+
if (null !== n)
|
|
4676
4686
|
// Special case when it's a duplicate op to give a slightly clearer error message.
|
|
4677
|
-
throw
|
|
4687
|
+
throw n === e.op ? new U(R, `Invalid query. You cannot use more than one '${e.op.toString()}' filter.`) : new U(R, `Invalid query. You cannot use '${e.op.toString()}' filters with '${n.toString()}' filters.`);
|
|
4678
4688
|
}(t, c), c;
|
|
4679
|
-
}(t._query, "where",
|
|
4680
|
-
return new
|
|
4681
|
-
const
|
|
4682
|
-
return new
|
|
4683
|
-
}(t._query,
|
|
4689
|
+
}(t._query, "where", e, t.firestore._databaseId, this.dt, this.wt, this.yt);
|
|
4690
|
+
return new fn(t.firestore, t.converter, function(t, e) {
|
|
4691
|
+
const n = t.filters.concat([ e ]);
|
|
4692
|
+
return new ae(t.path, t.collectionGroup, t.explicitOrderBy.slice(), n, t.limit, t.limitType, t.startAt, t.endAt);
|
|
4693
|
+
}(t._query, n));
|
|
4684
4694
|
}
|
|
4685
4695
|
}
|
|
4686
4696
|
|
|
@@ -4694,25 +4704,25 @@ class er extends tr {
|
|
|
4694
4704
|
* "<=", "!=").
|
|
4695
4705
|
* @param value - The value for comparison
|
|
4696
4706
|
* @returns The created {@link Query}.
|
|
4697
|
-
*/ function
|
|
4698
|
-
const r =
|
|
4699
|
-
return new
|
|
4707
|
+
*/ function sr(t, e, n) {
|
|
4708
|
+
const r = e, s = tr("where", t);
|
|
4709
|
+
return new rr(s, r, n);
|
|
4700
4710
|
}
|
|
4701
4711
|
|
|
4702
|
-
class
|
|
4703
|
-
constructor(t,
|
|
4704
|
-
super(), this.dt = t, this._t =
|
|
4712
|
+
class ir extends er {
|
|
4713
|
+
constructor(t, e) {
|
|
4714
|
+
super(), this.dt = t, this._t = e, this.type = "orderBy";
|
|
4705
4715
|
}
|
|
4706
4716
|
_apply(t) {
|
|
4707
|
-
const
|
|
4717
|
+
const e = function(t, e, n) {
|
|
4708
4718
|
if (null !== t.startAt) throw new U(R, "Invalid query. You must not call startAt() or startAfter() before calling orderBy().");
|
|
4709
4719
|
if (null !== t.endAt) throw new U(R, "Invalid query. You must not call endAt() or endBefore() before calling orderBy().");
|
|
4710
|
-
const r = new
|
|
4711
|
-
return function(t,
|
|
4712
|
-
if (null ===
|
|
4720
|
+
const r = new oe(e, n);
|
|
4721
|
+
return function(t, e) {
|
|
4722
|
+
if (null === he(t)) {
|
|
4713
4723
|
// This is the first order by. It must match any inequality.
|
|
4714
|
-
const
|
|
4715
|
-
null !==
|
|
4724
|
+
const n = le(t);
|
|
4725
|
+
null !== n && gr(t, n, e.field);
|
|
4716
4726
|
}
|
|
4717
4727
|
}(t, r), r;
|
|
4718
4728
|
}
|
|
@@ -4727,11 +4737,11 @@ class sr extends tr {
|
|
|
4727
4737
|
* of the query or if any of the fields in the order by are an uncommitted
|
|
4728
4738
|
* server timestamp.
|
|
4729
4739
|
*/ (t._query, this.dt, this._t);
|
|
4730
|
-
return new
|
|
4740
|
+
return new fn(t.firestore, t.converter, function(t, e) {
|
|
4731
4741
|
// TODO(dimond): validate that orderBy does not list the same key twice.
|
|
4732
|
-
const
|
|
4733
|
-
return new
|
|
4734
|
-
}(t._query,
|
|
4742
|
+
const n = t.explicitOrderBy.concat([ e ]);
|
|
4743
|
+
return new ae(t.path, t.collectionGroup, n, t.filters.slice(), t.limit, t.limitType, t.startAt, t.endAt);
|
|
4744
|
+
}(t._query, e));
|
|
4735
4745
|
}
|
|
4736
4746
|
}
|
|
4737
4747
|
|
|
@@ -4743,19 +4753,19 @@ class sr extends tr {
|
|
|
4743
4753
|
* @param directionStr - Optional direction to sort by ('asc' or 'desc'). If
|
|
4744
4754
|
* not specified, order will be ascending.
|
|
4745
4755
|
* @returns The created {@link Query}.
|
|
4746
|
-
*/ function
|
|
4747
|
-
const
|
|
4748
|
-
return new
|
|
4756
|
+
*/ function or(t, e = "asc") {
|
|
4757
|
+
const n = e, r = tr("orderBy", t);
|
|
4758
|
+
return new ir(r, n);
|
|
4749
4759
|
}
|
|
4750
4760
|
|
|
4751
|
-
class
|
|
4752
|
-
constructor(t,
|
|
4753
|
-
super(), this.type = t, this.gt =
|
|
4761
|
+
class ur extends er {
|
|
4762
|
+
constructor(t, e, n) {
|
|
4763
|
+
super(), this.type = t, this.gt = e, this.bt = n;
|
|
4754
4764
|
}
|
|
4755
4765
|
_apply(t) {
|
|
4756
|
-
return new
|
|
4757
|
-
return new
|
|
4758
|
-
}(t._query, this.gt, this.
|
|
4766
|
+
return new fn(t.firestore, t.converter, function(t, e, n) {
|
|
4767
|
+
return new ae(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), e, n, t.startAt, t.endAt);
|
|
4768
|
+
}(t._query, this.gt, this.bt));
|
|
4759
4769
|
}
|
|
4760
4770
|
}
|
|
4761
4771
|
|
|
@@ -4764,8 +4774,8 @@ class or extends tr {
|
|
|
4764
4774
|
*
|
|
4765
4775
|
* @param limit - The maximum number of items to return.
|
|
4766
4776
|
* @returns The created {@link Query}.
|
|
4767
|
-
*/ function
|
|
4768
|
-
return ct("limit", t), new
|
|
4777
|
+
*/ function cr(t) {
|
|
4778
|
+
return ct("limit", t), new ur("limit", t, "F" /* First */);
|
|
4769
4779
|
}
|
|
4770
4780
|
|
|
4771
4781
|
/**
|
|
@@ -4776,56 +4786,56 @@ class or extends tr {
|
|
|
4776
4786
|
*
|
|
4777
4787
|
* @param limit - The maximum number of items to return.
|
|
4778
4788
|
* @returns The created {@link Query}.
|
|
4779
|
-
*/ function
|
|
4780
|
-
return ct("limitToLast", t), new
|
|
4789
|
+
*/ function ar(t) {
|
|
4790
|
+
return ct("limitToLast", t), new ur("limitToLast", t, "L" /* Last */);
|
|
4781
4791
|
}
|
|
4782
4792
|
|
|
4783
|
-
class
|
|
4784
|
-
constructor(t,
|
|
4785
|
-
super(), this.type = t, this.
|
|
4793
|
+
class hr extends er {
|
|
4794
|
+
constructor(t, e, n) {
|
|
4795
|
+
super(), this.type = t, this.vt = e, this.Et = n;
|
|
4786
4796
|
}
|
|
4787
4797
|
_apply(t) {
|
|
4788
|
-
const
|
|
4789
|
-
return new
|
|
4790
|
-
return new
|
|
4791
|
-
}(t._query,
|
|
4798
|
+
const e = pr(t, this.type, this.vt, this.Et);
|
|
4799
|
+
return new fn(t.firestore, t.converter, function(t, e) {
|
|
4800
|
+
return new ae(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, e, t.endAt);
|
|
4801
|
+
}(t._query, e));
|
|
4792
4802
|
}
|
|
4793
4803
|
}
|
|
4794
4804
|
|
|
4795
|
-
function
|
|
4796
|
-
return new
|
|
4805
|
+
function lr(...t) {
|
|
4806
|
+
return new hr("startAt", t,
|
|
4797
4807
|
/*inclusive=*/ !0);
|
|
4798
4808
|
}
|
|
4799
4809
|
|
|
4800
|
-
function
|
|
4801
|
-
return new
|
|
4810
|
+
function fr(...t) {
|
|
4811
|
+
return new hr("startAfter", t,
|
|
4802
4812
|
/*inclusive=*/ !1);
|
|
4803
4813
|
}
|
|
4804
4814
|
|
|
4805
|
-
class
|
|
4806
|
-
constructor(t,
|
|
4807
|
-
super(), this.type = t, this.
|
|
4815
|
+
class dr extends er {
|
|
4816
|
+
constructor(t, e, n) {
|
|
4817
|
+
super(), this.type = t, this.vt = e, this.Et = n;
|
|
4808
4818
|
}
|
|
4809
4819
|
_apply(t) {
|
|
4810
|
-
const
|
|
4811
|
-
return new
|
|
4812
|
-
return new
|
|
4813
|
-
}(t._query,
|
|
4820
|
+
const e = pr(t, this.type, this.vt, this.Et);
|
|
4821
|
+
return new fn(t.firestore, t.converter, function(t, e) {
|
|
4822
|
+
return new ae(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, t.startAt, e);
|
|
4823
|
+
}(t._query, e));
|
|
4814
4824
|
}
|
|
4815
4825
|
}
|
|
4816
4826
|
|
|
4817
|
-
function
|
|
4818
|
-
return new
|
|
4827
|
+
function wr(...t) {
|
|
4828
|
+
return new dr("endBefore", t,
|
|
4819
4829
|
/*inclusive=*/ !1);
|
|
4820
4830
|
}
|
|
4821
4831
|
|
|
4822
|
-
function
|
|
4823
|
-
return new
|
|
4832
|
+
function mr(...t) {
|
|
4833
|
+
return new dr("endAt", t, /*inclusive=*/ !0);
|
|
4824
4834
|
}
|
|
4825
4835
|
|
|
4826
|
-
/** Helper function to create a bound from a document or fields */ function
|
|
4827
|
-
if (
|
|
4828
|
-
if (!r) throw new U(V, `Can't use a DocumentSnapshot that doesn't exist for ${
|
|
4836
|
+
/** Helper function to create a bound from a document or fields */ function pr(t, e, n, r) {
|
|
4837
|
+
if (n[0] = l(n[0]), n[0] instanceof Kn) return function(t, e, n, r, s) {
|
|
4838
|
+
if (!r) throw new U(V, `Can't use a DocumentSnapshot that doesn't exist for ${n}().`);
|
|
4829
4839
|
const i = [];
|
|
4830
4840
|
// Because people expect to continue/end a query at the exact document
|
|
4831
4841
|
// provided, we need to use the implicit sort order rather than the explicit
|
|
@@ -4834,23 +4844,23 @@ function wr(...t) {
|
|
|
4834
4844
|
// the provided document. Without the key (by using the explicit sort
|
|
4835
4845
|
// orders), multiple documents could match the position, yielding duplicate
|
|
4836
4846
|
// results.
|
|
4837
|
-
for (const
|
|
4838
|
-
const t = r.data.field(
|
|
4839
|
-
if ($t(t)) throw new U(R, 'Invalid query. You are trying to start or end a query using a document for which the field "' +
|
|
4847
|
+
for (const n of de(t)) if (n.field.isKeyField()) i.push(Ut(e, r.key)); else {
|
|
4848
|
+
const t = r.data.field(n.field);
|
|
4849
|
+
if ($t(t)) throw new U(R, 'Invalid query. You are trying to start or end a query using a document for which the field "' + n.field + '" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');
|
|
4840
4850
|
if (null === t) {
|
|
4841
|
-
const t =
|
|
4851
|
+
const t = n.field.canonicalString();
|
|
4842
4852
|
throw new U(R, `Invalid query. You are trying to start or end a query using a document for which the field '${t}' (used as the orderBy) does not exist.`);
|
|
4843
4853
|
}
|
|
4844
4854
|
i.push(t);
|
|
4845
4855
|
}
|
|
4846
|
-
return new
|
|
4856
|
+
return new ie(i, s);
|
|
4847
4857
|
}
|
|
4848
4858
|
/**
|
|
4849
4859
|
* Converts a list of field values to a `Bound` for the given query.
|
|
4850
|
-
*/ (t._query, t.firestore._databaseId,
|
|
4860
|
+
*/ (t._query, t.firestore._databaseId, e, n[0]._document, r);
|
|
4851
4861
|
{
|
|
4852
|
-
const s =
|
|
4853
|
-
return function(t,
|
|
4862
|
+
const s = Dn(t.firestore);
|
|
4863
|
+
return function(t, e, n, r, s, i) {
|
|
4854
4864
|
// Use explicit order by's because it has to match the query the user made
|
|
4855
4865
|
const o = t.explicitOrderBy;
|
|
4856
4866
|
if (s.length > o.length) throw new U(R, `Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);
|
|
@@ -4859,48 +4869,48 @@ function wr(...t) {
|
|
|
4859
4869
|
const c = s[i];
|
|
4860
4870
|
if (o[i].field.isKeyField()) {
|
|
4861
4871
|
if ("string" != typeof c) throw new U(R, `Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);
|
|
4862
|
-
if (!
|
|
4863
|
-
const
|
|
4864
|
-
if (!
|
|
4865
|
-
const s = new
|
|
4866
|
-
u.push(
|
|
4872
|
+
if (!fe(t) && -1 !== c.indexOf("/")) throw new U(R, `Invalid query. When querying a collection and ordering by documentId(), the value passed to ${r}() must be a plain document ID, but '${c}' contains a slash.`);
|
|
4873
|
+
const n = t.path.child(Z.fromString(c));
|
|
4874
|
+
if (!nt.isDocumentKey(n)) throw new U(R, `Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${r}() must result in a valid document path, but '${n}' is not because it contains an odd number of segments.`);
|
|
4875
|
+
const s = new nt(n);
|
|
4876
|
+
u.push(Ut(e, s));
|
|
4867
4877
|
} else {
|
|
4868
|
-
const t =
|
|
4878
|
+
const t = Un(n, r, c);
|
|
4869
4879
|
u.push(t);
|
|
4870
4880
|
}
|
|
4871
4881
|
}
|
|
4872
|
-
return new
|
|
4882
|
+
return new ie(u, i);
|
|
4873
4883
|
}
|
|
4874
4884
|
/**
|
|
4875
4885
|
* Parses the given `documentIdValue` into a `ReferenceValue`, throwing
|
|
4876
4886
|
* appropriate errors if the value is anything other than a `DocumentReference`
|
|
4877
4887
|
* or `string`, or if the string is malformed.
|
|
4878
|
-
*/ (t._query, t.firestore._databaseId, s,
|
|
4888
|
+
*/ (t._query, t.firestore._databaseId, s, e, n, r);
|
|
4879
4889
|
}
|
|
4880
4890
|
}
|
|
4881
4891
|
|
|
4882
|
-
function
|
|
4883
|
-
if ("string" == typeof (
|
|
4884
|
-
if ("" ===
|
|
4885
|
-
if (!
|
|
4886
|
-
const r =
|
|
4887
|
-
if (!
|
|
4888
|
-
return
|
|
4892
|
+
function yr(t, e, n) {
|
|
4893
|
+
if ("string" == typeof (n = l(n))) {
|
|
4894
|
+
if ("" === n) throw new U(R, "Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");
|
|
4895
|
+
if (!fe(e) && -1 !== n.indexOf("/")) throw new U(R, `Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);
|
|
4896
|
+
const r = e.path.child(Z.fromString(n));
|
|
4897
|
+
if (!nt.isDocumentKey(r)) throw new U(R, `Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);
|
|
4898
|
+
return Ut(t, new nt(r));
|
|
4889
4899
|
}
|
|
4890
|
-
if (
|
|
4891
|
-
throw new U(R, `Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${ot(
|
|
4900
|
+
if (n instanceof ln) return Ut(t, n._key);
|
|
4901
|
+
throw new U(R, `Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${ot(n)}.`);
|
|
4892
4902
|
}
|
|
4893
4903
|
|
|
4894
4904
|
/**
|
|
4895
4905
|
* Validates that the value passed into a disjunctive filter satisfies all
|
|
4896
4906
|
* array requirements.
|
|
4897
|
-
*/ function
|
|
4898
|
-
if (!Array.isArray(t) || 0 === t.length) throw new U(R, `Invalid Query. A non-empty array is required for '${
|
|
4899
|
-
if (t.length > 10) throw new U(R, `Invalid Query. '${
|
|
4907
|
+
*/ function _r(t, e) {
|
|
4908
|
+
if (!Array.isArray(t) || 0 === t.length) throw new U(R, `Invalid Query. A non-empty array is required for '${e.toString()}' filters.`);
|
|
4909
|
+
if (t.length > 10) throw new U(R, `Invalid Query. '${e.toString()}' filters support a maximum of 10 elements in the value array.`);
|
|
4900
4910
|
}
|
|
4901
4911
|
|
|
4902
|
-
function
|
|
4903
|
-
if (!
|
|
4912
|
+
function gr(t, e, n) {
|
|
4913
|
+
if (!n.isEqual(e)) throw new U(R, `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.`);
|
|
4904
4914
|
}
|
|
4905
4915
|
|
|
4906
4916
|
/**
|
|
@@ -4950,18 +4960,18 @@ function _r(t, n, e) {
|
|
|
4950
4960
|
* their `set()` or fails due to invalid data originating from a `toFirestore()`
|
|
4951
4961
|
* call.
|
|
4952
4962
|
*/
|
|
4953
|
-
function
|
|
4963
|
+
function br(t, e, n) {
|
|
4954
4964
|
let r;
|
|
4955
4965
|
// Cast to `any` in order to satisfy the union type constraint on
|
|
4956
4966
|
// toFirestore().
|
|
4957
4967
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4958
|
-
return r = t ?
|
|
4968
|
+
return r = t ? n && (n.merge || n.mergeFields) ? t.toFirestore(e, n) : t.toFirestore(e) : e,
|
|
4959
4969
|
r;
|
|
4960
4970
|
}
|
|
4961
4971
|
|
|
4962
4972
|
class vr extends class {
|
|
4963
|
-
convertValue(t,
|
|
4964
|
-
switch (
|
|
4973
|
+
convertValue(t, e = "none") {
|
|
4974
|
+
switch (qt(t)) {
|
|
4965
4975
|
case 0 /* NullValue */ :
|
|
4966
4976
|
return null;
|
|
4967
4977
|
|
|
@@ -4975,7 +4985,7 @@ class vr extends class {
|
|
|
4975
4985
|
return this.convertTimestamp(t.timestampValue);
|
|
4976
4986
|
|
|
4977
4987
|
case 4 /* ServerTimestampValue */ :
|
|
4978
|
-
return this.convertServerTimestamp(t,
|
|
4988
|
+
return this.convertServerTimestamp(t, e);
|
|
4979
4989
|
|
|
4980
4990
|
case 5 /* StringValue */ :
|
|
4981
4991
|
return t.stringValue;
|
|
@@ -4990,32 +5000,32 @@ class vr extends class {
|
|
|
4990
5000
|
return this.convertGeoPoint(t.geoPointValue);
|
|
4991
5001
|
|
|
4992
5002
|
case 9 /* ArrayValue */ :
|
|
4993
|
-
return this.convertArray(t.arrayValue,
|
|
5003
|
+
return this.convertArray(t.arrayValue, e);
|
|
4994
5004
|
|
|
4995
5005
|
case 10 /* ObjectValue */ :
|
|
4996
|
-
return this.convertObject(t.mapValue,
|
|
5006
|
+
return this.convertObject(t.mapValue, e);
|
|
4997
5007
|
|
|
4998
5008
|
default:
|
|
4999
|
-
throw
|
|
5009
|
+
throw b();
|
|
5000
5010
|
}
|
|
5001
5011
|
}
|
|
5002
|
-
convertObject(t,
|
|
5003
|
-
const
|
|
5012
|
+
convertObject(t, e) {
|
|
5013
|
+
const n = {};
|
|
5004
5014
|
return Tt(t.fields, ((t, r) => {
|
|
5005
|
-
|
|
5006
|
-
})),
|
|
5015
|
+
n[t] = this.convertValue(r, e);
|
|
5016
|
+
})), n;
|
|
5007
5017
|
}
|
|
5008
5018
|
convertGeoPoint(t) {
|
|
5009
|
-
return new
|
|
5019
|
+
return new Tn(Nt(t.latitude), Nt(t.longitude));
|
|
5010
5020
|
}
|
|
5011
|
-
convertArray(t,
|
|
5012
|
-
return (t.values || []).map((t => this.convertValue(t,
|
|
5021
|
+
convertArray(t, e) {
|
|
5022
|
+
return (t.values || []).map((t => this.convertValue(t, e)));
|
|
5013
5023
|
}
|
|
5014
|
-
convertServerTimestamp(t,
|
|
5015
|
-
switch (
|
|
5024
|
+
convertServerTimestamp(t, e) {
|
|
5025
|
+
switch (e) {
|
|
5016
5026
|
case "previous":
|
|
5017
|
-
const
|
|
5018
|
-
return null ==
|
|
5027
|
+
const n = St(t);
|
|
5028
|
+
return null == n ? null : this.convertValue(n, e);
|
|
5019
5029
|
|
|
5020
5030
|
case "estimate":
|
|
5021
5031
|
return this.convertTimestamp(Ft(t));
|
|
@@ -5025,16 +5035,16 @@ class vr extends class {
|
|
|
5025
5035
|
}
|
|
5026
5036
|
}
|
|
5027
5037
|
convertTimestamp(t) {
|
|
5028
|
-
const
|
|
5029
|
-
return new
|
|
5038
|
+
const e = Vt(t);
|
|
5039
|
+
return new bt(e.seconds, e.nanos);
|
|
5030
5040
|
}
|
|
5031
|
-
convertDocumentKey(t,
|
|
5032
|
-
const
|
|
5033
|
-
|
|
5034
|
-
const r = new J(
|
|
5035
|
-
return r.isEqual(
|
|
5041
|
+
convertDocumentKey(t, e) {
|
|
5042
|
+
const n = Z.fromString(t);
|
|
5043
|
+
v(He(n));
|
|
5044
|
+
const r = new J(n.get(1), n.get(3)), s = new nt(n.popFirst(5));
|
|
5045
|
+
return r.isEqual(e) ||
|
|
5036
5046
|
// TODO(b/64130202): Somehow support foreign references.
|
|
5037
|
-
y(`Document ${s} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${
|
|
5047
|
+
y(`Document ${s} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${e.projectId}/${e.database}) instead.`),
|
|
5038
5048
|
s;
|
|
5039
5049
|
}
|
|
5040
5050
|
} {
|
|
@@ -5042,11 +5052,11 @@ class vr extends class {
|
|
|
5042
5052
|
super(), this.firestore = t;
|
|
5043
5053
|
}
|
|
5044
5054
|
convertBytes(t) {
|
|
5045
|
-
return new
|
|
5055
|
+
return new vn(t);
|
|
5046
5056
|
}
|
|
5047
5057
|
convertReference(t) {
|
|
5048
|
-
const
|
|
5049
|
-
return new
|
|
5058
|
+
const e = this.convertDocumentKey(t, this.firestore._databaseId);
|
|
5059
|
+
return new ln(this.firestore, /* converter= */ null, e);
|
|
5050
5060
|
}
|
|
5051
5061
|
}
|
|
5052
5062
|
|
|
@@ -5062,12 +5072,12 @@ class vr extends class {
|
|
|
5062
5072
|
* @param reference - The reference of the document to fetch.
|
|
5063
5073
|
* @returns A Promise resolved with a `DocumentSnapshot` containing the current
|
|
5064
5074
|
* document contents.
|
|
5065
|
-
*/ function
|
|
5066
|
-
const
|
|
5067
|
-
return
|
|
5068
|
-
|
|
5069
|
-
const r =
|
|
5070
|
-
return new
|
|
5075
|
+
*/ function Er(t) {
|
|
5076
|
+
const e = rn((t = ut(t, ln)).firestore), n = new vr(t.firestore);
|
|
5077
|
+
return tn(e, [ t._key ]).then((e => {
|
|
5078
|
+
v(1 === e.length);
|
|
5079
|
+
const r = e[0];
|
|
5080
|
+
return new Kn(t.firestore, n, t._key, r.isFoundDocument() ? r : null, t.converter);
|
|
5071
5081
|
}));
|
|
5072
5082
|
}
|
|
5073
5083
|
|
|
@@ -5082,33 +5092,33 @@ class vr extends class {
|
|
|
5082
5092
|
*
|
|
5083
5093
|
* @param query - The `Query` to execute.
|
|
5084
5094
|
* @returns A Promise that will be resolved with the results of the query.
|
|
5085
|
-
*/ function
|
|
5095
|
+
*/ function Tr(t) {
|
|
5086
5096
|
!function(t) {
|
|
5087
5097
|
if ("L" /* Last */ === t.limitType && 0 === t.explicitOrderBy.length) throw new U(O, "limitToLast() queries require specifying at least one orderBy() clause");
|
|
5088
|
-
}((t = ut(t,
|
|
5089
|
-
const
|
|
5090
|
-
return
|
|
5091
|
-
const r =
|
|
5098
|
+
}((t = ut(t, fn))._query);
|
|
5099
|
+
const e = rn(t.firestore), n = new vr(t.firestore);
|
|
5100
|
+
return en(e, t._query).then((e => {
|
|
5101
|
+
const r = e.map((e => new Jn(t.firestore, n, e.key, e, t.converter)));
|
|
5092
5102
|
return "L" /* Last */ === t._query.limitType &&
|
|
5093
5103
|
// Limit to last queries reverse the orderBy constraint that was
|
|
5094
5104
|
// specified by the user. As such, we need to reverse the order of the
|
|
5095
5105
|
// results to return the documents in the expected order.
|
|
5096
|
-
r.reverse(), new
|
|
5106
|
+
r.reverse(), new Xn(t, r);
|
|
5097
5107
|
}));
|
|
5098
5108
|
}
|
|
5099
5109
|
|
|
5100
|
-
function
|
|
5101
|
-
const r =
|
|
5102
|
-
return
|
|
5110
|
+
function Ir(t, e, n) {
|
|
5111
|
+
const r = br((t = ut(t, ln)).converter, e, n), s = $n(Dn(t.firestore), "setDoc", t._key, r, null !== t.converter, n);
|
|
5112
|
+
return Ze(rn(t.firestore), [ s.toMutation(t._key, Te.none()) ]);
|
|
5103
5113
|
}
|
|
5104
5114
|
|
|
5105
|
-
function
|
|
5106
|
-
const s =
|
|
5115
|
+
function Ar(t, e, n, ...r) {
|
|
5116
|
+
const s = Dn((t = ut(t, ln)).firestore);
|
|
5107
5117
|
// For Compat types, we have to "extract" the underlying types before
|
|
5108
5118
|
// performing validation.
|
|
5109
5119
|
let i;
|
|
5110
|
-
i = "string" == typeof (
|
|
5111
|
-
return
|
|
5120
|
+
i = "string" == typeof (e = l(e)) || e instanceof gn ? kn(s, "updateDoc", t._key, e, n, r) : Ln(s, "updateDoc", t._key, e);
|
|
5121
|
+
return Ze(rn(t.firestore), [ i.toMutation(t._key, Te.exists(!0)) ]);
|
|
5112
5122
|
}
|
|
5113
5123
|
|
|
5114
5124
|
/**
|
|
@@ -5122,8 +5132,8 @@ function Ir(t, n, e, ...r) {
|
|
|
5122
5132
|
* @param reference - A reference to the document to delete.
|
|
5123
5133
|
* @returns A `Promise` resolved once the document has been successfully
|
|
5124
5134
|
* deleted from the backend.
|
|
5125
|
-
*/ function
|
|
5126
|
-
return
|
|
5135
|
+
*/ function Rr(t) {
|
|
5136
|
+
return Ze(rn((t = ut(t, ln)).firestore), [ new Pe(t._key, Te.none()) ]);
|
|
5127
5137
|
}
|
|
5128
5138
|
|
|
5129
5139
|
/**
|
|
@@ -5140,9 +5150,9 @@ function Ir(t, n, e, ...r) {
|
|
|
5140
5150
|
* @throws Error - If the provided input is not a valid Firestore document.
|
|
5141
5151
|
* @returns A `Promise` resolved with a `DocumentReference` pointing to the
|
|
5142
5152
|
* newly created document after it has been written to the backend.
|
|
5143
|
-
*/ function
|
|
5144
|
-
const
|
|
5145
|
-
return
|
|
5153
|
+
*/ function Pr(t, e) {
|
|
5154
|
+
const n = pn(t = ut(t, dn)), r = br(t.converter, e), s = $n(Dn(t.firestore), "addDoc", n._key, r, null !== n.converter, {});
|
|
5155
|
+
return Ze(rn(t.firestore), [ s.toMutation(n._key, Te.exists(!1)) ]).then((() => n));
|
|
5146
5156
|
}
|
|
5147
5157
|
|
|
5148
5158
|
/**
|
|
@@ -5164,15 +5174,15 @@ function Ir(t, n, e, ...r) {
|
|
|
5164
5174
|
/**
|
|
5165
5175
|
* Returns a sentinel for use with {@link @firebase/firestore/lite#(updateDoc:1)} or
|
|
5166
5176
|
* {@link @firebase/firestore/lite#(setDoc:1)} with `{merge: true}` to mark a field for deletion.
|
|
5167
|
-
*/ function
|
|
5168
|
-
return new
|
|
5177
|
+
*/ function Vr() {
|
|
5178
|
+
return new Sn("deleteField");
|
|
5169
5179
|
}
|
|
5170
5180
|
|
|
5171
5181
|
/**
|
|
5172
5182
|
* Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
|
|
5173
5183
|
* include a server-generated timestamp in the written data.
|
|
5174
|
-
*/ function
|
|
5175
|
-
return new
|
|
5184
|
+
*/ function Nr() {
|
|
5185
|
+
return new xn("serverTimestamp");
|
|
5176
5186
|
}
|
|
5177
5187
|
|
|
5178
5188
|
/**
|
|
@@ -5186,10 +5196,10 @@ function Ir(t, n, e, ...r) {
|
|
|
5186
5196
|
* @param elements - The elements to union into the array.
|
|
5187
5197
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5188
5198
|
* `updateDoc()`.
|
|
5189
|
-
*/ function
|
|
5199
|
+
*/ function Dr(...t) {
|
|
5190
5200
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5191
5201
|
// update() since we'd need the Firestore instance to do this.
|
|
5192
|
-
return new
|
|
5202
|
+
return new qn("arrayUnion", t);
|
|
5193
5203
|
}
|
|
5194
5204
|
|
|
5195
5205
|
/**
|
|
@@ -5202,10 +5212,10 @@ function Ir(t, n, e, ...r) {
|
|
|
5202
5212
|
* @param elements - The elements to remove from the array.
|
|
5203
5213
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5204
5214
|
* `updateDoc()`
|
|
5205
|
-
*/ function
|
|
5215
|
+
*/ function $r(...t) {
|
|
5206
5216
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5207
5217
|
// update() since we'd need the Firestore instance to do this.
|
|
5208
|
-
return new
|
|
5218
|
+
return new On("arrayRemove", t);
|
|
5209
5219
|
}
|
|
5210
5220
|
|
|
5211
5221
|
/**
|
|
@@ -5226,8 +5236,8 @@ function Ir(t, n, e, ...r) {
|
|
|
5226
5236
|
* @param n - The value to increment by.
|
|
5227
5237
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5228
5238
|
* `updateDoc()`
|
|
5229
|
-
*/ function
|
|
5230
|
-
return new
|
|
5239
|
+
*/ function Sr(t) {
|
|
5240
|
+
return new Cn("increment", t);
|
|
5231
5241
|
}
|
|
5232
5242
|
|
|
5233
5243
|
/**
|
|
@@ -5253,25 +5263,25 @@ function Ir(t, n, e, ...r) {
|
|
|
5253
5263
|
* provides methods for adding writes to the write batch. None of the writes
|
|
5254
5264
|
* will be committed (or visible locally) until {@link WriteBatch.commit} is
|
|
5255
5265
|
* called.
|
|
5256
|
-
*/ class
|
|
5266
|
+
*/ class Fr {
|
|
5257
5267
|
/** @hideconstructor */
|
|
5258
|
-
constructor(t,
|
|
5259
|
-
this._firestore = t, this._commitHandler =
|
|
5260
|
-
this._dataReader =
|
|
5268
|
+
constructor(t, e) {
|
|
5269
|
+
this._firestore = t, this._commitHandler = e, this._mutations = [], this._committed = !1,
|
|
5270
|
+
this._dataReader = Dn(t);
|
|
5261
5271
|
}
|
|
5262
|
-
set(t,
|
|
5272
|
+
set(t, e, n) {
|
|
5263
5273
|
this._verifyNotCommitted();
|
|
5264
|
-
const r =
|
|
5265
|
-
return this._mutations.push(i.toMutation(r._key,
|
|
5274
|
+
const r = xr(t, this._firestore), s = br(r.converter, e, n), i = $n(this._dataReader, "WriteBatch.set", r._key, s, null !== r.converter, n);
|
|
5275
|
+
return this._mutations.push(i.toMutation(r._key, Te.none())), this;
|
|
5266
5276
|
}
|
|
5267
|
-
update(t,
|
|
5277
|
+
update(t, e, n, ...r) {
|
|
5268
5278
|
this._verifyNotCommitted();
|
|
5269
|
-
const s =
|
|
5279
|
+
const s = xr(t, this._firestore);
|
|
5270
5280
|
// For Compat types, we have to "extract" the underlying types before
|
|
5271
5281
|
// performing validation.
|
|
5272
5282
|
let i;
|
|
5273
|
-
return i = "string" == typeof (
|
|
5274
|
-
this._mutations.push(i.toMutation(s._key,
|
|
5283
|
+
return i = "string" == typeof (e = l(e)) || e instanceof gn ? kn(this._dataReader, "WriteBatch.update", s._key, e, n, r) : Ln(this._dataReader, "WriteBatch.update", s._key, e),
|
|
5284
|
+
this._mutations.push(i.toMutation(s._key, Te.exists(!0))), this;
|
|
5275
5285
|
}
|
|
5276
5286
|
/**
|
|
5277
5287
|
* Deletes the document referred to by the provided {@link DocumentReference}.
|
|
@@ -5280,8 +5290,8 @@ function Ir(t, n, e, ...r) {
|
|
|
5280
5290
|
* @returns This `WriteBatch` instance. Used for chaining method calls.
|
|
5281
5291
|
*/ delete(t) {
|
|
5282
5292
|
this._verifyNotCommitted();
|
|
5283
|
-
const
|
|
5284
|
-
return this._mutations = this._mutations.concat(new
|
|
5293
|
+
const e = xr(t, this._firestore);
|
|
5294
|
+
return this._mutations = this._mutations.concat(new Pe(e._key, Te.none())), this;
|
|
5285
5295
|
}
|
|
5286
5296
|
/**
|
|
5287
5297
|
* Commits all of the writes in this write batch as a single atomic unit.
|
|
@@ -5302,8 +5312,8 @@ function Ir(t, n, e, ...r) {
|
|
|
5302
5312
|
}
|
|
5303
5313
|
}
|
|
5304
5314
|
|
|
5305
|
-
function
|
|
5306
|
-
if ((t = l(t)).firestore !==
|
|
5315
|
+
function xr(t, e) {
|
|
5316
|
+
if ((t = l(t)).firestore !== e) throw new U(R, "Provided document reference is from a different Firestore instance.");
|
|
5307
5317
|
return t;
|
|
5308
5318
|
}
|
|
5309
5319
|
|
|
@@ -5319,9 +5329,9 @@ function Fr(t, n) {
|
|
|
5319
5329
|
*
|
|
5320
5330
|
* @returns A `WriteBatch` that can be used to atomically execute multiple
|
|
5321
5331
|
* writes.
|
|
5322
|
-
*/ function
|
|
5323
|
-
const
|
|
5324
|
-
return new
|
|
5332
|
+
*/ function qr(t) {
|
|
5333
|
+
const e = rn(t = ut(t, on));
|
|
5334
|
+
return new Fr(t, (t => Ze(e, t)));
|
|
5325
5335
|
}
|
|
5326
5336
|
|
|
5327
5337
|
/**
|
|
@@ -5343,7 +5353,7 @@ function Fr(t, n) {
|
|
|
5343
5353
|
/**
|
|
5344
5354
|
* Internal transaction object responsible for accumulating the mutations to
|
|
5345
5355
|
* perform and the base versions for any documents read.
|
|
5346
|
-
*/ class
|
|
5356
|
+
*/ class Or {
|
|
5347
5357
|
constructor(t) {
|
|
5348
5358
|
this.datastore = t,
|
|
5349
5359
|
// The version of each document that was read during this transaction.
|
|
@@ -5363,66 +5373,66 @@ function Fr(t, n) {
|
|
|
5363
5373
|
}
|
|
5364
5374
|
async lookup(t) {
|
|
5365
5375
|
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new U(R, "Firestore transactions require all reads to be executed before all writes.");
|
|
5366
|
-
const
|
|
5367
|
-
return
|
|
5376
|
+
const e = await tn(this.datastore, t);
|
|
5377
|
+
return e.forEach((t => this.recordVersion(t))), e;
|
|
5368
5378
|
}
|
|
5369
|
-
set(t,
|
|
5370
|
-
this.write(
|
|
5379
|
+
set(t, e) {
|
|
5380
|
+
this.write(e.toMutation(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5371
5381
|
}
|
|
5372
|
-
update(t,
|
|
5382
|
+
update(t, e) {
|
|
5373
5383
|
try {
|
|
5374
|
-
this.write(
|
|
5384
|
+
this.write(e.toMutation(t, this.preconditionForUpdate(t)));
|
|
5375
5385
|
} catch (t) {
|
|
5376
5386
|
this.lastWriteError = t;
|
|
5377
5387
|
}
|
|
5378
5388
|
this.writtenDocs.add(t.toString());
|
|
5379
5389
|
}
|
|
5380
5390
|
delete(t) {
|
|
5381
|
-
this.write(new
|
|
5391
|
+
this.write(new Pe(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5382
5392
|
}
|
|
5383
5393
|
async commit() {
|
|
5384
5394
|
if (this.ensureCommitNotCalled(), this.lastWriteError) throw this.lastWriteError;
|
|
5385
5395
|
const t = this.readVersions;
|
|
5386
5396
|
// For each mutation, note that the doc was written.
|
|
5387
|
-
this.mutations.forEach((
|
|
5388
|
-
t.delete(
|
|
5397
|
+
this.mutations.forEach((e => {
|
|
5398
|
+
t.delete(e.key.toString());
|
|
5389
5399
|
})),
|
|
5390
5400
|
// For each document that was read but not written to, we want to perform
|
|
5391
5401
|
// a `verify` operation.
|
|
5392
|
-
t.forEach(((t,
|
|
5393
|
-
const
|
|
5394
|
-
this.mutations.push(new
|
|
5395
|
-
})), await
|
|
5402
|
+
t.forEach(((t, e) => {
|
|
5403
|
+
const n = nt.fromPath(e);
|
|
5404
|
+
this.mutations.push(new Ve(n, this.precondition(n)));
|
|
5405
|
+
})), await Ze(this.datastore, this.mutations), this.committed = !0;
|
|
5396
5406
|
}
|
|
5397
5407
|
recordVersion(t) {
|
|
5398
|
-
let
|
|
5399
|
-
if (t.isFoundDocument())
|
|
5400
|
-
if (!t.isNoDocument()) throw
|
|
5408
|
+
let e;
|
|
5409
|
+
if (t.isFoundDocument()) e = t.version; else {
|
|
5410
|
+
if (!t.isNoDocument()) throw b();
|
|
5401
5411
|
// For deleted docs, we must use baseVersion 0 when we overwrite them.
|
|
5402
|
-
|
|
5412
|
+
e = vt.min();
|
|
5403
5413
|
}
|
|
5404
|
-
const
|
|
5405
|
-
if (
|
|
5406
|
-
if (!
|
|
5414
|
+
const n = this.readVersions.get(t.key.toString());
|
|
5415
|
+
if (n) {
|
|
5416
|
+
if (!e.isEqual(n))
|
|
5407
5417
|
// This transaction will fail no matter what.
|
|
5408
5418
|
throw new U(x, "Document version changed between two reads.");
|
|
5409
|
-
} else this.readVersions.set(t.key.toString(),
|
|
5419
|
+
} else this.readVersions.set(t.key.toString(), e);
|
|
5410
5420
|
}
|
|
5411
5421
|
/**
|
|
5412
5422
|
* Returns the version of this document when it was read in this transaction,
|
|
5413
5423
|
* as a precondition, or no precondition if it was not read.
|
|
5414
5424
|
*/ precondition(t) {
|
|
5415
|
-
const
|
|
5416
|
-
return !this.writtenDocs.has(t.toString()) &&
|
|
5425
|
+
const e = this.readVersions.get(t.toString());
|
|
5426
|
+
return !this.writtenDocs.has(t.toString()) && e ? Te.updateTime(e) : Te.none();
|
|
5417
5427
|
}
|
|
5418
5428
|
/**
|
|
5419
5429
|
* Returns the precondition for a document if the operation is an update.
|
|
5420
5430
|
*/ preconditionForUpdate(t) {
|
|
5421
|
-
const
|
|
5431
|
+
const e = this.readVersions.get(t.toString());
|
|
5422
5432
|
// The first time a document is written, we want to take into account the
|
|
5423
5433
|
// read time and existence
|
|
5424
|
-
if (!this.writtenDocs.has(t.toString()) &&
|
|
5425
|
-
if (
|
|
5434
|
+
if (!this.writtenDocs.has(t.toString()) && e) {
|
|
5435
|
+
if (e.isEqual(vt.min()))
|
|
5426
5436
|
// The document doesn't exist, so fail the transaction.
|
|
5427
5437
|
// This has to be validated locally because you can't send a
|
|
5428
5438
|
// precondition that a document does not exist without changing the
|
|
@@ -5434,11 +5444,11 @@ function Fr(t, n) {
|
|
|
5434
5444
|
// transaction.
|
|
5435
5445
|
throw new U(R, "Can't update a document that doesn't exist.");
|
|
5436
5446
|
// Document exists, base precondition on document update time.
|
|
5437
|
-
return
|
|
5447
|
+
return Te.updateTime(e);
|
|
5438
5448
|
}
|
|
5439
5449
|
// Document was not read, so we just use the preconditions for a blind
|
|
5440
5450
|
// update.
|
|
5441
|
-
return
|
|
5451
|
+
return Te.exists(!0);
|
|
5442
5452
|
}
|
|
5443
5453
|
write(t) {
|
|
5444
5454
|
this.ensureCommitNotCalled(), this.mutations.push(t);
|
|
@@ -5466,20 +5476,20 @@ function Fr(t, n) {
|
|
|
5466
5476
|
* TransactionRunner encapsulates the logic needed to run and retry transactions
|
|
5467
5477
|
* with backoff.
|
|
5468
5478
|
*/
|
|
5469
|
-
class
|
|
5470
|
-
constructor(t,
|
|
5471
|
-
this.asyncQueue = t, this.datastore =
|
|
5472
|
-
this.Tt = 5, this.It = new
|
|
5479
|
+
class Cr {
|
|
5480
|
+
constructor(t, e, n, r) {
|
|
5481
|
+
this.asyncQueue = t, this.datastore = e, this.updateFunction = n, this.deferred = r,
|
|
5482
|
+
this.Tt = 5, this.It = new Je(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
|
|
5473
5483
|
}
|
|
5474
5484
|
/** Runs the transaction and sets the result on deferred. */ run() {
|
|
5475
5485
|
this.Tt -= 1, this.At();
|
|
5476
5486
|
}
|
|
5477
5487
|
At() {
|
|
5478
5488
|
this.It.W((async () => {
|
|
5479
|
-
const t = new
|
|
5480
|
-
|
|
5489
|
+
const t = new Or(this.datastore), e = this.Rt(t);
|
|
5490
|
+
e && e.then((e => {
|
|
5481
5491
|
this.asyncQueue.enqueueAndForget((() => t.commit().then((() => {
|
|
5482
|
-
this.deferred.resolve(
|
|
5492
|
+
this.deferred.resolve(e);
|
|
5483
5493
|
})).catch((t => {
|
|
5484
5494
|
this.Pt(t);
|
|
5485
5495
|
}))));
|
|
@@ -5490,8 +5500,8 @@ class Or {
|
|
|
5490
5500
|
}
|
|
5491
5501
|
Rt(t) {
|
|
5492
5502
|
try {
|
|
5493
|
-
const
|
|
5494
|
-
return !at(
|
|
5503
|
+
const e = this.updateFunction(t);
|
|
5504
|
+
return !at(e) && e.catch && e.then ? e : (this.deferred.reject(Error("Transaction callback must return a Promise")),
|
|
5495
5505
|
null);
|
|
5496
5506
|
} catch (t) {
|
|
5497
5507
|
// Do not retry errors thrown by user provided updateFunction.
|
|
@@ -5506,8 +5516,8 @@ class Or {
|
|
|
5506
5516
|
if ("FirebaseError" === t.name) {
|
|
5507
5517
|
// In transactions, the backend will fail outdated reads with FAILED_PRECONDITION and
|
|
5508
5518
|
// non-matching document versions with ABORTED. These errors should be retried.
|
|
5509
|
-
const
|
|
5510
|
-
return "aborted" ===
|
|
5519
|
+
const e = t.code;
|
|
5520
|
+
return "aborted" === e || "failed-precondition" === e || !
|
|
5511
5521
|
/**
|
|
5512
5522
|
* Determines whether an error code represents a permanent error when received
|
|
5513
5523
|
* in response to a non-write operation.
|
|
@@ -5517,7 +5527,7 @@ class Or {
|
|
|
5517
5527
|
function(t) {
|
|
5518
5528
|
switch (t) {
|
|
5519
5529
|
default:
|
|
5520
|
-
return
|
|
5530
|
+
return b();
|
|
5521
5531
|
|
|
5522
5532
|
case I:
|
|
5523
5533
|
case A:
|
|
@@ -5544,7 +5554,7 @@ class Or {
|
|
|
5544
5554
|
case k:
|
|
5545
5555
|
return !0;
|
|
5546
5556
|
}
|
|
5547
|
-
}(
|
|
5557
|
+
}(e);
|
|
5548
5558
|
}
|
|
5549
5559
|
return !1;
|
|
5550
5560
|
}
|
|
@@ -5566,7 +5576,7 @@ class Or {
|
|
|
5566
5576
|
* See the License for the specific language governing permissions and
|
|
5567
5577
|
* limitations under the License.
|
|
5568
5578
|
*/
|
|
5569
|
-
/** The Platform's 'document' implementation or null if not available. */ function
|
|
5579
|
+
/** The Platform's 'document' implementation or null if not available. */ function Lr() {
|
|
5570
5580
|
// `document` is not always available, e.g. in ReactNative and WebWorkers.
|
|
5571
5581
|
// eslint-disable-next-line no-restricted-globals
|
|
5572
5582
|
return "undefined" != typeof document ? document : null;
|
|
@@ -5598,9 +5608,9 @@ class Or {
|
|
|
5598
5608
|
* Note: We implement `PromiseLike` instead of `Promise`, as the `Promise` type
|
|
5599
5609
|
* in newer versions of TypeScript defines `finally`, which is not available in
|
|
5600
5610
|
* IE.
|
|
5601
|
-
*/ class
|
|
5602
|
-
constructor(t,
|
|
5603
|
-
this.asyncQueue = t, this.timerId =
|
|
5611
|
+
*/ class kr {
|
|
5612
|
+
constructor(t, e, n, r, s) {
|
|
5613
|
+
this.asyncQueue = t, this.timerId = e, this.targetTimeMs = n, this.op = r, this.removalCallback = s,
|
|
5604
5614
|
this.deferred = new j, this.then = this.deferred.promise.then.bind(this.deferred.promise),
|
|
5605
5615
|
// It's normal for the deferred promise to be canceled (due to cancellation)
|
|
5606
5616
|
// and so we attach a dummy catch callback to avoid
|
|
@@ -5620,9 +5630,9 @@ class Or {
|
|
|
5620
5630
|
* from its delayedOperations list.
|
|
5621
5631
|
* PORTING NOTE: This exists to prevent making removeDelayedOperation() and
|
|
5622
5632
|
* the DelayedOperation class public.
|
|
5623
|
-
*/ static createAndSchedule(t,
|
|
5624
|
-
const i = Date.now() +
|
|
5625
|
-
return o.start(
|
|
5633
|
+
*/ static createAndSchedule(t, e, n, r, s) {
|
|
5634
|
+
const i = Date.now() + n, o = new kr(t, e, i, r, s);
|
|
5635
|
+
return o.start(n), o;
|
|
5626
5636
|
}
|
|
5627
5637
|
/**
|
|
5628
5638
|
* Starts the timer. This is called immediately after construction by
|
|
@@ -5670,7 +5680,7 @@ class Or {
|
|
|
5670
5680
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5671
5681
|
* See the License for the specific language governing permissions and
|
|
5672
5682
|
* limitations under the License.
|
|
5673
|
-
*/ class
|
|
5683
|
+
*/ class Ur {
|
|
5674
5684
|
constructor() {
|
|
5675
5685
|
// The last promise in the queue.
|
|
5676
5686
|
this.Nt = Promise.resolve(),
|
|
@@ -5693,15 +5703,15 @@ class Or {
|
|
|
5693
5703
|
// List of TimerIds to fast-forward delays for.
|
|
5694
5704
|
this.Ot = [],
|
|
5695
5705
|
// Backoff timer used to schedule retries for retryable operations
|
|
5696
|
-
this.It = new
|
|
5706
|
+
this.It = new Je(this, "async_queue_retry" /* AsyncQueueRetry */),
|
|
5697
5707
|
// Visibility handler that triggers an immediate retry of all retryable
|
|
5698
5708
|
// operations. Meant to speed up recovery when we regain file system access
|
|
5699
5709
|
// after page comes into foreground.
|
|
5700
5710
|
this.Ct = () => {
|
|
5701
|
-
const t =
|
|
5711
|
+
const t = Lr();
|
|
5702
5712
|
t && p("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.It.H();
|
|
5703
5713
|
};
|
|
5704
|
-
const t =
|
|
5714
|
+
const t = Lr();
|
|
5705
5715
|
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.Ct);
|
|
5706
5716
|
}
|
|
5707
5717
|
get isShuttingDown() {
|
|
@@ -5722,8 +5732,8 @@ class Or {
|
|
|
5722
5732
|
enterRestrictedMode(t) {
|
|
5723
5733
|
if (!this.$t) {
|
|
5724
5734
|
this.$t = !0, this.qt = t || !1;
|
|
5725
|
-
const
|
|
5726
|
-
|
|
5735
|
+
const e = Lr();
|
|
5736
|
+
e && "function" == typeof e.removeEventListener && e.removeEventListener("visibilitychange", this.Ct);
|
|
5727
5737
|
}
|
|
5728
5738
|
}
|
|
5729
5739
|
enqueue(t) {
|
|
@@ -5733,9 +5743,9 @@ class Or {
|
|
|
5733
5743
|
// Create a deferred Promise that we can return to the callee. This
|
|
5734
5744
|
// allows us to return a "hanging Promise" only to the callee and still
|
|
5735
5745
|
// advance the queue even when the operation is not run.
|
|
5736
|
-
const
|
|
5737
|
-
return this.kt((() => this.$t && this.qt ? Promise.resolve() : (t().then(
|
|
5738
|
-
|
|
5746
|
+
const e = new j;
|
|
5747
|
+
return this.kt((() => this.$t && this.qt ? Promise.resolve() : (t().then(e.resolve, e.reject),
|
|
5748
|
+
e.promise))).then((() => e.promise));
|
|
5739
5749
|
}
|
|
5740
5750
|
enqueueRetryable(t) {
|
|
5741
5751
|
this.enqueueAndForget((() => (this.Dt.push(t), this.Ut())));
|
|
@@ -5805,18 +5815,18 @@ class Or {
|
|
|
5805
5815
|
}
|
|
5806
5816
|
}
|
|
5807
5817
|
kt(t) {
|
|
5808
|
-
const
|
|
5818
|
+
const e = this.Nt.then((() => (this.xt = !0, t().catch((t => {
|
|
5809
5819
|
this.Ft = t, this.xt = !1;
|
|
5810
|
-
const
|
|
5820
|
+
const e =
|
|
5811
5821
|
/**
|
|
5812
5822
|
* Chrome includes Error.message in Error.stack. Other browsers do not.
|
|
5813
5823
|
* This returns expected output of message + stack when available.
|
|
5814
5824
|
* @param error - Error or FirestoreError
|
|
5815
5825
|
*/
|
|
5816
5826
|
function(t) {
|
|
5817
|
-
let
|
|
5818
|
-
t.stack && (
|
|
5819
|
-
return
|
|
5827
|
+
let e = t.message || "";
|
|
5828
|
+
t.stack && (e = t.stack.includes(t.message) ? t.stack : t.message + "\n" + t.stack);
|
|
5829
|
+
return e;
|
|
5820
5830
|
}
|
|
5821
5831
|
/**
|
|
5822
5832
|
* @license
|
|
@@ -5846,19 +5856,19 @@ class Or {
|
|
|
5846
5856
|
// Re-throw the error so that this.tail becomes a rejected Promise and
|
|
5847
5857
|
// all further attempts to chain (via .then) will just short-circuit
|
|
5848
5858
|
// and return the rejected Promise.
|
|
5849
|
-
throw y("INTERNAL UNHANDLED ERROR: ",
|
|
5859
|
+
throw y("INTERNAL UNHANDLED ERROR: ", e), t;
|
|
5850
5860
|
})).then((t => (this.xt = !1, t))))));
|
|
5851
|
-
return this.Nt =
|
|
5861
|
+
return this.Nt = e, e;
|
|
5852
5862
|
}
|
|
5853
|
-
enqueueAfterDelay(t,
|
|
5863
|
+
enqueueAfterDelay(t, e, n) {
|
|
5854
5864
|
this.Lt(),
|
|
5855
5865
|
// Fast-forward delays for timerIds that have been overriden.
|
|
5856
|
-
this.Ot.indexOf(t) > -1 && (
|
|
5857
|
-
const r =
|
|
5866
|
+
this.Ot.indexOf(t) > -1 && (e = 0);
|
|
5867
|
+
const r = kr.createAndSchedule(this, t, e, n, (t => this.jt(t)));
|
|
5858
5868
|
return this.St.push(r), r;
|
|
5859
5869
|
}
|
|
5860
5870
|
Lt() {
|
|
5861
|
-
this.Ft &&
|
|
5871
|
+
this.Ft && b();
|
|
5862
5872
|
}
|
|
5863
5873
|
verifyOperationInProgress() {}
|
|
5864
5874
|
/**
|
|
@@ -5878,7 +5888,7 @@ class Or {
|
|
|
5878
5888
|
* For Tests: Determine if a delayed operation with a particular TimerId
|
|
5879
5889
|
* exists.
|
|
5880
5890
|
*/ Bt(t) {
|
|
5881
|
-
for (const
|
|
5891
|
+
for (const e of this.St) if (e.timerId === t) return !0;
|
|
5882
5892
|
return !1;
|
|
5883
5893
|
}
|
|
5884
5894
|
/**
|
|
@@ -5891,8 +5901,8 @@ class Or {
|
|
|
5891
5901
|
// Note that draining may generate more delayed ops, so we do that first.
|
|
5892
5902
|
return this.Mt().then((() => {
|
|
5893
5903
|
// Run ops in the same order they'd run if they ran naturally.
|
|
5894
|
-
this.St.sort(((t,
|
|
5895
|
-
for (const
|
|
5904
|
+
this.St.sort(((t, e) => t.targetTimeMs - e.targetTimeMs));
|
|
5905
|
+
for (const e of this.St) if (e.skipDelay(), "all" /* All */ !== t && e.timerId === t) break;
|
|
5896
5906
|
return this.Mt();
|
|
5897
5907
|
}));
|
|
5898
5908
|
}
|
|
@@ -5903,15 +5913,15 @@ class Or {
|
|
|
5903
5913
|
}
|
|
5904
5914
|
/** Called once a DelayedOperation is run or canceled. */ jt(t) {
|
|
5905
5915
|
// NOTE: indexOf / slice are O(n), but delayedOperations is expected to be small.
|
|
5906
|
-
const
|
|
5907
|
-
this.St.splice(
|
|
5916
|
+
const e = this.St.indexOf(t);
|
|
5917
|
+
this.St.splice(e, 1);
|
|
5908
5918
|
}
|
|
5909
5919
|
}
|
|
5910
5920
|
|
|
5911
|
-
class
|
|
5921
|
+
class jr {
|
|
5912
5922
|
/** @hideconstructor */
|
|
5913
|
-
constructor(t,
|
|
5914
|
-
this._firestore = t, this._transaction =
|
|
5923
|
+
constructor(t, e) {
|
|
5924
|
+
this._firestore = t, this._transaction = e, this._dataReader = Dn(t);
|
|
5915
5925
|
}
|
|
5916
5926
|
/**
|
|
5917
5927
|
* Reads the document referenced by the provided {@link DocumentReference}.
|
|
@@ -5919,25 +5929,25 @@ class Ur {
|
|
|
5919
5929
|
* @param documentRef - A reference to the document to be read.
|
|
5920
5930
|
* @returns A `DocumentSnapshot` with the read data.
|
|
5921
5931
|
*/ get(t) {
|
|
5922
|
-
const
|
|
5923
|
-
return this._transaction.lookup([
|
|
5924
|
-
if (!t || 1 !== t.length) return
|
|
5932
|
+
const e = xr(t, this._firestore), n = new vr(this._firestore);
|
|
5933
|
+
return this._transaction.lookup([ e._key ]).then((t => {
|
|
5934
|
+
if (!t || 1 !== t.length) return b();
|
|
5925
5935
|
const r = t[0];
|
|
5926
|
-
if (r.isFoundDocument()) return new
|
|
5927
|
-
if (r.isNoDocument()) return new
|
|
5928
|
-
throw
|
|
5936
|
+
if (r.isFoundDocument()) return new Kn(this._firestore, n, r.key, r, e.converter);
|
|
5937
|
+
if (r.isNoDocument()) return new Kn(this._firestore, n, e._key, null, e.converter);
|
|
5938
|
+
throw b();
|
|
5929
5939
|
}));
|
|
5930
5940
|
}
|
|
5931
|
-
set(t,
|
|
5932
|
-
const r =
|
|
5941
|
+
set(t, e, n) {
|
|
5942
|
+
const r = xr(t, this._firestore), s = br(r.converter, e, n), i = $n(this._dataReader, "Transaction.set", r._key, s, null !== r.converter, n);
|
|
5933
5943
|
return this._transaction.set(r._key, i), this;
|
|
5934
5944
|
}
|
|
5935
|
-
update(t,
|
|
5936
|
-
const s =
|
|
5945
|
+
update(t, e, n, ...r) {
|
|
5946
|
+
const s = xr(t, this._firestore);
|
|
5937
5947
|
// For Compat types, we have to "extract" the underlying types before
|
|
5938
5948
|
// performing validation.
|
|
5939
5949
|
let i;
|
|
5940
|
-
return i = "string" == typeof (
|
|
5950
|
+
return i = "string" == typeof (e = l(e)) || e instanceof gn ? kn(this._dataReader, "Transaction.update", s._key, e, n, r) : Ln(this._dataReader, "Transaction.update", s._key, e),
|
|
5941
5951
|
this._transaction.update(s._key, i), this;
|
|
5942
5952
|
}
|
|
5943
5953
|
/**
|
|
@@ -5946,8 +5956,8 @@ class Ur {
|
|
|
5946
5956
|
* @param documentRef - A reference to the document to be deleted.
|
|
5947
5957
|
* @returns This `Transaction` instance. Used for chaining method calls.
|
|
5948
5958
|
*/ delete(t) {
|
|
5949
|
-
const
|
|
5950
|
-
return this._transaction.delete(
|
|
5959
|
+
const e = xr(t, this._firestore);
|
|
5960
|
+
return this._transaction.delete(e._key), this;
|
|
5951
5961
|
}
|
|
5952
5962
|
}
|
|
5953
5963
|
|
|
@@ -5967,9 +5977,9 @@ class Ur {
|
|
|
5967
5977
|
* (the `updateFunction` returned a failed promise), the promise returned by the
|
|
5968
5978
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
5969
5979
|
* rejected promise with the corresponding failure error is returned.
|
|
5970
|
-
*/ function
|
|
5971
|
-
const
|
|
5972
|
-
return new
|
|
5980
|
+
*/ function Mr(t, e) {
|
|
5981
|
+
const n = rn(t = ut(t, on)), r = new j;
|
|
5982
|
+
return new Cr(new Ur, n, (n => e(new jr(t, n))), r).run(), r.promise;
|
|
5973
5983
|
}
|
|
5974
5984
|
|
|
5975
5985
|
/**
|
|
@@ -5981,12 +5991,12 @@ class Ur {
|
|
|
5981
5991
|
* @packageDocumentation
|
|
5982
5992
|
*/ !function(t) {
|
|
5983
5993
|
d = t;
|
|
5984
|
-
}(`${s}_lite`),
|
|
5985
|
-
const
|
|
5986
|
-
return
|
|
5994
|
+
}(`${s}_lite`), n(new i("firestore/lite", ((t, {options: e}) => {
|
|
5995
|
+
const n = t.getProvider("app").getImmediate(), r = new on(n, new G(t.getProvider("auth-internal")), new H(t.getProvider("app-check-internal")));
|
|
5996
|
+
return e && r._setSettings(e), r;
|
|
5987
5997
|
}), "PUBLIC")),
|
|
5988
5998
|
// RUNTIME_ENV and BUILD_TARGET are replaced by real values during the compilation
|
|
5989
|
-
r("firestore-lite", "3.4.8-canary.
|
|
5999
|
+
r("firestore-lite", "3.4.8-canary.d8be8bf1c", "rn"), r("firestore-lite", "3.4.8-canary.d8be8bf1c", "esm2017");
|
|
5990
6000
|
|
|
5991
|
-
export {
|
|
6001
|
+
export { vn as Bytes, dn as CollectionReference, ln as DocumentReference, Kn as DocumentSnapshot, gn as FieldPath, En as FieldValue, on as Firestore, U as FirestoreError, Tn as GeoPoint, fn as Query, er as QueryConstraint, Jn as QueryDocumentSnapshot, Xn as QuerySnapshot, bt as Timestamp, jr as Transaction, Fr as WriteBatch, Pr as addDoc, $r as arrayRemove, Dr as arrayUnion, wn as collection, mn as collectionGroup, an as connectFirestoreEmulator, Rr as deleteDoc, Vr as deleteField, pn as doc, bn as documentId, mr as endAt, wr as endBefore, Er as getDoc, Tr as getDocs, cn as getFirestore, Sr as increment, un as initializeFirestore, cr as limit, ar as limitToLast, or as orderBy, nr as query, _n as queryEqual, yn as refEqual, Mr as runTransaction, Nr as serverTimestamp, Ir as setDoc, m as setLogLevel, Zn as snapshotEqual, fr as startAfter, lr as startAt, hn as terminate, Ar as updateDoc, sr as where, qr as writeBatch };
|
|
5992
6002
|
//# sourceMappingURL=index.rn.esm2017.js.map
|