@firebase/firestore 3.5.0-canary.ee871fc0b → 3.5.0-canary.fdd4ab464
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/api/database.d.ts +9 -9
- package/dist/firestore/src/lite-api/database.d.ts +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.esm2017.js +2830 -2823
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +2785 -2778
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +11 -3
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +12 -4
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +2845 -2838
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +10 -10
- package/dist/lite/firestore/src/api/database.d.ts +9 -9
- package/dist/lite/firestore/src/lite-api/database.d.ts +1 -1
- package/dist/lite/index.browser.esm2017.js +898 -891
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +854 -847
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.node.cjs.js +11 -3
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +12 -4
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +905 -898
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +113 -113
- package/dist/lite/packages/firestore/src/api/database.d.ts +9 -9
- package/dist/lite/packages/firestore/src/lite-api/database.d.ts +1 -1
- package/dist/packages/firestore/dist/index.esm2017.d.ts +164 -164
- package/dist/packages/firestore/src/api/database.d.ts +9 -9
- package/dist/packages/firestore/src/lite-api/database.d.ts +1 -1
- package/dist/private.d.ts +8 -8
- package/package.json +9 -9
|
@@ -4,7 +4,7 @@ import { Component as i } from "@firebase/component";
|
|
|
4
4
|
|
|
5
5
|
import { Logger as o, LogLevel as u } from "@firebase/logger";
|
|
6
6
|
|
|
7
|
-
import { FirebaseError as c, base64 as a,
|
|
7
|
+
import { FirebaseError as c, base64 as a, getDefaultEmulatorHost as h, createMockUserToken as l, getModularInstance as f, deepEqual as d } from "@firebase/util";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @license
|
|
@@ -26,7 +26,7 @@ import { FirebaseError as c, base64 as a, createMockUserToken as h, getModularIn
|
|
|
26
26
|
* Simple wrapper around a nullable UID. Mostly exists to make code more
|
|
27
27
|
* readable.
|
|
28
28
|
*/
|
|
29
|
-
class
|
|
29
|
+
class w {
|
|
30
30
|
constructor(t) {
|
|
31
31
|
this.uid = t;
|
|
32
32
|
}
|
|
@@ -44,11 +44,11 @@ class d {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
/** A user with a null UID. */
|
|
47
|
+
/** A user with a null UID. */ w.UNAUTHENTICATED = new w(null),
|
|
48
48
|
// TODO(mikelehen): Look into getting a proper uid-equivalent for
|
|
49
49
|
// non-FirebaseAuth providers.
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
w.GOOGLE_CREDENTIALS = new w("google-credentials-uid"), w.FIRST_PARTY = new w("first-party-uid"),
|
|
51
|
+
w.MOCK_USER = new w("mock-user");
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* @license
|
|
@@ -66,7 +66,7 @@ d.MOCK_USER = new d("mock-user");
|
|
|
66
66
|
* See the License for the specific language governing permissions and
|
|
67
67
|
* limitations under the License.
|
|
68
68
|
*/
|
|
69
|
-
let
|
|
69
|
+
let m = "9.10.0-canary.fdd4ab464";
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* @license
|
|
@@ -84,7 +84,7 @@ let w = "9.10.0-canary.ee871fc0b";
|
|
|
84
84
|
* See the License for the specific language governing permissions and
|
|
85
85
|
* limitations under the License.
|
|
86
86
|
*/
|
|
87
|
-
const
|
|
87
|
+
const p = new o("@firebase/firestore");
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
90
|
* Sets the verbosity of Cloud Firestore logs (debug, error, or silent).
|
|
@@ -98,36 +98,36 @@ const m = new o("@firebase/firestore");
|
|
|
98
98
|
* <li>`error` to log errors only.</li>
|
|
99
99
|
* <li><code>`silent` to turn off logging.</li>
|
|
100
100
|
* </ul>
|
|
101
|
-
*/ function
|
|
102
|
-
|
|
101
|
+
*/ function y(t) {
|
|
102
|
+
p.setLogLevel(t);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
function
|
|
106
|
-
if (
|
|
107
|
-
const n = e.map(
|
|
108
|
-
|
|
105
|
+
function g(t, ...e) {
|
|
106
|
+
if (p.logLevel <= u.DEBUG) {
|
|
107
|
+
const n = e.map(b);
|
|
108
|
+
p.debug(`Firestore (${m}): ${t}`, ...n);
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
function
|
|
113
|
-
if (
|
|
114
|
-
const n = e.map(
|
|
115
|
-
|
|
112
|
+
function _(t, ...e) {
|
|
113
|
+
if (p.logLevel <= u.ERROR) {
|
|
114
|
+
const n = e.map(b);
|
|
115
|
+
p.error(`Firestore (${m}): ${t}`, ...n);
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
120
|
* @internal
|
|
121
|
-
*/ function
|
|
122
|
-
if (
|
|
123
|
-
const n = e.map(
|
|
124
|
-
|
|
121
|
+
*/ function v(t, ...e) {
|
|
122
|
+
if (p.logLevel <= u.WARN) {
|
|
123
|
+
const n = e.map(b);
|
|
124
|
+
p.warn(`Firestore (${m}): ${t}`, ...n);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
/**
|
|
129
129
|
* Converts an additional log parameter to a string representation.
|
|
130
|
-
*/ function
|
|
130
|
+
*/ function b(t) {
|
|
131
131
|
if ("string" == typeof t) return t;
|
|
132
132
|
try {
|
|
133
133
|
return e = t, JSON.stringify(e);
|
|
@@ -178,14 +178,14 @@ function g(t, ...e) {
|
|
|
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 E(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 e = `FIRESTORE (${
|
|
184
|
+
const e = `FIRESTORE (${m}) 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
|
|
188
|
+
throw _(e), new Error(e);
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
/**
|
|
@@ -193,14 +193,14 @@ function g(t, ...e) {
|
|
|
193
193
|
* given message if it did.
|
|
194
194
|
*
|
|
195
195
|
* Messages are stripped in production builds.
|
|
196
|
-
*/ function
|
|
197
|
-
t ||
|
|
196
|
+
*/ function I(t, e) {
|
|
197
|
+
t || E();
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
/**
|
|
201
201
|
* Casts `obj` to `T`. In non-production builds, verifies that `obj` is an
|
|
202
202
|
* instance of `T` before casting.
|
|
203
|
-
*/ function
|
|
203
|
+
*/ function T(t,
|
|
204
204
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
205
205
|
e) {
|
|
206
206
|
return t;
|
|
@@ -221,9 +221,9 @@ e) {
|
|
|
221
221
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
222
222
|
* See the License for the specific language governing permissions and
|
|
223
223
|
* limitations under the License.
|
|
224
|
-
*/ const
|
|
224
|
+
*/ const A = "ok", R = "cancelled", P = "unknown", V = "invalid-argument", N = "deadline-exceeded", $ = "not-found", D = "already-exists", x = "permission-denied", S = "unauthenticated", F = "resource-exhausted", q = "failed-precondition", O = "aborted", k = "out-of-range", C = "unimplemented", L = "internal", M = "unavailable", U = "data-loss";
|
|
225
225
|
|
|
226
|
-
/** An error returned by a Firestore operation. */ class
|
|
226
|
+
/** An error returned by a Firestore operation. */ class j extends c {
|
|
227
227
|
/** @hideconstructor */
|
|
228
228
|
constructor(
|
|
229
229
|
/**
|
|
@@ -257,7 +257,7 @@ e) {
|
|
|
257
257
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
258
258
|
* See the License for the specific language governing permissions and
|
|
259
259
|
* limitations under the License.
|
|
260
|
-
*/ class
|
|
260
|
+
*/ class B {
|
|
261
261
|
constructor() {
|
|
262
262
|
this.promise = new Promise(((t, e) => {
|
|
263
263
|
this.resolve = t, this.reject = e;
|
|
@@ -280,7 +280,7 @@ e) {
|
|
|
280
280
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
281
281
|
* See the License for the specific language governing permissions and
|
|
282
282
|
* limitations under the License.
|
|
283
|
-
*/ class
|
|
283
|
+
*/ class Q {
|
|
284
284
|
constructor(t, e) {
|
|
285
285
|
this.user = e, this.type = "OAuth", this.headers = new Map, this.headers.set("Authorization", `Bearer ${t}`);
|
|
286
286
|
}
|
|
@@ -289,14 +289,14 @@ e) {
|
|
|
289
289
|
/**
|
|
290
290
|
* A CredentialsProvider that always yields an empty token.
|
|
291
291
|
* @internal
|
|
292
|
-
*/ class
|
|
292
|
+
*/ class z {
|
|
293
293
|
getToken() {
|
|
294
294
|
return Promise.resolve(null);
|
|
295
295
|
}
|
|
296
296
|
invalidateToken() {}
|
|
297
297
|
start(t, e) {
|
|
298
298
|
// Fire with initial user.
|
|
299
|
-
t.enqueueRetryable((() => e(
|
|
299
|
+
t.enqueueRetryable((() => e(w.UNAUTHENTICATED)));
|
|
300
300
|
}
|
|
301
301
|
shutdown() {}
|
|
302
302
|
}
|
|
@@ -304,7 +304,7 @@ e) {
|
|
|
304
304
|
/**
|
|
305
305
|
* A CredentialsProvider that always returns a constant token. Used for
|
|
306
306
|
* emulator token mocking.
|
|
307
|
-
*/ class
|
|
307
|
+
*/ class W {
|
|
308
308
|
constructor(t) {
|
|
309
309
|
this.token = t,
|
|
310
310
|
/**
|
|
@@ -328,15 +328,15 @@ e) {
|
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
330
|
|
|
331
|
-
/** Credential provider for the Lite SDK. */ class
|
|
331
|
+
/** Credential provider for the Lite SDK. */ class G {
|
|
332
332
|
constructor(t) {
|
|
333
333
|
this.auth = null, t.onInit((t => {
|
|
334
334
|
this.auth = t;
|
|
335
335
|
}));
|
|
336
336
|
}
|
|
337
337
|
getToken() {
|
|
338
|
-
return this.auth ? this.auth.getToken().then((t => t ? (
|
|
339
|
-
new
|
|
338
|
+
return this.auth ? this.auth.getToken().then((t => t ? (I("string" == typeof t.accessToken),
|
|
339
|
+
new Q(t.accessToken, new w(this.auth.getUid()))) : null)) : Promise.resolve(null);
|
|
340
340
|
}
|
|
341
341
|
invalidateToken() {}
|
|
342
342
|
start(t, e) {}
|
|
@@ -349,15 +349,15 @@ e) {
|
|
|
349
349
|
* Technically this may no longer be necessary since the SDK should gracefully
|
|
350
350
|
* recover from unauthenticated errors (see b/33147818 for context), but it's
|
|
351
351
|
* safer to keep the implementation as-is.
|
|
352
|
-
*/ class
|
|
352
|
+
*/ class K {
|
|
353
353
|
constructor(t, e, n, r) {
|
|
354
|
-
this.t = t, this.i = e, this.o = n, this.u = r, this.type = "FirstParty", this.user =
|
|
354
|
+
this.t = t, this.i = e, this.o = n, this.u = r, this.type = "FirstParty", this.user = w.FIRST_PARTY,
|
|
355
355
|
this.h = new Map;
|
|
356
356
|
}
|
|
357
357
|
/** Gets an authorization token, using a provided factory function, or falling back to First Party GAPI. */ l() {
|
|
358
358
|
return this.u ? this.u() : (
|
|
359
359
|
// Make sure this really is a Gapi client.
|
|
360
|
-
|
|
360
|
+
I(!("object" != typeof this.t || null === this.t || !this.t.auth || !this.t.auth.getAuthHeaderValueForFirstParty)),
|
|
361
361
|
this.t.auth.getAuthHeaderValueForFirstParty([]));
|
|
362
362
|
}
|
|
363
363
|
get headers() {
|
|
@@ -373,36 +373,36 @@ e) {
|
|
|
373
373
|
* Provides user credentials required for the Firestore JavaScript SDK
|
|
374
374
|
* to authenticate the user, using technique that is only available
|
|
375
375
|
* to applications hosted by Google.
|
|
376
|
-
*/ class
|
|
376
|
+
*/ class Y {
|
|
377
377
|
constructor(t, e, n, r) {
|
|
378
378
|
this.t = t, this.i = e, this.o = n, this.u = r;
|
|
379
379
|
}
|
|
380
380
|
getToken() {
|
|
381
|
-
return Promise.resolve(new
|
|
381
|
+
return Promise.resolve(new K(this.t, this.i, this.o, this.u));
|
|
382
382
|
}
|
|
383
383
|
start(t, e) {
|
|
384
384
|
// Fire with initial uid.
|
|
385
|
-
t.enqueueRetryable((() => e(
|
|
385
|
+
t.enqueueRetryable((() => e(w.FIRST_PARTY)));
|
|
386
386
|
}
|
|
387
387
|
shutdown() {}
|
|
388
388
|
invalidateToken() {}
|
|
389
389
|
}
|
|
390
390
|
|
|
391
|
-
class
|
|
391
|
+
class H {
|
|
392
392
|
constructor(t) {
|
|
393
393
|
this.value = t, this.type = "AppCheck", this.headers = new Map, t && t.length > 0 && this.headers.set("x-firebase-appcheck", this.value);
|
|
394
394
|
}
|
|
395
395
|
}
|
|
396
396
|
|
|
397
|
-
/** AppCheck token provider for the Lite SDK. */ class
|
|
397
|
+
/** AppCheck token provider for the Lite SDK. */ class J {
|
|
398
398
|
constructor(t) {
|
|
399
399
|
this.m = t, this.appCheck = null, t.onInit((t => {
|
|
400
400
|
this.appCheck = t;
|
|
401
401
|
}));
|
|
402
402
|
}
|
|
403
403
|
getToken() {
|
|
404
|
-
return this.appCheck ? this.appCheck.getToken().then((t => t ? (
|
|
405
|
-
new
|
|
404
|
+
return this.appCheck ? this.appCheck.getToken().then((t => t ? (I("string" == typeof t.token),
|
|
405
|
+
new H(t.token)) : null)) : Promise.resolve(null);
|
|
406
406
|
}
|
|
407
407
|
invalidateToken() {}
|
|
408
408
|
start(t, e) {}
|
|
@@ -429,7 +429,7 @@ class Y {
|
|
|
429
429
|
* See the License for the specific language governing permissions and
|
|
430
430
|
* limitations under the License.
|
|
431
431
|
*/
|
|
432
|
-
class
|
|
432
|
+
class X {
|
|
433
433
|
/**
|
|
434
434
|
* Constructs a DatabaseInfo using the provided host, databaseId and
|
|
435
435
|
* persistenceKey.
|
|
@@ -458,38 +458,38 @@ class J {
|
|
|
458
458
|
* Represents the database ID a Firestore client is associated with.
|
|
459
459
|
* @internal
|
|
460
460
|
*/
|
|
461
|
-
class
|
|
461
|
+
class Z {
|
|
462
462
|
constructor(t, e) {
|
|
463
463
|
this.projectId = t, this.database = e || "(default)";
|
|
464
464
|
}
|
|
465
465
|
static empty() {
|
|
466
|
-
return new
|
|
466
|
+
return new Z("", "");
|
|
467
467
|
}
|
|
468
468
|
get isDefaultDatabase() {
|
|
469
469
|
return "(default)" === this.database;
|
|
470
470
|
}
|
|
471
471
|
isEqual(t) {
|
|
472
|
-
return t instanceof
|
|
472
|
+
return t instanceof Z && t.projectId === this.projectId && t.database === this.database;
|
|
473
473
|
}
|
|
474
474
|
}
|
|
475
475
|
|
|
476
476
|
/**
|
|
477
477
|
* Path represents an ordered sequence of string segments.
|
|
478
478
|
*/
|
|
479
|
-
class
|
|
479
|
+
class tt {
|
|
480
480
|
constructor(t, e, n) {
|
|
481
|
-
void 0 === e ? e = 0 : e > t.length &&
|
|
481
|
+
void 0 === e ? e = 0 : e > t.length && E(), void 0 === n ? n = t.length - e : n > t.length - e && E(),
|
|
482
482
|
this.segments = t, this.offset = e, this.len = n;
|
|
483
483
|
}
|
|
484
484
|
get length() {
|
|
485
485
|
return this.len;
|
|
486
486
|
}
|
|
487
487
|
isEqual(t) {
|
|
488
|
-
return 0 ===
|
|
488
|
+
return 0 === tt.comparator(this, t);
|
|
489
489
|
}
|
|
490
490
|
child(t) {
|
|
491
491
|
const e = this.segments.slice(this.offset, this.limit());
|
|
492
|
-
return t instanceof
|
|
492
|
+
return t instanceof tt ? t.forEach((t => {
|
|
493
493
|
e.push(t);
|
|
494
494
|
})) : e.push(t), this.construct(e);
|
|
495
495
|
}
|
|
@@ -546,9 +546,9 @@ class Z {
|
|
|
546
546
|
* within Firestore.
|
|
547
547
|
*
|
|
548
548
|
* @internal
|
|
549
|
-
*/ class
|
|
549
|
+
*/ class et extends tt {
|
|
550
550
|
construct(t, e, n) {
|
|
551
|
-
return new
|
|
551
|
+
return new et(t, e, n);
|
|
552
552
|
}
|
|
553
553
|
canonicalString() {
|
|
554
554
|
// NOTE: The client is ignorant of any path segments containing escape
|
|
@@ -569,35 +569,35 @@ class Z {
|
|
|
569
569
|
// for legacy reasons and should not be used frequently).
|
|
570
570
|
const e = [];
|
|
571
571
|
for (const n of t) {
|
|
572
|
-
if (n.indexOf("//") >= 0) throw new
|
|
572
|
+
if (n.indexOf("//") >= 0) throw new j(V, `Invalid segment (${n}). Paths must not contain // in them.`);
|
|
573
573
|
// Strip leading and traling slashed.
|
|
574
574
|
e.push(...n.split("/").filter((t => t.length > 0)));
|
|
575
575
|
}
|
|
576
|
-
return new
|
|
576
|
+
return new et(e);
|
|
577
577
|
}
|
|
578
578
|
static emptyPath() {
|
|
579
|
-
return new
|
|
579
|
+
return new et([]);
|
|
580
580
|
}
|
|
581
581
|
}
|
|
582
582
|
|
|
583
|
-
const
|
|
583
|
+
const nt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
584
584
|
|
|
585
585
|
/**
|
|
586
586
|
* A dot-separated path for navigating sub-objects within a document.
|
|
587
587
|
* @internal
|
|
588
|
-
*/ class
|
|
588
|
+
*/ class rt extends tt {
|
|
589
589
|
construct(t, e, n) {
|
|
590
|
-
return new
|
|
590
|
+
return new rt(t, e, n);
|
|
591
591
|
}
|
|
592
592
|
/**
|
|
593
593
|
* Returns true if the string could be used as a segment in a field path
|
|
594
594
|
* without escaping.
|
|
595
595
|
*/ static isValidIdentifier(t) {
|
|
596
|
-
return
|
|
596
|
+
return nt.test(t);
|
|
597
597
|
}
|
|
598
598
|
canonicalString() {
|
|
599
599
|
return this.toArray().map((t => (t = t.replace(/\\/g, "\\\\").replace(/`/g, "\\`"),
|
|
600
|
-
|
|
600
|
+
rt.isValidIdentifier(t) || (t = "`" + t + "`"), t))).join(".");
|
|
601
601
|
}
|
|
602
602
|
toString() {
|
|
603
603
|
return this.canonicalString();
|
|
@@ -610,7 +610,7 @@ const et = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
610
610
|
/**
|
|
611
611
|
* The field designating the key of a document.
|
|
612
612
|
*/ static keyField() {
|
|
613
|
-
return new
|
|
613
|
+
return new rt([ "__name__" ]);
|
|
614
614
|
}
|
|
615
615
|
/**
|
|
616
616
|
* Parses a field string from the given server-formatted string.
|
|
@@ -625,24 +625,24 @@ const et = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
625
625
|
const e = [];
|
|
626
626
|
let n = "", r = 0;
|
|
627
627
|
const s = () => {
|
|
628
|
-
if (0 === n.length) throw new
|
|
628
|
+
if (0 === n.length) throw new j(V, `Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);
|
|
629
629
|
e.push(n), n = "";
|
|
630
630
|
};
|
|
631
631
|
let i = !1;
|
|
632
632
|
for (;r < t.length; ) {
|
|
633
633
|
const e = t[r];
|
|
634
634
|
if ("\\" === e) {
|
|
635
|
-
if (r + 1 === t.length) throw new
|
|
635
|
+
if (r + 1 === t.length) throw new j(V, "Path has trailing escape character: " + t);
|
|
636
636
|
const e = t[r + 1];
|
|
637
|
-
if ("\\" !== e && "." !== e && "`" !== e) throw new
|
|
637
|
+
if ("\\" !== e && "." !== e && "`" !== e) throw new j(V, "Path has invalid escape sequence: " + t);
|
|
638
638
|
n += e, r += 2;
|
|
639
639
|
} else "`" === e ? (i = !i, r++) : "." !== e || i ? (n += e, r++) : (s(), r++);
|
|
640
640
|
}
|
|
641
|
-
if (s(), i) throw new
|
|
642
|
-
return new
|
|
641
|
+
if (s(), i) throw new j(V, "Unterminated ` in path: " + t);
|
|
642
|
+
return new rt(e);
|
|
643
643
|
}
|
|
644
644
|
static emptyPath() {
|
|
645
|
-
return new
|
|
645
|
+
return new rt([]);
|
|
646
646
|
}
|
|
647
647
|
}
|
|
648
648
|
|
|
@@ -664,18 +664,18 @@ const et = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
664
664
|
*/
|
|
665
665
|
/**
|
|
666
666
|
* @internal
|
|
667
|
-
*/ class
|
|
667
|
+
*/ class st {
|
|
668
668
|
constructor(t) {
|
|
669
669
|
this.path = t;
|
|
670
670
|
}
|
|
671
671
|
static fromPath(t) {
|
|
672
|
-
return new
|
|
672
|
+
return new st(et.fromString(t));
|
|
673
673
|
}
|
|
674
674
|
static fromName(t) {
|
|
675
|
-
return new
|
|
675
|
+
return new st(et.fromString(t).popFirst(5));
|
|
676
676
|
}
|
|
677
677
|
static empty() {
|
|
678
|
-
return new
|
|
678
|
+
return new st(et.emptyPath());
|
|
679
679
|
}
|
|
680
680
|
get collectionGroup() {
|
|
681
681
|
return this.path.popLast().lastSegment();
|
|
@@ -690,13 +690,13 @@ const et = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
690
690
|
return this.path.popLast();
|
|
691
691
|
}
|
|
692
692
|
isEqual(t) {
|
|
693
|
-
return null !== t && 0 ===
|
|
693
|
+
return null !== t && 0 === et.comparator(this.path, t.path);
|
|
694
694
|
}
|
|
695
695
|
toString() {
|
|
696
696
|
return this.path.toString();
|
|
697
697
|
}
|
|
698
698
|
static comparator(t, e) {
|
|
699
|
-
return
|
|
699
|
+
return et.comparator(t.path, e.path);
|
|
700
700
|
}
|
|
701
701
|
static isDocumentKey(t) {
|
|
702
702
|
return t.length % 2 == 0;
|
|
@@ -707,7 +707,7 @@ const et = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
707
707
|
* @param segments - The segments of the path to the document
|
|
708
708
|
* @returns A new instance of DocumentKey
|
|
709
709
|
*/ static fromSegments(t) {
|
|
710
|
-
return new
|
|
710
|
+
return new st(new et(t.slice()));
|
|
711
711
|
}
|
|
712
712
|
}
|
|
713
713
|
|
|
@@ -726,8 +726,8 @@ const et = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
726
726
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
727
727
|
* See the License for the specific language governing permissions and
|
|
728
728
|
* limitations under the License.
|
|
729
|
-
*/ function
|
|
730
|
-
if (!n) throw new
|
|
729
|
+
*/ function it(t, e, n) {
|
|
730
|
+
if (!n) throw new j(V, `Function ${t}() cannot be called with an empty ${e}.`);
|
|
731
731
|
}
|
|
732
732
|
|
|
733
733
|
/**
|
|
@@ -738,15 +738,15 @@ const et = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
738
738
|
* Validates that `path` refers to a document (indicated by the fact it contains
|
|
739
739
|
* an even numbers of segments).
|
|
740
740
|
*/
|
|
741
|
-
function
|
|
742
|
-
if (!
|
|
741
|
+
function ot(t) {
|
|
742
|
+
if (!st.isDocumentKey(t)) throw new j(V, `Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`);
|
|
743
743
|
}
|
|
744
744
|
|
|
745
745
|
/**
|
|
746
746
|
* Validates that `path` refers to a collection (indicated by the fact it
|
|
747
747
|
* contains an odd numbers of segments).
|
|
748
|
-
*/ function
|
|
749
|
-
if (
|
|
748
|
+
*/ function ut(t) {
|
|
749
|
+
if (st.isDocumentKey(t)) throw new j(V, `Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`);
|
|
750
750
|
}
|
|
751
751
|
|
|
752
752
|
/**
|
|
@@ -754,7 +754,7 @@ function it(t) {
|
|
|
754
754
|
* (i.e. excludes Array, Date, etc.).
|
|
755
755
|
*/
|
|
756
756
|
/** Returns a string describing the type / value of the provided input. */
|
|
757
|
-
function
|
|
757
|
+
function ct(t) {
|
|
758
758
|
if (void 0 === t) return "undefined";
|
|
759
759
|
if (null === t) return "null";
|
|
760
760
|
if ("string" == typeof t) return t.length > 20 && (t = `${t.substring(0, 20)}...`),
|
|
@@ -780,27 +780,27 @@ function ut(t) {
|
|
|
780
780
|
return e ? `a custom ${e} object` : "an object";
|
|
781
781
|
}
|
|
782
782
|
}
|
|
783
|
-
return "function" == typeof t ? "a function" :
|
|
783
|
+
return "function" == typeof t ? "a function" : E();
|
|
784
784
|
}
|
|
785
785
|
|
|
786
|
-
function
|
|
786
|
+
function at(t,
|
|
787
787
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
788
788
|
e) {
|
|
789
789
|
if ("_delegate" in t && (
|
|
790
790
|
// Unwrap Compat types
|
|
791
791
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
792
792
|
t = t._delegate), !(t instanceof e)) {
|
|
793
|
-
if (e.name === t.constructor.name) throw new
|
|
793
|
+
if (e.name === t.constructor.name) throw new j(V, "Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");
|
|
794
794
|
{
|
|
795
|
-
const n =
|
|
796
|
-
throw new
|
|
795
|
+
const n = ct(t);
|
|
796
|
+
throw new j(V, `Expected type '${e.name}', but it was: ${n}`);
|
|
797
797
|
}
|
|
798
798
|
}
|
|
799
799
|
return t;
|
|
800
800
|
}
|
|
801
801
|
|
|
802
|
-
function
|
|
803
|
-
if (e <= 0) throw new
|
|
802
|
+
function ht(t, e) {
|
|
803
|
+
if (e <= 0) throw new j(V, `Function ${t}() requires a positive number, but it was: ${e}.`);
|
|
804
804
|
}
|
|
805
805
|
|
|
806
806
|
/**
|
|
@@ -821,11 +821,11 @@ function at(t, e) {
|
|
|
821
821
|
*/
|
|
822
822
|
/**
|
|
823
823
|
* Returns whether a variable is either undefined or null.
|
|
824
|
-
*/ function
|
|
824
|
+
*/ function lt(t) {
|
|
825
825
|
return null == t;
|
|
826
826
|
}
|
|
827
827
|
|
|
828
|
-
/** Returns whether the value represents -0. */ function
|
|
828
|
+
/** Returns whether the value represents -0. */ function ft(t) {
|
|
829
829
|
// Detect if the value is -0.0. Based on polyfill from
|
|
830
830
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
831
831
|
return 0 === t && 1 / t == -1 / 0;
|
|
@@ -851,7 +851,7 @@ function at(t, e) {
|
|
|
851
851
|
* See the License for the specific language governing permissions and
|
|
852
852
|
* limitations under the License.
|
|
853
853
|
*/
|
|
854
|
-
const
|
|
854
|
+
const dt = {
|
|
855
855
|
BatchGetDocuments: "batchGet",
|
|
856
856
|
Commit: "commit",
|
|
857
857
|
RunQuery: "runQuery",
|
|
@@ -889,7 +889,7 @@ const ft = {
|
|
|
889
889
|
* are used for reverse lookups from the webchannel stream. Do NOT change the
|
|
890
890
|
* names of these identifiers or change this into a const enum.
|
|
891
891
|
*/
|
|
892
|
-
var
|
|
892
|
+
var wt, mt;
|
|
893
893
|
|
|
894
894
|
/**
|
|
895
895
|
* Converts an HTTP Status Code to the equivalent error code.
|
|
@@ -898,8 +898,8 @@ var dt, wt;
|
|
|
898
898
|
* @returns The equivalent Code. Unknown status codes are mapped to
|
|
899
899
|
* Code.UNKNOWN.
|
|
900
900
|
*/
|
|
901
|
-
function
|
|
902
|
-
if (void 0 === t) return
|
|
901
|
+
function pt(t) {
|
|
902
|
+
if (void 0 === t) return _("RPC_ERROR", "HTTP error has no status"), P;
|
|
903
903
|
// The canonical error codes for Google APIs [1] specify mapping onto HTTP
|
|
904
904
|
// status codes but the mapping is not bijective. In each case of ambiguity
|
|
905
905
|
// this function chooses a primary error.
|
|
@@ -909,66 +909,66 @@ function mt(t) {
|
|
|
909
909
|
switch (t) {
|
|
910
910
|
case 200:
|
|
911
911
|
// OK
|
|
912
|
-
return
|
|
912
|
+
return A;
|
|
913
913
|
|
|
914
914
|
case 400:
|
|
915
915
|
// Bad Request
|
|
916
|
-
return
|
|
916
|
+
return q;
|
|
917
917
|
|
|
918
918
|
// Other possibilities based on the forward mapping
|
|
919
919
|
// return Code.INVALID_ARGUMENT;
|
|
920
920
|
// return Code.OUT_OF_RANGE;
|
|
921
921
|
case 401:
|
|
922
922
|
// Unauthorized
|
|
923
|
-
return
|
|
923
|
+
return S;
|
|
924
924
|
|
|
925
925
|
case 403:
|
|
926
926
|
// Forbidden
|
|
927
|
-
return
|
|
927
|
+
return x;
|
|
928
928
|
|
|
929
929
|
case 404:
|
|
930
930
|
// Not Found
|
|
931
|
-
return
|
|
931
|
+
return $;
|
|
932
932
|
|
|
933
933
|
case 409:
|
|
934
934
|
// Conflict
|
|
935
|
-
return
|
|
935
|
+
return O;
|
|
936
936
|
|
|
937
937
|
// Other possibilities:
|
|
938
938
|
// return Code.ALREADY_EXISTS;
|
|
939
939
|
case 416:
|
|
940
940
|
// Range Not Satisfiable
|
|
941
|
-
return
|
|
941
|
+
return k;
|
|
942
942
|
|
|
943
943
|
case 429:
|
|
944
944
|
// Too Many Requests
|
|
945
|
-
return
|
|
945
|
+
return F;
|
|
946
946
|
|
|
947
947
|
case 499:
|
|
948
948
|
// Client Closed Request
|
|
949
|
-
return
|
|
949
|
+
return R;
|
|
950
950
|
|
|
951
951
|
case 500:
|
|
952
952
|
// Internal Server Error
|
|
953
|
-
return
|
|
953
|
+
return P;
|
|
954
954
|
|
|
955
955
|
// Other possibilities:
|
|
956
956
|
// return Code.INTERNAL;
|
|
957
957
|
// return Code.DATA_LOSS;
|
|
958
958
|
case 501:
|
|
959
959
|
// Unimplemented
|
|
960
|
-
return
|
|
960
|
+
return C;
|
|
961
961
|
|
|
962
962
|
case 503:
|
|
963
963
|
// Service Unavailable
|
|
964
|
-
return
|
|
964
|
+
return M;
|
|
965
965
|
|
|
966
966
|
case 504:
|
|
967
967
|
// Gateway Timeout
|
|
968
|
-
return
|
|
968
|
+
return N;
|
|
969
969
|
|
|
970
970
|
default:
|
|
971
|
-
return t >= 200 && t < 300 ?
|
|
971
|
+
return t >= 200 && t < 300 ? A : t >= 400 && t < 500 ? q : t >= 500 && t < 600 ? L : P;
|
|
972
972
|
}
|
|
973
973
|
}
|
|
974
974
|
|
|
@@ -991,16 +991,16 @@ function mt(t) {
|
|
|
991
991
|
/**
|
|
992
992
|
* A Rest-based connection that relies on the native HTTP stack
|
|
993
993
|
* (e.g. `fetch` or a polyfill).
|
|
994
|
-
*/ (
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
994
|
+
*/ (mt = wt || (wt = {}))[mt.OK = 0] = "OK", mt[mt.CANCELLED = 1] = "CANCELLED",
|
|
995
|
+
mt[mt.UNKNOWN = 2] = "UNKNOWN", mt[mt.INVALID_ARGUMENT = 3] = "INVALID_ARGUMENT",
|
|
996
|
+
mt[mt.DEADLINE_EXCEEDED = 4] = "DEADLINE_EXCEEDED", mt[mt.NOT_FOUND = 5] = "NOT_FOUND",
|
|
997
|
+
mt[mt.ALREADY_EXISTS = 6] = "ALREADY_EXISTS", mt[mt.PERMISSION_DENIED = 7] = "PERMISSION_DENIED",
|
|
998
|
+
mt[mt.UNAUTHENTICATED = 16] = "UNAUTHENTICATED", mt[mt.RESOURCE_EXHAUSTED = 8] = "RESOURCE_EXHAUSTED",
|
|
999
|
+
mt[mt.FAILED_PRECONDITION = 9] = "FAILED_PRECONDITION", mt[mt.ABORTED = 10] = "ABORTED",
|
|
1000
|
+
mt[mt.OUT_OF_RANGE = 11] = "OUT_OF_RANGE", mt[mt.UNIMPLEMENTED = 12] = "UNIMPLEMENTED",
|
|
1001
|
+
mt[mt.INTERNAL = 13] = "INTERNAL", mt[mt.UNAVAILABLE = 14] = "UNAVAILABLE", mt[mt.DATA_LOSS = 15] = "DATA_LOSS";
|
|
1002
1002
|
|
|
1003
|
-
class
|
|
1003
|
+
class yt extends
|
|
1004
1004
|
/**
|
|
1005
1005
|
* Base class for all Rest-based connections to the backend (WebChannel and
|
|
1006
1006
|
* HTTP).
|
|
@@ -1018,11 +1018,11 @@ class {
|
|
|
1018
1018
|
}
|
|
1019
1019
|
I(t, e, n, r, s) {
|
|
1020
1020
|
const i = this.T(t, e);
|
|
1021
|
-
|
|
1021
|
+
g("RestConnection", "Sending: ", i, n);
|
|
1022
1022
|
const o = {};
|
|
1023
|
-
return this.A(o, r, s), this.R(t, i, o, n).then((t => (
|
|
1023
|
+
return this.A(o, r, s), this.R(t, i, o, n).then((t => (g("RestConnection", "Received: ", t),
|
|
1024
1024
|
t)), (e => {
|
|
1025
|
-
throw
|
|
1025
|
+
throw v("RestConnection", `${t} failed with error: `, e, "url: ", i, "request:", n),
|
|
1026
1026
|
e;
|
|
1027
1027
|
}));
|
|
1028
1028
|
}
|
|
@@ -1035,7 +1035,7 @@ class {
|
|
|
1035
1035
|
* Modifies the headers for a request, adding any authorization token if
|
|
1036
1036
|
* present and any additional headers for the request.
|
|
1037
1037
|
*/ A(t, e, n) {
|
|
1038
|
-
t["X-Goog-Api-Client"] = "gl-js/ fire/" +
|
|
1038
|
+
t["X-Goog-Api-Client"] = "gl-js/ fire/" + m,
|
|
1039
1039
|
// Content-Type: text/plain will avoid preflight requests which might
|
|
1040
1040
|
// mess with CORS and redirects by proxies. If we add custom headers
|
|
1041
1041
|
// we will need to change this code to potentially use the $httpOverwrite
|
|
@@ -1044,7 +1044,7 @@ class {
|
|
|
1044
1044
|
e && e.headers.forEach(((e, n) => t[n] = e)), n && n.headers.forEach(((e, n) => t[n] = e));
|
|
1045
1045
|
}
|
|
1046
1046
|
T(t, e) {
|
|
1047
|
-
const n =
|
|
1047
|
+
const n = dt[t];
|
|
1048
1048
|
return `${this.p}/v1/${e}:${n}`;
|
|
1049
1049
|
}
|
|
1050
1050
|
} {
|
|
@@ -1068,9 +1068,9 @@ class {
|
|
|
1068
1068
|
body: s
|
|
1069
1069
|
});
|
|
1070
1070
|
} catch (t) {
|
|
1071
|
-
throw new
|
|
1071
|
+
throw new j(pt(t.status), "Request failed with error: " + t.statusText);
|
|
1072
1072
|
}
|
|
1073
|
-
if (!i.ok) throw new
|
|
1073
|
+
if (!i.ok) throw new j(pt(i.status), "Request failed with error: " + i.statusText);
|
|
1074
1074
|
return i.json();
|
|
1075
1075
|
}
|
|
1076
1076
|
}
|
|
@@ -1113,7 +1113,7 @@ class {
|
|
|
1113
1113
|
*
|
|
1114
1114
|
* If `nBytes < 0` , an error will be thrown.
|
|
1115
1115
|
*/
|
|
1116
|
-
function
|
|
1116
|
+
function gt(t) {
|
|
1117
1117
|
// Polyfills for IE and WebWorker by using `self` and `msCrypto` when `crypto` is not available.
|
|
1118
1118
|
const e =
|
|
1119
1119
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1139,14 +1139,14 @@ function yt(t) {
|
|
|
1139
1139
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1140
1140
|
* See the License for the specific language governing permissions and
|
|
1141
1141
|
* limitations under the License.
|
|
1142
|
-
*/ class
|
|
1142
|
+
*/ class _t {
|
|
1143
1143
|
static $() {
|
|
1144
1144
|
// Alphanumeric characters
|
|
1145
1145
|
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", e = Math.floor(256 / t.length) * t.length;
|
|
1146
1146
|
// The largest byte value that is a multiple of `char.length`.
|
|
1147
1147
|
let n = "";
|
|
1148
1148
|
for (;n.length < 20; ) {
|
|
1149
|
-
const r =
|
|
1149
|
+
const r = gt(40);
|
|
1150
1150
|
for (let s = 0; s < r.length; ++s)
|
|
1151
1151
|
// Only accept values that are [0, maxMultiple), this ensures they can
|
|
1152
1152
|
// be evenly mapped to indices of `chars` via a modulo operation.
|
|
@@ -1156,11 +1156,11 @@ function yt(t) {
|
|
|
1156
1156
|
}
|
|
1157
1157
|
}
|
|
1158
1158
|
|
|
1159
|
-
function
|
|
1159
|
+
function vt(t, e) {
|
|
1160
1160
|
return t < e ? -1 : t > e ? 1 : 0;
|
|
1161
1161
|
}
|
|
1162
1162
|
|
|
1163
|
-
/** Helper to compare arrays using isEqual(). */ function
|
|
1163
|
+
/** Helper to compare arrays using isEqual(). */ function bt(t, e, n) {
|
|
1164
1164
|
return t.length === e.length && t.every(((t, r) => n(t, e[r])));
|
|
1165
1165
|
}
|
|
1166
1166
|
|
|
@@ -1195,7 +1195,7 @@ function _t(t, e) {
|
|
|
1195
1195
|
* For examples and further specifications, refer to the
|
|
1196
1196
|
* {@link https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto | Timestamp definition}.
|
|
1197
1197
|
*/
|
|
1198
|
-
class
|
|
1198
|
+
class Et {
|
|
1199
1199
|
/**
|
|
1200
1200
|
* Creates a new timestamp.
|
|
1201
1201
|
*
|
|
@@ -1216,18 +1216,18 @@ class bt {
|
|
|
1216
1216
|
* The fractions of a second at nanosecond resolution.*
|
|
1217
1217
|
*/
|
|
1218
1218
|
e) {
|
|
1219
|
-
if (this.seconds = t, this.nanoseconds = e, e < 0) throw new
|
|
1220
|
-
if (e >= 1e9) throw new
|
|
1221
|
-
if (t < -62135596800) throw new
|
|
1219
|
+
if (this.seconds = t, this.nanoseconds = e, e < 0) throw new j(V, "Timestamp nanoseconds out of range: " + e);
|
|
1220
|
+
if (e >= 1e9) throw new j(V, "Timestamp nanoseconds out of range: " + e);
|
|
1221
|
+
if (t < -62135596800) throw new j(V, "Timestamp seconds out of range: " + t);
|
|
1222
1222
|
// This will break in the year 10,000.
|
|
1223
|
-
if (t >= 253402300800) throw new
|
|
1223
|
+
if (t >= 253402300800) throw new j(V, "Timestamp seconds out of range: " + t);
|
|
1224
1224
|
}
|
|
1225
1225
|
/**
|
|
1226
1226
|
* Creates a new timestamp with the current date, with millisecond precision.
|
|
1227
1227
|
*
|
|
1228
1228
|
* @returns a new timestamp representing the current date.
|
|
1229
1229
|
*/ static now() {
|
|
1230
|
-
return
|
|
1230
|
+
return Et.fromMillis(Date.now());
|
|
1231
1231
|
}
|
|
1232
1232
|
/**
|
|
1233
1233
|
* Creates a new timestamp from the given date.
|
|
@@ -1236,7 +1236,7 @@ class bt {
|
|
|
1236
1236
|
* @returns A new `Timestamp` representing the same point in time as the given
|
|
1237
1237
|
* date.
|
|
1238
1238
|
*/ static fromDate(t) {
|
|
1239
|
-
return
|
|
1239
|
+
return Et.fromMillis(t.getTime());
|
|
1240
1240
|
}
|
|
1241
1241
|
/**
|
|
1242
1242
|
* Creates a new timestamp from the given number of milliseconds.
|
|
@@ -1247,7 +1247,7 @@ class bt {
|
|
|
1247
1247
|
* number of milliseconds.
|
|
1248
1248
|
*/ static fromMillis(t) {
|
|
1249
1249
|
const e = Math.floor(t / 1e3), n = Math.floor(1e6 * (t - 1e3 * e));
|
|
1250
|
-
return new
|
|
1250
|
+
return new Et(e, n);
|
|
1251
1251
|
}
|
|
1252
1252
|
/**
|
|
1253
1253
|
* Converts a `Timestamp` to a JavaScript `Date` object. This conversion
|
|
@@ -1269,7 +1269,7 @@ class bt {
|
|
|
1269
1269
|
return 1e3 * this.seconds + this.nanoseconds / 1e6;
|
|
1270
1270
|
}
|
|
1271
1271
|
_compareTo(t) {
|
|
1272
|
-
return this.seconds === t.seconds ?
|
|
1272
|
+
return this.seconds === t.seconds ? vt(this.nanoseconds, t.nanoseconds) : vt(this.seconds, t.seconds);
|
|
1273
1273
|
}
|
|
1274
1274
|
/**
|
|
1275
1275
|
* Returns true if this `Timestamp` is equal to the provided one.
|
|
@@ -1325,18 +1325,18 @@ class bt {
|
|
|
1325
1325
|
/**
|
|
1326
1326
|
* A version of a document in Firestore. This corresponds to the version
|
|
1327
1327
|
* timestamp, such as update_time or read_time.
|
|
1328
|
-
*/ class
|
|
1328
|
+
*/ class It {
|
|
1329
1329
|
constructor(t) {
|
|
1330
1330
|
this.timestamp = t;
|
|
1331
1331
|
}
|
|
1332
1332
|
static fromTimestamp(t) {
|
|
1333
|
-
return new
|
|
1333
|
+
return new It(t);
|
|
1334
1334
|
}
|
|
1335
1335
|
static min() {
|
|
1336
|
-
return new
|
|
1336
|
+
return new It(new Et(0, 0));
|
|
1337
1337
|
}
|
|
1338
1338
|
static max() {
|
|
1339
|
-
return new
|
|
1339
|
+
return new It(new Et(253402300799, 999999999));
|
|
1340
1340
|
}
|
|
1341
1341
|
compareTo(t) {
|
|
1342
1342
|
return this.timestamp._compareTo(t.timestamp);
|
|
@@ -1371,13 +1371,13 @@ class bt {
|
|
|
1371
1371
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1372
1372
|
* See the License for the specific language governing permissions and
|
|
1373
1373
|
* limitations under the License.
|
|
1374
|
-
*/ function
|
|
1374
|
+
*/ function Tt(t) {
|
|
1375
1375
|
let e = 0;
|
|
1376
1376
|
for (const n in t) Object.prototype.hasOwnProperty.call(t, n) && e++;
|
|
1377
1377
|
return e;
|
|
1378
1378
|
}
|
|
1379
1379
|
|
|
1380
|
-
function
|
|
1380
|
+
function At(t, e) {
|
|
1381
1381
|
for (const n in t) Object.prototype.hasOwnProperty.call(t, n) && e(n, t[n]);
|
|
1382
1382
|
}
|
|
1383
1383
|
|
|
@@ -1399,17 +1399,17 @@ function Tt(t, e) {
|
|
|
1399
1399
|
*/
|
|
1400
1400
|
// An immutable sorted map implementation, based on a Left-leaning Red-Black
|
|
1401
1401
|
// tree.
|
|
1402
|
-
class
|
|
1402
|
+
class Rt {
|
|
1403
1403
|
constructor(t, e) {
|
|
1404
|
-
this.comparator = t, this.root = e ||
|
|
1404
|
+
this.comparator = t, this.root = e || Vt.EMPTY;
|
|
1405
1405
|
}
|
|
1406
1406
|
// Returns a copy of the map, with the specified key/value added or replaced.
|
|
1407
1407
|
insert(t, e) {
|
|
1408
|
-
return new
|
|
1408
|
+
return new Rt(this.comparator, this.root.insert(t, e, this.comparator).copy(null, null, Vt.BLACK, null, null));
|
|
1409
1409
|
}
|
|
1410
1410
|
// Returns a copy of the map, with the specified key removed.
|
|
1411
1411
|
remove(t) {
|
|
1412
|
-
return new
|
|
1412
|
+
return new Rt(this.comparator, this.root.remove(t, this.comparator).copy(null, null, Vt.BLACK, null, null));
|
|
1413
1413
|
}
|
|
1414
1414
|
// Returns the value of the node with the given key, or null.
|
|
1415
1415
|
get(t) {
|
|
@@ -1475,22 +1475,22 @@ class At {
|
|
|
1475
1475
|
}
|
|
1476
1476
|
// Returns an iterator over the SortedMap.
|
|
1477
1477
|
getIterator() {
|
|
1478
|
-
return new
|
|
1478
|
+
return new Pt(this.root, null, this.comparator, !1);
|
|
1479
1479
|
}
|
|
1480
1480
|
getIteratorFrom(t) {
|
|
1481
|
-
return new
|
|
1481
|
+
return new Pt(this.root, t, this.comparator, !1);
|
|
1482
1482
|
}
|
|
1483
1483
|
getReverseIterator() {
|
|
1484
|
-
return new
|
|
1484
|
+
return new Pt(this.root, null, this.comparator, !0);
|
|
1485
1485
|
}
|
|
1486
1486
|
getReverseIteratorFrom(t) {
|
|
1487
|
-
return new
|
|
1487
|
+
return new Pt(this.root, t, this.comparator, !0);
|
|
1488
1488
|
}
|
|
1489
1489
|
}
|
|
1490
1490
|
|
|
1491
1491
|
// end SortedMap
|
|
1492
1492
|
// An iterator over an LLRBNode.
|
|
1493
|
-
class
|
|
1493
|
+
class Pt {
|
|
1494
1494
|
constructor(t, e, n, r) {
|
|
1495
1495
|
this.isReverse = r, this.nodeStack = [];
|
|
1496
1496
|
let s = 1;
|
|
@@ -1535,14 +1535,14 @@ class Rt {
|
|
|
1535
1535
|
|
|
1536
1536
|
// end SortedMapIterator
|
|
1537
1537
|
// Represents a node in a Left-leaning Red-Black tree.
|
|
1538
|
-
class
|
|
1538
|
+
class Vt {
|
|
1539
1539
|
constructor(t, e, n, r, s) {
|
|
1540
|
-
this.key = t, this.value = e, this.color = null != n ? n :
|
|
1541
|
-
this.right = null != s ? s :
|
|
1540
|
+
this.key = t, this.value = e, this.color = null != n ? n : Vt.RED, this.left = null != r ? r : Vt.EMPTY,
|
|
1541
|
+
this.right = null != s ? s : Vt.EMPTY, this.size = this.left.size + 1 + this.right.size;
|
|
1542
1542
|
}
|
|
1543
1543
|
// Returns a copy of the current node, optionally replacing pieces of it.
|
|
1544
1544
|
copy(t, e, n, r, s) {
|
|
1545
|
-
return new
|
|
1545
|
+
return new Vt(null != t ? t : this.key, null != e ? e : this.value, null != n ? n : this.color, null != r ? r : this.left, null != s ? s : this.right);
|
|
1546
1546
|
}
|
|
1547
1547
|
isEmpty() {
|
|
1548
1548
|
return !1;
|
|
@@ -1581,7 +1581,7 @@ class Pt {
|
|
|
1581
1581
|
r.fixUp();
|
|
1582
1582
|
}
|
|
1583
1583
|
removeMin() {
|
|
1584
|
-
if (this.left.isEmpty()) return
|
|
1584
|
+
if (this.left.isEmpty()) return Vt.EMPTY;
|
|
1585
1585
|
let t = this;
|
|
1586
1586
|
return t.left.isRed() || t.left.left.isRed() || (t = t.moveRedLeft()), t = t.copy(null, null, null, t.left.removeMin(), null),
|
|
1587
1587
|
t.fixUp();
|
|
@@ -1593,7 +1593,7 @@ class Pt {
|
|
|
1593
1593
|
r = r.copy(null, null, null, r.left.remove(t, e), null); else {
|
|
1594
1594
|
if (r.left.isRed() && (r = r.rotateRight()), r.right.isEmpty() || r.right.isRed() || r.right.left.isRed() || (r = r.moveRedRight()),
|
|
1595
1595
|
0 === e(t, r.key)) {
|
|
1596
|
-
if (r.right.isEmpty()) return
|
|
1596
|
+
if (r.right.isEmpty()) return Vt.EMPTY;
|
|
1597
1597
|
n = r.right.min(), r = r.copy(n.key, n.value, null, null, r.right.removeMin());
|
|
1598
1598
|
}
|
|
1599
1599
|
r = r.copy(null, null, null, null, r.right.remove(t, e));
|
|
@@ -1619,11 +1619,11 @@ class Pt {
|
|
|
1619
1619
|
return t.left.left.isRed() && (t = t.rotateRight(), t = t.colorFlip()), t;
|
|
1620
1620
|
}
|
|
1621
1621
|
rotateLeft() {
|
|
1622
|
-
const t = this.copy(null, null,
|
|
1622
|
+
const t = this.copy(null, null, Vt.RED, null, this.right.left);
|
|
1623
1623
|
return this.right.copy(null, null, this.color, t, null);
|
|
1624
1624
|
}
|
|
1625
1625
|
rotateRight() {
|
|
1626
|
-
const t = this.copy(null, null,
|
|
1626
|
+
const t = this.copy(null, null, Vt.RED, this.left.right, null);
|
|
1627
1627
|
return this.left.copy(null, null, this.color, null, t);
|
|
1628
1628
|
}
|
|
1629
1629
|
colorFlip() {
|
|
@@ -1638,10 +1638,10 @@ class Pt {
|
|
|
1638
1638
|
// In a balanced RB tree, the black-depth (number of black nodes) from root to
|
|
1639
1639
|
// leaves is equal on both sides. This function verifies that or asserts.
|
|
1640
1640
|
check() {
|
|
1641
|
-
if (this.isRed() && this.left.isRed()) throw
|
|
1642
|
-
if (this.right.isRed()) throw
|
|
1641
|
+
if (this.isRed() && this.left.isRed()) throw E();
|
|
1642
|
+
if (this.right.isRed()) throw E();
|
|
1643
1643
|
const t = this.left.check();
|
|
1644
|
-
if (t !== this.right.check()) throw
|
|
1644
|
+
if (t !== this.right.check()) throw E();
|
|
1645
1645
|
return t + (this.isRed() ? 0 : 1);
|
|
1646
1646
|
}
|
|
1647
1647
|
}
|
|
@@ -1649,29 +1649,29 @@ class Pt {
|
|
|
1649
1649
|
// end LLRBNode
|
|
1650
1650
|
// Empty node is shared between all LLRB trees.
|
|
1651
1651
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1652
|
-
|
|
1652
|
+
Vt.EMPTY = null, Vt.RED = !0, Vt.BLACK = !1;
|
|
1653
1653
|
|
|
1654
1654
|
// end LLRBEmptyNode
|
|
1655
|
-
|
|
1655
|
+
Vt.EMPTY = new
|
|
1656
1656
|
// Represents an empty node (a leaf node in the Red-Black Tree).
|
|
1657
1657
|
class {
|
|
1658
1658
|
constructor() {
|
|
1659
1659
|
this.size = 0;
|
|
1660
1660
|
}
|
|
1661
1661
|
get key() {
|
|
1662
|
-
throw
|
|
1662
|
+
throw E();
|
|
1663
1663
|
}
|
|
1664
1664
|
get value() {
|
|
1665
|
-
throw
|
|
1665
|
+
throw E();
|
|
1666
1666
|
}
|
|
1667
1667
|
get color() {
|
|
1668
|
-
throw
|
|
1668
|
+
throw E();
|
|
1669
1669
|
}
|
|
1670
1670
|
get left() {
|
|
1671
|
-
throw
|
|
1671
|
+
throw E();
|
|
1672
1672
|
}
|
|
1673
1673
|
get right() {
|
|
1674
|
-
throw
|
|
1674
|
+
throw E();
|
|
1675
1675
|
}
|
|
1676
1676
|
// Returns a copy of the current node.
|
|
1677
1677
|
copy(t, e, n, r, s) {
|
|
@@ -1679,7 +1679,7 @@ class {
|
|
|
1679
1679
|
}
|
|
1680
1680
|
// Returns a copy of the tree, with the specified key/value added.
|
|
1681
1681
|
insert(t, e, n) {
|
|
1682
|
-
return new
|
|
1682
|
+
return new Vt(t, e);
|
|
1683
1683
|
}
|
|
1684
1684
|
// Returns a copy of the tree, with the specified key removed.
|
|
1685
1685
|
remove(t, e) {
|
|
@@ -1735,9 +1735,9 @@ class {
|
|
|
1735
1735
|
* NOTE: if provided comparator returns 0 for two elements, we consider them to
|
|
1736
1736
|
* be equal!
|
|
1737
1737
|
*/
|
|
1738
|
-
class
|
|
1738
|
+
class Nt {
|
|
1739
1739
|
constructor(t) {
|
|
1740
|
-
this.comparator = t, this.data = new
|
|
1740
|
+
this.comparator = t, this.data = new Rt(this.comparator);
|
|
1741
1741
|
}
|
|
1742
1742
|
has(t) {
|
|
1743
1743
|
return null !== this.data.get(t);
|
|
@@ -1778,10 +1778,10 @@ class Vt {
|
|
|
1778
1778
|
return e.hasNext() ? e.getNext().key : null;
|
|
1779
1779
|
}
|
|
1780
1780
|
getIterator() {
|
|
1781
|
-
return new
|
|
1781
|
+
return new $t(this.data.getIterator());
|
|
1782
1782
|
}
|
|
1783
1783
|
getIteratorFrom(t) {
|
|
1784
|
-
return new
|
|
1784
|
+
return new $t(this.data.getIteratorFrom(t));
|
|
1785
1785
|
}
|
|
1786
1786
|
/** Inserts or updates an element */ add(t) {
|
|
1787
1787
|
return this.copy(this.data.remove(t).insert(t, !0));
|
|
@@ -1800,7 +1800,7 @@ class Vt {
|
|
|
1800
1800
|
})), e;
|
|
1801
1801
|
}
|
|
1802
1802
|
isEqual(t) {
|
|
1803
|
-
if (!(t instanceof
|
|
1803
|
+
if (!(t instanceof Nt)) return !1;
|
|
1804
1804
|
if (this.size !== t.size) return !1;
|
|
1805
1805
|
const e = this.data.getIterator(), n = t.data.getIterator();
|
|
1806
1806
|
for (;e.hasNext(); ) {
|
|
@@ -1820,12 +1820,12 @@ class Vt {
|
|
|
1820
1820
|
return this.forEach((e => t.push(e))), "SortedSet(" + t.toString() + ")";
|
|
1821
1821
|
}
|
|
1822
1822
|
copy(t) {
|
|
1823
|
-
const e = new
|
|
1823
|
+
const e = new Nt(this.comparator);
|
|
1824
1824
|
return e.data = t, e;
|
|
1825
1825
|
}
|
|
1826
1826
|
}
|
|
1827
1827
|
|
|
1828
|
-
class
|
|
1828
|
+
class $t {
|
|
1829
1829
|
constructor(t) {
|
|
1830
1830
|
this.iter = t;
|
|
1831
1831
|
}
|
|
@@ -1862,24 +1862,24 @@ class Nt {
|
|
|
1862
1862
|
* foo.bar - Overwrites only the field bar of the object foo.
|
|
1863
1863
|
* If foo is not an object, foo is replaced with an object
|
|
1864
1864
|
* containing foo
|
|
1865
|
-
*/ class
|
|
1865
|
+
*/ class Dt {
|
|
1866
1866
|
constructor(t) {
|
|
1867
1867
|
this.fields = t,
|
|
1868
1868
|
// TODO(dimond): validation of FieldMask
|
|
1869
1869
|
// Sort the field mask to support `FieldMask.isEqual()` and assert below.
|
|
1870
|
-
t.sort(
|
|
1870
|
+
t.sort(rt.comparator);
|
|
1871
1871
|
}
|
|
1872
1872
|
static empty() {
|
|
1873
|
-
return new
|
|
1873
|
+
return new Dt([]);
|
|
1874
1874
|
}
|
|
1875
1875
|
/**
|
|
1876
1876
|
* Returns a new FieldMask object that is the result of adding all the given
|
|
1877
1877
|
* fields paths to this field mask.
|
|
1878
1878
|
*/ unionWith(t) {
|
|
1879
|
-
let e = new
|
|
1879
|
+
let e = new Nt(rt.comparator);
|
|
1880
1880
|
for (const t of this.fields) e = e.add(t);
|
|
1881
1881
|
for (const n of t) e = e.add(n);
|
|
1882
|
-
return new
|
|
1882
|
+
return new Dt(e.toArray());
|
|
1883
1883
|
}
|
|
1884
1884
|
/**
|
|
1885
1885
|
* Verifies that `fieldPath` is included by at least one field in this field
|
|
@@ -1891,7 +1891,7 @@ class Nt {
|
|
|
1891
1891
|
return !1;
|
|
1892
1892
|
}
|
|
1893
1893
|
isEqual(t) {
|
|
1894
|
-
return
|
|
1894
|
+
return bt(this.fields, t.fields, ((t, e) => t.isEqual(e)));
|
|
1895
1895
|
}
|
|
1896
1896
|
}
|
|
1897
1897
|
|
|
@@ -1914,7 +1914,7 @@ class Nt {
|
|
|
1914
1914
|
// WebSafe uses a different URL-encoding safe alphabet that doesn't match
|
|
1915
1915
|
// the encoding used on the backend.
|
|
1916
1916
|
/** Converts a Base64 encoded string to a binary string. */
|
|
1917
|
-
function
|
|
1917
|
+
function xt(t) {
|
|
1918
1918
|
return String.fromCharCode.apply(null,
|
|
1919
1919
|
// We use `decodeStringToByteArray()` instead of `decodeString()` since
|
|
1920
1920
|
// `decodeString()` returns Unicode strings, which doesn't match the values
|
|
@@ -1948,13 +1948,13 @@ function Dt(t) {
|
|
|
1948
1948
|
* before being sent as a proto.
|
|
1949
1949
|
* @internal
|
|
1950
1950
|
*/
|
|
1951
|
-
class
|
|
1951
|
+
class St {
|
|
1952
1952
|
constructor(t) {
|
|
1953
1953
|
this.binaryString = t;
|
|
1954
1954
|
}
|
|
1955
1955
|
static fromBase64String(t) {
|
|
1956
|
-
const e =
|
|
1957
|
-
return new
|
|
1956
|
+
const e = xt(t);
|
|
1957
|
+
return new St(e);
|
|
1958
1958
|
}
|
|
1959
1959
|
static fromUint8Array(t) {
|
|
1960
1960
|
// TODO(indexing); Remove the copy of the byte string here as this method
|
|
@@ -1971,7 +1971,7 @@ class xt {
|
|
|
1971
1971
|
/**
|
|
1972
1972
|
* Helper function to convert a binary string to an Uint8Array.
|
|
1973
1973
|
*/ (t);
|
|
1974
|
-
return new
|
|
1974
|
+
return new St(e);
|
|
1975
1975
|
}
|
|
1976
1976
|
[Symbol.iterator]() {
|
|
1977
1977
|
let t = 0;
|
|
@@ -2021,31 +2021,31 @@ class xt {
|
|
|
2021
2021
|
return 2 * this.binaryString.length;
|
|
2022
2022
|
}
|
|
2023
2023
|
compareTo(t) {
|
|
2024
|
-
return
|
|
2024
|
+
return vt(this.binaryString, t.binaryString);
|
|
2025
2025
|
}
|
|
2026
2026
|
isEqual(t) {
|
|
2027
2027
|
return this.binaryString === t.binaryString;
|
|
2028
2028
|
}
|
|
2029
2029
|
}
|
|
2030
2030
|
|
|
2031
|
-
|
|
2031
|
+
St.EMPTY_BYTE_STRING = new St("");
|
|
2032
2032
|
|
|
2033
|
-
const
|
|
2033
|
+
const Ft = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
2034
2034
|
|
|
2035
2035
|
/**
|
|
2036
2036
|
* Converts the possible Proto values for a timestamp value into a "seconds and
|
|
2037
2037
|
* nanos" representation.
|
|
2038
|
-
*/ function
|
|
2038
|
+
*/ function qt(t) {
|
|
2039
2039
|
// The json interface (for the browser) will return an iso timestamp string,
|
|
2040
2040
|
// while the proto js library (for node) will return a
|
|
2041
2041
|
// google.protobuf.Timestamp instance.
|
|
2042
|
-
if (
|
|
2042
|
+
if (I(!!t), "string" == typeof t) {
|
|
2043
2043
|
// The date string can have higher precision (nanos) than the Date class
|
|
2044
2044
|
// (millis), so we do some custom parsing here.
|
|
2045
2045
|
// Parse the nanos right out of the string.
|
|
2046
2046
|
let e = 0;
|
|
2047
|
-
const n =
|
|
2048
|
-
if (
|
|
2047
|
+
const n = Ft.exec(t);
|
|
2048
|
+
if (I(!!n), n[1]) {
|
|
2049
2049
|
// Pad the fraction out to 9 digits (nanos).
|
|
2050
2050
|
let t = n[1];
|
|
2051
2051
|
t = (t + "000000000").substr(0, 9), e = Number(t);
|
|
@@ -2058,21 +2058,21 @@ const St = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
2058
2058
|
};
|
|
2059
2059
|
}
|
|
2060
2060
|
return {
|
|
2061
|
-
seconds:
|
|
2062
|
-
nanos:
|
|
2061
|
+
seconds: Ot(t.seconds),
|
|
2062
|
+
nanos: Ot(t.nanos)
|
|
2063
2063
|
};
|
|
2064
2064
|
}
|
|
2065
2065
|
|
|
2066
2066
|
/**
|
|
2067
2067
|
* Converts the possible Proto types for numbers into a JavaScript number.
|
|
2068
2068
|
* Returns 0 if the value is not numeric.
|
|
2069
|
-
*/ function
|
|
2069
|
+
*/ function Ot(t) {
|
|
2070
2070
|
// TODO(bjornick): Handle int64 greater than 53 bits.
|
|
2071
2071
|
return "number" == typeof t ? t : "string" == typeof t ? Number(t) : 0;
|
|
2072
2072
|
}
|
|
2073
2073
|
|
|
2074
|
-
/** Converts the possible Proto types for Blobs into a ByteString. */ function
|
|
2075
|
-
return "string" == typeof t ?
|
|
2074
|
+
/** Converts the possible Proto types for Blobs into a ByteString. */ function kt(t) {
|
|
2075
|
+
return "string" == typeof t ? St.fromBase64String(t) : St.fromUint8Array(t);
|
|
2076
2076
|
}
|
|
2077
2077
|
|
|
2078
2078
|
/**
|
|
@@ -2108,7 +2108,7 @@ const St = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
2108
2108
|
* FieldValueOptions to value().
|
|
2109
2109
|
* - With respect to other ServerTimestampValues, they sort by their
|
|
2110
2110
|
* localWriteTime.
|
|
2111
|
-
*/ function
|
|
2111
|
+
*/ function Ct(t) {
|
|
2112
2112
|
var e, n;
|
|
2113
2113
|
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);
|
|
2114
2114
|
}
|
|
@@ -2118,16 +2118,16 @@ const St = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
2118
2118
|
*
|
|
2119
2119
|
* Preserving the previous values allows the user to display the last resoled
|
|
2120
2120
|
* value until the backend responds with the timestamp.
|
|
2121
|
-
*/ function
|
|
2121
|
+
*/ function Lt(t) {
|
|
2122
2122
|
const e = t.mapValue.fields.__previous_value__;
|
|
2123
|
-
return
|
|
2123
|
+
return Ct(e) ? Lt(e) : e;
|
|
2124
2124
|
}
|
|
2125
2125
|
|
|
2126
2126
|
/**
|
|
2127
2127
|
* Returns the local time at which this timestamp was first set.
|
|
2128
|
-
*/ function
|
|
2129
|
-
const e =
|
|
2130
|
-
return new
|
|
2128
|
+
*/ function Mt(t) {
|
|
2129
|
+
const e = qt(t.mapValue.fields.__local_write_time__.timestampValue);
|
|
2130
|
+
return new Et(e.seconds, e.nanos);
|
|
2131
2131
|
}
|
|
2132
2132
|
|
|
2133
2133
|
/**
|
|
@@ -2145,7 +2145,7 @@ const St = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
2145
2145
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2146
2146
|
* See the License for the specific language governing permissions and
|
|
2147
2147
|
* limitations under the License.
|
|
2148
|
-
*/ const
|
|
2148
|
+
*/ const Ut = {
|
|
2149
2149
|
fields: {
|
|
2150
2150
|
__type__: {
|
|
2151
2151
|
stringValue: "__max__"
|
|
@@ -2154,8 +2154,8 @@ const St = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
2154
2154
|
};
|
|
2155
2155
|
|
|
2156
2156
|
/** Extracts the backend's type order for the provided value. */
|
|
2157
|
-
function
|
|
2158
|
-
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 ?
|
|
2157
|
+
function jt(t) {
|
|
2158
|
+
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 ? Ct(t) ? 4 /* ServerTimestampValue */ :
|
|
2159
2159
|
/** Returns true if the Value represents the canonical {@link #MAX_VALUE} . */
|
|
2160
2160
|
function(t) {
|
|
2161
2161
|
return "__max__" === (((t.mapValue || {}).fields || {}).__type__ || {}).stringValue;
|
|
@@ -2179,13 +2179,13 @@ function Ut(t) {
|
|
|
2179
2179
|
/**
|
|
2180
2180
|
* An ObjectValue represents a MapValue in the Firestore Proto and offers the
|
|
2181
2181
|
* ability to add and remove fields (via the ObjectValueBuilder).
|
|
2182
|
-
*/ (t) ? 9007199254740991 /* MaxValue */ : 10 /* ObjectValue */ :
|
|
2182
|
+
*/ (t) ? 9007199254740991 /* MaxValue */ : 10 /* ObjectValue */ : E();
|
|
2183
2183
|
}
|
|
2184
2184
|
|
|
2185
|
-
/** Tests `left` and `right` for equality based on the backend semantics. */ function
|
|
2185
|
+
/** Tests `left` and `right` for equality based on the backend semantics. */ function Bt(t, e) {
|
|
2186
2186
|
if (t === e) return !0;
|
|
2187
|
-
const n =
|
|
2188
|
-
if (n !==
|
|
2187
|
+
const n = jt(t);
|
|
2188
|
+
if (n !== jt(e)) return !1;
|
|
2189
2189
|
switch (n) {
|
|
2190
2190
|
case 0 /* NullValue */ :
|
|
2191
2191
|
case 9007199254740991 /* MaxValue */ :
|
|
@@ -2195,14 +2195,14 @@ function Ut(t) {
|
|
|
2195
2195
|
return t.booleanValue === e.booleanValue;
|
|
2196
2196
|
|
|
2197
2197
|
case 4 /* ServerTimestampValue */ :
|
|
2198
|
-
return
|
|
2198
|
+
return Mt(t).isEqual(Mt(e));
|
|
2199
2199
|
|
|
2200
2200
|
case 3 /* TimestampValue */ :
|
|
2201
2201
|
return function(t, e) {
|
|
2202
2202
|
if ("string" == typeof t.timestampValue && "string" == typeof e.timestampValue && t.timestampValue.length === e.timestampValue.length)
|
|
2203
2203
|
// Use string equality for ISO 8601 timestamps
|
|
2204
2204
|
return t.timestampValue === e.timestampValue;
|
|
2205
|
-
const n =
|
|
2205
|
+
const n = qt(t.timestampValue), r = qt(e.timestampValue);
|
|
2206
2206
|
return n.seconds === r.seconds && n.nanos === r.nanos;
|
|
2207
2207
|
}(t, e);
|
|
2208
2208
|
|
|
@@ -2211,7 +2211,7 @@ function Ut(t) {
|
|
|
2211
2211
|
|
|
2212
2212
|
case 6 /* BlobValue */ :
|
|
2213
2213
|
return function(t, e) {
|
|
2214
|
-
return
|
|
2214
|
+
return kt(t.bytesValue).isEqual(kt(e.bytesValue));
|
|
2215
2215
|
}(t, e);
|
|
2216
2216
|
|
|
2217
2217
|
case 7 /* RefValue */ :
|
|
@@ -2219,72 +2219,72 @@ function Ut(t) {
|
|
|
2219
2219
|
|
|
2220
2220
|
case 8 /* GeoPointValue */ :
|
|
2221
2221
|
return function(t, e) {
|
|
2222
|
-
return
|
|
2222
|
+
return Ot(t.geoPointValue.latitude) === Ot(e.geoPointValue.latitude) && Ot(t.geoPointValue.longitude) === Ot(e.geoPointValue.longitude);
|
|
2223
2223
|
}(t, e);
|
|
2224
2224
|
|
|
2225
2225
|
case 2 /* NumberValue */ :
|
|
2226
2226
|
return function(t, e) {
|
|
2227
|
-
if ("integerValue" in t && "integerValue" in e) return
|
|
2227
|
+
if ("integerValue" in t && "integerValue" in e) return Ot(t.integerValue) === Ot(e.integerValue);
|
|
2228
2228
|
if ("doubleValue" in t && "doubleValue" in e) {
|
|
2229
|
-
const n =
|
|
2230
|
-
return n === r ?
|
|
2229
|
+
const n = Ot(t.doubleValue), r = Ot(e.doubleValue);
|
|
2230
|
+
return n === r ? ft(n) === ft(r) : isNaN(n) && isNaN(r);
|
|
2231
2231
|
}
|
|
2232
2232
|
return !1;
|
|
2233
2233
|
}(t, e);
|
|
2234
2234
|
|
|
2235
2235
|
case 9 /* ArrayValue */ :
|
|
2236
|
-
return
|
|
2236
|
+
return bt(t.arrayValue.values || [], e.arrayValue.values || [], Bt);
|
|
2237
2237
|
|
|
2238
2238
|
case 10 /* ObjectValue */ :
|
|
2239
2239
|
return function(t, e) {
|
|
2240
2240
|
const n = t.mapValue.fields || {}, r = e.mapValue.fields || {};
|
|
2241
|
-
if (
|
|
2242
|
-
for (const t in n) if (n.hasOwnProperty(t) && (void 0 === r[t] || !
|
|
2241
|
+
if (Tt(n) !== Tt(r)) return !1;
|
|
2242
|
+
for (const t in n) if (n.hasOwnProperty(t) && (void 0 === r[t] || !Bt(n[t], r[t]))) return !1;
|
|
2243
2243
|
return !0;
|
|
2244
2244
|
}
|
|
2245
2245
|
/** Returns true if the ArrayValue contains the specified element. */ (t, e);
|
|
2246
2246
|
|
|
2247
2247
|
default:
|
|
2248
|
-
return
|
|
2248
|
+
return E();
|
|
2249
2249
|
}
|
|
2250
2250
|
}
|
|
2251
2251
|
|
|
2252
|
-
function
|
|
2253
|
-
return void 0 !== (t.values || []).find((t =>
|
|
2252
|
+
function Qt(t, e) {
|
|
2253
|
+
return void 0 !== (t.values || []).find((t => Bt(t, e)));
|
|
2254
2254
|
}
|
|
2255
2255
|
|
|
2256
|
-
function
|
|
2256
|
+
function zt(t, e) {
|
|
2257
2257
|
if (t === e) return 0;
|
|
2258
|
-
const n =
|
|
2259
|
-
if (n !== r) return
|
|
2258
|
+
const n = jt(t), r = jt(e);
|
|
2259
|
+
if (n !== r) return vt(n, r);
|
|
2260
2260
|
switch (n) {
|
|
2261
2261
|
case 0 /* NullValue */ :
|
|
2262
2262
|
case 9007199254740991 /* MaxValue */ :
|
|
2263
2263
|
return 0;
|
|
2264
2264
|
|
|
2265
2265
|
case 1 /* BooleanValue */ :
|
|
2266
|
-
return
|
|
2266
|
+
return vt(t.booleanValue, e.booleanValue);
|
|
2267
2267
|
|
|
2268
2268
|
case 2 /* NumberValue */ :
|
|
2269
2269
|
return function(t, e) {
|
|
2270
|
-
const n =
|
|
2270
|
+
const n = Ot(t.integerValue || t.doubleValue), r = Ot(e.integerValue || e.doubleValue);
|
|
2271
2271
|
return n < r ? -1 : n > r ? 1 : n === r ? 0 :
|
|
2272
2272
|
// one or both are NaN.
|
|
2273
2273
|
isNaN(n) ? isNaN(r) ? 0 : -1 : 1;
|
|
2274
2274
|
}(t, e);
|
|
2275
2275
|
|
|
2276
2276
|
case 3 /* TimestampValue */ :
|
|
2277
|
-
return
|
|
2277
|
+
return Wt(t.timestampValue, e.timestampValue);
|
|
2278
2278
|
|
|
2279
2279
|
case 4 /* ServerTimestampValue */ :
|
|
2280
|
-
return
|
|
2280
|
+
return Wt(Mt(t), Mt(e));
|
|
2281
2281
|
|
|
2282
2282
|
case 5 /* StringValue */ :
|
|
2283
|
-
return
|
|
2283
|
+
return vt(t.stringValue, e.stringValue);
|
|
2284
2284
|
|
|
2285
2285
|
case 6 /* BlobValue */ :
|
|
2286
2286
|
return function(t, e) {
|
|
2287
|
-
const n =
|
|
2287
|
+
const n = kt(t), r = kt(e);
|
|
2288
2288
|
return n.compareTo(r);
|
|
2289
2289
|
}(t.bytesValue, e.bytesValue);
|
|
2290
2290
|
|
|
@@ -2292,34 +2292,34 @@ function Qt(t, e) {
|
|
|
2292
2292
|
return function(t, e) {
|
|
2293
2293
|
const n = t.split("/"), r = e.split("/");
|
|
2294
2294
|
for (let t = 0; t < n.length && t < r.length; t++) {
|
|
2295
|
-
const e =
|
|
2295
|
+
const e = vt(n[t], r[t]);
|
|
2296
2296
|
if (0 !== e) return e;
|
|
2297
2297
|
}
|
|
2298
|
-
return
|
|
2298
|
+
return vt(n.length, r.length);
|
|
2299
2299
|
}(t.referenceValue, e.referenceValue);
|
|
2300
2300
|
|
|
2301
2301
|
case 8 /* GeoPointValue */ :
|
|
2302
2302
|
return function(t, e) {
|
|
2303
|
-
const n =
|
|
2303
|
+
const n = vt(Ot(t.latitude), Ot(e.latitude));
|
|
2304
2304
|
if (0 !== n) return n;
|
|
2305
|
-
return
|
|
2305
|
+
return vt(Ot(t.longitude), Ot(e.longitude));
|
|
2306
2306
|
}(t.geoPointValue, e.geoPointValue);
|
|
2307
2307
|
|
|
2308
2308
|
case 9 /* ArrayValue */ :
|
|
2309
2309
|
return function(t, e) {
|
|
2310
2310
|
const n = t.values || [], r = e.values || [];
|
|
2311
2311
|
for (let t = 0; t < n.length && t < r.length; ++t) {
|
|
2312
|
-
const e =
|
|
2312
|
+
const e = zt(n[t], r[t]);
|
|
2313
2313
|
if (e) return e;
|
|
2314
2314
|
}
|
|
2315
|
-
return
|
|
2315
|
+
return vt(n.length, r.length);
|
|
2316
2316
|
}(t.arrayValue, e.arrayValue);
|
|
2317
2317
|
|
|
2318
2318
|
case 10 /* ObjectValue */ :
|
|
2319
2319
|
return function(t, e) {
|
|
2320
|
-
if (t ===
|
|
2321
|
-
if (t ===
|
|
2322
|
-
if (e ===
|
|
2320
|
+
if (t === Ut && e === Ut) return 0;
|
|
2321
|
+
if (t === Ut) return 1;
|
|
2322
|
+
if (e === Ut) return -1;
|
|
2323
2323
|
const n = t.fields || {}, r = Object.keys(n), s = e.fields || {}, i = Object.keys(s);
|
|
2324
2324
|
// Even though MapValues are likely sorted correctly based on their insertion
|
|
2325
2325
|
// order (e.g. when received from the backend), local modifications can bring
|
|
@@ -2327,49 +2327,49 @@ function Qt(t, e) {
|
|
|
2327
2327
|
// canonical IDs are independent of insertion order.
|
|
2328
2328
|
r.sort(), i.sort();
|
|
2329
2329
|
for (let t = 0; t < r.length && t < i.length; ++t) {
|
|
2330
|
-
const e =
|
|
2330
|
+
const e = vt(r[t], i[t]);
|
|
2331
2331
|
if (0 !== e) return e;
|
|
2332
|
-
const o =
|
|
2332
|
+
const o = zt(n[r[t]], s[i[t]]);
|
|
2333
2333
|
if (0 !== o) return o;
|
|
2334
2334
|
}
|
|
2335
|
-
return
|
|
2335
|
+
return vt(r.length, i.length);
|
|
2336
2336
|
}
|
|
2337
2337
|
/** Returns a reference value for the provided database and key. */ (t.mapValue, e.mapValue);
|
|
2338
2338
|
|
|
2339
2339
|
default:
|
|
2340
|
-
throw
|
|
2340
|
+
throw E();
|
|
2341
2341
|
}
|
|
2342
2342
|
}
|
|
2343
2343
|
|
|
2344
|
-
function
|
|
2345
|
-
if ("string" == typeof t && "string" == typeof e && t.length === e.length) return
|
|
2346
|
-
const n =
|
|
2347
|
-
return 0 !== s ? s :
|
|
2344
|
+
function Wt(t, e) {
|
|
2345
|
+
if ("string" == typeof t && "string" == typeof e && t.length === e.length) return vt(t, e);
|
|
2346
|
+
const n = qt(t), r = qt(e), s = vt(n.seconds, r.seconds);
|
|
2347
|
+
return 0 !== s ? s : vt(n.nanos, r.nanos);
|
|
2348
2348
|
}
|
|
2349
2349
|
|
|
2350
|
-
function
|
|
2350
|
+
function Gt(t, e) {
|
|
2351
2351
|
return {
|
|
2352
2352
|
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${e.path.canonicalString()}`
|
|
2353
2353
|
};
|
|
2354
2354
|
}
|
|
2355
2355
|
|
|
2356
|
-
/** Returns true if `value` is an ArrayValue. */ function
|
|
2356
|
+
/** Returns true if `value` is an ArrayValue. */ function Kt(t) {
|
|
2357
2357
|
return !!t && "arrayValue" in t;
|
|
2358
2358
|
}
|
|
2359
2359
|
|
|
2360
|
-
/** Returns true if `value` is a NullValue. */ function
|
|
2360
|
+
/** Returns true if `value` is a NullValue. */ function Yt(t) {
|
|
2361
2361
|
return !!t && "nullValue" in t;
|
|
2362
2362
|
}
|
|
2363
2363
|
|
|
2364
|
-
/** Returns true if `value` is NaN. */ function
|
|
2364
|
+
/** Returns true if `value` is NaN. */ function Ht(t) {
|
|
2365
2365
|
return !!t && "doubleValue" in t && isNaN(Number(t.doubleValue));
|
|
2366
2366
|
}
|
|
2367
2367
|
|
|
2368
|
-
/** Returns true if `value` is a MapValue. */ function
|
|
2368
|
+
/** Returns true if `value` is a MapValue. */ function Jt(t) {
|
|
2369
2369
|
return !!t && "mapValue" in t;
|
|
2370
2370
|
}
|
|
2371
2371
|
|
|
2372
|
-
/** Creates a deep copy of `source`. */ function
|
|
2372
|
+
/** Creates a deep copy of `source`. */ function Xt(t) {
|
|
2373
2373
|
if (t.geoPointValue) return {
|
|
2374
2374
|
geoPointValue: Object.assign({}, t.geoPointValue)
|
|
2375
2375
|
};
|
|
@@ -2382,7 +2382,7 @@ function Wt(t, e) {
|
|
|
2382
2382
|
fields: {}
|
|
2383
2383
|
}
|
|
2384
2384
|
};
|
|
2385
|
-
return
|
|
2385
|
+
return At(t.mapValue.fields, ((t, n) => e.mapValue.fields[t] = Xt(n))), e;
|
|
2386
2386
|
}
|
|
2387
2387
|
if (t.arrayValue) {
|
|
2388
2388
|
const e = {
|
|
@@ -2390,18 +2390,18 @@ function Wt(t, e) {
|
|
|
2390
2390
|
values: []
|
|
2391
2391
|
}
|
|
2392
2392
|
};
|
|
2393
|
-
for (let n = 0; n < (t.arrayValue.values || []).length; ++n) e.arrayValue.values[n] =
|
|
2393
|
+
for (let n = 0; n < (t.arrayValue.values || []).length; ++n) e.arrayValue.values[n] = Xt(t.arrayValue.values[n]);
|
|
2394
2394
|
return e;
|
|
2395
2395
|
}
|
|
2396
2396
|
return Object.assign({}, t);
|
|
2397
2397
|
}
|
|
2398
2398
|
|
|
2399
|
-
class
|
|
2399
|
+
class Zt {
|
|
2400
2400
|
constructor(t) {
|
|
2401
2401
|
this.value = t;
|
|
2402
2402
|
}
|
|
2403
2403
|
static empty() {
|
|
2404
|
-
return new
|
|
2404
|
+
return new Zt({
|
|
2405
2405
|
mapValue: {}
|
|
2406
2406
|
});
|
|
2407
2407
|
}
|
|
@@ -2415,7 +2415,7 @@ class Xt {
|
|
|
2415
2415
|
{
|
|
2416
2416
|
let e = this.value;
|
|
2417
2417
|
for (let n = 0; n < t.length - 1; ++n) if (e = (e.mapValue.fields || {})[t.get(n)],
|
|
2418
|
-
!
|
|
2418
|
+
!Jt(e)) return null;
|
|
2419
2419
|
return e = (e.mapValue.fields || {})[t.lastSegment()], e || null;
|
|
2420
2420
|
}
|
|
2421
2421
|
}
|
|
@@ -2425,21 +2425,21 @@ class Xt {
|
|
|
2425
2425
|
* @param path - The field path to set.
|
|
2426
2426
|
* @param value - The value to set.
|
|
2427
2427
|
*/ set(t, e) {
|
|
2428
|
-
this.getFieldsMap(t.popLast())[t.lastSegment()] =
|
|
2428
|
+
this.getFieldsMap(t.popLast())[t.lastSegment()] = Xt(e);
|
|
2429
2429
|
}
|
|
2430
2430
|
/**
|
|
2431
2431
|
* Sets the provided fields to the provided values.
|
|
2432
2432
|
*
|
|
2433
2433
|
* @param data - A map of fields to values (or null for deletes).
|
|
2434
2434
|
*/ setAll(t) {
|
|
2435
|
-
let e =
|
|
2435
|
+
let e = rt.emptyPath(), n = {}, r = [];
|
|
2436
2436
|
t.forEach(((t, s) => {
|
|
2437
2437
|
if (!e.isImmediateParentOf(s)) {
|
|
2438
2438
|
// Insert the accumulated changes at this parent location
|
|
2439
2439
|
const t = this.getFieldsMap(e);
|
|
2440
2440
|
this.applyChanges(t, n, r), n = {}, r = [], e = s.popLast();
|
|
2441
2441
|
}
|
|
2442
|
-
t ? n[s.lastSegment()] =
|
|
2442
|
+
t ? n[s.lastSegment()] = Xt(t) : r.push(s.lastSegment());
|
|
2443
2443
|
}));
|
|
2444
2444
|
const s = this.getFieldsMap(e);
|
|
2445
2445
|
this.applyChanges(s, n, r);
|
|
@@ -2451,10 +2451,10 @@ class Xt {
|
|
|
2451
2451
|
* @param path - The field path to remove.
|
|
2452
2452
|
*/ delete(t) {
|
|
2453
2453
|
const e = this.field(t.popLast());
|
|
2454
|
-
|
|
2454
|
+
Jt(e) && e.mapValue.fields && delete e.mapValue.fields[t.lastSegment()];
|
|
2455
2455
|
}
|
|
2456
2456
|
isEqual(t) {
|
|
2457
|
-
return
|
|
2457
|
+
return Bt(this.value, t.value);
|
|
2458
2458
|
}
|
|
2459
2459
|
/**
|
|
2460
2460
|
* Returns the map that contains the leaf element of `path`. If the parent
|
|
@@ -2466,7 +2466,7 @@ class Xt {
|
|
|
2466
2466
|
});
|
|
2467
2467
|
for (let n = 0; n < t.length; ++n) {
|
|
2468
2468
|
let r = e.mapValue.fields[t.get(n)];
|
|
2469
|
-
|
|
2469
|
+
Jt(r) && r.mapValue.fields || (r = {
|
|
2470
2470
|
mapValue: {
|
|
2471
2471
|
fields: {}
|
|
2472
2472
|
}
|
|
@@ -2478,11 +2478,11 @@ class Xt {
|
|
|
2478
2478
|
* Modifies `fieldsMap` by adding, replacing or deleting the specified
|
|
2479
2479
|
* entries.
|
|
2480
2480
|
*/ applyChanges(t, e, n) {
|
|
2481
|
-
|
|
2481
|
+
At(e, ((e, n) => t[e] = n));
|
|
2482
2482
|
for (const e of n) delete t[e];
|
|
2483
2483
|
}
|
|
2484
2484
|
clone() {
|
|
2485
|
-
return new Xt(
|
|
2485
|
+
return new Zt(Xt(this.value));
|
|
2486
2486
|
}
|
|
2487
2487
|
}
|
|
2488
2488
|
|
|
@@ -2511,7 +2511,7 @@ class Xt {
|
|
|
2511
2511
|
* not transition to one of these states even after all mutations have been
|
|
2512
2512
|
* applied, `isValidDocument()` returns false and the document should be removed
|
|
2513
2513
|
* from all views.
|
|
2514
|
-
*/ class
|
|
2514
|
+
*/ class te {
|
|
2515
2515
|
constructor(t, e, n, r, s, i) {
|
|
2516
2516
|
this.key = t, this.documentType = e, this.version = n, this.readTime = r, this.data = s,
|
|
2517
2517
|
this.documentState = i;
|
|
@@ -2520,23 +2520,23 @@ class Xt {
|
|
|
2520
2520
|
* Creates a document with no known version or data, but which can serve as
|
|
2521
2521
|
* base document for mutations.
|
|
2522
2522
|
*/ static newInvalidDocument(t) {
|
|
2523
|
-
return new
|
|
2523
|
+
return new te(t, 0 /* INVALID */ , It.min(), It.min(), Zt.empty(), 0 /* SYNCED */);
|
|
2524
2524
|
}
|
|
2525
2525
|
/**
|
|
2526
2526
|
* Creates a new document that is known to exist with the given data at the
|
|
2527
2527
|
* given version.
|
|
2528
2528
|
*/ static newFoundDocument(t, e, n) {
|
|
2529
|
-
return new
|
|
2529
|
+
return new te(t, 1 /* FOUND_DOCUMENT */ , e, It.min(), n, 0 /* SYNCED */);
|
|
2530
2530
|
}
|
|
2531
2531
|
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t, e) {
|
|
2532
|
-
return new
|
|
2532
|
+
return new te(t, 2 /* NO_DOCUMENT */ , e, It.min(), Zt.empty(), 0 /* SYNCED */);
|
|
2533
2533
|
}
|
|
2534
2534
|
/**
|
|
2535
2535
|
* Creates a new document that is known to exist at the given version but
|
|
2536
2536
|
* whose data is not known (e.g. a document that was updated without a known
|
|
2537
2537
|
* base document).
|
|
2538
2538
|
*/ static newUnknownDocument(t, e) {
|
|
2539
|
-
return new
|
|
2539
|
+
return new te(t, 3 /* UNKNOWN_DOCUMENT */ , e, It.min(), Zt.empty(), 2 /* HAS_COMMITTED_MUTATIONS */);
|
|
2540
2540
|
}
|
|
2541
2541
|
/**
|
|
2542
2542
|
* Changes the document type to indicate that it exists and that its version
|
|
@@ -2549,7 +2549,7 @@ class Xt {
|
|
|
2549
2549
|
* Changes the document type to indicate that it doesn't exist at the given
|
|
2550
2550
|
* version.
|
|
2551
2551
|
*/ convertToNoDocument(t) {
|
|
2552
|
-
return this.version = t, this.documentType = 2 /* NO_DOCUMENT */ , this.data =
|
|
2552
|
+
return this.version = t, this.documentType = 2 /* NO_DOCUMENT */ , this.data = Zt.empty(),
|
|
2553
2553
|
this.documentState = 0 /* SYNCED */ , this;
|
|
2554
2554
|
}
|
|
2555
2555
|
/**
|
|
@@ -2557,14 +2557,14 @@ class Xt {
|
|
|
2557
2557
|
* that its data is not known (e.g. a document that was updated without a known
|
|
2558
2558
|
* base document).
|
|
2559
2559
|
*/ convertToUnknownDocument(t) {
|
|
2560
|
-
return this.version = t, this.documentType = 3 /* UNKNOWN_DOCUMENT */ , this.data =
|
|
2560
|
+
return this.version = t, this.documentType = 3 /* UNKNOWN_DOCUMENT */ , this.data = Zt.empty(),
|
|
2561
2561
|
this.documentState = 2 /* HAS_COMMITTED_MUTATIONS */ , this;
|
|
2562
2562
|
}
|
|
2563
2563
|
setHasCommittedMutations() {
|
|
2564
2564
|
return this.documentState = 2 /* HAS_COMMITTED_MUTATIONS */ , this;
|
|
2565
2565
|
}
|
|
2566
2566
|
setHasLocalMutations() {
|
|
2567
|
-
return this.documentState = 1 /* HAS_LOCAL_MUTATIONS */ , this.version =
|
|
2567
|
+
return this.documentState = 1 /* HAS_LOCAL_MUTATIONS */ , this.version = It.min(),
|
|
2568
2568
|
this;
|
|
2569
2569
|
}
|
|
2570
2570
|
setReadTime(t) {
|
|
@@ -2592,10 +2592,10 @@ class Xt {
|
|
|
2592
2592
|
return 3 /* UNKNOWN_DOCUMENT */ === this.documentType;
|
|
2593
2593
|
}
|
|
2594
2594
|
isEqual(t) {
|
|
2595
|
-
return t instanceof
|
|
2595
|
+
return t instanceof te && this.key.isEqual(t.key) && this.version.isEqual(t.version) && this.documentType === t.documentType && this.documentState === t.documentState && this.data.isEqual(t.data);
|
|
2596
2596
|
}
|
|
2597
2597
|
mutableCopy() {
|
|
2598
|
-
return new
|
|
2598
|
+
return new te(this.key, this.documentType, this.version, this.readTime, this.data.clone(), this.documentState);
|
|
2599
2599
|
}
|
|
2600
2600
|
toString() {
|
|
2601
2601
|
return `Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`;
|
|
@@ -2619,7 +2619,7 @@ class Xt {
|
|
|
2619
2619
|
* limitations under the License.
|
|
2620
2620
|
*/
|
|
2621
2621
|
// Visible for testing
|
|
2622
|
-
class
|
|
2622
|
+
class ee {
|
|
2623
2623
|
constructor(t, e = null, n = [], r = [], s = null, i = null, o = null) {
|
|
2624
2624
|
this.path = t, this.collectionGroup = e, this.orderBy = n, this.filters = r, this.limit = s,
|
|
2625
2625
|
this.startAt = i, this.endAt = o, this.D = null;
|
|
@@ -2633,26 +2633,26 @@ class te {
|
|
|
2633
2633
|
* NOTE: you should always construct `Target` from `Query.toTarget` instead of
|
|
2634
2634
|
* using this factory method, because `Query` provides an implicit `orderBy`
|
|
2635
2635
|
* property.
|
|
2636
|
-
*/ function
|
|
2637
|
-
return new
|
|
2636
|
+
*/ function ne(t, e = null, n = [], r = [], s = null, i = null, o = null) {
|
|
2637
|
+
return new ee(t, e, n, r, s, i, o);
|
|
2638
2638
|
}
|
|
2639
2639
|
|
|
2640
|
-
class
|
|
2640
|
+
class re extends class {} {
|
|
2641
2641
|
constructor(t, e, n) {
|
|
2642
2642
|
super(), this.field = t, this.op = e, this.value = n;
|
|
2643
2643
|
}
|
|
2644
2644
|
/**
|
|
2645
2645
|
* Creates a filter based on the provided arguments.
|
|
2646
2646
|
*/ static create(t, e, n) {
|
|
2647
|
-
return t.isKeyField() ? "in" /* IN */ === e || "not-in" /* NOT_IN */ === e ? this.S(t, e, n) : new
|
|
2647
|
+
return t.isKeyField() ? "in" /* IN */ === e || "not-in" /* NOT_IN */ === e ? this.S(t, e, n) : new se(t, e, n) : "array-contains" /* ARRAY_CONTAINS */ === e ? new ce(t, n) : "in" /* IN */ === e ? new ae(t, n) : "not-in" /* NOT_IN */ === e ? new he(t, n) : "array-contains-any" /* ARRAY_CONTAINS_ANY */ === e ? new le(t, n) : new re(t, e, n);
|
|
2648
2648
|
}
|
|
2649
2649
|
static S(t, e, n) {
|
|
2650
|
-
return "in" /* IN */ === e ? new
|
|
2650
|
+
return "in" /* IN */ === e ? new ie(t, n) : new oe(t, n);
|
|
2651
2651
|
}
|
|
2652
2652
|
matches(t) {
|
|
2653
2653
|
const e = t.data.field(this.field);
|
|
2654
2654
|
// Types do not have to match in NOT_EQUAL filters.
|
|
2655
|
-
return "!=" /* NOT_EQUAL */ === this.op ? null !== e && this.F(
|
|
2655
|
+
return "!=" /* NOT_EQUAL */ === this.op ? null !== e && this.F(zt(e, this.value)) : null !== e && jt(this.value) === jt(e) && this.F(zt(e, this.value));
|
|
2656
2656
|
// Only compare types with matching backend order (such as double and int).
|
|
2657
2657
|
}
|
|
2658
2658
|
F(t) {
|
|
@@ -2676,7 +2676,7 @@ class ne extends class {} {
|
|
|
2676
2676
|
return t >= 0;
|
|
2677
2677
|
|
|
2678
2678
|
default:
|
|
2679
|
-
return
|
|
2679
|
+
return E();
|
|
2680
2680
|
}
|
|
2681
2681
|
}
|
|
2682
2682
|
q() {
|
|
@@ -2685,79 +2685,79 @@ class ne extends class {} {
|
|
|
2685
2685
|
}
|
|
2686
2686
|
|
|
2687
2687
|
/** Filter that matches on key fields (i.e. '__name__'). */
|
|
2688
|
-
class
|
|
2688
|
+
class se extends re {
|
|
2689
2689
|
constructor(t, e, n) {
|
|
2690
|
-
super(t, e, n), this.key =
|
|
2690
|
+
super(t, e, n), this.key = st.fromName(n.referenceValue);
|
|
2691
2691
|
}
|
|
2692
2692
|
matches(t) {
|
|
2693
|
-
const e =
|
|
2693
|
+
const e = st.comparator(t.key, this.key);
|
|
2694
2694
|
return this.F(e);
|
|
2695
2695
|
}
|
|
2696
2696
|
}
|
|
2697
2697
|
|
|
2698
|
-
/** Filter that matches on key fields within an array. */ class
|
|
2698
|
+
/** Filter that matches on key fields within an array. */ class ie extends re {
|
|
2699
2699
|
constructor(t, e) {
|
|
2700
|
-
super(t, "in" /* IN */ , e), this.keys =
|
|
2700
|
+
super(t, "in" /* IN */ , e), this.keys = ue("in" /* IN */ , e);
|
|
2701
2701
|
}
|
|
2702
2702
|
matches(t) {
|
|
2703
2703
|
return this.keys.some((e => e.isEqual(t.key)));
|
|
2704
2704
|
}
|
|
2705
2705
|
}
|
|
2706
2706
|
|
|
2707
|
-
/** Filter that matches on key fields not present within an array. */ class
|
|
2707
|
+
/** Filter that matches on key fields not present within an array. */ class oe extends re {
|
|
2708
2708
|
constructor(t, e) {
|
|
2709
|
-
super(t, "not-in" /* NOT_IN */ , e), this.keys =
|
|
2709
|
+
super(t, "not-in" /* NOT_IN */ , e), this.keys = ue("not-in" /* NOT_IN */ , e);
|
|
2710
2710
|
}
|
|
2711
2711
|
matches(t) {
|
|
2712
2712
|
return !this.keys.some((e => e.isEqual(t.key)));
|
|
2713
2713
|
}
|
|
2714
2714
|
}
|
|
2715
2715
|
|
|
2716
|
-
function
|
|
2716
|
+
function ue(t, e) {
|
|
2717
2717
|
var n;
|
|
2718
|
-
return ((null === (n = e.arrayValue) || void 0 === n ? void 0 : n.values) || []).map((t =>
|
|
2718
|
+
return ((null === (n = e.arrayValue) || void 0 === n ? void 0 : n.values) || []).map((t => st.fromName(t.referenceValue)));
|
|
2719
2719
|
}
|
|
2720
2720
|
|
|
2721
|
-
/** A Filter that implements the array-contains operator. */ class
|
|
2721
|
+
/** A Filter that implements the array-contains operator. */ class ce extends re {
|
|
2722
2722
|
constructor(t, e) {
|
|
2723
2723
|
super(t, "array-contains" /* ARRAY_CONTAINS */ , e);
|
|
2724
2724
|
}
|
|
2725
2725
|
matches(t) {
|
|
2726
2726
|
const e = t.data.field(this.field);
|
|
2727
|
-
return
|
|
2727
|
+
return Kt(e) && Qt(e.arrayValue, this.value);
|
|
2728
2728
|
}
|
|
2729
2729
|
}
|
|
2730
2730
|
|
|
2731
|
-
/** A Filter that implements the IN operator. */ class
|
|
2731
|
+
/** A Filter that implements the IN operator. */ class ae extends re {
|
|
2732
2732
|
constructor(t, e) {
|
|
2733
2733
|
super(t, "in" /* IN */ , e);
|
|
2734
2734
|
}
|
|
2735
2735
|
matches(t) {
|
|
2736
2736
|
const e = t.data.field(this.field);
|
|
2737
|
-
return null !== e &&
|
|
2737
|
+
return null !== e && Qt(this.value.arrayValue, e);
|
|
2738
2738
|
}
|
|
2739
2739
|
}
|
|
2740
2740
|
|
|
2741
|
-
/** A Filter that implements the not-in operator. */ class
|
|
2741
|
+
/** A Filter that implements the not-in operator. */ class he extends re {
|
|
2742
2742
|
constructor(t, e) {
|
|
2743
2743
|
super(t, "not-in" /* NOT_IN */ , e);
|
|
2744
2744
|
}
|
|
2745
2745
|
matches(t) {
|
|
2746
|
-
if (
|
|
2746
|
+
if (Qt(this.value.arrayValue, {
|
|
2747
2747
|
nullValue: "NULL_VALUE"
|
|
2748
2748
|
})) return !1;
|
|
2749
2749
|
const e = t.data.field(this.field);
|
|
2750
|
-
return null !== e && !
|
|
2750
|
+
return null !== e && !Qt(this.value.arrayValue, e);
|
|
2751
2751
|
}
|
|
2752
2752
|
}
|
|
2753
2753
|
|
|
2754
|
-
/** A Filter that implements the array-contains-any operator. */ class
|
|
2754
|
+
/** A Filter that implements the array-contains-any operator. */ class le extends re {
|
|
2755
2755
|
constructor(t, e) {
|
|
2756
2756
|
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ , e);
|
|
2757
2757
|
}
|
|
2758
2758
|
matches(t) {
|
|
2759
2759
|
const e = t.data.field(this.field);
|
|
2760
|
-
return !(!
|
|
2760
|
+
return !(!Kt(e) || !e.arrayValue.values) && e.arrayValue.values.some((t => Qt(this.value.arrayValue, t)));
|
|
2761
2761
|
}
|
|
2762
2762
|
}
|
|
2763
2763
|
|
|
@@ -2774,7 +2774,7 @@ function oe(t, e) {
|
|
|
2774
2774
|
* Bound provides a function to determine whether a document comes before or
|
|
2775
2775
|
* after a bound. This is influenced by whether the position is just before or
|
|
2776
2776
|
* just after the provided values.
|
|
2777
|
-
*/ class
|
|
2777
|
+
*/ class fe {
|
|
2778
2778
|
constructor(t, e) {
|
|
2779
2779
|
this.position = t, this.inclusive = e;
|
|
2780
2780
|
}
|
|
@@ -2782,22 +2782,22 @@ function oe(t, e) {
|
|
|
2782
2782
|
|
|
2783
2783
|
/**
|
|
2784
2784
|
* An ordering on a field, in some Direction. Direction defaults to ASCENDING.
|
|
2785
|
-
*/ class
|
|
2785
|
+
*/ class de {
|
|
2786
2786
|
constructor(t, e = "asc" /* ASCENDING */) {
|
|
2787
2787
|
this.field = t, this.dir = e;
|
|
2788
2788
|
}
|
|
2789
2789
|
}
|
|
2790
2790
|
|
|
2791
|
-
function
|
|
2791
|
+
function we(t, e) {
|
|
2792
2792
|
return t.dir === e.dir && t.field.isEqual(e.field);
|
|
2793
2793
|
}
|
|
2794
2794
|
|
|
2795
|
-
function
|
|
2795
|
+
function me(t, e) {
|
|
2796
2796
|
if (null === t) return null === e;
|
|
2797
2797
|
if (null === e) return !1;
|
|
2798
2798
|
if (t.inclusive !== e.inclusive || t.position.length !== e.position.length) return !1;
|
|
2799
2799
|
for (let n = 0; n < t.position.length; n++) {
|
|
2800
|
-
if (!
|
|
2800
|
+
if (!Bt(t.position[n], e.position[n])) return !1;
|
|
2801
2801
|
}
|
|
2802
2802
|
return !0;
|
|
2803
2803
|
}
|
|
@@ -2824,7 +2824,7 @@ function we(t, e) {
|
|
|
2824
2824
|
* query the RemoteStore results.
|
|
2825
2825
|
*
|
|
2826
2826
|
* Visible for testing.
|
|
2827
|
-
*/ class
|
|
2827
|
+
*/ class pe {
|
|
2828
2828
|
/**
|
|
2829
2829
|
* Initializes a Query with a path and optional additional query constraints.
|
|
2830
2830
|
* Path must currently be empty if this is a collection group query.
|
|
@@ -2837,11 +2837,11 @@ function we(t, e) {
|
|
|
2837
2837
|
}
|
|
2838
2838
|
}
|
|
2839
2839
|
|
|
2840
|
-
/** Creates a new Query for a query that matches all documents at `path` */ function
|
|
2840
|
+
/** Creates a new Query for a query that matches all documents at `path` */ function ye(t) {
|
|
2841
2841
|
return t.explicitOrderBy.length > 0 ? t.explicitOrderBy[0].field : null;
|
|
2842
2842
|
}
|
|
2843
2843
|
|
|
2844
|
-
function
|
|
2844
|
+
function ge(t) {
|
|
2845
2845
|
for (const e of t.filters) if (e.q()) return e.field;
|
|
2846
2846
|
return null;
|
|
2847
2847
|
}
|
|
@@ -2854,7 +2854,7 @@ function ye(t) {
|
|
|
2854
2854
|
* Returns whether the query matches a collection group rather than a specific
|
|
2855
2855
|
* collection.
|
|
2856
2856
|
*/
|
|
2857
|
-
function
|
|
2857
|
+
function _e(t) {
|
|
2858
2858
|
return null !== t.collectionGroup;
|
|
2859
2859
|
}
|
|
2860
2860
|
|
|
@@ -2862,23 +2862,23 @@ function ge(t) {
|
|
|
2862
2862
|
* Returns the implicit order by constraint that is used to execute the Query,
|
|
2863
2863
|
* which can be different from the order by constraints the user provided (e.g.
|
|
2864
2864
|
* the SDK and backend always orders by `__name__`).
|
|
2865
|
-
*/ function
|
|
2866
|
-
const e =
|
|
2865
|
+
*/ function ve(t) {
|
|
2866
|
+
const e = T(t);
|
|
2867
2867
|
if (null === e.O) {
|
|
2868
2868
|
e.O = [];
|
|
2869
|
-
const t =
|
|
2869
|
+
const t = ge(e), n = ye(e);
|
|
2870
2870
|
if (null !== t && null === n)
|
|
2871
2871
|
// In order to implicitly add key ordering, we must also add the
|
|
2872
2872
|
// inequality filter field for it to be a valid query.
|
|
2873
2873
|
// Note that the default inequality field and key ordering is ascending.
|
|
2874
|
-
t.isKeyField() || e.O.push(new
|
|
2874
|
+
t.isKeyField() || e.O.push(new de(t)), e.O.push(new de(rt.keyField(), "asc" /* ASCENDING */)); else {
|
|
2875
2875
|
let t = !1;
|
|
2876
2876
|
for (const n of e.explicitOrderBy) e.O.push(n), n.field.isKeyField() && (t = !0);
|
|
2877
2877
|
if (!t) {
|
|
2878
2878
|
// The order of the implicit key ordering always matches the last
|
|
2879
2879
|
// explicit order by
|
|
2880
2880
|
const t = e.explicitOrderBy.length > 0 ? e.explicitOrderBy[e.explicitOrderBy.length - 1].dir : "asc" /* ASCENDING */;
|
|
2881
|
-
e.O.push(new
|
|
2881
|
+
e.O.push(new de(rt.keyField(), t));
|
|
2882
2882
|
}
|
|
2883
2883
|
}
|
|
2884
2884
|
}
|
|
@@ -2887,34 +2887,34 @@ function ge(t) {
|
|
|
2887
2887
|
|
|
2888
2888
|
/**
|
|
2889
2889
|
* Converts this `Query` instance to it's corresponding `Target` representation.
|
|
2890
|
-
*/ function
|
|
2891
|
-
const e =
|
|
2892
|
-
if (!e.k) if ("F" /* First */ === e.limitType) e.k =
|
|
2890
|
+
*/ function be(t) {
|
|
2891
|
+
const e = T(t);
|
|
2892
|
+
if (!e.k) if ("F" /* First */ === e.limitType) e.k = ne(e.path, e.collectionGroup, ve(e), e.filters, e.limit, e.startAt, e.endAt); else {
|
|
2893
2893
|
// Flip the orderBy directions since we want the last results
|
|
2894
2894
|
const t = [];
|
|
2895
|
-
for (const n of
|
|
2895
|
+
for (const n of ve(e)) {
|
|
2896
2896
|
const e = "desc" /* DESCENDING */ === n.dir ? "asc" /* ASCENDING */ : "desc" /* DESCENDING */;
|
|
2897
|
-
t.push(new
|
|
2897
|
+
t.push(new de(n.field, e));
|
|
2898
2898
|
}
|
|
2899
2899
|
// We need to swap the cursors to match the now-flipped query ordering.
|
|
2900
|
-
const n = e.endAt ? new
|
|
2900
|
+
const n = e.endAt ? new fe(e.endAt.position, e.endAt.inclusive) : null, r = e.startAt ? new fe(e.startAt.position, e.startAt.inclusive) : null;
|
|
2901
2901
|
// Now return as a LimitType.First query.
|
|
2902
|
-
e.k =
|
|
2902
|
+
e.k = ne(e.path, e.collectionGroup, t, e.filters, e.limit, n, r);
|
|
2903
2903
|
}
|
|
2904
2904
|
return e.k;
|
|
2905
2905
|
}
|
|
2906
2906
|
|
|
2907
|
-
function
|
|
2907
|
+
function Ee(t, e) {
|
|
2908
2908
|
return function(t, e) {
|
|
2909
2909
|
if (t.limit !== e.limit) return !1;
|
|
2910
2910
|
if (t.orderBy.length !== e.orderBy.length) return !1;
|
|
2911
|
-
for (let n = 0; n < t.orderBy.length; n++) if (!
|
|
2911
|
+
for (let n = 0; n < t.orderBy.length; n++) if (!we(t.orderBy[n], e.orderBy[n])) return !1;
|
|
2912
2912
|
if (t.filters.length !== e.filters.length) return !1;
|
|
2913
2913
|
for (let s = 0; s < t.filters.length; s++) if (n = t.filters[s], r = e.filters[s],
|
|
2914
|
-
n.op !== r.op || !n.field.isEqual(r.field) || !
|
|
2914
|
+
n.op !== r.op || !n.field.isEqual(r.field) || !Bt(n.value, r.value)) return !1;
|
|
2915
2915
|
var n, r;
|
|
2916
|
-
return t.collectionGroup === e.collectionGroup && !!t.path.isEqual(e.path) && !!
|
|
2917
|
-
}(
|
|
2916
|
+
return t.collectionGroup === e.collectionGroup && !!t.path.isEqual(e.path) && !!me(t.startAt, e.startAt) && me(t.endAt, e.endAt);
|
|
2917
|
+
}(be(t), be(e)) && t.limitType === e.limitType;
|
|
2918
2918
|
}
|
|
2919
2919
|
|
|
2920
2920
|
/**
|
|
@@ -2942,9 +2942,9 @@ function be(t, e) {
|
|
|
2942
2942
|
* The return value is an IntegerValue if it can safely represent the value,
|
|
2943
2943
|
* otherwise a DoubleValue is returned.
|
|
2944
2944
|
*/
|
|
2945
|
-
function
|
|
2945
|
+
function Ie(t, e) {
|
|
2946
2946
|
return function(t) {
|
|
2947
|
-
return "number" == typeof t && Number.isInteger(t) && !
|
|
2947
|
+
return "number" == typeof t && Number.isInteger(t) && !ft(t) && t <= Number.MAX_SAFE_INTEGER && t >= Number.MIN_SAFE_INTEGER;
|
|
2948
2948
|
}(e) ?
|
|
2949
2949
|
/**
|
|
2950
2950
|
* Returns an IntegerValue for `value`.
|
|
@@ -2966,7 +2966,7 @@ function Ee(t, e) {
|
|
|
2966
2966
|
};
|
|
2967
2967
|
}
|
|
2968
2968
|
return {
|
|
2969
|
-
doubleValue:
|
|
2969
|
+
doubleValue: ft(e) ? "-0" : e
|
|
2970
2970
|
};
|
|
2971
2971
|
}(t, e);
|
|
2972
2972
|
}
|
|
@@ -2987,7 +2987,7 @@ function Ee(t, e) {
|
|
|
2987
2987
|
* See the License for the specific language governing permissions and
|
|
2988
2988
|
* limitations under the License.
|
|
2989
2989
|
*/
|
|
2990
|
-
/** Used to represent a field transform on a mutation. */ class
|
|
2990
|
+
/** Used to represent a field transform on a mutation. */ class Te {
|
|
2991
2991
|
constructor() {
|
|
2992
2992
|
// Make sure that the structural type of `TransformOperation` is unique.
|
|
2993
2993
|
// See https://github.com/microsoft/TypeScript/issues/5451
|
|
@@ -2995,15 +2995,15 @@ function Ee(t, e) {
|
|
|
2995
2995
|
}
|
|
2996
2996
|
}
|
|
2997
2997
|
|
|
2998
|
-
/** Transforms a value into a server-generated timestamp. */ class
|
|
2998
|
+
/** Transforms a value into a server-generated timestamp. */ class Ae extends Te {}
|
|
2999
2999
|
|
|
3000
|
-
/** Transforms an array value via a union operation. */ class
|
|
3000
|
+
/** Transforms an array value via a union operation. */ class Re extends Te {
|
|
3001
3001
|
constructor(t) {
|
|
3002
3002
|
super(), this.elements = t;
|
|
3003
3003
|
}
|
|
3004
3004
|
}
|
|
3005
3005
|
|
|
3006
|
-
/** Transforms an array value via a remove operation. */ class
|
|
3006
|
+
/** Transforms an array value via a remove operation. */ class Pe extends Te {
|
|
3007
3007
|
constructor(t) {
|
|
3008
3008
|
super(), this.elements = t;
|
|
3009
3009
|
}
|
|
@@ -3014,7 +3014,7 @@ function Ee(t, e) {
|
|
|
3014
3014
|
* transforms. Converts all field values to integers or doubles, but unlike the
|
|
3015
3015
|
* backend does not cap integer values at 2^63. Instead, JavaScript number
|
|
3016
3016
|
* arithmetic is used and precision loss can occur for values greater than 2^53.
|
|
3017
|
-
*/ class
|
|
3017
|
+
*/ class Ve extends Te {
|
|
3018
3018
|
constructor(t, e) {
|
|
3019
3019
|
super(), this.L = t, this.M = e;
|
|
3020
3020
|
}
|
|
@@ -3036,7 +3036,7 @@ function Ee(t, e) {
|
|
|
3036
3036
|
* See the License for the specific language governing permissions and
|
|
3037
3037
|
* limitations under the License.
|
|
3038
3038
|
*/
|
|
3039
|
-
/** A field path and the TransformOperation to perform upon it. */ class
|
|
3039
|
+
/** A field path and the TransformOperation to perform upon it. */ class Ne {
|
|
3040
3040
|
constructor(t, e) {
|
|
3041
3041
|
this.field = t, this.transform = e;
|
|
3042
3042
|
}
|
|
@@ -3046,18 +3046,18 @@ function Ee(t, e) {
|
|
|
3046
3046
|
* Encodes a precondition for a mutation. This follows the model that the
|
|
3047
3047
|
* backend accepts with the special case of an explicit "empty" precondition
|
|
3048
3048
|
* (meaning no precondition).
|
|
3049
|
-
*/ class
|
|
3049
|
+
*/ class $e {
|
|
3050
3050
|
constructor(t, e) {
|
|
3051
3051
|
this.updateTime = t, this.exists = e;
|
|
3052
3052
|
}
|
|
3053
3053
|
/** Creates a new empty Precondition. */ static none() {
|
|
3054
|
-
return new
|
|
3054
|
+
return new $e;
|
|
3055
3055
|
}
|
|
3056
3056
|
/** Creates a new Precondition with an exists flag. */ static exists(t) {
|
|
3057
|
-
return new
|
|
3057
|
+
return new $e(void 0, t);
|
|
3058
3058
|
}
|
|
3059
3059
|
/** Creates a new Precondition based on a version a document exists at. */ static updateTime(t) {
|
|
3060
|
-
return new
|
|
3060
|
+
return new $e(t);
|
|
3061
3061
|
}
|
|
3062
3062
|
/** Returns whether this Precondition is empty. */ get isNone() {
|
|
3063
3063
|
return void 0 === this.updateTime && void 0 === this.exists;
|
|
@@ -3110,12 +3110,12 @@ function Ee(t, e) {
|
|
|
3110
3110
|
* applyToLocalView() to implement the actual behavior of applying the mutation
|
|
3111
3111
|
* to some source document (see `setMutationApplyToRemoteDocument()` for an
|
|
3112
3112
|
* example).
|
|
3113
|
-
*/ class
|
|
3113
|
+
*/ class De {}
|
|
3114
3114
|
|
|
3115
3115
|
/**
|
|
3116
3116
|
* A mutation that creates or replaces the document at the given key with the
|
|
3117
3117
|
* object value contents.
|
|
3118
|
-
*/ class
|
|
3118
|
+
*/ class xe extends De {
|
|
3119
3119
|
constructor(t, e, n, r = []) {
|
|
3120
3120
|
super(), this.key = t, this.value = e, this.precondition = n, this.fieldTransforms = r,
|
|
3121
3121
|
this.type = 0 /* Set */;
|
|
@@ -3137,7 +3137,7 @@ function Ee(t, e) {
|
|
|
3137
3137
|
* is deleted.
|
|
3138
3138
|
* * When a field is not in the mask but is in the values, the values map is
|
|
3139
3139
|
* ignored.
|
|
3140
|
-
*/ class
|
|
3140
|
+
*/ class Se extends De {
|
|
3141
3141
|
constructor(t, e, n, r, s = []) {
|
|
3142
3142
|
super(), this.key = t, this.data = e, this.fieldMask = n, this.precondition = r,
|
|
3143
3143
|
this.fieldTransforms = s, this.type = 1 /* Patch */;
|
|
@@ -3147,7 +3147,7 @@ function Ee(t, e) {
|
|
|
3147
3147
|
}
|
|
3148
3148
|
}
|
|
3149
3149
|
|
|
3150
|
-
/** A mutation that deletes the document at the given key. */ class
|
|
3150
|
+
/** A mutation that deletes the document at the given key. */ class Fe extends De {
|
|
3151
3151
|
constructor(t, e) {
|
|
3152
3152
|
super(), this.key = t, this.precondition = e, this.type = 2 /* Delete */ , this.fieldTransforms = [];
|
|
3153
3153
|
}
|
|
@@ -3162,7 +3162,7 @@ function Ee(t, e) {
|
|
|
3162
3162
|
*
|
|
3163
3163
|
* The `verify` operation is only used in Transactions, and this class serves
|
|
3164
3164
|
* primarily to facilitate serialization into protos.
|
|
3165
|
-
*/ class
|
|
3165
|
+
*/ class qe extends De {
|
|
3166
3166
|
constructor(t, e) {
|
|
3167
3167
|
super(), this.key = t, this.precondition = e, this.type = 3 /* Verify */ , this.fieldTransforms = [];
|
|
3168
3168
|
}
|
|
@@ -3186,13 +3186,13 @@ function Ee(t, e) {
|
|
|
3186
3186
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3187
3187
|
* See the License for the specific language governing permissions and
|
|
3188
3188
|
* limitations under the License.
|
|
3189
|
-
*/ const
|
|
3189
|
+
*/ const Oe = (() => {
|
|
3190
3190
|
const t = {
|
|
3191
3191
|
asc: "ASCENDING",
|
|
3192
3192
|
desc: "DESCENDING"
|
|
3193
3193
|
};
|
|
3194
3194
|
return t;
|
|
3195
|
-
})(),
|
|
3195
|
+
})(), ke = (() => {
|
|
3196
3196
|
const t = {
|
|
3197
3197
|
"<": "LESS_THAN",
|
|
3198
3198
|
"<=": "LESS_THAN_OR_EQUAL",
|
|
@@ -3222,7 +3222,7 @@ function Ee(t, e) {
|
|
|
3222
3222
|
* TODO(klimt): We can remove the databaseId argument if we keep the full
|
|
3223
3223
|
* resource name in documents.
|
|
3224
3224
|
*/
|
|
3225
|
-
class
|
|
3225
|
+
class Ce {
|
|
3226
3226
|
constructor(t, e) {
|
|
3227
3227
|
this.databaseId = t, this.C = e;
|
|
3228
3228
|
}
|
|
@@ -3239,7 +3239,7 @@ class ke {
|
|
|
3239
3239
|
/**
|
|
3240
3240
|
* Returns a value for a Date that's appropriate to put into a proto.
|
|
3241
3241
|
*/
|
|
3242
|
-
function
|
|
3242
|
+
function Le(t, e) {
|
|
3243
3243
|
if (t.C) {
|
|
3244
3244
|
return `${new Date(1e3 * e.seconds).toISOString().replace(/\.\d*/, "").replace("Z", "")}.${("000000000" + e.nanoseconds).slice(-9)}Z`;
|
|
3245
3245
|
}
|
|
@@ -3254,129 +3254,129 @@ function Ce(t, e) {
|
|
|
3254
3254
|
*
|
|
3255
3255
|
* Visible for testing.
|
|
3256
3256
|
*/
|
|
3257
|
-
function
|
|
3257
|
+
function Me(t, e) {
|
|
3258
3258
|
return t.C ? e.toBase64() : e.toUint8Array();
|
|
3259
3259
|
}
|
|
3260
3260
|
|
|
3261
|
-
function
|
|
3262
|
-
return
|
|
3261
|
+
function Ue(t, e) {
|
|
3262
|
+
return Le(t, e.toTimestamp());
|
|
3263
3263
|
}
|
|
3264
3264
|
|
|
3265
|
-
function
|
|
3266
|
-
return
|
|
3267
|
-
const e =
|
|
3268
|
-
return new
|
|
3265
|
+
function je(t) {
|
|
3266
|
+
return I(!!t), It.fromTimestamp(function(t) {
|
|
3267
|
+
const e = qt(t);
|
|
3268
|
+
return new Et(e.seconds, e.nanos);
|
|
3269
3269
|
}(t));
|
|
3270
3270
|
}
|
|
3271
3271
|
|
|
3272
|
-
function
|
|
3272
|
+
function Be(t, e) {
|
|
3273
3273
|
return function(t) {
|
|
3274
|
-
return new
|
|
3274
|
+
return new et([ "projects", t.projectId, "databases", t.database ]);
|
|
3275
3275
|
}(t).child("documents").child(e).canonicalString();
|
|
3276
3276
|
}
|
|
3277
3277
|
|
|
3278
|
-
function
|
|
3279
|
-
return
|
|
3278
|
+
function Qe(t, e) {
|
|
3279
|
+
return Be(t.databaseId, e.path);
|
|
3280
3280
|
}
|
|
3281
3281
|
|
|
3282
|
-
function
|
|
3282
|
+
function ze(t, e) {
|
|
3283
3283
|
const n = function(t) {
|
|
3284
|
-
const e =
|
|
3285
|
-
return
|
|
3284
|
+
const e = et.fromString(t);
|
|
3285
|
+
return I(nn(e)), e;
|
|
3286
3286
|
}(e);
|
|
3287
|
-
if (n.get(1) !== t.databaseId.projectId) throw new
|
|
3288
|
-
if (n.get(3) !== t.databaseId.database) throw new
|
|
3289
|
-
return new
|
|
3287
|
+
if (n.get(1) !== t.databaseId.projectId) throw new j(V, "Tried to deserialize key from different project: " + n.get(1) + " vs " + t.databaseId.projectId);
|
|
3288
|
+
if (n.get(3) !== t.databaseId.database) throw new j(V, "Tried to deserialize key from different database: " + n.get(3) + " vs " + t.databaseId.database);
|
|
3289
|
+
return new st((I((r = n).length > 4 && "documents" === r.get(4)), r.popFirst(5)));
|
|
3290
3290
|
var r;
|
|
3291
3291
|
/** Creates a Document proto from key and fields (but no create/update time) */}
|
|
3292
3292
|
|
|
3293
|
-
function
|
|
3294
|
-
return
|
|
3293
|
+
function We(t, e) {
|
|
3294
|
+
return Be(t.databaseId, e);
|
|
3295
3295
|
}
|
|
3296
3296
|
|
|
3297
|
-
function
|
|
3298
|
-
return new
|
|
3297
|
+
function Ge(t) {
|
|
3298
|
+
return new et([ "projects", t.databaseId.projectId, "databases", t.databaseId.database ]).canonicalString();
|
|
3299
3299
|
}
|
|
3300
3300
|
|
|
3301
|
-
function
|
|
3301
|
+
function Ke(t, e, n) {
|
|
3302
3302
|
return {
|
|
3303
|
-
name:
|
|
3303
|
+
name: Qe(t, e),
|
|
3304
3304
|
fields: n.value.mapValue.fields
|
|
3305
3305
|
};
|
|
3306
3306
|
}
|
|
3307
3307
|
|
|
3308
|
-
function
|
|
3308
|
+
function Ye(t, e) {
|
|
3309
3309
|
return "found" in e ? function(t, e) {
|
|
3310
|
-
|
|
3311
|
-
const n =
|
|
3310
|
+
I(!!e.found), e.found.name, e.found.updateTime;
|
|
3311
|
+
const n = ze(t, e.found.name), r = je(e.found.updateTime), s = new Zt({
|
|
3312
3312
|
mapValue: {
|
|
3313
3313
|
fields: e.found.fields
|
|
3314
3314
|
}
|
|
3315
3315
|
});
|
|
3316
|
-
return
|
|
3316
|
+
return te.newFoundDocument(n, r, s);
|
|
3317
3317
|
}(t, e) : "missing" in e ? function(t, e) {
|
|
3318
|
-
|
|
3319
|
-
const n =
|
|
3320
|
-
return
|
|
3321
|
-
}(t, e) :
|
|
3318
|
+
I(!!e.missing), I(!!e.readTime);
|
|
3319
|
+
const n = ze(t, e.missing), r = je(e.readTime);
|
|
3320
|
+
return te.newNoDocument(n, r);
|
|
3321
|
+
}(t, e) : E();
|
|
3322
3322
|
}
|
|
3323
3323
|
|
|
3324
|
-
function
|
|
3324
|
+
function He(t, e) {
|
|
3325
3325
|
let n;
|
|
3326
|
-
if (e instanceof
|
|
3327
|
-
update:
|
|
3326
|
+
if (e instanceof xe) n = {
|
|
3327
|
+
update: Ke(t, e.key, e.value)
|
|
3328
|
+
}; else if (e instanceof Fe) n = {
|
|
3329
|
+
delete: Qe(t, e.key)
|
|
3328
3330
|
}; else if (e instanceof Se) n = {
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
update: Ge(t, e.key, e.data),
|
|
3332
|
-
updateMask: tn(e.fieldMask)
|
|
3331
|
+
update: Ke(t, e.key, e.data),
|
|
3332
|
+
updateMask: en(e.fieldMask)
|
|
3333
3333
|
}; else {
|
|
3334
|
-
if (!(e instanceof
|
|
3334
|
+
if (!(e instanceof qe)) return E();
|
|
3335
3335
|
n = {
|
|
3336
|
-
verify:
|
|
3336
|
+
verify: Qe(t, e.key)
|
|
3337
3337
|
};
|
|
3338
3338
|
}
|
|
3339
3339
|
return e.fieldTransforms.length > 0 && (n.updateTransforms = e.fieldTransforms.map((t => function(t, e) {
|
|
3340
3340
|
const n = e.transform;
|
|
3341
|
-
if (n instanceof
|
|
3341
|
+
if (n instanceof Ae) return {
|
|
3342
3342
|
fieldPath: e.field.canonicalString(),
|
|
3343
3343
|
setToServerValue: "REQUEST_TIME"
|
|
3344
3344
|
};
|
|
3345
|
-
if (n instanceof
|
|
3345
|
+
if (n instanceof Re) return {
|
|
3346
3346
|
fieldPath: e.field.canonicalString(),
|
|
3347
3347
|
appendMissingElements: {
|
|
3348
3348
|
values: n.elements
|
|
3349
3349
|
}
|
|
3350
3350
|
};
|
|
3351
|
-
if (n instanceof
|
|
3351
|
+
if (n instanceof Pe) return {
|
|
3352
3352
|
fieldPath: e.field.canonicalString(),
|
|
3353
3353
|
removeAllFromArray: {
|
|
3354
3354
|
values: n.elements
|
|
3355
3355
|
}
|
|
3356
3356
|
};
|
|
3357
|
-
if (n instanceof
|
|
3357
|
+
if (n instanceof Ve) return {
|
|
3358
3358
|
fieldPath: e.field.canonicalString(),
|
|
3359
3359
|
increment: n.M
|
|
3360
3360
|
};
|
|
3361
|
-
throw
|
|
3361
|
+
throw E();
|
|
3362
3362
|
}(0, t)))), e.precondition.isNone || (n.currentDocument = function(t, e) {
|
|
3363
3363
|
return void 0 !== e.updateTime ? {
|
|
3364
|
-
updateTime:
|
|
3364
|
+
updateTime: Ue(t, e.updateTime)
|
|
3365
3365
|
} : void 0 !== e.exists ? {
|
|
3366
3366
|
exists: e.exists
|
|
3367
|
-
} :
|
|
3367
|
+
} : E();
|
|
3368
3368
|
}(t, e.precondition)), n;
|
|
3369
3369
|
}
|
|
3370
3370
|
|
|
3371
|
-
function
|
|
3371
|
+
function Je(t, e) {
|
|
3372
3372
|
// Dissect the path into parent, collectionId, and optional key filter.
|
|
3373
3373
|
const n = {
|
|
3374
3374
|
structuredQuery: {}
|
|
3375
3375
|
}, r = e.path;
|
|
3376
|
-
null !== e.collectionGroup ? (n.parent =
|
|
3376
|
+
null !== e.collectionGroup ? (n.parent = We(t, r), n.structuredQuery.from = [ {
|
|
3377
3377
|
collectionId: e.collectionGroup,
|
|
3378
3378
|
allDescendants: !0
|
|
3379
|
-
} ]) : (n.parent =
|
|
3379
|
+
} ]) : (n.parent = We(t, r.popLast()), n.structuredQuery.from = [ {
|
|
3380
3380
|
collectionId: r.lastSegment()
|
|
3381
3381
|
} ]);
|
|
3382
3382
|
const s = function(t) {
|
|
@@ -3385,36 +3385,36 @@ function He(t, e) {
|
|
|
3385
3385
|
// visible for testing
|
|
3386
3386
|
function(t) {
|
|
3387
3387
|
if ("==" /* EQUAL */ === t.op) {
|
|
3388
|
-
if (
|
|
3388
|
+
if (Ht(t.value)) return {
|
|
3389
3389
|
unaryFilter: {
|
|
3390
|
-
field:
|
|
3390
|
+
field: tn(t.field),
|
|
3391
3391
|
op: "IS_NAN"
|
|
3392
3392
|
}
|
|
3393
3393
|
};
|
|
3394
|
-
if (
|
|
3394
|
+
if (Yt(t.value)) return {
|
|
3395
3395
|
unaryFilter: {
|
|
3396
|
-
field:
|
|
3396
|
+
field: tn(t.field),
|
|
3397
3397
|
op: "IS_NULL"
|
|
3398
3398
|
}
|
|
3399
3399
|
};
|
|
3400
3400
|
} else if ("!=" /* NOT_EQUAL */ === t.op) {
|
|
3401
|
-
if (
|
|
3401
|
+
if (Ht(t.value)) return {
|
|
3402
3402
|
unaryFilter: {
|
|
3403
|
-
field:
|
|
3403
|
+
field: tn(t.field),
|
|
3404
3404
|
op: "IS_NOT_NAN"
|
|
3405
3405
|
}
|
|
3406
3406
|
};
|
|
3407
|
-
if (
|
|
3407
|
+
if (Yt(t.value)) return {
|
|
3408
3408
|
unaryFilter: {
|
|
3409
|
-
field:
|
|
3409
|
+
field: tn(t.field),
|
|
3410
3410
|
op: "IS_NOT_NULL"
|
|
3411
3411
|
}
|
|
3412
3412
|
};
|
|
3413
3413
|
}
|
|
3414
3414
|
return {
|
|
3415
3415
|
fieldFilter: {
|
|
3416
|
-
field:
|
|
3417
|
-
op:
|
|
3416
|
+
field: tn(t.field),
|
|
3417
|
+
op: Ze(t.op),
|
|
3418
3418
|
value: t.value
|
|
3419
3419
|
}
|
|
3420
3420
|
};
|
|
@@ -3434,14 +3434,14 @@ function He(t, e) {
|
|
|
3434
3434
|
// visible for testing
|
|
3435
3435
|
function(t) {
|
|
3436
3436
|
return {
|
|
3437
|
-
field:
|
|
3438
|
-
direction:
|
|
3437
|
+
field: tn(t.field),
|
|
3438
|
+
direction: Xe(t.dir)
|
|
3439
3439
|
};
|
|
3440
3440
|
}(t)));
|
|
3441
3441
|
}(e.orderBy);
|
|
3442
3442
|
i && (n.structuredQuery.orderBy = i);
|
|
3443
3443
|
const o = function(t, e) {
|
|
3444
|
-
return t.C ||
|
|
3444
|
+
return t.C || lt(e) ? e : {
|
|
3445
3445
|
value: e
|
|
3446
3446
|
};
|
|
3447
3447
|
}(t, e.limit);
|
|
@@ -3459,29 +3459,29 @@ function He(t, e) {
|
|
|
3459
3459
|
(e.endAt)), n;
|
|
3460
3460
|
}
|
|
3461
3461
|
|
|
3462
|
-
function Je(t) {
|
|
3463
|
-
return qe[t];
|
|
3464
|
-
}
|
|
3465
|
-
|
|
3466
|
-
// visible for testing
|
|
3467
3462
|
function Xe(t) {
|
|
3468
3463
|
return Oe[t];
|
|
3469
3464
|
}
|
|
3470
3465
|
|
|
3466
|
+
// visible for testing
|
|
3471
3467
|
function Ze(t) {
|
|
3468
|
+
return ke[t];
|
|
3469
|
+
}
|
|
3470
|
+
|
|
3471
|
+
function tn(t) {
|
|
3472
3472
|
return {
|
|
3473
3473
|
fieldPath: t.canonicalString()
|
|
3474
3474
|
};
|
|
3475
3475
|
}
|
|
3476
3476
|
|
|
3477
|
-
function
|
|
3477
|
+
function en(t) {
|
|
3478
3478
|
const e = [];
|
|
3479
3479
|
return t.fields.forEach((t => e.push(t.canonicalString()))), {
|
|
3480
3480
|
fieldPaths: e
|
|
3481
3481
|
};
|
|
3482
3482
|
}
|
|
3483
3483
|
|
|
3484
|
-
function
|
|
3484
|
+
function nn(t) {
|
|
3485
3485
|
// Resource names have at least 4 components (project ID, database ID)
|
|
3486
3486
|
return t.length >= 4 && "projects" === t.get(0) && "databases" === t.get(2);
|
|
3487
3487
|
}
|
|
@@ -3501,8 +3501,8 @@ function en(t) {
|
|
|
3501
3501
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3502
3502
|
* See the License for the specific language governing permissions and
|
|
3503
3503
|
* limitations under the License.
|
|
3504
|
-
*/ function
|
|
3505
|
-
return new
|
|
3504
|
+
*/ function rn(t) {
|
|
3505
|
+
return new Ce(t, /* useProto3Json= */ !0);
|
|
3506
3506
|
}
|
|
3507
3507
|
|
|
3508
3508
|
/**
|
|
@@ -3530,7 +3530,7 @@ function en(t) {
|
|
|
3530
3530
|
* base delay. This prevents clients from accidentally synchronizing their
|
|
3531
3531
|
* delays causing spikes of load to the backend.
|
|
3532
3532
|
*/
|
|
3533
|
-
class
|
|
3533
|
+
class sn {
|
|
3534
3534
|
constructor(
|
|
3535
3535
|
/**
|
|
3536
3536
|
* The AsyncQueue to run backoff operations on.
|
|
@@ -3585,7 +3585,7 @@ class rn {
|
|
|
3585
3585
|
// honored as such).
|
|
3586
3586
|
const e = Math.floor(this.G + this.X()), n = Math.max(0, Date.now() - this.Y), r = Math.max(0, e - n);
|
|
3587
3587
|
// Guard against lastAttemptTime being in the future due to a clock change.
|
|
3588
|
-
r > 0 &&
|
|
3588
|
+
r > 0 && g("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.G} ms, delay with jitter: ${e} ms, last attempt: ${n} ms ago)`),
|
|
3589
3589
|
this.K = this.U.enqueueAfterDelay(this.timerId, r, (() => (this.Y = Date.now(),
|
|
3590
3590
|
t()))),
|
|
3591
3591
|
// Apply backoff factor to determine next delay and ensure it is within
|
|
@@ -3628,24 +3628,24 @@ class rn {
|
|
|
3628
3628
|
* An implementation of Datastore that exposes additional state for internal
|
|
3629
3629
|
* consumption.
|
|
3630
3630
|
*/
|
|
3631
|
-
class
|
|
3631
|
+
class on extends class {} {
|
|
3632
3632
|
constructor(t, e, n, r) {
|
|
3633
3633
|
super(), this.authCredentials = t, this.appCheckCredentials = e, this.tt = n, this.L = r,
|
|
3634
3634
|
this.et = !1;
|
|
3635
3635
|
}
|
|
3636
3636
|
nt() {
|
|
3637
|
-
if (this.et) throw new
|
|
3637
|
+
if (this.et) throw new j(q, "The client has already been terminated.");
|
|
3638
3638
|
}
|
|
3639
3639
|
/** Invokes the provided RPC with auth and AppCheck tokens. */ I(t, e, n) {
|
|
3640
3640
|
return this.nt(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.tt.I(t, e, n, r, s))).catch((t => {
|
|
3641
|
-
throw "FirebaseError" === t.name ? (t.code ===
|
|
3642
|
-
this.appCheckCredentials.invalidateToken()), t) : new
|
|
3641
|
+
throw "FirebaseError" === t.name ? (t.code === S && (this.authCredentials.invalidateToken(),
|
|
3642
|
+
this.appCheckCredentials.invalidateToken()), t) : new j(P, t.toString());
|
|
3643
3643
|
}));
|
|
3644
3644
|
}
|
|
3645
3645
|
/** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */ P(t, e, n, r) {
|
|
3646
3646
|
return this.nt(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([s, i]) => this.tt.P(t, e, n, s, i, r))).catch((t => {
|
|
3647
|
-
throw "FirebaseError" === t.name ? (t.code ===
|
|
3648
|
-
this.appCheckCredentials.invalidateToken()), t) : new
|
|
3647
|
+
throw "FirebaseError" === t.name ? (t.code === S && (this.authCredentials.invalidateToken(),
|
|
3648
|
+
this.appCheckCredentials.invalidateToken()), t) : new j(P, t.toString());
|
|
3649
3649
|
}));
|
|
3650
3650
|
}
|
|
3651
3651
|
terminate() {
|
|
@@ -3655,45 +3655,45 @@ class sn extends class {} {
|
|
|
3655
3655
|
|
|
3656
3656
|
// TODO(firestorexp): Make sure there is only one Datastore instance per
|
|
3657
3657
|
// firestore-exp client.
|
|
3658
|
-
async function
|
|
3659
|
-
const n =
|
|
3660
|
-
writes: e.map((t =>
|
|
3658
|
+
async function un(t, e) {
|
|
3659
|
+
const n = T(t), r = Ge(n.L) + "/documents", s = {
|
|
3660
|
+
writes: e.map((t => He(n.L, t)))
|
|
3661
3661
|
};
|
|
3662
3662
|
await n.I("Commit", r, s);
|
|
3663
3663
|
}
|
|
3664
3664
|
|
|
3665
|
-
async function
|
|
3666
|
-
const n =
|
|
3667
|
-
documents: e.map((t =>
|
|
3665
|
+
async function cn(t, e) {
|
|
3666
|
+
const n = T(t), r = Ge(n.L) + "/documents", s = {
|
|
3667
|
+
documents: e.map((t => Qe(n.L, t)))
|
|
3668
3668
|
}, i = await n.P("BatchGetDocuments", r, s, e.length), o = new Map;
|
|
3669
3669
|
i.forEach((t => {
|
|
3670
|
-
const e =
|
|
3670
|
+
const e = Ye(n.L, t);
|
|
3671
3671
|
o.set(e.key.toString(), e);
|
|
3672
3672
|
}));
|
|
3673
3673
|
const u = [];
|
|
3674
3674
|
return e.forEach((t => {
|
|
3675
3675
|
const e = o.get(t.toString());
|
|
3676
|
-
|
|
3676
|
+
I(!!e), u.push(e);
|
|
3677
3677
|
})), u;
|
|
3678
3678
|
}
|
|
3679
3679
|
|
|
3680
|
-
async function
|
|
3681
|
-
const n =
|
|
3680
|
+
async function an(t, e) {
|
|
3681
|
+
const n = T(t), r = Je(n.L, be(e));
|
|
3682
3682
|
return (await n.P("RunQuery", r.parent, {
|
|
3683
3683
|
structuredQuery: r.structuredQuery
|
|
3684
3684
|
})).filter((t => !!t.document)).map((t => function(t, e, n) {
|
|
3685
|
-
const r =
|
|
3685
|
+
const r = ze(t, e.name), s = je(e.updateTime), i = new Zt({
|
|
3686
3686
|
mapValue: {
|
|
3687
3687
|
fields: e.fields
|
|
3688
3688
|
}
|
|
3689
|
-
}), o =
|
|
3689
|
+
}), o = te.newFoundDocument(r, s, i);
|
|
3690
3690
|
return n && o.setHasCommittedMutations(), n ? o.setHasCommittedMutations() : o;
|
|
3691
3691
|
}(n.L, t.document, void 0)));
|
|
3692
3692
|
}
|
|
3693
3693
|
|
|
3694
|
-
async function
|
|
3695
|
-
const n =
|
|
3696
|
-
const n =
|
|
3694
|
+
async function hn(t, e) {
|
|
3695
|
+
const n = T(t), r = function(t, e) {
|
|
3696
|
+
const n = Je(t, e);
|
|
3697
3697
|
return {
|
|
3698
3698
|
structuredAggregationQuery: {
|
|
3699
3699
|
aggregations: [ {
|
|
@@ -3704,7 +3704,7 @@ async function an(t, e) {
|
|
|
3704
3704
|
},
|
|
3705
3705
|
parent: n.parent
|
|
3706
3706
|
};
|
|
3707
|
-
}(n.L,
|
|
3707
|
+
}(n.L, be(e)), s = r.parent;
|
|
3708
3708
|
n.tt.v || delete r.parent;
|
|
3709
3709
|
return (await n.P("RunAggregationQuery", s, r, /*expectedResponseCount=*/ 1)).filter((t => !!t.result)).map((t => t.result.aggregateFields));
|
|
3710
3710
|
}
|
|
@@ -3724,7 +3724,7 @@ async function an(t, e) {
|
|
|
3724
3724
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3725
3725
|
* See the License for the specific language governing permissions and
|
|
3726
3726
|
* limitations under the License.
|
|
3727
|
-
*/ const
|
|
3727
|
+
*/ const ln = new Map;
|
|
3728
3728
|
|
|
3729
3729
|
/**
|
|
3730
3730
|
* An instance map that ensures only one Datastore exists per Firestore
|
|
@@ -3735,17 +3735,17 @@ async function an(t, e) {
|
|
|
3735
3735
|
* instance. Callers must invoke removeComponents() when the Firestore
|
|
3736
3736
|
* instance is terminated.
|
|
3737
3737
|
*/
|
|
3738
|
-
function
|
|
3739
|
-
if (t._terminated) throw new
|
|
3740
|
-
if (!
|
|
3741
|
-
|
|
3738
|
+
function fn(t) {
|
|
3739
|
+
if (t._terminated) throw new j(q, "The client has already been terminated.");
|
|
3740
|
+
if (!ln.has(t)) {
|
|
3741
|
+
g("ComponentProvider", "Initializing Datastore");
|
|
3742
3742
|
const i = function(t) {
|
|
3743
|
-
return new
|
|
3743
|
+
return new yt(t, fetch.bind(null));
|
|
3744
3744
|
}((e = t._databaseId, n = t.app.options.appId || "", r = t._persistenceKey, s = t._freezeSettings(),
|
|
3745
|
-
new
|
|
3746
|
-
return new
|
|
3745
|
+
new X(e, n, r, s.host, s.ssl, s.experimentalForceLongPolling, s.experimentalAutoDetectLongPolling, s.useFetchStreams))), o = rn(t._databaseId), u = function(t, e, n, r) {
|
|
3746
|
+
return new on(t, e, n, r);
|
|
3747
3747
|
}(t._authCredentials, t._appCheckCredentials, i, o);
|
|
3748
|
-
|
|
3748
|
+
ln.set(t, u);
|
|
3749
3749
|
}
|
|
3750
3750
|
var e, n, r, s;
|
|
3751
3751
|
/**
|
|
@@ -3763,7 +3763,7 @@ function ln(t) {
|
|
|
3763
3763
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3764
3764
|
* See the License for the specific language governing permissions and
|
|
3765
3765
|
* limitations under the License.
|
|
3766
|
-
*/ return
|
|
3766
|
+
*/ return ln.get(t);
|
|
3767
3767
|
}
|
|
3768
3768
|
|
|
3769
3769
|
/**
|
|
@@ -3775,21 +3775,21 @@ function ln(t) {
|
|
|
3775
3775
|
* user-supplied `FirestoreSettings` object. This is a separate type so that
|
|
3776
3776
|
* defaults can be supplied and the value can be checked for equality.
|
|
3777
3777
|
*/
|
|
3778
|
-
class
|
|
3778
|
+
class dn {
|
|
3779
3779
|
constructor(t) {
|
|
3780
3780
|
var e;
|
|
3781
3781
|
if (void 0 === t.host) {
|
|
3782
|
-
if (void 0 !== t.ssl) throw new
|
|
3782
|
+
if (void 0 !== t.ssl) throw new j(V, "Can't provide ssl option if host option is not set");
|
|
3783
3783
|
this.host = "firestore.googleapis.com", this.ssl = true;
|
|
3784
3784
|
} else this.host = t.host, this.ssl = null === (e = t.ssl) || void 0 === e || e;
|
|
3785
3785
|
if (this.credentials = t.credentials, this.ignoreUndefinedProperties = !!t.ignoreUndefinedProperties,
|
|
3786
3786
|
void 0 === t.cacheSizeBytes) this.cacheSizeBytes = 41943040; else {
|
|
3787
|
-
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new
|
|
3787
|
+
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new j(V, "cacheSizeBytes must be at least 1048576");
|
|
3788
3788
|
this.cacheSizeBytes = t.cacheSizeBytes;
|
|
3789
3789
|
}
|
|
3790
3790
|
this.experimentalForceLongPolling = !!t.experimentalForceLongPolling, this.experimentalAutoDetectLongPolling = !!t.experimentalAutoDetectLongPolling,
|
|
3791
3791
|
this.useFetchStreams = !!t.useFetchStreams, function(t, e, n, r) {
|
|
3792
|
-
if (!0 === e && !0 === r) throw new
|
|
3792
|
+
if (!0 === e && !0 === r) throw new j(V, `${t} and ${n} cannot be used together.`);
|
|
3793
3793
|
}("experimentalForceLongPolling", t.experimentalForceLongPolling, "experimentalAutoDetectLongPolling", t.experimentalAutoDetectLongPolling);
|
|
3794
3794
|
}
|
|
3795
3795
|
isEqual(t) {
|
|
@@ -3817,7 +3817,7 @@ class fn {
|
|
|
3817
3817
|
* The Cloud Firestore service interface.
|
|
3818
3818
|
*
|
|
3819
3819
|
* Do not call this constructor directly. Instead, use {@link (getFirestore:1)}.
|
|
3820
|
-
*/ class
|
|
3820
|
+
*/ class wn {
|
|
3821
3821
|
/** @hideconstructor */
|
|
3822
3822
|
constructor(t, e, n, r) {
|
|
3823
3823
|
this._authCredentials = t, this._appCheckCredentials = e, this._databaseId = n,
|
|
@@ -3825,14 +3825,14 @@ class fn {
|
|
|
3825
3825
|
/**
|
|
3826
3826
|
* Whether it's a Firestore or Firestore Lite instance.
|
|
3827
3827
|
*/
|
|
3828
|
-
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new
|
|
3828
|
+
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new dn({}),
|
|
3829
3829
|
this._settingsFrozen = !1;
|
|
3830
3830
|
}
|
|
3831
3831
|
/**
|
|
3832
3832
|
* The {@link @firebase/app#FirebaseApp} associated with this `Firestore` service
|
|
3833
3833
|
* instance.
|
|
3834
3834
|
*/ get app() {
|
|
3835
|
-
if (!this._app) throw new
|
|
3835
|
+
if (!this._app) throw new j(q, "Firestore was not initialized using the Firebase SDK. 'app' is not available");
|
|
3836
3836
|
return this._app;
|
|
3837
3837
|
}
|
|
3838
3838
|
get _initialized() {
|
|
@@ -3842,19 +3842,19 @@ class fn {
|
|
|
3842
3842
|
return void 0 !== this._terminateTask;
|
|
3843
3843
|
}
|
|
3844
3844
|
_setSettings(t) {
|
|
3845
|
-
if (this._settingsFrozen) throw new
|
|
3846
|
-
this._settings = new
|
|
3847
|
-
if (!t) return new
|
|
3845
|
+
if (this._settingsFrozen) throw new j(q, "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.");
|
|
3846
|
+
this._settings = new dn(t), void 0 !== t.credentials && (this._authCredentials = function(t) {
|
|
3847
|
+
if (!t) return new z;
|
|
3848
3848
|
switch (t.type) {
|
|
3849
3849
|
case "gapi":
|
|
3850
3850
|
const e = t.client;
|
|
3851
|
-
return new
|
|
3851
|
+
return new Y(e, t.sessionIndex || "0", t.iamToken || null, t.authTokenFactory || null);
|
|
3852
3852
|
|
|
3853
3853
|
case "provider":
|
|
3854
3854
|
return t.client;
|
|
3855
3855
|
|
|
3856
3856
|
default:
|
|
3857
|
-
throw new
|
|
3857
|
+
throw new j(V, "makeAuthCredentialsProvider failed due to invalid credential type");
|
|
3858
3858
|
}
|
|
3859
3859
|
}(t.credentials));
|
|
3860
3860
|
}
|
|
@@ -3882,27 +3882,34 @@ class fn {
|
|
|
3882
3882
|
* Only ever called once.
|
|
3883
3883
|
*/ _terminate() {
|
|
3884
3884
|
return function(t) {
|
|
3885
|
-
const e =
|
|
3886
|
-
e && (
|
|
3885
|
+
const e = ln.get(t);
|
|
3886
|
+
e && (g("ComponentProvider", "Removing Datastore"), ln.delete(t), e.terminate());
|
|
3887
3887
|
}(this), Promise.resolve();
|
|
3888
3888
|
}
|
|
3889
3889
|
}
|
|
3890
3890
|
|
|
3891
|
-
function
|
|
3891
|
+
function mn(t, e, n) {
|
|
3892
3892
|
n || (n = "(default)");
|
|
3893
3893
|
const r = _getProvider(t, "firestore/lite");
|
|
3894
|
-
if (r.isInitialized(n)) throw new
|
|
3894
|
+
if (r.isInitialized(n)) throw new j(q, "Firestore can only be initialized once per app.");
|
|
3895
3895
|
return r.initialize({
|
|
3896
3896
|
options: e,
|
|
3897
3897
|
instanceIdentifier: n
|
|
3898
3898
|
});
|
|
3899
3899
|
}
|
|
3900
3900
|
|
|
3901
|
-
function
|
|
3902
|
-
const r = "object" == typeof e ? e : t(), s = "string" == typeof e ? e : n || "(default)"
|
|
3903
|
-
return _getProvider(r, "firestore/lite").getImmediate({
|
|
3901
|
+
function pn(e, n) {
|
|
3902
|
+
const r = "object" == typeof e ? e : t(), s = "string" == typeof e ? e : n || "(default)", i = _getProvider(r, "firestore/lite").getImmediate({
|
|
3904
3903
|
identifier: s
|
|
3905
3904
|
});
|
|
3905
|
+
if (!i._initialized) {
|
|
3906
|
+
const t = h("firestore");
|
|
3907
|
+
if (t) {
|
|
3908
|
+
const [e, n] = t.split(":");
|
|
3909
|
+
yn(i, e, parseInt(n, 10));
|
|
3910
|
+
}
|
|
3911
|
+
}
|
|
3912
|
+
return i;
|
|
3906
3913
|
}
|
|
3907
3914
|
|
|
3908
3915
|
/**
|
|
@@ -3917,24 +3924,24 @@ function mn(e, n) {
|
|
|
3917
3924
|
* @param port - the emulator port (ex: 9000).
|
|
3918
3925
|
* @param options.mockUserToken - the mock auth token to use for unit testing
|
|
3919
3926
|
* Security Rules.
|
|
3920
|
-
*/ function
|
|
3927
|
+
*/ function yn(t, e, n, r = {}) {
|
|
3921
3928
|
var s;
|
|
3922
|
-
const i = (t =
|
|
3923
|
-
if ("firestore.googleapis.com" !== i.host && i.host !== e &&
|
|
3929
|
+
const i = (t = at(t, wn))._getSettings();
|
|
3930
|
+
if ("firestore.googleapis.com" !== i.host && i.host !== e && v("Host has been set in both settings() and useEmulator(), emulator host will be used"),
|
|
3924
3931
|
t._setSettings(Object.assign(Object.assign({}, i), {
|
|
3925
3932
|
host: `${e}:${n}`,
|
|
3926
3933
|
ssl: !1
|
|
3927
3934
|
})), r.mockUserToken) {
|
|
3928
3935
|
let e, n;
|
|
3929
|
-
if ("string" == typeof r.mockUserToken) e = r.mockUserToken, n =
|
|
3936
|
+
if ("string" == typeof r.mockUserToken) e = r.mockUserToken, n = w.MOCK_USER; else {
|
|
3930
3937
|
// Let createMockUserToken validate first (catches common mistakes like
|
|
3931
3938
|
// invalid field "uid" and missing field "sub" / "user_id".)
|
|
3932
|
-
e =
|
|
3939
|
+
e = l(r.mockUserToken, null === (s = t._app) || void 0 === s ? void 0 : s.options.projectId);
|
|
3933
3940
|
const i = r.mockUserToken.sub || r.mockUserToken.user_id;
|
|
3934
|
-
if (!i) throw new
|
|
3935
|
-
n = new
|
|
3941
|
+
if (!i) throw new j(V, "mockUserToken must contain 'sub' or 'user_id' field!");
|
|
3942
|
+
n = new w(i);
|
|
3936
3943
|
}
|
|
3937
|
-
t._authCredentials = new
|
|
3944
|
+
t._authCredentials = new W(new Q(e, n));
|
|
3938
3945
|
}
|
|
3939
3946
|
}
|
|
3940
3947
|
|
|
@@ -3957,8 +3964,8 @@ function mn(e, n) {
|
|
|
3957
3964
|
* @param firestore - The `Firestore` instance to terminate.
|
|
3958
3965
|
* @returns A `Promise` that is resolved when the instance has been successfully
|
|
3959
3966
|
* terminated.
|
|
3960
|
-
*/ function
|
|
3961
|
-
return t =
|
|
3967
|
+
*/ function gn(t) {
|
|
3968
|
+
return t = at(t, wn), e(t.app, "firestore/lite"), t._delete();
|
|
3962
3969
|
}
|
|
3963
3970
|
|
|
3964
3971
|
/**
|
|
@@ -3997,7 +4004,7 @@ function mn(e, n) {
|
|
|
3997
4004
|
* Represents an aggregation that can be performed by Firestore.
|
|
3998
4005
|
*/
|
|
3999
4006
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
4000
|
-
class
|
|
4007
|
+
class _n {
|
|
4001
4008
|
constructor() {
|
|
4002
4009
|
/** A type string to uniquely identify instances of this class. */
|
|
4003
4010
|
this.type = "AggregateField";
|
|
@@ -4006,7 +4013,7 @@ class gn {
|
|
|
4006
4013
|
|
|
4007
4014
|
/**
|
|
4008
4015
|
* The results of executing an aggregation query.
|
|
4009
|
-
*/ class
|
|
4016
|
+
*/ class vn {
|
|
4010
4017
|
/** @hideconstructor */
|
|
4011
4018
|
constructor(t, e) {
|
|
4012
4019
|
this._data = e,
|
|
@@ -4047,15 +4054,15 @@ class gn {
|
|
|
4047
4054
|
/**
|
|
4048
4055
|
* CountQueryRunner encapsulates the logic needed to run the count aggregation
|
|
4049
4056
|
* queries.
|
|
4050
|
-
*/ class
|
|
4057
|
+
*/ class bn {
|
|
4051
4058
|
constructor(t, e, n) {
|
|
4052
4059
|
this.query = t, this.datastore = e, this.userDataWriter = n;
|
|
4053
4060
|
}
|
|
4054
4061
|
run() {
|
|
4055
|
-
return
|
|
4056
|
-
|
|
4062
|
+
return hn(this.datastore, this.query._query).then((t => {
|
|
4063
|
+
I(void 0 !== t[0]);
|
|
4057
4064
|
const e = Object.entries(t[0]).filter((([t, e]) => "count_alias" === t)).map((([t, e]) => this.userDataWriter.convertValue(e)))[0];
|
|
4058
|
-
return
|
|
4065
|
+
return I("number" == typeof e), Promise.resolve(new vn(this.query, {
|
|
4059
4066
|
count: e
|
|
4060
4067
|
}));
|
|
4061
4068
|
}));
|
|
@@ -4082,7 +4089,7 @@ class gn {
|
|
|
4082
4089
|
* A `DocumentReference` refers to a document location in a Firestore database
|
|
4083
4090
|
* and can be used to write, read, or listen to the location. The document at
|
|
4084
4091
|
* the referenced location may or may not exist.
|
|
4085
|
-
*/ class
|
|
4092
|
+
*/ class En {
|
|
4086
4093
|
/** @hideconstructor */
|
|
4087
4094
|
constructor(t,
|
|
4088
4095
|
/**
|
|
@@ -4110,17 +4117,17 @@ class gn {
|
|
|
4110
4117
|
/**
|
|
4111
4118
|
* The collection this `DocumentReference` belongs to.
|
|
4112
4119
|
*/ get parent() {
|
|
4113
|
-
return new
|
|
4120
|
+
return new Tn(this.firestore, this.converter, this._key.path.popLast());
|
|
4114
4121
|
}
|
|
4115
4122
|
withConverter(t) {
|
|
4116
|
-
return new
|
|
4123
|
+
return new En(this.firestore, t, this._key);
|
|
4117
4124
|
}
|
|
4118
4125
|
}
|
|
4119
4126
|
|
|
4120
4127
|
/**
|
|
4121
4128
|
* A `Query` refers to a query which you can read or listen to. You can also
|
|
4122
4129
|
* construct refined `Query` objects by adding filters and ordering.
|
|
4123
|
-
*/ class
|
|
4130
|
+
*/ class In {
|
|
4124
4131
|
// This is the lite version of the Query class in the main SDK.
|
|
4125
4132
|
/** @hideconstructor protected */
|
|
4126
4133
|
constructor(t,
|
|
@@ -4133,17 +4140,17 @@ class gn {
|
|
|
4133
4140
|
this.type = "query", this.firestore = t;
|
|
4134
4141
|
}
|
|
4135
4142
|
withConverter(t) {
|
|
4136
|
-
return new
|
|
4143
|
+
return new In(this.firestore, t, this._query);
|
|
4137
4144
|
}
|
|
4138
4145
|
}
|
|
4139
4146
|
|
|
4140
4147
|
/**
|
|
4141
4148
|
* A `CollectionReference` object can be used for adding documents, getting
|
|
4142
4149
|
* document references, and querying for documents (using {@link query}).
|
|
4143
|
-
*/ class
|
|
4150
|
+
*/ class Tn extends In {
|
|
4144
4151
|
/** @hideconstructor */
|
|
4145
4152
|
constructor(t, e, n) {
|
|
4146
|
-
super(t, e, new
|
|
4153
|
+
super(t, e, new pe(n)), this._path = n,
|
|
4147
4154
|
/** The type of this Firestore reference. */
|
|
4148
4155
|
this.type = "collection";
|
|
4149
4156
|
}
|
|
@@ -4161,23 +4168,23 @@ class gn {
|
|
|
4161
4168
|
* subcollection. If this isn't a subcollection, the reference is null.
|
|
4162
4169
|
*/ get parent() {
|
|
4163
4170
|
const t = this._path.popLast();
|
|
4164
|
-
return t.isEmpty() ? null : new
|
|
4165
|
-
/* converter= */ null, new
|
|
4171
|
+
return t.isEmpty() ? null : new En(this.firestore,
|
|
4172
|
+
/* converter= */ null, new st(t));
|
|
4166
4173
|
}
|
|
4167
4174
|
withConverter(t) {
|
|
4168
|
-
return new
|
|
4175
|
+
return new Tn(this.firestore, t, this._path);
|
|
4169
4176
|
}
|
|
4170
4177
|
}
|
|
4171
4178
|
|
|
4172
|
-
function
|
|
4173
|
-
if (t =
|
|
4174
|
-
const r =
|
|
4175
|
-
return
|
|
4179
|
+
function An(t, e, ...n) {
|
|
4180
|
+
if (t = f(t), it("collection", "path", e), t instanceof wn) {
|
|
4181
|
+
const r = et.fromString(e, ...n);
|
|
4182
|
+
return ut(r), new Tn(t, /* converter= */ null, r);
|
|
4176
4183
|
}
|
|
4177
4184
|
{
|
|
4178
|
-
if (!(t instanceof
|
|
4179
|
-
const r = t._path.child(
|
|
4180
|
-
return
|
|
4185
|
+
if (!(t instanceof En || t instanceof Tn)) throw new j(V, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
4186
|
+
const r = t._path.child(et.fromString(e, ...n));
|
|
4187
|
+
return ut(r), new Tn(t.firestore,
|
|
4181
4188
|
/* converter= */ null, r);
|
|
4182
4189
|
}
|
|
4183
4190
|
}
|
|
@@ -4194,32 +4201,32 @@ function Tn(t, e, ...n) {
|
|
|
4194
4201
|
* collection or subcollection with this ID as the last segment of its path
|
|
4195
4202
|
* will be included. Cannot contain a slash.
|
|
4196
4203
|
* @returns The created `Query`.
|
|
4197
|
-
*/ function
|
|
4198
|
-
if (t =
|
|
4199
|
-
return new
|
|
4204
|
+
*/ function Rn(t, e) {
|
|
4205
|
+
if (t = at(t, wn), it("collectionGroup", "collection id", e), e.indexOf("/") >= 0) throw new j(V, `Invalid collection ID '${e}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);
|
|
4206
|
+
return new In(t,
|
|
4200
4207
|
/* converter= */ null,
|
|
4201
4208
|
/**
|
|
4202
4209
|
* Creates a new Query for a collection group query that matches all documents
|
|
4203
4210
|
* within the provided collection group.
|
|
4204
4211
|
*/
|
|
4205
4212
|
function(t) {
|
|
4206
|
-
return new
|
|
4213
|
+
return new pe(et.emptyPath(), t);
|
|
4207
4214
|
}(e));
|
|
4208
4215
|
}
|
|
4209
4216
|
|
|
4210
|
-
function
|
|
4211
|
-
if (t =
|
|
4217
|
+
function Pn(t, e, ...n) {
|
|
4218
|
+
if (t = f(t),
|
|
4212
4219
|
// We allow omission of 'pathString' but explicitly prohibit passing in both
|
|
4213
4220
|
// 'undefined' and 'null'.
|
|
4214
|
-
1 === arguments.length && (e =
|
|
4215
|
-
const r =
|
|
4216
|
-
return
|
|
4217
|
-
/* converter= */ null, new
|
|
4221
|
+
1 === arguments.length && (e = _t.$()), it("doc", "path", e), t instanceof wn) {
|
|
4222
|
+
const r = et.fromString(e, ...n);
|
|
4223
|
+
return ot(r), new En(t,
|
|
4224
|
+
/* converter= */ null, new st(r));
|
|
4218
4225
|
}
|
|
4219
4226
|
{
|
|
4220
|
-
if (!(t instanceof
|
|
4221
|
-
const r = t._path.child(
|
|
4222
|
-
return
|
|
4227
|
+
if (!(t instanceof En || t instanceof Tn)) throw new j(V, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
4228
|
+
const r = t._path.child(et.fromString(e, ...n));
|
|
4229
|
+
return ot(r), new En(t.firestore, t instanceof Tn ? t.converter : null, new st(r));
|
|
4223
4230
|
}
|
|
4224
4231
|
}
|
|
4225
4232
|
|
|
@@ -4230,8 +4237,8 @@ function Rn(t, e, ...n) {
|
|
|
4230
4237
|
* @param right - A reference to compare.
|
|
4231
4238
|
* @returns true if the references point to the same location in the same
|
|
4232
4239
|
* Firestore database.
|
|
4233
|
-
*/ function
|
|
4234
|
-
return t =
|
|
4240
|
+
*/ function Vn(t, e) {
|
|
4241
|
+
return t = f(t), e = f(e), (t instanceof En || t instanceof Tn) && (e instanceof En || e instanceof Tn) && (t.firestore === e.firestore && t.path === e.path && t.converter === e.converter);
|
|
4235
4242
|
}
|
|
4236
4243
|
|
|
4237
4244
|
/**
|
|
@@ -4242,8 +4249,8 @@ function Rn(t, e, ...n) {
|
|
|
4242
4249
|
* @param right - A `Query` to compare.
|
|
4243
4250
|
* @returns true if the references point to the same location in the same
|
|
4244
4251
|
* Firestore database.
|
|
4245
|
-
*/ function
|
|
4246
|
-
return t =
|
|
4252
|
+
*/ function Nn(t, e) {
|
|
4253
|
+
return t = f(t), e = f(e), t instanceof In && e instanceof In && (t.firestore === e.firestore && Ee(t._query, e._query) && t.converter === e.converter);
|
|
4247
4254
|
}
|
|
4248
4255
|
|
|
4249
4256
|
/**
|
|
@@ -4264,7 +4271,7 @@ function Rn(t, e, ...n) {
|
|
|
4264
4271
|
*/
|
|
4265
4272
|
/**
|
|
4266
4273
|
* An immutable object representing an array of bytes.
|
|
4267
|
-
*/ class
|
|
4274
|
+
*/ class $n {
|
|
4268
4275
|
/** @hideconstructor */
|
|
4269
4276
|
constructor(t) {
|
|
4270
4277
|
this._byteString = t;
|
|
@@ -4276,9 +4283,9 @@ function Rn(t, e, ...n) {
|
|
|
4276
4283
|
* @param base64 - The Base64 string used to create the `Bytes` object.
|
|
4277
4284
|
*/ static fromBase64String(t) {
|
|
4278
4285
|
try {
|
|
4279
|
-
return new
|
|
4286
|
+
return new $n(St.fromBase64String(t));
|
|
4280
4287
|
} catch (t) {
|
|
4281
|
-
throw new
|
|
4288
|
+
throw new j(V, "Failed to construct data from Base64 string: " + t);
|
|
4282
4289
|
}
|
|
4283
4290
|
}
|
|
4284
4291
|
/**
|
|
@@ -4286,7 +4293,7 @@ function Rn(t, e, ...n) {
|
|
|
4286
4293
|
*
|
|
4287
4294
|
* @param array - The Uint8Array used to create the `Bytes` object.
|
|
4288
4295
|
*/ static fromUint8Array(t) {
|
|
4289
|
-
return new
|
|
4296
|
+
return new $n(St.fromUint8Array(t));
|
|
4290
4297
|
}
|
|
4291
4298
|
/**
|
|
4292
4299
|
* Returns the underlying bytes as a Base64-encoded string.
|
|
@@ -4342,7 +4349,7 @@ function Rn(t, e, ...n) {
|
|
|
4342
4349
|
*
|
|
4343
4350
|
* Create a `FieldPath` by providing field names. If more than one field
|
|
4344
4351
|
* name is provided, the path will point to a nested field in a document.
|
|
4345
|
-
*/ class
|
|
4352
|
+
*/ class Dn {
|
|
4346
4353
|
/**
|
|
4347
4354
|
* Creates a `FieldPath` from the provided field names. If more than one field
|
|
4348
4355
|
* name is provided, the path will point to a nested field in a document.
|
|
@@ -4350,8 +4357,8 @@ function Rn(t, e, ...n) {
|
|
|
4350
4357
|
* @param fieldNames - A list of field names.
|
|
4351
4358
|
*/
|
|
4352
4359
|
constructor(...t) {
|
|
4353
|
-
for (let e = 0; e < t.length; ++e) if (0 === t[e].length) throw new
|
|
4354
|
-
this._internalPath = new
|
|
4360
|
+
for (let e = 0; e < t.length; ++e) if (0 === t[e].length) throw new j(V, "Invalid field name at argument $(i + 1). Field names must not be empty.");
|
|
4361
|
+
this._internalPath = new rt(t);
|
|
4355
4362
|
}
|
|
4356
4363
|
/**
|
|
4357
4364
|
* Returns true if this `FieldPath` is equal to the provided one.
|
|
@@ -4366,8 +4373,8 @@ function Rn(t, e, ...n) {
|
|
|
4366
4373
|
/**
|
|
4367
4374
|
* Returns a special sentinel `FieldPath` to refer to the ID of a document.
|
|
4368
4375
|
* It can be used in queries to sort or filter by the document ID.
|
|
4369
|
-
*/ function
|
|
4370
|
-
return new
|
|
4376
|
+
*/ function xn() {
|
|
4377
|
+
return new Dn("__name__");
|
|
4371
4378
|
}
|
|
4372
4379
|
|
|
4373
4380
|
/**
|
|
@@ -4389,7 +4396,7 @@ function Rn(t, e, ...n) {
|
|
|
4389
4396
|
/**
|
|
4390
4397
|
* Sentinel values that can be used when writing document fields with `set()`
|
|
4391
4398
|
* or `update()`.
|
|
4392
|
-
*/ class
|
|
4399
|
+
*/ class Sn {
|
|
4393
4400
|
/**
|
|
4394
4401
|
* @param _methodName - The public API endpoint that returns this class.
|
|
4395
4402
|
* @hideconstructor
|
|
@@ -4421,7 +4428,7 @@ function Rn(t, e, ...n) {
|
|
|
4421
4428
|
*
|
|
4422
4429
|
* Latitude values are in the range of [-90, 90].
|
|
4423
4430
|
* Longitude values are in the range of [-180, 180].
|
|
4424
|
-
*/ class
|
|
4431
|
+
*/ class Fn {
|
|
4425
4432
|
/**
|
|
4426
4433
|
* Creates a new immutable `GeoPoint` object with the provided latitude and
|
|
4427
4434
|
* longitude values.
|
|
@@ -4429,8 +4436,8 @@ function Rn(t, e, ...n) {
|
|
|
4429
4436
|
* @param longitude - The longitude as number between -180 and 180.
|
|
4430
4437
|
*/
|
|
4431
4438
|
constructor(t, e) {
|
|
4432
|
-
if (!isFinite(t) || t < -90 || t > 90) throw new
|
|
4433
|
-
if (!isFinite(e) || e < -180 || e > 180) throw new
|
|
4439
|
+
if (!isFinite(t) || t < -90 || t > 90) throw new j(V, "Latitude must be a number between -90 and 90, but was: " + t);
|
|
4440
|
+
if (!isFinite(e) || e < -180 || e > 180) throw new j(V, "Longitude must be a number between -180 and 180, but was: " + e);
|
|
4434
4441
|
this._lat = t, this._long = e;
|
|
4435
4442
|
}
|
|
4436
4443
|
/**
|
|
@@ -4461,7 +4468,7 @@ function Rn(t, e, ...n) {
|
|
|
4461
4468
|
* Actually private to JS consumers of our API, so this function is prefixed
|
|
4462
4469
|
* with an underscore.
|
|
4463
4470
|
*/ _compareTo(t) {
|
|
4464
|
-
return
|
|
4471
|
+
return vt(this._lat, t._lat) || vt(this._long, t._long);
|
|
4465
4472
|
}
|
|
4466
4473
|
}
|
|
4467
4474
|
|
|
@@ -4480,29 +4487,29 @@ function Rn(t, e, ...n) {
|
|
|
4480
4487
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4481
4488
|
* See the License for the specific language governing permissions and
|
|
4482
4489
|
* limitations under the License.
|
|
4483
|
-
*/ const
|
|
4490
|
+
*/ const qn = /^__.*__$/;
|
|
4484
4491
|
|
|
4485
|
-
/** The result of parsing document data (e.g. for a setData call). */ class
|
|
4492
|
+
/** The result of parsing document data (e.g. for a setData call). */ class On {
|
|
4486
4493
|
constructor(t, e, n) {
|
|
4487
4494
|
this.data = t, this.fieldMask = e, this.fieldTransforms = n;
|
|
4488
4495
|
}
|
|
4489
4496
|
toMutation(t, e) {
|
|
4490
|
-
return null !== this.fieldMask ? new
|
|
4497
|
+
return null !== this.fieldMask ? new Se(t, this.data, this.fieldMask, e, this.fieldTransforms) : new xe(t, this.data, e, this.fieldTransforms);
|
|
4491
4498
|
}
|
|
4492
4499
|
}
|
|
4493
4500
|
|
|
4494
|
-
/** The result of parsing "update" data (i.e. for an updateData call). */ class
|
|
4501
|
+
/** The result of parsing "update" data (i.e. for an updateData call). */ class kn {
|
|
4495
4502
|
constructor(t,
|
|
4496
4503
|
// The fieldMask does not include document transforms.
|
|
4497
4504
|
e, n) {
|
|
4498
4505
|
this.data = t, this.fieldMask = e, this.fieldTransforms = n;
|
|
4499
4506
|
}
|
|
4500
4507
|
toMutation(t, e) {
|
|
4501
|
-
return new
|
|
4508
|
+
return new Se(t, this.data, this.fieldMask, e, this.fieldTransforms);
|
|
4502
4509
|
}
|
|
4503
4510
|
}
|
|
4504
4511
|
|
|
4505
|
-
function
|
|
4512
|
+
function Cn(t) {
|
|
4506
4513
|
switch (t) {
|
|
4507
4514
|
case 0 /* Set */ :
|
|
4508
4515
|
// fall through
|
|
@@ -4516,11 +4523,11 @@ function kn(t) {
|
|
|
4516
4523
|
return !1;
|
|
4517
4524
|
|
|
4518
4525
|
default:
|
|
4519
|
-
throw
|
|
4526
|
+
throw E();
|
|
4520
4527
|
}
|
|
4521
4528
|
}
|
|
4522
4529
|
|
|
4523
|
-
/** A "context" object passed around while parsing user data. */ class
|
|
4530
|
+
/** A "context" object passed around while parsing user data. */ class Ln {
|
|
4524
4531
|
/**
|
|
4525
4532
|
* Initializes a ParseContext with the given source and path.
|
|
4526
4533
|
*
|
|
@@ -4552,7 +4559,7 @@ function kn(t) {
|
|
|
4552
4559
|
return this.settings.st;
|
|
4553
4560
|
}
|
|
4554
4561
|
/** Returns a new context with the specified settings overwritten. */ it(t) {
|
|
4555
|
-
return new
|
|
4562
|
+
return new Ln(Object.assign(Object.assign({}, this.settings), t), this.databaseId, this.L, this.ignoreUndefinedProperties, this.fieldTransforms, this.fieldMask);
|
|
4556
4563
|
}
|
|
4557
4564
|
ot(t) {
|
|
4558
4565
|
var e;
|
|
@@ -4579,7 +4586,7 @@ function kn(t) {
|
|
|
4579
4586
|
});
|
|
4580
4587
|
}
|
|
4581
4588
|
lt(t) {
|
|
4582
|
-
return
|
|
4589
|
+
return ir(t, this.settings.methodName, this.settings.ft || !1, this.path, this.settings.dt);
|
|
4583
4590
|
}
|
|
4584
4591
|
/** Returns 'true' if 'fieldPath' was traversed when creating this context. */ contains(t) {
|
|
4585
4592
|
return void 0 !== this.fieldMask.find((e => t.isPrefixOf(e))) || void 0 !== this.fieldTransforms.find((e => t.isPrefixOf(e.field)));
|
|
@@ -4591,52 +4598,52 @@ function kn(t) {
|
|
|
4591
4598
|
}
|
|
4592
4599
|
ct(t) {
|
|
4593
4600
|
if (0 === t.length) throw this.lt("Document fields must not be empty");
|
|
4594
|
-
if (
|
|
4601
|
+
if (Cn(this.st) && qn.test(t)) throw this.lt('Document fields cannot begin and end with "__"');
|
|
4595
4602
|
}
|
|
4596
4603
|
}
|
|
4597
4604
|
|
|
4598
4605
|
/**
|
|
4599
4606
|
* Helper for parsing raw user input (provided via the API) into internal model
|
|
4600
4607
|
* classes.
|
|
4601
|
-
*/ class
|
|
4608
|
+
*/ class Mn {
|
|
4602
4609
|
constructor(t, e, n) {
|
|
4603
|
-
this.databaseId = t, this.ignoreUndefinedProperties = e, this.L = n ||
|
|
4610
|
+
this.databaseId = t, this.ignoreUndefinedProperties = e, this.L = n || rn(t);
|
|
4604
4611
|
}
|
|
4605
4612
|
/** Creates a new top-level parse context. */ wt(t, e, n, r = !1) {
|
|
4606
|
-
return new
|
|
4613
|
+
return new Ln({
|
|
4607
4614
|
st: t,
|
|
4608
4615
|
methodName: e,
|
|
4609
4616
|
dt: n,
|
|
4610
|
-
path:
|
|
4617
|
+
path: rt.emptyPath(),
|
|
4611
4618
|
ut: !1,
|
|
4612
4619
|
ft: r
|
|
4613
4620
|
}, this.databaseId, this.L, this.ignoreUndefinedProperties);
|
|
4614
4621
|
}
|
|
4615
4622
|
}
|
|
4616
4623
|
|
|
4617
|
-
function
|
|
4618
|
-
const e = t._freezeSettings(), n =
|
|
4619
|
-
return new
|
|
4624
|
+
function Un(t) {
|
|
4625
|
+
const e = t._freezeSettings(), n = rn(t._databaseId);
|
|
4626
|
+
return new Mn(t._databaseId, !!e.ignoreUndefinedProperties, n);
|
|
4620
4627
|
}
|
|
4621
4628
|
|
|
4622
|
-
/** Parse document data from a set() call. */ function
|
|
4629
|
+
/** Parse document data from a set() call. */ function jn(t, e, n, r, s, i = {}) {
|
|
4623
4630
|
const o = t.wt(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ , e, n, s);
|
|
4624
|
-
|
|
4625
|
-
const u =
|
|
4631
|
+
er("Data must be an object, but it was:", o, r);
|
|
4632
|
+
const u = Zn(r, o);
|
|
4626
4633
|
let c, a;
|
|
4627
|
-
if (i.merge) c = new
|
|
4634
|
+
if (i.merge) c = new Dt(o.fieldMask), a = o.fieldTransforms; else if (i.mergeFields) {
|
|
4628
4635
|
const t = [];
|
|
4629
4636
|
for (const r of i.mergeFields) {
|
|
4630
|
-
const s =
|
|
4631
|
-
if (!o.contains(s)) throw new
|
|
4632
|
-
|
|
4637
|
+
const s = nr(e, r, n);
|
|
4638
|
+
if (!o.contains(s)) throw new j(V, `Field '${s}' is specified in your field mask but missing from your input data.`);
|
|
4639
|
+
or(t, s) || t.push(s);
|
|
4633
4640
|
}
|
|
4634
|
-
c = new
|
|
4641
|
+
c = new Dt(t), a = o.fieldTransforms.filter((t => c.covers(t.field)));
|
|
4635
4642
|
} else c = null, a = o.fieldTransforms;
|
|
4636
|
-
return new
|
|
4643
|
+
return new On(new Zt(u), c, a);
|
|
4637
4644
|
}
|
|
4638
4645
|
|
|
4639
|
-
class
|
|
4646
|
+
class Bn extends Sn {
|
|
4640
4647
|
_toFieldTransform(t) {
|
|
4641
4648
|
if (2 /* MergeSet */ !== t.st) throw 1 /* Update */ === t.st ? t.lt(`${this._methodName}() can only appear at the top level of your update data`) : t.lt(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);
|
|
4642
4649
|
// No transform to add for a delete, but we need to add it to our
|
|
@@ -4644,7 +4651,7 @@ class jn extends xn {
|
|
|
4644
4651
|
return t.fieldMask.push(t.path), null;
|
|
4645
4652
|
}
|
|
4646
4653
|
isEqual(t) {
|
|
4647
|
-
return t instanceof
|
|
4654
|
+
return t instanceof Bn;
|
|
4648
4655
|
}
|
|
4649
4656
|
}
|
|
4650
4657
|
|
|
@@ -4663,8 +4670,8 @@ class jn extends xn {
|
|
|
4663
4670
|
* context.
|
|
4664
4671
|
* @param context - The parent context.
|
|
4665
4672
|
* @param arrayElement - Whether or not the FieldValue has an array.
|
|
4666
|
-
*/ function
|
|
4667
|
-
return new
|
|
4673
|
+
*/ function Qn(t, e, n) {
|
|
4674
|
+
return new Ln({
|
|
4668
4675
|
st: 3 /* Argument */ ,
|
|
4669
4676
|
dt: e.settings.dt,
|
|
4670
4677
|
methodName: t._methodName,
|
|
@@ -4672,23 +4679,23 @@ class jn extends xn {
|
|
|
4672
4679
|
}, e.databaseId, e.L, e.ignoreUndefinedProperties);
|
|
4673
4680
|
}
|
|
4674
4681
|
|
|
4675
|
-
class
|
|
4682
|
+
class zn extends Sn {
|
|
4676
4683
|
_toFieldTransform(t) {
|
|
4677
|
-
return new
|
|
4684
|
+
return new Ne(t.path, new Ae);
|
|
4678
4685
|
}
|
|
4679
4686
|
isEqual(t) {
|
|
4680
|
-
return t instanceof
|
|
4687
|
+
return t instanceof zn;
|
|
4681
4688
|
}
|
|
4682
4689
|
}
|
|
4683
4690
|
|
|
4684
|
-
class
|
|
4691
|
+
class Wn extends Sn {
|
|
4685
4692
|
constructor(t, e) {
|
|
4686
4693
|
super(t), this.yt = e;
|
|
4687
4694
|
}
|
|
4688
4695
|
_toFieldTransform(t) {
|
|
4689
|
-
const e =
|
|
4690
|
-
/*array=*/ !0), n = this.yt.map((t =>
|
|
4691
|
-
return new
|
|
4696
|
+
const e = Qn(this, t,
|
|
4697
|
+
/*array=*/ !0), n = this.yt.map((t => Xn(t, e))), r = new Re(n);
|
|
4698
|
+
return new Ne(t.path, r);
|
|
4692
4699
|
}
|
|
4693
4700
|
isEqual(t) {
|
|
4694
4701
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4696,14 +4703,14 @@ class zn extends xn {
|
|
|
4696
4703
|
}
|
|
4697
4704
|
}
|
|
4698
4705
|
|
|
4699
|
-
class
|
|
4706
|
+
class Gn extends Sn {
|
|
4700
4707
|
constructor(t, e) {
|
|
4701
4708
|
super(t), this.yt = e;
|
|
4702
4709
|
}
|
|
4703
4710
|
_toFieldTransform(t) {
|
|
4704
|
-
const e =
|
|
4705
|
-
/*array=*/ !0), n = this.yt.map((t =>
|
|
4706
|
-
return new
|
|
4711
|
+
const e = Qn(this, t,
|
|
4712
|
+
/*array=*/ !0), n = this.yt.map((t => Xn(t, e))), r = new Pe(n);
|
|
4713
|
+
return new Ne(t.path, r);
|
|
4707
4714
|
}
|
|
4708
4715
|
isEqual(t) {
|
|
4709
4716
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4711,13 +4718,13 @@ class Wn extends xn {
|
|
|
4711
4718
|
}
|
|
4712
4719
|
}
|
|
4713
4720
|
|
|
4714
|
-
class
|
|
4721
|
+
class Kn extends Sn {
|
|
4715
4722
|
constructor(t, e) {
|
|
4716
4723
|
super(t), this.gt = e;
|
|
4717
4724
|
}
|
|
4718
4725
|
_toFieldTransform(t) {
|
|
4719
|
-
const e = new
|
|
4720
|
-
return new
|
|
4726
|
+
const e = new Ve(t.L, Ie(t.L, this.gt));
|
|
4727
|
+
return new Ne(t.path, e);
|
|
4721
4728
|
}
|
|
4722
4729
|
isEqual(t) {
|
|
4723
4730
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4725,50 +4732,50 @@ class Gn extends xn {
|
|
|
4725
4732
|
}
|
|
4726
4733
|
}
|
|
4727
4734
|
|
|
4728
|
-
/** Parse update data from an update() call. */ function
|
|
4735
|
+
/** Parse update data from an update() call. */ function Yn(t, e, n, r) {
|
|
4729
4736
|
const s = t.wt(1 /* Update */ , e, n);
|
|
4730
|
-
|
|
4731
|
-
const i = [], o =
|
|
4732
|
-
|
|
4733
|
-
const u =
|
|
4737
|
+
er("Data must be an object, but it was:", s, r);
|
|
4738
|
+
const i = [], o = Zt.empty();
|
|
4739
|
+
At(r, ((t, r) => {
|
|
4740
|
+
const u = sr(e, t, n);
|
|
4734
4741
|
// For Compat types, we have to "extract" the underlying types before
|
|
4735
4742
|
// performing validation.
|
|
4736
|
-
r =
|
|
4743
|
+
r = f(r);
|
|
4737
4744
|
const c = s.at(u);
|
|
4738
|
-
if (r instanceof
|
|
4745
|
+
if (r instanceof Bn)
|
|
4739
4746
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4740
4747
|
i.push(u); else {
|
|
4741
|
-
const t =
|
|
4748
|
+
const t = Xn(r, c);
|
|
4742
4749
|
null != t && (i.push(u), o.set(u, t));
|
|
4743
4750
|
}
|
|
4744
4751
|
}));
|
|
4745
|
-
const u = new
|
|
4746
|
-
return new
|
|
4752
|
+
const u = new Dt(i);
|
|
4753
|
+
return new kn(o, u, s.fieldTransforms);
|
|
4747
4754
|
}
|
|
4748
4755
|
|
|
4749
|
-
/** Parse update data from a list of field/value arguments. */ function
|
|
4750
|
-
const o = t.wt(1 /* Update */ , e, n), u = [
|
|
4751
|
-
if (i.length % 2 != 0) throw new
|
|
4752
|
-
for (let t = 0; t < i.length; t += 2) u.push(
|
|
4753
|
-
const a = [], h =
|
|
4756
|
+
/** Parse update data from a list of field/value arguments. */ function Hn(t, e, n, r, s, i) {
|
|
4757
|
+
const o = t.wt(1 /* Update */ , e, n), u = [ nr(e, r, n) ], c = [ s ];
|
|
4758
|
+
if (i.length % 2 != 0) throw new j(V, `Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);
|
|
4759
|
+
for (let t = 0; t < i.length; t += 2) u.push(nr(e, i[t])), c.push(i[t + 1]);
|
|
4760
|
+
const a = [], h = Zt.empty();
|
|
4754
4761
|
// We iterate in reverse order to pick the last value for a field if the
|
|
4755
4762
|
// user specified the field multiple times.
|
|
4756
|
-
for (let t = u.length - 1; t >= 0; --t) if (!
|
|
4763
|
+
for (let t = u.length - 1; t >= 0; --t) if (!or(a, u[t])) {
|
|
4757
4764
|
const e = u[t];
|
|
4758
4765
|
let n = c[t];
|
|
4759
4766
|
// For Compat types, we have to "extract" the underlying types before
|
|
4760
4767
|
// performing validation.
|
|
4761
|
-
n =
|
|
4768
|
+
n = f(n);
|
|
4762
4769
|
const r = o.at(e);
|
|
4763
|
-
if (n instanceof
|
|
4770
|
+
if (n instanceof Bn)
|
|
4764
4771
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4765
4772
|
a.push(e); else {
|
|
4766
|
-
const t =
|
|
4773
|
+
const t = Xn(n, r);
|
|
4767
4774
|
null != t && (a.push(e), h.set(e, t));
|
|
4768
4775
|
}
|
|
4769
4776
|
}
|
|
4770
|
-
const
|
|
4771
|
-
return new
|
|
4777
|
+
const l = new Dt(a);
|
|
4778
|
+
return new kn(h, l, o.fieldTransforms);
|
|
4772
4779
|
}
|
|
4773
4780
|
|
|
4774
4781
|
/**
|
|
@@ -4777,8 +4784,8 @@ class Gn extends xn {
|
|
|
4777
4784
|
*
|
|
4778
4785
|
* @param allowArrays - Whether the query value is an array that may directly
|
|
4779
4786
|
* contain additional arrays (e.g. the operand of an `in` query).
|
|
4780
|
-
*/ function
|
|
4781
|
-
return
|
|
4787
|
+
*/ function Jn(t, e, n, r = !1) {
|
|
4788
|
+
return Xn(n, t.wt(r ? 4 /* ArrayArgument */ : 3 /* Argument */ , e));
|
|
4782
4789
|
}
|
|
4783
4790
|
|
|
4784
4791
|
/**
|
|
@@ -4789,12 +4796,12 @@ class Gn extends xn {
|
|
|
4789
4796
|
* the source of the data being parsed, etc.
|
|
4790
4797
|
* @returns The parsed value, or null if the value was a FieldValue sentinel
|
|
4791
4798
|
* that should not be included in the resulting parsed data.
|
|
4792
|
-
*/ function
|
|
4793
|
-
if (
|
|
4799
|
+
*/ function Xn(t, e) {
|
|
4800
|
+
if (tr(
|
|
4794
4801
|
// Unwrap the API type from the Compat SDK. This will return the API type
|
|
4795
4802
|
// from firestore-exp.
|
|
4796
|
-
t =
|
|
4797
|
-
if (t instanceof
|
|
4803
|
+
t = f(t))) return er("Unsupported field value:", e, t), Zn(t, e);
|
|
4804
|
+
if (t instanceof Sn)
|
|
4798
4805
|
// FieldValues usually parse into transforms (except deleteField())
|
|
4799
4806
|
// in which case we do not want to include this field in our parsed data
|
|
4800
4807
|
// (as doing so will overwrite the field directly prior to the transform
|
|
@@ -4806,7 +4813,7 @@ class Gn extends xn {
|
|
|
4806
4813
|
*/
|
|
4807
4814
|
return function(t, e) {
|
|
4808
4815
|
// Sentinels are only supported with writes, and not within arrays.
|
|
4809
|
-
if (!
|
|
4816
|
+
if (!Cn(e.st)) throw e.lt(`${t._methodName}() can only be used with update() and set()`);
|
|
4810
4817
|
if (!e.path) throw e.lt(`${t._methodName}() is not currently supported inside arrays`);
|
|
4811
4818
|
const n = t._toFieldTransform(e);
|
|
4812
4819
|
n && e.fieldTransforms.push(n);
|
|
@@ -4836,7 +4843,7 @@ class Gn extends xn {
|
|
|
4836
4843
|
const n = [];
|
|
4837
4844
|
let r = 0;
|
|
4838
4845
|
for (const s of t) {
|
|
4839
|
-
let t =
|
|
4846
|
+
let t = Xn(s, e.ht(r));
|
|
4840
4847
|
null == t && (
|
|
4841
4848
|
// Just include nulls in the array for fields being replaced with a
|
|
4842
4849
|
// sentinel.
|
|
@@ -4852,10 +4859,10 @@ class Gn extends xn {
|
|
|
4852
4859
|
}(t, e);
|
|
4853
4860
|
}
|
|
4854
4861
|
return function(t, e) {
|
|
4855
|
-
if (null === (t =
|
|
4862
|
+
if (null === (t = f(t))) return {
|
|
4856
4863
|
nullValue: "NULL_VALUE"
|
|
4857
4864
|
};
|
|
4858
|
-
if ("number" == typeof t) return
|
|
4865
|
+
if ("number" == typeof t) return Ie(e.L, t);
|
|
4859
4866
|
if ("boolean" == typeof t) return {
|
|
4860
4867
|
booleanValue: t
|
|
4861
4868
|
};
|
|
@@ -4863,37 +4870,37 @@ class Gn extends xn {
|
|
|
4863
4870
|
stringValue: t
|
|
4864
4871
|
};
|
|
4865
4872
|
if (t instanceof Date) {
|
|
4866
|
-
const n =
|
|
4873
|
+
const n = Et.fromDate(t);
|
|
4867
4874
|
return {
|
|
4868
|
-
timestampValue:
|
|
4875
|
+
timestampValue: Le(e.L, n)
|
|
4869
4876
|
};
|
|
4870
4877
|
}
|
|
4871
|
-
if (t instanceof
|
|
4878
|
+
if (t instanceof Et) {
|
|
4872
4879
|
// Firestore backend truncates precision down to microseconds. To ensure
|
|
4873
4880
|
// offline mode works the same with regards to truncation, perform the
|
|
4874
4881
|
// truncation immediately without waiting for the backend to do that.
|
|
4875
|
-
const n = new
|
|
4882
|
+
const n = new Et(t.seconds, 1e3 * Math.floor(t.nanoseconds / 1e3));
|
|
4876
4883
|
return {
|
|
4877
|
-
timestampValue:
|
|
4884
|
+
timestampValue: Le(e.L, n)
|
|
4878
4885
|
};
|
|
4879
4886
|
}
|
|
4880
|
-
if (t instanceof
|
|
4887
|
+
if (t instanceof Fn) return {
|
|
4881
4888
|
geoPointValue: {
|
|
4882
4889
|
latitude: t.latitude,
|
|
4883
4890
|
longitude: t.longitude
|
|
4884
4891
|
}
|
|
4885
4892
|
};
|
|
4886
|
-
if (t instanceof
|
|
4887
|
-
bytesValue:
|
|
4893
|
+
if (t instanceof $n) return {
|
|
4894
|
+
bytesValue: Me(e.L, t._byteString)
|
|
4888
4895
|
};
|
|
4889
|
-
if (t instanceof
|
|
4896
|
+
if (t instanceof En) {
|
|
4890
4897
|
const n = e.databaseId, r = t.firestore._databaseId;
|
|
4891
4898
|
if (!r.isEqual(n)) throw e.lt(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);
|
|
4892
4899
|
return {
|
|
4893
|
-
referenceValue:
|
|
4900
|
+
referenceValue: Be(t.firestore._databaseId || e.databaseId, t._key.path)
|
|
4894
4901
|
};
|
|
4895
4902
|
}
|
|
4896
|
-
throw e.lt(`Unsupported field value: ${
|
|
4903
|
+
throw e.lt(`Unsupported field value: ${ct(t)}`);
|
|
4897
4904
|
}
|
|
4898
4905
|
/**
|
|
4899
4906
|
* Checks whether an object looks like a JSON object that should be converted
|
|
@@ -4904,13 +4911,13 @@ class Gn extends xn {
|
|
|
4904
4911
|
*/ (t, e);
|
|
4905
4912
|
}
|
|
4906
4913
|
|
|
4907
|
-
function
|
|
4914
|
+
function Zn(t, e) {
|
|
4908
4915
|
const n = {};
|
|
4909
4916
|
return !function(t) {
|
|
4910
4917
|
for (const e in t) if (Object.prototype.hasOwnProperty.call(t, e)) return !1;
|
|
4911
4918
|
return !0;
|
|
4912
|
-
}(t) ?
|
|
4913
|
-
const s =
|
|
4919
|
+
}(t) ? At(t, ((t, r) => {
|
|
4920
|
+
const s = Xn(r, e.ot(t));
|
|
4914
4921
|
null != s && (n[t] = s);
|
|
4915
4922
|
})) :
|
|
4916
4923
|
// If we encounter an empty object, we explicitly add it to the update
|
|
@@ -4922,35 +4929,35 @@ function Xn(t, e) {
|
|
|
4922
4929
|
};
|
|
4923
4930
|
}
|
|
4924
4931
|
|
|
4925
|
-
function
|
|
4926
|
-
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof
|
|
4932
|
+
function tr(t) {
|
|
4933
|
+
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof Et || t instanceof Fn || t instanceof $n || t instanceof En || t instanceof Sn);
|
|
4927
4934
|
}
|
|
4928
4935
|
|
|
4929
|
-
function
|
|
4930
|
-
if (!
|
|
4936
|
+
function er(t, e, n) {
|
|
4937
|
+
if (!tr(n) || !function(t) {
|
|
4931
4938
|
return "object" == typeof t && null !== t && (Object.getPrototypeOf(t) === Object.prototype || null === Object.getPrototypeOf(t));
|
|
4932
4939
|
}(n)) {
|
|
4933
|
-
const r =
|
|
4940
|
+
const r = ct(n);
|
|
4934
4941
|
throw "an object" === r ? e.lt(t + " a custom object") : e.lt(t + " " + r);
|
|
4935
4942
|
}
|
|
4936
4943
|
}
|
|
4937
4944
|
|
|
4938
4945
|
/**
|
|
4939
4946
|
* Helper that calls fromDotSeparatedString() but wraps any error thrown.
|
|
4940
|
-
*/ function
|
|
4947
|
+
*/ function nr(t, e, n) {
|
|
4941
4948
|
if ((
|
|
4942
4949
|
// If required, replace the FieldPath Compat class with with the firestore-exp
|
|
4943
4950
|
// FieldPath.
|
|
4944
|
-
e =
|
|
4945
|
-
if ("string" == typeof e) return
|
|
4946
|
-
throw
|
|
4951
|
+
e = f(e)) instanceof Dn) return e._internalPath;
|
|
4952
|
+
if ("string" == typeof e) return sr(t, e);
|
|
4953
|
+
throw ir("Field path arguments must be of type string or ", t,
|
|
4947
4954
|
/* hasConverter= */ !1,
|
|
4948
4955
|
/* path= */ void 0, n);
|
|
4949
4956
|
}
|
|
4950
4957
|
|
|
4951
4958
|
/**
|
|
4952
4959
|
* Matches any characters in a field path string that are reserved.
|
|
4953
|
-
*/ const
|
|
4960
|
+
*/ const rr = new RegExp("[~\\*/\\[\\]]");
|
|
4954
4961
|
|
|
4955
4962
|
/**
|
|
4956
4963
|
* Wraps fromDotSeparatedString with an error message about the method that
|
|
@@ -4960,29 +4967,29 @@ function tr(t, e, n) {
|
|
|
4960
4967
|
* split on dots.
|
|
4961
4968
|
* @param targetDoc - The document against which the field path will be
|
|
4962
4969
|
* evaluated.
|
|
4963
|
-
*/ function
|
|
4964
|
-
if (e.search(
|
|
4970
|
+
*/ function sr(t, e, n) {
|
|
4971
|
+
if (e.search(rr) >= 0) throw ir(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`, t,
|
|
4965
4972
|
/* hasConverter= */ !1,
|
|
4966
4973
|
/* path= */ void 0, n);
|
|
4967
4974
|
try {
|
|
4968
|
-
return new
|
|
4975
|
+
return new Dn(...e.split("."))._internalPath;
|
|
4969
4976
|
} catch (r) {
|
|
4970
|
-
throw
|
|
4977
|
+
throw ir(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`, t,
|
|
4971
4978
|
/* hasConverter= */ !1,
|
|
4972
4979
|
/* path= */ void 0, n);
|
|
4973
4980
|
}
|
|
4974
4981
|
}
|
|
4975
4982
|
|
|
4976
|
-
function
|
|
4983
|
+
function ir(t, e, n, r, s) {
|
|
4977
4984
|
const i = r && !r.isEmpty(), o = void 0 !== s;
|
|
4978
4985
|
let u = `Function ${e}() called with invalid data`;
|
|
4979
4986
|
n && (u += " (via `toFirestore()`)"), u += ". ";
|
|
4980
4987
|
let c = "";
|
|
4981
4988
|
return (i || o) && (c += " (found", i && (c += ` in field ${r}`), o && (c += ` in document ${s}`),
|
|
4982
|
-
c += ")"), new
|
|
4989
|
+
c += ")"), new j(V, u + t + c);
|
|
4983
4990
|
}
|
|
4984
4991
|
|
|
4985
|
-
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function
|
|
4992
|
+
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function or(t, e) {
|
|
4986
4993
|
return t.some((t => t.isEqual(e)));
|
|
4987
4994
|
}
|
|
4988
4995
|
|
|
@@ -5010,7 +5017,7 @@ function sr(t, e, n, r, s) {
|
|
|
5010
5017
|
* For a `DocumentSnapshot` that points to a non-existing document, any data
|
|
5011
5018
|
* access will return 'undefined'. You can use the `exists()` method to
|
|
5012
5019
|
* explicitly verify a document's existence.
|
|
5013
|
-
*/ class
|
|
5020
|
+
*/ class ur {
|
|
5014
5021
|
// Note: This class is stripped down version of the DocumentSnapshot in
|
|
5015
5022
|
// the legacy SDK. The changes are:
|
|
5016
5023
|
// - No support for SnapshotMetadata.
|
|
@@ -5026,7 +5033,7 @@ function sr(t, e, n, r, s) {
|
|
|
5026
5033
|
/**
|
|
5027
5034
|
* The `DocumentReference` for the document included in the `DocumentSnapshot`.
|
|
5028
5035
|
*/ get ref() {
|
|
5029
|
-
return new
|
|
5036
|
+
return new En(this._firestore, this._converter, this._key);
|
|
5030
5037
|
}
|
|
5031
5038
|
/**
|
|
5032
5039
|
* Signals whether or not the document at the snapshot's location exists.
|
|
@@ -5046,7 +5053,7 @@ function sr(t, e, n, r, s) {
|
|
|
5046
5053
|
if (this._converter) {
|
|
5047
5054
|
// We only want to use the converter and create a new DocumentSnapshot
|
|
5048
5055
|
// if a converter has been provided.
|
|
5049
|
-
const t = new
|
|
5056
|
+
const t = new cr(this._firestore, this._userDataWriter, this._key, this._document,
|
|
5050
5057
|
/* converter= */ null);
|
|
5051
5058
|
return this._converter.fromFirestore(t);
|
|
5052
5059
|
}
|
|
@@ -5066,7 +5073,7 @@ function sr(t, e, n, r, s) {
|
|
|
5066
5073
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5067
5074
|
get(t) {
|
|
5068
5075
|
if (this._document) {
|
|
5069
|
-
const e = this._document.data.field(
|
|
5076
|
+
const e = this._document.data.field(lr("DocumentSnapshot.get", t));
|
|
5070
5077
|
if (null !== e) return this._userDataWriter.convertValue(e);
|
|
5071
5078
|
}
|
|
5072
5079
|
}
|
|
@@ -5082,7 +5089,7 @@ function sr(t, e, n, r, s) {
|
|
|
5082
5089
|
* `DocumentSnapshot`. Since query results contain only existing documents, the
|
|
5083
5090
|
* `exists` property will always be true and `data()` will never return
|
|
5084
5091
|
* 'undefined'.
|
|
5085
|
-
*/ class
|
|
5092
|
+
*/ class cr extends ur {
|
|
5086
5093
|
/**
|
|
5087
5094
|
* Retrieves all fields in the document as an `Object`.
|
|
5088
5095
|
*
|
|
@@ -5100,7 +5107,7 @@ function sr(t, e, n, r, s) {
|
|
|
5100
5107
|
* array via the `docs` property or enumerated using the `forEach` method. The
|
|
5101
5108
|
* number of documents can be determined via the `empty` and `size`
|
|
5102
5109
|
* properties.
|
|
5103
|
-
*/ class
|
|
5110
|
+
*/ class ar {
|
|
5104
5111
|
/** @hideconstructor */
|
|
5105
5112
|
constructor(t, e) {
|
|
5106
5113
|
this._docs = e, this.query = t;
|
|
@@ -5131,14 +5138,14 @@ function sr(t, e, n, r, s) {
|
|
|
5131
5138
|
* @param left - A snapshot to compare.
|
|
5132
5139
|
* @param right - A snapshot to compare.
|
|
5133
5140
|
* @returns true if the snapshots are equal.
|
|
5134
|
-
*/ function
|
|
5135
|
-
return t =
|
|
5141
|
+
*/ function hr(t, e) {
|
|
5142
|
+
return t = f(t), e = f(e), t instanceof ur && e instanceof ur ? 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 ar && e instanceof ar && (Nn(t.query, e.query) && bt(t.docs, e.docs, hr));
|
|
5136
5143
|
}
|
|
5137
5144
|
|
|
5138
5145
|
/**
|
|
5139
5146
|
* Helper that calls `fromDotSeparatedString()` but wraps any error thrown.
|
|
5140
|
-
*/ function
|
|
5141
|
-
return "string" == typeof e ?
|
|
5147
|
+
*/ function lr(t, e) {
|
|
5148
|
+
return "string" == typeof e ? sr(t, e) : e instanceof Dn ? e._internalPath : e._delegate._internalPath;
|
|
5142
5149
|
}
|
|
5143
5150
|
|
|
5144
5151
|
/**
|
|
@@ -5165,7 +5172,7 @@ function sr(t, e, n, r, s) {
|
|
|
5165
5172
|
* can then be passed to {@link query} to create a new query instance that
|
|
5166
5173
|
* also contains this `QueryConstraint`.
|
|
5167
5174
|
*/
|
|
5168
|
-
class
|
|
5175
|
+
class fr {}
|
|
5169
5176
|
|
|
5170
5177
|
/**
|
|
5171
5178
|
* Creates a new immutable instance of {@link Query} that is extended to also include
|
|
@@ -5175,40 +5182,40 @@ class lr {}
|
|
|
5175
5182
|
* @param queryConstraints - The list of {@link QueryConstraint}s to apply.
|
|
5176
5183
|
* @throws if any of the provided query constraints cannot be combined with the
|
|
5177
5184
|
* existing or new constraints.
|
|
5178
|
-
*/ function
|
|
5185
|
+
*/ function dr(t, ...e) {
|
|
5179
5186
|
for (const n of e) t = n._apply(t);
|
|
5180
5187
|
return t;
|
|
5181
5188
|
}
|
|
5182
5189
|
|
|
5183
|
-
class
|
|
5190
|
+
class wr extends fr {
|
|
5184
5191
|
constructor(t, e, n) {
|
|
5185
5192
|
super(), this._t = t, this.vt = e, this.bt = n, this.type = "where";
|
|
5186
5193
|
}
|
|
5187
5194
|
_apply(t) {
|
|
5188
|
-
const e =
|
|
5195
|
+
const e = Un(t.firestore), n = function(t, e, n, r, s, i, o) {
|
|
5189
5196
|
let u;
|
|
5190
5197
|
if (s.isKeyField()) {
|
|
5191
|
-
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new
|
|
5198
|
+
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new j(V, `Invalid Query. You can't perform '${i}' queries on documentId().`);
|
|
5192
5199
|
if ("in" /* IN */ === i || "not-in" /* NOT_IN */ === i) {
|
|
5193
|
-
|
|
5200
|
+
Nr(o, i);
|
|
5194
5201
|
const e = [];
|
|
5195
|
-
for (const n of o) e.push(
|
|
5202
|
+
for (const n of o) e.push(Vr(r, t, n));
|
|
5196
5203
|
u = {
|
|
5197
5204
|
arrayValue: {
|
|
5198
5205
|
values: e
|
|
5199
5206
|
}
|
|
5200
5207
|
};
|
|
5201
|
-
} else u =
|
|
5202
|
-
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i ||
|
|
5203
|
-
u =
|
|
5208
|
+
} else u = Vr(r, t, o);
|
|
5209
|
+
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i || Nr(o, i),
|
|
5210
|
+
u = Jn(n, e, o,
|
|
5204
5211
|
/* allowArrays= */ "in" /* IN */ === i || "not-in" /* NOT_IN */ === i);
|
|
5205
|
-
const c =
|
|
5212
|
+
const c = re.create(s, i, u);
|
|
5206
5213
|
return function(t, e) {
|
|
5207
5214
|
if (e.q()) {
|
|
5208
|
-
const n =
|
|
5209
|
-
if (null !== n && !n.isEqual(e.field)) throw new
|
|
5210
|
-
const r =
|
|
5211
|
-
null !== r &&
|
|
5215
|
+
const n = ge(t);
|
|
5216
|
+
if (null !== n && !n.isEqual(e.field)) throw new j(V, `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()}'`);
|
|
5217
|
+
const r = ye(t);
|
|
5218
|
+
null !== r && $r(t, e.field, r);
|
|
5212
5219
|
}
|
|
5213
5220
|
const n = function(t, e) {
|
|
5214
5221
|
for (const n of t.filters) if (e.indexOf(n.op) >= 0) return n.op;
|
|
@@ -5249,12 +5256,12 @@ class dr extends lr {
|
|
|
5249
5256
|
}(e.op));
|
|
5250
5257
|
if (null !== n)
|
|
5251
5258
|
// Special case when it's a duplicate op to give a slightly clearer error message.
|
|
5252
|
-
throw n === e.op ? new
|
|
5259
|
+
throw n === e.op ? new j(V, `Invalid query. You cannot use more than one '${e.op.toString()}' filter.`) : new j(V, `Invalid query. You cannot use '${e.op.toString()}' filters with '${n.toString()}' filters.`);
|
|
5253
5260
|
}(t, c), c;
|
|
5254
5261
|
}(t._query, "where", e, t.firestore._databaseId, this._t, this.vt, this.bt);
|
|
5255
|
-
return new
|
|
5262
|
+
return new In(t.firestore, t.converter, function(t, e) {
|
|
5256
5263
|
const n = t.filters.concat([ e ]);
|
|
5257
|
-
return new
|
|
5264
|
+
return new pe(t.path, t.collectionGroup, t.explicitOrderBy.slice(), n, t.limit, t.limitType, t.startAt, t.endAt);
|
|
5258
5265
|
}(t._query, n));
|
|
5259
5266
|
}
|
|
5260
5267
|
}
|
|
@@ -5269,25 +5276,25 @@ class dr extends lr {
|
|
|
5269
5276
|
* "<=", "!=").
|
|
5270
5277
|
* @param value - The value for comparison
|
|
5271
5278
|
* @returns The created {@link Query}.
|
|
5272
|
-
*/ function
|
|
5273
|
-
const r = e, s =
|
|
5274
|
-
return new
|
|
5279
|
+
*/ function mr(t, e, n) {
|
|
5280
|
+
const r = e, s = lr("where", t);
|
|
5281
|
+
return new wr(s, r, n);
|
|
5275
5282
|
}
|
|
5276
5283
|
|
|
5277
|
-
class
|
|
5284
|
+
class pr extends fr {
|
|
5278
5285
|
constructor(t, e) {
|
|
5279
5286
|
super(), this._t = t, this.Et = e, this.type = "orderBy";
|
|
5280
5287
|
}
|
|
5281
5288
|
_apply(t) {
|
|
5282
5289
|
const e = function(t, e, n) {
|
|
5283
|
-
if (null !== t.startAt) throw new
|
|
5284
|
-
if (null !== t.endAt) throw new
|
|
5285
|
-
const r = new
|
|
5290
|
+
if (null !== t.startAt) throw new j(V, "Invalid query. You must not call startAt() or startAfter() before calling orderBy().");
|
|
5291
|
+
if (null !== t.endAt) throw new j(V, "Invalid query. You must not call endAt() or endBefore() before calling orderBy().");
|
|
5292
|
+
const r = new de(e, n);
|
|
5286
5293
|
return function(t, e) {
|
|
5287
|
-
if (null ===
|
|
5294
|
+
if (null === ye(t)) {
|
|
5288
5295
|
// This is the first order by. It must match any inequality.
|
|
5289
|
-
const n =
|
|
5290
|
-
null !== n &&
|
|
5296
|
+
const n = ge(t);
|
|
5297
|
+
null !== n && $r(t, n, e.field);
|
|
5291
5298
|
}
|
|
5292
5299
|
}(t, r), r;
|
|
5293
5300
|
}
|
|
@@ -5302,10 +5309,10 @@ class mr extends lr {
|
|
|
5302
5309
|
* of the query or if any of the fields in the order by are an uncommitted
|
|
5303
5310
|
* server timestamp.
|
|
5304
5311
|
*/ (t._query, this._t, this.Et);
|
|
5305
|
-
return new
|
|
5312
|
+
return new In(t.firestore, t.converter, function(t, e) {
|
|
5306
5313
|
// TODO(dimond): validate that orderBy does not list the same key twice.
|
|
5307
5314
|
const n = t.explicitOrderBy.concat([ e ]);
|
|
5308
|
-
return new
|
|
5315
|
+
return new pe(t.path, t.collectionGroup, n, t.filters.slice(), t.limit, t.limitType, t.startAt, t.endAt);
|
|
5309
5316
|
}(t._query, e));
|
|
5310
5317
|
}
|
|
5311
5318
|
}
|
|
@@ -5318,18 +5325,18 @@ class mr extends lr {
|
|
|
5318
5325
|
* @param directionStr - Optional direction to sort by ('asc' or 'desc'). If
|
|
5319
5326
|
* not specified, order will be ascending.
|
|
5320
5327
|
* @returns The created {@link Query}.
|
|
5321
|
-
*/ function
|
|
5322
|
-
const n = e, r =
|
|
5323
|
-
return new
|
|
5328
|
+
*/ function yr(t, e = "asc") {
|
|
5329
|
+
const n = e, r = lr("orderBy", t);
|
|
5330
|
+
return new pr(r, n);
|
|
5324
5331
|
}
|
|
5325
5332
|
|
|
5326
|
-
class
|
|
5333
|
+
class gr extends fr {
|
|
5327
5334
|
constructor(t, e, n) {
|
|
5328
5335
|
super(), this.type = t, this.It = e, this.Tt = n;
|
|
5329
5336
|
}
|
|
5330
5337
|
_apply(t) {
|
|
5331
|
-
return new
|
|
5332
|
-
return new
|
|
5338
|
+
return new In(t.firestore, t.converter, function(t, e, n) {
|
|
5339
|
+
return new pe(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), e, n, t.startAt, t.endAt);
|
|
5333
5340
|
}(t._query, this.It, this.Tt));
|
|
5334
5341
|
}
|
|
5335
5342
|
}
|
|
@@ -5339,8 +5346,8 @@ class yr extends lr {
|
|
|
5339
5346
|
*
|
|
5340
5347
|
* @param limit - The maximum number of items to return.
|
|
5341
5348
|
* @returns The created {@link Query}.
|
|
5342
|
-
*/ function
|
|
5343
|
-
return
|
|
5349
|
+
*/ function _r(t) {
|
|
5350
|
+
return ht("limit", t), new gr("limit", t, "F" /* First */);
|
|
5344
5351
|
}
|
|
5345
5352
|
|
|
5346
5353
|
/**
|
|
@@ -5351,56 +5358,56 @@ class yr extends lr {
|
|
|
5351
5358
|
*
|
|
5352
5359
|
* @param limit - The maximum number of items to return.
|
|
5353
5360
|
* @returns The created {@link Query}.
|
|
5354
|
-
*/ function
|
|
5355
|
-
return
|
|
5361
|
+
*/ function vr(t) {
|
|
5362
|
+
return ht("limitToLast", t), new gr("limitToLast", t, "L" /* Last */);
|
|
5356
5363
|
}
|
|
5357
5364
|
|
|
5358
|
-
class
|
|
5365
|
+
class br extends fr {
|
|
5359
5366
|
constructor(t, e, n) {
|
|
5360
5367
|
super(), this.type = t, this.At = e, this.Rt = n;
|
|
5361
5368
|
}
|
|
5362
5369
|
_apply(t) {
|
|
5363
|
-
const e =
|
|
5364
|
-
return new
|
|
5365
|
-
return new
|
|
5370
|
+
const e = Pr(t, this.type, this.At, this.Rt);
|
|
5371
|
+
return new In(t.firestore, t.converter, function(t, e) {
|
|
5372
|
+
return new pe(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, e, t.endAt);
|
|
5366
5373
|
}(t._query, e));
|
|
5367
5374
|
}
|
|
5368
5375
|
}
|
|
5369
5376
|
|
|
5370
|
-
function
|
|
5371
|
-
return new
|
|
5377
|
+
function Er(...t) {
|
|
5378
|
+
return new br("startAt", t,
|
|
5372
5379
|
/*inclusive=*/ !0);
|
|
5373
5380
|
}
|
|
5374
5381
|
|
|
5375
|
-
function
|
|
5376
|
-
return new
|
|
5382
|
+
function Ir(...t) {
|
|
5383
|
+
return new br("startAfter", t,
|
|
5377
5384
|
/*inclusive=*/ !1);
|
|
5378
5385
|
}
|
|
5379
5386
|
|
|
5380
|
-
class
|
|
5387
|
+
class Tr extends fr {
|
|
5381
5388
|
constructor(t, e, n) {
|
|
5382
5389
|
super(), this.type = t, this.At = e, this.Rt = n;
|
|
5383
5390
|
}
|
|
5384
5391
|
_apply(t) {
|
|
5385
|
-
const e =
|
|
5386
|
-
return new
|
|
5387
|
-
return new
|
|
5392
|
+
const e = Pr(t, this.type, this.At, this.Rt);
|
|
5393
|
+
return new In(t.firestore, t.converter, function(t, e) {
|
|
5394
|
+
return new pe(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, t.startAt, e);
|
|
5388
5395
|
}(t._query, e));
|
|
5389
5396
|
}
|
|
5390
5397
|
}
|
|
5391
5398
|
|
|
5392
|
-
function
|
|
5393
|
-
return new
|
|
5399
|
+
function Ar(...t) {
|
|
5400
|
+
return new Tr("endBefore", t,
|
|
5394
5401
|
/*inclusive=*/ !1);
|
|
5395
5402
|
}
|
|
5396
5403
|
|
|
5397
|
-
function
|
|
5398
|
-
return new
|
|
5404
|
+
function Rr(...t) {
|
|
5405
|
+
return new Tr("endAt", t, /*inclusive=*/ !0);
|
|
5399
5406
|
}
|
|
5400
5407
|
|
|
5401
|
-
/** Helper function to create a bound from a document or fields */ function
|
|
5402
|
-
if (n[0] =
|
|
5403
|
-
if (!r) throw new
|
|
5408
|
+
/** Helper function to create a bound from a document or fields */ function Pr(t, e, n, r) {
|
|
5409
|
+
if (n[0] = f(n[0]), n[0] instanceof ur) return function(t, e, n, r, s) {
|
|
5410
|
+
if (!r) throw new j($, `Can't use a DocumentSnapshot that doesn't exist for ${n}().`);
|
|
5404
5411
|
const i = [];
|
|
5405
5412
|
// Because people expect to continue/end a query at the exact document
|
|
5406
5413
|
// provided, we need to use the implicit sort order rather than the explicit
|
|
@@ -5409,42 +5416,42 @@ function Ar(...t) {
|
|
|
5409
5416
|
// the provided document. Without the key (by using the explicit sort
|
|
5410
5417
|
// orders), multiple documents could match the position, yielding duplicate
|
|
5411
5418
|
// results.
|
|
5412
|
-
for (const n of
|
|
5419
|
+
for (const n of ve(t)) if (n.field.isKeyField()) i.push(Gt(e, r.key)); else {
|
|
5413
5420
|
const t = r.data.field(n.field);
|
|
5414
|
-
if (
|
|
5421
|
+
if (Ct(t)) throw new j(V, '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.)');
|
|
5415
5422
|
if (null === t) {
|
|
5416
5423
|
const t = n.field.canonicalString();
|
|
5417
|
-
throw new
|
|
5424
|
+
throw new j(V, `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.`);
|
|
5418
5425
|
}
|
|
5419
5426
|
i.push(t);
|
|
5420
5427
|
}
|
|
5421
|
-
return new
|
|
5428
|
+
return new fe(i, s);
|
|
5422
5429
|
}
|
|
5423
5430
|
/**
|
|
5424
5431
|
* Converts a list of field values to a `Bound` for the given query.
|
|
5425
5432
|
*/ (t._query, t.firestore._databaseId, e, n[0]._document, r);
|
|
5426
5433
|
{
|
|
5427
|
-
const s =
|
|
5434
|
+
const s = Un(t.firestore);
|
|
5428
5435
|
return function(t, e, n, r, s, i) {
|
|
5429
5436
|
// Use explicit order by's because it has to match the query the user made
|
|
5430
5437
|
const o = t.explicitOrderBy;
|
|
5431
|
-
if (s.length > o.length) throw new
|
|
5438
|
+
if (s.length > o.length) throw new j(V, `Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);
|
|
5432
5439
|
const u = [];
|
|
5433
5440
|
for (let i = 0; i < s.length; i++) {
|
|
5434
5441
|
const c = s[i];
|
|
5435
5442
|
if (o[i].field.isKeyField()) {
|
|
5436
|
-
if ("string" != typeof c) throw new
|
|
5437
|
-
if (!
|
|
5438
|
-
const n = t.path.child(
|
|
5439
|
-
if (!
|
|
5440
|
-
const s = new
|
|
5441
|
-
u.push(
|
|
5443
|
+
if ("string" != typeof c) throw new j(V, `Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);
|
|
5444
|
+
if (!_e(t) && -1 !== c.indexOf("/")) throw new j(V, `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.`);
|
|
5445
|
+
const n = t.path.child(et.fromString(c));
|
|
5446
|
+
if (!st.isDocumentKey(n)) throw new j(V, `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.`);
|
|
5447
|
+
const s = new st(n);
|
|
5448
|
+
u.push(Gt(e, s));
|
|
5442
5449
|
} else {
|
|
5443
|
-
const t =
|
|
5450
|
+
const t = Jn(n, r, c);
|
|
5444
5451
|
u.push(t);
|
|
5445
5452
|
}
|
|
5446
5453
|
}
|
|
5447
|
-
return new
|
|
5454
|
+
return new fe(u, i);
|
|
5448
5455
|
}
|
|
5449
5456
|
/**
|
|
5450
5457
|
* Parses the given `documentIdValue` into a `ReferenceValue`, throwing
|
|
@@ -5454,28 +5461,28 @@ function Ar(...t) {
|
|
|
5454
5461
|
}
|
|
5455
5462
|
}
|
|
5456
5463
|
|
|
5457
|
-
function
|
|
5458
|
-
if ("string" == typeof (n =
|
|
5459
|
-
if ("" === n) throw new
|
|
5460
|
-
if (!
|
|
5461
|
-
const r = e.path.child(
|
|
5462
|
-
if (!
|
|
5463
|
-
return
|
|
5464
|
+
function Vr(t, e, n) {
|
|
5465
|
+
if ("string" == typeof (n = f(n))) {
|
|
5466
|
+
if ("" === n) throw new j(V, "Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");
|
|
5467
|
+
if (!_e(e) && -1 !== n.indexOf("/")) throw new j(V, `Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);
|
|
5468
|
+
const r = e.path.child(et.fromString(n));
|
|
5469
|
+
if (!st.isDocumentKey(r)) throw new j(V, `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}).`);
|
|
5470
|
+
return Gt(t, new st(r));
|
|
5464
5471
|
}
|
|
5465
|
-
if (n instanceof
|
|
5466
|
-
throw new
|
|
5472
|
+
if (n instanceof En) return Gt(t, n._key);
|
|
5473
|
+
throw new j(V, `Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${ct(n)}.`);
|
|
5467
5474
|
}
|
|
5468
5475
|
|
|
5469
5476
|
/**
|
|
5470
5477
|
* Validates that the value passed into a disjunctive filter satisfies all
|
|
5471
5478
|
* array requirements.
|
|
5472
|
-
*/ function
|
|
5473
|
-
if (!Array.isArray(t) || 0 === t.length) throw new
|
|
5474
|
-
if (t.length > 10) throw new
|
|
5479
|
+
*/ function Nr(t, e) {
|
|
5480
|
+
if (!Array.isArray(t) || 0 === t.length) throw new j(V, `Invalid Query. A non-empty array is required for '${e.toString()}' filters.`);
|
|
5481
|
+
if (t.length > 10) throw new j(V, `Invalid Query. '${e.toString()}' filters support a maximum of 10 elements in the value array.`);
|
|
5475
5482
|
}
|
|
5476
5483
|
|
|
5477
|
-
function
|
|
5478
|
-
if (!n.isEqual(e)) throw new
|
|
5484
|
+
function $r(t, e, n) {
|
|
5485
|
+
if (!n.isEqual(e)) throw new j(V, `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.`);
|
|
5479
5486
|
}
|
|
5480
5487
|
|
|
5481
5488
|
/**
|
|
@@ -5525,7 +5532,7 @@ function Nr(t, e, n) {
|
|
|
5525
5532
|
* their `set()` or fails due to invalid data originating from a `toFirestore()`
|
|
5526
5533
|
* call.
|
|
5527
5534
|
*/
|
|
5528
|
-
function
|
|
5535
|
+
function Dr(t, e, n) {
|
|
5529
5536
|
let r;
|
|
5530
5537
|
// Cast to `any` in order to satisfy the union type constraint on
|
|
5531
5538
|
// toFirestore().
|
|
@@ -5534,9 +5541,9 @@ function $r(t, e, n) {
|
|
|
5534
5541
|
r;
|
|
5535
5542
|
}
|
|
5536
5543
|
|
|
5537
|
-
class
|
|
5544
|
+
class xr extends class {
|
|
5538
5545
|
convertValue(t, e = "none") {
|
|
5539
|
-
switch (
|
|
5546
|
+
switch (jt(t)) {
|
|
5540
5547
|
case 0 /* NullValue */ :
|
|
5541
5548
|
return null;
|
|
5542
5549
|
|
|
@@ -5544,7 +5551,7 @@ class Dr extends class {
|
|
|
5544
5551
|
return t.booleanValue;
|
|
5545
5552
|
|
|
5546
5553
|
case 2 /* NumberValue */ :
|
|
5547
|
-
return
|
|
5554
|
+
return Ot(t.integerValue || t.doubleValue);
|
|
5548
5555
|
|
|
5549
5556
|
case 3 /* TimestampValue */ :
|
|
5550
5557
|
return this.convertTimestamp(t.timestampValue);
|
|
@@ -5556,7 +5563,7 @@ class Dr extends class {
|
|
|
5556
5563
|
return t.stringValue;
|
|
5557
5564
|
|
|
5558
5565
|
case 6 /* BlobValue */ :
|
|
5559
|
-
return this.convertBytes(
|
|
5566
|
+
return this.convertBytes(kt(t.bytesValue));
|
|
5560
5567
|
|
|
5561
5568
|
case 7 /* RefValue */ :
|
|
5562
5569
|
return this.convertReference(t.referenceValue);
|
|
@@ -5571,17 +5578,17 @@ class Dr extends class {
|
|
|
5571
5578
|
return this.convertObject(t.mapValue, e);
|
|
5572
5579
|
|
|
5573
5580
|
default:
|
|
5574
|
-
throw
|
|
5581
|
+
throw E();
|
|
5575
5582
|
}
|
|
5576
5583
|
}
|
|
5577
5584
|
convertObject(t, e) {
|
|
5578
5585
|
const n = {};
|
|
5579
|
-
return
|
|
5586
|
+
return At(t.fields, ((t, r) => {
|
|
5580
5587
|
n[t] = this.convertValue(r, e);
|
|
5581
5588
|
})), n;
|
|
5582
5589
|
}
|
|
5583
5590
|
convertGeoPoint(t) {
|
|
5584
|
-
return new
|
|
5591
|
+
return new Fn(Ot(t.latitude), Ot(t.longitude));
|
|
5585
5592
|
}
|
|
5586
5593
|
convertArray(t, e) {
|
|
5587
5594
|
return (t.values || []).map((t => this.convertValue(t, e)));
|
|
@@ -5589,27 +5596,27 @@ class Dr extends class {
|
|
|
5589
5596
|
convertServerTimestamp(t, e) {
|
|
5590
5597
|
switch (e) {
|
|
5591
5598
|
case "previous":
|
|
5592
|
-
const n =
|
|
5599
|
+
const n = Lt(t);
|
|
5593
5600
|
return null == n ? null : this.convertValue(n, e);
|
|
5594
5601
|
|
|
5595
5602
|
case "estimate":
|
|
5596
|
-
return this.convertTimestamp(
|
|
5603
|
+
return this.convertTimestamp(Mt(t));
|
|
5597
5604
|
|
|
5598
5605
|
default:
|
|
5599
5606
|
return null;
|
|
5600
5607
|
}
|
|
5601
5608
|
}
|
|
5602
5609
|
convertTimestamp(t) {
|
|
5603
|
-
const e =
|
|
5604
|
-
return new
|
|
5610
|
+
const e = qt(t);
|
|
5611
|
+
return new Et(e.seconds, e.nanos);
|
|
5605
5612
|
}
|
|
5606
5613
|
convertDocumentKey(t, e) {
|
|
5607
|
-
const n =
|
|
5608
|
-
|
|
5609
|
-
const r = new
|
|
5614
|
+
const n = et.fromString(t);
|
|
5615
|
+
I(nn(n));
|
|
5616
|
+
const r = new Z(n.get(1), n.get(3)), s = new st(n.popFirst(5));
|
|
5610
5617
|
return r.isEqual(e) ||
|
|
5611
5618
|
// TODO(b/64130202): Somehow support foreign references.
|
|
5612
|
-
|
|
5619
|
+
_(`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.`),
|
|
5613
5620
|
s;
|
|
5614
5621
|
}
|
|
5615
5622
|
} {
|
|
@@ -5617,11 +5624,11 @@ class Dr extends class {
|
|
|
5617
5624
|
super(), this.firestore = t;
|
|
5618
5625
|
}
|
|
5619
5626
|
convertBytes(t) {
|
|
5620
|
-
return new
|
|
5627
|
+
return new $n(t);
|
|
5621
5628
|
}
|
|
5622
5629
|
convertReference(t) {
|
|
5623
5630
|
const e = this.convertDocumentKey(t, this.firestore._databaseId);
|
|
5624
|
-
return new
|
|
5631
|
+
return new En(this.firestore, /* converter= */ null, e);
|
|
5625
5632
|
}
|
|
5626
5633
|
}
|
|
5627
5634
|
|
|
@@ -5637,12 +5644,12 @@ class Dr extends class {
|
|
|
5637
5644
|
* @param reference - The reference of the document to fetch.
|
|
5638
5645
|
* @returns A Promise resolved with a `DocumentSnapshot` containing the current
|
|
5639
5646
|
* document contents.
|
|
5640
|
-
*/ function
|
|
5641
|
-
const e =
|
|
5642
|
-
return
|
|
5643
|
-
|
|
5647
|
+
*/ function Sr(t) {
|
|
5648
|
+
const e = fn((t = at(t, En)).firestore), n = new xr(t.firestore);
|
|
5649
|
+
return cn(e, [ t._key ]).then((e => {
|
|
5650
|
+
I(1 === e.length);
|
|
5644
5651
|
const r = e[0];
|
|
5645
|
-
return new
|
|
5652
|
+
return new ur(t.firestore, n, t._key, r.isFoundDocument() ? r : null, t.converter);
|
|
5646
5653
|
}));
|
|
5647
5654
|
}
|
|
5648
5655
|
|
|
@@ -5657,33 +5664,33 @@ class Dr extends class {
|
|
|
5657
5664
|
*
|
|
5658
5665
|
* @param query - The `Query` to execute.
|
|
5659
5666
|
* @returns A Promise that will be resolved with the results of the query.
|
|
5660
|
-
*/ function
|
|
5667
|
+
*/ function Fr(t) {
|
|
5661
5668
|
!function(t) {
|
|
5662
|
-
if ("L" /* Last */ === t.limitType && 0 === t.explicitOrderBy.length) throw new
|
|
5663
|
-
}((t =
|
|
5664
|
-
const e =
|
|
5665
|
-
return
|
|
5666
|
-
const r = e.map((e => new
|
|
5669
|
+
if ("L" /* Last */ === t.limitType && 0 === t.explicitOrderBy.length) throw new j(C, "limitToLast() queries require specifying at least one orderBy() clause");
|
|
5670
|
+
}((t = at(t, In))._query);
|
|
5671
|
+
const e = fn(t.firestore), n = new xr(t.firestore);
|
|
5672
|
+
return an(e, t._query).then((e => {
|
|
5673
|
+
const r = e.map((e => new cr(t.firestore, n, e.key, e, t.converter)));
|
|
5667
5674
|
return "L" /* Last */ === t._query.limitType &&
|
|
5668
5675
|
// Limit to last queries reverse the orderBy constraint that was
|
|
5669
5676
|
// specified by the user. As such, we need to reverse the order of the
|
|
5670
5677
|
// results to return the documents in the expected order.
|
|
5671
|
-
r.reverse(), new
|
|
5678
|
+
r.reverse(), new ar(t, r);
|
|
5672
5679
|
}));
|
|
5673
5680
|
}
|
|
5674
5681
|
|
|
5675
|
-
function
|
|
5676
|
-
const r =
|
|
5677
|
-
return
|
|
5682
|
+
function qr(t, e, n) {
|
|
5683
|
+
const r = Dr((t = at(t, En)).converter, e, n), s = jn(Un(t.firestore), "setDoc", t._key, r, null !== t.converter, n);
|
|
5684
|
+
return un(fn(t.firestore), [ s.toMutation(t._key, $e.none()) ]);
|
|
5678
5685
|
}
|
|
5679
5686
|
|
|
5680
|
-
function
|
|
5681
|
-
const s =
|
|
5687
|
+
function Or(t, e, n, ...r) {
|
|
5688
|
+
const s = Un((t = at(t, En)).firestore);
|
|
5682
5689
|
// For Compat types, we have to "extract" the underlying types before
|
|
5683
5690
|
// performing validation.
|
|
5684
5691
|
let i;
|
|
5685
|
-
i = "string" == typeof (e =
|
|
5686
|
-
return
|
|
5692
|
+
i = "string" == typeof (e = f(e)) || e instanceof Dn ? Hn(s, "updateDoc", t._key, e, n, r) : Yn(s, "updateDoc", t._key, e);
|
|
5693
|
+
return un(fn(t.firestore), [ i.toMutation(t._key, $e.exists(!0)) ]);
|
|
5687
5694
|
}
|
|
5688
5695
|
|
|
5689
5696
|
/**
|
|
@@ -5697,8 +5704,8 @@ function qr(t, e, n, ...r) {
|
|
|
5697
5704
|
* @param reference - A reference to the document to delete.
|
|
5698
5705
|
* @returns A `Promise` resolved once the document has been successfully
|
|
5699
5706
|
* deleted from the backend.
|
|
5700
|
-
*/ function
|
|
5701
|
-
return
|
|
5707
|
+
*/ function kr(t) {
|
|
5708
|
+
return un(fn((t = at(t, En)).firestore), [ new Fe(t._key, $e.none()) ]);
|
|
5702
5709
|
}
|
|
5703
5710
|
|
|
5704
5711
|
/**
|
|
@@ -5715,9 +5722,9 @@ function qr(t, e, n, ...r) {
|
|
|
5715
5722
|
* @throws Error - If the provided input is not a valid Firestore document.
|
|
5716
5723
|
* @returns A `Promise` resolved with a `DocumentReference` pointing to the
|
|
5717
5724
|
* newly created document after it has been written to the backend.
|
|
5718
|
-
*/ function
|
|
5719
|
-
const n =
|
|
5720
|
-
return
|
|
5725
|
+
*/ function Cr(t, e) {
|
|
5726
|
+
const n = Pn(t = at(t, Tn)), r = Dr(t.converter, e), s = jn(Un(t.firestore), "addDoc", n._key, r, null !== n.converter, {});
|
|
5727
|
+
return un(fn(t.firestore), [ s.toMutation(n._key, $e.exists(!1)) ]).then((() => n));
|
|
5721
5728
|
}
|
|
5722
5729
|
|
|
5723
5730
|
/**
|
|
@@ -5749,9 +5756,9 @@ function qr(t, e, n, ...r) {
|
|
|
5749
5756
|
* @returns A Promise that will be resolved with the count; the count can be
|
|
5750
5757
|
* retrieved from `snapshot.data().count`, where `snapshot` is the
|
|
5751
5758
|
* `AggregateQuerySnapshot` to which the returned Promise resolves.
|
|
5752
|
-
*/ function
|
|
5753
|
-
const e =
|
|
5754
|
-
return new
|
|
5759
|
+
*/ function Lr(t) {
|
|
5760
|
+
const e = at(t.firestore, wn), n = fn(e), r = new xr(e);
|
|
5761
|
+
return new bn(t, n, r).run();
|
|
5755
5762
|
}
|
|
5756
5763
|
|
|
5757
5764
|
/**
|
|
@@ -5765,8 +5772,8 @@ function qr(t, e, n, ...r) {
|
|
|
5765
5772
|
*
|
|
5766
5773
|
* @returns `true` if the objects are "equal", as defined above, or `false`
|
|
5767
5774
|
* otherwise.
|
|
5768
|
-
*/ function
|
|
5769
|
-
return
|
|
5775
|
+
*/ function Mr(t, e) {
|
|
5776
|
+
return Nn(t.query, e.query) && d(t.data(), e.data());
|
|
5770
5777
|
}
|
|
5771
5778
|
|
|
5772
5779
|
/**
|
|
@@ -5788,15 +5795,15 @@ function qr(t, e, n, ...r) {
|
|
|
5788
5795
|
/**
|
|
5789
5796
|
* Returns a sentinel for use with {@link @firebase/firestore/lite#(updateDoc:1)} or
|
|
5790
5797
|
* {@link @firebase/firestore/lite#(setDoc:1)} with `{merge: true}` to mark a field for deletion.
|
|
5791
|
-
*/ function
|
|
5792
|
-
return new
|
|
5798
|
+
*/ function Ur() {
|
|
5799
|
+
return new Bn("deleteField");
|
|
5793
5800
|
}
|
|
5794
5801
|
|
|
5795
5802
|
/**
|
|
5796
5803
|
* Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
|
|
5797
5804
|
* include a server-generated timestamp in the written data.
|
|
5798
|
-
*/ function
|
|
5799
|
-
return new
|
|
5805
|
+
*/ function jr() {
|
|
5806
|
+
return new zn("serverTimestamp");
|
|
5800
5807
|
}
|
|
5801
5808
|
|
|
5802
5809
|
/**
|
|
@@ -5810,10 +5817,10 @@ function qr(t, e, n, ...r) {
|
|
|
5810
5817
|
* @param elements - The elements to union into the array.
|
|
5811
5818
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5812
5819
|
* `updateDoc()`.
|
|
5813
|
-
*/ function
|
|
5820
|
+
*/ function Br(...t) {
|
|
5814
5821
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5815
5822
|
// update() since we'd need the Firestore instance to do this.
|
|
5816
|
-
return new
|
|
5823
|
+
return new Wn("arrayUnion", t);
|
|
5817
5824
|
}
|
|
5818
5825
|
|
|
5819
5826
|
/**
|
|
@@ -5826,10 +5833,10 @@ function qr(t, e, n, ...r) {
|
|
|
5826
5833
|
* @param elements - The elements to remove from the array.
|
|
5827
5834
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5828
5835
|
* `updateDoc()`
|
|
5829
|
-
*/ function
|
|
5836
|
+
*/ function Qr(...t) {
|
|
5830
5837
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5831
5838
|
// update() since we'd need the Firestore instance to do this.
|
|
5832
|
-
return new
|
|
5839
|
+
return new Gn("arrayRemove", t);
|
|
5833
5840
|
}
|
|
5834
5841
|
|
|
5835
5842
|
/**
|
|
@@ -5850,8 +5857,8 @@ function qr(t, e, n, ...r) {
|
|
|
5850
5857
|
* @param n - The value to increment by.
|
|
5851
5858
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5852
5859
|
* `updateDoc()`
|
|
5853
|
-
*/ function
|
|
5854
|
-
return new
|
|
5860
|
+
*/ function zr(t) {
|
|
5861
|
+
return new Kn("increment", t);
|
|
5855
5862
|
}
|
|
5856
5863
|
|
|
5857
5864
|
/**
|
|
@@ -5877,25 +5884,25 @@ function qr(t, e, n, ...r) {
|
|
|
5877
5884
|
* provides methods for adding writes to the write batch. None of the writes
|
|
5878
5885
|
* will be committed (or visible locally) until {@link WriteBatch.commit} is
|
|
5879
5886
|
* called.
|
|
5880
|
-
*/ class
|
|
5887
|
+
*/ class Wr {
|
|
5881
5888
|
/** @hideconstructor */
|
|
5882
5889
|
constructor(t, e) {
|
|
5883
5890
|
this._firestore = t, this._commitHandler = e, this._mutations = [], this._committed = !1,
|
|
5884
|
-
this._dataReader =
|
|
5891
|
+
this._dataReader = Un(t);
|
|
5885
5892
|
}
|
|
5886
5893
|
set(t, e, n) {
|
|
5887
5894
|
this._verifyNotCommitted();
|
|
5888
|
-
const r =
|
|
5889
|
-
return this._mutations.push(i.toMutation(r._key,
|
|
5895
|
+
const r = Gr(t, this._firestore), s = Dr(r.converter, e, n), i = jn(this._dataReader, "WriteBatch.set", r._key, s, null !== r.converter, n);
|
|
5896
|
+
return this._mutations.push(i.toMutation(r._key, $e.none())), this;
|
|
5890
5897
|
}
|
|
5891
5898
|
update(t, e, n, ...r) {
|
|
5892
5899
|
this._verifyNotCommitted();
|
|
5893
|
-
const s =
|
|
5900
|
+
const s = Gr(t, this._firestore);
|
|
5894
5901
|
// For Compat types, we have to "extract" the underlying types before
|
|
5895
5902
|
// performing validation.
|
|
5896
5903
|
let i;
|
|
5897
|
-
return i = "string" == typeof (e =
|
|
5898
|
-
this._mutations.push(i.toMutation(s._key,
|
|
5904
|
+
return i = "string" == typeof (e = f(e)) || e instanceof Dn ? Hn(this._dataReader, "WriteBatch.update", s._key, e, n, r) : Yn(this._dataReader, "WriteBatch.update", s._key, e),
|
|
5905
|
+
this._mutations.push(i.toMutation(s._key, $e.exists(!0))), this;
|
|
5899
5906
|
}
|
|
5900
5907
|
/**
|
|
5901
5908
|
* Deletes the document referred to by the provided {@link DocumentReference}.
|
|
@@ -5904,8 +5911,8 @@ function qr(t, e, n, ...r) {
|
|
|
5904
5911
|
* @returns This `WriteBatch` instance. Used for chaining method calls.
|
|
5905
5912
|
*/ delete(t) {
|
|
5906
5913
|
this._verifyNotCommitted();
|
|
5907
|
-
const e =
|
|
5908
|
-
return this._mutations = this._mutations.concat(new
|
|
5914
|
+
const e = Gr(t, this._firestore);
|
|
5915
|
+
return this._mutations = this._mutations.concat(new Fe(e._key, $e.none())), this;
|
|
5909
5916
|
}
|
|
5910
5917
|
/**
|
|
5911
5918
|
* Commits all of the writes in this write batch as a single atomic unit.
|
|
@@ -5922,12 +5929,12 @@ function qr(t, e, n, ...r) {
|
|
|
5922
5929
|
return this._verifyNotCommitted(), this._committed = !0, this._mutations.length > 0 ? this._commitHandler(this._mutations) : Promise.resolve();
|
|
5923
5930
|
}
|
|
5924
5931
|
_verifyNotCommitted() {
|
|
5925
|
-
if (this._committed) throw new
|
|
5932
|
+
if (this._committed) throw new j(q, "A write batch can no longer be used after commit() has been called.");
|
|
5926
5933
|
}
|
|
5927
5934
|
}
|
|
5928
5935
|
|
|
5929
|
-
function
|
|
5930
|
-
if ((t =
|
|
5936
|
+
function Gr(t, e) {
|
|
5937
|
+
if ((t = f(t)).firestore !== e) throw new j(V, "Provided document reference is from a different Firestore instance.");
|
|
5931
5938
|
return t;
|
|
5932
5939
|
}
|
|
5933
5940
|
|
|
@@ -5943,9 +5950,9 @@ function Wr(t, e) {
|
|
|
5943
5950
|
*
|
|
5944
5951
|
* @returns A `WriteBatch` that can be used to atomically execute multiple
|
|
5945
5952
|
* writes.
|
|
5946
|
-
*/ function
|
|
5947
|
-
const e =
|
|
5948
|
-
return new
|
|
5953
|
+
*/ function Kr(t) {
|
|
5954
|
+
const e = fn(t = at(t, wn));
|
|
5955
|
+
return new Wr(t, (t => un(e, t)));
|
|
5949
5956
|
}
|
|
5950
5957
|
|
|
5951
5958
|
/**
|
|
@@ -5967,7 +5974,7 @@ function Wr(t, e) {
|
|
|
5967
5974
|
/**
|
|
5968
5975
|
* Internal transaction object responsible for accumulating the mutations to
|
|
5969
5976
|
* perform and the base versions for any documents read.
|
|
5970
|
-
*/ class
|
|
5977
|
+
*/ class Yr {
|
|
5971
5978
|
constructor(t) {
|
|
5972
5979
|
this.datastore = t,
|
|
5973
5980
|
// The version of each document that was read during this transaction.
|
|
@@ -5986,8 +5993,8 @@ function Wr(t, e) {
|
|
|
5986
5993
|
this.writtenDocs = new Set;
|
|
5987
5994
|
}
|
|
5988
5995
|
async lookup(t) {
|
|
5989
|
-
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new
|
|
5990
|
-
const e = await
|
|
5996
|
+
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new j(V, "Firestore transactions require all reads to be executed before all writes.");
|
|
5997
|
+
const e = await cn(this.datastore, t);
|
|
5991
5998
|
return e.forEach((t => this.recordVersion(t))), e;
|
|
5992
5999
|
}
|
|
5993
6000
|
set(t, e) {
|
|
@@ -6002,7 +6009,7 @@ function Wr(t, e) {
|
|
|
6002
6009
|
this.writtenDocs.add(t.toString());
|
|
6003
6010
|
}
|
|
6004
6011
|
delete(t) {
|
|
6005
|
-
this.write(new
|
|
6012
|
+
this.write(new Fe(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
6006
6013
|
}
|
|
6007
6014
|
async commit() {
|
|
6008
6015
|
if (this.ensureCommitNotCalled(), this.lastWriteError) throw this.lastWriteError;
|
|
@@ -6014,22 +6021,22 @@ function Wr(t, e) {
|
|
|
6014
6021
|
// For each document that was read but not written to, we want to perform
|
|
6015
6022
|
// a `verify` operation.
|
|
6016
6023
|
t.forEach(((t, e) => {
|
|
6017
|
-
const n =
|
|
6018
|
-
this.mutations.push(new
|
|
6019
|
-
})), await
|
|
6024
|
+
const n = st.fromPath(e);
|
|
6025
|
+
this.mutations.push(new qe(n, this.precondition(n)));
|
|
6026
|
+
})), await un(this.datastore, this.mutations), this.committed = !0;
|
|
6020
6027
|
}
|
|
6021
6028
|
recordVersion(t) {
|
|
6022
6029
|
let e;
|
|
6023
6030
|
if (t.isFoundDocument()) e = t.version; else {
|
|
6024
|
-
if (!t.isNoDocument()) throw
|
|
6031
|
+
if (!t.isNoDocument()) throw E();
|
|
6025
6032
|
// Represent a deleted doc using SnapshotVersion.min().
|
|
6026
|
-
e =
|
|
6033
|
+
e = It.min();
|
|
6027
6034
|
}
|
|
6028
6035
|
const n = this.readVersions.get(t.key.toString());
|
|
6029
6036
|
if (n) {
|
|
6030
6037
|
if (!e.isEqual(n))
|
|
6031
6038
|
// This transaction will fail no matter what.
|
|
6032
|
-
throw new
|
|
6039
|
+
throw new j(O, "Document version changed between two reads.");
|
|
6033
6040
|
} else this.readVersions.set(t.key.toString(), e);
|
|
6034
6041
|
}
|
|
6035
6042
|
/**
|
|
@@ -6037,7 +6044,7 @@ function Wr(t, e) {
|
|
|
6037
6044
|
* as a precondition, or no precondition if it was not read.
|
|
6038
6045
|
*/ precondition(t) {
|
|
6039
6046
|
const e = this.readVersions.get(t.toString());
|
|
6040
|
-
return !this.writtenDocs.has(t.toString()) && e ? e.isEqual(
|
|
6047
|
+
return !this.writtenDocs.has(t.toString()) && e ? e.isEqual(It.min()) ? $e.exists(!1) : $e.updateTime(e) : $e.none();
|
|
6041
6048
|
}
|
|
6042
6049
|
/**
|
|
6043
6050
|
* Returns the precondition for a document if the operation is an update.
|
|
@@ -6046,7 +6053,7 @@ function Wr(t, e) {
|
|
|
6046
6053
|
// The first time a document is written, we want to take into account the
|
|
6047
6054
|
// read time and existence
|
|
6048
6055
|
if (!this.writtenDocs.has(t.toString()) && e) {
|
|
6049
|
-
if (e.isEqual(
|
|
6056
|
+
if (e.isEqual(It.min()))
|
|
6050
6057
|
// The document doesn't exist, so fail the transaction.
|
|
6051
6058
|
// This has to be validated locally because you can't send a
|
|
6052
6059
|
// precondition that a document does not exist without changing the
|
|
@@ -6056,13 +6063,13 @@ function Wr(t, e) {
|
|
|
6056
6063
|
// express that to the backend, we have to validate locally.
|
|
6057
6064
|
// Note: this can change once we can send separate verify writes in the
|
|
6058
6065
|
// transaction.
|
|
6059
|
-
throw new
|
|
6066
|
+
throw new j(V, "Can't update a document that doesn't exist.");
|
|
6060
6067
|
// Document exists, base precondition on document update time.
|
|
6061
|
-
return
|
|
6068
|
+
return $e.updateTime(e);
|
|
6062
6069
|
}
|
|
6063
6070
|
// Document was not read, so we just use the preconditions for a blind
|
|
6064
6071
|
// update.
|
|
6065
|
-
return
|
|
6072
|
+
return $e.exists(!0);
|
|
6066
6073
|
}
|
|
6067
6074
|
write(t) {
|
|
6068
6075
|
this.ensureCommitNotCalled(), this.mutations.push(t);
|
|
@@ -6085,7 +6092,7 @@ function Wr(t, e) {
|
|
|
6085
6092
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6086
6093
|
* See the License for the specific language governing permissions and
|
|
6087
6094
|
* limitations under the License.
|
|
6088
|
-
*/ const
|
|
6095
|
+
*/ const Hr = {
|
|
6089
6096
|
maxAttempts: 5
|
|
6090
6097
|
};
|
|
6091
6098
|
|
|
@@ -6109,17 +6116,17 @@ function Wr(t, e) {
|
|
|
6109
6116
|
* TransactionRunner encapsulates the logic needed to run and retry transactions
|
|
6110
6117
|
* with backoff.
|
|
6111
6118
|
*/
|
|
6112
|
-
class
|
|
6119
|
+
class Jr {
|
|
6113
6120
|
constructor(t, e, n, r, s) {
|
|
6114
6121
|
this.asyncQueue = t, this.datastore = e, this.options = n, this.updateFunction = r,
|
|
6115
|
-
this.deferred = s, this.Pt = n.maxAttempts, this.Vt = new
|
|
6122
|
+
this.deferred = s, this.Pt = n.maxAttempts, this.Vt = new sn(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
|
|
6116
6123
|
}
|
|
6117
6124
|
/** Runs the transaction and sets the result on deferred. */ run() {
|
|
6118
6125
|
this.Pt -= 1, this.Nt();
|
|
6119
6126
|
}
|
|
6120
6127
|
Nt() {
|
|
6121
6128
|
this.Vt.J((async () => {
|
|
6122
|
-
const t = new
|
|
6129
|
+
const t = new Yr(this.datastore), e = this.$t(t);
|
|
6123
6130
|
e && e.then((e => {
|
|
6124
6131
|
this.asyncQueue.enqueueAndForget((() => t.commit().then((() => {
|
|
6125
6132
|
this.deferred.resolve(e);
|
|
@@ -6134,7 +6141,7 @@ class Hr {
|
|
|
6134
6141
|
$t(t) {
|
|
6135
6142
|
try {
|
|
6136
6143
|
const e = this.updateFunction(t);
|
|
6137
|
-
return !
|
|
6144
|
+
return !lt(e) && e.catch && e.then ? e : (this.deferred.reject(Error("Transaction callback must return a Promise")),
|
|
6138
6145
|
null);
|
|
6139
6146
|
} catch (t) {
|
|
6140
6147
|
// Do not retry errors thrown by user provided updateFunction.
|
|
@@ -6160,31 +6167,31 @@ class Hr {
|
|
|
6160
6167
|
function(t) {
|
|
6161
6168
|
switch (t) {
|
|
6162
6169
|
default:
|
|
6163
|
-
return
|
|
6170
|
+
return E();
|
|
6164
6171
|
|
|
6165
|
-
case A:
|
|
6166
6172
|
case R:
|
|
6167
|
-
case
|
|
6168
|
-
case
|
|
6169
|
-
case
|
|
6173
|
+
case P:
|
|
6174
|
+
case N:
|
|
6175
|
+
case F:
|
|
6170
6176
|
case L:
|
|
6177
|
+
case M:
|
|
6171
6178
|
// Unauthenticated means something went wrong with our token and we need
|
|
6172
6179
|
// to retry with new credentials which will happen automatically.
|
|
6173
|
-
case
|
|
6180
|
+
case S:
|
|
6174
6181
|
return !1;
|
|
6175
6182
|
|
|
6176
|
-
case
|
|
6177
|
-
case N:
|
|
6183
|
+
case V:
|
|
6178
6184
|
case $:
|
|
6179
6185
|
case D:
|
|
6180
|
-
case
|
|
6186
|
+
case x:
|
|
6187
|
+
case q:
|
|
6181
6188
|
// Aborted might be retried in some scenarios, but that is dependant on
|
|
6182
6189
|
// the context and should handled individually by the calling code.
|
|
6183
6190
|
// See https://cloud.google.com/apis/design/errors.
|
|
6184
|
-
case
|
|
6185
|
-
case O:
|
|
6191
|
+
case O:
|
|
6186
6192
|
case k:
|
|
6187
|
-
case
|
|
6193
|
+
case C:
|
|
6194
|
+
case U:
|
|
6188
6195
|
return !0;
|
|
6189
6196
|
}
|
|
6190
6197
|
}(e);
|
|
@@ -6209,7 +6216,7 @@ class Hr {
|
|
|
6209
6216
|
* See the License for the specific language governing permissions and
|
|
6210
6217
|
* limitations under the License.
|
|
6211
6218
|
*/
|
|
6212
|
-
/** The Platform's 'document' implementation or null if not available. */ function
|
|
6219
|
+
/** The Platform's 'document' implementation or null if not available. */ function Xr() {
|
|
6213
6220
|
// `document` is not always available, e.g. in ReactNative and WebWorkers.
|
|
6214
6221
|
// eslint-disable-next-line no-restricted-globals
|
|
6215
6222
|
return "undefined" != typeof document ? document : null;
|
|
@@ -6241,10 +6248,10 @@ class Hr {
|
|
|
6241
6248
|
* Note: We implement `PromiseLike` instead of `Promise`, as the `Promise` type
|
|
6242
6249
|
* in newer versions of TypeScript defines `finally`, which is not available in
|
|
6243
6250
|
* IE.
|
|
6244
|
-
*/ class
|
|
6251
|
+
*/ class Zr {
|
|
6245
6252
|
constructor(t, e, n, r, s) {
|
|
6246
6253
|
this.asyncQueue = t, this.timerId = e, this.targetTimeMs = n, this.op = r, this.removalCallback = s,
|
|
6247
|
-
this.deferred = new
|
|
6254
|
+
this.deferred = new B, this.then = this.deferred.promise.then.bind(this.deferred.promise),
|
|
6248
6255
|
// It's normal for the deferred promise to be canceled (due to cancellation)
|
|
6249
6256
|
// and so we attach a dummy catch callback to avoid
|
|
6250
6257
|
// 'UnhandledPromiseRejectionWarning' log spam.
|
|
@@ -6264,7 +6271,7 @@ class Hr {
|
|
|
6264
6271
|
* PORTING NOTE: This exists to prevent making removeDelayedOperation() and
|
|
6265
6272
|
* the DelayedOperation class public.
|
|
6266
6273
|
*/ static createAndSchedule(t, e, n, r, s) {
|
|
6267
|
-
const i = Date.now() + n, o = new
|
|
6274
|
+
const i = Date.now() + n, o = new Zr(t, e, i, r, s);
|
|
6268
6275
|
return o.start(n), o;
|
|
6269
6276
|
}
|
|
6270
6277
|
/**
|
|
@@ -6286,7 +6293,7 @@ class Hr {
|
|
|
6286
6293
|
* As long as the operation has not yet been run, calling cancel() provides a
|
|
6287
6294
|
* guarantee that the operation will not be run.
|
|
6288
6295
|
*/ cancel(t) {
|
|
6289
|
-
null !== this.timerHandle && (this.clearTimeout(), this.deferred.reject(new
|
|
6296
|
+
null !== this.timerHandle && (this.clearTimeout(), this.deferred.reject(new j(R, "Operation cancelled" + (t ? ": " + t : ""))));
|
|
6290
6297
|
}
|
|
6291
6298
|
handleDelayElapsed() {
|
|
6292
6299
|
this.asyncQueue.enqueueAndForget((() => null !== this.timerHandle ? (this.clearTimeout(),
|
|
@@ -6313,7 +6320,7 @@ class Hr {
|
|
|
6313
6320
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6314
6321
|
* See the License for the specific language governing permissions and
|
|
6315
6322
|
* limitations under the License.
|
|
6316
|
-
*/ class
|
|
6323
|
+
*/ class ts {
|
|
6317
6324
|
constructor() {
|
|
6318
6325
|
// The last promise in the queue.
|
|
6319
6326
|
this.St = Promise.resolve(),
|
|
@@ -6336,15 +6343,15 @@ class Hr {
|
|
|
6336
6343
|
// List of TimerIds to fast-forward delays for.
|
|
6337
6344
|
this.Mt = [],
|
|
6338
6345
|
// Backoff timer used to schedule retries for retryable operations
|
|
6339
|
-
this.Vt = new
|
|
6346
|
+
this.Vt = new sn(this, "async_queue_retry" /* AsyncQueueRetry */),
|
|
6340
6347
|
// Visibility handler that triggers an immediate retry of all retryable
|
|
6341
6348
|
// operations. Meant to speed up recovery when we regain file system access
|
|
6342
6349
|
// after page comes into foreground.
|
|
6343
6350
|
this.Ut = () => {
|
|
6344
|
-
const t =
|
|
6345
|
-
t &&
|
|
6351
|
+
const t = Xr();
|
|
6352
|
+
t && g("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.Vt.Z();
|
|
6346
6353
|
};
|
|
6347
|
-
const t =
|
|
6354
|
+
const t = Xr();
|
|
6348
6355
|
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.Ut);
|
|
6349
6356
|
}
|
|
6350
6357
|
get isShuttingDown() {
|
|
@@ -6365,7 +6372,7 @@ class Hr {
|
|
|
6365
6372
|
enterRestrictedMode(t) {
|
|
6366
6373
|
if (!this.qt) {
|
|
6367
6374
|
this.qt = !0, this.Lt = t || !1;
|
|
6368
|
-
const e =
|
|
6375
|
+
const e = Xr();
|
|
6369
6376
|
e && "function" == typeof e.removeEventListener && e.removeEventListener("visibilitychange", this.Ut);
|
|
6370
6377
|
}
|
|
6371
6378
|
}
|
|
@@ -6376,7 +6383,7 @@ class Hr {
|
|
|
6376
6383
|
// Create a deferred Promise that we can return to the callee. This
|
|
6377
6384
|
// allows us to return a "hanging Promise" only to the callee and still
|
|
6378
6385
|
// advance the queue even when the operation is not run.
|
|
6379
|
-
const e = new
|
|
6386
|
+
const e = new B;
|
|
6380
6387
|
return this.Bt((() => this.qt && this.Lt ? Promise.resolve() : (t().then(e.resolve, e.reject),
|
|
6381
6388
|
e.promise))).then((() => e.promise));
|
|
6382
6389
|
}
|
|
@@ -6431,7 +6438,7 @@ class Hr {
|
|
|
6431
6438
|
* limitations under the License.
|
|
6432
6439
|
*/ (t)) throw t;
|
|
6433
6440
|
// Failure will be handled by AsyncQueue
|
|
6434
|
-
|
|
6441
|
+
g("AsyncQueue", "Operation failed with retryable error: " + t);
|
|
6435
6442
|
}
|
|
6436
6443
|
this.Ft.length > 0 &&
|
|
6437
6444
|
// If there are additional operations, we re-schedule `retryNextOp()`.
|
|
@@ -6489,7 +6496,7 @@ class Hr {
|
|
|
6489
6496
|
// Re-throw the error so that this.tail becomes a rejected Promise and
|
|
6490
6497
|
// all further attempts to chain (via .then) will just short-circuit
|
|
6491
6498
|
// and return the rejected Promise.
|
|
6492
|
-
throw
|
|
6499
|
+
throw _("INTERNAL UNHANDLED ERROR: ", e), t;
|
|
6493
6500
|
})).then((t => (this.Ct = !1, t))))));
|
|
6494
6501
|
return this.St = e, e;
|
|
6495
6502
|
}
|
|
@@ -6497,11 +6504,11 @@ class Hr {
|
|
|
6497
6504
|
this.jt(),
|
|
6498
6505
|
// Fast-forward delays for timerIds that have been overriden.
|
|
6499
6506
|
this.Mt.indexOf(t) > -1 && (e = 0);
|
|
6500
|
-
const r =
|
|
6507
|
+
const r = Zr.createAndSchedule(this, t, e, n, (t => this.zt(t)));
|
|
6501
6508
|
return this.Ot.push(r), r;
|
|
6502
6509
|
}
|
|
6503
6510
|
jt() {
|
|
6504
|
-
this.kt &&
|
|
6511
|
+
this.kt && E();
|
|
6505
6512
|
}
|
|
6506
6513
|
verifyOperationInProgress() {}
|
|
6507
6514
|
/**
|
|
@@ -6551,10 +6558,10 @@ class Hr {
|
|
|
6551
6558
|
}
|
|
6552
6559
|
}
|
|
6553
6560
|
|
|
6554
|
-
class
|
|
6561
|
+
class es {
|
|
6555
6562
|
/** @hideconstructor */
|
|
6556
6563
|
constructor(t, e) {
|
|
6557
|
-
this._firestore = t, this._transaction = e, this._dataReader =
|
|
6564
|
+
this._firestore = t, this._transaction = e, this._dataReader = Un(t);
|
|
6558
6565
|
}
|
|
6559
6566
|
/**
|
|
6560
6567
|
* Reads the document referenced by the provided {@link DocumentReference}.
|
|
@@ -6562,25 +6569,25 @@ class ts {
|
|
|
6562
6569
|
* @param documentRef - A reference to the document to be read.
|
|
6563
6570
|
* @returns A `DocumentSnapshot` with the read data.
|
|
6564
6571
|
*/ get(t) {
|
|
6565
|
-
const e =
|
|
6572
|
+
const e = Gr(t, this._firestore), n = new xr(this._firestore);
|
|
6566
6573
|
return this._transaction.lookup([ e._key ]).then((t => {
|
|
6567
|
-
if (!t || 1 !== t.length) return
|
|
6574
|
+
if (!t || 1 !== t.length) return E();
|
|
6568
6575
|
const r = t[0];
|
|
6569
|
-
if (r.isFoundDocument()) return new
|
|
6570
|
-
if (r.isNoDocument()) return new
|
|
6571
|
-
throw
|
|
6576
|
+
if (r.isFoundDocument()) return new ur(this._firestore, n, r.key, r, e.converter);
|
|
6577
|
+
if (r.isNoDocument()) return new ur(this._firestore, n, e._key, null, e.converter);
|
|
6578
|
+
throw E();
|
|
6572
6579
|
}));
|
|
6573
6580
|
}
|
|
6574
6581
|
set(t, e, n) {
|
|
6575
|
-
const r =
|
|
6582
|
+
const r = Gr(t, this._firestore), s = Dr(r.converter, e, n), i = jn(this._dataReader, "Transaction.set", r._key, s, null !== r.converter, n);
|
|
6576
6583
|
return this._transaction.set(r._key, i), this;
|
|
6577
6584
|
}
|
|
6578
6585
|
update(t, e, n, ...r) {
|
|
6579
|
-
const s =
|
|
6586
|
+
const s = Gr(t, this._firestore);
|
|
6580
6587
|
// For Compat types, we have to "extract" the underlying types before
|
|
6581
6588
|
// performing validation.
|
|
6582
6589
|
let i;
|
|
6583
|
-
return i = "string" == typeof (e =
|
|
6590
|
+
return i = "string" == typeof (e = f(e)) || e instanceof Dn ? Hn(this._dataReader, "Transaction.update", s._key, e, n, r) : Yn(this._dataReader, "Transaction.update", s._key, e),
|
|
6584
6591
|
this._transaction.update(s._key, i), this;
|
|
6585
6592
|
}
|
|
6586
6593
|
/**
|
|
@@ -6589,7 +6596,7 @@ class ts {
|
|
|
6589
6596
|
* @param documentRef - A reference to the document to be deleted.
|
|
6590
6597
|
* @returns This `Transaction` instance. Used for chaining method calls.
|
|
6591
6598
|
*/ delete(t) {
|
|
6592
|
-
const e =
|
|
6599
|
+
const e = Gr(t, this._firestore);
|
|
6593
6600
|
return this._transaction.delete(e._key), this;
|
|
6594
6601
|
}
|
|
6595
6602
|
}
|
|
@@ -6612,13 +6619,13 @@ class ts {
|
|
|
6612
6619
|
* (the `updateFunction` returned a failed promise), the promise returned by the
|
|
6613
6620
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
6614
6621
|
* rejected promise with the corresponding failure error is returned.
|
|
6615
|
-
*/ function
|
|
6616
|
-
const r =
|
|
6622
|
+
*/ function ns(t, e, n) {
|
|
6623
|
+
const r = fn(t = at(t, wn)), s = Object.assign(Object.assign({}, Hr), n);
|
|
6617
6624
|
!function(t) {
|
|
6618
|
-
if (t.maxAttempts < 1) throw new
|
|
6625
|
+
if (t.maxAttempts < 1) throw new j(V, "Max attempts must be at least 1");
|
|
6619
6626
|
}(s);
|
|
6620
|
-
const i = new
|
|
6621
|
-
return new
|
|
6627
|
+
const i = new B;
|
|
6628
|
+
return new Jr(new ts, r, s, (n => e(new es(t, n))), i).run(), i.promise;
|
|
6622
6629
|
}
|
|
6623
6630
|
|
|
6624
6631
|
/**
|
|
@@ -6629,11 +6636,11 @@ class ts {
|
|
|
6629
6636
|
* directly to the backend, and `onSnapshot()` APIs are not supported.
|
|
6630
6637
|
* @packageDocumentation
|
|
6631
6638
|
*/ !function(t) {
|
|
6632
|
-
|
|
6639
|
+
m = t;
|
|
6633
6640
|
}(`${s}_lite`), n(new i("firestore/lite", ((t, {instanceIdentifier: e, options: n}) => {
|
|
6634
|
-
const r = t.getProvider("app").getImmediate(), s = new
|
|
6635
|
-
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new
|
|
6636
|
-
return new
|
|
6641
|
+
const r = t.getProvider("app").getImmediate(), s = new wn(new G(t.getProvider("auth-internal")), new J(t.getProvider("app-check-internal")), function(t, e) {
|
|
6642
|
+
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new j(V, '"projectId" not provided in firebase.initializeApp.');
|
|
6643
|
+
return new Z(t.options.projectId, e);
|
|
6637
6644
|
}
|
|
6638
6645
|
/**
|
|
6639
6646
|
* @license
|
|
@@ -6654,7 +6661,7 @@ class ts {
|
|
|
6654
6661
|
return n && s._setSettings(n), s;
|
|
6655
6662
|
}), "PUBLIC").setMultipleInstances(!0)),
|
|
6656
6663
|
// RUNTIME_ENV and BUILD_TARGET are replaced by real values during the compilation
|
|
6657
|
-
r("firestore-lite", "3.5.0-canary.
|
|
6664
|
+
r("firestore-lite", "3.5.0-canary.fdd4ab464", "rn"), r("firestore-lite", "3.5.0-canary.fdd4ab464", "esm2017");
|
|
6658
6665
|
|
|
6659
|
-
export {
|
|
6666
|
+
export { _n as AggregateField, vn as AggregateQuerySnapshot, $n as Bytes, Tn as CollectionReference, En as DocumentReference, ur as DocumentSnapshot, Dn as FieldPath, Sn as FieldValue, wn as Firestore, j as FirestoreError, Fn as GeoPoint, In as Query, fr as QueryConstraint, cr as QueryDocumentSnapshot, ar as QuerySnapshot, Et as Timestamp, es as Transaction, Wr as WriteBatch, Cr as addDoc, Mr as aggregateQuerySnapshotEqual, Qr as arrayRemove, Br as arrayUnion, An as collection, Rn as collectionGroup, yn as connectFirestoreEmulator, kr as deleteDoc, Ur as deleteField, Pn as doc, xn as documentId, Rr as endAt, Ar as endBefore, Lr as getCount, Sr as getDoc, Fr as getDocs, pn as getFirestore, zr as increment, mn as initializeFirestore, _r as limit, vr as limitToLast, yr as orderBy, dr as query, Nn as queryEqual, Vn as refEqual, ns as runTransaction, jr as serverTimestamp, qr as setDoc, y as setLogLevel, hr as snapshotEqual, Ir as startAfter, Er as startAt, gn as terminate, Or as updateDoc, mr as where, Kr as writeBatch };
|
|
6660
6667
|
//# sourceMappingURL=index.rn.esm2017.js.map
|