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