@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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _registerComponent, registerVersion, _getProvider, getApp, _removeServiceInstance, SDK_VERSION } from '@firebase/app';
|
|
2
2
|
import { Component } from '@firebase/component';
|
|
3
3
|
import { Logger, LogLevel } from '@firebase/logger';
|
|
4
|
-
import { FirebaseError, createMockUserToken, getModularInstance, deepEqual } from '@firebase/util';
|
|
4
|
+
import { FirebaseError, getDefaultEmulatorHost, createMockUserToken, getModularInstance, deepEqual } from '@firebase/util';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @license
|
|
@@ -23,7 +23,7 @@ import { FirebaseError, createMockUserToken, getModularInstance, deepEqual } fro
|
|
|
23
23
|
* Simple wrapper around a nullable UID. Mostly exists to make code more
|
|
24
24
|
* readable.
|
|
25
25
|
*/
|
|
26
|
-
class
|
|
26
|
+
class d {
|
|
27
27
|
constructor(t) {
|
|
28
28
|
this.uid = t;
|
|
29
29
|
}
|
|
@@ -41,11 +41,11 @@ class f {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
/** A user with a null UID. */
|
|
44
|
+
/** A user with a null UID. */ d.UNAUTHENTICATED = new d(null),
|
|
45
45
|
// TODO(mikelehen): Look into getting a proper uid-equivalent for
|
|
46
46
|
// non-FirebaseAuth providers.
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
d.GOOGLE_CREDENTIALS = new d("google-credentials-uid"), d.FIRST_PARTY = new d("first-party-uid"),
|
|
48
|
+
d.MOCK_USER = new d("mock-user");
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* @license
|
|
@@ -63,7 +63,7 @@ f.MOCK_USER = new f("mock-user");
|
|
|
63
63
|
* See the License for the specific language governing permissions and
|
|
64
64
|
* limitations under the License.
|
|
65
65
|
*/
|
|
66
|
-
let
|
|
66
|
+
let w = "9.10.0-canary.fdd4ab464";
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* @license
|
|
@@ -81,7 +81,7 @@ let d = "9.10.0-canary.ee871fc0b";
|
|
|
81
81
|
* See the License for the specific language governing permissions and
|
|
82
82
|
* limitations under the License.
|
|
83
83
|
*/
|
|
84
|
-
const
|
|
84
|
+
const m = new Logger("@firebase/firestore");
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
87
|
* Sets the verbosity of Cloud Firestore logs (debug, error, or silent).
|
|
@@ -95,36 +95,36 @@ const w = new Logger("@firebase/firestore");
|
|
|
95
95
|
* <li>`error` to log errors only.</li>
|
|
96
96
|
* <li><code>`silent` to turn off logging.</li>
|
|
97
97
|
* </ul>
|
|
98
|
-
*/ function
|
|
99
|
-
|
|
98
|
+
*/ function p(t) {
|
|
99
|
+
m.setLogLevel(t);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
function
|
|
103
|
-
if (
|
|
104
|
-
const n = e.map(
|
|
105
|
-
|
|
102
|
+
function y(t, ...e) {
|
|
103
|
+
if (m.logLevel <= LogLevel.DEBUG) {
|
|
104
|
+
const n = e.map(v);
|
|
105
|
+
m.debug(`Firestore (${w}): ${t}`, ...n);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
function
|
|
110
|
-
if (
|
|
111
|
-
const n = e.map(
|
|
112
|
-
|
|
109
|
+
function _(t, ...e) {
|
|
110
|
+
if (m.logLevel <= LogLevel.ERROR) {
|
|
111
|
+
const n = e.map(v);
|
|
112
|
+
m.error(`Firestore (${w}): ${t}`, ...n);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
/**
|
|
117
117
|
* @internal
|
|
118
|
-
*/ function
|
|
119
|
-
if (
|
|
120
|
-
const n = e.map(
|
|
121
|
-
|
|
118
|
+
*/ function g(t, ...e) {
|
|
119
|
+
if (m.logLevel <= LogLevel.WARN) {
|
|
120
|
+
const n = e.map(v);
|
|
121
|
+
m.warn(`Firestore (${w}): ${t}`, ...n);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
/**
|
|
126
126
|
* Converts an additional log parameter to a string representation.
|
|
127
|
-
*/ function
|
|
127
|
+
*/ function v(t) {
|
|
128
128
|
if ("string" == typeof t) return t;
|
|
129
129
|
try {
|
|
130
130
|
return e = t, JSON.stringify(e);
|
|
@@ -175,14 +175,14 @@ function y(t, ...e) {
|
|
|
175
175
|
* Returns `never` and can be used in expressions:
|
|
176
176
|
* @example
|
|
177
177
|
* let futureVar = fail('not implemented yet');
|
|
178
|
-
*/ function
|
|
178
|
+
*/ function b(t = "Unexpected state") {
|
|
179
179
|
// Log the failure in addition to throw an exception, just in case the
|
|
180
180
|
// exception is swallowed.
|
|
181
|
-
const e = `FIRESTORE (${
|
|
181
|
+
const e = `FIRESTORE (${w}) INTERNAL ASSERTION FAILED: ` + t;
|
|
182
182
|
// NOTE: We don't use FirestoreError here because these are internal failures
|
|
183
183
|
// that cannot be handled by the user. (Also it would create a circular
|
|
184
184
|
// dependency between the error and assert modules which doesn't work.)
|
|
185
|
-
throw
|
|
185
|
+
throw _(e), new Error(e);
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
/**
|
|
@@ -190,14 +190,14 @@ function y(t, ...e) {
|
|
|
190
190
|
* given message if it did.
|
|
191
191
|
*
|
|
192
192
|
* Messages are stripped in production builds.
|
|
193
|
-
*/ function
|
|
194
|
-
t ||
|
|
193
|
+
*/ function E(t, e) {
|
|
194
|
+
t || b();
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
/**
|
|
198
198
|
* Casts `obj` to `T`. In non-production builds, verifies that `obj` is an
|
|
199
199
|
* instance of `T` before casting.
|
|
200
|
-
*/ function
|
|
200
|
+
*/ function I(t,
|
|
201
201
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
202
202
|
e) {
|
|
203
203
|
return t;
|
|
@@ -218,9 +218,9 @@ e) {
|
|
|
218
218
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
219
219
|
* See the License for the specific language governing permissions and
|
|
220
220
|
* limitations under the License.
|
|
221
|
-
*/ const
|
|
221
|
+
*/ const T = "ok", A = "cancelled", R = "unknown", P = "invalid-argument", V = "deadline-exceeded", N = "not-found", D = "already-exists", $ = "permission-denied", x = "unauthenticated", F = "resource-exhausted", S = "failed-precondition", q = "aborted", O = "out-of-range", k = "unimplemented", C = "internal", L = "unavailable", M = "data-loss";
|
|
222
222
|
|
|
223
|
-
/** An error returned by a Firestore operation. */ class
|
|
223
|
+
/** An error returned by a Firestore operation. */ class U extends FirebaseError {
|
|
224
224
|
/** @hideconstructor */
|
|
225
225
|
constructor(
|
|
226
226
|
/**
|
|
@@ -254,7 +254,7 @@ e) {
|
|
|
254
254
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
255
255
|
* See the License for the specific language governing permissions and
|
|
256
256
|
* limitations under the License.
|
|
257
|
-
*/ class
|
|
257
|
+
*/ class j {
|
|
258
258
|
constructor() {
|
|
259
259
|
this.promise = new Promise(((t, e) => {
|
|
260
260
|
this.resolve = t, this.reject = e;
|
|
@@ -277,7 +277,7 @@ e) {
|
|
|
277
277
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
278
278
|
* See the License for the specific language governing permissions and
|
|
279
279
|
* limitations under the License.
|
|
280
|
-
*/ class
|
|
280
|
+
*/ class B {
|
|
281
281
|
constructor(t, e) {
|
|
282
282
|
this.user = e, this.type = "OAuth", this.headers = new Map, this.headers.set("Authorization", `Bearer ${t}`);
|
|
283
283
|
}
|
|
@@ -286,14 +286,14 @@ e) {
|
|
|
286
286
|
/**
|
|
287
287
|
* A CredentialsProvider that always yields an empty token.
|
|
288
288
|
* @internal
|
|
289
|
-
*/ class
|
|
289
|
+
*/ class Q {
|
|
290
290
|
getToken() {
|
|
291
291
|
return Promise.resolve(null);
|
|
292
292
|
}
|
|
293
293
|
invalidateToken() {}
|
|
294
294
|
start(t, e) {
|
|
295
295
|
// Fire with initial user.
|
|
296
|
-
t.enqueueRetryable((() => e(
|
|
296
|
+
t.enqueueRetryable((() => e(d.UNAUTHENTICATED)));
|
|
297
297
|
}
|
|
298
298
|
shutdown() {}
|
|
299
299
|
}
|
|
@@ -301,7 +301,7 @@ e) {
|
|
|
301
301
|
/**
|
|
302
302
|
* A CredentialsProvider that always returns a constant token. Used for
|
|
303
303
|
* emulator token mocking.
|
|
304
|
-
*/ class
|
|
304
|
+
*/ class z {
|
|
305
305
|
constructor(t) {
|
|
306
306
|
this.token = t,
|
|
307
307
|
/**
|
|
@@ -325,15 +325,15 @@ e) {
|
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
327
|
|
|
328
|
-
/** Credential provider for the Lite SDK. */ class
|
|
328
|
+
/** Credential provider for the Lite SDK. */ class G {
|
|
329
329
|
constructor(t) {
|
|
330
330
|
this.auth = null, t.onInit((t => {
|
|
331
331
|
this.auth = t;
|
|
332
332
|
}));
|
|
333
333
|
}
|
|
334
334
|
getToken() {
|
|
335
|
-
return this.auth ? this.auth.getToken().then((t => t ? (
|
|
336
|
-
new
|
|
335
|
+
return this.auth ? this.auth.getToken().then((t => t ? (E("string" == typeof t.accessToken),
|
|
336
|
+
new B(t.accessToken, new d(this.auth.getUid()))) : null)) : Promise.resolve(null);
|
|
337
337
|
}
|
|
338
338
|
invalidateToken() {}
|
|
339
339
|
start(t, e) {}
|
|
@@ -346,15 +346,15 @@ e) {
|
|
|
346
346
|
* Technically this may no longer be necessary since the SDK should gracefully
|
|
347
347
|
* recover from unauthenticated errors (see b/33147818 for context), but it's
|
|
348
348
|
* safer to keep the implementation as-is.
|
|
349
|
-
*/ class
|
|
349
|
+
*/ class W {
|
|
350
350
|
constructor(t, e, n, r) {
|
|
351
|
-
this.t = t, this.i = e, this.o = n, this.u = r, this.type = "FirstParty", this.user =
|
|
351
|
+
this.t = t, this.i = e, this.o = n, this.u = r, this.type = "FirstParty", this.user = d.FIRST_PARTY,
|
|
352
352
|
this.h = new Map;
|
|
353
353
|
}
|
|
354
354
|
/** Gets an authorization token, using a provided factory function, or falling back to First Party GAPI. */ l() {
|
|
355
355
|
return this.u ? this.u() : (
|
|
356
356
|
// Make sure this really is a Gapi client.
|
|
357
|
-
|
|
357
|
+
E(!("object" != typeof this.t || null === this.t || !this.t.auth || !this.t.auth.getAuthHeaderValueForFirstParty)),
|
|
358
358
|
this.t.auth.getAuthHeaderValueForFirstParty([]));
|
|
359
359
|
}
|
|
360
360
|
get headers() {
|
|
@@ -370,36 +370,36 @@ e) {
|
|
|
370
370
|
* Provides user credentials required for the Firestore JavaScript SDK
|
|
371
371
|
* to authenticate the user, using technique that is only available
|
|
372
372
|
* to applications hosted by Google.
|
|
373
|
-
*/ class
|
|
373
|
+
*/ class K {
|
|
374
374
|
constructor(t, e, n, r) {
|
|
375
375
|
this.t = t, this.i = e, this.o = n, this.u = r;
|
|
376
376
|
}
|
|
377
377
|
getToken() {
|
|
378
|
-
return Promise.resolve(new
|
|
378
|
+
return Promise.resolve(new W(this.t, this.i, this.o, this.u));
|
|
379
379
|
}
|
|
380
380
|
start(t, e) {
|
|
381
381
|
// Fire with initial uid.
|
|
382
|
-
t.enqueueRetryable((() => e(
|
|
382
|
+
t.enqueueRetryable((() => e(d.FIRST_PARTY)));
|
|
383
383
|
}
|
|
384
384
|
shutdown() {}
|
|
385
385
|
invalidateToken() {}
|
|
386
386
|
}
|
|
387
387
|
|
|
388
|
-
class
|
|
388
|
+
class Y {
|
|
389
389
|
constructor(t) {
|
|
390
390
|
this.value = t, this.type = "AppCheck", this.headers = new Map, t && t.length > 0 && this.headers.set("x-firebase-appcheck", this.value);
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
393
|
|
|
394
|
-
/** AppCheck token provider for the Lite SDK. */ class
|
|
394
|
+
/** AppCheck token provider for the Lite SDK. */ class H {
|
|
395
395
|
constructor(t) {
|
|
396
396
|
this.m = t, this.appCheck = null, t.onInit((t => {
|
|
397
397
|
this.appCheck = t;
|
|
398
398
|
}));
|
|
399
399
|
}
|
|
400
400
|
getToken() {
|
|
401
|
-
return this.appCheck ? this.appCheck.getToken().then((t => t ? (
|
|
402
|
-
new
|
|
401
|
+
return this.appCheck ? this.appCheck.getToken().then((t => t ? (E("string" == typeof t.token),
|
|
402
|
+
new Y(t.token)) : null)) : Promise.resolve(null);
|
|
403
403
|
}
|
|
404
404
|
invalidateToken() {}
|
|
405
405
|
start(t, e) {}
|
|
@@ -426,7 +426,7 @@ class K {
|
|
|
426
426
|
* See the License for the specific language governing permissions and
|
|
427
427
|
* limitations under the License.
|
|
428
428
|
*/
|
|
429
|
-
class
|
|
429
|
+
class J {
|
|
430
430
|
/**
|
|
431
431
|
* Constructs a DatabaseInfo using the provided host, databaseId and
|
|
432
432
|
* persistenceKey.
|
|
@@ -455,38 +455,38 @@ class H {
|
|
|
455
455
|
* Represents the database ID a Firestore client is associated with.
|
|
456
456
|
* @internal
|
|
457
457
|
*/
|
|
458
|
-
class
|
|
458
|
+
class X {
|
|
459
459
|
constructor(t, e) {
|
|
460
460
|
this.projectId = t, this.database = e || "(default)";
|
|
461
461
|
}
|
|
462
462
|
static empty() {
|
|
463
|
-
return new
|
|
463
|
+
return new X("", "");
|
|
464
464
|
}
|
|
465
465
|
get isDefaultDatabase() {
|
|
466
466
|
return "(default)" === this.database;
|
|
467
467
|
}
|
|
468
468
|
isEqual(t) {
|
|
469
|
-
return t instanceof
|
|
469
|
+
return t instanceof X && t.projectId === this.projectId && t.database === this.database;
|
|
470
470
|
}
|
|
471
471
|
}
|
|
472
472
|
|
|
473
473
|
/**
|
|
474
474
|
* Path represents an ordered sequence of string segments.
|
|
475
475
|
*/
|
|
476
|
-
class
|
|
476
|
+
class Z {
|
|
477
477
|
constructor(t, e, n) {
|
|
478
|
-
void 0 === e ? e = 0 : e > t.length &&
|
|
478
|
+
void 0 === e ? e = 0 : e > t.length && b(), void 0 === n ? n = t.length - e : n > t.length - e && b(),
|
|
479
479
|
this.segments = t, this.offset = e, this.len = n;
|
|
480
480
|
}
|
|
481
481
|
get length() {
|
|
482
482
|
return this.len;
|
|
483
483
|
}
|
|
484
484
|
isEqual(t) {
|
|
485
|
-
return 0 ===
|
|
485
|
+
return 0 === Z.comparator(this, t);
|
|
486
486
|
}
|
|
487
487
|
child(t) {
|
|
488
488
|
const e = this.segments.slice(this.offset, this.limit());
|
|
489
|
-
return t instanceof
|
|
489
|
+
return t instanceof Z ? t.forEach((t => {
|
|
490
490
|
e.push(t);
|
|
491
491
|
})) : e.push(t), this.construct(e);
|
|
492
492
|
}
|
|
@@ -543,9 +543,9 @@ class X {
|
|
|
543
543
|
* within Firestore.
|
|
544
544
|
*
|
|
545
545
|
* @internal
|
|
546
|
-
*/ class
|
|
546
|
+
*/ class tt extends Z {
|
|
547
547
|
construct(t, e, n) {
|
|
548
|
-
return new
|
|
548
|
+
return new tt(t, e, n);
|
|
549
549
|
}
|
|
550
550
|
canonicalString() {
|
|
551
551
|
// NOTE: The client is ignorant of any path segments containing escape
|
|
@@ -566,35 +566,35 @@ class X {
|
|
|
566
566
|
// for legacy reasons and should not be used frequently).
|
|
567
567
|
const e = [];
|
|
568
568
|
for (const n of t) {
|
|
569
|
-
if (n.indexOf("//") >= 0) throw new
|
|
569
|
+
if (n.indexOf("//") >= 0) throw new U(P, `Invalid segment (${n}). Paths must not contain // in them.`);
|
|
570
570
|
// Strip leading and traling slashed.
|
|
571
571
|
e.push(...n.split("/").filter((t => t.length > 0)));
|
|
572
572
|
}
|
|
573
|
-
return new
|
|
573
|
+
return new tt(e);
|
|
574
574
|
}
|
|
575
575
|
static emptyPath() {
|
|
576
|
-
return new
|
|
576
|
+
return new tt([]);
|
|
577
577
|
}
|
|
578
578
|
}
|
|
579
579
|
|
|
580
|
-
const
|
|
580
|
+
const et = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
581
581
|
|
|
582
582
|
/**
|
|
583
583
|
* A dot-separated path for navigating sub-objects within a document.
|
|
584
584
|
* @internal
|
|
585
|
-
*/ class
|
|
585
|
+
*/ class nt extends Z {
|
|
586
586
|
construct(t, e, n) {
|
|
587
|
-
return new
|
|
587
|
+
return new nt(t, e, n);
|
|
588
588
|
}
|
|
589
589
|
/**
|
|
590
590
|
* Returns true if the string could be used as a segment in a field path
|
|
591
591
|
* without escaping.
|
|
592
592
|
*/ static isValidIdentifier(t) {
|
|
593
|
-
return
|
|
593
|
+
return et.test(t);
|
|
594
594
|
}
|
|
595
595
|
canonicalString() {
|
|
596
596
|
return this.toArray().map((t => (t = t.replace(/\\/g, "\\\\").replace(/`/g, "\\`"),
|
|
597
|
-
|
|
597
|
+
nt.isValidIdentifier(t) || (t = "`" + t + "`"), t))).join(".");
|
|
598
598
|
}
|
|
599
599
|
toString() {
|
|
600
600
|
return this.canonicalString();
|
|
@@ -607,7 +607,7 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
607
607
|
/**
|
|
608
608
|
* The field designating the key of a document.
|
|
609
609
|
*/ static keyField() {
|
|
610
|
-
return new
|
|
610
|
+
return new nt([ "__name__" ]);
|
|
611
611
|
}
|
|
612
612
|
/**
|
|
613
613
|
* Parses a field string from the given server-formatted string.
|
|
@@ -622,24 +622,24 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
622
622
|
const e = [];
|
|
623
623
|
let n = "", r = 0;
|
|
624
624
|
const s = () => {
|
|
625
|
-
if (0 === n.length) throw new
|
|
625
|
+
if (0 === n.length) throw new U(P, `Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);
|
|
626
626
|
e.push(n), n = "";
|
|
627
627
|
};
|
|
628
628
|
let i = !1;
|
|
629
629
|
for (;r < t.length; ) {
|
|
630
630
|
const e = t[r];
|
|
631
631
|
if ("\\" === e) {
|
|
632
|
-
if (r + 1 === t.length) throw new
|
|
632
|
+
if (r + 1 === t.length) throw new U(P, "Path has trailing escape character: " + t);
|
|
633
633
|
const e = t[r + 1];
|
|
634
|
-
if ("\\" !== e && "." !== e && "`" !== e) throw new
|
|
634
|
+
if ("\\" !== e && "." !== e && "`" !== e) throw new U(P, "Path has invalid escape sequence: " + t);
|
|
635
635
|
n += e, r += 2;
|
|
636
636
|
} else "`" === e ? (i = !i, r++) : "." !== e || i ? (n += e, r++) : (s(), r++);
|
|
637
637
|
}
|
|
638
|
-
if (s(), i) throw new
|
|
639
|
-
return new
|
|
638
|
+
if (s(), i) throw new U(P, "Unterminated ` in path: " + t);
|
|
639
|
+
return new nt(e);
|
|
640
640
|
}
|
|
641
641
|
static emptyPath() {
|
|
642
|
-
return new
|
|
642
|
+
return new nt([]);
|
|
643
643
|
}
|
|
644
644
|
}
|
|
645
645
|
|
|
@@ -661,18 +661,18 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
661
661
|
*/
|
|
662
662
|
/**
|
|
663
663
|
* @internal
|
|
664
|
-
*/ class
|
|
664
|
+
*/ class rt {
|
|
665
665
|
constructor(t) {
|
|
666
666
|
this.path = t;
|
|
667
667
|
}
|
|
668
668
|
static fromPath(t) {
|
|
669
|
-
return new
|
|
669
|
+
return new rt(tt.fromString(t));
|
|
670
670
|
}
|
|
671
671
|
static fromName(t) {
|
|
672
|
-
return new
|
|
672
|
+
return new rt(tt.fromString(t).popFirst(5));
|
|
673
673
|
}
|
|
674
674
|
static empty() {
|
|
675
|
-
return new
|
|
675
|
+
return new rt(tt.emptyPath());
|
|
676
676
|
}
|
|
677
677
|
get collectionGroup() {
|
|
678
678
|
return this.path.popLast().lastSegment();
|
|
@@ -687,13 +687,13 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
687
687
|
return this.path.popLast();
|
|
688
688
|
}
|
|
689
689
|
isEqual(t) {
|
|
690
|
-
return null !== t && 0 ===
|
|
690
|
+
return null !== t && 0 === tt.comparator(this.path, t.path);
|
|
691
691
|
}
|
|
692
692
|
toString() {
|
|
693
693
|
return this.path.toString();
|
|
694
694
|
}
|
|
695
695
|
static comparator(t, e) {
|
|
696
|
-
return
|
|
696
|
+
return tt.comparator(t.path, e.path);
|
|
697
697
|
}
|
|
698
698
|
static isDocumentKey(t) {
|
|
699
699
|
return t.length % 2 == 0;
|
|
@@ -704,7 +704,7 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
704
704
|
* @param segments - The segments of the path to the document
|
|
705
705
|
* @returns A new instance of DocumentKey
|
|
706
706
|
*/ static fromSegments(t) {
|
|
707
|
-
return new
|
|
707
|
+
return new rt(new tt(t.slice()));
|
|
708
708
|
}
|
|
709
709
|
}
|
|
710
710
|
|
|
@@ -723,8 +723,8 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
723
723
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
724
724
|
* See the License for the specific language governing permissions and
|
|
725
725
|
* limitations under the License.
|
|
726
|
-
*/ function
|
|
727
|
-
if (!n) throw new
|
|
726
|
+
*/ function st(t, e, n) {
|
|
727
|
+
if (!n) throw new U(P, `Function ${t}() cannot be called with an empty ${e}.`);
|
|
728
728
|
}
|
|
729
729
|
|
|
730
730
|
/**
|
|
@@ -735,15 +735,15 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
735
735
|
* Validates that `path` refers to a document (indicated by the fact it contains
|
|
736
736
|
* an even numbers of segments).
|
|
737
737
|
*/
|
|
738
|
-
function
|
|
739
|
-
if (!
|
|
738
|
+
function it(t) {
|
|
739
|
+
if (!rt.isDocumentKey(t)) throw new U(P, `Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`);
|
|
740
740
|
}
|
|
741
741
|
|
|
742
742
|
/**
|
|
743
743
|
* Validates that `path` refers to a collection (indicated by the fact it
|
|
744
744
|
* contains an odd numbers of segments).
|
|
745
|
-
*/ function
|
|
746
|
-
if (
|
|
745
|
+
*/ function ot(t) {
|
|
746
|
+
if (rt.isDocumentKey(t)) throw new U(P, `Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`);
|
|
747
747
|
}
|
|
748
748
|
|
|
749
749
|
/**
|
|
@@ -751,7 +751,7 @@ function st(t) {
|
|
|
751
751
|
* (i.e. excludes Array, Date, etc.).
|
|
752
752
|
*/
|
|
753
753
|
/** Returns a string describing the type / value of the provided input. */
|
|
754
|
-
function
|
|
754
|
+
function ut(t) {
|
|
755
755
|
if (void 0 === t) return "undefined";
|
|
756
756
|
if (null === t) return "null";
|
|
757
757
|
if ("string" == typeof t) return t.length > 20 && (t = `${t.substring(0, 20)}...`),
|
|
@@ -777,27 +777,27 @@ function ot(t) {
|
|
|
777
777
|
return e ? `a custom ${e} object` : "an object";
|
|
778
778
|
}
|
|
779
779
|
}
|
|
780
|
-
return "function" == typeof t ? "a function" :
|
|
780
|
+
return "function" == typeof t ? "a function" : b();
|
|
781
781
|
}
|
|
782
782
|
|
|
783
|
-
function
|
|
783
|
+
function ct(t,
|
|
784
784
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
785
785
|
e) {
|
|
786
786
|
if ("_delegate" in t && (
|
|
787
787
|
// Unwrap Compat types
|
|
788
788
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
789
789
|
t = t._delegate), !(t instanceof e)) {
|
|
790
|
-
if (e.name === t.constructor.name) throw new
|
|
790
|
+
if (e.name === t.constructor.name) throw new U(P, "Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");
|
|
791
791
|
{
|
|
792
|
-
const n =
|
|
793
|
-
throw new
|
|
792
|
+
const n = ut(t);
|
|
793
|
+
throw new U(P, `Expected type '${e.name}', but it was: ${n}`);
|
|
794
794
|
}
|
|
795
795
|
}
|
|
796
796
|
return t;
|
|
797
797
|
}
|
|
798
798
|
|
|
799
|
-
function
|
|
800
|
-
if (e <= 0) throw new
|
|
799
|
+
function at(t, e) {
|
|
800
|
+
if (e <= 0) throw new U(P, `Function ${t}() requires a positive number, but it was: ${e}.`);
|
|
801
801
|
}
|
|
802
802
|
|
|
803
803
|
/**
|
|
@@ -818,11 +818,11 @@ function ct(t, e) {
|
|
|
818
818
|
*/
|
|
819
819
|
/**
|
|
820
820
|
* Returns whether a variable is either undefined or null.
|
|
821
|
-
*/ function
|
|
821
|
+
*/ function ht(t) {
|
|
822
822
|
return null == t;
|
|
823
823
|
}
|
|
824
824
|
|
|
825
|
-
/** Returns whether the value represents -0. */ function
|
|
825
|
+
/** Returns whether the value represents -0. */ function lt(t) {
|
|
826
826
|
// Detect if the value is -0.0. Based on polyfill from
|
|
827
827
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
828
828
|
return 0 === t && 1 / t == -1 / 0;
|
|
@@ -848,7 +848,7 @@ function ct(t, e) {
|
|
|
848
848
|
* See the License for the specific language governing permissions and
|
|
849
849
|
* limitations under the License.
|
|
850
850
|
*/
|
|
851
|
-
const
|
|
851
|
+
const ft = {
|
|
852
852
|
BatchGetDocuments: "batchGet",
|
|
853
853
|
Commit: "commit",
|
|
854
854
|
RunQuery: "runQuery",
|
|
@@ -886,7 +886,7 @@ const lt = {
|
|
|
886
886
|
* are used for reverse lookups from the webchannel stream. Do NOT change the
|
|
887
887
|
* names of these identifiers or change this into a const enum.
|
|
888
888
|
*/
|
|
889
|
-
var
|
|
889
|
+
var dt, wt;
|
|
890
890
|
|
|
891
891
|
/**
|
|
892
892
|
* Converts an HTTP Status Code to the equivalent error code.
|
|
@@ -895,8 +895,8 @@ var ft, dt;
|
|
|
895
895
|
* @returns The equivalent Code. Unknown status codes are mapped to
|
|
896
896
|
* Code.UNKNOWN.
|
|
897
897
|
*/
|
|
898
|
-
function
|
|
899
|
-
if (void 0 === t) return
|
|
898
|
+
function mt(t) {
|
|
899
|
+
if (void 0 === t) return _("RPC_ERROR", "HTTP error has no status"), R;
|
|
900
900
|
// The canonical error codes for Google APIs [1] specify mapping onto HTTP
|
|
901
901
|
// status codes but the mapping is not bijective. In each case of ambiguity
|
|
902
902
|
// this function chooses a primary error.
|
|
@@ -906,66 +906,66 @@ function wt(t) {
|
|
|
906
906
|
switch (t) {
|
|
907
907
|
case 200:
|
|
908
908
|
// OK
|
|
909
|
-
return
|
|
909
|
+
return T;
|
|
910
910
|
|
|
911
911
|
case 400:
|
|
912
912
|
// Bad Request
|
|
913
|
-
return
|
|
913
|
+
return S;
|
|
914
914
|
|
|
915
915
|
// Other possibilities based on the forward mapping
|
|
916
916
|
// return Code.INVALID_ARGUMENT;
|
|
917
917
|
// return Code.OUT_OF_RANGE;
|
|
918
918
|
case 401:
|
|
919
919
|
// Unauthorized
|
|
920
|
-
return
|
|
920
|
+
return x;
|
|
921
921
|
|
|
922
922
|
case 403:
|
|
923
923
|
// Forbidden
|
|
924
|
-
return
|
|
924
|
+
return $;
|
|
925
925
|
|
|
926
926
|
case 404:
|
|
927
927
|
// Not Found
|
|
928
|
-
return
|
|
928
|
+
return N;
|
|
929
929
|
|
|
930
930
|
case 409:
|
|
931
931
|
// Conflict
|
|
932
|
-
return
|
|
932
|
+
return q;
|
|
933
933
|
|
|
934
934
|
// Other possibilities:
|
|
935
935
|
// return Code.ALREADY_EXISTS;
|
|
936
936
|
case 416:
|
|
937
937
|
// Range Not Satisfiable
|
|
938
|
-
return
|
|
938
|
+
return O;
|
|
939
939
|
|
|
940
940
|
case 429:
|
|
941
941
|
// Too Many Requests
|
|
942
|
-
return
|
|
942
|
+
return F;
|
|
943
943
|
|
|
944
944
|
case 499:
|
|
945
945
|
// Client Closed Request
|
|
946
|
-
return
|
|
946
|
+
return A;
|
|
947
947
|
|
|
948
948
|
case 500:
|
|
949
949
|
// Internal Server Error
|
|
950
|
-
return
|
|
950
|
+
return R;
|
|
951
951
|
|
|
952
952
|
// Other possibilities:
|
|
953
953
|
// return Code.INTERNAL;
|
|
954
954
|
// return Code.DATA_LOSS;
|
|
955
955
|
case 501:
|
|
956
956
|
// Unimplemented
|
|
957
|
-
return
|
|
957
|
+
return k;
|
|
958
958
|
|
|
959
959
|
case 503:
|
|
960
960
|
// Service Unavailable
|
|
961
|
-
return
|
|
961
|
+
return L;
|
|
962
962
|
|
|
963
963
|
case 504:
|
|
964
964
|
// Gateway Timeout
|
|
965
|
-
return
|
|
965
|
+
return V;
|
|
966
966
|
|
|
967
967
|
default:
|
|
968
|
-
return t >= 200 && t < 300 ?
|
|
968
|
+
return t >= 200 && t < 300 ? T : t >= 400 && t < 500 ? S : t >= 500 && t < 600 ? C : R;
|
|
969
969
|
}
|
|
970
970
|
}
|
|
971
971
|
|
|
@@ -988,16 +988,16 @@ function wt(t) {
|
|
|
988
988
|
/**
|
|
989
989
|
* A Rest-based connection that relies on the native HTTP stack
|
|
990
990
|
* (e.g. `fetch` or a polyfill).
|
|
991
|
-
*/ (
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
991
|
+
*/ (wt = dt || (dt = {}))[wt.OK = 0] = "OK", wt[wt.CANCELLED = 1] = "CANCELLED",
|
|
992
|
+
wt[wt.UNKNOWN = 2] = "UNKNOWN", wt[wt.INVALID_ARGUMENT = 3] = "INVALID_ARGUMENT",
|
|
993
|
+
wt[wt.DEADLINE_EXCEEDED = 4] = "DEADLINE_EXCEEDED", wt[wt.NOT_FOUND = 5] = "NOT_FOUND",
|
|
994
|
+
wt[wt.ALREADY_EXISTS = 6] = "ALREADY_EXISTS", wt[wt.PERMISSION_DENIED = 7] = "PERMISSION_DENIED",
|
|
995
|
+
wt[wt.UNAUTHENTICATED = 16] = "UNAUTHENTICATED", wt[wt.RESOURCE_EXHAUSTED = 8] = "RESOURCE_EXHAUSTED",
|
|
996
|
+
wt[wt.FAILED_PRECONDITION = 9] = "FAILED_PRECONDITION", wt[wt.ABORTED = 10] = "ABORTED",
|
|
997
|
+
wt[wt.OUT_OF_RANGE = 11] = "OUT_OF_RANGE", wt[wt.UNIMPLEMENTED = 12] = "UNIMPLEMENTED",
|
|
998
|
+
wt[wt.INTERNAL = 13] = "INTERNAL", wt[wt.UNAVAILABLE = 14] = "UNAVAILABLE", wt[wt.DATA_LOSS = 15] = "DATA_LOSS";
|
|
999
999
|
|
|
1000
|
-
class
|
|
1000
|
+
class pt extends
|
|
1001
1001
|
/**
|
|
1002
1002
|
* Base class for all Rest-based connections to the backend (WebChannel and
|
|
1003
1003
|
* HTTP).
|
|
@@ -1015,11 +1015,11 @@ class {
|
|
|
1015
1015
|
}
|
|
1016
1016
|
I(t, e, n, r, s) {
|
|
1017
1017
|
const i = this.T(t, e);
|
|
1018
|
-
|
|
1018
|
+
y("RestConnection", "Sending: ", i, n);
|
|
1019
1019
|
const o = {};
|
|
1020
|
-
return this.A(o, r, s), this.R(t, i, o, n).then((t => (
|
|
1020
|
+
return this.A(o, r, s), this.R(t, i, o, n).then((t => (y("RestConnection", "Received: ", t),
|
|
1021
1021
|
t)), (e => {
|
|
1022
|
-
throw
|
|
1022
|
+
throw g("RestConnection", `${t} failed with error: `, e, "url: ", i, "request:", n),
|
|
1023
1023
|
e;
|
|
1024
1024
|
}));
|
|
1025
1025
|
}
|
|
@@ -1032,7 +1032,7 @@ class {
|
|
|
1032
1032
|
* Modifies the headers for a request, adding any authorization token if
|
|
1033
1033
|
* present and any additional headers for the request.
|
|
1034
1034
|
*/ A(t, e, n) {
|
|
1035
|
-
t["X-Goog-Api-Client"] = "gl-js/ fire/" +
|
|
1035
|
+
t["X-Goog-Api-Client"] = "gl-js/ fire/" + w,
|
|
1036
1036
|
// Content-Type: text/plain will avoid preflight requests which might
|
|
1037
1037
|
// mess with CORS and redirects by proxies. If we add custom headers
|
|
1038
1038
|
// we will need to change this code to potentially use the $httpOverwrite
|
|
@@ -1041,7 +1041,7 @@ class {
|
|
|
1041
1041
|
e && e.headers.forEach(((e, n) => t[n] = e)), n && n.headers.forEach(((e, n) => t[n] = e));
|
|
1042
1042
|
}
|
|
1043
1043
|
T(t, e) {
|
|
1044
|
-
const n =
|
|
1044
|
+
const n = ft[t];
|
|
1045
1045
|
return `${this.p}/v1/${e}:${n}`;
|
|
1046
1046
|
}
|
|
1047
1047
|
} {
|
|
@@ -1065,9 +1065,9 @@ class {
|
|
|
1065
1065
|
body: s
|
|
1066
1066
|
});
|
|
1067
1067
|
} catch (t) {
|
|
1068
|
-
throw new
|
|
1068
|
+
throw new U(mt(t.status), "Request failed with error: " + t.statusText);
|
|
1069
1069
|
}
|
|
1070
|
-
if (!i.ok) throw new
|
|
1070
|
+
if (!i.ok) throw new U(mt(i.status), "Request failed with error: " + i.statusText);
|
|
1071
1071
|
return i.json();
|
|
1072
1072
|
}
|
|
1073
1073
|
}
|
|
@@ -1110,7 +1110,7 @@ class {
|
|
|
1110
1110
|
*
|
|
1111
1111
|
* If `nBytes < 0` , an error will be thrown.
|
|
1112
1112
|
*/
|
|
1113
|
-
function
|
|
1113
|
+
function yt(t) {
|
|
1114
1114
|
// Polyfills for IE and WebWorker by using `self` and `msCrypto` when `crypto` is not available.
|
|
1115
1115
|
const e =
|
|
1116
1116
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1136,14 +1136,14 @@ function pt(t) {
|
|
|
1136
1136
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1137
1137
|
* See the License for the specific language governing permissions and
|
|
1138
1138
|
* limitations under the License.
|
|
1139
|
-
*/ class
|
|
1139
|
+
*/ class _t {
|
|
1140
1140
|
static D() {
|
|
1141
1141
|
// Alphanumeric characters
|
|
1142
1142
|
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", e = Math.floor(256 / t.length) * t.length;
|
|
1143
1143
|
// The largest byte value that is a multiple of `char.length`.
|
|
1144
1144
|
let n = "";
|
|
1145
1145
|
for (;n.length < 20; ) {
|
|
1146
|
-
const r =
|
|
1146
|
+
const r = yt(40);
|
|
1147
1147
|
for (let s = 0; s < r.length; ++s)
|
|
1148
1148
|
// Only accept values that are [0, maxMultiple), this ensures they can
|
|
1149
1149
|
// be evenly mapped to indices of `chars` via a modulo operation.
|
|
@@ -1153,11 +1153,11 @@ function pt(t) {
|
|
|
1153
1153
|
}
|
|
1154
1154
|
}
|
|
1155
1155
|
|
|
1156
|
-
function
|
|
1156
|
+
function gt(t, e) {
|
|
1157
1157
|
return t < e ? -1 : t > e ? 1 : 0;
|
|
1158
1158
|
}
|
|
1159
1159
|
|
|
1160
|
-
/** Helper to compare arrays using isEqual(). */ function
|
|
1160
|
+
/** Helper to compare arrays using isEqual(). */ function vt(t, e, n) {
|
|
1161
1161
|
return t.length === e.length && t.every(((t, r) => n(t, e[r])));
|
|
1162
1162
|
}
|
|
1163
1163
|
|
|
@@ -1192,7 +1192,7 @@ function _t(t, e) {
|
|
|
1192
1192
|
* For examples and further specifications, refer to the
|
|
1193
1193
|
* {@link https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto | Timestamp definition}.
|
|
1194
1194
|
*/
|
|
1195
|
-
class
|
|
1195
|
+
class bt {
|
|
1196
1196
|
/**
|
|
1197
1197
|
* Creates a new timestamp.
|
|
1198
1198
|
*
|
|
@@ -1213,18 +1213,18 @@ class vt {
|
|
|
1213
1213
|
* The fractions of a second at nanosecond resolution.*
|
|
1214
1214
|
*/
|
|
1215
1215
|
e) {
|
|
1216
|
-
if (this.seconds = t, this.nanoseconds = e, e < 0) throw new
|
|
1217
|
-
if (e >= 1e9) throw new
|
|
1218
|
-
if (t < -62135596800) throw new
|
|
1216
|
+
if (this.seconds = t, this.nanoseconds = e, e < 0) throw new U(P, "Timestamp nanoseconds out of range: " + e);
|
|
1217
|
+
if (e >= 1e9) throw new U(P, "Timestamp nanoseconds out of range: " + e);
|
|
1218
|
+
if (t < -62135596800) throw new U(P, "Timestamp seconds out of range: " + t);
|
|
1219
1219
|
// This will break in the year 10,000.
|
|
1220
|
-
if (t >= 253402300800) throw new
|
|
1220
|
+
if (t >= 253402300800) throw new U(P, "Timestamp seconds out of range: " + t);
|
|
1221
1221
|
}
|
|
1222
1222
|
/**
|
|
1223
1223
|
* Creates a new timestamp with the current date, with millisecond precision.
|
|
1224
1224
|
*
|
|
1225
1225
|
* @returns a new timestamp representing the current date.
|
|
1226
1226
|
*/ static now() {
|
|
1227
|
-
return
|
|
1227
|
+
return bt.fromMillis(Date.now());
|
|
1228
1228
|
}
|
|
1229
1229
|
/**
|
|
1230
1230
|
* Creates a new timestamp from the given date.
|
|
@@ -1233,7 +1233,7 @@ class vt {
|
|
|
1233
1233
|
* @returns A new `Timestamp` representing the same point in time as the given
|
|
1234
1234
|
* date.
|
|
1235
1235
|
*/ static fromDate(t) {
|
|
1236
|
-
return
|
|
1236
|
+
return bt.fromMillis(t.getTime());
|
|
1237
1237
|
}
|
|
1238
1238
|
/**
|
|
1239
1239
|
* Creates a new timestamp from the given number of milliseconds.
|
|
@@ -1244,7 +1244,7 @@ class vt {
|
|
|
1244
1244
|
* number of milliseconds.
|
|
1245
1245
|
*/ static fromMillis(t) {
|
|
1246
1246
|
const e = Math.floor(t / 1e3), n = Math.floor(1e6 * (t - 1e3 * e));
|
|
1247
|
-
return new
|
|
1247
|
+
return new bt(e, n);
|
|
1248
1248
|
}
|
|
1249
1249
|
/**
|
|
1250
1250
|
* Converts a `Timestamp` to a JavaScript `Date` object. This conversion
|
|
@@ -1266,7 +1266,7 @@ class vt {
|
|
|
1266
1266
|
return 1e3 * this.seconds + this.nanoseconds / 1e6;
|
|
1267
1267
|
}
|
|
1268
1268
|
_compareTo(t) {
|
|
1269
|
-
return this.seconds === t.seconds ?
|
|
1269
|
+
return this.seconds === t.seconds ? gt(this.nanoseconds, t.nanoseconds) : gt(this.seconds, t.seconds);
|
|
1270
1270
|
}
|
|
1271
1271
|
/**
|
|
1272
1272
|
* Returns true if this `Timestamp` is equal to the provided one.
|
|
@@ -1322,18 +1322,18 @@ class vt {
|
|
|
1322
1322
|
/**
|
|
1323
1323
|
* A version of a document in Firestore. This corresponds to the version
|
|
1324
1324
|
* timestamp, such as update_time or read_time.
|
|
1325
|
-
*/ class
|
|
1325
|
+
*/ class Et {
|
|
1326
1326
|
constructor(t) {
|
|
1327
1327
|
this.timestamp = t;
|
|
1328
1328
|
}
|
|
1329
1329
|
static fromTimestamp(t) {
|
|
1330
|
-
return new
|
|
1330
|
+
return new Et(t);
|
|
1331
1331
|
}
|
|
1332
1332
|
static min() {
|
|
1333
|
-
return new
|
|
1333
|
+
return new Et(new bt(0, 0));
|
|
1334
1334
|
}
|
|
1335
1335
|
static max() {
|
|
1336
|
-
return new
|
|
1336
|
+
return new Et(new bt(253402300799, 999999999));
|
|
1337
1337
|
}
|
|
1338
1338
|
compareTo(t) {
|
|
1339
1339
|
return this.timestamp._compareTo(t.timestamp);
|
|
@@ -1368,13 +1368,13 @@ class vt {
|
|
|
1368
1368
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1369
1369
|
* See the License for the specific language governing permissions and
|
|
1370
1370
|
* limitations under the License.
|
|
1371
|
-
*/ function
|
|
1371
|
+
*/ function It(t) {
|
|
1372
1372
|
let e = 0;
|
|
1373
1373
|
for (const n in t) Object.prototype.hasOwnProperty.call(t, n) && e++;
|
|
1374
1374
|
return e;
|
|
1375
1375
|
}
|
|
1376
1376
|
|
|
1377
|
-
function
|
|
1377
|
+
function Tt(t, e) {
|
|
1378
1378
|
for (const n in t) Object.prototype.hasOwnProperty.call(t, n) && e(n, t[n]);
|
|
1379
1379
|
}
|
|
1380
1380
|
|
|
@@ -1396,17 +1396,17 @@ function It(t, e) {
|
|
|
1396
1396
|
*/
|
|
1397
1397
|
// An immutable sorted map implementation, based on a Left-leaning Red-Black
|
|
1398
1398
|
// tree.
|
|
1399
|
-
class
|
|
1399
|
+
class At {
|
|
1400
1400
|
constructor(t, e) {
|
|
1401
|
-
this.comparator = t, this.root = e ||
|
|
1401
|
+
this.comparator = t, this.root = e || Pt.EMPTY;
|
|
1402
1402
|
}
|
|
1403
1403
|
// Returns a copy of the map, with the specified key/value added or replaced.
|
|
1404
1404
|
insert(t, e) {
|
|
1405
|
-
return new
|
|
1405
|
+
return new At(this.comparator, this.root.insert(t, e, this.comparator).copy(null, null, Pt.BLACK, null, null));
|
|
1406
1406
|
}
|
|
1407
1407
|
// Returns a copy of the map, with the specified key removed.
|
|
1408
1408
|
remove(t) {
|
|
1409
|
-
return new
|
|
1409
|
+
return new At(this.comparator, this.root.remove(t, this.comparator).copy(null, null, Pt.BLACK, null, null));
|
|
1410
1410
|
}
|
|
1411
1411
|
// Returns the value of the node with the given key, or null.
|
|
1412
1412
|
get(t) {
|
|
@@ -1472,22 +1472,22 @@ class Tt {
|
|
|
1472
1472
|
}
|
|
1473
1473
|
// Returns an iterator over the SortedMap.
|
|
1474
1474
|
getIterator() {
|
|
1475
|
-
return new
|
|
1475
|
+
return new Rt(this.root, null, this.comparator, !1);
|
|
1476
1476
|
}
|
|
1477
1477
|
getIteratorFrom(t) {
|
|
1478
|
-
return new
|
|
1478
|
+
return new Rt(this.root, t, this.comparator, !1);
|
|
1479
1479
|
}
|
|
1480
1480
|
getReverseIterator() {
|
|
1481
|
-
return new
|
|
1481
|
+
return new Rt(this.root, null, this.comparator, !0);
|
|
1482
1482
|
}
|
|
1483
1483
|
getReverseIteratorFrom(t) {
|
|
1484
|
-
return new
|
|
1484
|
+
return new Rt(this.root, t, this.comparator, !0);
|
|
1485
1485
|
}
|
|
1486
1486
|
}
|
|
1487
1487
|
|
|
1488
1488
|
// end SortedMap
|
|
1489
1489
|
// An iterator over an LLRBNode.
|
|
1490
|
-
class
|
|
1490
|
+
class Rt {
|
|
1491
1491
|
constructor(t, e, n, r) {
|
|
1492
1492
|
this.isReverse = r, this.nodeStack = [];
|
|
1493
1493
|
let s = 1;
|
|
@@ -1532,14 +1532,14 @@ class At {
|
|
|
1532
1532
|
|
|
1533
1533
|
// end SortedMapIterator
|
|
1534
1534
|
// Represents a node in a Left-leaning Red-Black tree.
|
|
1535
|
-
class
|
|
1535
|
+
class Pt {
|
|
1536
1536
|
constructor(t, e, n, r, s) {
|
|
1537
|
-
this.key = t, this.value = e, this.color = null != n ? n :
|
|
1538
|
-
this.right = null != s ? s :
|
|
1537
|
+
this.key = t, this.value = e, this.color = null != n ? n : Pt.RED, this.left = null != r ? r : Pt.EMPTY,
|
|
1538
|
+
this.right = null != s ? s : Pt.EMPTY, this.size = this.left.size + 1 + this.right.size;
|
|
1539
1539
|
}
|
|
1540
1540
|
// Returns a copy of the current node, optionally replacing pieces of it.
|
|
1541
1541
|
copy(t, e, n, r, s) {
|
|
1542
|
-
return new
|
|
1542
|
+
return new Pt(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);
|
|
1543
1543
|
}
|
|
1544
1544
|
isEmpty() {
|
|
1545
1545
|
return !1;
|
|
@@ -1578,7 +1578,7 @@ class Rt {
|
|
|
1578
1578
|
r.fixUp();
|
|
1579
1579
|
}
|
|
1580
1580
|
removeMin() {
|
|
1581
|
-
if (this.left.isEmpty()) return
|
|
1581
|
+
if (this.left.isEmpty()) return Pt.EMPTY;
|
|
1582
1582
|
let t = this;
|
|
1583
1583
|
return t.left.isRed() || t.left.left.isRed() || (t = t.moveRedLeft()), t = t.copy(null, null, null, t.left.removeMin(), null),
|
|
1584
1584
|
t.fixUp();
|
|
@@ -1590,7 +1590,7 @@ class Rt {
|
|
|
1590
1590
|
r = r.copy(null, null, null, r.left.remove(t, e), null); else {
|
|
1591
1591
|
if (r.left.isRed() && (r = r.rotateRight()), r.right.isEmpty() || r.right.isRed() || r.right.left.isRed() || (r = r.moveRedRight()),
|
|
1592
1592
|
0 === e(t, r.key)) {
|
|
1593
|
-
if (r.right.isEmpty()) return
|
|
1593
|
+
if (r.right.isEmpty()) return Pt.EMPTY;
|
|
1594
1594
|
n = r.right.min(), r = r.copy(n.key, n.value, null, null, r.right.removeMin());
|
|
1595
1595
|
}
|
|
1596
1596
|
r = r.copy(null, null, null, null, r.right.remove(t, e));
|
|
@@ -1616,11 +1616,11 @@ class Rt {
|
|
|
1616
1616
|
return t.left.left.isRed() && (t = t.rotateRight(), t = t.colorFlip()), t;
|
|
1617
1617
|
}
|
|
1618
1618
|
rotateLeft() {
|
|
1619
|
-
const t = this.copy(null, null,
|
|
1619
|
+
const t = this.copy(null, null, Pt.RED, null, this.right.left);
|
|
1620
1620
|
return this.right.copy(null, null, this.color, t, null);
|
|
1621
1621
|
}
|
|
1622
1622
|
rotateRight() {
|
|
1623
|
-
const t = this.copy(null, null,
|
|
1623
|
+
const t = this.copy(null, null, Pt.RED, this.left.right, null);
|
|
1624
1624
|
return this.left.copy(null, null, this.color, null, t);
|
|
1625
1625
|
}
|
|
1626
1626
|
colorFlip() {
|
|
@@ -1635,10 +1635,10 @@ class Rt {
|
|
|
1635
1635
|
// In a balanced RB tree, the black-depth (number of black nodes) from root to
|
|
1636
1636
|
// leaves is equal on both sides. This function verifies that or asserts.
|
|
1637
1637
|
check() {
|
|
1638
|
-
if (this.isRed() && this.left.isRed()) throw
|
|
1639
|
-
if (this.right.isRed()) throw
|
|
1638
|
+
if (this.isRed() && this.left.isRed()) throw b();
|
|
1639
|
+
if (this.right.isRed()) throw b();
|
|
1640
1640
|
const t = this.left.check();
|
|
1641
|
-
if (t !== this.right.check()) throw
|
|
1641
|
+
if (t !== this.right.check()) throw b();
|
|
1642
1642
|
return t + (this.isRed() ? 0 : 1);
|
|
1643
1643
|
}
|
|
1644
1644
|
}
|
|
@@ -1646,29 +1646,29 @@ class Rt {
|
|
|
1646
1646
|
// end LLRBNode
|
|
1647
1647
|
// Empty node is shared between all LLRB trees.
|
|
1648
1648
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1649
|
-
|
|
1649
|
+
Pt.EMPTY = null, Pt.RED = !0, Pt.BLACK = !1;
|
|
1650
1650
|
|
|
1651
1651
|
// end LLRBEmptyNode
|
|
1652
|
-
|
|
1652
|
+
Pt.EMPTY = new
|
|
1653
1653
|
// Represents an empty node (a leaf node in the Red-Black Tree).
|
|
1654
1654
|
class {
|
|
1655
1655
|
constructor() {
|
|
1656
1656
|
this.size = 0;
|
|
1657
1657
|
}
|
|
1658
1658
|
get key() {
|
|
1659
|
-
throw
|
|
1659
|
+
throw b();
|
|
1660
1660
|
}
|
|
1661
1661
|
get value() {
|
|
1662
|
-
throw
|
|
1662
|
+
throw b();
|
|
1663
1663
|
}
|
|
1664
1664
|
get color() {
|
|
1665
|
-
throw
|
|
1665
|
+
throw b();
|
|
1666
1666
|
}
|
|
1667
1667
|
get left() {
|
|
1668
|
-
throw
|
|
1668
|
+
throw b();
|
|
1669
1669
|
}
|
|
1670
1670
|
get right() {
|
|
1671
|
-
throw
|
|
1671
|
+
throw b();
|
|
1672
1672
|
}
|
|
1673
1673
|
// Returns a copy of the current node.
|
|
1674
1674
|
copy(t, e, n, r, s) {
|
|
@@ -1676,7 +1676,7 @@ class {
|
|
|
1676
1676
|
}
|
|
1677
1677
|
// Returns a copy of the tree, with the specified key/value added.
|
|
1678
1678
|
insert(t, e, n) {
|
|
1679
|
-
return new
|
|
1679
|
+
return new Pt(t, e);
|
|
1680
1680
|
}
|
|
1681
1681
|
// Returns a copy of the tree, with the specified key removed.
|
|
1682
1682
|
remove(t, e) {
|
|
@@ -1732,9 +1732,9 @@ class {
|
|
|
1732
1732
|
* NOTE: if provided comparator returns 0 for two elements, we consider them to
|
|
1733
1733
|
* be equal!
|
|
1734
1734
|
*/
|
|
1735
|
-
class
|
|
1735
|
+
class Vt {
|
|
1736
1736
|
constructor(t) {
|
|
1737
|
-
this.comparator = t, this.data = new
|
|
1737
|
+
this.comparator = t, this.data = new At(this.comparator);
|
|
1738
1738
|
}
|
|
1739
1739
|
has(t) {
|
|
1740
1740
|
return null !== this.data.get(t);
|
|
@@ -1775,10 +1775,10 @@ class Pt {
|
|
|
1775
1775
|
return e.hasNext() ? e.getNext().key : null;
|
|
1776
1776
|
}
|
|
1777
1777
|
getIterator() {
|
|
1778
|
-
return new
|
|
1778
|
+
return new Nt(this.data.getIterator());
|
|
1779
1779
|
}
|
|
1780
1780
|
getIteratorFrom(t) {
|
|
1781
|
-
return new
|
|
1781
|
+
return new Nt(this.data.getIteratorFrom(t));
|
|
1782
1782
|
}
|
|
1783
1783
|
/** Inserts or updates an element */ add(t) {
|
|
1784
1784
|
return this.copy(this.data.remove(t).insert(t, !0));
|
|
@@ -1797,7 +1797,7 @@ class Pt {
|
|
|
1797
1797
|
})), e;
|
|
1798
1798
|
}
|
|
1799
1799
|
isEqual(t) {
|
|
1800
|
-
if (!(t instanceof
|
|
1800
|
+
if (!(t instanceof Vt)) return !1;
|
|
1801
1801
|
if (this.size !== t.size) return !1;
|
|
1802
1802
|
const e = this.data.getIterator(), n = t.data.getIterator();
|
|
1803
1803
|
for (;e.hasNext(); ) {
|
|
@@ -1817,12 +1817,12 @@ class Pt {
|
|
|
1817
1817
|
return this.forEach((e => t.push(e))), "SortedSet(" + t.toString() + ")";
|
|
1818
1818
|
}
|
|
1819
1819
|
copy(t) {
|
|
1820
|
-
const e = new
|
|
1820
|
+
const e = new Vt(this.comparator);
|
|
1821
1821
|
return e.data = t, e;
|
|
1822
1822
|
}
|
|
1823
1823
|
}
|
|
1824
1824
|
|
|
1825
|
-
class
|
|
1825
|
+
class Nt {
|
|
1826
1826
|
constructor(t) {
|
|
1827
1827
|
this.iter = t;
|
|
1828
1828
|
}
|
|
@@ -1859,24 +1859,24 @@ class Vt {
|
|
|
1859
1859
|
* foo.bar - Overwrites only the field bar of the object foo.
|
|
1860
1860
|
* If foo is not an object, foo is replaced with an object
|
|
1861
1861
|
* containing foo
|
|
1862
|
-
*/ class
|
|
1862
|
+
*/ class Dt {
|
|
1863
1863
|
constructor(t) {
|
|
1864
1864
|
this.fields = t,
|
|
1865
1865
|
// TODO(dimond): validation of FieldMask
|
|
1866
1866
|
// Sort the field mask to support `FieldMask.isEqual()` and assert below.
|
|
1867
|
-
t.sort(
|
|
1867
|
+
t.sort(nt.comparator);
|
|
1868
1868
|
}
|
|
1869
1869
|
static empty() {
|
|
1870
|
-
return new
|
|
1870
|
+
return new Dt([]);
|
|
1871
1871
|
}
|
|
1872
1872
|
/**
|
|
1873
1873
|
* Returns a new FieldMask object that is the result of adding all the given
|
|
1874
1874
|
* fields paths to this field mask.
|
|
1875
1875
|
*/ unionWith(t) {
|
|
1876
|
-
let e = new
|
|
1876
|
+
let e = new Vt(nt.comparator);
|
|
1877
1877
|
for (const t of this.fields) e = e.add(t);
|
|
1878
1878
|
for (const n of t) e = e.add(n);
|
|
1879
|
-
return new
|
|
1879
|
+
return new Dt(e.toArray());
|
|
1880
1880
|
}
|
|
1881
1881
|
/**
|
|
1882
1882
|
* Verifies that `fieldPath` is included by at least one field in this field
|
|
@@ -1888,7 +1888,7 @@ class Vt {
|
|
|
1888
1888
|
return !1;
|
|
1889
1889
|
}
|
|
1890
1890
|
isEqual(t) {
|
|
1891
|
-
return
|
|
1891
|
+
return vt(this.fields, t.fields, ((t, e) => t.isEqual(e)));
|
|
1892
1892
|
}
|
|
1893
1893
|
}
|
|
1894
1894
|
|
|
@@ -1934,13 +1934,13 @@ class Vt {
|
|
|
1934
1934
|
* before being sent as a proto.
|
|
1935
1935
|
* @internal
|
|
1936
1936
|
*/
|
|
1937
|
-
class
|
|
1937
|
+
class $t {
|
|
1938
1938
|
constructor(t) {
|
|
1939
1939
|
this.binaryString = t;
|
|
1940
1940
|
}
|
|
1941
1941
|
static fromBase64String(t) {
|
|
1942
1942
|
const e = atob(t);
|
|
1943
|
-
return new
|
|
1943
|
+
return new $t(e);
|
|
1944
1944
|
}
|
|
1945
1945
|
static fromUint8Array(t) {
|
|
1946
1946
|
// TODO(indexing); Remove the copy of the byte string here as this method
|
|
@@ -1957,7 +1957,7 @@ class Dt {
|
|
|
1957
1957
|
/**
|
|
1958
1958
|
* Helper function to convert a binary string to an Uint8Array.
|
|
1959
1959
|
*/ (t);
|
|
1960
|
-
return new
|
|
1960
|
+
return new $t(e);
|
|
1961
1961
|
}
|
|
1962
1962
|
[Symbol.iterator]() {
|
|
1963
1963
|
let t = 0;
|
|
@@ -2005,31 +2005,31 @@ class Dt {
|
|
|
2005
2005
|
return 2 * this.binaryString.length;
|
|
2006
2006
|
}
|
|
2007
2007
|
compareTo(t) {
|
|
2008
|
-
return
|
|
2008
|
+
return gt(this.binaryString, t.binaryString);
|
|
2009
2009
|
}
|
|
2010
2010
|
isEqual(t) {
|
|
2011
2011
|
return this.binaryString === t.binaryString;
|
|
2012
2012
|
}
|
|
2013
2013
|
}
|
|
2014
2014
|
|
|
2015
|
-
|
|
2015
|
+
$t.EMPTY_BYTE_STRING = new $t("");
|
|
2016
2016
|
|
|
2017
|
-
const
|
|
2017
|
+
const xt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
2018
2018
|
|
|
2019
2019
|
/**
|
|
2020
2020
|
* Converts the possible Proto values for a timestamp value into a "seconds and
|
|
2021
2021
|
* nanos" representation.
|
|
2022
|
-
*/ function
|
|
2022
|
+
*/ function Ft(t) {
|
|
2023
2023
|
// The json interface (for the browser) will return an iso timestamp string,
|
|
2024
2024
|
// while the proto js library (for node) will return a
|
|
2025
2025
|
// google.protobuf.Timestamp instance.
|
|
2026
|
-
if (
|
|
2026
|
+
if (E(!!t), "string" == typeof t) {
|
|
2027
2027
|
// The date string can have higher precision (nanos) than the Date class
|
|
2028
2028
|
// (millis), so we do some custom parsing here.
|
|
2029
2029
|
// Parse the nanos right out of the string.
|
|
2030
2030
|
let e = 0;
|
|
2031
|
-
const n =
|
|
2032
|
-
if (
|
|
2031
|
+
const n = xt.exec(t);
|
|
2032
|
+
if (E(!!n), n[1]) {
|
|
2033
2033
|
// Pad the fraction out to 9 digits (nanos).
|
|
2034
2034
|
let t = n[1];
|
|
2035
2035
|
t = (t + "000000000").substr(0, 9), e = Number(t);
|
|
@@ -2042,21 +2042,21 @@ const $t = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
2042
2042
|
};
|
|
2043
2043
|
}
|
|
2044
2044
|
return {
|
|
2045
|
-
seconds:
|
|
2046
|
-
nanos:
|
|
2045
|
+
seconds: St(t.seconds),
|
|
2046
|
+
nanos: St(t.nanos)
|
|
2047
2047
|
};
|
|
2048
2048
|
}
|
|
2049
2049
|
|
|
2050
2050
|
/**
|
|
2051
2051
|
* Converts the possible Proto types for numbers into a JavaScript number.
|
|
2052
2052
|
* Returns 0 if the value is not numeric.
|
|
2053
|
-
*/ function
|
|
2053
|
+
*/ function St(t) {
|
|
2054
2054
|
// TODO(bjornick): Handle int64 greater than 53 bits.
|
|
2055
2055
|
return "number" == typeof t ? t : "string" == typeof t ? Number(t) : 0;
|
|
2056
2056
|
}
|
|
2057
2057
|
|
|
2058
|
-
/** Converts the possible Proto types for Blobs into a ByteString. */ function
|
|
2059
|
-
return "string" == typeof t ?
|
|
2058
|
+
/** Converts the possible Proto types for Blobs into a ByteString. */ function qt(t) {
|
|
2059
|
+
return "string" == typeof t ? $t.fromBase64String(t) : $t.fromUint8Array(t);
|
|
2060
2060
|
}
|
|
2061
2061
|
|
|
2062
2062
|
/**
|
|
@@ -2092,7 +2092,7 @@ const $t = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
2092
2092
|
* FieldValueOptions to value().
|
|
2093
2093
|
* - With respect to other ServerTimestampValues, they sort by their
|
|
2094
2094
|
* localWriteTime.
|
|
2095
|
-
*/ function
|
|
2095
|
+
*/ function Ot(t) {
|
|
2096
2096
|
var e, n;
|
|
2097
2097
|
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);
|
|
2098
2098
|
}
|
|
@@ -2102,16 +2102,16 @@ const $t = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
2102
2102
|
*
|
|
2103
2103
|
* Preserving the previous values allows the user to display the last resoled
|
|
2104
2104
|
* value until the backend responds with the timestamp.
|
|
2105
|
-
*/ function
|
|
2105
|
+
*/ function kt(t) {
|
|
2106
2106
|
const e = t.mapValue.fields.__previous_value__;
|
|
2107
|
-
return
|
|
2107
|
+
return Ot(e) ? kt(e) : e;
|
|
2108
2108
|
}
|
|
2109
2109
|
|
|
2110
2110
|
/**
|
|
2111
2111
|
* Returns the local time at which this timestamp was first set.
|
|
2112
|
-
*/ function
|
|
2113
|
-
const e =
|
|
2114
|
-
return new
|
|
2112
|
+
*/ function Ct(t) {
|
|
2113
|
+
const e = Ft(t.mapValue.fields.__local_write_time__.timestampValue);
|
|
2114
|
+
return new bt(e.seconds, e.nanos);
|
|
2115
2115
|
}
|
|
2116
2116
|
|
|
2117
2117
|
/**
|
|
@@ -2129,7 +2129,7 @@ const $t = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
2129
2129
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2130
2130
|
* See the License for the specific language governing permissions and
|
|
2131
2131
|
* limitations under the License.
|
|
2132
|
-
*/ const
|
|
2132
|
+
*/ const Lt = {
|
|
2133
2133
|
fields: {
|
|
2134
2134
|
__type__: {
|
|
2135
2135
|
stringValue: "__max__"
|
|
@@ -2138,8 +2138,8 @@ const $t = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
2138
2138
|
};
|
|
2139
2139
|
|
|
2140
2140
|
/** Extracts the backend's type order for the provided value. */
|
|
2141
|
-
function
|
|
2142
|
-
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 ?
|
|
2141
|
+
function Mt(t) {
|
|
2142
|
+
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 ? Ot(t) ? 4 /* ServerTimestampValue */ :
|
|
2143
2143
|
/** Returns true if the Value represents the canonical {@link #MAX_VALUE} . */
|
|
2144
2144
|
function(t) {
|
|
2145
2145
|
return "__max__" === (((t.mapValue || {}).fields || {}).__type__ || {}).stringValue;
|
|
@@ -2163,13 +2163,13 @@ function Lt(t) {
|
|
|
2163
2163
|
/**
|
|
2164
2164
|
* An ObjectValue represents a MapValue in the Firestore Proto and offers the
|
|
2165
2165
|
* ability to add and remove fields (via the ObjectValueBuilder).
|
|
2166
|
-
*/ (t) ? 9007199254740991 /* MaxValue */ : 10 /* ObjectValue */ :
|
|
2166
|
+
*/ (t) ? 9007199254740991 /* MaxValue */ : 10 /* ObjectValue */ : b();
|
|
2167
2167
|
}
|
|
2168
2168
|
|
|
2169
|
-
/** Tests `left` and `right` for equality based on the backend semantics. */ function
|
|
2169
|
+
/** Tests `left` and `right` for equality based on the backend semantics. */ function Ut(t, e) {
|
|
2170
2170
|
if (t === e) return !0;
|
|
2171
|
-
const n =
|
|
2172
|
-
if (n !==
|
|
2171
|
+
const n = Mt(t);
|
|
2172
|
+
if (n !== Mt(e)) return !1;
|
|
2173
2173
|
switch (n) {
|
|
2174
2174
|
case 0 /* NullValue */ :
|
|
2175
2175
|
case 9007199254740991 /* MaxValue */ :
|
|
@@ -2179,14 +2179,14 @@ function Lt(t) {
|
|
|
2179
2179
|
return t.booleanValue === e.booleanValue;
|
|
2180
2180
|
|
|
2181
2181
|
case 4 /* ServerTimestampValue */ :
|
|
2182
|
-
return
|
|
2182
|
+
return Ct(t).isEqual(Ct(e));
|
|
2183
2183
|
|
|
2184
2184
|
case 3 /* TimestampValue */ :
|
|
2185
2185
|
return function(t, e) {
|
|
2186
2186
|
if ("string" == typeof t.timestampValue && "string" == typeof e.timestampValue && t.timestampValue.length === e.timestampValue.length)
|
|
2187
2187
|
// Use string equality for ISO 8601 timestamps
|
|
2188
2188
|
return t.timestampValue === e.timestampValue;
|
|
2189
|
-
const n =
|
|
2189
|
+
const n = Ft(t.timestampValue), r = Ft(e.timestampValue);
|
|
2190
2190
|
return n.seconds === r.seconds && n.nanos === r.nanos;
|
|
2191
2191
|
}(t, e);
|
|
2192
2192
|
|
|
@@ -2195,7 +2195,7 @@ function Lt(t) {
|
|
|
2195
2195
|
|
|
2196
2196
|
case 6 /* BlobValue */ :
|
|
2197
2197
|
return function(t, e) {
|
|
2198
|
-
return
|
|
2198
|
+
return qt(t.bytesValue).isEqual(qt(e.bytesValue));
|
|
2199
2199
|
}(t, e);
|
|
2200
2200
|
|
|
2201
2201
|
case 7 /* RefValue */ :
|
|
@@ -2203,72 +2203,72 @@ function Lt(t) {
|
|
|
2203
2203
|
|
|
2204
2204
|
case 8 /* GeoPointValue */ :
|
|
2205
2205
|
return function(t, e) {
|
|
2206
|
-
return
|
|
2206
|
+
return St(t.geoPointValue.latitude) === St(e.geoPointValue.latitude) && St(t.geoPointValue.longitude) === St(e.geoPointValue.longitude);
|
|
2207
2207
|
}(t, e);
|
|
2208
2208
|
|
|
2209
2209
|
case 2 /* NumberValue */ :
|
|
2210
2210
|
return function(t, e) {
|
|
2211
|
-
if ("integerValue" in t && "integerValue" in e) return
|
|
2211
|
+
if ("integerValue" in t && "integerValue" in e) return St(t.integerValue) === St(e.integerValue);
|
|
2212
2212
|
if ("doubleValue" in t && "doubleValue" in e) {
|
|
2213
|
-
const n =
|
|
2214
|
-
return n === r ?
|
|
2213
|
+
const n = St(t.doubleValue), r = St(e.doubleValue);
|
|
2214
|
+
return n === r ? lt(n) === lt(r) : isNaN(n) && isNaN(r);
|
|
2215
2215
|
}
|
|
2216
2216
|
return !1;
|
|
2217
2217
|
}(t, e);
|
|
2218
2218
|
|
|
2219
2219
|
case 9 /* ArrayValue */ :
|
|
2220
|
-
return
|
|
2220
|
+
return vt(t.arrayValue.values || [], e.arrayValue.values || [], Ut);
|
|
2221
2221
|
|
|
2222
2222
|
case 10 /* ObjectValue */ :
|
|
2223
2223
|
return function(t, e) {
|
|
2224
2224
|
const n = t.mapValue.fields || {}, r = e.mapValue.fields || {};
|
|
2225
|
-
if (
|
|
2226
|
-
for (const t in n) if (n.hasOwnProperty(t) && (void 0 === r[t] || !
|
|
2225
|
+
if (It(n) !== It(r)) return !1;
|
|
2226
|
+
for (const t in n) if (n.hasOwnProperty(t) && (void 0 === r[t] || !Ut(n[t], r[t]))) return !1;
|
|
2227
2227
|
return !0;
|
|
2228
2228
|
}
|
|
2229
2229
|
/** Returns true if the ArrayValue contains the specified element. */ (t, e);
|
|
2230
2230
|
|
|
2231
2231
|
default:
|
|
2232
|
-
return
|
|
2232
|
+
return b();
|
|
2233
2233
|
}
|
|
2234
2234
|
}
|
|
2235
2235
|
|
|
2236
|
-
function
|
|
2237
|
-
return void 0 !== (t.values || []).find((t =>
|
|
2236
|
+
function jt(t, e) {
|
|
2237
|
+
return void 0 !== (t.values || []).find((t => Ut(t, e)));
|
|
2238
2238
|
}
|
|
2239
2239
|
|
|
2240
|
-
function
|
|
2240
|
+
function Bt(t, e) {
|
|
2241
2241
|
if (t === e) return 0;
|
|
2242
|
-
const n =
|
|
2243
|
-
if (n !== r) return
|
|
2242
|
+
const n = Mt(t), r = Mt(e);
|
|
2243
|
+
if (n !== r) return gt(n, r);
|
|
2244
2244
|
switch (n) {
|
|
2245
2245
|
case 0 /* NullValue */ :
|
|
2246
2246
|
case 9007199254740991 /* MaxValue */ :
|
|
2247
2247
|
return 0;
|
|
2248
2248
|
|
|
2249
2249
|
case 1 /* BooleanValue */ :
|
|
2250
|
-
return
|
|
2250
|
+
return gt(t.booleanValue, e.booleanValue);
|
|
2251
2251
|
|
|
2252
2252
|
case 2 /* NumberValue */ :
|
|
2253
2253
|
return function(t, e) {
|
|
2254
|
-
const n =
|
|
2254
|
+
const n = St(t.integerValue || t.doubleValue), r = St(e.integerValue || e.doubleValue);
|
|
2255
2255
|
return n < r ? -1 : n > r ? 1 : n === r ? 0 :
|
|
2256
2256
|
// one or both are NaN.
|
|
2257
2257
|
isNaN(n) ? isNaN(r) ? 0 : -1 : 1;
|
|
2258
2258
|
}(t, e);
|
|
2259
2259
|
|
|
2260
2260
|
case 3 /* TimestampValue */ :
|
|
2261
|
-
return
|
|
2261
|
+
return Qt(t.timestampValue, e.timestampValue);
|
|
2262
2262
|
|
|
2263
2263
|
case 4 /* ServerTimestampValue */ :
|
|
2264
|
-
return
|
|
2264
|
+
return Qt(Ct(t), Ct(e));
|
|
2265
2265
|
|
|
2266
2266
|
case 5 /* StringValue */ :
|
|
2267
|
-
return
|
|
2267
|
+
return gt(t.stringValue, e.stringValue);
|
|
2268
2268
|
|
|
2269
2269
|
case 6 /* BlobValue */ :
|
|
2270
2270
|
return function(t, e) {
|
|
2271
|
-
const n =
|
|
2271
|
+
const n = qt(t), r = qt(e);
|
|
2272
2272
|
return n.compareTo(r);
|
|
2273
2273
|
}(t.bytesValue, e.bytesValue);
|
|
2274
2274
|
|
|
@@ -2276,34 +2276,34 @@ function jt(t, e) {
|
|
|
2276
2276
|
return function(t, e) {
|
|
2277
2277
|
const n = t.split("/"), r = e.split("/");
|
|
2278
2278
|
for (let t = 0; t < n.length && t < r.length; t++) {
|
|
2279
|
-
const e =
|
|
2279
|
+
const e = gt(n[t], r[t]);
|
|
2280
2280
|
if (0 !== e) return e;
|
|
2281
2281
|
}
|
|
2282
|
-
return
|
|
2282
|
+
return gt(n.length, r.length);
|
|
2283
2283
|
}(t.referenceValue, e.referenceValue);
|
|
2284
2284
|
|
|
2285
2285
|
case 8 /* GeoPointValue */ :
|
|
2286
2286
|
return function(t, e) {
|
|
2287
|
-
const n =
|
|
2287
|
+
const n = gt(St(t.latitude), St(e.latitude));
|
|
2288
2288
|
if (0 !== n) return n;
|
|
2289
|
-
return
|
|
2289
|
+
return gt(St(t.longitude), St(e.longitude));
|
|
2290
2290
|
}(t.geoPointValue, e.geoPointValue);
|
|
2291
2291
|
|
|
2292
2292
|
case 9 /* ArrayValue */ :
|
|
2293
2293
|
return function(t, e) {
|
|
2294
2294
|
const n = t.values || [], r = e.values || [];
|
|
2295
2295
|
for (let t = 0; t < n.length && t < r.length; ++t) {
|
|
2296
|
-
const e =
|
|
2296
|
+
const e = Bt(n[t], r[t]);
|
|
2297
2297
|
if (e) return e;
|
|
2298
2298
|
}
|
|
2299
|
-
return
|
|
2299
|
+
return gt(n.length, r.length);
|
|
2300
2300
|
}(t.arrayValue, e.arrayValue);
|
|
2301
2301
|
|
|
2302
2302
|
case 10 /* ObjectValue */ :
|
|
2303
2303
|
return function(t, e) {
|
|
2304
|
-
if (t ===
|
|
2305
|
-
if (t ===
|
|
2306
|
-
if (e ===
|
|
2304
|
+
if (t === Lt && e === Lt) return 0;
|
|
2305
|
+
if (t === Lt) return 1;
|
|
2306
|
+
if (e === Lt) return -1;
|
|
2307
2307
|
const n = t.fields || {}, r = Object.keys(n), s = e.fields || {}, i = Object.keys(s);
|
|
2308
2308
|
// Even though MapValues are likely sorted correctly based on their insertion
|
|
2309
2309
|
// order (e.g. when received from the backend), local modifications can bring
|
|
@@ -2311,49 +2311,49 @@ function jt(t, e) {
|
|
|
2311
2311
|
// canonical IDs are independent of insertion order.
|
|
2312
2312
|
r.sort(), i.sort();
|
|
2313
2313
|
for (let t = 0; t < r.length && t < i.length; ++t) {
|
|
2314
|
-
const e =
|
|
2314
|
+
const e = gt(r[t], i[t]);
|
|
2315
2315
|
if (0 !== e) return e;
|
|
2316
|
-
const o =
|
|
2316
|
+
const o = Bt(n[r[t]], s[i[t]]);
|
|
2317
2317
|
if (0 !== o) return o;
|
|
2318
2318
|
}
|
|
2319
|
-
return
|
|
2319
|
+
return gt(r.length, i.length);
|
|
2320
2320
|
}
|
|
2321
2321
|
/** Returns a reference value for the provided database and key. */ (t.mapValue, e.mapValue);
|
|
2322
2322
|
|
|
2323
2323
|
default:
|
|
2324
|
-
throw
|
|
2324
|
+
throw b();
|
|
2325
2325
|
}
|
|
2326
2326
|
}
|
|
2327
2327
|
|
|
2328
|
-
function
|
|
2329
|
-
if ("string" == typeof t && "string" == typeof e && t.length === e.length) return
|
|
2330
|
-
const n =
|
|
2331
|
-
return 0 !== s ? s :
|
|
2328
|
+
function Qt(t, e) {
|
|
2329
|
+
if ("string" == typeof t && "string" == typeof e && t.length === e.length) return gt(t, e);
|
|
2330
|
+
const n = Ft(t), r = Ft(e), s = gt(n.seconds, r.seconds);
|
|
2331
|
+
return 0 !== s ? s : gt(n.nanos, r.nanos);
|
|
2332
2332
|
}
|
|
2333
2333
|
|
|
2334
|
-
function
|
|
2334
|
+
function zt(t, e) {
|
|
2335
2335
|
return {
|
|
2336
2336
|
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${e.path.canonicalString()}`
|
|
2337
2337
|
};
|
|
2338
2338
|
}
|
|
2339
2339
|
|
|
2340
|
-
/** Returns true if `value` is an ArrayValue. */ function
|
|
2340
|
+
/** Returns true if `value` is an ArrayValue. */ function Gt(t) {
|
|
2341
2341
|
return !!t && "arrayValue" in t;
|
|
2342
2342
|
}
|
|
2343
2343
|
|
|
2344
|
-
/** Returns true if `value` is a NullValue. */ function
|
|
2344
|
+
/** Returns true if `value` is a NullValue. */ function Wt(t) {
|
|
2345
2345
|
return !!t && "nullValue" in t;
|
|
2346
2346
|
}
|
|
2347
2347
|
|
|
2348
|
-
/** Returns true if `value` is NaN. */ function
|
|
2348
|
+
/** Returns true if `value` is NaN. */ function Kt(t) {
|
|
2349
2349
|
return !!t && "doubleValue" in t && isNaN(Number(t.doubleValue));
|
|
2350
2350
|
}
|
|
2351
2351
|
|
|
2352
|
-
/** Returns true if `value` is a MapValue. */ function
|
|
2352
|
+
/** Returns true if `value` is a MapValue. */ function Yt(t) {
|
|
2353
2353
|
return !!t && "mapValue" in t;
|
|
2354
2354
|
}
|
|
2355
2355
|
|
|
2356
|
-
/** Creates a deep copy of `source`. */ function
|
|
2356
|
+
/** Creates a deep copy of `source`. */ function Ht(t) {
|
|
2357
2357
|
if (t.geoPointValue) return {
|
|
2358
2358
|
geoPointValue: Object.assign({}, t.geoPointValue)
|
|
2359
2359
|
};
|
|
@@ -2366,7 +2366,7 @@ function Qt(t, e) {
|
|
|
2366
2366
|
fields: {}
|
|
2367
2367
|
}
|
|
2368
2368
|
};
|
|
2369
|
-
return
|
|
2369
|
+
return Tt(t.mapValue.fields, ((t, n) => e.mapValue.fields[t] = Ht(n))), e;
|
|
2370
2370
|
}
|
|
2371
2371
|
if (t.arrayValue) {
|
|
2372
2372
|
const e = {
|
|
@@ -2374,18 +2374,18 @@ function Qt(t, e) {
|
|
|
2374
2374
|
values: []
|
|
2375
2375
|
}
|
|
2376
2376
|
};
|
|
2377
|
-
for (let n = 0; n < (t.arrayValue.values || []).length; ++n) e.arrayValue.values[n] =
|
|
2377
|
+
for (let n = 0; n < (t.arrayValue.values || []).length; ++n) e.arrayValue.values[n] = Ht(t.arrayValue.values[n]);
|
|
2378
2378
|
return e;
|
|
2379
2379
|
}
|
|
2380
2380
|
return Object.assign({}, t);
|
|
2381
2381
|
}
|
|
2382
2382
|
|
|
2383
|
-
class
|
|
2383
|
+
class Jt {
|
|
2384
2384
|
constructor(t) {
|
|
2385
2385
|
this.value = t;
|
|
2386
2386
|
}
|
|
2387
2387
|
static empty() {
|
|
2388
|
-
return new
|
|
2388
|
+
return new Jt({
|
|
2389
2389
|
mapValue: {}
|
|
2390
2390
|
});
|
|
2391
2391
|
}
|
|
@@ -2399,7 +2399,7 @@ class Ht {
|
|
|
2399
2399
|
{
|
|
2400
2400
|
let e = this.value;
|
|
2401
2401
|
for (let n = 0; n < t.length - 1; ++n) if (e = (e.mapValue.fields || {})[t.get(n)],
|
|
2402
|
-
!
|
|
2402
|
+
!Yt(e)) return null;
|
|
2403
2403
|
return e = (e.mapValue.fields || {})[t.lastSegment()], e || null;
|
|
2404
2404
|
}
|
|
2405
2405
|
}
|
|
@@ -2409,21 +2409,21 @@ class Ht {
|
|
|
2409
2409
|
* @param path - The field path to set.
|
|
2410
2410
|
* @param value - The value to set.
|
|
2411
2411
|
*/ set(t, e) {
|
|
2412
|
-
this.getFieldsMap(t.popLast())[t.lastSegment()] =
|
|
2412
|
+
this.getFieldsMap(t.popLast())[t.lastSegment()] = Ht(e);
|
|
2413
2413
|
}
|
|
2414
2414
|
/**
|
|
2415
2415
|
* Sets the provided fields to the provided values.
|
|
2416
2416
|
*
|
|
2417
2417
|
* @param data - A map of fields to values (or null for deletes).
|
|
2418
2418
|
*/ setAll(t) {
|
|
2419
|
-
let e =
|
|
2419
|
+
let e = nt.emptyPath(), n = {}, r = [];
|
|
2420
2420
|
t.forEach(((t, s) => {
|
|
2421
2421
|
if (!e.isImmediateParentOf(s)) {
|
|
2422
2422
|
// Insert the accumulated changes at this parent location
|
|
2423
2423
|
const t = this.getFieldsMap(e);
|
|
2424
2424
|
this.applyChanges(t, n, r), n = {}, r = [], e = s.popLast();
|
|
2425
2425
|
}
|
|
2426
|
-
t ? n[s.lastSegment()] =
|
|
2426
|
+
t ? n[s.lastSegment()] = Ht(t) : r.push(s.lastSegment());
|
|
2427
2427
|
}));
|
|
2428
2428
|
const s = this.getFieldsMap(e);
|
|
2429
2429
|
this.applyChanges(s, n, r);
|
|
@@ -2435,10 +2435,10 @@ class Ht {
|
|
|
2435
2435
|
* @param path - The field path to remove.
|
|
2436
2436
|
*/ delete(t) {
|
|
2437
2437
|
const e = this.field(t.popLast());
|
|
2438
|
-
|
|
2438
|
+
Yt(e) && e.mapValue.fields && delete e.mapValue.fields[t.lastSegment()];
|
|
2439
2439
|
}
|
|
2440
2440
|
isEqual(t) {
|
|
2441
|
-
return
|
|
2441
|
+
return Ut(this.value, t.value);
|
|
2442
2442
|
}
|
|
2443
2443
|
/**
|
|
2444
2444
|
* Returns the map that contains the leaf element of `path`. If the parent
|
|
@@ -2450,7 +2450,7 @@ class Ht {
|
|
|
2450
2450
|
});
|
|
2451
2451
|
for (let n = 0; n < t.length; ++n) {
|
|
2452
2452
|
let r = e.mapValue.fields[t.get(n)];
|
|
2453
|
-
|
|
2453
|
+
Yt(r) && r.mapValue.fields || (r = {
|
|
2454
2454
|
mapValue: {
|
|
2455
2455
|
fields: {}
|
|
2456
2456
|
}
|
|
@@ -2462,11 +2462,11 @@ class Ht {
|
|
|
2462
2462
|
* Modifies `fieldsMap` by adding, replacing or deleting the specified
|
|
2463
2463
|
* entries.
|
|
2464
2464
|
*/ applyChanges(t, e, n) {
|
|
2465
|
-
|
|
2465
|
+
Tt(e, ((e, n) => t[e] = n));
|
|
2466
2466
|
for (const e of n) delete t[e];
|
|
2467
2467
|
}
|
|
2468
2468
|
clone() {
|
|
2469
|
-
return new Ht(
|
|
2469
|
+
return new Jt(Ht(this.value));
|
|
2470
2470
|
}
|
|
2471
2471
|
}
|
|
2472
2472
|
|
|
@@ -2495,7 +2495,7 @@ class Ht {
|
|
|
2495
2495
|
* not transition to one of these states even after all mutations have been
|
|
2496
2496
|
* applied, `isValidDocument()` returns false and the document should be removed
|
|
2497
2497
|
* from all views.
|
|
2498
|
-
*/ class
|
|
2498
|
+
*/ class Xt {
|
|
2499
2499
|
constructor(t, e, n, r, s, i) {
|
|
2500
2500
|
this.key = t, this.documentType = e, this.version = n, this.readTime = r, this.data = s,
|
|
2501
2501
|
this.documentState = i;
|
|
@@ -2504,23 +2504,23 @@ class Ht {
|
|
|
2504
2504
|
* Creates a document with no known version or data, but which can serve as
|
|
2505
2505
|
* base document for mutations.
|
|
2506
2506
|
*/ static newInvalidDocument(t) {
|
|
2507
|
-
return new
|
|
2507
|
+
return new Xt(t, 0 /* INVALID */ , Et.min(), Et.min(), Jt.empty(), 0 /* SYNCED */);
|
|
2508
2508
|
}
|
|
2509
2509
|
/**
|
|
2510
2510
|
* Creates a new document that is known to exist with the given data at the
|
|
2511
2511
|
* given version.
|
|
2512
2512
|
*/ static newFoundDocument(t, e, n) {
|
|
2513
|
-
return new
|
|
2513
|
+
return new Xt(t, 1 /* FOUND_DOCUMENT */ , e, Et.min(), n, 0 /* SYNCED */);
|
|
2514
2514
|
}
|
|
2515
2515
|
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t, e) {
|
|
2516
|
-
return new
|
|
2516
|
+
return new Xt(t, 2 /* NO_DOCUMENT */ , e, Et.min(), Jt.empty(), 0 /* SYNCED */);
|
|
2517
2517
|
}
|
|
2518
2518
|
/**
|
|
2519
2519
|
* Creates a new document that is known to exist at the given version but
|
|
2520
2520
|
* whose data is not known (e.g. a document that was updated without a known
|
|
2521
2521
|
* base document).
|
|
2522
2522
|
*/ static newUnknownDocument(t, e) {
|
|
2523
|
-
return new
|
|
2523
|
+
return new Xt(t, 3 /* UNKNOWN_DOCUMENT */ , e, Et.min(), Jt.empty(), 2 /* HAS_COMMITTED_MUTATIONS */);
|
|
2524
2524
|
}
|
|
2525
2525
|
/**
|
|
2526
2526
|
* Changes the document type to indicate that it exists and that its version
|
|
@@ -2533,7 +2533,7 @@ class Ht {
|
|
|
2533
2533
|
* Changes the document type to indicate that it doesn't exist at the given
|
|
2534
2534
|
* version.
|
|
2535
2535
|
*/ convertToNoDocument(t) {
|
|
2536
|
-
return this.version = t, this.documentType = 2 /* NO_DOCUMENT */ , this.data =
|
|
2536
|
+
return this.version = t, this.documentType = 2 /* NO_DOCUMENT */ , this.data = Jt.empty(),
|
|
2537
2537
|
this.documentState = 0 /* SYNCED */ , this;
|
|
2538
2538
|
}
|
|
2539
2539
|
/**
|
|
@@ -2541,14 +2541,14 @@ class Ht {
|
|
|
2541
2541
|
* that its data is not known (e.g. a document that was updated without a known
|
|
2542
2542
|
* base document).
|
|
2543
2543
|
*/ convertToUnknownDocument(t) {
|
|
2544
|
-
return this.version = t, this.documentType = 3 /* UNKNOWN_DOCUMENT */ , this.data =
|
|
2544
|
+
return this.version = t, this.documentType = 3 /* UNKNOWN_DOCUMENT */ , this.data = Jt.empty(),
|
|
2545
2545
|
this.documentState = 2 /* HAS_COMMITTED_MUTATIONS */ , this;
|
|
2546
2546
|
}
|
|
2547
2547
|
setHasCommittedMutations() {
|
|
2548
2548
|
return this.documentState = 2 /* HAS_COMMITTED_MUTATIONS */ , this;
|
|
2549
2549
|
}
|
|
2550
2550
|
setHasLocalMutations() {
|
|
2551
|
-
return this.documentState = 1 /* HAS_LOCAL_MUTATIONS */ , this.version =
|
|
2551
|
+
return this.documentState = 1 /* HAS_LOCAL_MUTATIONS */ , this.version = Et.min(),
|
|
2552
2552
|
this;
|
|
2553
2553
|
}
|
|
2554
2554
|
setReadTime(t) {
|
|
@@ -2576,10 +2576,10 @@ class Ht {
|
|
|
2576
2576
|
return 3 /* UNKNOWN_DOCUMENT */ === this.documentType;
|
|
2577
2577
|
}
|
|
2578
2578
|
isEqual(t) {
|
|
2579
|
-
return t instanceof
|
|
2579
|
+
return t instanceof Xt && this.key.isEqual(t.key) && this.version.isEqual(t.version) && this.documentType === t.documentType && this.documentState === t.documentState && this.data.isEqual(t.data);
|
|
2580
2580
|
}
|
|
2581
2581
|
mutableCopy() {
|
|
2582
|
-
return new
|
|
2582
|
+
return new Xt(this.key, this.documentType, this.version, this.readTime, this.data.clone(), this.documentState);
|
|
2583
2583
|
}
|
|
2584
2584
|
toString() {
|
|
2585
2585
|
return `Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`;
|
|
@@ -2603,7 +2603,7 @@ class Ht {
|
|
|
2603
2603
|
* limitations under the License.
|
|
2604
2604
|
*/
|
|
2605
2605
|
// Visible for testing
|
|
2606
|
-
class
|
|
2606
|
+
class Zt {
|
|
2607
2607
|
constructor(t, e = null, n = [], r = [], s = null, i = null, o = null) {
|
|
2608
2608
|
this.path = t, this.collectionGroup = e, this.orderBy = n, this.filters = r, this.limit = s,
|
|
2609
2609
|
this.startAt = i, this.endAt = o, this.$ = null;
|
|
@@ -2617,26 +2617,26 @@ class Xt {
|
|
|
2617
2617
|
* NOTE: you should always construct `Target` from `Query.toTarget` instead of
|
|
2618
2618
|
* using this factory method, because `Query` provides an implicit `orderBy`
|
|
2619
2619
|
* property.
|
|
2620
|
-
*/ function
|
|
2621
|
-
return new
|
|
2620
|
+
*/ function te(t, e = null, n = [], r = [], s = null, i = null, o = null) {
|
|
2621
|
+
return new Zt(t, e, n, r, s, i, o);
|
|
2622
2622
|
}
|
|
2623
2623
|
|
|
2624
|
-
class
|
|
2624
|
+
class ee extends class {} {
|
|
2625
2625
|
constructor(t, e, n) {
|
|
2626
2626
|
super(), this.field = t, this.op = e, this.value = n;
|
|
2627
2627
|
}
|
|
2628
2628
|
/**
|
|
2629
2629
|
* Creates a filter based on the provided arguments.
|
|
2630
2630
|
*/ static create(t, e, n) {
|
|
2631
|
-
return t.isKeyField() ? "in" /* IN */ === e || "not-in" /* NOT_IN */ === e ? this.F(t, e, n) : new
|
|
2631
|
+
return t.isKeyField() ? "in" /* IN */ === e || "not-in" /* NOT_IN */ === e ? this.F(t, e, n) : new ne(t, e, n) : "array-contains" /* ARRAY_CONTAINS */ === e ? new oe(t, n) : "in" /* IN */ === e ? new ue(t, n) : "not-in" /* NOT_IN */ === e ? new ce(t, n) : "array-contains-any" /* ARRAY_CONTAINS_ANY */ === e ? new ae(t, n) : new ee(t, e, n);
|
|
2632
2632
|
}
|
|
2633
2633
|
static F(t, e, n) {
|
|
2634
|
-
return "in" /* IN */ === e ? new
|
|
2634
|
+
return "in" /* IN */ === e ? new re(t, n) : new se(t, n);
|
|
2635
2635
|
}
|
|
2636
2636
|
matches(t) {
|
|
2637
2637
|
const e = t.data.field(this.field);
|
|
2638
2638
|
// Types do not have to match in NOT_EQUAL filters.
|
|
2639
|
-
return "!=" /* NOT_EQUAL */ === this.op ? null !== e && this.S(
|
|
2639
|
+
return "!=" /* NOT_EQUAL */ === this.op ? null !== e && this.S(Bt(e, this.value)) : null !== e && Mt(this.value) === Mt(e) && this.S(Bt(e, this.value));
|
|
2640
2640
|
// Only compare types with matching backend order (such as double and int).
|
|
2641
2641
|
}
|
|
2642
2642
|
S(t) {
|
|
@@ -2660,7 +2660,7 @@ class te extends class {} {
|
|
|
2660
2660
|
return t >= 0;
|
|
2661
2661
|
|
|
2662
2662
|
default:
|
|
2663
|
-
return
|
|
2663
|
+
return b();
|
|
2664
2664
|
}
|
|
2665
2665
|
}
|
|
2666
2666
|
q() {
|
|
@@ -2669,79 +2669,79 @@ class te extends class {} {
|
|
|
2669
2669
|
}
|
|
2670
2670
|
|
|
2671
2671
|
/** Filter that matches on key fields (i.e. '__name__'). */
|
|
2672
|
-
class
|
|
2672
|
+
class ne extends ee {
|
|
2673
2673
|
constructor(t, e, n) {
|
|
2674
|
-
super(t, e, n), this.key =
|
|
2674
|
+
super(t, e, n), this.key = rt.fromName(n.referenceValue);
|
|
2675
2675
|
}
|
|
2676
2676
|
matches(t) {
|
|
2677
|
-
const e =
|
|
2677
|
+
const e = rt.comparator(t.key, this.key);
|
|
2678
2678
|
return this.S(e);
|
|
2679
2679
|
}
|
|
2680
2680
|
}
|
|
2681
2681
|
|
|
2682
|
-
/** Filter that matches on key fields within an array. */ class
|
|
2682
|
+
/** Filter that matches on key fields within an array. */ class re extends ee {
|
|
2683
2683
|
constructor(t, e) {
|
|
2684
|
-
super(t, "in" /* IN */ , e), this.keys =
|
|
2684
|
+
super(t, "in" /* IN */ , e), this.keys = ie("in" /* IN */ , e);
|
|
2685
2685
|
}
|
|
2686
2686
|
matches(t) {
|
|
2687
2687
|
return this.keys.some((e => e.isEqual(t.key)));
|
|
2688
2688
|
}
|
|
2689
2689
|
}
|
|
2690
2690
|
|
|
2691
|
-
/** Filter that matches on key fields not present within an array. */ class
|
|
2691
|
+
/** Filter that matches on key fields not present within an array. */ class se extends ee {
|
|
2692
2692
|
constructor(t, e) {
|
|
2693
|
-
super(t, "not-in" /* NOT_IN */ , e), this.keys =
|
|
2693
|
+
super(t, "not-in" /* NOT_IN */ , e), this.keys = ie("not-in" /* NOT_IN */ , e);
|
|
2694
2694
|
}
|
|
2695
2695
|
matches(t) {
|
|
2696
2696
|
return !this.keys.some((e => e.isEqual(t.key)));
|
|
2697
2697
|
}
|
|
2698
2698
|
}
|
|
2699
2699
|
|
|
2700
|
-
function
|
|
2700
|
+
function ie(t, e) {
|
|
2701
2701
|
var n;
|
|
2702
|
-
return ((null === (n = e.arrayValue) || void 0 === n ? void 0 : n.values) || []).map((t =>
|
|
2702
|
+
return ((null === (n = e.arrayValue) || void 0 === n ? void 0 : n.values) || []).map((t => rt.fromName(t.referenceValue)));
|
|
2703
2703
|
}
|
|
2704
2704
|
|
|
2705
|
-
/** A Filter that implements the array-contains operator. */ class
|
|
2705
|
+
/** A Filter that implements the array-contains operator. */ class oe extends ee {
|
|
2706
2706
|
constructor(t, e) {
|
|
2707
2707
|
super(t, "array-contains" /* ARRAY_CONTAINS */ , e);
|
|
2708
2708
|
}
|
|
2709
2709
|
matches(t) {
|
|
2710
2710
|
const e = t.data.field(this.field);
|
|
2711
|
-
return
|
|
2711
|
+
return Gt(e) && jt(e.arrayValue, this.value);
|
|
2712
2712
|
}
|
|
2713
2713
|
}
|
|
2714
2714
|
|
|
2715
|
-
/** A Filter that implements the IN operator. */ class
|
|
2715
|
+
/** A Filter that implements the IN operator. */ class ue extends ee {
|
|
2716
2716
|
constructor(t, e) {
|
|
2717
2717
|
super(t, "in" /* IN */ , e);
|
|
2718
2718
|
}
|
|
2719
2719
|
matches(t) {
|
|
2720
2720
|
const e = t.data.field(this.field);
|
|
2721
|
-
return null !== e &&
|
|
2721
|
+
return null !== e && jt(this.value.arrayValue, e);
|
|
2722
2722
|
}
|
|
2723
2723
|
}
|
|
2724
2724
|
|
|
2725
|
-
/** A Filter that implements the not-in operator. */ class
|
|
2725
|
+
/** A Filter that implements the not-in operator. */ class ce extends ee {
|
|
2726
2726
|
constructor(t, e) {
|
|
2727
2727
|
super(t, "not-in" /* NOT_IN */ , e);
|
|
2728
2728
|
}
|
|
2729
2729
|
matches(t) {
|
|
2730
|
-
if (
|
|
2730
|
+
if (jt(this.value.arrayValue, {
|
|
2731
2731
|
nullValue: "NULL_VALUE"
|
|
2732
2732
|
})) return !1;
|
|
2733
2733
|
const e = t.data.field(this.field);
|
|
2734
|
-
return null !== e && !
|
|
2734
|
+
return null !== e && !jt(this.value.arrayValue, e);
|
|
2735
2735
|
}
|
|
2736
2736
|
}
|
|
2737
2737
|
|
|
2738
|
-
/** A Filter that implements the array-contains-any operator. */ class
|
|
2738
|
+
/** A Filter that implements the array-contains-any operator. */ class ae extends ee {
|
|
2739
2739
|
constructor(t, e) {
|
|
2740
2740
|
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ , e);
|
|
2741
2741
|
}
|
|
2742
2742
|
matches(t) {
|
|
2743
2743
|
const e = t.data.field(this.field);
|
|
2744
|
-
return !(!
|
|
2744
|
+
return !(!Gt(e) || !e.arrayValue.values) && e.arrayValue.values.some((t => jt(this.value.arrayValue, t)));
|
|
2745
2745
|
}
|
|
2746
2746
|
}
|
|
2747
2747
|
|
|
@@ -2758,7 +2758,7 @@ function se(t, e) {
|
|
|
2758
2758
|
* Bound provides a function to determine whether a document comes before or
|
|
2759
2759
|
* after a bound. This is influenced by whether the position is just before or
|
|
2760
2760
|
* just after the provided values.
|
|
2761
|
-
*/ class
|
|
2761
|
+
*/ class he {
|
|
2762
2762
|
constructor(t, e) {
|
|
2763
2763
|
this.position = t, this.inclusive = e;
|
|
2764
2764
|
}
|
|
@@ -2766,22 +2766,22 @@ function se(t, e) {
|
|
|
2766
2766
|
|
|
2767
2767
|
/**
|
|
2768
2768
|
* An ordering on a field, in some Direction. Direction defaults to ASCENDING.
|
|
2769
|
-
*/ class
|
|
2769
|
+
*/ class le {
|
|
2770
2770
|
constructor(t, e = "asc" /* ASCENDING */) {
|
|
2771
2771
|
this.field = t, this.dir = e;
|
|
2772
2772
|
}
|
|
2773
2773
|
}
|
|
2774
2774
|
|
|
2775
|
-
function
|
|
2775
|
+
function fe(t, e) {
|
|
2776
2776
|
return t.dir === e.dir && t.field.isEqual(e.field);
|
|
2777
2777
|
}
|
|
2778
2778
|
|
|
2779
|
-
function
|
|
2779
|
+
function de(t, e) {
|
|
2780
2780
|
if (null === t) return null === e;
|
|
2781
2781
|
if (null === e) return !1;
|
|
2782
2782
|
if (t.inclusive !== e.inclusive || t.position.length !== e.position.length) return !1;
|
|
2783
2783
|
for (let n = 0; n < t.position.length; n++) {
|
|
2784
|
-
if (!
|
|
2784
|
+
if (!Ut(t.position[n], e.position[n])) return !1;
|
|
2785
2785
|
}
|
|
2786
2786
|
return !0;
|
|
2787
2787
|
}
|
|
@@ -2808,7 +2808,7 @@ function fe(t, e) {
|
|
|
2808
2808
|
* query the RemoteStore results.
|
|
2809
2809
|
*
|
|
2810
2810
|
* Visible for testing.
|
|
2811
|
-
*/ class
|
|
2811
|
+
*/ class we {
|
|
2812
2812
|
/**
|
|
2813
2813
|
* Initializes a Query with a path and optional additional query constraints.
|
|
2814
2814
|
* Path must currently be empty if this is a collection group query.
|
|
@@ -2821,11 +2821,11 @@ function fe(t, e) {
|
|
|
2821
2821
|
}
|
|
2822
2822
|
}
|
|
2823
2823
|
|
|
2824
|
-
/** Creates a new Query for a query that matches all documents at `path` */ function
|
|
2824
|
+
/** Creates a new Query for a query that matches all documents at `path` */ function me(t) {
|
|
2825
2825
|
return t.explicitOrderBy.length > 0 ? t.explicitOrderBy[0].field : null;
|
|
2826
2826
|
}
|
|
2827
2827
|
|
|
2828
|
-
function
|
|
2828
|
+
function pe(t) {
|
|
2829
2829
|
for (const e of t.filters) if (e.q()) return e.field;
|
|
2830
2830
|
return null;
|
|
2831
2831
|
}
|
|
@@ -2838,7 +2838,7 @@ function me(t) {
|
|
|
2838
2838
|
* Returns whether the query matches a collection group rather than a specific
|
|
2839
2839
|
* collection.
|
|
2840
2840
|
*/
|
|
2841
|
-
function
|
|
2841
|
+
function ye(t) {
|
|
2842
2842
|
return null !== t.collectionGroup;
|
|
2843
2843
|
}
|
|
2844
2844
|
|
|
@@ -2846,23 +2846,23 @@ function pe(t) {
|
|
|
2846
2846
|
* Returns the implicit order by constraint that is used to execute the Query,
|
|
2847
2847
|
* which can be different from the order by constraints the user provided (e.g.
|
|
2848
2848
|
* the SDK and backend always orders by `__name__`).
|
|
2849
|
-
*/ function
|
|
2850
|
-
const e =
|
|
2849
|
+
*/ function _e(t) {
|
|
2850
|
+
const e = I(t);
|
|
2851
2851
|
if (null === e.O) {
|
|
2852
2852
|
e.O = [];
|
|
2853
|
-
const t =
|
|
2853
|
+
const t = pe(e), n = me(e);
|
|
2854
2854
|
if (null !== t && null === n)
|
|
2855
2855
|
// In order to implicitly add key ordering, we must also add the
|
|
2856
2856
|
// inequality filter field for it to be a valid query.
|
|
2857
2857
|
// Note that the default inequality field and key ordering is ascending.
|
|
2858
|
-
t.isKeyField() || e.O.push(new
|
|
2858
|
+
t.isKeyField() || e.O.push(new le(t)), e.O.push(new le(nt.keyField(), "asc" /* ASCENDING */)); else {
|
|
2859
2859
|
let t = !1;
|
|
2860
2860
|
for (const n of e.explicitOrderBy) e.O.push(n), n.field.isKeyField() && (t = !0);
|
|
2861
2861
|
if (!t) {
|
|
2862
2862
|
// The order of the implicit key ordering always matches the last
|
|
2863
2863
|
// explicit order by
|
|
2864
2864
|
const t = e.explicitOrderBy.length > 0 ? e.explicitOrderBy[e.explicitOrderBy.length - 1].dir : "asc" /* ASCENDING */;
|
|
2865
|
-
e.O.push(new
|
|
2865
|
+
e.O.push(new le(nt.keyField(), t));
|
|
2866
2866
|
}
|
|
2867
2867
|
}
|
|
2868
2868
|
}
|
|
@@ -2871,34 +2871,34 @@ function pe(t) {
|
|
|
2871
2871
|
|
|
2872
2872
|
/**
|
|
2873
2873
|
* Converts this `Query` instance to it's corresponding `Target` representation.
|
|
2874
|
-
*/ function
|
|
2875
|
-
const e =
|
|
2876
|
-
if (!e.k) if ("F" /* First */ === e.limitType) e.k =
|
|
2874
|
+
*/ function ge(t) {
|
|
2875
|
+
const e = I(t);
|
|
2876
|
+
if (!e.k) if ("F" /* First */ === e.limitType) e.k = te(e.path, e.collectionGroup, _e(e), e.filters, e.limit, e.startAt, e.endAt); else {
|
|
2877
2877
|
// Flip the orderBy directions since we want the last results
|
|
2878
2878
|
const t = [];
|
|
2879
|
-
for (const n of
|
|
2879
|
+
for (const n of _e(e)) {
|
|
2880
2880
|
const e = "desc" /* DESCENDING */ === n.dir ? "asc" /* ASCENDING */ : "desc" /* DESCENDING */;
|
|
2881
|
-
t.push(new
|
|
2881
|
+
t.push(new le(n.field, e));
|
|
2882
2882
|
}
|
|
2883
2883
|
// We need to swap the cursors to match the now-flipped query ordering.
|
|
2884
|
-
const n = e.endAt ? new
|
|
2884
|
+
const n = e.endAt ? new he(e.endAt.position, e.endAt.inclusive) : null, r = e.startAt ? new he(e.startAt.position, e.startAt.inclusive) : null;
|
|
2885
2885
|
// Now return as a LimitType.First query.
|
|
2886
|
-
e.k =
|
|
2886
|
+
e.k = te(e.path, e.collectionGroup, t, e.filters, e.limit, n, r);
|
|
2887
2887
|
}
|
|
2888
2888
|
return e.k;
|
|
2889
2889
|
}
|
|
2890
2890
|
|
|
2891
|
-
function
|
|
2891
|
+
function ve(t, e) {
|
|
2892
2892
|
return function(t, e) {
|
|
2893
2893
|
if (t.limit !== e.limit) return !1;
|
|
2894
2894
|
if (t.orderBy.length !== e.orderBy.length) return !1;
|
|
2895
|
-
for (let n = 0; n < t.orderBy.length; n++) if (!
|
|
2895
|
+
for (let n = 0; n < t.orderBy.length; n++) if (!fe(t.orderBy[n], e.orderBy[n])) return !1;
|
|
2896
2896
|
if (t.filters.length !== e.filters.length) return !1;
|
|
2897
2897
|
for (let s = 0; s < t.filters.length; s++) if (n = t.filters[s], r = e.filters[s],
|
|
2898
|
-
n.op !== r.op || !n.field.isEqual(r.field) || !
|
|
2898
|
+
n.op !== r.op || !n.field.isEqual(r.field) || !Ut(n.value, r.value)) return !1;
|
|
2899
2899
|
var n, r;
|
|
2900
|
-
return t.collectionGroup === e.collectionGroup && !!t.path.isEqual(e.path) && !!
|
|
2901
|
-
}(
|
|
2900
|
+
return t.collectionGroup === e.collectionGroup && !!t.path.isEqual(e.path) && !!de(t.startAt, e.startAt) && de(t.endAt, e.endAt);
|
|
2901
|
+
}(ge(t), ge(e)) && t.limitType === e.limitType;
|
|
2902
2902
|
}
|
|
2903
2903
|
|
|
2904
2904
|
/**
|
|
@@ -2926,9 +2926,9 @@ function ge(t, e) {
|
|
|
2926
2926
|
* The return value is an IntegerValue if it can safely represent the value,
|
|
2927
2927
|
* otherwise a DoubleValue is returned.
|
|
2928
2928
|
*/
|
|
2929
|
-
function
|
|
2929
|
+
function be(t, e) {
|
|
2930
2930
|
return function(t) {
|
|
2931
|
-
return "number" == typeof t && Number.isInteger(t) && !
|
|
2931
|
+
return "number" == typeof t && Number.isInteger(t) && !lt(t) && t <= Number.MAX_SAFE_INTEGER && t >= Number.MIN_SAFE_INTEGER;
|
|
2932
2932
|
}(e) ?
|
|
2933
2933
|
/**
|
|
2934
2934
|
* Returns an IntegerValue for `value`.
|
|
@@ -2950,7 +2950,7 @@ function ve(t, e) {
|
|
|
2950
2950
|
};
|
|
2951
2951
|
}
|
|
2952
2952
|
return {
|
|
2953
|
-
doubleValue:
|
|
2953
|
+
doubleValue: lt(e) ? "-0" : e
|
|
2954
2954
|
};
|
|
2955
2955
|
}(t, e);
|
|
2956
2956
|
}
|
|
@@ -2971,7 +2971,7 @@ function ve(t, e) {
|
|
|
2971
2971
|
* See the License for the specific language governing permissions and
|
|
2972
2972
|
* limitations under the License.
|
|
2973
2973
|
*/
|
|
2974
|
-
/** Used to represent a field transform on a mutation. */ class
|
|
2974
|
+
/** Used to represent a field transform on a mutation. */ class Ee {
|
|
2975
2975
|
constructor() {
|
|
2976
2976
|
// Make sure that the structural type of `TransformOperation` is unique.
|
|
2977
2977
|
// See https://github.com/microsoft/TypeScript/issues/5451
|
|
@@ -2979,15 +2979,15 @@ function ve(t, e) {
|
|
|
2979
2979
|
}
|
|
2980
2980
|
}
|
|
2981
2981
|
|
|
2982
|
-
/** Transforms a value into a server-generated timestamp. */ class
|
|
2982
|
+
/** Transforms a value into a server-generated timestamp. */ class Ie extends Ee {}
|
|
2983
2983
|
|
|
2984
|
-
/** Transforms an array value via a union operation. */ class
|
|
2984
|
+
/** Transforms an array value via a union operation. */ class Te extends Ee {
|
|
2985
2985
|
constructor(t) {
|
|
2986
2986
|
super(), this.elements = t;
|
|
2987
2987
|
}
|
|
2988
2988
|
}
|
|
2989
2989
|
|
|
2990
|
-
/** Transforms an array value via a remove operation. */ class
|
|
2990
|
+
/** Transforms an array value via a remove operation. */ class Ae extends Ee {
|
|
2991
2991
|
constructor(t) {
|
|
2992
2992
|
super(), this.elements = t;
|
|
2993
2993
|
}
|
|
@@ -2998,7 +2998,7 @@ function ve(t, e) {
|
|
|
2998
2998
|
* transforms. Converts all field values to integers or doubles, but unlike the
|
|
2999
2999
|
* backend does not cap integer values at 2^63. Instead, JavaScript number
|
|
3000
3000
|
* arithmetic is used and precision loss can occur for values greater than 2^53.
|
|
3001
|
-
*/ class
|
|
3001
|
+
*/ class Re extends Ee {
|
|
3002
3002
|
constructor(t, e) {
|
|
3003
3003
|
super(), this.L = t, this.M = e;
|
|
3004
3004
|
}
|
|
@@ -3020,7 +3020,7 @@ function ve(t, e) {
|
|
|
3020
3020
|
* See the License for the specific language governing permissions and
|
|
3021
3021
|
* limitations under the License.
|
|
3022
3022
|
*/
|
|
3023
|
-
/** A field path and the TransformOperation to perform upon it. */ class
|
|
3023
|
+
/** A field path and the TransformOperation to perform upon it. */ class Pe {
|
|
3024
3024
|
constructor(t, e) {
|
|
3025
3025
|
this.field = t, this.transform = e;
|
|
3026
3026
|
}
|
|
@@ -3030,18 +3030,18 @@ function ve(t, e) {
|
|
|
3030
3030
|
* Encodes a precondition for a mutation. This follows the model that the
|
|
3031
3031
|
* backend accepts with the special case of an explicit "empty" precondition
|
|
3032
3032
|
* (meaning no precondition).
|
|
3033
|
-
*/ class
|
|
3033
|
+
*/ class Ve {
|
|
3034
3034
|
constructor(t, e) {
|
|
3035
3035
|
this.updateTime = t, this.exists = e;
|
|
3036
3036
|
}
|
|
3037
3037
|
/** Creates a new empty Precondition. */ static none() {
|
|
3038
|
-
return new
|
|
3038
|
+
return new Ve;
|
|
3039
3039
|
}
|
|
3040
3040
|
/** Creates a new Precondition with an exists flag. */ static exists(t) {
|
|
3041
|
-
return new
|
|
3041
|
+
return new Ve(void 0, t);
|
|
3042
3042
|
}
|
|
3043
3043
|
/** Creates a new Precondition based on a version a document exists at. */ static updateTime(t) {
|
|
3044
|
-
return new
|
|
3044
|
+
return new Ve(t);
|
|
3045
3045
|
}
|
|
3046
3046
|
/** Returns whether this Precondition is empty. */ get isNone() {
|
|
3047
3047
|
return void 0 === this.updateTime && void 0 === this.exists;
|
|
@@ -3094,12 +3094,12 @@ function ve(t, e) {
|
|
|
3094
3094
|
* applyToLocalView() to implement the actual behavior of applying the mutation
|
|
3095
3095
|
* to some source document (see `setMutationApplyToRemoteDocument()` for an
|
|
3096
3096
|
* example).
|
|
3097
|
-
*/ class
|
|
3097
|
+
*/ class Ne {}
|
|
3098
3098
|
|
|
3099
3099
|
/**
|
|
3100
3100
|
* A mutation that creates or replaces the document at the given key with the
|
|
3101
3101
|
* object value contents.
|
|
3102
|
-
*/ class
|
|
3102
|
+
*/ class De extends Ne {
|
|
3103
3103
|
constructor(t, e, n, r = []) {
|
|
3104
3104
|
super(), this.key = t, this.value = e, this.precondition = n, this.fieldTransforms = r,
|
|
3105
3105
|
this.type = 0 /* Set */;
|
|
@@ -3121,7 +3121,7 @@ function ve(t, e) {
|
|
|
3121
3121
|
* is deleted.
|
|
3122
3122
|
* * When a field is not in the mask but is in the values, the values map is
|
|
3123
3123
|
* ignored.
|
|
3124
|
-
*/ class
|
|
3124
|
+
*/ class $e extends Ne {
|
|
3125
3125
|
constructor(t, e, n, r, s = []) {
|
|
3126
3126
|
super(), this.key = t, this.data = e, this.fieldMask = n, this.precondition = r,
|
|
3127
3127
|
this.fieldTransforms = s, this.type = 1 /* Patch */;
|
|
@@ -3131,7 +3131,7 @@ function ve(t, e) {
|
|
|
3131
3131
|
}
|
|
3132
3132
|
}
|
|
3133
3133
|
|
|
3134
|
-
/** A mutation that deletes the document at the given key. */ class
|
|
3134
|
+
/** A mutation that deletes the document at the given key. */ class xe extends Ne {
|
|
3135
3135
|
constructor(t, e) {
|
|
3136
3136
|
super(), this.key = t, this.precondition = e, this.type = 2 /* Delete */ , this.fieldTransforms = [];
|
|
3137
3137
|
}
|
|
@@ -3146,7 +3146,7 @@ function ve(t, e) {
|
|
|
3146
3146
|
*
|
|
3147
3147
|
* The `verify` operation is only used in Transactions, and this class serves
|
|
3148
3148
|
* primarily to facilitate serialization into protos.
|
|
3149
|
-
*/ class
|
|
3149
|
+
*/ class Fe extends Ne {
|
|
3150
3150
|
constructor(t, e) {
|
|
3151
3151
|
super(), this.key = t, this.precondition = e, this.type = 3 /* Verify */ , this.fieldTransforms = [];
|
|
3152
3152
|
}
|
|
@@ -3170,13 +3170,13 @@ function ve(t, e) {
|
|
|
3170
3170
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3171
3171
|
* See the License for the specific language governing permissions and
|
|
3172
3172
|
* limitations under the License.
|
|
3173
|
-
*/ const
|
|
3173
|
+
*/ const Se = (() => {
|
|
3174
3174
|
const t = {
|
|
3175
3175
|
asc: "ASCENDING",
|
|
3176
3176
|
desc: "DESCENDING"
|
|
3177
3177
|
};
|
|
3178
3178
|
return t;
|
|
3179
|
-
})(),
|
|
3179
|
+
})(), qe = (() => {
|
|
3180
3180
|
const t = {
|
|
3181
3181
|
"<": "LESS_THAN",
|
|
3182
3182
|
"<=": "LESS_THAN_OR_EQUAL",
|
|
@@ -3206,7 +3206,7 @@ function ve(t, e) {
|
|
|
3206
3206
|
* TODO(klimt): We can remove the databaseId argument if we keep the full
|
|
3207
3207
|
* resource name in documents.
|
|
3208
3208
|
*/
|
|
3209
|
-
class
|
|
3209
|
+
class Oe {
|
|
3210
3210
|
constructor(t, e) {
|
|
3211
3211
|
this.databaseId = t, this.C = e;
|
|
3212
3212
|
}
|
|
@@ -3223,7 +3223,7 @@ class qe {
|
|
|
3223
3223
|
/**
|
|
3224
3224
|
* Returns a value for a Date that's appropriate to put into a proto.
|
|
3225
3225
|
*/
|
|
3226
|
-
function
|
|
3226
|
+
function ke(t, e) {
|
|
3227
3227
|
if (t.C) {
|
|
3228
3228
|
return `${new Date(1e3 * e.seconds).toISOString().replace(/\.\d*/, "").replace("Z", "")}.${("000000000" + e.nanoseconds).slice(-9)}Z`;
|
|
3229
3229
|
}
|
|
@@ -3238,129 +3238,129 @@ function Oe(t, e) {
|
|
|
3238
3238
|
*
|
|
3239
3239
|
* Visible for testing.
|
|
3240
3240
|
*/
|
|
3241
|
-
function
|
|
3241
|
+
function Ce(t, e) {
|
|
3242
3242
|
return t.C ? e.toBase64() : e.toUint8Array();
|
|
3243
3243
|
}
|
|
3244
3244
|
|
|
3245
|
-
function
|
|
3246
|
-
return
|
|
3245
|
+
function Le(t, e) {
|
|
3246
|
+
return ke(t, e.toTimestamp());
|
|
3247
3247
|
}
|
|
3248
3248
|
|
|
3249
|
-
function
|
|
3250
|
-
return
|
|
3251
|
-
const e =
|
|
3252
|
-
return new
|
|
3249
|
+
function Me(t) {
|
|
3250
|
+
return E(!!t), Et.fromTimestamp(function(t) {
|
|
3251
|
+
const e = Ft(t);
|
|
3252
|
+
return new bt(e.seconds, e.nanos);
|
|
3253
3253
|
}(t));
|
|
3254
3254
|
}
|
|
3255
3255
|
|
|
3256
|
-
function
|
|
3256
|
+
function Ue(t, e) {
|
|
3257
3257
|
return function(t) {
|
|
3258
|
-
return new
|
|
3258
|
+
return new tt([ "projects", t.projectId, "databases", t.database ]);
|
|
3259
3259
|
}(t).child("documents").child(e).canonicalString();
|
|
3260
3260
|
}
|
|
3261
3261
|
|
|
3262
|
-
function
|
|
3263
|
-
return
|
|
3262
|
+
function je(t, e) {
|
|
3263
|
+
return Ue(t.databaseId, e.path);
|
|
3264
3264
|
}
|
|
3265
3265
|
|
|
3266
|
-
function
|
|
3266
|
+
function Be(t, e) {
|
|
3267
3267
|
const n = function(t) {
|
|
3268
|
-
const e =
|
|
3269
|
-
return
|
|
3268
|
+
const e = tt.fromString(t);
|
|
3269
|
+
return E(tn(e)), e;
|
|
3270
3270
|
}(e);
|
|
3271
|
-
if (n.get(1) !== t.databaseId.projectId) throw new
|
|
3272
|
-
if (n.get(3) !== t.databaseId.database) throw new
|
|
3273
|
-
return new
|
|
3271
|
+
if (n.get(1) !== t.databaseId.projectId) throw new U(P, "Tried to deserialize key from different project: " + n.get(1) + " vs " + t.databaseId.projectId);
|
|
3272
|
+
if (n.get(3) !== t.databaseId.database) throw new U(P, "Tried to deserialize key from different database: " + n.get(3) + " vs " + t.databaseId.database);
|
|
3273
|
+
return new rt((E((r = n).length > 4 && "documents" === r.get(4)), r.popFirst(5)));
|
|
3274
3274
|
var r;
|
|
3275
3275
|
/** Creates a Document proto from key and fields (but no create/update time) */}
|
|
3276
3276
|
|
|
3277
|
-
function
|
|
3278
|
-
return
|
|
3277
|
+
function Qe(t, e) {
|
|
3278
|
+
return Ue(t.databaseId, e);
|
|
3279
3279
|
}
|
|
3280
3280
|
|
|
3281
|
-
function
|
|
3282
|
-
return new
|
|
3281
|
+
function ze(t) {
|
|
3282
|
+
return new tt([ "projects", t.databaseId.projectId, "databases", t.databaseId.database ]).canonicalString();
|
|
3283
3283
|
}
|
|
3284
3284
|
|
|
3285
|
-
function
|
|
3285
|
+
function Ge(t, e, n) {
|
|
3286
3286
|
return {
|
|
3287
|
-
name:
|
|
3287
|
+
name: je(t, e),
|
|
3288
3288
|
fields: n.value.mapValue.fields
|
|
3289
3289
|
};
|
|
3290
3290
|
}
|
|
3291
3291
|
|
|
3292
|
-
function
|
|
3292
|
+
function We(t, e) {
|
|
3293
3293
|
return "found" in e ? function(t, e) {
|
|
3294
|
-
|
|
3295
|
-
const n =
|
|
3294
|
+
E(!!e.found), e.found.name, e.found.updateTime;
|
|
3295
|
+
const n = Be(t, e.found.name), r = Me(e.found.updateTime), s = new Jt({
|
|
3296
3296
|
mapValue: {
|
|
3297
3297
|
fields: e.found.fields
|
|
3298
3298
|
}
|
|
3299
3299
|
});
|
|
3300
|
-
return
|
|
3300
|
+
return Xt.newFoundDocument(n, r, s);
|
|
3301
3301
|
}(t, e) : "missing" in e ? function(t, e) {
|
|
3302
|
-
|
|
3303
|
-
const n =
|
|
3304
|
-
return
|
|
3305
|
-
}(t, e) :
|
|
3302
|
+
E(!!e.missing), E(!!e.readTime);
|
|
3303
|
+
const n = Be(t, e.missing), r = Me(e.readTime);
|
|
3304
|
+
return Xt.newNoDocument(n, r);
|
|
3305
|
+
}(t, e) : b();
|
|
3306
3306
|
}
|
|
3307
3307
|
|
|
3308
|
-
function
|
|
3308
|
+
function Ke(t, e) {
|
|
3309
3309
|
let n;
|
|
3310
|
-
if (e instanceof
|
|
3311
|
-
update:
|
|
3310
|
+
if (e instanceof De) n = {
|
|
3311
|
+
update: Ge(t, e.key, e.value)
|
|
3312
|
+
}; else if (e instanceof xe) n = {
|
|
3313
|
+
delete: je(t, e.key)
|
|
3312
3314
|
}; else if (e instanceof $e) n = {
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
update: ze(t, e.key, e.data),
|
|
3316
|
-
updateMask: Xe(e.fieldMask)
|
|
3315
|
+
update: Ge(t, e.key, e.data),
|
|
3316
|
+
updateMask: Ze(e.fieldMask)
|
|
3317
3317
|
}; else {
|
|
3318
|
-
if (!(e instanceof
|
|
3318
|
+
if (!(e instanceof Fe)) return b();
|
|
3319
3319
|
n = {
|
|
3320
|
-
verify:
|
|
3320
|
+
verify: je(t, e.key)
|
|
3321
3321
|
};
|
|
3322
3322
|
}
|
|
3323
3323
|
return e.fieldTransforms.length > 0 && (n.updateTransforms = e.fieldTransforms.map((t => function(t, e) {
|
|
3324
3324
|
const n = e.transform;
|
|
3325
|
-
if (n instanceof
|
|
3325
|
+
if (n instanceof Ie) return {
|
|
3326
3326
|
fieldPath: e.field.canonicalString(),
|
|
3327
3327
|
setToServerValue: "REQUEST_TIME"
|
|
3328
3328
|
};
|
|
3329
|
-
if (n instanceof
|
|
3329
|
+
if (n instanceof Te) return {
|
|
3330
3330
|
fieldPath: e.field.canonicalString(),
|
|
3331
3331
|
appendMissingElements: {
|
|
3332
3332
|
values: n.elements
|
|
3333
3333
|
}
|
|
3334
3334
|
};
|
|
3335
|
-
if (n instanceof
|
|
3335
|
+
if (n instanceof Ae) return {
|
|
3336
3336
|
fieldPath: e.field.canonicalString(),
|
|
3337
3337
|
removeAllFromArray: {
|
|
3338
3338
|
values: n.elements
|
|
3339
3339
|
}
|
|
3340
3340
|
};
|
|
3341
|
-
if (n instanceof
|
|
3341
|
+
if (n instanceof Re) return {
|
|
3342
3342
|
fieldPath: e.field.canonicalString(),
|
|
3343
3343
|
increment: n.M
|
|
3344
3344
|
};
|
|
3345
|
-
throw
|
|
3345
|
+
throw b();
|
|
3346
3346
|
}(0, t)))), e.precondition.isNone || (n.currentDocument = function(t, e) {
|
|
3347
3347
|
return void 0 !== e.updateTime ? {
|
|
3348
|
-
updateTime:
|
|
3348
|
+
updateTime: Le(t, e.updateTime)
|
|
3349
3349
|
} : void 0 !== e.exists ? {
|
|
3350
3350
|
exists: e.exists
|
|
3351
|
-
} :
|
|
3351
|
+
} : b();
|
|
3352
3352
|
}(t, e.precondition)), n;
|
|
3353
3353
|
}
|
|
3354
3354
|
|
|
3355
|
-
function
|
|
3355
|
+
function Ye(t, e) {
|
|
3356
3356
|
// Dissect the path into parent, collectionId, and optional key filter.
|
|
3357
3357
|
const n = {
|
|
3358
3358
|
structuredQuery: {}
|
|
3359
3359
|
}, r = e.path;
|
|
3360
|
-
null !== e.collectionGroup ? (n.parent =
|
|
3360
|
+
null !== e.collectionGroup ? (n.parent = Qe(t, r), n.structuredQuery.from = [ {
|
|
3361
3361
|
collectionId: e.collectionGroup,
|
|
3362
3362
|
allDescendants: !0
|
|
3363
|
-
} ]) : (n.parent =
|
|
3363
|
+
} ]) : (n.parent = Qe(t, r.popLast()), n.structuredQuery.from = [ {
|
|
3364
3364
|
collectionId: r.lastSegment()
|
|
3365
3365
|
} ]);
|
|
3366
3366
|
const s = function(t) {
|
|
@@ -3369,36 +3369,36 @@ function Ke(t, e) {
|
|
|
3369
3369
|
// visible for testing
|
|
3370
3370
|
function(t) {
|
|
3371
3371
|
if ("==" /* EQUAL */ === t.op) {
|
|
3372
|
-
if (
|
|
3372
|
+
if (Kt(t.value)) return {
|
|
3373
3373
|
unaryFilter: {
|
|
3374
|
-
field:
|
|
3374
|
+
field: Xe(t.field),
|
|
3375
3375
|
op: "IS_NAN"
|
|
3376
3376
|
}
|
|
3377
3377
|
};
|
|
3378
|
-
if (
|
|
3378
|
+
if (Wt(t.value)) return {
|
|
3379
3379
|
unaryFilter: {
|
|
3380
|
-
field:
|
|
3380
|
+
field: Xe(t.field),
|
|
3381
3381
|
op: "IS_NULL"
|
|
3382
3382
|
}
|
|
3383
3383
|
};
|
|
3384
3384
|
} else if ("!=" /* NOT_EQUAL */ === t.op) {
|
|
3385
|
-
if (
|
|
3385
|
+
if (Kt(t.value)) return {
|
|
3386
3386
|
unaryFilter: {
|
|
3387
|
-
field:
|
|
3387
|
+
field: Xe(t.field),
|
|
3388
3388
|
op: "IS_NOT_NAN"
|
|
3389
3389
|
}
|
|
3390
3390
|
};
|
|
3391
|
-
if (
|
|
3391
|
+
if (Wt(t.value)) return {
|
|
3392
3392
|
unaryFilter: {
|
|
3393
|
-
field:
|
|
3393
|
+
field: Xe(t.field),
|
|
3394
3394
|
op: "IS_NOT_NULL"
|
|
3395
3395
|
}
|
|
3396
3396
|
};
|
|
3397
3397
|
}
|
|
3398
3398
|
return {
|
|
3399
3399
|
fieldFilter: {
|
|
3400
|
-
field:
|
|
3401
|
-
op:
|
|
3400
|
+
field: Xe(t.field),
|
|
3401
|
+
op: Je(t.op),
|
|
3402
3402
|
value: t.value
|
|
3403
3403
|
}
|
|
3404
3404
|
};
|
|
@@ -3418,14 +3418,14 @@ function Ke(t, e) {
|
|
|
3418
3418
|
// visible for testing
|
|
3419
3419
|
function(t) {
|
|
3420
3420
|
return {
|
|
3421
|
-
field:
|
|
3422
|
-
direction:
|
|
3421
|
+
field: Xe(t.field),
|
|
3422
|
+
direction: He(t.dir)
|
|
3423
3423
|
};
|
|
3424
3424
|
}(t)));
|
|
3425
3425
|
}(e.orderBy);
|
|
3426
3426
|
i && (n.structuredQuery.orderBy = i);
|
|
3427
3427
|
const o = function(t, e) {
|
|
3428
|
-
return t.C ||
|
|
3428
|
+
return t.C || ht(e) ? e : {
|
|
3429
3429
|
value: e
|
|
3430
3430
|
};
|
|
3431
3431
|
}(t, e.limit);
|
|
@@ -3443,29 +3443,29 @@ function Ke(t, e) {
|
|
|
3443
3443
|
(e.endAt)), n;
|
|
3444
3444
|
}
|
|
3445
3445
|
|
|
3446
|
-
function Ye(t) {
|
|
3447
|
-
return Fe[t];
|
|
3448
|
-
}
|
|
3449
|
-
|
|
3450
|
-
// visible for testing
|
|
3451
3446
|
function He(t) {
|
|
3452
3447
|
return Se[t];
|
|
3453
3448
|
}
|
|
3454
3449
|
|
|
3450
|
+
// visible for testing
|
|
3455
3451
|
function Je(t) {
|
|
3452
|
+
return qe[t];
|
|
3453
|
+
}
|
|
3454
|
+
|
|
3455
|
+
function Xe(t) {
|
|
3456
3456
|
return {
|
|
3457
3457
|
fieldPath: t.canonicalString()
|
|
3458
3458
|
};
|
|
3459
3459
|
}
|
|
3460
3460
|
|
|
3461
|
-
function
|
|
3461
|
+
function Ze(t) {
|
|
3462
3462
|
const e = [];
|
|
3463
3463
|
return t.fields.forEach((t => e.push(t.canonicalString()))), {
|
|
3464
3464
|
fieldPaths: e
|
|
3465
3465
|
};
|
|
3466
3466
|
}
|
|
3467
3467
|
|
|
3468
|
-
function
|
|
3468
|
+
function tn(t) {
|
|
3469
3469
|
// Resource names have at least 4 components (project ID, database ID)
|
|
3470
3470
|
return t.length >= 4 && "projects" === t.get(0) && "databases" === t.get(2);
|
|
3471
3471
|
}
|
|
@@ -3485,8 +3485,8 @@ function Ze(t) {
|
|
|
3485
3485
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3486
3486
|
* See the License for the specific language governing permissions and
|
|
3487
3487
|
* limitations under the License.
|
|
3488
|
-
*/ function
|
|
3489
|
-
return new
|
|
3488
|
+
*/ function en(t) {
|
|
3489
|
+
return new Oe(t, /* useProto3Json= */ !0);
|
|
3490
3490
|
}
|
|
3491
3491
|
|
|
3492
3492
|
/**
|
|
@@ -3514,7 +3514,7 @@ function Ze(t) {
|
|
|
3514
3514
|
* base delay. This prevents clients from accidentally synchronizing their
|
|
3515
3515
|
* delays causing spikes of load to the backend.
|
|
3516
3516
|
*/
|
|
3517
|
-
class
|
|
3517
|
+
class nn {
|
|
3518
3518
|
constructor(
|
|
3519
3519
|
/**
|
|
3520
3520
|
* The AsyncQueue to run backoff operations on.
|
|
@@ -3569,7 +3569,7 @@ class en {
|
|
|
3569
3569
|
// honored as such).
|
|
3570
3570
|
const e = Math.floor(this.W + this.X()), n = Math.max(0, Date.now() - this.Y), r = Math.max(0, e - n);
|
|
3571
3571
|
// Guard against lastAttemptTime being in the future due to a clock change.
|
|
3572
|
-
r > 0 &&
|
|
3572
|
+
r > 0 && y("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.W} ms, delay with jitter: ${e} ms, last attempt: ${n} ms ago)`),
|
|
3573
3573
|
this.K = this.U.enqueueAfterDelay(this.timerId, r, (() => (this.Y = Date.now(),
|
|
3574
3574
|
t()))),
|
|
3575
3575
|
// Apply backoff factor to determine next delay and ensure it is within
|
|
@@ -3612,24 +3612,24 @@ class en {
|
|
|
3612
3612
|
* An implementation of Datastore that exposes additional state for internal
|
|
3613
3613
|
* consumption.
|
|
3614
3614
|
*/
|
|
3615
|
-
class
|
|
3615
|
+
class rn extends class {} {
|
|
3616
3616
|
constructor(t, e, n, r) {
|
|
3617
3617
|
super(), this.authCredentials = t, this.appCheckCredentials = e, this.tt = n, this.L = r,
|
|
3618
3618
|
this.et = !1;
|
|
3619
3619
|
}
|
|
3620
3620
|
nt() {
|
|
3621
|
-
if (this.et) throw new
|
|
3621
|
+
if (this.et) throw new U(S, "The client has already been terminated.");
|
|
3622
3622
|
}
|
|
3623
3623
|
/** Invokes the provided RPC with auth and AppCheck tokens. */ I(t, e, n) {
|
|
3624
3624
|
return this.nt(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.tt.I(t, e, n, r, s))).catch((t => {
|
|
3625
|
-
throw "FirebaseError" === t.name ? (t.code ===
|
|
3626
|
-
this.appCheckCredentials.invalidateToken()), t) : new
|
|
3625
|
+
throw "FirebaseError" === t.name ? (t.code === x && (this.authCredentials.invalidateToken(),
|
|
3626
|
+
this.appCheckCredentials.invalidateToken()), t) : new U(R, t.toString());
|
|
3627
3627
|
}));
|
|
3628
3628
|
}
|
|
3629
3629
|
/** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */ P(t, e, n, r) {
|
|
3630
3630
|
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 => {
|
|
3631
|
-
throw "FirebaseError" === t.name ? (t.code ===
|
|
3632
|
-
this.appCheckCredentials.invalidateToken()), t) : new
|
|
3631
|
+
throw "FirebaseError" === t.name ? (t.code === x && (this.authCredentials.invalidateToken(),
|
|
3632
|
+
this.appCheckCredentials.invalidateToken()), t) : new U(R, t.toString());
|
|
3633
3633
|
}));
|
|
3634
3634
|
}
|
|
3635
3635
|
terminate() {
|
|
@@ -3639,45 +3639,45 @@ class nn extends class {} {
|
|
|
3639
3639
|
|
|
3640
3640
|
// TODO(firestorexp): Make sure there is only one Datastore instance per
|
|
3641
3641
|
// firestore-exp client.
|
|
3642
|
-
async function
|
|
3643
|
-
const n =
|
|
3644
|
-
writes: e.map((t =>
|
|
3642
|
+
async function sn(t, e) {
|
|
3643
|
+
const n = I(t), r = ze(n.L) + "/documents", s = {
|
|
3644
|
+
writes: e.map((t => Ke(n.L, t)))
|
|
3645
3645
|
};
|
|
3646
3646
|
await n.I("Commit", r, s);
|
|
3647
3647
|
}
|
|
3648
3648
|
|
|
3649
|
-
async function
|
|
3650
|
-
const n =
|
|
3651
|
-
documents: e.map((t =>
|
|
3649
|
+
async function on(t, e) {
|
|
3650
|
+
const n = I(t), r = ze(n.L) + "/documents", s = {
|
|
3651
|
+
documents: e.map((t => je(n.L, t)))
|
|
3652
3652
|
}, i = await n.P("BatchGetDocuments", r, s, e.length), o = new Map;
|
|
3653
3653
|
i.forEach((t => {
|
|
3654
|
-
const e =
|
|
3654
|
+
const e = We(n.L, t);
|
|
3655
3655
|
o.set(e.key.toString(), e);
|
|
3656
3656
|
}));
|
|
3657
3657
|
const u = [];
|
|
3658
3658
|
return e.forEach((t => {
|
|
3659
3659
|
const e = o.get(t.toString());
|
|
3660
|
-
|
|
3660
|
+
E(!!e), u.push(e);
|
|
3661
3661
|
})), u;
|
|
3662
3662
|
}
|
|
3663
3663
|
|
|
3664
|
-
async function
|
|
3665
|
-
const n =
|
|
3664
|
+
async function un(t, e) {
|
|
3665
|
+
const n = I(t), r = Ye(n.L, ge(e));
|
|
3666
3666
|
return (await n.P("RunQuery", r.parent, {
|
|
3667
3667
|
structuredQuery: r.structuredQuery
|
|
3668
3668
|
})).filter((t => !!t.document)).map((t => function(t, e, n) {
|
|
3669
|
-
const r =
|
|
3669
|
+
const r = Be(t, e.name), s = Me(e.updateTime), i = new Jt({
|
|
3670
3670
|
mapValue: {
|
|
3671
3671
|
fields: e.fields
|
|
3672
3672
|
}
|
|
3673
|
-
}), o =
|
|
3673
|
+
}), o = Xt.newFoundDocument(r, s, i);
|
|
3674
3674
|
return n && o.setHasCommittedMutations(), n ? o.setHasCommittedMutations() : o;
|
|
3675
3675
|
}(n.L, t.document, void 0)));
|
|
3676
3676
|
}
|
|
3677
3677
|
|
|
3678
|
-
async function
|
|
3679
|
-
const n =
|
|
3680
|
-
const n =
|
|
3678
|
+
async function cn(t, e) {
|
|
3679
|
+
const n = I(t), r = function(t, e) {
|
|
3680
|
+
const n = Ye(t, e);
|
|
3681
3681
|
return {
|
|
3682
3682
|
structuredAggregationQuery: {
|
|
3683
3683
|
aggregations: [ {
|
|
@@ -3688,7 +3688,7 @@ async function un(t, e) {
|
|
|
3688
3688
|
},
|
|
3689
3689
|
parent: n.parent
|
|
3690
3690
|
};
|
|
3691
|
-
}(n.L,
|
|
3691
|
+
}(n.L, ge(e)), s = r.parent;
|
|
3692
3692
|
n.tt.v || delete r.parent;
|
|
3693
3693
|
return (await n.P("RunAggregationQuery", s, r, /*expectedResponseCount=*/ 1)).filter((t => !!t.result)).map((t => t.result.aggregateFields));
|
|
3694
3694
|
}
|
|
@@ -3708,7 +3708,7 @@ async function un(t, e) {
|
|
|
3708
3708
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3709
3709
|
* See the License for the specific language governing permissions and
|
|
3710
3710
|
* limitations under the License.
|
|
3711
|
-
*/ const
|
|
3711
|
+
*/ const an = new Map;
|
|
3712
3712
|
|
|
3713
3713
|
/**
|
|
3714
3714
|
* An instance map that ensures only one Datastore exists per Firestore
|
|
@@ -3719,17 +3719,17 @@ async function un(t, e) {
|
|
|
3719
3719
|
* instance. Callers must invoke removeComponents() when the Firestore
|
|
3720
3720
|
* instance is terminated.
|
|
3721
3721
|
*/
|
|
3722
|
-
function
|
|
3723
|
-
if (t._terminated) throw new
|
|
3724
|
-
if (!
|
|
3725
|
-
|
|
3722
|
+
function hn(t) {
|
|
3723
|
+
if (t._terminated) throw new U(S, "The client has already been terminated.");
|
|
3724
|
+
if (!an.has(t)) {
|
|
3725
|
+
y("ComponentProvider", "Initializing Datastore");
|
|
3726
3726
|
const i = function(t) {
|
|
3727
|
-
return new
|
|
3727
|
+
return new pt(t, fetch.bind(null));
|
|
3728
3728
|
}((e = t._databaseId, n = t.app.options.appId || "", r = t._persistenceKey, s = t._freezeSettings(),
|
|
3729
|
-
new
|
|
3730
|
-
return new
|
|
3729
|
+
new J(e, n, r, s.host, s.ssl, s.experimentalForceLongPolling, s.experimentalAutoDetectLongPolling, s.useFetchStreams))), o = en(t._databaseId), u = function(t, e, n, r) {
|
|
3730
|
+
return new rn(t, e, n, r);
|
|
3731
3731
|
}(t._authCredentials, t._appCheckCredentials, i, o);
|
|
3732
|
-
|
|
3732
|
+
an.set(t, u);
|
|
3733
3733
|
}
|
|
3734
3734
|
var e, n, r, s;
|
|
3735
3735
|
/**
|
|
@@ -3747,7 +3747,7 @@ function an(t) {
|
|
|
3747
3747
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3748
3748
|
* See the License for the specific language governing permissions and
|
|
3749
3749
|
* limitations under the License.
|
|
3750
|
-
*/ return
|
|
3750
|
+
*/ return an.get(t);
|
|
3751
3751
|
}
|
|
3752
3752
|
|
|
3753
3753
|
/**
|
|
@@ -3759,21 +3759,21 @@ function an(t) {
|
|
|
3759
3759
|
* user-supplied `FirestoreSettings` object. This is a separate type so that
|
|
3760
3760
|
* defaults can be supplied and the value can be checked for equality.
|
|
3761
3761
|
*/
|
|
3762
|
-
class
|
|
3762
|
+
class ln {
|
|
3763
3763
|
constructor(t) {
|
|
3764
3764
|
var e;
|
|
3765
3765
|
if (void 0 === t.host) {
|
|
3766
|
-
if (void 0 !== t.ssl) throw new
|
|
3766
|
+
if (void 0 !== t.ssl) throw new U(P, "Can't provide ssl option if host option is not set");
|
|
3767
3767
|
this.host = "firestore.googleapis.com", this.ssl = true;
|
|
3768
3768
|
} else this.host = t.host, this.ssl = null === (e = t.ssl) || void 0 === e || e;
|
|
3769
3769
|
if (this.credentials = t.credentials, this.ignoreUndefinedProperties = !!t.ignoreUndefinedProperties,
|
|
3770
3770
|
void 0 === t.cacheSizeBytes) this.cacheSizeBytes = 41943040; else {
|
|
3771
|
-
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new
|
|
3771
|
+
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new U(P, "cacheSizeBytes must be at least 1048576");
|
|
3772
3772
|
this.cacheSizeBytes = t.cacheSizeBytes;
|
|
3773
3773
|
}
|
|
3774
3774
|
this.experimentalForceLongPolling = !!t.experimentalForceLongPolling, this.experimentalAutoDetectLongPolling = !!t.experimentalAutoDetectLongPolling,
|
|
3775
3775
|
this.useFetchStreams = !!t.useFetchStreams, function(t, e, n, r) {
|
|
3776
|
-
if (!0 === e && !0 === r) throw new
|
|
3776
|
+
if (!0 === e && !0 === r) throw new U(P, `${t} and ${n} cannot be used together.`);
|
|
3777
3777
|
}("experimentalForceLongPolling", t.experimentalForceLongPolling, "experimentalAutoDetectLongPolling", t.experimentalAutoDetectLongPolling);
|
|
3778
3778
|
}
|
|
3779
3779
|
isEqual(t) {
|
|
@@ -3801,7 +3801,7 @@ class hn {
|
|
|
3801
3801
|
* The Cloud Firestore service interface.
|
|
3802
3802
|
*
|
|
3803
3803
|
* Do not call this constructor directly. Instead, use {@link (getFirestore:1)}.
|
|
3804
|
-
*/ class
|
|
3804
|
+
*/ class fn {
|
|
3805
3805
|
/** @hideconstructor */
|
|
3806
3806
|
constructor(t, e, n, r) {
|
|
3807
3807
|
this._authCredentials = t, this._appCheckCredentials = e, this._databaseId = n,
|
|
@@ -3809,14 +3809,14 @@ class hn {
|
|
|
3809
3809
|
/**
|
|
3810
3810
|
* Whether it's a Firestore or Firestore Lite instance.
|
|
3811
3811
|
*/
|
|
3812
|
-
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new
|
|
3812
|
+
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new ln({}),
|
|
3813
3813
|
this._settingsFrozen = !1;
|
|
3814
3814
|
}
|
|
3815
3815
|
/**
|
|
3816
3816
|
* The {@link @firebase/app#FirebaseApp} associated with this `Firestore` service
|
|
3817
3817
|
* instance.
|
|
3818
3818
|
*/ get app() {
|
|
3819
|
-
if (!this._app) throw new
|
|
3819
|
+
if (!this._app) throw new U(S, "Firestore was not initialized using the Firebase SDK. 'app' is not available");
|
|
3820
3820
|
return this._app;
|
|
3821
3821
|
}
|
|
3822
3822
|
get _initialized() {
|
|
@@ -3826,19 +3826,19 @@ class hn {
|
|
|
3826
3826
|
return void 0 !== this._terminateTask;
|
|
3827
3827
|
}
|
|
3828
3828
|
_setSettings(t) {
|
|
3829
|
-
if (this._settingsFrozen) throw new
|
|
3830
|
-
this._settings = new
|
|
3831
|
-
if (!t) return new
|
|
3829
|
+
if (this._settingsFrozen) throw new U(S, "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.");
|
|
3830
|
+
this._settings = new ln(t), void 0 !== t.credentials && (this._authCredentials = function(t) {
|
|
3831
|
+
if (!t) return new Q;
|
|
3832
3832
|
switch (t.type) {
|
|
3833
3833
|
case "gapi":
|
|
3834
3834
|
const e = t.client;
|
|
3835
|
-
return new
|
|
3835
|
+
return new K(e, t.sessionIndex || "0", t.iamToken || null, t.authTokenFactory || null);
|
|
3836
3836
|
|
|
3837
3837
|
case "provider":
|
|
3838
3838
|
return t.client;
|
|
3839
3839
|
|
|
3840
3840
|
default:
|
|
3841
|
-
throw new
|
|
3841
|
+
throw new U(P, "makeAuthCredentialsProvider failed due to invalid credential type");
|
|
3842
3842
|
}
|
|
3843
3843
|
}(t.credentials));
|
|
3844
3844
|
}
|
|
@@ -3866,27 +3866,34 @@ class hn {
|
|
|
3866
3866
|
* Only ever called once.
|
|
3867
3867
|
*/ _terminate() {
|
|
3868
3868
|
return function(t) {
|
|
3869
|
-
const e =
|
|
3870
|
-
e && (
|
|
3869
|
+
const e = an.get(t);
|
|
3870
|
+
e && (y("ComponentProvider", "Removing Datastore"), an.delete(t), e.terminate());
|
|
3871
3871
|
}(this), Promise.resolve();
|
|
3872
3872
|
}
|
|
3873
3873
|
}
|
|
3874
3874
|
|
|
3875
|
-
function
|
|
3875
|
+
function dn(t, e, n) {
|
|
3876
3876
|
n || (n = "(default)");
|
|
3877
3877
|
const r = _getProvider(t, "firestore/lite");
|
|
3878
|
-
if (r.isInitialized(n)) throw new
|
|
3878
|
+
if (r.isInitialized(n)) throw new U(S, "Firestore can only be initialized once per app.");
|
|
3879
3879
|
return r.initialize({
|
|
3880
3880
|
options: e,
|
|
3881
3881
|
instanceIdentifier: n
|
|
3882
3882
|
});
|
|
3883
3883
|
}
|
|
3884
3884
|
|
|
3885
|
-
function
|
|
3886
|
-
const r = "object" == typeof e ? e : getApp(), s = "string" == typeof e ? e : n || "(default)"
|
|
3887
|
-
return _getProvider(r, "firestore/lite").getImmediate({
|
|
3885
|
+
function wn(e, n) {
|
|
3886
|
+
const r = "object" == typeof e ? e : getApp(), s = "string" == typeof e ? e : n || "(default)", i = _getProvider(r, "firestore/lite").getImmediate({
|
|
3888
3887
|
identifier: s
|
|
3889
3888
|
});
|
|
3889
|
+
if (!i._initialized) {
|
|
3890
|
+
const t = getDefaultEmulatorHost("firestore");
|
|
3891
|
+
if (t) {
|
|
3892
|
+
const [e, n] = t.split(":");
|
|
3893
|
+
mn(i, e, parseInt(n, 10));
|
|
3894
|
+
}
|
|
3895
|
+
}
|
|
3896
|
+
return i;
|
|
3890
3897
|
}
|
|
3891
3898
|
|
|
3892
3899
|
/**
|
|
@@ -3901,24 +3908,24 @@ function dn(e, n) {
|
|
|
3901
3908
|
* @param port - the emulator port (ex: 9000).
|
|
3902
3909
|
* @param options.mockUserToken - the mock auth token to use for unit testing
|
|
3903
3910
|
* Security Rules.
|
|
3904
|
-
*/ function
|
|
3911
|
+
*/ function mn(t, e, n, r = {}) {
|
|
3905
3912
|
var s;
|
|
3906
|
-
const i = (t =
|
|
3907
|
-
if ("firestore.googleapis.com" !== i.host && i.host !== e &&
|
|
3913
|
+
const i = (t = ct(t, fn))._getSettings();
|
|
3914
|
+
if ("firestore.googleapis.com" !== i.host && i.host !== e && g("Host has been set in both settings() and useEmulator(), emulator host will be used"),
|
|
3908
3915
|
t._setSettings(Object.assign(Object.assign({}, i), {
|
|
3909
3916
|
host: `${e}:${n}`,
|
|
3910
3917
|
ssl: !1
|
|
3911
3918
|
})), r.mockUserToken) {
|
|
3912
3919
|
let e, n;
|
|
3913
|
-
if ("string" == typeof r.mockUserToken) e = r.mockUserToken, n =
|
|
3920
|
+
if ("string" == typeof r.mockUserToken) e = r.mockUserToken, n = d.MOCK_USER; else {
|
|
3914
3921
|
// Let createMockUserToken validate first (catches common mistakes like
|
|
3915
3922
|
// invalid field "uid" and missing field "sub" / "user_id".)
|
|
3916
3923
|
e = createMockUserToken(r.mockUserToken, null === (s = t._app) || void 0 === s ? void 0 : s.options.projectId);
|
|
3917
3924
|
const i = r.mockUserToken.sub || r.mockUserToken.user_id;
|
|
3918
|
-
if (!i) throw new
|
|
3919
|
-
n = new
|
|
3925
|
+
if (!i) throw new U(P, "mockUserToken must contain 'sub' or 'user_id' field!");
|
|
3926
|
+
n = new d(i);
|
|
3920
3927
|
}
|
|
3921
|
-
t._authCredentials = new
|
|
3928
|
+
t._authCredentials = new z(new B(e, n));
|
|
3922
3929
|
}
|
|
3923
3930
|
}
|
|
3924
3931
|
|
|
@@ -3941,8 +3948,8 @@ function dn(e, n) {
|
|
|
3941
3948
|
* @param firestore - The `Firestore` instance to terminate.
|
|
3942
3949
|
* @returns A `Promise` that is resolved when the instance has been successfully
|
|
3943
3950
|
* terminated.
|
|
3944
|
-
*/ function
|
|
3945
|
-
return t =
|
|
3951
|
+
*/ function pn(t) {
|
|
3952
|
+
return t = ct(t, fn), _removeServiceInstance(t.app, "firestore/lite"), t._delete();
|
|
3946
3953
|
}
|
|
3947
3954
|
|
|
3948
3955
|
/**
|
|
@@ -3981,7 +3988,7 @@ function dn(e, n) {
|
|
|
3981
3988
|
* Represents an aggregation that can be performed by Firestore.
|
|
3982
3989
|
*/
|
|
3983
3990
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3984
|
-
class
|
|
3991
|
+
class yn {
|
|
3985
3992
|
constructor() {
|
|
3986
3993
|
/** A type string to uniquely identify instances of this class. */
|
|
3987
3994
|
this.type = "AggregateField";
|
|
@@ -3990,7 +3997,7 @@ class pn {
|
|
|
3990
3997
|
|
|
3991
3998
|
/**
|
|
3992
3999
|
* The results of executing an aggregation query.
|
|
3993
|
-
*/ class
|
|
4000
|
+
*/ class _n {
|
|
3994
4001
|
/** @hideconstructor */
|
|
3995
4002
|
constructor(t, e) {
|
|
3996
4003
|
this._data = e,
|
|
@@ -4031,15 +4038,15 @@ class pn {
|
|
|
4031
4038
|
/**
|
|
4032
4039
|
* CountQueryRunner encapsulates the logic needed to run the count aggregation
|
|
4033
4040
|
* queries.
|
|
4034
|
-
*/ class
|
|
4041
|
+
*/ class gn {
|
|
4035
4042
|
constructor(t, e, n) {
|
|
4036
4043
|
this.query = t, this.datastore = e, this.userDataWriter = n;
|
|
4037
4044
|
}
|
|
4038
4045
|
run() {
|
|
4039
|
-
return
|
|
4040
|
-
|
|
4046
|
+
return cn(this.datastore, this.query._query).then((t => {
|
|
4047
|
+
E(void 0 !== t[0]);
|
|
4041
4048
|
const e = Object.entries(t[0]).filter((([t, e]) => "count_alias" === t)).map((([t, e]) => this.userDataWriter.convertValue(e)))[0];
|
|
4042
|
-
return
|
|
4049
|
+
return E("number" == typeof e), Promise.resolve(new _n(this.query, {
|
|
4043
4050
|
count: e
|
|
4044
4051
|
}));
|
|
4045
4052
|
}));
|
|
@@ -4066,7 +4073,7 @@ class pn {
|
|
|
4066
4073
|
* A `DocumentReference` refers to a document location in a Firestore database
|
|
4067
4074
|
* and can be used to write, read, or listen to the location. The document at
|
|
4068
4075
|
* the referenced location may or may not exist.
|
|
4069
|
-
*/ class
|
|
4076
|
+
*/ class vn {
|
|
4070
4077
|
/** @hideconstructor */
|
|
4071
4078
|
constructor(t,
|
|
4072
4079
|
/**
|
|
@@ -4094,17 +4101,17 @@ class pn {
|
|
|
4094
4101
|
/**
|
|
4095
4102
|
* The collection this `DocumentReference` belongs to.
|
|
4096
4103
|
*/ get parent() {
|
|
4097
|
-
return new
|
|
4104
|
+
return new En(this.firestore, this.converter, this._key.path.popLast());
|
|
4098
4105
|
}
|
|
4099
4106
|
withConverter(t) {
|
|
4100
|
-
return new
|
|
4107
|
+
return new vn(this.firestore, t, this._key);
|
|
4101
4108
|
}
|
|
4102
4109
|
}
|
|
4103
4110
|
|
|
4104
4111
|
/**
|
|
4105
4112
|
* A `Query` refers to a query which you can read or listen to. You can also
|
|
4106
4113
|
* construct refined `Query` objects by adding filters and ordering.
|
|
4107
|
-
*/ class
|
|
4114
|
+
*/ class bn {
|
|
4108
4115
|
// This is the lite version of the Query class in the main SDK.
|
|
4109
4116
|
/** @hideconstructor protected */
|
|
4110
4117
|
constructor(t,
|
|
@@ -4117,17 +4124,17 @@ class pn {
|
|
|
4117
4124
|
this.type = "query", this.firestore = t;
|
|
4118
4125
|
}
|
|
4119
4126
|
withConverter(t) {
|
|
4120
|
-
return new
|
|
4127
|
+
return new bn(this.firestore, t, this._query);
|
|
4121
4128
|
}
|
|
4122
4129
|
}
|
|
4123
4130
|
|
|
4124
4131
|
/**
|
|
4125
4132
|
* A `CollectionReference` object can be used for adding documents, getting
|
|
4126
4133
|
* document references, and querying for documents (using {@link query}).
|
|
4127
|
-
*/ class
|
|
4134
|
+
*/ class En extends bn {
|
|
4128
4135
|
/** @hideconstructor */
|
|
4129
4136
|
constructor(t, e, n) {
|
|
4130
|
-
super(t, e, new
|
|
4137
|
+
super(t, e, new we(n)), this._path = n,
|
|
4131
4138
|
/** The type of this Firestore reference. */
|
|
4132
4139
|
this.type = "collection";
|
|
4133
4140
|
}
|
|
@@ -4145,23 +4152,23 @@ class pn {
|
|
|
4145
4152
|
* subcollection. If this isn't a subcollection, the reference is null.
|
|
4146
4153
|
*/ get parent() {
|
|
4147
4154
|
const t = this._path.popLast();
|
|
4148
|
-
return t.isEmpty() ? null : new
|
|
4149
|
-
/* converter= */ null, new
|
|
4155
|
+
return t.isEmpty() ? null : new vn(this.firestore,
|
|
4156
|
+
/* converter= */ null, new rt(t));
|
|
4150
4157
|
}
|
|
4151
4158
|
withConverter(t) {
|
|
4152
|
-
return new
|
|
4159
|
+
return new En(this.firestore, t, this._path);
|
|
4153
4160
|
}
|
|
4154
4161
|
}
|
|
4155
4162
|
|
|
4156
|
-
function
|
|
4157
|
-
if (t = getModularInstance(t),
|
|
4158
|
-
const r =
|
|
4159
|
-
return
|
|
4163
|
+
function In(t, e, ...n) {
|
|
4164
|
+
if (t = getModularInstance(t), st("collection", "path", e), t instanceof fn) {
|
|
4165
|
+
const r = tt.fromString(e, ...n);
|
|
4166
|
+
return ot(r), new En(t, /* converter= */ null, r);
|
|
4160
4167
|
}
|
|
4161
4168
|
{
|
|
4162
|
-
if (!(t instanceof
|
|
4163
|
-
const r = t._path.child(
|
|
4164
|
-
return
|
|
4169
|
+
if (!(t instanceof vn || t instanceof En)) throw new U(P, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
4170
|
+
const r = t._path.child(tt.fromString(e, ...n));
|
|
4171
|
+
return ot(r), new En(t.firestore,
|
|
4165
4172
|
/* converter= */ null, r);
|
|
4166
4173
|
}
|
|
4167
4174
|
}
|
|
@@ -4178,32 +4185,32 @@ function En(t, e, ...n) {
|
|
|
4178
4185
|
* collection or subcollection with this ID as the last segment of its path
|
|
4179
4186
|
* will be included. Cannot contain a slash.
|
|
4180
4187
|
* @returns The created `Query`.
|
|
4181
|
-
*/ function
|
|
4182
|
-
if (t =
|
|
4183
|
-
return new
|
|
4188
|
+
*/ function Tn(t, e) {
|
|
4189
|
+
if (t = ct(t, fn), st("collectionGroup", "collection id", e), e.indexOf("/") >= 0) throw new U(P, `Invalid collection ID '${e}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);
|
|
4190
|
+
return new bn(t,
|
|
4184
4191
|
/* converter= */ null,
|
|
4185
4192
|
/**
|
|
4186
4193
|
* Creates a new Query for a collection group query that matches all documents
|
|
4187
4194
|
* within the provided collection group.
|
|
4188
4195
|
*/
|
|
4189
4196
|
function(t) {
|
|
4190
|
-
return new
|
|
4197
|
+
return new we(tt.emptyPath(), t);
|
|
4191
4198
|
}(e));
|
|
4192
4199
|
}
|
|
4193
4200
|
|
|
4194
|
-
function
|
|
4201
|
+
function An(t, e, ...n) {
|
|
4195
4202
|
if (t = getModularInstance(t),
|
|
4196
4203
|
// We allow omission of 'pathString' but explicitly prohibit passing in both
|
|
4197
4204
|
// 'undefined' and 'null'.
|
|
4198
|
-
1 === arguments.length && (e =
|
|
4199
|
-
const r =
|
|
4200
|
-
return
|
|
4201
|
-
/* converter= */ null, new
|
|
4205
|
+
1 === arguments.length && (e = _t.D()), st("doc", "path", e), t instanceof fn) {
|
|
4206
|
+
const r = tt.fromString(e, ...n);
|
|
4207
|
+
return it(r), new vn(t,
|
|
4208
|
+
/* converter= */ null, new rt(r));
|
|
4202
4209
|
}
|
|
4203
4210
|
{
|
|
4204
|
-
if (!(t instanceof
|
|
4205
|
-
const r = t._path.child(
|
|
4206
|
-
return
|
|
4211
|
+
if (!(t instanceof vn || t instanceof En)) throw new U(P, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
4212
|
+
const r = t._path.child(tt.fromString(e, ...n));
|
|
4213
|
+
return it(r), new vn(t.firestore, t instanceof En ? t.converter : null, new rt(r));
|
|
4207
4214
|
}
|
|
4208
4215
|
}
|
|
4209
4216
|
|
|
@@ -4214,8 +4221,8 @@ function Tn(t, e, ...n) {
|
|
|
4214
4221
|
* @param right - A reference to compare.
|
|
4215
4222
|
* @returns true if the references point to the same location in the same
|
|
4216
4223
|
* Firestore database.
|
|
4217
|
-
*/ function
|
|
4218
|
-
return t = getModularInstance(t), e = getModularInstance(e), (t instanceof
|
|
4224
|
+
*/ function Rn(t, e) {
|
|
4225
|
+
return t = getModularInstance(t), e = getModularInstance(e), (t instanceof vn || t instanceof En) && (e instanceof vn || e instanceof En) && (t.firestore === e.firestore && t.path === e.path && t.converter === e.converter);
|
|
4219
4226
|
}
|
|
4220
4227
|
|
|
4221
4228
|
/**
|
|
@@ -4226,8 +4233,8 @@ function Tn(t, e, ...n) {
|
|
|
4226
4233
|
* @param right - A `Query` to compare.
|
|
4227
4234
|
* @returns true if the references point to the same location in the same
|
|
4228
4235
|
* Firestore database.
|
|
4229
|
-
*/ function
|
|
4230
|
-
return t = getModularInstance(t), e = getModularInstance(e), t instanceof
|
|
4236
|
+
*/ function Pn(t, e) {
|
|
4237
|
+
return t = getModularInstance(t), e = getModularInstance(e), t instanceof bn && e instanceof bn && (t.firestore === e.firestore && ve(t._query, e._query) && t.converter === e.converter);
|
|
4231
4238
|
}
|
|
4232
4239
|
|
|
4233
4240
|
/**
|
|
@@ -4248,7 +4255,7 @@ function Tn(t, e, ...n) {
|
|
|
4248
4255
|
*/
|
|
4249
4256
|
/**
|
|
4250
4257
|
* An immutable object representing an array of bytes.
|
|
4251
|
-
*/ class
|
|
4258
|
+
*/ class Vn {
|
|
4252
4259
|
/** @hideconstructor */
|
|
4253
4260
|
constructor(t) {
|
|
4254
4261
|
this._byteString = t;
|
|
@@ -4260,9 +4267,9 @@ function Tn(t, e, ...n) {
|
|
|
4260
4267
|
* @param base64 - The Base64 string used to create the `Bytes` object.
|
|
4261
4268
|
*/ static fromBase64String(t) {
|
|
4262
4269
|
try {
|
|
4263
|
-
return new
|
|
4270
|
+
return new Vn($t.fromBase64String(t));
|
|
4264
4271
|
} catch (t) {
|
|
4265
|
-
throw new
|
|
4272
|
+
throw new U(P, "Failed to construct data from Base64 string: " + t);
|
|
4266
4273
|
}
|
|
4267
4274
|
}
|
|
4268
4275
|
/**
|
|
@@ -4270,7 +4277,7 @@ function Tn(t, e, ...n) {
|
|
|
4270
4277
|
*
|
|
4271
4278
|
* @param array - The Uint8Array used to create the `Bytes` object.
|
|
4272
4279
|
*/ static fromUint8Array(t) {
|
|
4273
|
-
return new
|
|
4280
|
+
return new Vn($t.fromUint8Array(t));
|
|
4274
4281
|
}
|
|
4275
4282
|
/**
|
|
4276
4283
|
* Returns the underlying bytes as a Base64-encoded string.
|
|
@@ -4326,7 +4333,7 @@ function Tn(t, e, ...n) {
|
|
|
4326
4333
|
*
|
|
4327
4334
|
* Create a `FieldPath` by providing field names. If more than one field
|
|
4328
4335
|
* name is provided, the path will point to a nested field in a document.
|
|
4329
|
-
*/ class
|
|
4336
|
+
*/ class Nn {
|
|
4330
4337
|
/**
|
|
4331
4338
|
* Creates a `FieldPath` from the provided field names. If more than one field
|
|
4332
4339
|
* name is provided, the path will point to a nested field in a document.
|
|
@@ -4334,8 +4341,8 @@ function Tn(t, e, ...n) {
|
|
|
4334
4341
|
* @param fieldNames - A list of field names.
|
|
4335
4342
|
*/
|
|
4336
4343
|
constructor(...t) {
|
|
4337
|
-
for (let e = 0; e < t.length; ++e) if (0 === t[e].length) throw new
|
|
4338
|
-
this._internalPath = new
|
|
4344
|
+
for (let e = 0; e < t.length; ++e) if (0 === t[e].length) throw new U(P, "Invalid field name at argument $(i + 1). Field names must not be empty.");
|
|
4345
|
+
this._internalPath = new nt(t);
|
|
4339
4346
|
}
|
|
4340
4347
|
/**
|
|
4341
4348
|
* Returns true if this `FieldPath` is equal to the provided one.
|
|
@@ -4350,8 +4357,8 @@ function Tn(t, e, ...n) {
|
|
|
4350
4357
|
/**
|
|
4351
4358
|
* Returns a special sentinel `FieldPath` to refer to the ID of a document.
|
|
4352
4359
|
* It can be used in queries to sort or filter by the document ID.
|
|
4353
|
-
*/ function
|
|
4354
|
-
return new
|
|
4360
|
+
*/ function Dn() {
|
|
4361
|
+
return new Nn("__name__");
|
|
4355
4362
|
}
|
|
4356
4363
|
|
|
4357
4364
|
/**
|
|
@@ -4373,7 +4380,7 @@ function Tn(t, e, ...n) {
|
|
|
4373
4380
|
/**
|
|
4374
4381
|
* Sentinel values that can be used when writing document fields with `set()`
|
|
4375
4382
|
* or `update()`.
|
|
4376
|
-
*/ class
|
|
4383
|
+
*/ class $n {
|
|
4377
4384
|
/**
|
|
4378
4385
|
* @param _methodName - The public API endpoint that returns this class.
|
|
4379
4386
|
* @hideconstructor
|
|
@@ -4405,7 +4412,7 @@ function Tn(t, e, ...n) {
|
|
|
4405
4412
|
*
|
|
4406
4413
|
* Latitude values are in the range of [-90, 90].
|
|
4407
4414
|
* Longitude values are in the range of [-180, 180].
|
|
4408
|
-
*/ class
|
|
4415
|
+
*/ class xn {
|
|
4409
4416
|
/**
|
|
4410
4417
|
* Creates a new immutable `GeoPoint` object with the provided latitude and
|
|
4411
4418
|
* longitude values.
|
|
@@ -4413,8 +4420,8 @@ function Tn(t, e, ...n) {
|
|
|
4413
4420
|
* @param longitude - The longitude as number between -180 and 180.
|
|
4414
4421
|
*/
|
|
4415
4422
|
constructor(t, e) {
|
|
4416
|
-
if (!isFinite(t) || t < -90 || t > 90) throw new
|
|
4417
|
-
if (!isFinite(e) || e < -180 || e > 180) throw new
|
|
4423
|
+
if (!isFinite(t) || t < -90 || t > 90) throw new U(P, "Latitude must be a number between -90 and 90, but was: " + t);
|
|
4424
|
+
if (!isFinite(e) || e < -180 || e > 180) throw new U(P, "Longitude must be a number between -180 and 180, but was: " + e);
|
|
4418
4425
|
this._lat = t, this._long = e;
|
|
4419
4426
|
}
|
|
4420
4427
|
/**
|
|
@@ -4445,7 +4452,7 @@ function Tn(t, e, ...n) {
|
|
|
4445
4452
|
* Actually private to JS consumers of our API, so this function is prefixed
|
|
4446
4453
|
* with an underscore.
|
|
4447
4454
|
*/ _compareTo(t) {
|
|
4448
|
-
return
|
|
4455
|
+
return gt(this._lat, t._lat) || gt(this._long, t._long);
|
|
4449
4456
|
}
|
|
4450
4457
|
}
|
|
4451
4458
|
|
|
@@ -4464,29 +4471,29 @@ function Tn(t, e, ...n) {
|
|
|
4464
4471
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4465
4472
|
* See the License for the specific language governing permissions and
|
|
4466
4473
|
* limitations under the License.
|
|
4467
|
-
*/ const
|
|
4474
|
+
*/ const Fn = /^__.*__$/;
|
|
4468
4475
|
|
|
4469
|
-
/** The result of parsing document data (e.g. for a setData call). */ class
|
|
4476
|
+
/** The result of parsing document data (e.g. for a setData call). */ class Sn {
|
|
4470
4477
|
constructor(t, e, n) {
|
|
4471
4478
|
this.data = t, this.fieldMask = e, this.fieldTransforms = n;
|
|
4472
4479
|
}
|
|
4473
4480
|
toMutation(t, e) {
|
|
4474
|
-
return null !== this.fieldMask ? new
|
|
4481
|
+
return null !== this.fieldMask ? new $e(t, this.data, this.fieldMask, e, this.fieldTransforms) : new De(t, this.data, e, this.fieldTransforms);
|
|
4475
4482
|
}
|
|
4476
4483
|
}
|
|
4477
4484
|
|
|
4478
|
-
/** The result of parsing "update" data (i.e. for an updateData call). */ class
|
|
4485
|
+
/** The result of parsing "update" data (i.e. for an updateData call). */ class qn {
|
|
4479
4486
|
constructor(t,
|
|
4480
4487
|
// The fieldMask does not include document transforms.
|
|
4481
4488
|
e, n) {
|
|
4482
4489
|
this.data = t, this.fieldMask = e, this.fieldTransforms = n;
|
|
4483
4490
|
}
|
|
4484
4491
|
toMutation(t, e) {
|
|
4485
|
-
return new
|
|
4492
|
+
return new $e(t, this.data, this.fieldMask, e, this.fieldTransforms);
|
|
4486
4493
|
}
|
|
4487
4494
|
}
|
|
4488
4495
|
|
|
4489
|
-
function
|
|
4496
|
+
function On(t) {
|
|
4490
4497
|
switch (t) {
|
|
4491
4498
|
case 0 /* Set */ :
|
|
4492
4499
|
// fall through
|
|
@@ -4500,11 +4507,11 @@ function qn(t) {
|
|
|
4500
4507
|
return !1;
|
|
4501
4508
|
|
|
4502
4509
|
default:
|
|
4503
|
-
throw
|
|
4510
|
+
throw b();
|
|
4504
4511
|
}
|
|
4505
4512
|
}
|
|
4506
4513
|
|
|
4507
|
-
/** A "context" object passed around while parsing user data. */ class
|
|
4514
|
+
/** A "context" object passed around while parsing user data. */ class kn {
|
|
4508
4515
|
/**
|
|
4509
4516
|
* Initializes a ParseContext with the given source and path.
|
|
4510
4517
|
*
|
|
@@ -4536,7 +4543,7 @@ function qn(t) {
|
|
|
4536
4543
|
return this.settings.st;
|
|
4537
4544
|
}
|
|
4538
4545
|
/** Returns a new context with the specified settings overwritten. */ it(t) {
|
|
4539
|
-
return new
|
|
4546
|
+
return new kn(Object.assign(Object.assign({}, this.settings), t), this.databaseId, this.L, this.ignoreUndefinedProperties, this.fieldTransforms, this.fieldMask);
|
|
4540
4547
|
}
|
|
4541
4548
|
ot(t) {
|
|
4542
4549
|
var e;
|
|
@@ -4563,7 +4570,7 @@ function qn(t) {
|
|
|
4563
4570
|
});
|
|
4564
4571
|
}
|
|
4565
4572
|
lt(t) {
|
|
4566
|
-
return
|
|
4573
|
+
return rr(t, this.settings.methodName, this.settings.ft || !1, this.path, this.settings.dt);
|
|
4567
4574
|
}
|
|
4568
4575
|
/** Returns 'true' if 'fieldPath' was traversed when creating this context. */ contains(t) {
|
|
4569
4576
|
return void 0 !== this.fieldMask.find((e => t.isPrefixOf(e))) || void 0 !== this.fieldTransforms.find((e => t.isPrefixOf(e.field)));
|
|
@@ -4575,52 +4582,52 @@ function qn(t) {
|
|
|
4575
4582
|
}
|
|
4576
4583
|
ct(t) {
|
|
4577
4584
|
if (0 === t.length) throw this.lt("Document fields must not be empty");
|
|
4578
|
-
if (
|
|
4585
|
+
if (On(this.st) && Fn.test(t)) throw this.lt('Document fields cannot begin and end with "__"');
|
|
4579
4586
|
}
|
|
4580
4587
|
}
|
|
4581
4588
|
|
|
4582
4589
|
/**
|
|
4583
4590
|
* Helper for parsing raw user input (provided via the API) into internal model
|
|
4584
4591
|
* classes.
|
|
4585
|
-
*/ class
|
|
4592
|
+
*/ class Cn {
|
|
4586
4593
|
constructor(t, e, n) {
|
|
4587
|
-
this.databaseId = t, this.ignoreUndefinedProperties = e, this.L = n ||
|
|
4594
|
+
this.databaseId = t, this.ignoreUndefinedProperties = e, this.L = n || en(t);
|
|
4588
4595
|
}
|
|
4589
4596
|
/** Creates a new top-level parse context. */ wt(t, e, n, r = !1) {
|
|
4590
|
-
return new
|
|
4597
|
+
return new kn({
|
|
4591
4598
|
st: t,
|
|
4592
4599
|
methodName: e,
|
|
4593
4600
|
dt: n,
|
|
4594
|
-
path:
|
|
4601
|
+
path: nt.emptyPath(),
|
|
4595
4602
|
ut: !1,
|
|
4596
4603
|
ft: r
|
|
4597
4604
|
}, this.databaseId, this.L, this.ignoreUndefinedProperties);
|
|
4598
4605
|
}
|
|
4599
4606
|
}
|
|
4600
4607
|
|
|
4601
|
-
function
|
|
4602
|
-
const e = t._freezeSettings(), n =
|
|
4603
|
-
return new
|
|
4608
|
+
function Ln(t) {
|
|
4609
|
+
const e = t._freezeSettings(), n = en(t._databaseId);
|
|
4610
|
+
return new Cn(t._databaseId, !!e.ignoreUndefinedProperties, n);
|
|
4604
4611
|
}
|
|
4605
4612
|
|
|
4606
|
-
/** Parse document data from a set() call. */ function
|
|
4613
|
+
/** Parse document data from a set() call. */ function Mn(t, e, n, r, s, i = {}) {
|
|
4607
4614
|
const o = t.wt(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ , e, n, s);
|
|
4608
|
-
|
|
4609
|
-
const u =
|
|
4615
|
+
Zn("Data must be an object, but it was:", o, r);
|
|
4616
|
+
const u = Jn(r, o);
|
|
4610
4617
|
let c, a;
|
|
4611
|
-
if (i.merge) c = new
|
|
4618
|
+
if (i.merge) c = new Dt(o.fieldMask), a = o.fieldTransforms; else if (i.mergeFields) {
|
|
4612
4619
|
const t = [];
|
|
4613
4620
|
for (const r of i.mergeFields) {
|
|
4614
|
-
const s =
|
|
4615
|
-
if (!o.contains(s)) throw new
|
|
4616
|
-
|
|
4621
|
+
const s = tr(e, r, n);
|
|
4622
|
+
if (!o.contains(s)) throw new U(P, `Field '${s}' is specified in your field mask but missing from your input data.`);
|
|
4623
|
+
sr(t, s) || t.push(s);
|
|
4617
4624
|
}
|
|
4618
|
-
c = new
|
|
4625
|
+
c = new Dt(t), a = o.fieldTransforms.filter((t => c.covers(t.field)));
|
|
4619
4626
|
} else c = null, a = o.fieldTransforms;
|
|
4620
|
-
return new
|
|
4627
|
+
return new Sn(new Jt(u), c, a);
|
|
4621
4628
|
}
|
|
4622
4629
|
|
|
4623
|
-
class
|
|
4630
|
+
class Un extends $n {
|
|
4624
4631
|
_toFieldTransform(t) {
|
|
4625
4632
|
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}`);
|
|
4626
4633
|
// No transform to add for a delete, but we need to add it to our
|
|
@@ -4628,7 +4635,7 @@ class Mn extends Dn {
|
|
|
4628
4635
|
return t.fieldMask.push(t.path), null;
|
|
4629
4636
|
}
|
|
4630
4637
|
isEqual(t) {
|
|
4631
|
-
return t instanceof
|
|
4638
|
+
return t instanceof Un;
|
|
4632
4639
|
}
|
|
4633
4640
|
}
|
|
4634
4641
|
|
|
@@ -4647,8 +4654,8 @@ class Mn extends Dn {
|
|
|
4647
4654
|
* context.
|
|
4648
4655
|
* @param context - The parent context.
|
|
4649
4656
|
* @param arrayElement - Whether or not the FieldValue has an array.
|
|
4650
|
-
*/ function
|
|
4651
|
-
return new
|
|
4657
|
+
*/ function jn(t, e, n) {
|
|
4658
|
+
return new kn({
|
|
4652
4659
|
st: 3 /* Argument */ ,
|
|
4653
4660
|
dt: e.settings.dt,
|
|
4654
4661
|
methodName: t._methodName,
|
|
@@ -4656,23 +4663,23 @@ class Mn extends Dn {
|
|
|
4656
4663
|
}, e.databaseId, e.L, e.ignoreUndefinedProperties);
|
|
4657
4664
|
}
|
|
4658
4665
|
|
|
4659
|
-
class
|
|
4666
|
+
class Bn extends $n {
|
|
4660
4667
|
_toFieldTransform(t) {
|
|
4661
|
-
return new
|
|
4668
|
+
return new Pe(t.path, new Ie);
|
|
4662
4669
|
}
|
|
4663
4670
|
isEqual(t) {
|
|
4664
|
-
return t instanceof
|
|
4671
|
+
return t instanceof Bn;
|
|
4665
4672
|
}
|
|
4666
4673
|
}
|
|
4667
4674
|
|
|
4668
|
-
class
|
|
4675
|
+
class Qn extends $n {
|
|
4669
4676
|
constructor(t, e) {
|
|
4670
4677
|
super(t), this.yt = e;
|
|
4671
4678
|
}
|
|
4672
4679
|
_toFieldTransform(t) {
|
|
4673
|
-
const e =
|
|
4674
|
-
/*array=*/ !0), n = this.yt.map((t =>
|
|
4675
|
-
return new
|
|
4680
|
+
const e = jn(this, t,
|
|
4681
|
+
/*array=*/ !0), n = this.yt.map((t => Hn(t, e))), r = new Te(n);
|
|
4682
|
+
return new Pe(t.path, r);
|
|
4676
4683
|
}
|
|
4677
4684
|
isEqual(t) {
|
|
4678
4685
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4680,14 +4687,14 @@ class Bn extends Dn {
|
|
|
4680
4687
|
}
|
|
4681
4688
|
}
|
|
4682
4689
|
|
|
4683
|
-
class
|
|
4690
|
+
class zn extends $n {
|
|
4684
4691
|
constructor(t, e) {
|
|
4685
4692
|
super(t), this.yt = e;
|
|
4686
4693
|
}
|
|
4687
4694
|
_toFieldTransform(t) {
|
|
4688
|
-
const e =
|
|
4689
|
-
/*array=*/ !0), n = this.yt.map((t =>
|
|
4690
|
-
return new
|
|
4695
|
+
const e = jn(this, t,
|
|
4696
|
+
/*array=*/ !0), n = this.yt.map((t => Hn(t, e))), r = new Ae(n);
|
|
4697
|
+
return new Pe(t.path, r);
|
|
4691
4698
|
}
|
|
4692
4699
|
isEqual(t) {
|
|
4693
4700
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4695,13 +4702,13 @@ class Qn extends Dn {
|
|
|
4695
4702
|
}
|
|
4696
4703
|
}
|
|
4697
4704
|
|
|
4698
|
-
class
|
|
4705
|
+
class Gn extends $n {
|
|
4699
4706
|
constructor(t, e) {
|
|
4700
4707
|
super(t), this._t = e;
|
|
4701
4708
|
}
|
|
4702
4709
|
_toFieldTransform(t) {
|
|
4703
|
-
const e = new
|
|
4704
|
-
return new
|
|
4710
|
+
const e = new Re(t.L, be(t.L, this._t));
|
|
4711
|
+
return new Pe(t.path, e);
|
|
4705
4712
|
}
|
|
4706
4713
|
isEqual(t) {
|
|
4707
4714
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4709,50 +4716,50 @@ class zn extends Dn {
|
|
|
4709
4716
|
}
|
|
4710
4717
|
}
|
|
4711
4718
|
|
|
4712
|
-
/** Parse update data from an update() call. */ function
|
|
4719
|
+
/** Parse update data from an update() call. */ function Wn(t, e, n, r) {
|
|
4713
4720
|
const s = t.wt(1 /* Update */ , e, n);
|
|
4714
|
-
|
|
4715
|
-
const i = [], o =
|
|
4716
|
-
|
|
4717
|
-
const u =
|
|
4721
|
+
Zn("Data must be an object, but it was:", s, r);
|
|
4722
|
+
const i = [], o = Jt.empty();
|
|
4723
|
+
Tt(r, ((t, r) => {
|
|
4724
|
+
const u = nr(e, t, n);
|
|
4718
4725
|
// For Compat types, we have to "extract" the underlying types before
|
|
4719
4726
|
// performing validation.
|
|
4720
4727
|
r = getModularInstance(r);
|
|
4721
4728
|
const c = s.at(u);
|
|
4722
|
-
if (r instanceof
|
|
4729
|
+
if (r instanceof Un)
|
|
4723
4730
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4724
4731
|
i.push(u); else {
|
|
4725
|
-
const t =
|
|
4732
|
+
const t = Hn(r, c);
|
|
4726
4733
|
null != t && (i.push(u), o.set(u, t));
|
|
4727
4734
|
}
|
|
4728
4735
|
}));
|
|
4729
|
-
const u = new
|
|
4730
|
-
return new
|
|
4736
|
+
const u = new Dt(i);
|
|
4737
|
+
return new qn(o, u, s.fieldTransforms);
|
|
4731
4738
|
}
|
|
4732
4739
|
|
|
4733
|
-
/** Parse update data from a list of field/value arguments. */ function
|
|
4734
|
-
const o = t.wt(1 /* Update */ , e, n), u = [
|
|
4735
|
-
if (i.length % 2 != 0) throw new
|
|
4736
|
-
for (let t = 0; t < i.length; t += 2) u.push(
|
|
4737
|
-
const a = [],
|
|
4740
|
+
/** Parse update data from a list of field/value arguments. */ function Kn(t, e, n, r, s, i) {
|
|
4741
|
+
const o = t.wt(1 /* Update */ , e, n), u = [ tr(e, r, n) ], c = [ s ];
|
|
4742
|
+
if (i.length % 2 != 0) throw new U(P, `Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);
|
|
4743
|
+
for (let t = 0; t < i.length; t += 2) u.push(tr(e, i[t])), c.push(i[t + 1]);
|
|
4744
|
+
const a = [], h = Jt.empty();
|
|
4738
4745
|
// We iterate in reverse order to pick the last value for a field if the
|
|
4739
4746
|
// user specified the field multiple times.
|
|
4740
|
-
for (let t = u.length - 1; t >= 0; --t) if (!
|
|
4747
|
+
for (let t = u.length - 1; t >= 0; --t) if (!sr(a, u[t])) {
|
|
4741
4748
|
const e = u[t];
|
|
4742
4749
|
let n = c[t];
|
|
4743
4750
|
// For Compat types, we have to "extract" the underlying types before
|
|
4744
4751
|
// performing validation.
|
|
4745
4752
|
n = getModularInstance(n);
|
|
4746
4753
|
const r = o.at(e);
|
|
4747
|
-
if (n instanceof
|
|
4754
|
+
if (n instanceof Un)
|
|
4748
4755
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4749
4756
|
a.push(e); else {
|
|
4750
|
-
const t =
|
|
4751
|
-
null != t && (a.push(e),
|
|
4757
|
+
const t = Hn(n, r);
|
|
4758
|
+
null != t && (a.push(e), h.set(e, t));
|
|
4752
4759
|
}
|
|
4753
4760
|
}
|
|
4754
|
-
const f = new
|
|
4755
|
-
return new
|
|
4761
|
+
const f = new Dt(a);
|
|
4762
|
+
return new qn(h, f, o.fieldTransforms);
|
|
4756
4763
|
}
|
|
4757
4764
|
|
|
4758
4765
|
/**
|
|
@@ -4761,8 +4768,8 @@ class zn extends Dn {
|
|
|
4761
4768
|
*
|
|
4762
4769
|
* @param allowArrays - Whether the query value is an array that may directly
|
|
4763
4770
|
* contain additional arrays (e.g. the operand of an `in` query).
|
|
4764
|
-
*/ function
|
|
4765
|
-
return
|
|
4771
|
+
*/ function Yn(t, e, n, r = !1) {
|
|
4772
|
+
return Hn(n, t.wt(r ? 4 /* ArrayArgument */ : 3 /* Argument */ , e));
|
|
4766
4773
|
}
|
|
4767
4774
|
|
|
4768
4775
|
/**
|
|
@@ -4773,12 +4780,12 @@ class zn extends Dn {
|
|
|
4773
4780
|
* the source of the data being parsed, etc.
|
|
4774
4781
|
* @returns The parsed value, or null if the value was a FieldValue sentinel
|
|
4775
4782
|
* that should not be included in the resulting parsed data.
|
|
4776
|
-
*/ function
|
|
4777
|
-
if (
|
|
4783
|
+
*/ function Hn(t, e) {
|
|
4784
|
+
if (Xn(
|
|
4778
4785
|
// Unwrap the API type from the Compat SDK. This will return the API type
|
|
4779
4786
|
// from firestore-exp.
|
|
4780
|
-
t = getModularInstance(t))) return
|
|
4781
|
-
if (t instanceof
|
|
4787
|
+
t = getModularInstance(t))) return Zn("Unsupported field value:", e, t), Jn(t, e);
|
|
4788
|
+
if (t instanceof $n)
|
|
4782
4789
|
// FieldValues usually parse into transforms (except deleteField())
|
|
4783
4790
|
// in which case we do not want to include this field in our parsed data
|
|
4784
4791
|
// (as doing so will overwrite the field directly prior to the transform
|
|
@@ -4790,7 +4797,7 @@ class zn extends Dn {
|
|
|
4790
4797
|
*/
|
|
4791
4798
|
return function(t, e) {
|
|
4792
4799
|
// Sentinels are only supported with writes, and not within arrays.
|
|
4793
|
-
if (!
|
|
4800
|
+
if (!On(e.st)) throw e.lt(`${t._methodName}() can only be used with update() and set()`);
|
|
4794
4801
|
if (!e.path) throw e.lt(`${t._methodName}() is not currently supported inside arrays`);
|
|
4795
4802
|
const n = t._toFieldTransform(e);
|
|
4796
4803
|
n && e.fieldTransforms.push(n);
|
|
@@ -4820,7 +4827,7 @@ class zn extends Dn {
|
|
|
4820
4827
|
const n = [];
|
|
4821
4828
|
let r = 0;
|
|
4822
4829
|
for (const s of t) {
|
|
4823
|
-
let t =
|
|
4830
|
+
let t = Hn(s, e.ht(r));
|
|
4824
4831
|
null == t && (
|
|
4825
4832
|
// Just include nulls in the array for fields being replaced with a
|
|
4826
4833
|
// sentinel.
|
|
@@ -4839,7 +4846,7 @@ class zn extends Dn {
|
|
|
4839
4846
|
if (null === (t = getModularInstance(t))) return {
|
|
4840
4847
|
nullValue: "NULL_VALUE"
|
|
4841
4848
|
};
|
|
4842
|
-
if ("number" == typeof t) return
|
|
4849
|
+
if ("number" == typeof t) return be(e.L, t);
|
|
4843
4850
|
if ("boolean" == typeof t) return {
|
|
4844
4851
|
booleanValue: t
|
|
4845
4852
|
};
|
|
@@ -4847,37 +4854,37 @@ class zn extends Dn {
|
|
|
4847
4854
|
stringValue: t
|
|
4848
4855
|
};
|
|
4849
4856
|
if (t instanceof Date) {
|
|
4850
|
-
const n =
|
|
4857
|
+
const n = bt.fromDate(t);
|
|
4851
4858
|
return {
|
|
4852
|
-
timestampValue:
|
|
4859
|
+
timestampValue: ke(e.L, n)
|
|
4853
4860
|
};
|
|
4854
4861
|
}
|
|
4855
|
-
if (t instanceof
|
|
4862
|
+
if (t instanceof bt) {
|
|
4856
4863
|
// Firestore backend truncates precision down to microseconds. To ensure
|
|
4857
4864
|
// offline mode works the same with regards to truncation, perform the
|
|
4858
4865
|
// truncation immediately without waiting for the backend to do that.
|
|
4859
|
-
const n = new
|
|
4866
|
+
const n = new bt(t.seconds, 1e3 * Math.floor(t.nanoseconds / 1e3));
|
|
4860
4867
|
return {
|
|
4861
|
-
timestampValue:
|
|
4868
|
+
timestampValue: ke(e.L, n)
|
|
4862
4869
|
};
|
|
4863
4870
|
}
|
|
4864
|
-
if (t instanceof
|
|
4871
|
+
if (t instanceof xn) return {
|
|
4865
4872
|
geoPointValue: {
|
|
4866
4873
|
latitude: t.latitude,
|
|
4867
4874
|
longitude: t.longitude
|
|
4868
4875
|
}
|
|
4869
4876
|
};
|
|
4870
|
-
if (t instanceof
|
|
4871
|
-
bytesValue:
|
|
4877
|
+
if (t instanceof Vn) return {
|
|
4878
|
+
bytesValue: Ce(e.L, t._byteString)
|
|
4872
4879
|
};
|
|
4873
|
-
if (t instanceof
|
|
4880
|
+
if (t instanceof vn) {
|
|
4874
4881
|
const n = e.databaseId, r = t.firestore._databaseId;
|
|
4875
4882
|
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}`);
|
|
4876
4883
|
return {
|
|
4877
|
-
referenceValue:
|
|
4884
|
+
referenceValue: Ue(t.firestore._databaseId || e.databaseId, t._key.path)
|
|
4878
4885
|
};
|
|
4879
4886
|
}
|
|
4880
|
-
throw e.lt(`Unsupported field value: ${
|
|
4887
|
+
throw e.lt(`Unsupported field value: ${ut(t)}`);
|
|
4881
4888
|
}
|
|
4882
4889
|
/**
|
|
4883
4890
|
* Checks whether an object looks like a JSON object that should be converted
|
|
@@ -4888,13 +4895,13 @@ class zn extends Dn {
|
|
|
4888
4895
|
*/ (t, e);
|
|
4889
4896
|
}
|
|
4890
4897
|
|
|
4891
|
-
function
|
|
4898
|
+
function Jn(t, e) {
|
|
4892
4899
|
const n = {};
|
|
4893
4900
|
return !function(t) {
|
|
4894
4901
|
for (const e in t) if (Object.prototype.hasOwnProperty.call(t, e)) return !1;
|
|
4895
4902
|
return !0;
|
|
4896
|
-
}(t) ?
|
|
4897
|
-
const s =
|
|
4903
|
+
}(t) ? Tt(t, ((t, r) => {
|
|
4904
|
+
const s = Hn(r, e.ot(t));
|
|
4898
4905
|
null != s && (n[t] = s);
|
|
4899
4906
|
})) :
|
|
4900
4907
|
// If we encounter an empty object, we explicitly add it to the update
|
|
@@ -4906,35 +4913,35 @@ function Hn(t, e) {
|
|
|
4906
4913
|
};
|
|
4907
4914
|
}
|
|
4908
4915
|
|
|
4909
|
-
function
|
|
4910
|
-
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof
|
|
4916
|
+
function Xn(t) {
|
|
4917
|
+
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof bt || t instanceof xn || t instanceof Vn || t instanceof vn || t instanceof $n);
|
|
4911
4918
|
}
|
|
4912
4919
|
|
|
4913
|
-
function
|
|
4914
|
-
if (!
|
|
4920
|
+
function Zn(t, e, n) {
|
|
4921
|
+
if (!Xn(n) || !function(t) {
|
|
4915
4922
|
return "object" == typeof t && null !== t && (Object.getPrototypeOf(t) === Object.prototype || null === Object.getPrototypeOf(t));
|
|
4916
4923
|
}(n)) {
|
|
4917
|
-
const r =
|
|
4924
|
+
const r = ut(n);
|
|
4918
4925
|
throw "an object" === r ? e.lt(t + " a custom object") : e.lt(t + " " + r);
|
|
4919
4926
|
}
|
|
4920
4927
|
}
|
|
4921
4928
|
|
|
4922
4929
|
/**
|
|
4923
4930
|
* Helper that calls fromDotSeparatedString() but wraps any error thrown.
|
|
4924
|
-
*/ function
|
|
4931
|
+
*/ function tr(t, e, n) {
|
|
4925
4932
|
if ((
|
|
4926
4933
|
// If required, replace the FieldPath Compat class with with the firestore-exp
|
|
4927
4934
|
// FieldPath.
|
|
4928
|
-
e = getModularInstance(e)) instanceof
|
|
4929
|
-
if ("string" == typeof e) return
|
|
4930
|
-
throw
|
|
4935
|
+
e = getModularInstance(e)) instanceof Nn) return e._internalPath;
|
|
4936
|
+
if ("string" == typeof e) return nr(t, e);
|
|
4937
|
+
throw rr("Field path arguments must be of type string or ", t,
|
|
4931
4938
|
/* hasConverter= */ !1,
|
|
4932
4939
|
/* path= */ void 0, n);
|
|
4933
4940
|
}
|
|
4934
4941
|
|
|
4935
4942
|
/**
|
|
4936
4943
|
* Matches any characters in a field path string that are reserved.
|
|
4937
|
-
*/ const
|
|
4944
|
+
*/ const er = new RegExp("[~\\*/\\[\\]]");
|
|
4938
4945
|
|
|
4939
4946
|
/**
|
|
4940
4947
|
* Wraps fromDotSeparatedString with an error message about the method that
|
|
@@ -4944,29 +4951,29 @@ function Xn(t, e, n) {
|
|
|
4944
4951
|
* split on dots.
|
|
4945
4952
|
* @param targetDoc - The document against which the field path will be
|
|
4946
4953
|
* evaluated.
|
|
4947
|
-
*/ function
|
|
4948
|
-
if (e.search(
|
|
4954
|
+
*/ function nr(t, e, n) {
|
|
4955
|
+
if (e.search(er) >= 0) throw rr(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`, t,
|
|
4949
4956
|
/* hasConverter= */ !1,
|
|
4950
4957
|
/* path= */ void 0, n);
|
|
4951
4958
|
try {
|
|
4952
|
-
return new
|
|
4959
|
+
return new Nn(...e.split("."))._internalPath;
|
|
4953
4960
|
} catch (r) {
|
|
4954
|
-
throw
|
|
4961
|
+
throw rr(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`, t,
|
|
4955
4962
|
/* hasConverter= */ !1,
|
|
4956
4963
|
/* path= */ void 0, n);
|
|
4957
4964
|
}
|
|
4958
4965
|
}
|
|
4959
4966
|
|
|
4960
|
-
function
|
|
4967
|
+
function rr(t, e, n, r, s) {
|
|
4961
4968
|
const i = r && !r.isEmpty(), o = void 0 !== s;
|
|
4962
4969
|
let u = `Function ${e}() called with invalid data`;
|
|
4963
4970
|
n && (u += " (via `toFirestore()`)"), u += ". ";
|
|
4964
4971
|
let c = "";
|
|
4965
4972
|
return (i || o) && (c += " (found", i && (c += ` in field ${r}`), o && (c += ` in document ${s}`),
|
|
4966
|
-
c += ")"), new
|
|
4973
|
+
c += ")"), new U(P, u + t + c);
|
|
4967
4974
|
}
|
|
4968
4975
|
|
|
4969
|
-
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function
|
|
4976
|
+
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function sr(t, e) {
|
|
4970
4977
|
return t.some((t => t.isEqual(e)));
|
|
4971
4978
|
}
|
|
4972
4979
|
|
|
@@ -4994,7 +5001,7 @@ function nr(t, e, n, r, s) {
|
|
|
4994
5001
|
* For a `DocumentSnapshot` that points to a non-existing document, any data
|
|
4995
5002
|
* access will return 'undefined'. You can use the `exists()` method to
|
|
4996
5003
|
* explicitly verify a document's existence.
|
|
4997
|
-
*/ class
|
|
5004
|
+
*/ class ir {
|
|
4998
5005
|
// Note: This class is stripped down version of the DocumentSnapshot in
|
|
4999
5006
|
// the legacy SDK. The changes are:
|
|
5000
5007
|
// - No support for SnapshotMetadata.
|
|
@@ -5010,7 +5017,7 @@ function nr(t, e, n, r, s) {
|
|
|
5010
5017
|
/**
|
|
5011
5018
|
* The `DocumentReference` for the document included in the `DocumentSnapshot`.
|
|
5012
5019
|
*/ get ref() {
|
|
5013
|
-
return new
|
|
5020
|
+
return new vn(this._firestore, this._converter, this._key);
|
|
5014
5021
|
}
|
|
5015
5022
|
/**
|
|
5016
5023
|
* Signals whether or not the document at the snapshot's location exists.
|
|
@@ -5030,7 +5037,7 @@ function nr(t, e, n, r, s) {
|
|
|
5030
5037
|
if (this._converter) {
|
|
5031
5038
|
// We only want to use the converter and create a new DocumentSnapshot
|
|
5032
5039
|
// if a converter has been provided.
|
|
5033
|
-
const t = new
|
|
5040
|
+
const t = new or(this._firestore, this._userDataWriter, this._key, this._document,
|
|
5034
5041
|
/* converter= */ null);
|
|
5035
5042
|
return this._converter.fromFirestore(t);
|
|
5036
5043
|
}
|
|
@@ -5050,7 +5057,7 @@ function nr(t, e, n, r, s) {
|
|
|
5050
5057
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5051
5058
|
get(t) {
|
|
5052
5059
|
if (this._document) {
|
|
5053
|
-
const e = this._document.data.field(
|
|
5060
|
+
const e = this._document.data.field(ar("DocumentSnapshot.get", t));
|
|
5054
5061
|
if (null !== e) return this._userDataWriter.convertValue(e);
|
|
5055
5062
|
}
|
|
5056
5063
|
}
|
|
@@ -5066,7 +5073,7 @@ function nr(t, e, n, r, s) {
|
|
|
5066
5073
|
* `DocumentSnapshot`. Since query results contain only existing documents, the
|
|
5067
5074
|
* `exists` property will always be true and `data()` will never return
|
|
5068
5075
|
* 'undefined'.
|
|
5069
|
-
*/ class
|
|
5076
|
+
*/ class or extends ir {
|
|
5070
5077
|
/**
|
|
5071
5078
|
* Retrieves all fields in the document as an `Object`.
|
|
5072
5079
|
*
|
|
@@ -5084,7 +5091,7 @@ function nr(t, e, n, r, s) {
|
|
|
5084
5091
|
* array via the `docs` property or enumerated using the `forEach` method. The
|
|
5085
5092
|
* number of documents can be determined via the `empty` and `size`
|
|
5086
5093
|
* properties.
|
|
5087
|
-
*/ class
|
|
5094
|
+
*/ class ur {
|
|
5088
5095
|
/** @hideconstructor */
|
|
5089
5096
|
constructor(t, e) {
|
|
5090
5097
|
this._docs = e, this.query = t;
|
|
@@ -5115,14 +5122,14 @@ function nr(t, e, n, r, s) {
|
|
|
5115
5122
|
* @param left - A snapshot to compare.
|
|
5116
5123
|
* @param right - A snapshot to compare.
|
|
5117
5124
|
* @returns true if the snapshots are equal.
|
|
5118
|
-
*/ function
|
|
5119
|
-
return t = getModularInstance(t), e = getModularInstance(e), t instanceof
|
|
5125
|
+
*/ function cr(t, e) {
|
|
5126
|
+
return t = getModularInstance(t), e = getModularInstance(e), t instanceof ir && e instanceof ir ? 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 ur && e instanceof ur && (Pn(t.query, e.query) && vt(t.docs, e.docs, cr));
|
|
5120
5127
|
}
|
|
5121
5128
|
|
|
5122
5129
|
/**
|
|
5123
5130
|
* Helper that calls `fromDotSeparatedString()` but wraps any error thrown.
|
|
5124
|
-
*/ function
|
|
5125
|
-
return "string" == typeof e ?
|
|
5131
|
+
*/ function ar(t, e) {
|
|
5132
|
+
return "string" == typeof e ? nr(t, e) : e instanceof Nn ? e._internalPath : e._delegate._internalPath;
|
|
5126
5133
|
}
|
|
5127
5134
|
|
|
5128
5135
|
/**
|
|
@@ -5149,7 +5156,7 @@ function nr(t, e, n, r, s) {
|
|
|
5149
5156
|
* can then be passed to {@link query} to create a new query instance that
|
|
5150
5157
|
* also contains this `QueryConstraint`.
|
|
5151
5158
|
*/
|
|
5152
|
-
class
|
|
5159
|
+
class hr {}
|
|
5153
5160
|
|
|
5154
5161
|
/**
|
|
5155
5162
|
* Creates a new immutable instance of {@link Query} that is extended to also include
|
|
@@ -5159,40 +5166,40 @@ class ar {}
|
|
|
5159
5166
|
* @param queryConstraints - The list of {@link QueryConstraint}s to apply.
|
|
5160
5167
|
* @throws if any of the provided query constraints cannot be combined with the
|
|
5161
5168
|
* existing or new constraints.
|
|
5162
|
-
*/ function
|
|
5169
|
+
*/ function lr(t, ...e) {
|
|
5163
5170
|
for (const n of e) t = n._apply(t);
|
|
5164
5171
|
return t;
|
|
5165
5172
|
}
|
|
5166
5173
|
|
|
5167
|
-
class
|
|
5174
|
+
class fr extends hr {
|
|
5168
5175
|
constructor(t, e, n) {
|
|
5169
5176
|
super(), this.gt = t, this.vt = e, this.bt = n, this.type = "where";
|
|
5170
5177
|
}
|
|
5171
5178
|
_apply(t) {
|
|
5172
|
-
const e =
|
|
5179
|
+
const e = Ln(t.firestore), n = function(t, e, n, r, s, i, o) {
|
|
5173
5180
|
let u;
|
|
5174
5181
|
if (s.isKeyField()) {
|
|
5175
|
-
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new
|
|
5182
|
+
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new U(P, `Invalid Query. You can't perform '${i}' queries on documentId().`);
|
|
5176
5183
|
if ("in" /* IN */ === i || "not-in" /* NOT_IN */ === i) {
|
|
5177
|
-
|
|
5184
|
+
Pr(o, i);
|
|
5178
5185
|
const e = [];
|
|
5179
|
-
for (const n of o) e.push(
|
|
5186
|
+
for (const n of o) e.push(Rr(r, t, n));
|
|
5180
5187
|
u = {
|
|
5181
5188
|
arrayValue: {
|
|
5182
5189
|
values: e
|
|
5183
5190
|
}
|
|
5184
5191
|
};
|
|
5185
|
-
} else u =
|
|
5186
|
-
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i ||
|
|
5187
|
-
u =
|
|
5192
|
+
} else u = Rr(r, t, o);
|
|
5193
|
+
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i || Pr(o, i),
|
|
5194
|
+
u = Yn(n, e, o,
|
|
5188
5195
|
/* allowArrays= */ "in" /* IN */ === i || "not-in" /* NOT_IN */ === i);
|
|
5189
|
-
const c =
|
|
5196
|
+
const c = ee.create(s, i, u);
|
|
5190
5197
|
return function(t, e) {
|
|
5191
5198
|
if (e.q()) {
|
|
5192
|
-
const n =
|
|
5193
|
-
if (null !== n && !n.isEqual(e.field)) throw new
|
|
5194
|
-
const r =
|
|
5195
|
-
null !== r &&
|
|
5199
|
+
const n = pe(t);
|
|
5200
|
+
if (null !== n && !n.isEqual(e.field)) throw new U(P, `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()}'`);
|
|
5201
|
+
const r = me(t);
|
|
5202
|
+
null !== r && Vr(t, e.field, r);
|
|
5196
5203
|
}
|
|
5197
5204
|
const n = function(t, e) {
|
|
5198
5205
|
for (const n of t.filters) if (e.indexOf(n.op) >= 0) return n.op;
|
|
@@ -5233,12 +5240,12 @@ class lr extends ar {
|
|
|
5233
5240
|
}(e.op));
|
|
5234
5241
|
if (null !== n)
|
|
5235
5242
|
// Special case when it's a duplicate op to give a slightly clearer error message.
|
|
5236
|
-
throw n === e.op ? new
|
|
5243
|
+
throw n === e.op ? new U(P, `Invalid query. You cannot use more than one '${e.op.toString()}' filter.`) : new U(P, `Invalid query. You cannot use '${e.op.toString()}' filters with '${n.toString()}' filters.`);
|
|
5237
5244
|
}(t, c), c;
|
|
5238
5245
|
}(t._query, "where", e, t.firestore._databaseId, this.gt, this.vt, this.bt);
|
|
5239
|
-
return new
|
|
5246
|
+
return new bn(t.firestore, t.converter, function(t, e) {
|
|
5240
5247
|
const n = t.filters.concat([ e ]);
|
|
5241
|
-
return new
|
|
5248
|
+
return new we(t.path, t.collectionGroup, t.explicitOrderBy.slice(), n, t.limit, t.limitType, t.startAt, t.endAt);
|
|
5242
5249
|
}(t._query, n));
|
|
5243
5250
|
}
|
|
5244
5251
|
}
|
|
@@ -5253,25 +5260,25 @@ class lr extends ar {
|
|
|
5253
5260
|
* "<=", "!=").
|
|
5254
5261
|
* @param value - The value for comparison
|
|
5255
5262
|
* @returns The created {@link Query}.
|
|
5256
|
-
*/ function
|
|
5257
|
-
const r = e, s =
|
|
5258
|
-
return new
|
|
5263
|
+
*/ function dr(t, e, n) {
|
|
5264
|
+
const r = e, s = ar("where", t);
|
|
5265
|
+
return new fr(s, r, n);
|
|
5259
5266
|
}
|
|
5260
5267
|
|
|
5261
|
-
class
|
|
5268
|
+
class wr extends hr {
|
|
5262
5269
|
constructor(t, e) {
|
|
5263
5270
|
super(), this.gt = t, this.Et = e, this.type = "orderBy";
|
|
5264
5271
|
}
|
|
5265
5272
|
_apply(t) {
|
|
5266
5273
|
const e = function(t, e, n) {
|
|
5267
|
-
if (null !== t.startAt) throw new
|
|
5268
|
-
if (null !== t.endAt) throw new
|
|
5269
|
-
const r = new
|
|
5274
|
+
if (null !== t.startAt) throw new U(P, "Invalid query. You must not call startAt() or startAfter() before calling orderBy().");
|
|
5275
|
+
if (null !== t.endAt) throw new U(P, "Invalid query. You must not call endAt() or endBefore() before calling orderBy().");
|
|
5276
|
+
const r = new le(e, n);
|
|
5270
5277
|
return function(t, e) {
|
|
5271
|
-
if (null ===
|
|
5278
|
+
if (null === me(t)) {
|
|
5272
5279
|
// This is the first order by. It must match any inequality.
|
|
5273
|
-
const n =
|
|
5274
|
-
null !== n &&
|
|
5280
|
+
const n = pe(t);
|
|
5281
|
+
null !== n && Vr(t, n, e.field);
|
|
5275
5282
|
}
|
|
5276
5283
|
}(t, r), r;
|
|
5277
5284
|
}
|
|
@@ -5286,10 +5293,10 @@ class dr extends ar {
|
|
|
5286
5293
|
* of the query or if any of the fields in the order by are an uncommitted
|
|
5287
5294
|
* server timestamp.
|
|
5288
5295
|
*/ (t._query, this.gt, this.Et);
|
|
5289
|
-
return new
|
|
5296
|
+
return new bn(t.firestore, t.converter, function(t, e) {
|
|
5290
5297
|
// TODO(dimond): validate that orderBy does not list the same key twice.
|
|
5291
5298
|
const n = t.explicitOrderBy.concat([ e ]);
|
|
5292
|
-
return new
|
|
5299
|
+
return new we(t.path, t.collectionGroup, n, t.filters.slice(), t.limit, t.limitType, t.startAt, t.endAt);
|
|
5293
5300
|
}(t._query, e));
|
|
5294
5301
|
}
|
|
5295
5302
|
}
|
|
@@ -5302,18 +5309,18 @@ class dr extends ar {
|
|
|
5302
5309
|
* @param directionStr - Optional direction to sort by ('asc' or 'desc'). If
|
|
5303
5310
|
* not specified, order will be ascending.
|
|
5304
5311
|
* @returns The created {@link Query}.
|
|
5305
|
-
*/ function
|
|
5306
|
-
const n = e, r =
|
|
5307
|
-
return new
|
|
5312
|
+
*/ function mr(t, e = "asc") {
|
|
5313
|
+
const n = e, r = ar("orderBy", t);
|
|
5314
|
+
return new wr(r, n);
|
|
5308
5315
|
}
|
|
5309
5316
|
|
|
5310
|
-
class
|
|
5317
|
+
class pr extends hr {
|
|
5311
5318
|
constructor(t, e, n) {
|
|
5312
5319
|
super(), this.type = t, this.It = e, this.Tt = n;
|
|
5313
5320
|
}
|
|
5314
5321
|
_apply(t) {
|
|
5315
|
-
return new
|
|
5316
|
-
return new
|
|
5322
|
+
return new bn(t.firestore, t.converter, function(t, e, n) {
|
|
5323
|
+
return new we(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), e, n, t.startAt, t.endAt);
|
|
5317
5324
|
}(t._query, this.It, this.Tt));
|
|
5318
5325
|
}
|
|
5319
5326
|
}
|
|
@@ -5323,8 +5330,8 @@ class mr extends ar {
|
|
|
5323
5330
|
*
|
|
5324
5331
|
* @param limit - The maximum number of items to return.
|
|
5325
5332
|
* @returns The created {@link Query}.
|
|
5326
|
-
*/ function
|
|
5327
|
-
return
|
|
5333
|
+
*/ function yr(t) {
|
|
5334
|
+
return at("limit", t), new pr("limit", t, "F" /* First */);
|
|
5328
5335
|
}
|
|
5329
5336
|
|
|
5330
5337
|
/**
|
|
@@ -5335,56 +5342,56 @@ class mr extends ar {
|
|
|
5335
5342
|
*
|
|
5336
5343
|
* @param limit - The maximum number of items to return.
|
|
5337
5344
|
* @returns The created {@link Query}.
|
|
5338
|
-
*/ function
|
|
5339
|
-
return
|
|
5345
|
+
*/ function _r(t) {
|
|
5346
|
+
return at("limitToLast", t), new pr("limitToLast", t, "L" /* Last */);
|
|
5340
5347
|
}
|
|
5341
5348
|
|
|
5342
|
-
class
|
|
5349
|
+
class gr extends hr {
|
|
5343
5350
|
constructor(t, e, n) {
|
|
5344
5351
|
super(), this.type = t, this.At = e, this.Rt = n;
|
|
5345
5352
|
}
|
|
5346
5353
|
_apply(t) {
|
|
5347
|
-
const e =
|
|
5348
|
-
return new
|
|
5349
|
-
return new
|
|
5354
|
+
const e = Ar(t, this.type, this.At, this.Rt);
|
|
5355
|
+
return new bn(t.firestore, t.converter, function(t, e) {
|
|
5356
|
+
return new we(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, e, t.endAt);
|
|
5350
5357
|
}(t._query, e));
|
|
5351
5358
|
}
|
|
5352
5359
|
}
|
|
5353
5360
|
|
|
5354
|
-
function
|
|
5355
|
-
return new
|
|
5361
|
+
function vr(...t) {
|
|
5362
|
+
return new gr("startAt", t,
|
|
5356
5363
|
/*inclusive=*/ !0);
|
|
5357
5364
|
}
|
|
5358
5365
|
|
|
5359
|
-
function
|
|
5360
|
-
return new
|
|
5366
|
+
function br(...t) {
|
|
5367
|
+
return new gr("startAfter", t,
|
|
5361
5368
|
/*inclusive=*/ !1);
|
|
5362
5369
|
}
|
|
5363
5370
|
|
|
5364
|
-
class
|
|
5371
|
+
class Er extends hr {
|
|
5365
5372
|
constructor(t, e, n) {
|
|
5366
5373
|
super(), this.type = t, this.At = e, this.Rt = n;
|
|
5367
5374
|
}
|
|
5368
5375
|
_apply(t) {
|
|
5369
|
-
const e =
|
|
5370
|
-
return new
|
|
5371
|
-
return new
|
|
5376
|
+
const e = Ar(t, this.type, this.At, this.Rt);
|
|
5377
|
+
return new bn(t.firestore, t.converter, function(t, e) {
|
|
5378
|
+
return new we(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, t.startAt, e);
|
|
5372
5379
|
}(t._query, e));
|
|
5373
5380
|
}
|
|
5374
5381
|
}
|
|
5375
5382
|
|
|
5376
|
-
function
|
|
5377
|
-
return new
|
|
5383
|
+
function Ir(...t) {
|
|
5384
|
+
return new Er("endBefore", t,
|
|
5378
5385
|
/*inclusive=*/ !1);
|
|
5379
5386
|
}
|
|
5380
5387
|
|
|
5381
|
-
function
|
|
5382
|
-
return new
|
|
5388
|
+
function Tr(...t) {
|
|
5389
|
+
return new Er("endAt", t, /*inclusive=*/ !0);
|
|
5383
5390
|
}
|
|
5384
5391
|
|
|
5385
|
-
/** Helper function to create a bound from a document or fields */ function
|
|
5386
|
-
if (n[0] = getModularInstance(n[0]), n[0] instanceof
|
|
5387
|
-
if (!r) throw new
|
|
5392
|
+
/** Helper function to create a bound from a document or fields */ function Ar(t, e, n, r) {
|
|
5393
|
+
if (n[0] = getModularInstance(n[0]), n[0] instanceof ir) return function(t, e, n, r, s) {
|
|
5394
|
+
if (!r) throw new U(N, `Can't use a DocumentSnapshot that doesn't exist for ${n}().`);
|
|
5388
5395
|
const i = [];
|
|
5389
5396
|
// Because people expect to continue/end a query at the exact document
|
|
5390
5397
|
// provided, we need to use the implicit sort order rather than the explicit
|
|
@@ -5393,42 +5400,42 @@ function Ir(...t) {
|
|
|
5393
5400
|
// the provided document. Without the key (by using the explicit sort
|
|
5394
5401
|
// orders), multiple documents could match the position, yielding duplicate
|
|
5395
5402
|
// results.
|
|
5396
|
-
for (const n of
|
|
5403
|
+
for (const n of _e(t)) if (n.field.isKeyField()) i.push(zt(e, r.key)); else {
|
|
5397
5404
|
const t = r.data.field(n.field);
|
|
5398
|
-
if (
|
|
5405
|
+
if (Ot(t)) throw new U(P, '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.)');
|
|
5399
5406
|
if (null === t) {
|
|
5400
5407
|
const t = n.field.canonicalString();
|
|
5401
|
-
throw new
|
|
5408
|
+
throw new U(P, `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.`);
|
|
5402
5409
|
}
|
|
5403
5410
|
i.push(t);
|
|
5404
5411
|
}
|
|
5405
|
-
return new
|
|
5412
|
+
return new he(i, s);
|
|
5406
5413
|
}
|
|
5407
5414
|
/**
|
|
5408
5415
|
* Converts a list of field values to a `Bound` for the given query.
|
|
5409
5416
|
*/ (t._query, t.firestore._databaseId, e, n[0]._document, r);
|
|
5410
5417
|
{
|
|
5411
|
-
const s =
|
|
5418
|
+
const s = Ln(t.firestore);
|
|
5412
5419
|
return function(t, e, n, r, s, i) {
|
|
5413
5420
|
// Use explicit order by's because it has to match the query the user made
|
|
5414
5421
|
const o = t.explicitOrderBy;
|
|
5415
|
-
if (s.length > o.length) throw new
|
|
5422
|
+
if (s.length > o.length) throw new U(P, `Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);
|
|
5416
5423
|
const u = [];
|
|
5417
5424
|
for (let i = 0; i < s.length; i++) {
|
|
5418
5425
|
const c = s[i];
|
|
5419
5426
|
if (o[i].field.isKeyField()) {
|
|
5420
|
-
if ("string" != typeof c) throw new
|
|
5421
|
-
if (!
|
|
5422
|
-
const n = t.path.child(
|
|
5423
|
-
if (!
|
|
5424
|
-
const s = new
|
|
5425
|
-
u.push(
|
|
5427
|
+
if ("string" != typeof c) throw new U(P, `Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);
|
|
5428
|
+
if (!ye(t) && -1 !== c.indexOf("/")) throw new U(P, `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.`);
|
|
5429
|
+
const n = t.path.child(tt.fromString(c));
|
|
5430
|
+
if (!rt.isDocumentKey(n)) throw new U(P, `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.`);
|
|
5431
|
+
const s = new rt(n);
|
|
5432
|
+
u.push(zt(e, s));
|
|
5426
5433
|
} else {
|
|
5427
|
-
const t =
|
|
5434
|
+
const t = Yn(n, r, c);
|
|
5428
5435
|
u.push(t);
|
|
5429
5436
|
}
|
|
5430
5437
|
}
|
|
5431
|
-
return new
|
|
5438
|
+
return new he(u, i);
|
|
5432
5439
|
}
|
|
5433
5440
|
/**
|
|
5434
5441
|
* Parses the given `documentIdValue` into a `ReferenceValue`, throwing
|
|
@@ -5438,28 +5445,28 @@ function Ir(...t) {
|
|
|
5438
5445
|
}
|
|
5439
5446
|
}
|
|
5440
5447
|
|
|
5441
|
-
function
|
|
5448
|
+
function Rr(t, e, n) {
|
|
5442
5449
|
if ("string" == typeof (n = getModularInstance(n))) {
|
|
5443
|
-
if ("" === n) throw new
|
|
5444
|
-
if (!
|
|
5445
|
-
const r = e.path.child(
|
|
5446
|
-
if (!
|
|
5447
|
-
return
|
|
5450
|
+
if ("" === n) throw new U(P, "Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");
|
|
5451
|
+
if (!ye(e) && -1 !== n.indexOf("/")) throw new U(P, `Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);
|
|
5452
|
+
const r = e.path.child(tt.fromString(n));
|
|
5453
|
+
if (!rt.isDocumentKey(r)) throw new U(P, `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}).`);
|
|
5454
|
+
return zt(t, new rt(r));
|
|
5448
5455
|
}
|
|
5449
|
-
if (n instanceof
|
|
5450
|
-
throw new
|
|
5456
|
+
if (n instanceof vn) return zt(t, n._key);
|
|
5457
|
+
throw new U(P, `Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${ut(n)}.`);
|
|
5451
5458
|
}
|
|
5452
5459
|
|
|
5453
5460
|
/**
|
|
5454
5461
|
* Validates that the value passed into a disjunctive filter satisfies all
|
|
5455
5462
|
* array requirements.
|
|
5456
|
-
*/ function
|
|
5457
|
-
if (!Array.isArray(t) || 0 === t.length) throw new
|
|
5458
|
-
if (t.length > 10) throw new
|
|
5463
|
+
*/ function Pr(t, e) {
|
|
5464
|
+
if (!Array.isArray(t) || 0 === t.length) throw new U(P, `Invalid Query. A non-empty array is required for '${e.toString()}' filters.`);
|
|
5465
|
+
if (t.length > 10) throw new U(P, `Invalid Query. '${e.toString()}' filters support a maximum of 10 elements in the value array.`);
|
|
5459
5466
|
}
|
|
5460
5467
|
|
|
5461
|
-
function
|
|
5462
|
-
if (!n.isEqual(e)) throw new
|
|
5468
|
+
function Vr(t, e, n) {
|
|
5469
|
+
if (!n.isEqual(e)) throw new U(P, `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.`);
|
|
5463
5470
|
}
|
|
5464
5471
|
|
|
5465
5472
|
/**
|
|
@@ -5509,7 +5516,7 @@ function Pr(t, e, n) {
|
|
|
5509
5516
|
* their `set()` or fails due to invalid data originating from a `toFirestore()`
|
|
5510
5517
|
* call.
|
|
5511
5518
|
*/
|
|
5512
|
-
function
|
|
5519
|
+
function Nr(t, e, n) {
|
|
5513
5520
|
let r;
|
|
5514
5521
|
// Cast to `any` in order to satisfy the union type constraint on
|
|
5515
5522
|
// toFirestore().
|
|
@@ -5518,9 +5525,9 @@ function Vr(t, e, n) {
|
|
|
5518
5525
|
r;
|
|
5519
5526
|
}
|
|
5520
5527
|
|
|
5521
|
-
class
|
|
5528
|
+
class Dr extends class {
|
|
5522
5529
|
convertValue(t, e = "none") {
|
|
5523
|
-
switch (
|
|
5530
|
+
switch (Mt(t)) {
|
|
5524
5531
|
case 0 /* NullValue */ :
|
|
5525
5532
|
return null;
|
|
5526
5533
|
|
|
@@ -5528,7 +5535,7 @@ class Nr extends class {
|
|
|
5528
5535
|
return t.booleanValue;
|
|
5529
5536
|
|
|
5530
5537
|
case 2 /* NumberValue */ :
|
|
5531
|
-
return
|
|
5538
|
+
return St(t.integerValue || t.doubleValue);
|
|
5532
5539
|
|
|
5533
5540
|
case 3 /* TimestampValue */ :
|
|
5534
5541
|
return this.convertTimestamp(t.timestampValue);
|
|
@@ -5540,7 +5547,7 @@ class Nr extends class {
|
|
|
5540
5547
|
return t.stringValue;
|
|
5541
5548
|
|
|
5542
5549
|
case 6 /* BlobValue */ :
|
|
5543
|
-
return this.convertBytes(
|
|
5550
|
+
return this.convertBytes(qt(t.bytesValue));
|
|
5544
5551
|
|
|
5545
5552
|
case 7 /* RefValue */ :
|
|
5546
5553
|
return this.convertReference(t.referenceValue);
|
|
@@ -5555,17 +5562,17 @@ class Nr extends class {
|
|
|
5555
5562
|
return this.convertObject(t.mapValue, e);
|
|
5556
5563
|
|
|
5557
5564
|
default:
|
|
5558
|
-
throw
|
|
5565
|
+
throw b();
|
|
5559
5566
|
}
|
|
5560
5567
|
}
|
|
5561
5568
|
convertObject(t, e) {
|
|
5562
5569
|
const n = {};
|
|
5563
|
-
return
|
|
5570
|
+
return Tt(t.fields, ((t, r) => {
|
|
5564
5571
|
n[t] = this.convertValue(r, e);
|
|
5565
5572
|
})), n;
|
|
5566
5573
|
}
|
|
5567
5574
|
convertGeoPoint(t) {
|
|
5568
|
-
return new
|
|
5575
|
+
return new xn(St(t.latitude), St(t.longitude));
|
|
5569
5576
|
}
|
|
5570
5577
|
convertArray(t, e) {
|
|
5571
5578
|
return (t.values || []).map((t => this.convertValue(t, e)));
|
|
@@ -5573,27 +5580,27 @@ class Nr extends class {
|
|
|
5573
5580
|
convertServerTimestamp(t, e) {
|
|
5574
5581
|
switch (e) {
|
|
5575
5582
|
case "previous":
|
|
5576
|
-
const n =
|
|
5583
|
+
const n = kt(t);
|
|
5577
5584
|
return null == n ? null : this.convertValue(n, e);
|
|
5578
5585
|
|
|
5579
5586
|
case "estimate":
|
|
5580
|
-
return this.convertTimestamp(
|
|
5587
|
+
return this.convertTimestamp(Ct(t));
|
|
5581
5588
|
|
|
5582
5589
|
default:
|
|
5583
5590
|
return null;
|
|
5584
5591
|
}
|
|
5585
5592
|
}
|
|
5586
5593
|
convertTimestamp(t) {
|
|
5587
|
-
const e =
|
|
5588
|
-
return new
|
|
5594
|
+
const e = Ft(t);
|
|
5595
|
+
return new bt(e.seconds, e.nanos);
|
|
5589
5596
|
}
|
|
5590
5597
|
convertDocumentKey(t, e) {
|
|
5591
|
-
const n =
|
|
5592
|
-
|
|
5593
|
-
const r = new
|
|
5598
|
+
const n = tt.fromString(t);
|
|
5599
|
+
E(tn(n));
|
|
5600
|
+
const r = new X(n.get(1), n.get(3)), s = new rt(n.popFirst(5));
|
|
5594
5601
|
return r.isEqual(e) ||
|
|
5595
5602
|
// TODO(b/64130202): Somehow support foreign references.
|
|
5596
|
-
|
|
5603
|
+
_(`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.`),
|
|
5597
5604
|
s;
|
|
5598
5605
|
}
|
|
5599
5606
|
} {
|
|
@@ -5601,11 +5608,11 @@ class Nr extends class {
|
|
|
5601
5608
|
super(), this.firestore = t;
|
|
5602
5609
|
}
|
|
5603
5610
|
convertBytes(t) {
|
|
5604
|
-
return new
|
|
5611
|
+
return new Vn(t);
|
|
5605
5612
|
}
|
|
5606
5613
|
convertReference(t) {
|
|
5607
5614
|
const e = this.convertDocumentKey(t, this.firestore._databaseId);
|
|
5608
|
-
return new
|
|
5615
|
+
return new vn(this.firestore, /* converter= */ null, e);
|
|
5609
5616
|
}
|
|
5610
5617
|
}
|
|
5611
5618
|
|
|
@@ -5621,12 +5628,12 @@ class Nr extends class {
|
|
|
5621
5628
|
* @param reference - The reference of the document to fetch.
|
|
5622
5629
|
* @returns A Promise resolved with a `DocumentSnapshot` containing the current
|
|
5623
5630
|
* document contents.
|
|
5624
|
-
*/ function
|
|
5625
|
-
const e =
|
|
5626
|
-
return
|
|
5627
|
-
|
|
5631
|
+
*/ function $r(t) {
|
|
5632
|
+
const e = hn((t = ct(t, vn)).firestore), n = new Dr(t.firestore);
|
|
5633
|
+
return on(e, [ t._key ]).then((e => {
|
|
5634
|
+
E(1 === e.length);
|
|
5628
5635
|
const r = e[0];
|
|
5629
|
-
return new
|
|
5636
|
+
return new ir(t.firestore, n, t._key, r.isFoundDocument() ? r : null, t.converter);
|
|
5630
5637
|
}));
|
|
5631
5638
|
}
|
|
5632
5639
|
|
|
@@ -5641,33 +5648,33 @@ class Nr extends class {
|
|
|
5641
5648
|
*
|
|
5642
5649
|
* @param query - The `Query` to execute.
|
|
5643
5650
|
* @returns A Promise that will be resolved with the results of the query.
|
|
5644
|
-
*/ function
|
|
5651
|
+
*/ function xr(t) {
|
|
5645
5652
|
!function(t) {
|
|
5646
|
-
if ("L" /* Last */ === t.limitType && 0 === t.explicitOrderBy.length) throw new
|
|
5647
|
-
}((t =
|
|
5648
|
-
const e =
|
|
5649
|
-
return
|
|
5650
|
-
const r = e.map((e => new
|
|
5653
|
+
if ("L" /* Last */ === t.limitType && 0 === t.explicitOrderBy.length) throw new U(k, "limitToLast() queries require specifying at least one orderBy() clause");
|
|
5654
|
+
}((t = ct(t, bn))._query);
|
|
5655
|
+
const e = hn(t.firestore), n = new Dr(t.firestore);
|
|
5656
|
+
return un(e, t._query).then((e => {
|
|
5657
|
+
const r = e.map((e => new or(t.firestore, n, e.key, e, t.converter)));
|
|
5651
5658
|
return "L" /* Last */ === t._query.limitType &&
|
|
5652
5659
|
// Limit to last queries reverse the orderBy constraint that was
|
|
5653
5660
|
// specified by the user. As such, we need to reverse the order of the
|
|
5654
5661
|
// results to return the documents in the expected order.
|
|
5655
|
-
r.reverse(), new
|
|
5662
|
+
r.reverse(), new ur(t, r);
|
|
5656
5663
|
}));
|
|
5657
5664
|
}
|
|
5658
5665
|
|
|
5659
|
-
function
|
|
5660
|
-
const r =
|
|
5661
|
-
return
|
|
5666
|
+
function Fr(t, e, n) {
|
|
5667
|
+
const r = Nr((t = ct(t, vn)).converter, e, n), s = Mn(Ln(t.firestore), "setDoc", t._key, r, null !== t.converter, n);
|
|
5668
|
+
return sn(hn(t.firestore), [ s.toMutation(t._key, Ve.none()) ]);
|
|
5662
5669
|
}
|
|
5663
5670
|
|
|
5664
|
-
function
|
|
5665
|
-
const s =
|
|
5671
|
+
function Sr(t, e, n, ...r) {
|
|
5672
|
+
const s = Ln((t = ct(t, vn)).firestore);
|
|
5666
5673
|
// For Compat types, we have to "extract" the underlying types before
|
|
5667
5674
|
// performing validation.
|
|
5668
5675
|
let i;
|
|
5669
|
-
i = "string" == typeof (e = getModularInstance(e)) || e instanceof
|
|
5670
|
-
return
|
|
5676
|
+
i = "string" == typeof (e = getModularInstance(e)) || e instanceof Nn ? Kn(s, "updateDoc", t._key, e, n, r) : Wn(s, "updateDoc", t._key, e);
|
|
5677
|
+
return sn(hn(t.firestore), [ i.toMutation(t._key, Ve.exists(!0)) ]);
|
|
5671
5678
|
}
|
|
5672
5679
|
|
|
5673
5680
|
/**
|
|
@@ -5681,8 +5688,8 @@ function Fr(t, e, n, ...r) {
|
|
|
5681
5688
|
* @param reference - A reference to the document to delete.
|
|
5682
5689
|
* @returns A `Promise` resolved once the document has been successfully
|
|
5683
5690
|
* deleted from the backend.
|
|
5684
|
-
*/ function
|
|
5685
|
-
return
|
|
5691
|
+
*/ function qr(t) {
|
|
5692
|
+
return sn(hn((t = ct(t, vn)).firestore), [ new xe(t._key, Ve.none()) ]);
|
|
5686
5693
|
}
|
|
5687
5694
|
|
|
5688
5695
|
/**
|
|
@@ -5699,9 +5706,9 @@ function Fr(t, e, n, ...r) {
|
|
|
5699
5706
|
* @throws Error - If the provided input is not a valid Firestore document.
|
|
5700
5707
|
* @returns A `Promise` resolved with a `DocumentReference` pointing to the
|
|
5701
5708
|
* newly created document after it has been written to the backend.
|
|
5702
|
-
*/ function
|
|
5703
|
-
const n =
|
|
5704
|
-
return
|
|
5709
|
+
*/ function Or(t, e) {
|
|
5710
|
+
const n = An(t = ct(t, En)), r = Nr(t.converter, e), s = Mn(Ln(t.firestore), "addDoc", n._key, r, null !== n.converter, {});
|
|
5711
|
+
return sn(hn(t.firestore), [ s.toMutation(n._key, Ve.exists(!1)) ]).then((() => n));
|
|
5705
5712
|
}
|
|
5706
5713
|
|
|
5707
5714
|
/**
|
|
@@ -5733,9 +5740,9 @@ function Fr(t, e, n, ...r) {
|
|
|
5733
5740
|
* @returns A Promise that will be resolved with the count; the count can be
|
|
5734
5741
|
* retrieved from `snapshot.data().count`, where `snapshot` is the
|
|
5735
5742
|
* `AggregateQuerySnapshot` to which the returned Promise resolves.
|
|
5736
|
-
*/ function
|
|
5737
|
-
const e =
|
|
5738
|
-
return new
|
|
5743
|
+
*/ function kr(t) {
|
|
5744
|
+
const e = ct(t.firestore, fn), n = hn(e), r = new Dr(e);
|
|
5745
|
+
return new gn(t, n, r).run();
|
|
5739
5746
|
}
|
|
5740
5747
|
|
|
5741
5748
|
/**
|
|
@@ -5749,8 +5756,8 @@ function Fr(t, e, n, ...r) {
|
|
|
5749
5756
|
*
|
|
5750
5757
|
* @returns `true` if the objects are "equal", as defined above, or `false`
|
|
5751
5758
|
* otherwise.
|
|
5752
|
-
*/ function
|
|
5753
|
-
return
|
|
5759
|
+
*/ function Cr(t, e) {
|
|
5760
|
+
return Pn(t.query, e.query) && deepEqual(t.data(), e.data());
|
|
5754
5761
|
}
|
|
5755
5762
|
|
|
5756
5763
|
/**
|
|
@@ -5772,15 +5779,15 @@ function Fr(t, e, n, ...r) {
|
|
|
5772
5779
|
/**
|
|
5773
5780
|
* Returns a sentinel for use with {@link @firebase/firestore/lite#(updateDoc:1)} or
|
|
5774
5781
|
* {@link @firebase/firestore/lite#(setDoc:1)} with `{merge: true}` to mark a field for deletion.
|
|
5775
|
-
*/ function
|
|
5776
|
-
return new
|
|
5782
|
+
*/ function Lr() {
|
|
5783
|
+
return new Un("deleteField");
|
|
5777
5784
|
}
|
|
5778
5785
|
|
|
5779
5786
|
/**
|
|
5780
5787
|
* Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
|
|
5781
5788
|
* include a server-generated timestamp in the written data.
|
|
5782
|
-
*/ function
|
|
5783
|
-
return new
|
|
5789
|
+
*/ function Mr() {
|
|
5790
|
+
return new Bn("serverTimestamp");
|
|
5784
5791
|
}
|
|
5785
5792
|
|
|
5786
5793
|
/**
|
|
@@ -5794,10 +5801,10 @@ function Fr(t, e, n, ...r) {
|
|
|
5794
5801
|
* @param elements - The elements to union into the array.
|
|
5795
5802
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5796
5803
|
* `updateDoc()`.
|
|
5797
|
-
*/ function
|
|
5804
|
+
*/ function Ur(...t) {
|
|
5798
5805
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5799
5806
|
// update() since we'd need the Firestore instance to do this.
|
|
5800
|
-
return new
|
|
5807
|
+
return new Qn("arrayUnion", t);
|
|
5801
5808
|
}
|
|
5802
5809
|
|
|
5803
5810
|
/**
|
|
@@ -5810,10 +5817,10 @@ function Fr(t, e, n, ...r) {
|
|
|
5810
5817
|
* @param elements - The elements to remove from the array.
|
|
5811
5818
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5812
5819
|
* `updateDoc()`
|
|
5813
|
-
*/ function
|
|
5820
|
+
*/ function jr(...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 zn("arrayRemove", t);
|
|
5817
5824
|
}
|
|
5818
5825
|
|
|
5819
5826
|
/**
|
|
@@ -5834,8 +5841,8 @@ function Fr(t, e, n, ...r) {
|
|
|
5834
5841
|
* @param n - The value to increment by.
|
|
5835
5842
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5836
5843
|
* `updateDoc()`
|
|
5837
|
-
*/ function
|
|
5838
|
-
return new
|
|
5844
|
+
*/ function Br(t) {
|
|
5845
|
+
return new Gn("increment", t);
|
|
5839
5846
|
}
|
|
5840
5847
|
|
|
5841
5848
|
/**
|
|
@@ -5861,25 +5868,25 @@ function Fr(t, e, n, ...r) {
|
|
|
5861
5868
|
* provides methods for adding writes to the write batch. None of the writes
|
|
5862
5869
|
* will be committed (or visible locally) until {@link WriteBatch.commit} is
|
|
5863
5870
|
* called.
|
|
5864
|
-
*/ class
|
|
5871
|
+
*/ class Qr {
|
|
5865
5872
|
/** @hideconstructor */
|
|
5866
5873
|
constructor(t, e) {
|
|
5867
5874
|
this._firestore = t, this._commitHandler = e, this._mutations = [], this._committed = !1,
|
|
5868
|
-
this._dataReader =
|
|
5875
|
+
this._dataReader = Ln(t);
|
|
5869
5876
|
}
|
|
5870
5877
|
set(t, e, n) {
|
|
5871
5878
|
this._verifyNotCommitted();
|
|
5872
|
-
const r =
|
|
5873
|
-
return this._mutations.push(i.toMutation(r._key,
|
|
5879
|
+
const r = zr(t, this._firestore), s = Nr(r.converter, e, n), i = Mn(this._dataReader, "WriteBatch.set", r._key, s, null !== r.converter, n);
|
|
5880
|
+
return this._mutations.push(i.toMutation(r._key, Ve.none())), this;
|
|
5874
5881
|
}
|
|
5875
5882
|
update(t, e, n, ...r) {
|
|
5876
5883
|
this._verifyNotCommitted();
|
|
5877
|
-
const s =
|
|
5884
|
+
const s = zr(t, this._firestore);
|
|
5878
5885
|
// For Compat types, we have to "extract" the underlying types before
|
|
5879
5886
|
// performing validation.
|
|
5880
5887
|
let i;
|
|
5881
|
-
return i = "string" == typeof (e = getModularInstance(e)) || e instanceof
|
|
5882
|
-
this._mutations.push(i.toMutation(s._key,
|
|
5888
|
+
return i = "string" == typeof (e = getModularInstance(e)) || e instanceof Nn ? Kn(this._dataReader, "WriteBatch.update", s._key, e, n, r) : Wn(this._dataReader, "WriteBatch.update", s._key, e),
|
|
5889
|
+
this._mutations.push(i.toMutation(s._key, Ve.exists(!0))), this;
|
|
5883
5890
|
}
|
|
5884
5891
|
/**
|
|
5885
5892
|
* Deletes the document referred to by the provided {@link DocumentReference}.
|
|
@@ -5888,8 +5895,8 @@ function Fr(t, e, n, ...r) {
|
|
|
5888
5895
|
* @returns This `WriteBatch` instance. Used for chaining method calls.
|
|
5889
5896
|
*/ delete(t) {
|
|
5890
5897
|
this._verifyNotCommitted();
|
|
5891
|
-
const e =
|
|
5892
|
-
return this._mutations = this._mutations.concat(new
|
|
5898
|
+
const e = zr(t, this._firestore);
|
|
5899
|
+
return this._mutations = this._mutations.concat(new xe(e._key, Ve.none())), this;
|
|
5893
5900
|
}
|
|
5894
5901
|
/**
|
|
5895
5902
|
* Commits all of the writes in this write batch as a single atomic unit.
|
|
@@ -5906,12 +5913,12 @@ function Fr(t, e, n, ...r) {
|
|
|
5906
5913
|
return this._verifyNotCommitted(), this._committed = !0, this._mutations.length > 0 ? this._commitHandler(this._mutations) : Promise.resolve();
|
|
5907
5914
|
}
|
|
5908
5915
|
_verifyNotCommitted() {
|
|
5909
|
-
if (this._committed) throw new
|
|
5916
|
+
if (this._committed) throw new U(S, "A write batch can no longer be used after commit() has been called.");
|
|
5910
5917
|
}
|
|
5911
5918
|
}
|
|
5912
5919
|
|
|
5913
|
-
function
|
|
5914
|
-
if ((t = getModularInstance(t)).firestore !== e) throw new
|
|
5920
|
+
function zr(t, e) {
|
|
5921
|
+
if ((t = getModularInstance(t)).firestore !== e) throw new U(P, "Provided document reference is from a different Firestore instance.");
|
|
5915
5922
|
return t;
|
|
5916
5923
|
}
|
|
5917
5924
|
|
|
@@ -5927,9 +5934,9 @@ function Qr(t, e) {
|
|
|
5927
5934
|
*
|
|
5928
5935
|
* @returns A `WriteBatch` that can be used to atomically execute multiple
|
|
5929
5936
|
* writes.
|
|
5930
|
-
*/ function
|
|
5931
|
-
const e =
|
|
5932
|
-
return new
|
|
5937
|
+
*/ function Gr(t) {
|
|
5938
|
+
const e = hn(t = ct(t, fn));
|
|
5939
|
+
return new Qr(t, (t => sn(e, t)));
|
|
5933
5940
|
}
|
|
5934
5941
|
|
|
5935
5942
|
/**
|
|
@@ -5951,7 +5958,7 @@ function Qr(t, e) {
|
|
|
5951
5958
|
/**
|
|
5952
5959
|
* Internal transaction object responsible for accumulating the mutations to
|
|
5953
5960
|
* perform and the base versions for any documents read.
|
|
5954
|
-
*/ class
|
|
5961
|
+
*/ class Wr {
|
|
5955
5962
|
constructor(t) {
|
|
5956
5963
|
this.datastore = t,
|
|
5957
5964
|
// The version of each document that was read during this transaction.
|
|
@@ -5970,8 +5977,8 @@ function Qr(t, e) {
|
|
|
5970
5977
|
this.writtenDocs = new Set;
|
|
5971
5978
|
}
|
|
5972
5979
|
async lookup(t) {
|
|
5973
|
-
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new
|
|
5974
|
-
const e = await
|
|
5980
|
+
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new U(P, "Firestore transactions require all reads to be executed before all writes.");
|
|
5981
|
+
const e = await on(this.datastore, t);
|
|
5975
5982
|
return e.forEach((t => this.recordVersion(t))), e;
|
|
5976
5983
|
}
|
|
5977
5984
|
set(t, e) {
|
|
@@ -5986,7 +5993,7 @@ function Qr(t, e) {
|
|
|
5986
5993
|
this.writtenDocs.add(t.toString());
|
|
5987
5994
|
}
|
|
5988
5995
|
delete(t) {
|
|
5989
|
-
this.write(new
|
|
5996
|
+
this.write(new xe(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5990
5997
|
}
|
|
5991
5998
|
async commit() {
|
|
5992
5999
|
if (this.ensureCommitNotCalled(), this.lastWriteError) throw this.lastWriteError;
|
|
@@ -5998,22 +6005,22 @@ function Qr(t, e) {
|
|
|
5998
6005
|
// For each document that was read but not written to, we want to perform
|
|
5999
6006
|
// a `verify` operation.
|
|
6000
6007
|
t.forEach(((t, e) => {
|
|
6001
|
-
const n =
|
|
6002
|
-
this.mutations.push(new
|
|
6003
|
-
})), await
|
|
6008
|
+
const n = rt.fromPath(e);
|
|
6009
|
+
this.mutations.push(new Fe(n, this.precondition(n)));
|
|
6010
|
+
})), await sn(this.datastore, this.mutations), this.committed = !0;
|
|
6004
6011
|
}
|
|
6005
6012
|
recordVersion(t) {
|
|
6006
6013
|
let e;
|
|
6007
6014
|
if (t.isFoundDocument()) e = t.version; else {
|
|
6008
|
-
if (!t.isNoDocument()) throw
|
|
6015
|
+
if (!t.isNoDocument()) throw b();
|
|
6009
6016
|
// Represent a deleted doc using SnapshotVersion.min().
|
|
6010
|
-
e =
|
|
6017
|
+
e = Et.min();
|
|
6011
6018
|
}
|
|
6012
6019
|
const n = this.readVersions.get(t.key.toString());
|
|
6013
6020
|
if (n) {
|
|
6014
6021
|
if (!e.isEqual(n))
|
|
6015
6022
|
// This transaction will fail no matter what.
|
|
6016
|
-
throw new
|
|
6023
|
+
throw new U(q, "Document version changed between two reads.");
|
|
6017
6024
|
} else this.readVersions.set(t.key.toString(), e);
|
|
6018
6025
|
}
|
|
6019
6026
|
/**
|
|
@@ -6021,7 +6028,7 @@ function Qr(t, e) {
|
|
|
6021
6028
|
* as a precondition, or no precondition if it was not read.
|
|
6022
6029
|
*/ precondition(t) {
|
|
6023
6030
|
const e = this.readVersions.get(t.toString());
|
|
6024
|
-
return !this.writtenDocs.has(t.toString()) && e ? e.isEqual(
|
|
6031
|
+
return !this.writtenDocs.has(t.toString()) && e ? e.isEqual(Et.min()) ? Ve.exists(!1) : Ve.updateTime(e) : Ve.none();
|
|
6025
6032
|
}
|
|
6026
6033
|
/**
|
|
6027
6034
|
* Returns the precondition for a document if the operation is an update.
|
|
@@ -6030,7 +6037,7 @@ function Qr(t, e) {
|
|
|
6030
6037
|
// The first time a document is written, we want to take into account the
|
|
6031
6038
|
// read time and existence
|
|
6032
6039
|
if (!this.writtenDocs.has(t.toString()) && e) {
|
|
6033
|
-
if (e.isEqual(
|
|
6040
|
+
if (e.isEqual(Et.min()))
|
|
6034
6041
|
// The document doesn't exist, so fail the transaction.
|
|
6035
6042
|
// This has to be validated locally because you can't send a
|
|
6036
6043
|
// precondition that a document does not exist without changing the
|
|
@@ -6040,13 +6047,13 @@ function Qr(t, e) {
|
|
|
6040
6047
|
// express that to the backend, we have to validate locally.
|
|
6041
6048
|
// Note: this can change once we can send separate verify writes in the
|
|
6042
6049
|
// transaction.
|
|
6043
|
-
throw new
|
|
6050
|
+
throw new U(P, "Can't update a document that doesn't exist.");
|
|
6044
6051
|
// Document exists, base precondition on document update time.
|
|
6045
|
-
return
|
|
6052
|
+
return Ve.updateTime(e);
|
|
6046
6053
|
}
|
|
6047
6054
|
// Document was not read, so we just use the preconditions for a blind
|
|
6048
6055
|
// update.
|
|
6049
|
-
return
|
|
6056
|
+
return Ve.exists(!0);
|
|
6050
6057
|
}
|
|
6051
6058
|
write(t) {
|
|
6052
6059
|
this.ensureCommitNotCalled(), this.mutations.push(t);
|
|
@@ -6069,7 +6076,7 @@ function Qr(t, e) {
|
|
|
6069
6076
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6070
6077
|
* See the License for the specific language governing permissions and
|
|
6071
6078
|
* limitations under the License.
|
|
6072
|
-
*/ const
|
|
6079
|
+
*/ const Kr = {
|
|
6073
6080
|
maxAttempts: 5
|
|
6074
6081
|
};
|
|
6075
6082
|
|
|
@@ -6093,17 +6100,17 @@ function Qr(t, e) {
|
|
|
6093
6100
|
* TransactionRunner encapsulates the logic needed to run and retry transactions
|
|
6094
6101
|
* with backoff.
|
|
6095
6102
|
*/
|
|
6096
|
-
class
|
|
6103
|
+
class Yr {
|
|
6097
6104
|
constructor(t, e, n, r, s) {
|
|
6098
6105
|
this.asyncQueue = t, this.datastore = e, this.options = n, this.updateFunction = r,
|
|
6099
|
-
this.deferred = s, this.Pt = n.maxAttempts, this.Vt = new
|
|
6106
|
+
this.deferred = s, this.Pt = n.maxAttempts, this.Vt = new nn(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
|
|
6100
6107
|
}
|
|
6101
6108
|
/** Runs the transaction and sets the result on deferred. */ run() {
|
|
6102
6109
|
this.Pt -= 1, this.Nt();
|
|
6103
6110
|
}
|
|
6104
6111
|
Nt() {
|
|
6105
6112
|
this.Vt.J((async () => {
|
|
6106
|
-
const t = new
|
|
6113
|
+
const t = new Wr(this.datastore), e = this.Dt(t);
|
|
6107
6114
|
e && e.then((e => {
|
|
6108
6115
|
this.asyncQueue.enqueueAndForget((() => t.commit().then((() => {
|
|
6109
6116
|
this.deferred.resolve(e);
|
|
@@ -6118,7 +6125,7 @@ class Kr {
|
|
|
6118
6125
|
Dt(t) {
|
|
6119
6126
|
try {
|
|
6120
6127
|
const e = this.updateFunction(t);
|
|
6121
|
-
return !
|
|
6128
|
+
return !ht(e) && e.catch && e.then ? e : (this.deferred.reject(Error("Transaction callback must return a Promise")),
|
|
6122
6129
|
null);
|
|
6123
6130
|
} catch (t) {
|
|
6124
6131
|
// Do not retry errors thrown by user provided updateFunction.
|
|
@@ -6144,31 +6151,31 @@ class Kr {
|
|
|
6144
6151
|
function(t) {
|
|
6145
6152
|
switch (t) {
|
|
6146
6153
|
default:
|
|
6147
|
-
return
|
|
6154
|
+
return b();
|
|
6148
6155
|
|
|
6149
|
-
case T:
|
|
6150
6156
|
case A:
|
|
6151
|
-
case
|
|
6152
|
-
case
|
|
6153
|
-
case
|
|
6157
|
+
case R:
|
|
6158
|
+
case V:
|
|
6159
|
+
case F:
|
|
6154
6160
|
case C:
|
|
6161
|
+
case L:
|
|
6155
6162
|
// Unauthenticated means something went wrong with our token and we need
|
|
6156
6163
|
// to retry with new credentials which will happen automatically.
|
|
6157
|
-
case
|
|
6164
|
+
case x:
|
|
6158
6165
|
return !1;
|
|
6159
6166
|
|
|
6160
|
-
case
|
|
6161
|
-
case V:
|
|
6167
|
+
case P:
|
|
6162
6168
|
case N:
|
|
6163
6169
|
case D:
|
|
6164
|
-
case
|
|
6170
|
+
case $:
|
|
6171
|
+
case S:
|
|
6165
6172
|
// Aborted might be retried in some scenarios, but that is dependant on
|
|
6166
6173
|
// the context and should handled individually by the calling code.
|
|
6167
6174
|
// See https://cloud.google.com/apis/design/errors.
|
|
6168
|
-
case
|
|
6169
|
-
case q:
|
|
6175
|
+
case q:
|
|
6170
6176
|
case O:
|
|
6171
|
-
case
|
|
6177
|
+
case k:
|
|
6178
|
+
case M:
|
|
6172
6179
|
return !0;
|
|
6173
6180
|
}
|
|
6174
6181
|
}(e);
|
|
@@ -6193,7 +6200,7 @@ class Kr {
|
|
|
6193
6200
|
* See the License for the specific language governing permissions and
|
|
6194
6201
|
* limitations under the License.
|
|
6195
6202
|
*/
|
|
6196
|
-
/** The Platform's 'document' implementation or null if not available. */ function
|
|
6203
|
+
/** The Platform's 'document' implementation or null if not available. */ function Hr() {
|
|
6197
6204
|
// `document` is not always available, e.g. in ReactNative and WebWorkers.
|
|
6198
6205
|
// eslint-disable-next-line no-restricted-globals
|
|
6199
6206
|
return "undefined" != typeof document ? document : null;
|
|
@@ -6225,10 +6232,10 @@ class Kr {
|
|
|
6225
6232
|
* Note: We implement `PromiseLike` instead of `Promise`, as the `Promise` type
|
|
6226
6233
|
* in newer versions of TypeScript defines `finally`, which is not available in
|
|
6227
6234
|
* IE.
|
|
6228
|
-
*/ class
|
|
6235
|
+
*/ class Jr {
|
|
6229
6236
|
constructor(t, e, n, r, s) {
|
|
6230
6237
|
this.asyncQueue = t, this.timerId = e, this.targetTimeMs = n, this.op = r, this.removalCallback = s,
|
|
6231
|
-
this.deferred = new
|
|
6238
|
+
this.deferred = new j, this.then = this.deferred.promise.then.bind(this.deferred.promise),
|
|
6232
6239
|
// It's normal for the deferred promise to be canceled (due to cancellation)
|
|
6233
6240
|
// and so we attach a dummy catch callback to avoid
|
|
6234
6241
|
// 'UnhandledPromiseRejectionWarning' log spam.
|
|
@@ -6248,7 +6255,7 @@ class Kr {
|
|
|
6248
6255
|
* PORTING NOTE: This exists to prevent making removeDelayedOperation() and
|
|
6249
6256
|
* the DelayedOperation class public.
|
|
6250
6257
|
*/ static createAndSchedule(t, e, n, r, s) {
|
|
6251
|
-
const i = Date.now() + n, o = new
|
|
6258
|
+
const i = Date.now() + n, o = new Jr(t, e, i, r, s);
|
|
6252
6259
|
return o.start(n), o;
|
|
6253
6260
|
}
|
|
6254
6261
|
/**
|
|
@@ -6270,7 +6277,7 @@ class Kr {
|
|
|
6270
6277
|
* As long as the operation has not yet been run, calling cancel() provides a
|
|
6271
6278
|
* guarantee that the operation will not be run.
|
|
6272
6279
|
*/ cancel(t) {
|
|
6273
|
-
null !== this.timerHandle && (this.clearTimeout(), this.deferred.reject(new
|
|
6280
|
+
null !== this.timerHandle && (this.clearTimeout(), this.deferred.reject(new U(A, "Operation cancelled" + (t ? ": " + t : ""))));
|
|
6274
6281
|
}
|
|
6275
6282
|
handleDelayElapsed() {
|
|
6276
6283
|
this.asyncQueue.enqueueAndForget((() => null !== this.timerHandle ? (this.clearTimeout(),
|
|
@@ -6297,7 +6304,7 @@ class Kr {
|
|
|
6297
6304
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6298
6305
|
* See the License for the specific language governing permissions and
|
|
6299
6306
|
* limitations under the License.
|
|
6300
|
-
*/ class
|
|
6307
|
+
*/ class Xr {
|
|
6301
6308
|
constructor() {
|
|
6302
6309
|
// The last promise in the queue.
|
|
6303
6310
|
this.Ft = Promise.resolve(),
|
|
@@ -6320,15 +6327,15 @@ class Kr {
|
|
|
6320
6327
|
// List of TimerIds to fast-forward delays for.
|
|
6321
6328
|
this.Mt = [],
|
|
6322
6329
|
// Backoff timer used to schedule retries for retryable operations
|
|
6323
|
-
this.Vt = new
|
|
6330
|
+
this.Vt = new nn(this, "async_queue_retry" /* AsyncQueueRetry */),
|
|
6324
6331
|
// Visibility handler that triggers an immediate retry of all retryable
|
|
6325
6332
|
// operations. Meant to speed up recovery when we regain file system access
|
|
6326
6333
|
// after page comes into foreground.
|
|
6327
6334
|
this.Ut = () => {
|
|
6328
|
-
const t =
|
|
6329
|
-
t &&
|
|
6335
|
+
const t = Hr();
|
|
6336
|
+
t && y("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.Vt.Z();
|
|
6330
6337
|
};
|
|
6331
|
-
const t =
|
|
6338
|
+
const t = Hr();
|
|
6332
6339
|
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.Ut);
|
|
6333
6340
|
}
|
|
6334
6341
|
get isShuttingDown() {
|
|
@@ -6349,7 +6356,7 @@ class Kr {
|
|
|
6349
6356
|
enterRestrictedMode(t) {
|
|
6350
6357
|
if (!this.qt) {
|
|
6351
6358
|
this.qt = !0, this.Lt = t || !1;
|
|
6352
|
-
const e =
|
|
6359
|
+
const e = Hr();
|
|
6353
6360
|
e && "function" == typeof e.removeEventListener && e.removeEventListener("visibilitychange", this.Ut);
|
|
6354
6361
|
}
|
|
6355
6362
|
}
|
|
@@ -6360,7 +6367,7 @@ class Kr {
|
|
|
6360
6367
|
// Create a deferred Promise that we can return to the callee. This
|
|
6361
6368
|
// allows us to return a "hanging Promise" only to the callee and still
|
|
6362
6369
|
// advance the queue even when the operation is not run.
|
|
6363
|
-
const e = new
|
|
6370
|
+
const e = new j;
|
|
6364
6371
|
return this.Bt((() => this.qt && this.Lt ? Promise.resolve() : (t().then(e.resolve, e.reject),
|
|
6365
6372
|
e.promise))).then((() => e.promise));
|
|
6366
6373
|
}
|
|
@@ -6415,7 +6422,7 @@ class Kr {
|
|
|
6415
6422
|
* limitations under the License.
|
|
6416
6423
|
*/ (t)) throw t;
|
|
6417
6424
|
// Failure will be handled by AsyncQueue
|
|
6418
|
-
|
|
6425
|
+
y("AsyncQueue", "Operation failed with retryable error: " + t);
|
|
6419
6426
|
}
|
|
6420
6427
|
this.St.length > 0 &&
|
|
6421
6428
|
// If there are additional operations, we re-schedule `retryNextOp()`.
|
|
@@ -6473,7 +6480,7 @@ class Kr {
|
|
|
6473
6480
|
// Re-throw the error so that this.tail becomes a rejected Promise and
|
|
6474
6481
|
// all further attempts to chain (via .then) will just short-circuit
|
|
6475
6482
|
// and return the rejected Promise.
|
|
6476
|
-
throw
|
|
6483
|
+
throw _("INTERNAL UNHANDLED ERROR: ", e), t;
|
|
6477
6484
|
})).then((t => (this.Ct = !1, t))))));
|
|
6478
6485
|
return this.Ft = e, e;
|
|
6479
6486
|
}
|
|
@@ -6481,11 +6488,11 @@ class Kr {
|
|
|
6481
6488
|
this.jt(),
|
|
6482
6489
|
// Fast-forward delays for timerIds that have been overriden.
|
|
6483
6490
|
this.Mt.indexOf(t) > -1 && (e = 0);
|
|
6484
|
-
const r =
|
|
6491
|
+
const r = Jr.createAndSchedule(this, t, e, n, (t => this.zt(t)));
|
|
6485
6492
|
return this.Ot.push(r), r;
|
|
6486
6493
|
}
|
|
6487
6494
|
jt() {
|
|
6488
|
-
this.kt &&
|
|
6495
|
+
this.kt && b();
|
|
6489
6496
|
}
|
|
6490
6497
|
verifyOperationInProgress() {}
|
|
6491
6498
|
/**
|
|
@@ -6535,10 +6542,10 @@ class Kr {
|
|
|
6535
6542
|
}
|
|
6536
6543
|
}
|
|
6537
6544
|
|
|
6538
|
-
class
|
|
6545
|
+
class Zr {
|
|
6539
6546
|
/** @hideconstructor */
|
|
6540
6547
|
constructor(t, e) {
|
|
6541
|
-
this._firestore = t, this._transaction = e, this._dataReader =
|
|
6548
|
+
this._firestore = t, this._transaction = e, this._dataReader = Ln(t);
|
|
6542
6549
|
}
|
|
6543
6550
|
/**
|
|
6544
6551
|
* Reads the document referenced by the provided {@link DocumentReference}.
|
|
@@ -6546,25 +6553,25 @@ class Xr {
|
|
|
6546
6553
|
* @param documentRef - A reference to the document to be read.
|
|
6547
6554
|
* @returns A `DocumentSnapshot` with the read data.
|
|
6548
6555
|
*/ get(t) {
|
|
6549
|
-
const e =
|
|
6556
|
+
const e = zr(t, this._firestore), n = new Dr(this._firestore);
|
|
6550
6557
|
return this._transaction.lookup([ e._key ]).then((t => {
|
|
6551
|
-
if (!t || 1 !== t.length) return
|
|
6558
|
+
if (!t || 1 !== t.length) return b();
|
|
6552
6559
|
const r = t[0];
|
|
6553
|
-
if (r.isFoundDocument()) return new
|
|
6554
|
-
if (r.isNoDocument()) return new
|
|
6555
|
-
throw
|
|
6560
|
+
if (r.isFoundDocument()) return new ir(this._firestore, n, r.key, r, e.converter);
|
|
6561
|
+
if (r.isNoDocument()) return new ir(this._firestore, n, e._key, null, e.converter);
|
|
6562
|
+
throw b();
|
|
6556
6563
|
}));
|
|
6557
6564
|
}
|
|
6558
6565
|
set(t, e, n) {
|
|
6559
|
-
const r =
|
|
6566
|
+
const r = zr(t, this._firestore), s = Nr(r.converter, e, n), i = Mn(this._dataReader, "Transaction.set", r._key, s, null !== r.converter, n);
|
|
6560
6567
|
return this._transaction.set(r._key, i), this;
|
|
6561
6568
|
}
|
|
6562
6569
|
update(t, e, n, ...r) {
|
|
6563
|
-
const s =
|
|
6570
|
+
const s = zr(t, this._firestore);
|
|
6564
6571
|
// For Compat types, we have to "extract" the underlying types before
|
|
6565
6572
|
// performing validation.
|
|
6566
6573
|
let i;
|
|
6567
|
-
return i = "string" == typeof (e = getModularInstance(e)) || e instanceof
|
|
6574
|
+
return i = "string" == typeof (e = getModularInstance(e)) || e instanceof Nn ? Kn(this._dataReader, "Transaction.update", s._key, e, n, r) : Wn(this._dataReader, "Transaction.update", s._key, e),
|
|
6568
6575
|
this._transaction.update(s._key, i), this;
|
|
6569
6576
|
}
|
|
6570
6577
|
/**
|
|
@@ -6573,7 +6580,7 @@ class Xr {
|
|
|
6573
6580
|
* @param documentRef - A reference to the document to be deleted.
|
|
6574
6581
|
* @returns This `Transaction` instance. Used for chaining method calls.
|
|
6575
6582
|
*/ delete(t) {
|
|
6576
|
-
const e =
|
|
6583
|
+
const e = zr(t, this._firestore);
|
|
6577
6584
|
return this._transaction.delete(e._key), this;
|
|
6578
6585
|
}
|
|
6579
6586
|
}
|
|
@@ -6596,13 +6603,13 @@ class Xr {
|
|
|
6596
6603
|
* (the `updateFunction` returned a failed promise), the promise returned by the
|
|
6597
6604
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
6598
6605
|
* rejected promise with the corresponding failure error is returned.
|
|
6599
|
-
*/ function
|
|
6600
|
-
const r =
|
|
6606
|
+
*/ function ts(t, e, n) {
|
|
6607
|
+
const r = hn(t = ct(t, fn)), s = Object.assign(Object.assign({}, Kr), n);
|
|
6601
6608
|
!function(t) {
|
|
6602
|
-
if (t.maxAttempts < 1) throw new
|
|
6609
|
+
if (t.maxAttempts < 1) throw new U(P, "Max attempts must be at least 1");
|
|
6603
6610
|
}(s);
|
|
6604
|
-
const i = new
|
|
6605
|
-
return new
|
|
6611
|
+
const i = new j;
|
|
6612
|
+
return new Yr(new Xr, r, s, (n => e(new Zr(t, n))), i).run(), i.promise;
|
|
6606
6613
|
}
|
|
6607
6614
|
|
|
6608
6615
|
/**
|
|
@@ -6613,11 +6620,11 @@ class Xr {
|
|
|
6613
6620
|
* directly to the backend, and `onSnapshot()` APIs are not supported.
|
|
6614
6621
|
* @packageDocumentation
|
|
6615
6622
|
*/ !function(t) {
|
|
6616
|
-
|
|
6623
|
+
w = t;
|
|
6617
6624
|
}(`${SDK_VERSION}_lite`), _registerComponent(new Component("firestore/lite", ((t, {instanceIdentifier: e, options: n}) => {
|
|
6618
|
-
const r = t.getProvider("app").getImmediate(), s = new
|
|
6619
|
-
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new
|
|
6620
|
-
return new
|
|
6625
|
+
const r = t.getProvider("app").getImmediate(), s = new fn(new G(t.getProvider("auth-internal")), new H(t.getProvider("app-check-internal")), function(t, e) {
|
|
6626
|
+
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new U(P, '"projectId" not provided in firebase.initializeApp.');
|
|
6627
|
+
return new X(t.options.projectId, e);
|
|
6621
6628
|
}
|
|
6622
6629
|
/**
|
|
6623
6630
|
* @license
|
|
@@ -6638,7 +6645,7 @@ class Xr {
|
|
|
6638
6645
|
return n && s._setSettings(n), s;
|
|
6639
6646
|
}), "PUBLIC").setMultipleInstances(!0)),
|
|
6640
6647
|
// RUNTIME_ENV and BUILD_TARGET are replaced by real values during the compilation
|
|
6641
|
-
registerVersion("firestore-lite", "3.5.0-canary.
|
|
6648
|
+
registerVersion("firestore-lite", "3.5.0-canary.fdd4ab464", ""), registerVersion("firestore-lite", "3.5.0-canary.fdd4ab464", "esm2017");
|
|
6642
6649
|
|
|
6643
|
-
export {
|
|
6650
|
+
export { yn as AggregateField, _n as AggregateQuerySnapshot, Vn as Bytes, En as CollectionReference, vn as DocumentReference, ir as DocumentSnapshot, Nn as FieldPath, $n as FieldValue, fn as Firestore, U as FirestoreError, xn as GeoPoint, bn as Query, hr as QueryConstraint, or as QueryDocumentSnapshot, ur as QuerySnapshot, bt as Timestamp, Zr as Transaction, Qr as WriteBatch, Or as addDoc, Cr as aggregateQuerySnapshotEqual, jr as arrayRemove, Ur as arrayUnion, In as collection, Tn as collectionGroup, mn as connectFirestoreEmulator, qr as deleteDoc, Lr as deleteField, An as doc, Dn as documentId, Tr as endAt, Ir as endBefore, kr as getCount, $r as getDoc, xr as getDocs, wn as getFirestore, Br as increment, dn as initializeFirestore, yr as limit, _r as limitToLast, mr as orderBy, lr as query, Pn as queryEqual, Rn as refEqual, ts as runTransaction, Mr as serverTimestamp, Fr as setDoc, p as setLogLevel, cr as snapshotEqual, br as startAfter, vr as startAt, pn as terminate, Sr as updateDoc, dr as where, Gr as writeBatch };
|
|
6644
6651
|
//# sourceMappingURL=index.browser.esm2017.js.map
|