@firebase/firestore 3.4.4-canary.dd86989b3 → 3.4.4-canary.e8972ef49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
- package/dist/firestore/src/api.d.ts +1 -1
- package/dist/firestore/src/core/database_info.d.ts +1 -0
- package/dist/firestore/src/core/target.d.ts +34 -5
- package/dist/firestore/src/lite-api/query.d.ts +2 -2
- package/dist/firestore/src/local/index_manager.d.ts +52 -0
- package/dist/firestore/src/local/indexeddb_index_manager.d.ts +11 -0
- package/dist/firestore/src/local/indexeddb_schema.d.ts +121 -7
- package/dist/firestore/src/local/memory_index_manager.d.ts +11 -0
- package/dist/firestore/src/model/field_index.d.ts +4 -0
- package/dist/firestore/src/model/values.d.ts +7 -0
- package/dist/firestore/test/unit/model/target.test.d.ts +17 -0
- package/dist/firestore/test/util/helpers.d.ts +2 -2
- package/dist/index.esm2017.js +2626 -2469
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +2627 -2547
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +456 -279
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +456 -279
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +2652 -2491
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +171 -2
- package/dist/lite/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
- package/dist/lite/firestore/src/api.d.ts +1 -1
- package/dist/lite/firestore/src/core/database_info.d.ts +1 -0
- package/dist/lite/firestore/src/core/target.d.ts +34 -5
- package/dist/lite/firestore/src/lite-api/query.d.ts +2 -2
- package/dist/lite/firestore/src/local/index_manager.d.ts +52 -0
- package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +11 -0
- package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +121 -7
- package/dist/lite/firestore/src/local/memory_index_manager.d.ts +11 -0
- package/dist/lite/firestore/src/model/field_index.d.ts +4 -0
- package/dist/lite/firestore/src/model/values.d.ts +7 -0
- package/dist/lite/firestore/test/unit/model/target.test.d.ts +17 -0
- package/dist/lite/firestore/test/util/helpers.d.ts +2 -2
- package/dist/lite/index.browser.esm2017.js +1159 -1152
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +311 -308
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.node.cjs.js +39 -28
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +39 -28
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +360 -353
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +3 -2
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +125 -124
- package/dist/lite/packages/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
- package/dist/lite/packages/firestore/src/api.d.ts +1 -1
- package/dist/lite/packages/firestore/src/core/database_info.d.ts +1 -0
- package/dist/lite/packages/firestore/src/core/target.d.ts +34 -5
- package/dist/lite/packages/firestore/src/lite-api/query.d.ts +2 -2
- package/dist/lite/packages/firestore/src/local/index_manager.d.ts +52 -0
- package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +11 -0
- package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +121 -7
- package/dist/lite/packages/firestore/src/local/memory_index_manager.d.ts +11 -0
- package/dist/lite/packages/firestore/src/model/field_index.d.ts +4 -0
- package/dist/lite/packages/firestore/src/model/values.d.ts +7 -0
- package/dist/lite/packages/firestore/test/unit/model/target.test.d.ts +17 -0
- package/dist/lite/packages/firestore/test/util/helpers.d.ts +2 -2
- package/dist/lite/private.d.ts +2 -2
- package/dist/packages/firestore/dist/index.esm2017.d.ts +148 -147
- package/dist/packages/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
- package/dist/packages/firestore/src/api.d.ts +1 -1
- package/dist/packages/firestore/src/core/database_info.d.ts +1 -0
- package/dist/packages/firestore/src/core/target.d.ts +34 -5
- package/dist/packages/firestore/src/lite-api/query.d.ts +2 -2
- package/dist/packages/firestore/src/local/index_manager.d.ts +52 -0
- package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +11 -0
- package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +121 -7
- package/dist/packages/firestore/src/local/memory_index_manager.d.ts +11 -0
- package/dist/packages/firestore/src/model/field_index.d.ts +4 -0
- package/dist/packages/firestore/src/model/values.d.ts +7 -0
- package/dist/packages/firestore/test/unit/model/target.test.d.ts +17 -0
- package/dist/packages/firestore/test/util/helpers.d.ts +2 -2
- package/dist/private.d.ts +170 -2
- package/package.json +9 -9
|
@@ -63,7 +63,7 @@ l.MOCK_USER = new l("mock-user");
|
|
|
63
63
|
* See the License for the specific language governing permissions and
|
|
64
64
|
* limitations under the License.
|
|
65
65
|
*/
|
|
66
|
-
let f = "9.6.5-canary.
|
|
66
|
+
let f = "9.6.5-canary.e8972ef49";
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* @license
|
|
@@ -99,26 +99,26 @@ const d = new Logger("@firebase/firestore");
|
|
|
99
99
|
d.setLogLevel(t);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
function m(t, ...
|
|
102
|
+
function m(t, ...e) {
|
|
103
103
|
if (d.logLevel <= LogLevel.DEBUG) {
|
|
104
|
-
const
|
|
105
|
-
d.debug(`Firestore (${f}): ${t}`, ...
|
|
104
|
+
const n = e.map(_);
|
|
105
|
+
d.debug(`Firestore (${f}): ${t}`, ...n);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
function p(t, ...
|
|
109
|
+
function p(t, ...e) {
|
|
110
110
|
if (d.logLevel <= LogLevel.ERROR) {
|
|
111
|
-
const
|
|
112
|
-
d.error(`Firestore (${f}): ${t}`, ...
|
|
111
|
+
const n = e.map(_);
|
|
112
|
+
d.error(`Firestore (${f}): ${t}`, ...n);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
/**
|
|
117
117
|
* @internal
|
|
118
|
-
*/ function y(t, ...
|
|
118
|
+
*/ function y(t, ...e) {
|
|
119
119
|
if (d.logLevel <= LogLevel.WARN) {
|
|
120
|
-
const
|
|
121
|
-
d.warn(`Firestore (${f}): ${t}`, ...
|
|
120
|
+
const n = e.map(_);
|
|
121
|
+
d.warn(`Firestore (${f}): ${t}`, ...n);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
@@ -127,8 +127,8 @@ function p(t, ...n) {
|
|
|
127
127
|
*/ function _(t) {
|
|
128
128
|
if ("string" == typeof t) return t;
|
|
129
129
|
try {
|
|
130
|
-
return
|
|
131
|
-
} catch (
|
|
130
|
+
return e = t, JSON.stringify(e);
|
|
131
|
+
} catch (e) {
|
|
132
132
|
// Converting to JSON failed, just log the object directly
|
|
133
133
|
return t;
|
|
134
134
|
}
|
|
@@ -149,7 +149,7 @@ function p(t, ...n) {
|
|
|
149
149
|
* limitations under the License.
|
|
150
150
|
*/
|
|
151
151
|
/** Formats an object as a JSON string, suitable for logging. */
|
|
152
|
-
var
|
|
152
|
+
var e;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
/**
|
|
@@ -178,11 +178,11 @@ function p(t, ...n) {
|
|
|
178
178
|
*/ function g(t = "Unexpected state") {
|
|
179
179
|
// Log the failure in addition to throw an exception, just in case the
|
|
180
180
|
// exception is swallowed.
|
|
181
|
-
const
|
|
181
|
+
const e = `FIRESTORE (${f}) INTERNAL ASSERTION FAILED: ` + t;
|
|
182
182
|
// NOTE: We don't use FirestoreError here because these are internal failures
|
|
183
183
|
// that cannot be handled by the user. (Also it would create a circular
|
|
184
184
|
// dependency between the error and assert modules which doesn't work.)
|
|
185
|
-
throw p(
|
|
185
|
+
throw p(e), new Error(e);
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
/**
|
|
@@ -190,16 +190,16 @@ function p(t, ...n) {
|
|
|
190
190
|
* given message if it did.
|
|
191
191
|
*
|
|
192
192
|
* Messages are stripped in production builds.
|
|
193
|
-
*/ function
|
|
193
|
+
*/ function v(t, e) {
|
|
194
194
|
t || g();
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
/**
|
|
198
198
|
* Casts `obj` to `T`. In non-production builds, verifies that `obj` is an
|
|
199
199
|
* instance of `T` before casting.
|
|
200
|
-
*/ function
|
|
200
|
+
*/ function b(t,
|
|
201
201
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
202
|
-
|
|
202
|
+
e) {
|
|
203
203
|
return t;
|
|
204
204
|
}
|
|
205
205
|
|
|
@@ -230,8 +230,8 @@ n) {
|
|
|
230
230
|
/**
|
|
231
231
|
* A custom error description.
|
|
232
232
|
*/
|
|
233
|
-
|
|
234
|
-
super(t,
|
|
233
|
+
e) {
|
|
234
|
+
super(t, e), this.code = t, this.message = e,
|
|
235
235
|
// HACK: We write a toString property directly because Error is not a real
|
|
236
236
|
// class and so inheritance does not work correctly. We could alternatively
|
|
237
237
|
// do the same "back-door inheritance" trick that FirebaseError does.
|
|
@@ -256,8 +256,8 @@ n) {
|
|
|
256
256
|
* limitations under the License.
|
|
257
257
|
*/ class k {
|
|
258
258
|
constructor() {
|
|
259
|
-
this.promise = new Promise(((t,
|
|
260
|
-
this.resolve = t, this.reject =
|
|
259
|
+
this.promise = new Promise(((t, e) => {
|
|
260
|
+
this.resolve = t, this.reject = e;
|
|
261
261
|
}));
|
|
262
262
|
}
|
|
263
263
|
}
|
|
@@ -278,8 +278,8 @@ n) {
|
|
|
278
278
|
* See the License for the specific language governing permissions and
|
|
279
279
|
* limitations under the License.
|
|
280
280
|
*/ class j {
|
|
281
|
-
constructor(t,
|
|
282
|
-
this.user =
|
|
281
|
+
constructor(t, e) {
|
|
282
|
+
this.user = e, this.type = "OAuth", this.headers = new Map, this.headers.set("Authorization", `Bearer ${t}`);
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
285
|
|
|
@@ -291,9 +291,9 @@ n) {
|
|
|
291
291
|
return Promise.resolve(null);
|
|
292
292
|
}
|
|
293
293
|
invalidateToken() {}
|
|
294
|
-
start(t,
|
|
294
|
+
start(t, e) {
|
|
295
295
|
// Fire with initial user.
|
|
296
|
-
t.enqueueRetryable((() =>
|
|
296
|
+
t.enqueueRetryable((() => e(l.UNAUTHENTICATED)));
|
|
297
297
|
}
|
|
298
298
|
shutdown() {}
|
|
299
299
|
}
|
|
@@ -315,10 +315,10 @@ n) {
|
|
|
315
315
|
return Promise.resolve(this.token);
|
|
316
316
|
}
|
|
317
317
|
invalidateToken() {}
|
|
318
|
-
start(t,
|
|
319
|
-
this.changeListener =
|
|
318
|
+
start(t, e) {
|
|
319
|
+
this.changeListener = e,
|
|
320
320
|
// Fire with initial user.
|
|
321
|
-
t.enqueueRetryable((() =>
|
|
321
|
+
t.enqueueRetryable((() => e(this.token.user)));
|
|
322
322
|
}
|
|
323
323
|
shutdown() {
|
|
324
324
|
this.changeListener = null;
|
|
@@ -332,11 +332,11 @@ n) {
|
|
|
332
332
|
}));
|
|
333
333
|
}
|
|
334
334
|
getToken() {
|
|
335
|
-
return this.auth ? this.auth.getToken().then((t => t ? (
|
|
335
|
+
return this.auth ? this.auth.getToken().then((t => t ? (v("string" == typeof t.accessToken),
|
|
336
336
|
new j(t.accessToken, new l(this.auth.getUid()))) : null)) : Promise.resolve(null);
|
|
337
337
|
}
|
|
338
338
|
invalidateToken() {}
|
|
339
|
-
start(t,
|
|
339
|
+
start(t, e) {}
|
|
340
340
|
shutdown() {}
|
|
341
341
|
}
|
|
342
342
|
|
|
@@ -347,10 +347,10 @@ n) {
|
|
|
347
347
|
* recover from unauthenticated errors (see b/33147818 for context), but it's
|
|
348
348
|
* safer to keep the implementation as-is.
|
|
349
349
|
*/ class G {
|
|
350
|
-
constructor(t,
|
|
351
|
-
this.type = "FirstParty", this.user = l.FIRST_PARTY, this.headers = new Map, this.headers.set("X-Goog-AuthUser",
|
|
350
|
+
constructor(t, e, n) {
|
|
351
|
+
this.type = "FirstParty", this.user = l.FIRST_PARTY, this.headers = new Map, this.headers.set("X-Goog-AuthUser", e);
|
|
352
352
|
const r = t.auth.getAuthHeaderValueForFirstParty([]);
|
|
353
|
-
r && this.headers.set("Authorization", r),
|
|
353
|
+
r && this.headers.set("Authorization", r), n && this.headers.set("X-Goog-Iam-Authorization-Token", n);
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
356
|
|
|
@@ -359,15 +359,15 @@ n) {
|
|
|
359
359
|
* to authenticate the user, using technique that is only available
|
|
360
360
|
* to applications hosted by Google.
|
|
361
361
|
*/ class Q {
|
|
362
|
-
constructor(t,
|
|
363
|
-
this.t = t, this.i =
|
|
362
|
+
constructor(t, e, n) {
|
|
363
|
+
this.t = t, this.i = e, this.o = n;
|
|
364
364
|
}
|
|
365
365
|
getToken() {
|
|
366
366
|
return Promise.resolve(new G(this.t, this.i, this.o));
|
|
367
367
|
}
|
|
368
|
-
start(t,
|
|
368
|
+
start(t, e) {
|
|
369
369
|
// Fire with initial uid.
|
|
370
|
-
t.enqueueRetryable((() =>
|
|
370
|
+
t.enqueueRetryable((() => e(l.FIRST_PARTY)));
|
|
371
371
|
}
|
|
372
372
|
shutdown() {}
|
|
373
373
|
invalidateToken() {}
|
|
@@ -386,11 +386,11 @@ class W {
|
|
|
386
386
|
}));
|
|
387
387
|
}
|
|
388
388
|
getToken() {
|
|
389
|
-
return this.appCheck ? this.appCheck.getToken().then((t => t ? (
|
|
389
|
+
return this.appCheck ? this.appCheck.getToken().then((t => t ? (v("string" == typeof t.token),
|
|
390
390
|
new W(t.token)) : null)) : Promise.resolve(null);
|
|
391
391
|
}
|
|
392
392
|
invalidateToken() {}
|
|
393
|
-
start(t,
|
|
393
|
+
start(t, e) {}
|
|
394
394
|
shutdown() {}
|
|
395
395
|
}
|
|
396
396
|
|
|
@@ -432,8 +432,8 @@ class H {
|
|
|
432
432
|
* @param useFetchStreams Whether to use the Fetch API instead of
|
|
433
433
|
* XMLHTTPRequest
|
|
434
434
|
*/
|
|
435
|
-
constructor(t,
|
|
436
|
-
this.databaseId = t, this.appId =
|
|
435
|
+
constructor(t, e, n, r, s, i, o, u) {
|
|
436
|
+
this.databaseId = t, this.appId = e, this.persistenceKey = n, this.host = r, this.ssl = s,
|
|
437
437
|
this.forceLongPolling = i, this.autoDetectLongPolling = o, this.useFetchStreams = u;
|
|
438
438
|
}
|
|
439
439
|
}
|
|
@@ -444,8 +444,11 @@ class H {
|
|
|
444
444
|
* @internal
|
|
445
445
|
*/
|
|
446
446
|
class K {
|
|
447
|
-
constructor(t,
|
|
448
|
-
this.projectId = t, this.database =
|
|
447
|
+
constructor(t, e) {
|
|
448
|
+
this.projectId = t, this.database = e || "(default)";
|
|
449
|
+
}
|
|
450
|
+
static empty() {
|
|
451
|
+
return new K("", "");
|
|
449
452
|
}
|
|
450
453
|
get isDefaultDatabase() {
|
|
451
454
|
return "(default)" === this.database;
|
|
@@ -475,9 +478,9 @@ class K {
|
|
|
475
478
|
* Path represents an ordered sequence of string segments.
|
|
476
479
|
*/
|
|
477
480
|
class J {
|
|
478
|
-
constructor(t,
|
|
479
|
-
void 0 ===
|
|
480
|
-
this.segments = t, this.offset =
|
|
481
|
+
constructor(t, e, n) {
|
|
482
|
+
void 0 === e ? e = 0 : e > t.length && g(), void 0 === n ? n = t.length - e : n > t.length - e && g(),
|
|
483
|
+
this.segments = t, this.offset = e, this.len = n;
|
|
481
484
|
}
|
|
482
485
|
get length() {
|
|
483
486
|
return this.len;
|
|
@@ -486,10 +489,10 @@ class J {
|
|
|
486
489
|
return 0 === J.comparator(this, t);
|
|
487
490
|
}
|
|
488
491
|
child(t) {
|
|
489
|
-
const
|
|
492
|
+
const e = this.segments.slice(this.offset, this.limit());
|
|
490
493
|
return t instanceof J ? t.forEach((t => {
|
|
491
|
-
|
|
492
|
-
})) :
|
|
494
|
+
e.push(t);
|
|
495
|
+
})) : e.push(t), this.construct(e);
|
|
493
496
|
}
|
|
494
497
|
/** The index of one past the last segment of the path. */ limit() {
|
|
495
498
|
return this.offset + this.length;
|
|
@@ -514,28 +517,28 @@ class J {
|
|
|
514
517
|
}
|
|
515
518
|
isPrefixOf(t) {
|
|
516
519
|
if (t.length < this.length) return !1;
|
|
517
|
-
for (let
|
|
520
|
+
for (let e = 0; e < this.length; e++) if (this.get(e) !== t.get(e)) return !1;
|
|
518
521
|
return !0;
|
|
519
522
|
}
|
|
520
523
|
isImmediateParentOf(t) {
|
|
521
524
|
if (this.length + 1 !== t.length) return !1;
|
|
522
|
-
for (let
|
|
525
|
+
for (let e = 0; e < this.length; e++) if (this.get(e) !== t.get(e)) return !1;
|
|
523
526
|
return !0;
|
|
524
527
|
}
|
|
525
528
|
forEach(t) {
|
|
526
|
-
for (let
|
|
529
|
+
for (let e = this.offset, n = this.limit(); e < n; e++) t(this.segments[e]);
|
|
527
530
|
}
|
|
528
531
|
toArray() {
|
|
529
532
|
return this.segments.slice(this.offset, this.limit());
|
|
530
533
|
}
|
|
531
|
-
static comparator(t,
|
|
532
|
-
const
|
|
533
|
-
for (let r = 0; r <
|
|
534
|
-
const
|
|
535
|
-
if (
|
|
536
|
-
if (
|
|
534
|
+
static comparator(t, e) {
|
|
535
|
+
const n = Math.min(t.length, e.length);
|
|
536
|
+
for (let r = 0; r < n; r++) {
|
|
537
|
+
const n = t.get(r), s = e.get(r);
|
|
538
|
+
if (n < s) return -1;
|
|
539
|
+
if (n > s) return 1;
|
|
537
540
|
}
|
|
538
|
-
return t.length <
|
|
541
|
+
return t.length < e.length ? -1 : t.length > e.length ? 1 : 0;
|
|
539
542
|
}
|
|
540
543
|
}
|
|
541
544
|
|
|
@@ -545,8 +548,8 @@ class J {
|
|
|
545
548
|
*
|
|
546
549
|
* @internal
|
|
547
550
|
*/ class X extends J {
|
|
548
|
-
construct(t,
|
|
549
|
-
return new X(t,
|
|
551
|
+
construct(t, e, n) {
|
|
552
|
+
return new X(t, e, n);
|
|
550
553
|
}
|
|
551
554
|
canonicalString() {
|
|
552
555
|
// NOTE: The client is ignorant of any path segments containing escape
|
|
@@ -565,13 +568,13 @@ class J {
|
|
|
565
568
|
// NOTE: The client is ignorant of any path segments containing escape
|
|
566
569
|
// sequences (e.g. __id123__) and just passes them through raw (they exist
|
|
567
570
|
// for legacy reasons and should not be used frequently).
|
|
568
|
-
const
|
|
569
|
-
for (const
|
|
570
|
-
if (
|
|
571
|
+
const e = [];
|
|
572
|
+
for (const n of t) {
|
|
573
|
+
if (n.indexOf("//") >= 0) throw new U(A, `Invalid segment (${n}). Paths must not contain // in them.`);
|
|
571
574
|
// Strip leading and traling slashed.
|
|
572
|
-
|
|
575
|
+
e.push(...n.split("/").filter((t => t.length > 0)));
|
|
573
576
|
}
|
|
574
|
-
return new X(
|
|
577
|
+
return new X(e);
|
|
575
578
|
}
|
|
576
579
|
static emptyPath() {
|
|
577
580
|
return new X([]);
|
|
@@ -584,8 +587,8 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
584
587
|
* A dot-separated path for navigating sub-objects within a document.
|
|
585
588
|
* @internal
|
|
586
589
|
*/ class tt extends J {
|
|
587
|
-
construct(t,
|
|
588
|
-
return new tt(t,
|
|
590
|
+
construct(t, e, n) {
|
|
591
|
+
return new tt(t, e, n);
|
|
589
592
|
}
|
|
590
593
|
/**
|
|
591
594
|
* Returns true if the string could be used as a segment in a field path
|
|
@@ -620,24 +623,24 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
620
623
|
* TODO(b/37244157): we should make this more strict. Right now, it allows
|
|
621
624
|
* non-identifier path components, even if they aren't escaped.
|
|
622
625
|
*/ static fromServerFormat(t) {
|
|
623
|
-
const
|
|
624
|
-
let
|
|
626
|
+
const e = [];
|
|
627
|
+
let n = "", r = 0;
|
|
625
628
|
const s = () => {
|
|
626
|
-
if (0 ===
|
|
627
|
-
|
|
629
|
+
if (0 === n.length) throw new U(A, `Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);
|
|
630
|
+
e.push(n), n = "";
|
|
628
631
|
};
|
|
629
632
|
let i = !1;
|
|
630
633
|
for (;r < t.length; ) {
|
|
631
|
-
const
|
|
632
|
-
if ("\\" ===
|
|
634
|
+
const e = t[r];
|
|
635
|
+
if ("\\" === e) {
|
|
633
636
|
if (r + 1 === t.length) throw new U(A, "Path has trailing escape character: " + t);
|
|
634
|
-
const
|
|
635
|
-
if ("\\" !==
|
|
636
|
-
|
|
637
|
-
} else "`" ===
|
|
637
|
+
const e = t[r + 1];
|
|
638
|
+
if ("\\" !== e && "." !== e && "`" !== e) throw new U(A, "Path has invalid escape sequence: " + t);
|
|
639
|
+
n += e, r += 2;
|
|
640
|
+
} else "`" === e ? (i = !i, r++) : "." !== e || i ? (n += e, r++) : (s(), r++);
|
|
638
641
|
}
|
|
639
642
|
if (s(), i) throw new U(A, "Unterminated ` in path: " + t);
|
|
640
|
-
return new tt(
|
|
643
|
+
return new tt(e);
|
|
641
644
|
}
|
|
642
645
|
static emptyPath() {
|
|
643
646
|
return new tt([]);
|
|
@@ -662,18 +665,18 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
662
665
|
*/
|
|
663
666
|
/**
|
|
664
667
|
* @internal
|
|
665
|
-
*/ class
|
|
668
|
+
*/ class et {
|
|
666
669
|
constructor(t) {
|
|
667
670
|
this.path = t;
|
|
668
671
|
}
|
|
669
672
|
static fromPath(t) {
|
|
670
|
-
return new
|
|
673
|
+
return new et(X.fromString(t));
|
|
671
674
|
}
|
|
672
675
|
static fromName(t) {
|
|
673
|
-
return new
|
|
676
|
+
return new et(X.fromString(t).popFirst(5));
|
|
674
677
|
}
|
|
675
678
|
static empty() {
|
|
676
|
-
return new
|
|
679
|
+
return new et(X.emptyPath());
|
|
677
680
|
}
|
|
678
681
|
/** Returns true if the document is in the specified collectionId. */ hasCollectionId(t) {
|
|
679
682
|
return this.path.length >= 2 && this.path.get(this.path.length - 2) === t;
|
|
@@ -684,8 +687,8 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
684
687
|
toString() {
|
|
685
688
|
return this.path.toString();
|
|
686
689
|
}
|
|
687
|
-
static comparator(t,
|
|
688
|
-
return X.comparator(t.path,
|
|
690
|
+
static comparator(t, e) {
|
|
691
|
+
return X.comparator(t.path, e.path);
|
|
689
692
|
}
|
|
690
693
|
static isDocumentKey(t) {
|
|
691
694
|
return t.length % 2 == 0;
|
|
@@ -696,7 +699,7 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
696
699
|
* @param segments - The segments of the path to the document
|
|
697
700
|
* @returns A new instance of DocumentKey
|
|
698
701
|
*/ static fromSegments(t) {
|
|
699
|
-
return new
|
|
702
|
+
return new et(new X(t.slice()));
|
|
700
703
|
}
|
|
701
704
|
}
|
|
702
705
|
|
|
@@ -715,8 +718,8 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
715
718
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
716
719
|
* See the License for the specific language governing permissions and
|
|
717
720
|
* limitations under the License.
|
|
718
|
-
*/ function
|
|
719
|
-
if (!
|
|
721
|
+
*/ function nt(t, e, n) {
|
|
722
|
+
if (!n) throw new U(A, `Function ${t}() cannot be called with an empty ${e}.`);
|
|
720
723
|
}
|
|
721
724
|
|
|
722
725
|
/**
|
|
@@ -728,14 +731,14 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
728
731
|
* an even numbers of segments).
|
|
729
732
|
*/
|
|
730
733
|
function rt(t) {
|
|
731
|
-
if (!
|
|
734
|
+
if (!et.isDocumentKey(t)) throw new U(A, `Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`);
|
|
732
735
|
}
|
|
733
736
|
|
|
734
737
|
/**
|
|
735
738
|
* Validates that `path` refers to a collection (indicated by the fact it
|
|
736
739
|
* contains an odd numbers of segments).
|
|
737
740
|
*/ function st(t) {
|
|
738
|
-
if (
|
|
741
|
+
if (et.isDocumentKey(t)) throw new U(A, `Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`);
|
|
739
742
|
}
|
|
740
743
|
|
|
741
744
|
/**
|
|
@@ -752,7 +755,7 @@ function it(t) {
|
|
|
752
755
|
if ("object" == typeof t) {
|
|
753
756
|
if (t instanceof Array) return "an array";
|
|
754
757
|
{
|
|
755
|
-
const
|
|
758
|
+
const e =
|
|
756
759
|
/** try to get the constructor name for an object. */
|
|
757
760
|
function(t) {
|
|
758
761
|
if (t.constructor) return t.constructor.name;
|
|
@@ -766,7 +769,7 @@ function it(t) {
|
|
|
766
769
|
* arguments passed to the public API.
|
|
767
770
|
* @internal
|
|
768
771
|
*/ (t);
|
|
769
|
-
return
|
|
772
|
+
return e ? `a custom ${e} object` : "an object";
|
|
770
773
|
}
|
|
771
774
|
}
|
|
772
775
|
return "function" == typeof t ? "a function" : g();
|
|
@@ -774,22 +777,22 @@ function it(t) {
|
|
|
774
777
|
|
|
775
778
|
function ot(t,
|
|
776
779
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
777
|
-
|
|
780
|
+
e) {
|
|
778
781
|
if ("_delegate" in t && (
|
|
779
782
|
// Unwrap Compat types
|
|
780
783
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
781
|
-
t = t._delegate), !(t instanceof
|
|
782
|
-
if (
|
|
784
|
+
t = t._delegate), !(t instanceof e)) {
|
|
785
|
+
if (e.name === t.constructor.name) throw new U(A, "Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");
|
|
783
786
|
{
|
|
784
|
-
const
|
|
785
|
-
throw new U(A, `Expected type '${
|
|
787
|
+
const n = it(t);
|
|
788
|
+
throw new U(A, `Expected type '${e.name}', but it was: ${n}`);
|
|
786
789
|
}
|
|
787
790
|
}
|
|
788
791
|
return t;
|
|
789
792
|
}
|
|
790
793
|
|
|
791
|
-
function ut(t,
|
|
792
|
-
if (
|
|
794
|
+
function ut(t, e) {
|
|
795
|
+
if (e <= 0) throw new U(A, `Function ${t}() requires a positive number, but it was: ${e}.`);
|
|
793
796
|
}
|
|
794
797
|
|
|
795
798
|
/**
|
|
@@ -996,58 +999,58 @@ class wt extends
|
|
|
996
999
|
class {
|
|
997
1000
|
constructor(t) {
|
|
998
1001
|
this.databaseInfo = t, this.databaseId = t.databaseId;
|
|
999
|
-
const
|
|
1000
|
-
this.h =
|
|
1002
|
+
const e = t.ssl ? "https" : "http";
|
|
1003
|
+
this.h = e + "://" + t.host, this.l = "projects/" + this.databaseId.projectId + "/databases/" + this.databaseId.database + "/documents";
|
|
1001
1004
|
}
|
|
1002
|
-
m(t,
|
|
1003
|
-
const i = this.p(t,
|
|
1004
|
-
m("RestConnection", "Sending: ", i,
|
|
1005
|
+
m(t, e, n, r, s) {
|
|
1006
|
+
const i = this.p(t, e);
|
|
1007
|
+
m("RestConnection", "Sending: ", i, n);
|
|
1005
1008
|
const o = {};
|
|
1006
|
-
return this.g(o, r, s), this.v(t, i, o,
|
|
1007
|
-
t)), (
|
|
1008
|
-
throw y("RestConnection", `${t} failed with error: `,
|
|
1009
|
-
|
|
1009
|
+
return this.g(o, r, s), this.v(t, i, o, n).then((t => (m("RestConnection", "Received: ", t),
|
|
1010
|
+
t)), (e => {
|
|
1011
|
+
throw y("RestConnection", `${t} failed with error: `, e, "url: ", i, "request:", n),
|
|
1012
|
+
e;
|
|
1010
1013
|
}));
|
|
1011
1014
|
}
|
|
1012
|
-
T(t,
|
|
1015
|
+
T(t, e, n, r, s) {
|
|
1013
1016
|
// The REST API automatically aggregates all of the streamed results, so we
|
|
1014
1017
|
// can just use the normal invoke() method.
|
|
1015
|
-
return this.m(t,
|
|
1018
|
+
return this.m(t, e, n, r, s);
|
|
1016
1019
|
}
|
|
1017
1020
|
/**
|
|
1018
1021
|
* Modifies the headers for a request, adding any authorization token if
|
|
1019
1022
|
* present and any additional headers for the request.
|
|
1020
|
-
*/ g(t,
|
|
1023
|
+
*/ g(t, e, n) {
|
|
1021
1024
|
t["X-Goog-Api-Client"] = "gl-js/ fire/" + f,
|
|
1022
1025
|
// Content-Type: text/plain will avoid preflight requests which might
|
|
1023
1026
|
// mess with CORS and redirects by proxies. If we add custom headers
|
|
1024
1027
|
// we will need to change this code to potentially use the $httpOverwrite
|
|
1025
1028
|
// parameter supported by ESF to avoid triggering preflight requests.
|
|
1026
1029
|
t["Content-Type"] = "text/plain", this.databaseInfo.appId && (t["X-Firebase-GMPID"] = this.databaseInfo.appId),
|
|
1027
|
-
|
|
1030
|
+
e && e.headers.forEach(((e, n) => t[n] = e)), n && n.headers.forEach(((e, n) => t[n] = e));
|
|
1028
1031
|
}
|
|
1029
|
-
p(t,
|
|
1030
|
-
const
|
|
1031
|
-
return `${this.h}/v1/${
|
|
1032
|
+
p(t, e) {
|
|
1033
|
+
const n = ht[t];
|
|
1034
|
+
return `${this.h}/v1/${e}:${n}`;
|
|
1032
1035
|
}
|
|
1033
1036
|
} {
|
|
1034
1037
|
/**
|
|
1035
1038
|
* @param databaseInfo - The connection info.
|
|
1036
1039
|
* @param fetchImpl - `fetch` or a Polyfill that implements the fetch API.
|
|
1037
1040
|
*/
|
|
1038
|
-
constructor(t,
|
|
1039
|
-
super(t), this.I =
|
|
1041
|
+
constructor(t, e) {
|
|
1042
|
+
super(t), this.I = e;
|
|
1040
1043
|
}
|
|
1041
|
-
A(t,
|
|
1044
|
+
A(t, e) {
|
|
1042
1045
|
throw new Error("Not supported by FetchConnection");
|
|
1043
1046
|
}
|
|
1044
|
-
async v(t,
|
|
1047
|
+
async v(t, e, n, r) {
|
|
1045
1048
|
const s = JSON.stringify(r);
|
|
1046
1049
|
let i;
|
|
1047
1050
|
try {
|
|
1048
|
-
i = await this.I(
|
|
1051
|
+
i = await this.I(e, {
|
|
1049
1052
|
method: "POST",
|
|
1050
|
-
headers:
|
|
1053
|
+
headers: n,
|
|
1051
1054
|
body: s
|
|
1052
1055
|
});
|
|
1053
1056
|
} catch (t) {
|
|
@@ -1098,13 +1101,13 @@ class {
|
|
|
1098
1101
|
*/
|
|
1099
1102
|
function mt(t) {
|
|
1100
1103
|
// Polyfills for IE and WebWorker by using `self` and `msCrypto` when `crypto` is not available.
|
|
1101
|
-
const
|
|
1104
|
+
const e =
|
|
1102
1105
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1103
|
-
"undefined" != typeof self && (self.crypto || self.msCrypto),
|
|
1104
|
-
if (
|
|
1106
|
+
"undefined" != typeof self && (self.crypto || self.msCrypto), n = new Uint8Array(t);
|
|
1107
|
+
if (e && "function" == typeof e.getRandomValues) e.getRandomValues(n); else
|
|
1105
1108
|
// Falls back to Math.random
|
|
1106
|
-
for (let
|
|
1107
|
-
return
|
|
1109
|
+
for (let e = 0; e < t; e++) n[e] = Math.floor(256 * Math.random());
|
|
1110
|
+
return n;
|
|
1108
1111
|
}
|
|
1109
1112
|
|
|
1110
1113
|
/**
|
|
@@ -1125,26 +1128,26 @@ function mt(t) {
|
|
|
1125
1128
|
*/ class pt {
|
|
1126
1129
|
static R() {
|
|
1127
1130
|
// Alphanumeric characters
|
|
1128
|
-
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
|
|
1131
|
+
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", e = Math.floor(256 / t.length) * t.length;
|
|
1129
1132
|
// The largest byte value that is a multiple of `char.length`.
|
|
1130
|
-
let
|
|
1131
|
-
for (;
|
|
1133
|
+
let n = "";
|
|
1134
|
+
for (;n.length < 20; ) {
|
|
1132
1135
|
const r = mt(40);
|
|
1133
1136
|
for (let s = 0; s < r.length; ++s)
|
|
1134
1137
|
// Only accept values that are [0, maxMultiple), this ensures they can
|
|
1135
1138
|
// be evenly mapped to indices of `chars` via a modulo operation.
|
|
1136
|
-
|
|
1139
|
+
n.length < 20 && r[s] < e && (n += t.charAt(r[s] % t.length));
|
|
1137
1140
|
}
|
|
1138
|
-
return
|
|
1141
|
+
return n;
|
|
1139
1142
|
}
|
|
1140
1143
|
}
|
|
1141
1144
|
|
|
1142
|
-
function yt(t,
|
|
1143
|
-
return t <
|
|
1145
|
+
function yt(t, e) {
|
|
1146
|
+
return t < e ? -1 : t > e ? 1 : 0;
|
|
1144
1147
|
}
|
|
1145
1148
|
|
|
1146
|
-
/** Helper to compare arrays using isEqual(). */ function _t(t,
|
|
1147
|
-
return t.length ===
|
|
1149
|
+
/** Helper to compare arrays using isEqual(). */ function _t(t, e, n) {
|
|
1150
|
+
return t.length === e.length && t.every(((t, r) => n(t, e[r])));
|
|
1148
1151
|
}
|
|
1149
1152
|
|
|
1150
1153
|
/**
|
|
@@ -1198,9 +1201,9 @@ class gt {
|
|
|
1198
1201
|
/**
|
|
1199
1202
|
* The fractions of a second at nanosecond resolution.*
|
|
1200
1203
|
*/
|
|
1201
|
-
|
|
1202
|
-
if (this.seconds = t, this.nanoseconds =
|
|
1203
|
-
if (
|
|
1204
|
+
e) {
|
|
1205
|
+
if (this.seconds = t, this.nanoseconds = e, e < 0) throw new U(A, "Timestamp nanoseconds out of range: " + e);
|
|
1206
|
+
if (e >= 1e9) throw new U(A, "Timestamp nanoseconds out of range: " + e);
|
|
1204
1207
|
if (t < -62135596800) throw new U(A, "Timestamp seconds out of range: " + t);
|
|
1205
1208
|
// This will break in the year 10,000.
|
|
1206
1209
|
if (t >= 253402300800) throw new U(A, "Timestamp seconds out of range: " + t);
|
|
@@ -1229,8 +1232,8 @@ class gt {
|
|
|
1229
1232
|
* @returns A new `Timestamp` representing the same point in time as the given
|
|
1230
1233
|
* number of milliseconds.
|
|
1231
1234
|
*/ static fromMillis(t) {
|
|
1232
|
-
const
|
|
1233
|
-
return new gt(
|
|
1235
|
+
const e = Math.floor(t / 1e3), n = Math.floor(1e6 * (t - 1e3 * e));
|
|
1236
|
+
return new gt(e, n);
|
|
1234
1237
|
}
|
|
1235
1238
|
/**
|
|
1236
1239
|
* Converts a `Timestamp` to a JavaScript `Date` object. This conversion
|
|
@@ -1308,15 +1311,15 @@ class gt {
|
|
|
1308
1311
|
/**
|
|
1309
1312
|
* A version of a document in Firestore. This corresponds to the version
|
|
1310
1313
|
* timestamp, such as update_time or read_time.
|
|
1311
|
-
*/ class
|
|
1314
|
+
*/ class vt {
|
|
1312
1315
|
constructor(t) {
|
|
1313
1316
|
this.timestamp = t;
|
|
1314
1317
|
}
|
|
1315
1318
|
static fromTimestamp(t) {
|
|
1316
|
-
return new
|
|
1319
|
+
return new vt(t);
|
|
1317
1320
|
}
|
|
1318
1321
|
static min() {
|
|
1319
|
-
return new
|
|
1322
|
+
return new vt(new gt(0, 0));
|
|
1320
1323
|
}
|
|
1321
1324
|
compareTo(t) {
|
|
1322
1325
|
return this.timestamp._compareTo(t.timestamp);
|
|
@@ -1351,14 +1354,14 @@ class gt {
|
|
|
1351
1354
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1352
1355
|
* See the License for the specific language governing permissions and
|
|
1353
1356
|
* limitations under the License.
|
|
1354
|
-
*/ function
|
|
1355
|
-
let
|
|
1356
|
-
for (const
|
|
1357
|
-
return
|
|
1357
|
+
*/ function bt(t) {
|
|
1358
|
+
let e = 0;
|
|
1359
|
+
for (const n in t) Object.prototype.hasOwnProperty.call(t, n) && e++;
|
|
1360
|
+
return e;
|
|
1358
1361
|
}
|
|
1359
1362
|
|
|
1360
|
-
function Et(t,
|
|
1361
|
-
for (const
|
|
1363
|
+
function Et(t, e) {
|
|
1364
|
+
for (const n in t) Object.prototype.hasOwnProperty.call(t, n) && e(n, t[n]);
|
|
1362
1365
|
}
|
|
1363
1366
|
|
|
1364
1367
|
/**
|
|
@@ -1400,11 +1403,11 @@ class Tt {
|
|
|
1400
1403
|
*
|
|
1401
1404
|
* This is an O(n) operation, where `n` is the size of the field mask.
|
|
1402
1405
|
*/ covers(t) {
|
|
1403
|
-
for (const
|
|
1406
|
+
for (const e of this.fields) if (e.isPrefixOf(t)) return !0;
|
|
1404
1407
|
return !1;
|
|
1405
1408
|
}
|
|
1406
1409
|
isEqual(t) {
|
|
1407
|
-
return _t(this.fields, t.fields, ((t,
|
|
1410
|
+
return _t(this.fields, t.fields, ((t, e) => t.isEqual(e)));
|
|
1408
1411
|
}
|
|
1409
1412
|
}
|
|
1410
1413
|
|
|
@@ -1455,23 +1458,23 @@ class It {
|
|
|
1455
1458
|
this.binaryString = t;
|
|
1456
1459
|
}
|
|
1457
1460
|
static fromBase64String(t) {
|
|
1458
|
-
const
|
|
1459
|
-
return new It(
|
|
1461
|
+
const e = atob(t);
|
|
1462
|
+
return new It(e);
|
|
1460
1463
|
}
|
|
1461
1464
|
static fromUint8Array(t) {
|
|
1462
|
-
const
|
|
1465
|
+
const e =
|
|
1463
1466
|
/**
|
|
1464
1467
|
* Helper function to convert an Uint8array to a binary string.
|
|
1465
1468
|
*/
|
|
1466
1469
|
function(t) {
|
|
1467
|
-
let
|
|
1468
|
-
for (let
|
|
1469
|
-
return
|
|
1470
|
+
let e = "";
|
|
1471
|
+
for (let n = 0; n < t.length; ++n) e += String.fromCharCode(t[n]);
|
|
1472
|
+
return e;
|
|
1470
1473
|
}
|
|
1471
1474
|
/**
|
|
1472
1475
|
* Helper function to convert a binary string to an Uint8Array.
|
|
1473
1476
|
*/ (t);
|
|
1474
|
-
return new It(
|
|
1477
|
+
return new It(e);
|
|
1475
1478
|
}
|
|
1476
1479
|
[Symbol.iterator]() {
|
|
1477
1480
|
let t = 0;
|
|
@@ -1492,9 +1495,9 @@ class It {
|
|
|
1492
1495
|
}
|
|
1493
1496
|
toUint8Array() {
|
|
1494
1497
|
return function(t) {
|
|
1495
|
-
const
|
|
1496
|
-
for (let
|
|
1497
|
-
return
|
|
1498
|
+
const e = new Uint8Array(t.length);
|
|
1499
|
+
for (let n = 0; n < t.length; n++) e[n] = t.charCodeAt(n);
|
|
1500
|
+
return e;
|
|
1498
1501
|
}
|
|
1499
1502
|
/**
|
|
1500
1503
|
* @license
|
|
@@ -1537,22 +1540,22 @@ const At = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1537
1540
|
// The json interface (for the browser) will return an iso timestamp string,
|
|
1538
1541
|
// while the proto js library (for node) will return a
|
|
1539
1542
|
// google.protobuf.Timestamp instance.
|
|
1540
|
-
if (
|
|
1543
|
+
if (v(!!t), "string" == typeof t) {
|
|
1541
1544
|
// The date string can have higher precision (nanos) than the Date class
|
|
1542
1545
|
// (millis), so we do some custom parsing here.
|
|
1543
1546
|
// Parse the nanos right out of the string.
|
|
1544
|
-
let
|
|
1545
|
-
const
|
|
1546
|
-
if (
|
|
1547
|
+
let e = 0;
|
|
1548
|
+
const n = At.exec(t);
|
|
1549
|
+
if (v(!!n), n[1]) {
|
|
1547
1550
|
// Pad the fraction out to 9 digits (nanos).
|
|
1548
|
-
let t =
|
|
1549
|
-
t = (t + "000000000").substr(0, 9),
|
|
1551
|
+
let t = n[1];
|
|
1552
|
+
t = (t + "000000000").substr(0, 9), e = Number(t);
|
|
1550
1553
|
}
|
|
1551
1554
|
// Parse the date to get the seconds.
|
|
1552
1555
|
const r = new Date(t);
|
|
1553
1556
|
return {
|
|
1554
1557
|
seconds: Math.floor(r.getTime() / 1e3),
|
|
1555
|
-
nanos:
|
|
1558
|
+
nanos: e
|
|
1556
1559
|
};
|
|
1557
1560
|
}
|
|
1558
1561
|
return {
|
|
@@ -1607,8 +1610,8 @@ const At = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1607
1610
|
* - With respect to other ServerTimestampValues, they sort by their
|
|
1608
1611
|
* localWriteTime.
|
|
1609
1612
|
*/ function Dt(t) {
|
|
1610
|
-
var
|
|
1611
|
-
return "server_timestamp" === (null === (
|
|
1613
|
+
var e, n;
|
|
1614
|
+
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);
|
|
1612
1615
|
}
|
|
1613
1616
|
|
|
1614
1617
|
/**
|
|
@@ -1617,15 +1620,15 @@ const At = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1617
1620
|
* Preserving the previous values allows the user to display the last resoled
|
|
1618
1621
|
* value until the backend responds with the timestamp.
|
|
1619
1622
|
*/ function Nt(t) {
|
|
1620
|
-
const
|
|
1621
|
-
return Dt(
|
|
1623
|
+
const e = t.mapValue.fields.__previous_value__;
|
|
1624
|
+
return Dt(e) ? Nt(e) : e;
|
|
1622
1625
|
}
|
|
1623
1626
|
|
|
1624
1627
|
/**
|
|
1625
1628
|
* Returns the local time at which this timestamp was first set.
|
|
1626
1629
|
*/ function $t(t) {
|
|
1627
|
-
const
|
|
1628
|
-
return new gt(
|
|
1630
|
+
const e = Rt(t.mapValue.fields.__local_write_time__.timestampValue);
|
|
1631
|
+
return new gt(e.seconds, e.nanos);
|
|
1629
1632
|
}
|
|
1630
1633
|
|
|
1631
1634
|
/**
|
|
@@ -1648,169 +1651,169 @@ const At = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1648
1651
|
return "nullValue" in t ? 0 /* NullValue */ : "booleanValue" in t ? 1 /* BooleanValue */ : "integerValue" in t || "doubleValue" in t ? 2 /* NumberValue */ : "timestampValue" in t ? 3 /* TimestampValue */ : "stringValue" in t ? 5 /* StringValue */ : "bytesValue" in t ? 6 /* BlobValue */ : "referenceValue" in t ? 7 /* RefValue */ : "geoPointValue" in t ? 8 /* GeoPointValue */ : "arrayValue" in t ? 9 /* ArrayValue */ : "mapValue" in t ? Dt(t) ? 4 /* ServerTimestampValue */ : 10 /* ObjectValue */ : g();
|
|
1649
1652
|
}
|
|
1650
1653
|
|
|
1651
|
-
/** Tests `left` and `right` for equality based on the backend semantics. */ function Ft(t,
|
|
1652
|
-
if (t ===
|
|
1653
|
-
const
|
|
1654
|
-
if (
|
|
1655
|
-
switch (
|
|
1654
|
+
/** Tests `left` and `right` for equality based on the backend semantics. */ function Ft(t, e) {
|
|
1655
|
+
if (t === e) return !0;
|
|
1656
|
+
const n = St(t);
|
|
1657
|
+
if (n !== St(e)) return !1;
|
|
1658
|
+
switch (n) {
|
|
1656
1659
|
case 0 /* NullValue */ :
|
|
1657
1660
|
return !0;
|
|
1658
1661
|
|
|
1659
1662
|
case 1 /* BooleanValue */ :
|
|
1660
|
-
return t.booleanValue ===
|
|
1663
|
+
return t.booleanValue === e.booleanValue;
|
|
1661
1664
|
|
|
1662
1665
|
case 4 /* ServerTimestampValue */ :
|
|
1663
|
-
return $t(t).isEqual($t(
|
|
1666
|
+
return $t(t).isEqual($t(e));
|
|
1664
1667
|
|
|
1665
1668
|
case 3 /* TimestampValue */ :
|
|
1666
|
-
return function(t,
|
|
1667
|
-
if ("string" == typeof t.timestampValue && "string" == typeof
|
|
1669
|
+
return function(t, e) {
|
|
1670
|
+
if ("string" == typeof t.timestampValue && "string" == typeof e.timestampValue && t.timestampValue.length === e.timestampValue.length)
|
|
1668
1671
|
// Use string equality for ISO 8601 timestamps
|
|
1669
|
-
return t.timestampValue ===
|
|
1670
|
-
const
|
|
1671
|
-
return
|
|
1672
|
-
}(t,
|
|
1672
|
+
return t.timestampValue === e.timestampValue;
|
|
1673
|
+
const n = Rt(t.timestampValue), r = Rt(e.timestampValue);
|
|
1674
|
+
return n.seconds === r.seconds && n.nanos === r.nanos;
|
|
1675
|
+
}(t, e);
|
|
1673
1676
|
|
|
1674
1677
|
case 5 /* StringValue */ :
|
|
1675
|
-
return t.stringValue ===
|
|
1678
|
+
return t.stringValue === e.stringValue;
|
|
1676
1679
|
|
|
1677
1680
|
case 6 /* BlobValue */ :
|
|
1678
|
-
return function(t,
|
|
1679
|
-
return Vt(t.bytesValue).isEqual(Vt(
|
|
1680
|
-
}(t,
|
|
1681
|
+
return function(t, e) {
|
|
1682
|
+
return Vt(t.bytesValue).isEqual(Vt(e.bytesValue));
|
|
1683
|
+
}(t, e);
|
|
1681
1684
|
|
|
1682
1685
|
case 7 /* RefValue */ :
|
|
1683
|
-
return t.referenceValue ===
|
|
1686
|
+
return t.referenceValue === e.referenceValue;
|
|
1684
1687
|
|
|
1685
1688
|
case 8 /* GeoPointValue */ :
|
|
1686
|
-
return function(t,
|
|
1687
|
-
return Pt(t.geoPointValue.latitude) === Pt(
|
|
1688
|
-
}(t,
|
|
1689
|
+
return function(t, e) {
|
|
1690
|
+
return Pt(t.geoPointValue.latitude) === Pt(e.geoPointValue.latitude) && Pt(t.geoPointValue.longitude) === Pt(e.geoPointValue.longitude);
|
|
1691
|
+
}(t, e);
|
|
1689
1692
|
|
|
1690
1693
|
case 2 /* NumberValue */ :
|
|
1691
|
-
return function(t,
|
|
1692
|
-
if ("integerValue" in t && "integerValue" in
|
|
1693
|
-
if ("doubleValue" in t && "doubleValue" in
|
|
1694
|
-
const
|
|
1695
|
-
return
|
|
1694
|
+
return function(t, e) {
|
|
1695
|
+
if ("integerValue" in t && "integerValue" in e) return Pt(t.integerValue) === Pt(e.integerValue);
|
|
1696
|
+
if ("doubleValue" in t && "doubleValue" in e) {
|
|
1697
|
+
const n = Pt(t.doubleValue), r = Pt(e.doubleValue);
|
|
1698
|
+
return n === r ? at(n) === at(r) : isNaN(n) && isNaN(r);
|
|
1696
1699
|
}
|
|
1697
1700
|
return !1;
|
|
1698
|
-
}(t,
|
|
1701
|
+
}(t, e);
|
|
1699
1702
|
|
|
1700
1703
|
case 9 /* ArrayValue */ :
|
|
1701
|
-
return _t(t.arrayValue.values || [],
|
|
1704
|
+
return _t(t.arrayValue.values || [], e.arrayValue.values || [], Ft);
|
|
1702
1705
|
|
|
1703
1706
|
case 10 /* ObjectValue */ :
|
|
1704
|
-
return function(t,
|
|
1705
|
-
const
|
|
1706
|
-
if (
|
|
1707
|
-
for (const t in
|
|
1707
|
+
return function(t, e) {
|
|
1708
|
+
const n = t.mapValue.fields || {}, r = e.mapValue.fields || {};
|
|
1709
|
+
if (bt(n) !== bt(r)) return !1;
|
|
1710
|
+
for (const t in n) if (n.hasOwnProperty(t) && (void 0 === r[t] || !Ft(n[t], r[t]))) return !1;
|
|
1708
1711
|
return !0;
|
|
1709
1712
|
}
|
|
1710
|
-
/** Returns true if the ArrayValue contains the specified element. */ (t,
|
|
1713
|
+
/** Returns true if the ArrayValue contains the specified element. */ (t, e);
|
|
1711
1714
|
|
|
1712
1715
|
default:
|
|
1713
1716
|
return g();
|
|
1714
1717
|
}
|
|
1715
1718
|
}
|
|
1716
1719
|
|
|
1717
|
-
function xt(t,
|
|
1718
|
-
return void 0 !== (t.values || []).find((t => Ft(t,
|
|
1720
|
+
function xt(t, e) {
|
|
1721
|
+
return void 0 !== (t.values || []).find((t => Ft(t, e)));
|
|
1719
1722
|
}
|
|
1720
1723
|
|
|
1721
|
-
function qt(t,
|
|
1722
|
-
if (t ===
|
|
1723
|
-
const
|
|
1724
|
-
if (
|
|
1725
|
-
switch (
|
|
1724
|
+
function qt(t, e) {
|
|
1725
|
+
if (t === e) return 0;
|
|
1726
|
+
const n = St(t), r = St(e);
|
|
1727
|
+
if (n !== r) return yt(n, r);
|
|
1728
|
+
switch (n) {
|
|
1726
1729
|
case 0 /* NullValue */ :
|
|
1727
1730
|
return 0;
|
|
1728
1731
|
|
|
1729
1732
|
case 1 /* BooleanValue */ :
|
|
1730
|
-
return yt(t.booleanValue,
|
|
1733
|
+
return yt(t.booleanValue, e.booleanValue);
|
|
1731
1734
|
|
|
1732
1735
|
case 2 /* NumberValue */ :
|
|
1733
|
-
return function(t,
|
|
1734
|
-
const
|
|
1735
|
-
return
|
|
1736
|
+
return function(t, e) {
|
|
1737
|
+
const n = Pt(t.integerValue || t.doubleValue), r = Pt(e.integerValue || e.doubleValue);
|
|
1738
|
+
return n < r ? -1 : n > r ? 1 : n === r ? 0 :
|
|
1736
1739
|
// one or both are NaN.
|
|
1737
|
-
isNaN(
|
|
1738
|
-
}(t,
|
|
1740
|
+
isNaN(n) ? isNaN(r) ? 0 : -1 : 1;
|
|
1741
|
+
}(t, e);
|
|
1739
1742
|
|
|
1740
1743
|
case 3 /* TimestampValue */ :
|
|
1741
|
-
return Ot(t.timestampValue,
|
|
1744
|
+
return Ot(t.timestampValue, e.timestampValue);
|
|
1742
1745
|
|
|
1743
1746
|
case 4 /* ServerTimestampValue */ :
|
|
1744
|
-
return Ot($t(t), $t(
|
|
1747
|
+
return Ot($t(t), $t(e));
|
|
1745
1748
|
|
|
1746
1749
|
case 5 /* StringValue */ :
|
|
1747
|
-
return yt(t.stringValue,
|
|
1750
|
+
return yt(t.stringValue, e.stringValue);
|
|
1748
1751
|
|
|
1749
1752
|
case 6 /* BlobValue */ :
|
|
1750
|
-
return function(t,
|
|
1751
|
-
const
|
|
1752
|
-
return
|
|
1753
|
-
}(t.bytesValue,
|
|
1753
|
+
return function(t, e) {
|
|
1754
|
+
const n = Vt(t), r = Vt(e);
|
|
1755
|
+
return n.compareTo(r);
|
|
1756
|
+
}(t.bytesValue, e.bytesValue);
|
|
1754
1757
|
|
|
1755
1758
|
case 7 /* RefValue */ :
|
|
1756
|
-
return function(t,
|
|
1757
|
-
const
|
|
1758
|
-
for (let t = 0; t <
|
|
1759
|
-
const
|
|
1760
|
-
if (0 !==
|
|
1759
|
+
return function(t, e) {
|
|
1760
|
+
const n = t.split("/"), r = e.split("/");
|
|
1761
|
+
for (let t = 0; t < n.length && t < r.length; t++) {
|
|
1762
|
+
const e = yt(n[t], r[t]);
|
|
1763
|
+
if (0 !== e) return e;
|
|
1761
1764
|
}
|
|
1762
|
-
return yt(
|
|
1763
|
-
}(t.referenceValue,
|
|
1765
|
+
return yt(n.length, r.length);
|
|
1766
|
+
}(t.referenceValue, e.referenceValue);
|
|
1764
1767
|
|
|
1765
1768
|
case 8 /* GeoPointValue */ :
|
|
1766
|
-
return function(t,
|
|
1767
|
-
const
|
|
1768
|
-
if (0 !==
|
|
1769
|
-
return yt(Pt(t.longitude), Pt(
|
|
1770
|
-
}(t.geoPointValue,
|
|
1769
|
+
return function(t, e) {
|
|
1770
|
+
const n = yt(Pt(t.latitude), Pt(e.latitude));
|
|
1771
|
+
if (0 !== n) return n;
|
|
1772
|
+
return yt(Pt(t.longitude), Pt(e.longitude));
|
|
1773
|
+
}(t.geoPointValue, e.geoPointValue);
|
|
1771
1774
|
|
|
1772
1775
|
case 9 /* ArrayValue */ :
|
|
1773
|
-
return function(t,
|
|
1774
|
-
const
|
|
1775
|
-
for (let t = 0; t <
|
|
1776
|
-
const
|
|
1777
|
-
if (
|
|
1776
|
+
return function(t, e) {
|
|
1777
|
+
const n = t.values || [], r = e.values || [];
|
|
1778
|
+
for (let t = 0; t < n.length && t < r.length; ++t) {
|
|
1779
|
+
const e = qt(n[t], r[t]);
|
|
1780
|
+
if (e) return e;
|
|
1778
1781
|
}
|
|
1779
|
-
return yt(
|
|
1780
|
-
}(t.arrayValue,
|
|
1782
|
+
return yt(n.length, r.length);
|
|
1783
|
+
}(t.arrayValue, e.arrayValue);
|
|
1781
1784
|
|
|
1782
1785
|
case 10 /* ObjectValue */ :
|
|
1783
|
-
return function(t,
|
|
1784
|
-
const
|
|
1786
|
+
return function(t, e) {
|
|
1787
|
+
const n = t.fields || {}, r = Object.keys(n), s = e.fields || {}, i = Object.keys(s);
|
|
1785
1788
|
// Even though MapValues are likely sorted correctly based on their insertion
|
|
1786
1789
|
// order (e.g. when received from the backend), local modifications can bring
|
|
1787
1790
|
// elements out of order. We need to re-sort the elements to ensure that
|
|
1788
1791
|
// canonical IDs are independent of insertion order.
|
|
1789
1792
|
r.sort(), i.sort();
|
|
1790
1793
|
for (let t = 0; t < r.length && t < i.length; ++t) {
|
|
1791
|
-
const
|
|
1792
|
-
if (0 !==
|
|
1793
|
-
const o = qt(
|
|
1794
|
+
const e = yt(r[t], i[t]);
|
|
1795
|
+
if (0 !== e) return e;
|
|
1796
|
+
const o = qt(n[r[t]], s[i[t]]);
|
|
1794
1797
|
if (0 !== o) return o;
|
|
1795
1798
|
}
|
|
1796
1799
|
return yt(r.length, i.length);
|
|
1797
1800
|
}
|
|
1798
|
-
/** Returns a reference value for the provided database and key. */ (t.mapValue,
|
|
1801
|
+
/** Returns a reference value for the provided database and key. */ (t.mapValue, e.mapValue);
|
|
1799
1802
|
|
|
1800
1803
|
default:
|
|
1801
1804
|
throw g();
|
|
1802
1805
|
}
|
|
1803
1806
|
}
|
|
1804
1807
|
|
|
1805
|
-
function Ot(t,
|
|
1806
|
-
if ("string" == typeof t && "string" == typeof
|
|
1807
|
-
const
|
|
1808
|
-
return 0 !== s ? s : yt(
|
|
1808
|
+
function Ot(t, e) {
|
|
1809
|
+
if ("string" == typeof t && "string" == typeof e && t.length === e.length) return yt(t, e);
|
|
1810
|
+
const n = Rt(t), r = Rt(e), s = yt(n.seconds, r.seconds);
|
|
1811
|
+
return 0 !== s ? s : yt(n.nanos, r.nanos);
|
|
1809
1812
|
}
|
|
1810
1813
|
|
|
1811
|
-
function Ct(t,
|
|
1814
|
+
function Ct(t, e) {
|
|
1812
1815
|
return {
|
|
1813
|
-
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${
|
|
1816
|
+
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${e.path.canonicalString()}`
|
|
1814
1817
|
};
|
|
1815
1818
|
}
|
|
1816
1819
|
|
|
@@ -1838,21 +1841,21 @@ function Ct(t, n) {
|
|
|
1838
1841
|
timestampValue: Object.assign({}, t.timestampValue)
|
|
1839
1842
|
};
|
|
1840
1843
|
if (t.mapValue) {
|
|
1841
|
-
const
|
|
1844
|
+
const e = {
|
|
1842
1845
|
mapValue: {
|
|
1843
1846
|
fields: {}
|
|
1844
1847
|
}
|
|
1845
1848
|
};
|
|
1846
|
-
return Et(t.mapValue.fields, ((t,
|
|
1849
|
+
return Et(t.mapValue.fields, ((t, n) => e.mapValue.fields[t] = Mt(n))), e;
|
|
1847
1850
|
}
|
|
1848
1851
|
if (t.arrayValue) {
|
|
1849
|
-
const
|
|
1852
|
+
const e = {
|
|
1850
1853
|
arrayValue: {
|
|
1851
1854
|
values: []
|
|
1852
1855
|
}
|
|
1853
1856
|
};
|
|
1854
|
-
for (let
|
|
1855
|
-
return
|
|
1857
|
+
for (let n = 0; n < (t.arrayValue.values || []).length; ++n) e.arrayValue.values[n] = Mt(t.arrayValue.values[n]);
|
|
1858
|
+
return e;
|
|
1856
1859
|
}
|
|
1857
1860
|
return Object.assign({}, t);
|
|
1858
1861
|
}
|
|
@@ -1893,10 +1896,10 @@ function Ct(t, n) {
|
|
|
1893
1896
|
*/ field(t) {
|
|
1894
1897
|
if (t.isEmpty()) return this.value;
|
|
1895
1898
|
{
|
|
1896
|
-
let
|
|
1897
|
-
for (let
|
|
1898
|
-
!jt(
|
|
1899
|
-
return
|
|
1899
|
+
let e = this.value;
|
|
1900
|
+
for (let n = 0; n < t.length - 1; ++n) if (e = (e.mapValue.fields || {})[t.get(n)],
|
|
1901
|
+
!jt(e)) return null;
|
|
1902
|
+
return e = (e.mapValue.fields || {})[t.lastSegment()], e || null;
|
|
1900
1903
|
}
|
|
1901
1904
|
}
|
|
1902
1905
|
/**
|
|
@@ -1904,25 +1907,25 @@ function Ct(t, n) {
|
|
|
1904
1907
|
*
|
|
1905
1908
|
* @param path - The field path to set.
|
|
1906
1909
|
* @param value - The value to set.
|
|
1907
|
-
*/ set(t,
|
|
1908
|
-
this.getFieldsMap(t.popLast())[t.lastSegment()] = Mt(
|
|
1910
|
+
*/ set(t, e) {
|
|
1911
|
+
this.getFieldsMap(t.popLast())[t.lastSegment()] = Mt(e);
|
|
1909
1912
|
}
|
|
1910
1913
|
/**
|
|
1911
1914
|
* Sets the provided fields to the provided values.
|
|
1912
1915
|
*
|
|
1913
1916
|
* @param data - A map of fields to values (or null for deletes).
|
|
1914
1917
|
*/ setAll(t) {
|
|
1915
|
-
let
|
|
1918
|
+
let e = tt.emptyPath(), n = {}, r = [];
|
|
1916
1919
|
t.forEach(((t, s) => {
|
|
1917
|
-
if (!
|
|
1920
|
+
if (!e.isImmediateParentOf(s)) {
|
|
1918
1921
|
// Insert the accumulated changes at this parent location
|
|
1919
|
-
const t = this.getFieldsMap(
|
|
1920
|
-
this.applyChanges(t,
|
|
1922
|
+
const t = this.getFieldsMap(e);
|
|
1923
|
+
this.applyChanges(t, n, r), n = {}, r = [], e = s.popLast();
|
|
1921
1924
|
}
|
|
1922
|
-
t ?
|
|
1925
|
+
t ? n[s.lastSegment()] = Mt(t) : r.push(s.lastSegment());
|
|
1923
1926
|
}));
|
|
1924
|
-
const s = this.getFieldsMap(
|
|
1925
|
-
this.applyChanges(s,
|
|
1927
|
+
const s = this.getFieldsMap(e);
|
|
1928
|
+
this.applyChanges(s, n, r);
|
|
1926
1929
|
}
|
|
1927
1930
|
/**
|
|
1928
1931
|
* Removes the field at the specified path. If there is no field at the
|
|
@@ -1930,8 +1933,8 @@ function Ct(t, n) {
|
|
|
1930
1933
|
*
|
|
1931
1934
|
* @param path - The field path to remove.
|
|
1932
1935
|
*/ delete(t) {
|
|
1933
|
-
const
|
|
1934
|
-
jt(
|
|
1936
|
+
const e = this.field(t.popLast());
|
|
1937
|
+
jt(e) && e.mapValue.fields && delete e.mapValue.fields[t.lastSegment()];
|
|
1935
1938
|
}
|
|
1936
1939
|
isEqual(t) {
|
|
1937
1940
|
return Ft(this.value, t.value);
|
|
@@ -1940,26 +1943,26 @@ function Ct(t, n) {
|
|
|
1940
1943
|
* Returns the map that contains the leaf element of `path`. If the parent
|
|
1941
1944
|
* entry does not yet exist, or if it is not a map, a new map will be created.
|
|
1942
1945
|
*/ getFieldsMap(t) {
|
|
1943
|
-
let
|
|
1944
|
-
|
|
1946
|
+
let e = this.value;
|
|
1947
|
+
e.mapValue.fields || (e.mapValue = {
|
|
1945
1948
|
fields: {}
|
|
1946
1949
|
});
|
|
1947
|
-
for (let
|
|
1948
|
-
let r =
|
|
1950
|
+
for (let n = 0; n < t.length; ++n) {
|
|
1951
|
+
let r = e.mapValue.fields[t.get(n)];
|
|
1949
1952
|
jt(r) && r.mapValue.fields || (r = {
|
|
1950
1953
|
mapValue: {
|
|
1951
1954
|
fields: {}
|
|
1952
1955
|
}
|
|
1953
|
-
},
|
|
1956
|
+
}, e.mapValue.fields[t.get(n)] = r), e = r;
|
|
1954
1957
|
}
|
|
1955
|
-
return
|
|
1958
|
+
return e.mapValue.fields;
|
|
1956
1959
|
}
|
|
1957
1960
|
/**
|
|
1958
1961
|
* Modifies `fieldsMap` by adding, replacing or deleting the specified
|
|
1959
1962
|
* entries.
|
|
1960
|
-
*/ applyChanges(t,
|
|
1961
|
-
Et(
|
|
1962
|
-
for (const
|
|
1963
|
+
*/ applyChanges(t, e, n) {
|
|
1964
|
+
Et(e, ((e, n) => t[e] = n));
|
|
1965
|
+
for (const e of n) delete t[e];
|
|
1963
1966
|
}
|
|
1964
1967
|
clone() {
|
|
1965
1968
|
return new Bt(Mt(this.value));
|
|
@@ -1992,37 +1995,37 @@ function Ct(t, n) {
|
|
|
1992
1995
|
* applied, `isValidDocument()` returns false and the document should be removed
|
|
1993
1996
|
* from all views.
|
|
1994
1997
|
*/ class zt {
|
|
1995
|
-
constructor(t,
|
|
1996
|
-
this.key = t, this.documentType =
|
|
1998
|
+
constructor(t, e, n, r, s, i) {
|
|
1999
|
+
this.key = t, this.documentType = e, this.version = n, this.readTime = r, this.data = s,
|
|
1997
2000
|
this.documentState = i;
|
|
1998
2001
|
}
|
|
1999
2002
|
/**
|
|
2000
2003
|
* Creates a document with no known version or data, but which can serve as
|
|
2001
2004
|
* base document for mutations.
|
|
2002
2005
|
*/ static newInvalidDocument(t) {
|
|
2003
|
-
return new zt(t, 0 /* INVALID */ ,
|
|
2006
|
+
return new zt(t, 0 /* INVALID */ , vt.min(), vt.min(), Bt.empty(), 0 /* SYNCED */);
|
|
2004
2007
|
}
|
|
2005
2008
|
/**
|
|
2006
2009
|
* Creates a new document that is known to exist with the given data at the
|
|
2007
2010
|
* given version.
|
|
2008
|
-
*/ static newFoundDocument(t,
|
|
2009
|
-
return new zt(t, 1 /* FOUND_DOCUMENT */ ,
|
|
2011
|
+
*/ static newFoundDocument(t, e, n) {
|
|
2012
|
+
return new zt(t, 1 /* FOUND_DOCUMENT */ , e, vt.min(), n, 0 /* SYNCED */);
|
|
2010
2013
|
}
|
|
2011
|
-
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t,
|
|
2012
|
-
return new zt(t, 2 /* NO_DOCUMENT */ ,
|
|
2014
|
+
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t, e) {
|
|
2015
|
+
return new zt(t, 2 /* NO_DOCUMENT */ , e, vt.min(), Bt.empty(), 0 /* SYNCED */);
|
|
2013
2016
|
}
|
|
2014
2017
|
/**
|
|
2015
2018
|
* Creates a new document that is known to exist at the given version but
|
|
2016
2019
|
* whose data is not known (e.g. a document that was updated without a known
|
|
2017
2020
|
* base document).
|
|
2018
|
-
*/ static newUnknownDocument(t,
|
|
2019
|
-
return new zt(t, 3 /* UNKNOWN_DOCUMENT */ ,
|
|
2021
|
+
*/ static newUnknownDocument(t, e) {
|
|
2022
|
+
return new zt(t, 3 /* UNKNOWN_DOCUMENT */ , e, vt.min(), Bt.empty(), 2 /* HAS_COMMITTED_MUTATIONS */);
|
|
2020
2023
|
}
|
|
2021
2024
|
/**
|
|
2022
2025
|
* Changes the document type to indicate that it exists and that its version
|
|
2023
2026
|
* and data are known.
|
|
2024
|
-
*/ convertToFoundDocument(t,
|
|
2025
|
-
return this.version = t, this.documentType = 1 /* FOUND_DOCUMENT */ , this.data =
|
|
2027
|
+
*/ convertToFoundDocument(t, e) {
|
|
2028
|
+
return this.version = t, this.documentType = 1 /* FOUND_DOCUMENT */ , this.data = e,
|
|
2026
2029
|
this.documentState = 0 /* SYNCED */ , this;
|
|
2027
2030
|
}
|
|
2028
2031
|
/**
|
|
@@ -2099,8 +2102,8 @@ function Ct(t, n) {
|
|
|
2099
2102
|
*/
|
|
2100
2103
|
// Visible for testing
|
|
2101
2104
|
class Gt {
|
|
2102
|
-
constructor(t,
|
|
2103
|
-
this.path = t, this.collectionGroup =
|
|
2105
|
+
constructor(t, e = null, n = [], r = [], s = null, i = null, o = null) {
|
|
2106
|
+
this.path = t, this.collectionGroup = e, this.orderBy = n, this.filters = r, this.limit = s,
|
|
2104
2107
|
this.startAt = i, this.endAt = o, this.P = null;
|
|
2105
2108
|
}
|
|
2106
2109
|
}
|
|
@@ -2112,26 +2115,26 @@ class Gt {
|
|
|
2112
2115
|
* NOTE: you should always construct `Target` from `Query.toTarget` instead of
|
|
2113
2116
|
* using this factory method, because `Query` provides an implicit `orderBy`
|
|
2114
2117
|
* property.
|
|
2115
|
-
*/ function Qt(t,
|
|
2116
|
-
return new Gt(t,
|
|
2118
|
+
*/ function Qt(t, e = null, n = [], r = [], s = null, i = null, o = null) {
|
|
2119
|
+
return new Gt(t, e, n, r, s, i, o);
|
|
2117
2120
|
}
|
|
2118
2121
|
|
|
2119
2122
|
class Wt extends class {} {
|
|
2120
|
-
constructor(t,
|
|
2121
|
-
super(), this.field = t, this.op =
|
|
2123
|
+
constructor(t, e, n) {
|
|
2124
|
+
super(), this.field = t, this.op = e, this.value = n;
|
|
2122
2125
|
}
|
|
2123
2126
|
/**
|
|
2124
2127
|
* Creates a filter based on the provided arguments.
|
|
2125
|
-
*/ static create(t,
|
|
2126
|
-
return t.isKeyField() ? "in" /* IN */ ===
|
|
2128
|
+
*/ static create(t, e, n) {
|
|
2129
|
+
return t.isKeyField() ? "in" /* IN */ === e || "not-in" /* NOT_IN */ === e ? this.V(t, e, n) : new Yt(t, e, n) : "array-contains" /* ARRAY_CONTAINS */ === e ? new Xt(t, n) : "in" /* IN */ === e ? new Zt(t, n) : "not-in" /* NOT_IN */ === e ? new te(t, n) : "array-contains-any" /* ARRAY_CONTAINS_ANY */ === e ? new ee(t, n) : new Wt(t, e, n);
|
|
2127
2130
|
}
|
|
2128
|
-
static V(t,
|
|
2129
|
-
return "in" /* IN */ ===
|
|
2131
|
+
static V(t, e, n) {
|
|
2132
|
+
return "in" /* IN */ === e ? new Ht(t, n) : new Kt(t, n);
|
|
2130
2133
|
}
|
|
2131
2134
|
matches(t) {
|
|
2132
|
-
const
|
|
2135
|
+
const e = t.data.field(this.field);
|
|
2133
2136
|
// Types do not have to match in NOT_EQUAL filters.
|
|
2134
|
-
return "!=" /* NOT_EQUAL */ === this.op ? null !==
|
|
2137
|
+
return "!=" /* NOT_EQUAL */ === this.op ? null !== e && this.D(qt(e, this.value)) : null !== e && St(this.value) === St(e) && this.D(qt(e, this.value));
|
|
2135
2138
|
// Only compare types with matching backend order (such as double and int).
|
|
2136
2139
|
}
|
|
2137
2140
|
D(t) {
|
|
@@ -2165,78 +2168,78 @@ class Wt extends class {} {
|
|
|
2165
2168
|
|
|
2166
2169
|
/** Filter that matches on key fields (i.e. '__name__'). */
|
|
2167
2170
|
class Yt extends Wt {
|
|
2168
|
-
constructor(t,
|
|
2169
|
-
super(t,
|
|
2171
|
+
constructor(t, e, n) {
|
|
2172
|
+
super(t, e, n), this.key = et.fromName(n.referenceValue);
|
|
2170
2173
|
}
|
|
2171
2174
|
matches(t) {
|
|
2172
|
-
const
|
|
2173
|
-
return this.D(
|
|
2175
|
+
const e = et.comparator(t.key, this.key);
|
|
2176
|
+
return this.D(e);
|
|
2174
2177
|
}
|
|
2175
2178
|
}
|
|
2176
2179
|
|
|
2177
2180
|
/** Filter that matches on key fields within an array. */ class Ht extends Wt {
|
|
2178
|
-
constructor(t,
|
|
2179
|
-
super(t, "in" /* IN */ ,
|
|
2181
|
+
constructor(t, e) {
|
|
2182
|
+
super(t, "in" /* IN */ , e), this.keys = Jt("in" /* IN */ , e);
|
|
2180
2183
|
}
|
|
2181
2184
|
matches(t) {
|
|
2182
|
-
return this.keys.some((
|
|
2185
|
+
return this.keys.some((e => e.isEqual(t.key)));
|
|
2183
2186
|
}
|
|
2184
2187
|
}
|
|
2185
2188
|
|
|
2186
2189
|
/** Filter that matches on key fields not present within an array. */ class Kt extends Wt {
|
|
2187
|
-
constructor(t,
|
|
2188
|
-
super(t, "not-in" /* NOT_IN */ ,
|
|
2190
|
+
constructor(t, e) {
|
|
2191
|
+
super(t, "not-in" /* NOT_IN */ , e), this.keys = Jt("not-in" /* NOT_IN */ , e);
|
|
2189
2192
|
}
|
|
2190
2193
|
matches(t) {
|
|
2191
|
-
return !this.keys.some((
|
|
2194
|
+
return !this.keys.some((e => e.isEqual(t.key)));
|
|
2192
2195
|
}
|
|
2193
2196
|
}
|
|
2194
2197
|
|
|
2195
|
-
function Jt(t,
|
|
2196
|
-
var
|
|
2197
|
-
return ((null === (
|
|
2198
|
+
function Jt(t, e) {
|
|
2199
|
+
var n;
|
|
2200
|
+
return ((null === (n = e.arrayValue) || void 0 === n ? void 0 : n.values) || []).map((t => et.fromName(t.referenceValue)));
|
|
2198
2201
|
}
|
|
2199
2202
|
|
|
2200
2203
|
/** A Filter that implements the array-contains operator. */ class Xt extends Wt {
|
|
2201
|
-
constructor(t,
|
|
2202
|
-
super(t, "array-contains" /* ARRAY_CONTAINS */ ,
|
|
2204
|
+
constructor(t, e) {
|
|
2205
|
+
super(t, "array-contains" /* ARRAY_CONTAINS */ , e);
|
|
2203
2206
|
}
|
|
2204
2207
|
matches(t) {
|
|
2205
|
-
const
|
|
2206
|
-
return Lt(
|
|
2208
|
+
const e = t.data.field(this.field);
|
|
2209
|
+
return Lt(e) && xt(e.arrayValue, this.value);
|
|
2207
2210
|
}
|
|
2208
2211
|
}
|
|
2209
2212
|
|
|
2210
2213
|
/** A Filter that implements the IN operator. */ class Zt extends Wt {
|
|
2211
|
-
constructor(t,
|
|
2212
|
-
super(t, "in" /* IN */ ,
|
|
2214
|
+
constructor(t, e) {
|
|
2215
|
+
super(t, "in" /* IN */ , e);
|
|
2213
2216
|
}
|
|
2214
2217
|
matches(t) {
|
|
2215
|
-
const
|
|
2216
|
-
return null !==
|
|
2218
|
+
const e = t.data.field(this.field);
|
|
2219
|
+
return null !== e && xt(this.value.arrayValue, e);
|
|
2217
2220
|
}
|
|
2218
2221
|
}
|
|
2219
2222
|
|
|
2220
|
-
/** A Filter that implements the not-in operator. */ class
|
|
2221
|
-
constructor(t,
|
|
2222
|
-
super(t, "not-in" /* NOT_IN */ ,
|
|
2223
|
+
/** A Filter that implements the not-in operator. */ class te extends Wt {
|
|
2224
|
+
constructor(t, e) {
|
|
2225
|
+
super(t, "not-in" /* NOT_IN */ , e);
|
|
2223
2226
|
}
|
|
2224
2227
|
matches(t) {
|
|
2225
2228
|
if (xt(this.value.arrayValue, {
|
|
2226
2229
|
nullValue: "NULL_VALUE"
|
|
2227
2230
|
})) return !1;
|
|
2228
|
-
const
|
|
2229
|
-
return null !==
|
|
2231
|
+
const e = t.data.field(this.field);
|
|
2232
|
+
return null !== e && !xt(this.value.arrayValue, e);
|
|
2230
2233
|
}
|
|
2231
2234
|
}
|
|
2232
2235
|
|
|
2233
|
-
/** A Filter that implements the array-contains-any operator. */ class
|
|
2234
|
-
constructor(t,
|
|
2235
|
-
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ ,
|
|
2236
|
+
/** A Filter that implements the array-contains-any operator. */ class ee extends Wt {
|
|
2237
|
+
constructor(t, e) {
|
|
2238
|
+
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ , e);
|
|
2236
2239
|
}
|
|
2237
2240
|
matches(t) {
|
|
2238
|
-
const
|
|
2239
|
-
return !(!Lt(
|
|
2241
|
+
const e = t.data.field(this.field);
|
|
2242
|
+
return !(!Lt(e) || !e.arrayValue.values) && e.arrayValue.values.some((t => xt(this.value.arrayValue, t)));
|
|
2240
2243
|
}
|
|
2241
2244
|
}
|
|
2242
2245
|
|
|
@@ -2253,30 +2256,30 @@ function Jt(t, n) {
|
|
|
2253
2256
|
* Bound provides a function to determine whether a document comes before or
|
|
2254
2257
|
* after a bound. This is influenced by whether the position is just before or
|
|
2255
2258
|
* just after the provided values.
|
|
2256
|
-
*/ class
|
|
2257
|
-
constructor(t,
|
|
2258
|
-
this.position = t, this.
|
|
2259
|
+
*/ class ne {
|
|
2260
|
+
constructor(t, e) {
|
|
2261
|
+
this.position = t, this.inclusive = e;
|
|
2259
2262
|
}
|
|
2260
2263
|
}
|
|
2261
2264
|
|
|
2262
2265
|
/**
|
|
2263
2266
|
* An ordering on a field, in some Direction. Direction defaults to ASCENDING.
|
|
2264
|
-
*/ class
|
|
2265
|
-
constructor(t,
|
|
2266
|
-
this.field = t, this.dir =
|
|
2267
|
+
*/ class re {
|
|
2268
|
+
constructor(t, e = "asc" /* ASCENDING */) {
|
|
2269
|
+
this.field = t, this.dir = e;
|
|
2267
2270
|
}
|
|
2268
2271
|
}
|
|
2269
2272
|
|
|
2270
|
-
function
|
|
2271
|
-
return t.dir ===
|
|
2273
|
+
function se(t, e) {
|
|
2274
|
+
return t.dir === e.dir && t.field.isEqual(e.field);
|
|
2272
2275
|
}
|
|
2273
2276
|
|
|
2274
|
-
function
|
|
2275
|
-
if (null === t) return null ===
|
|
2276
|
-
if (null ===
|
|
2277
|
-
if (t.
|
|
2278
|
-
for (let
|
|
2279
|
-
if (!Ft(t.position[
|
|
2277
|
+
function ie(t, e) {
|
|
2278
|
+
if (null === t) return null === e;
|
|
2279
|
+
if (null === e) return !1;
|
|
2280
|
+
if (t.inclusive !== e.inclusive || t.position.length !== e.position.length) return !1;
|
|
2281
|
+
for (let n = 0; n < t.position.length; n++) {
|
|
2282
|
+
if (!Ft(t.position[n], e.position[n])) return !1;
|
|
2280
2283
|
}
|
|
2281
2284
|
return !0;
|
|
2282
2285
|
}
|
|
@@ -2303,29 +2306,29 @@ function on(t, n) {
|
|
|
2303
2306
|
* query the RemoteStore results.
|
|
2304
2307
|
*
|
|
2305
2308
|
* Visible for testing.
|
|
2306
|
-
*/ class
|
|
2309
|
+
*/ class oe {
|
|
2307
2310
|
/**
|
|
2308
2311
|
* Initializes a Query with a path and optional additional query constraints.
|
|
2309
2312
|
* Path must currently be empty if this is a collection group query.
|
|
2310
2313
|
*/
|
|
2311
|
-
constructor(t,
|
|
2312
|
-
this.path = t, this.collectionGroup =
|
|
2314
|
+
constructor(t, e = null, n = [], r = [], s = null, i = "F" /* First */ , o = null, u = null) {
|
|
2315
|
+
this.path = t, this.collectionGroup = e, this.explicitOrderBy = n, this.filters = r,
|
|
2313
2316
|
this.limit = s, this.limitType = i, this.startAt = o, this.endAt = u, this.$ = null,
|
|
2314
2317
|
// The corresponding `Target` of this `Query` instance.
|
|
2315
2318
|
this.S = null, this.startAt, this.endAt;
|
|
2316
2319
|
}
|
|
2317
2320
|
}
|
|
2318
2321
|
|
|
2319
|
-
/** Creates a new Query for a query that matches all documents at `path` */ function
|
|
2322
|
+
/** Creates a new Query for a query that matches all documents at `path` */ function ue(t) {
|
|
2320
2323
|
return !ct(t.limit) && "L" /* Last */ === t.limitType;
|
|
2321
2324
|
}
|
|
2322
2325
|
|
|
2323
|
-
function
|
|
2326
|
+
function ce(t) {
|
|
2324
2327
|
return t.explicitOrderBy.length > 0 ? t.explicitOrderBy[0].field : null;
|
|
2325
2328
|
}
|
|
2326
2329
|
|
|
2327
|
-
function
|
|
2328
|
-
for (const
|
|
2330
|
+
function ae(t) {
|
|
2331
|
+
for (const e of t.filters) if (e.N()) return e.field;
|
|
2329
2332
|
return null;
|
|
2330
2333
|
}
|
|
2331
2334
|
|
|
@@ -2337,7 +2340,7 @@ function hn(t) {
|
|
|
2337
2340
|
* Returns whether the query matches a collection group rather than a specific
|
|
2338
2341
|
* collection.
|
|
2339
2342
|
*/
|
|
2340
|
-
function
|
|
2343
|
+
function he(t) {
|
|
2341
2344
|
return null !== t.collectionGroup;
|
|
2342
2345
|
}
|
|
2343
2346
|
|
|
@@ -2345,59 +2348,59 @@ function ln(t) {
|
|
|
2345
2348
|
* Returns the implicit order by constraint that is used to execute the Query,
|
|
2346
2349
|
* which can be different from the order by constraints the user provided (e.g.
|
|
2347
2350
|
* the SDK and backend always orders by `__name__`).
|
|
2348
|
-
*/ function
|
|
2349
|
-
const
|
|
2350
|
-
if (null ===
|
|
2351
|
-
|
|
2352
|
-
const t =
|
|
2353
|
-
if (null !== t && null ===
|
|
2351
|
+
*/ function le(t) {
|
|
2352
|
+
const e = b(t);
|
|
2353
|
+
if (null === e.$) {
|
|
2354
|
+
e.$ = [];
|
|
2355
|
+
const t = ae(e), n = ce(e);
|
|
2356
|
+
if (null !== t && null === n)
|
|
2354
2357
|
// In order to implicitly add key ordering, we must also add the
|
|
2355
2358
|
// inequality filter field for it to be a valid query.
|
|
2356
2359
|
// Note that the default inequality field and key ordering is ascending.
|
|
2357
|
-
t.isKeyField() ||
|
|
2360
|
+
t.isKeyField() || e.$.push(new re(t)), e.$.push(new re(tt.keyField(), "asc" /* ASCENDING */)); else {
|
|
2358
2361
|
let t = !1;
|
|
2359
|
-
for (const
|
|
2362
|
+
for (const n of e.explicitOrderBy) e.$.push(n), n.field.isKeyField() && (t = !0);
|
|
2360
2363
|
if (!t) {
|
|
2361
2364
|
// The order of the implicit key ordering always matches the last
|
|
2362
2365
|
// explicit order by
|
|
2363
|
-
const t =
|
|
2364
|
-
|
|
2366
|
+
const t = e.explicitOrderBy.length > 0 ? e.explicitOrderBy[e.explicitOrderBy.length - 1].dir : "asc" /* ASCENDING */;
|
|
2367
|
+
e.$.push(new re(tt.keyField(), t));
|
|
2365
2368
|
}
|
|
2366
2369
|
}
|
|
2367
2370
|
}
|
|
2368
|
-
return
|
|
2371
|
+
return e.$;
|
|
2369
2372
|
}
|
|
2370
2373
|
|
|
2371
2374
|
/**
|
|
2372
2375
|
* Converts this `Query` instance to it's corresponding `Target` representation.
|
|
2373
|
-
*/ function
|
|
2374
|
-
const
|
|
2375
|
-
if (!
|
|
2376
|
+
*/ function fe(t) {
|
|
2377
|
+
const e = b(t);
|
|
2378
|
+
if (!e.S) if ("F" /* First */ === e.limitType) e.S = Qt(e.path, e.collectionGroup, le(e), e.filters, e.limit, e.startAt, e.endAt); else {
|
|
2376
2379
|
// Flip the orderBy directions since we want the last results
|
|
2377
2380
|
const t = [];
|
|
2378
|
-
for (const
|
|
2379
|
-
const
|
|
2380
|
-
t.push(new
|
|
2381
|
+
for (const n of le(e)) {
|
|
2382
|
+
const e = "desc" /* DESCENDING */ === n.dir ? "asc" /* ASCENDING */ : "desc" /* DESCENDING */;
|
|
2383
|
+
t.push(new re(n.field, e));
|
|
2381
2384
|
}
|
|
2382
2385
|
// We need to swap the cursors to match the now-flipped query ordering.
|
|
2383
|
-
const
|
|
2386
|
+
const n = e.endAt ? new ne(e.endAt.position, !e.endAt.inclusive) : null, r = e.startAt ? new ne(e.startAt.position, !e.startAt.inclusive) : null;
|
|
2384
2387
|
// Now return as a LimitType.First query.
|
|
2385
|
-
|
|
2388
|
+
e.S = Qt(e.path, e.collectionGroup, t, e.filters, e.limit, n, r);
|
|
2386
2389
|
}
|
|
2387
|
-
return
|
|
2390
|
+
return e.S;
|
|
2388
2391
|
}
|
|
2389
2392
|
|
|
2390
|
-
function
|
|
2391
|
-
return function(t,
|
|
2392
|
-
if (t.limit !==
|
|
2393
|
-
if (t.orderBy.length !==
|
|
2394
|
-
for (let
|
|
2395
|
-
if (t.filters.length !==
|
|
2396
|
-
for (let s = 0; s < t.filters.length; s++) if (
|
|
2397
|
-
|
|
2398
|
-
var
|
|
2399
|
-
return t.collectionGroup ===
|
|
2400
|
-
}(
|
|
2393
|
+
function de(t, e) {
|
|
2394
|
+
return function(t, e) {
|
|
2395
|
+
if (t.limit !== e.limit) return !1;
|
|
2396
|
+
if (t.orderBy.length !== e.orderBy.length) return !1;
|
|
2397
|
+
for (let n = 0; n < t.orderBy.length; n++) if (!se(t.orderBy[n], e.orderBy[n])) return !1;
|
|
2398
|
+
if (t.filters.length !== e.filters.length) return !1;
|
|
2399
|
+
for (let s = 0; s < t.filters.length; s++) if (n = t.filters[s], r = e.filters[s],
|
|
2400
|
+
n.op !== r.op || !n.field.isEqual(r.field) || !Ft(n.value, r.value)) return !1;
|
|
2401
|
+
var n, r;
|
|
2402
|
+
return t.collectionGroup === e.collectionGroup && !!t.path.isEqual(e.path) && !!ie(t.startAt, e.startAt) && ie(t.endAt, e.endAt);
|
|
2403
|
+
}(fe(t), fe(e)) && t.limitType === e.limitType;
|
|
2401
2404
|
}
|
|
2402
2405
|
|
|
2403
2406
|
/**
|
|
@@ -2425,10 +2428,10 @@ function wn(t, n) {
|
|
|
2425
2428
|
* The return value is an IntegerValue if it can safely represent the value,
|
|
2426
2429
|
* otherwise a DoubleValue is returned.
|
|
2427
2430
|
*/
|
|
2428
|
-
function
|
|
2431
|
+
function we(t, e) {
|
|
2429
2432
|
return function(t) {
|
|
2430
2433
|
return "number" == typeof t && Number.isInteger(t) && !at(t) && t <= Number.MAX_SAFE_INTEGER && t >= Number.MIN_SAFE_INTEGER;
|
|
2431
|
-
}(
|
|
2434
|
+
}(e) ?
|
|
2432
2435
|
/**
|
|
2433
2436
|
* Returns an IntegerValue for `value`.
|
|
2434
2437
|
*/
|
|
@@ -2436,22 +2439,22 @@ function mn(t, n) {
|
|
|
2436
2439
|
return {
|
|
2437
2440
|
integerValue: "" + t
|
|
2438
2441
|
};
|
|
2439
|
-
}(
|
|
2442
|
+
}(e) : function(t, e) {
|
|
2440
2443
|
if (t.F) {
|
|
2441
|
-
if (isNaN(
|
|
2444
|
+
if (isNaN(e)) return {
|
|
2442
2445
|
doubleValue: "NaN"
|
|
2443
2446
|
};
|
|
2444
|
-
if (
|
|
2447
|
+
if (e === 1 / 0) return {
|
|
2445
2448
|
doubleValue: "Infinity"
|
|
2446
2449
|
};
|
|
2447
|
-
if (
|
|
2450
|
+
if (e === -1 / 0) return {
|
|
2448
2451
|
doubleValue: "-Infinity"
|
|
2449
2452
|
};
|
|
2450
2453
|
}
|
|
2451
2454
|
return {
|
|
2452
|
-
doubleValue: at(
|
|
2455
|
+
doubleValue: at(e) ? "-0" : e
|
|
2453
2456
|
};
|
|
2454
|
-
}(t,
|
|
2457
|
+
}(t, e);
|
|
2455
2458
|
}
|
|
2456
2459
|
|
|
2457
2460
|
/**
|
|
@@ -2470,7 +2473,7 @@ function mn(t, n) {
|
|
|
2470
2473
|
* See the License for the specific language governing permissions and
|
|
2471
2474
|
* limitations under the License.
|
|
2472
2475
|
*/
|
|
2473
|
-
/** Used to represent a field transform on a mutation. */ class
|
|
2476
|
+
/** Used to represent a field transform on a mutation. */ class me {
|
|
2474
2477
|
constructor() {
|
|
2475
2478
|
// Make sure that the structural type of `TransformOperation` is unique.
|
|
2476
2479
|
// See https://github.com/microsoft/TypeScript/issues/5451
|
|
@@ -2478,15 +2481,15 @@ function mn(t, n) {
|
|
|
2478
2481
|
}
|
|
2479
2482
|
}
|
|
2480
2483
|
|
|
2481
|
-
/** Transforms a value into a server-generated timestamp. */ class
|
|
2484
|
+
/** Transforms a value into a server-generated timestamp. */ class pe extends me {}
|
|
2482
2485
|
|
|
2483
|
-
/** Transforms an array value via a union operation. */ class
|
|
2486
|
+
/** Transforms an array value via a union operation. */ class ye extends me {
|
|
2484
2487
|
constructor(t) {
|
|
2485
2488
|
super(), this.elements = t;
|
|
2486
2489
|
}
|
|
2487
2490
|
}
|
|
2488
2491
|
|
|
2489
|
-
/** Transforms an array value via a remove operation. */ class
|
|
2492
|
+
/** Transforms an array value via a remove operation. */ class _e extends me {
|
|
2490
2493
|
constructor(t) {
|
|
2491
2494
|
super(), this.elements = t;
|
|
2492
2495
|
}
|
|
@@ -2497,9 +2500,9 @@ function mn(t, n) {
|
|
|
2497
2500
|
* transforms. Converts all field values to integers or doubles, but unlike the
|
|
2498
2501
|
* backend does not cap integer values at 2^63. Instead, JavaScript number
|
|
2499
2502
|
* arithmetic is used and precision loss can occur for values greater than 2^53.
|
|
2500
|
-
*/ class
|
|
2501
|
-
constructor(t,
|
|
2502
|
-
super(), this.q = t, this.O =
|
|
2503
|
+
*/ class ge extends me {
|
|
2504
|
+
constructor(t, e) {
|
|
2505
|
+
super(), this.q = t, this.O = e;
|
|
2503
2506
|
}
|
|
2504
2507
|
}
|
|
2505
2508
|
|
|
@@ -2519,9 +2522,9 @@ function mn(t, n) {
|
|
|
2519
2522
|
* See the License for the specific language governing permissions and
|
|
2520
2523
|
* limitations under the License.
|
|
2521
2524
|
*/
|
|
2522
|
-
/** A field path and the TransformOperation to perform upon it. */ class
|
|
2523
|
-
constructor(t,
|
|
2524
|
-
this.field = t, this.transform =
|
|
2525
|
+
/** A field path and the TransformOperation to perform upon it. */ class ve {
|
|
2526
|
+
constructor(t, e) {
|
|
2527
|
+
this.field = t, this.transform = e;
|
|
2525
2528
|
}
|
|
2526
2529
|
}
|
|
2527
2530
|
|
|
@@ -2529,18 +2532,18 @@ function mn(t, n) {
|
|
|
2529
2532
|
* Encodes a precondition for a mutation. This follows the model that the
|
|
2530
2533
|
* backend accepts with the special case of an explicit "empty" precondition
|
|
2531
2534
|
* (meaning no precondition).
|
|
2532
|
-
*/ class
|
|
2533
|
-
constructor(t,
|
|
2534
|
-
this.updateTime = t, this.exists =
|
|
2535
|
+
*/ class be {
|
|
2536
|
+
constructor(t, e) {
|
|
2537
|
+
this.updateTime = t, this.exists = e;
|
|
2535
2538
|
}
|
|
2536
2539
|
/** Creates a new empty Precondition. */ static none() {
|
|
2537
|
-
return new
|
|
2540
|
+
return new be;
|
|
2538
2541
|
}
|
|
2539
2542
|
/** Creates a new Precondition with an exists flag. */ static exists(t) {
|
|
2540
|
-
return new
|
|
2543
|
+
return new be(void 0, t);
|
|
2541
2544
|
}
|
|
2542
2545
|
/** Creates a new Precondition based on a version a document exists at. */ static updateTime(t) {
|
|
2543
|
-
return new
|
|
2546
|
+
return new be(t);
|
|
2544
2547
|
}
|
|
2545
2548
|
/** Returns whether this Precondition is empty. */ get isNone() {
|
|
2546
2549
|
return void 0 === this.updateTime && void 0 === this.exists;
|
|
@@ -2593,14 +2596,14 @@ function mn(t, n) {
|
|
|
2593
2596
|
* applyToLocalView() to implement the actual behavior of applying the mutation
|
|
2594
2597
|
* to some source document (see `setMutationApplyToRemoteDocument()` for an
|
|
2595
2598
|
* example).
|
|
2596
|
-
*/ class
|
|
2599
|
+
*/ class Ee {}
|
|
2597
2600
|
|
|
2598
2601
|
/**
|
|
2599
2602
|
* A mutation that creates or replaces the document at the given key with the
|
|
2600
2603
|
* object value contents.
|
|
2601
|
-
*/ class
|
|
2602
|
-
constructor(t,
|
|
2603
|
-
super(), this.key = t, this.value =
|
|
2604
|
+
*/ class Te extends Ee {
|
|
2605
|
+
constructor(t, e, n, r = []) {
|
|
2606
|
+
super(), this.key = t, this.value = e, this.precondition = n, this.fieldTransforms = r,
|
|
2604
2607
|
this.type = 0 /* Set */;
|
|
2605
2608
|
}
|
|
2606
2609
|
}
|
|
@@ -2617,16 +2620,16 @@ function mn(t, n) {
|
|
|
2617
2620
|
* is deleted.
|
|
2618
2621
|
* * When a field is not in the mask but is in the values, the values map is
|
|
2619
2622
|
* ignored.
|
|
2620
|
-
*/ class
|
|
2621
|
-
constructor(t,
|
|
2622
|
-
super(), this.key = t, this.data =
|
|
2623
|
+
*/ class Ie extends Ee {
|
|
2624
|
+
constructor(t, e, n, r, s = []) {
|
|
2625
|
+
super(), this.key = t, this.data = e, this.fieldMask = n, this.precondition = r,
|
|
2623
2626
|
this.fieldTransforms = s, this.type = 1 /* Patch */;
|
|
2624
2627
|
}
|
|
2625
2628
|
}
|
|
2626
2629
|
|
|
2627
|
-
/** A mutation that deletes the document at the given key. */ class
|
|
2628
|
-
constructor(t,
|
|
2629
|
-
super(), this.key = t, this.precondition =
|
|
2630
|
+
/** A mutation that deletes the document at the given key. */ class Ae extends Ee {
|
|
2631
|
+
constructor(t, e) {
|
|
2632
|
+
super(), this.key = t, this.precondition = e, this.type = 2 /* Delete */ , this.fieldTransforms = [];
|
|
2630
2633
|
}
|
|
2631
2634
|
}
|
|
2632
2635
|
|
|
@@ -2636,9 +2639,9 @@ function mn(t, n) {
|
|
|
2636
2639
|
*
|
|
2637
2640
|
* The `verify` operation is only used in Transactions, and this class serves
|
|
2638
2641
|
* primarily to facilitate serialization into protos.
|
|
2639
|
-
*/ class
|
|
2640
|
-
constructor(t,
|
|
2641
|
-
super(), this.key = t, this.precondition =
|
|
2642
|
+
*/ class Re extends Ee {
|
|
2643
|
+
constructor(t, e) {
|
|
2644
|
+
super(), this.key = t, this.precondition = e, this.type = 3 /* Verify */ , this.fieldTransforms = [];
|
|
2642
2645
|
}
|
|
2643
2646
|
}
|
|
2644
2647
|
|
|
@@ -2657,13 +2660,13 @@ function mn(t, n) {
|
|
|
2657
2660
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2658
2661
|
* See the License for the specific language governing permissions and
|
|
2659
2662
|
* limitations under the License.
|
|
2660
|
-
*/ const
|
|
2663
|
+
*/ const Pe = (() => {
|
|
2661
2664
|
const t = {
|
|
2662
2665
|
asc: "ASCENDING",
|
|
2663
2666
|
desc: "DESCENDING"
|
|
2664
2667
|
};
|
|
2665
2668
|
return t;
|
|
2666
|
-
})(),
|
|
2669
|
+
})(), Ve = (() => {
|
|
2667
2670
|
const t = {
|
|
2668
2671
|
"<": "LESS_THAN",
|
|
2669
2672
|
"<=": "LESS_THAN_OR_EQUAL",
|
|
@@ -2693,9 +2696,9 @@ function mn(t, n) {
|
|
|
2693
2696
|
* TODO(klimt): We can remove the databaseId argument if we keep the full
|
|
2694
2697
|
* resource name in documents.
|
|
2695
2698
|
*/
|
|
2696
|
-
class
|
|
2697
|
-
constructor(t,
|
|
2698
|
-
this.databaseId = t, this.F =
|
|
2699
|
+
class De {
|
|
2700
|
+
constructor(t, e) {
|
|
2701
|
+
this.databaseId = t, this.F = e;
|
|
2699
2702
|
}
|
|
2700
2703
|
}
|
|
2701
2704
|
|
|
@@ -2710,13 +2713,13 @@ class Nn {
|
|
|
2710
2713
|
/**
|
|
2711
2714
|
* Returns a value for a Date that's appropriate to put into a proto.
|
|
2712
2715
|
*/
|
|
2713
|
-
function
|
|
2716
|
+
function Ne(t, e) {
|
|
2714
2717
|
if (t.F) {
|
|
2715
|
-
return `${new Date(1e3 *
|
|
2718
|
+
return `${new Date(1e3 * e.seconds).toISOString().replace(/\.\d*/, "").replace("Z", "")}.${("000000000" + e.nanoseconds).slice(-9)}Z`;
|
|
2716
2719
|
}
|
|
2717
2720
|
return {
|
|
2718
|
-
seconds: "" +
|
|
2719
|
-
nanos:
|
|
2721
|
+
seconds: "" + e.seconds,
|
|
2722
|
+
nanos: e.nanoseconds
|
|
2720
2723
|
};
|
|
2721
2724
|
}
|
|
2722
2725
|
|
|
@@ -2725,232 +2728,234 @@ function $n(t, n) {
|
|
|
2725
2728
|
*
|
|
2726
2729
|
* Visible for testing.
|
|
2727
2730
|
*/
|
|
2728
|
-
function
|
|
2729
|
-
return t.F ?
|
|
2731
|
+
function $e(t, e) {
|
|
2732
|
+
return t.F ? e.toBase64() : e.toUint8Array();
|
|
2730
2733
|
}
|
|
2731
2734
|
|
|
2732
|
-
function
|
|
2733
|
-
return
|
|
2735
|
+
function Se(t, e) {
|
|
2736
|
+
return Ne(t, e.toTimestamp());
|
|
2734
2737
|
}
|
|
2735
2738
|
|
|
2736
|
-
function
|
|
2737
|
-
return
|
|
2738
|
-
const
|
|
2739
|
-
return new gt(
|
|
2739
|
+
function Fe(t) {
|
|
2740
|
+
return v(!!t), vt.fromTimestamp(function(t) {
|
|
2741
|
+
const e = Rt(t);
|
|
2742
|
+
return new gt(e.seconds, e.nanos);
|
|
2740
2743
|
}(t));
|
|
2741
2744
|
}
|
|
2742
2745
|
|
|
2743
|
-
function
|
|
2746
|
+
function xe(t, e) {
|
|
2744
2747
|
return function(t) {
|
|
2745
2748
|
return new X([ "projects", t.projectId, "databases", t.database ]);
|
|
2746
|
-
}(t).child("documents").child(
|
|
2749
|
+
}(t).child("documents").child(e).canonicalString();
|
|
2747
2750
|
}
|
|
2748
2751
|
|
|
2749
|
-
function
|
|
2750
|
-
return
|
|
2752
|
+
function qe(t, e) {
|
|
2753
|
+
return xe(t.databaseId, e.path);
|
|
2751
2754
|
}
|
|
2752
2755
|
|
|
2753
|
-
function
|
|
2754
|
-
const
|
|
2755
|
-
const
|
|
2756
|
-
return
|
|
2757
|
-
}(
|
|
2758
|
-
if (
|
|
2759
|
-
if (
|
|
2760
|
-
return new
|
|
2756
|
+
function Oe(t, e) {
|
|
2757
|
+
const n = function(t) {
|
|
2758
|
+
const e = X.fromString(t);
|
|
2759
|
+
return v(We(e)), e;
|
|
2760
|
+
}(e);
|
|
2761
|
+
if (n.get(1) !== t.databaseId.projectId) throw new U(A, "Tried to deserialize key from different project: " + n.get(1) + " vs " + t.databaseId.projectId);
|
|
2762
|
+
if (n.get(3) !== t.databaseId.database) throw new U(A, "Tried to deserialize key from different database: " + n.get(3) + " vs " + t.databaseId.database);
|
|
2763
|
+
return new et((v((r = n).length > 4 && "documents" === r.get(4)), r.popFirst(5)));
|
|
2761
2764
|
var r;
|
|
2762
2765
|
/** Creates a Document proto from key and fields (but no create/update time) */}
|
|
2763
2766
|
|
|
2764
|
-
function
|
|
2765
|
-
return
|
|
2767
|
+
function Ce(t, e) {
|
|
2768
|
+
return xe(t.databaseId, e);
|
|
2766
2769
|
}
|
|
2767
2770
|
|
|
2768
|
-
function
|
|
2771
|
+
function Le(t) {
|
|
2769
2772
|
return new X([ "projects", t.databaseId.projectId, "databases", t.databaseId.database ]).canonicalString();
|
|
2770
2773
|
}
|
|
2771
2774
|
|
|
2772
|
-
function
|
|
2775
|
+
function Ue(t, e, n) {
|
|
2773
2776
|
return {
|
|
2774
|
-
name:
|
|
2775
|
-
fields:
|
|
2777
|
+
name: qe(t, e),
|
|
2778
|
+
fields: n.value.mapValue.fields
|
|
2776
2779
|
};
|
|
2777
2780
|
}
|
|
2778
2781
|
|
|
2779
|
-
function
|
|
2780
|
-
return "found" in
|
|
2781
|
-
|
|
2782
|
-
const
|
|
2782
|
+
function ke(t, e) {
|
|
2783
|
+
return "found" in e ? function(t, e) {
|
|
2784
|
+
v(!!e.found), e.found.name, e.found.updateTime;
|
|
2785
|
+
const n = Oe(t, e.found.name), r = Fe(e.found.updateTime), s = new Bt({
|
|
2783
2786
|
mapValue: {
|
|
2784
|
-
fields:
|
|
2787
|
+
fields: e.found.fields
|
|
2785
2788
|
}
|
|
2786
2789
|
});
|
|
2787
|
-
return zt.newFoundDocument(
|
|
2788
|
-
}(t,
|
|
2789
|
-
|
|
2790
|
-
const
|
|
2791
|
-
return zt.newNoDocument(
|
|
2792
|
-
}(t,
|
|
2793
|
-
}
|
|
2794
|
-
|
|
2795
|
-
function
|
|
2796
|
-
let
|
|
2797
|
-
if (
|
|
2798
|
-
update:
|
|
2799
|
-
}; else if (
|
|
2800
|
-
delete:
|
|
2801
|
-
}; else if (
|
|
2802
|
-
update:
|
|
2803
|
-
updateMask:
|
|
2790
|
+
return zt.newFoundDocument(n, r, s);
|
|
2791
|
+
}(t, e) : "missing" in e ? function(t, e) {
|
|
2792
|
+
v(!!e.missing), v(!!e.readTime);
|
|
2793
|
+
const n = Oe(t, e.missing), r = Fe(e.readTime);
|
|
2794
|
+
return zt.newNoDocument(n, r);
|
|
2795
|
+
}(t, e) : g();
|
|
2796
|
+
}
|
|
2797
|
+
|
|
2798
|
+
function je(t, e) {
|
|
2799
|
+
let n;
|
|
2800
|
+
if (e instanceof Te) n = {
|
|
2801
|
+
update: Ue(t, e.key, e.value)
|
|
2802
|
+
}; else if (e instanceof Ae) n = {
|
|
2803
|
+
delete: qe(t, e.key)
|
|
2804
|
+
}; else if (e instanceof Ie) n = {
|
|
2805
|
+
update: Ue(t, e.key, e.data),
|
|
2806
|
+
updateMask: Qe(e.fieldMask)
|
|
2804
2807
|
}; else {
|
|
2805
|
-
if (!(
|
|
2806
|
-
|
|
2807
|
-
verify:
|
|
2808
|
+
if (!(e instanceof Re)) return g();
|
|
2809
|
+
n = {
|
|
2810
|
+
verify: qe(t, e.key)
|
|
2808
2811
|
};
|
|
2809
2812
|
}
|
|
2810
|
-
return
|
|
2811
|
-
const
|
|
2812
|
-
if (
|
|
2813
|
-
fieldPath:
|
|
2813
|
+
return e.fieldTransforms.length > 0 && (n.updateTransforms = e.fieldTransforms.map((t => function(t, e) {
|
|
2814
|
+
const n = e.transform;
|
|
2815
|
+
if (n instanceof pe) return {
|
|
2816
|
+
fieldPath: e.field.canonicalString(),
|
|
2814
2817
|
setToServerValue: "REQUEST_TIME"
|
|
2815
2818
|
};
|
|
2816
|
-
if (
|
|
2817
|
-
fieldPath:
|
|
2819
|
+
if (n instanceof ye) return {
|
|
2820
|
+
fieldPath: e.field.canonicalString(),
|
|
2818
2821
|
appendMissingElements: {
|
|
2819
|
-
values:
|
|
2822
|
+
values: n.elements
|
|
2820
2823
|
}
|
|
2821
2824
|
};
|
|
2822
|
-
if (
|
|
2823
|
-
fieldPath:
|
|
2825
|
+
if (n instanceof _e) return {
|
|
2826
|
+
fieldPath: e.field.canonicalString(),
|
|
2824
2827
|
removeAllFromArray: {
|
|
2825
|
-
values:
|
|
2828
|
+
values: n.elements
|
|
2826
2829
|
}
|
|
2827
2830
|
};
|
|
2828
|
-
if (
|
|
2829
|
-
fieldPath:
|
|
2830
|
-
increment:
|
|
2831
|
+
if (n instanceof ge) return {
|
|
2832
|
+
fieldPath: e.field.canonicalString(),
|
|
2833
|
+
increment: n.O
|
|
2831
2834
|
};
|
|
2832
2835
|
throw g();
|
|
2833
|
-
}(0, t)))),
|
|
2834
|
-
return void 0 !==
|
|
2835
|
-
updateTime:
|
|
2836
|
-
} : void 0 !==
|
|
2837
|
-
exists:
|
|
2836
|
+
}(0, t)))), e.precondition.isNone || (n.currentDocument = function(t, e) {
|
|
2837
|
+
return void 0 !== e.updateTime ? {
|
|
2838
|
+
updateTime: Se(t, e.updateTime)
|
|
2839
|
+
} : void 0 !== e.exists ? {
|
|
2840
|
+
exists: e.exists
|
|
2838
2841
|
} : g();
|
|
2839
|
-
}(t,
|
|
2842
|
+
}(t, e.precondition)), n;
|
|
2840
2843
|
}
|
|
2841
2844
|
|
|
2842
|
-
function
|
|
2845
|
+
function Me(t, e) {
|
|
2843
2846
|
// Dissect the path into parent, collectionId, and optional key filter.
|
|
2844
|
-
const
|
|
2847
|
+
const n = {
|
|
2845
2848
|
structuredQuery: {}
|
|
2846
|
-
}, r =
|
|
2847
|
-
null !==
|
|
2848
|
-
collectionId:
|
|
2849
|
+
}, r = e.path;
|
|
2850
|
+
null !== e.collectionGroup ? (n.parent = Ce(t, r), n.structuredQuery.from = [ {
|
|
2851
|
+
collectionId: e.collectionGroup,
|
|
2849
2852
|
allDescendants: !0
|
|
2850
|
-
} ]) : (
|
|
2853
|
+
} ]) : (n.parent = Ce(t, r.popLast()), n.structuredQuery.from = [ {
|
|
2851
2854
|
collectionId: r.lastSegment()
|
|
2852
2855
|
} ]);
|
|
2853
2856
|
const s = function(t) {
|
|
2854
2857
|
if (0 === t.length) return;
|
|
2855
|
-
const
|
|
2858
|
+
const e = t.map((t =>
|
|
2856
2859
|
// visible for testing
|
|
2857
2860
|
function(t) {
|
|
2858
2861
|
if ("==" /* EQUAL */ === t.op) {
|
|
2859
2862
|
if (kt(t.value)) return {
|
|
2860
2863
|
unaryFilter: {
|
|
2861
|
-
field:
|
|
2864
|
+
field: Ge(t.field),
|
|
2862
2865
|
op: "IS_NAN"
|
|
2863
2866
|
}
|
|
2864
2867
|
};
|
|
2865
2868
|
if (Ut(t.value)) return {
|
|
2866
2869
|
unaryFilter: {
|
|
2867
|
-
field:
|
|
2870
|
+
field: Ge(t.field),
|
|
2868
2871
|
op: "IS_NULL"
|
|
2869
2872
|
}
|
|
2870
2873
|
};
|
|
2871
2874
|
} else if ("!=" /* NOT_EQUAL */ === t.op) {
|
|
2872
2875
|
if (kt(t.value)) return {
|
|
2873
2876
|
unaryFilter: {
|
|
2874
|
-
field:
|
|
2877
|
+
field: Ge(t.field),
|
|
2875
2878
|
op: "IS_NOT_NAN"
|
|
2876
2879
|
}
|
|
2877
2880
|
};
|
|
2878
2881
|
if (Ut(t.value)) return {
|
|
2879
2882
|
unaryFilter: {
|
|
2880
|
-
field:
|
|
2883
|
+
field: Ge(t.field),
|
|
2881
2884
|
op: "IS_NOT_NULL"
|
|
2882
2885
|
}
|
|
2883
2886
|
};
|
|
2884
2887
|
}
|
|
2885
2888
|
return {
|
|
2886
2889
|
fieldFilter: {
|
|
2887
|
-
field:
|
|
2888
|
-
op:
|
|
2890
|
+
field: Ge(t.field),
|
|
2891
|
+
op: ze(t.op),
|
|
2889
2892
|
value: t.value
|
|
2890
2893
|
}
|
|
2891
2894
|
};
|
|
2892
2895
|
}(t)));
|
|
2893
|
-
if (1 ===
|
|
2896
|
+
if (1 === e.length) return e[0];
|
|
2894
2897
|
return {
|
|
2895
2898
|
compositeFilter: {
|
|
2896
2899
|
op: "AND",
|
|
2897
|
-
filters:
|
|
2900
|
+
filters: e
|
|
2898
2901
|
}
|
|
2899
2902
|
};
|
|
2900
|
-
}(
|
|
2901
|
-
s && (
|
|
2903
|
+
}(e.filters);
|
|
2904
|
+
s && (n.structuredQuery.where = s);
|
|
2902
2905
|
const i = function(t) {
|
|
2903
2906
|
if (0 === t.length) return;
|
|
2904
2907
|
return t.map((t =>
|
|
2905
2908
|
// visible for testing
|
|
2906
2909
|
function(t) {
|
|
2907
2910
|
return {
|
|
2908
|
-
field:
|
|
2909
|
-
direction:
|
|
2911
|
+
field: Ge(t.field),
|
|
2912
|
+
direction: Be(t.dir)
|
|
2910
2913
|
};
|
|
2911
2914
|
}(t)));
|
|
2912
|
-
}(
|
|
2913
|
-
i && (
|
|
2914
|
-
const o = function(t,
|
|
2915
|
-
return t.F || ct(
|
|
2916
|
-
value:
|
|
2915
|
+
}(e.orderBy);
|
|
2916
|
+
i && (n.structuredQuery.orderBy = i);
|
|
2917
|
+
const o = function(t, e) {
|
|
2918
|
+
return t.F || ct(e) ? e : {
|
|
2919
|
+
value: e
|
|
2917
2920
|
};
|
|
2918
|
-
}(t,
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2921
|
+
}(t, e.limit);
|
|
2922
|
+
var u;
|
|
2923
|
+
return null !== o && (n.structuredQuery.limit = o), e.startAt && (n.structuredQuery.startAt = {
|
|
2924
|
+
before: (u = e.startAt).inclusive,
|
|
2925
|
+
values: u.position
|
|
2926
|
+
}), e.endAt && (n.structuredQuery.endAt = function(t) {
|
|
2927
|
+
return {
|
|
2928
|
+
before: !t.inclusive,
|
|
2929
|
+
values: t.position
|
|
2930
|
+
};
|
|
2931
|
+
}
|
|
2932
|
+
// visible for testing
|
|
2933
|
+
(e.endAt)), n;
|
|
2928
2934
|
}
|
|
2929
2935
|
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
return Vn[t];
|
|
2936
|
+
function Be(t) {
|
|
2937
|
+
return Pe[t];
|
|
2933
2938
|
}
|
|
2934
2939
|
|
|
2935
2940
|
// visible for testing
|
|
2936
|
-
function
|
|
2937
|
-
return
|
|
2941
|
+
function ze(t) {
|
|
2942
|
+
return Ve[t];
|
|
2938
2943
|
}
|
|
2939
2944
|
|
|
2940
|
-
function
|
|
2945
|
+
function Ge(t) {
|
|
2941
2946
|
return {
|
|
2942
2947
|
fieldPath: t.canonicalString()
|
|
2943
2948
|
};
|
|
2944
2949
|
}
|
|
2945
2950
|
|
|
2946
|
-
function
|
|
2947
|
-
const
|
|
2948
|
-
return t.fields.forEach((t =>
|
|
2949
|
-
fieldPaths:
|
|
2951
|
+
function Qe(t) {
|
|
2952
|
+
const e = [];
|
|
2953
|
+
return t.fields.forEach((t => e.push(t.canonicalString()))), {
|
|
2954
|
+
fieldPaths: e
|
|
2950
2955
|
};
|
|
2951
2956
|
}
|
|
2952
2957
|
|
|
2953
|
-
function
|
|
2958
|
+
function We(t) {
|
|
2954
2959
|
// Resource names have at least 4 components (project ID, database ID)
|
|
2955
2960
|
return t.length >= 4 && "projects" === t.get(0) && "databases" === t.get(2);
|
|
2956
2961
|
}
|
|
@@ -2970,8 +2975,8 @@ function Hn(t) {
|
|
|
2970
2975
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2971
2976
|
* See the License for the specific language governing permissions and
|
|
2972
2977
|
* limitations under the License.
|
|
2973
|
-
*/ function
|
|
2974
|
-
return new
|
|
2978
|
+
*/ function Ye(t) {
|
|
2979
|
+
return new De(t, /* useProto3Json= */ !0);
|
|
2975
2980
|
}
|
|
2976
2981
|
|
|
2977
2982
|
/**
|
|
@@ -2999,7 +3004,7 @@ function Hn(t) {
|
|
|
2999
3004
|
* base delay. This prevents clients from accidentally synchronizing their
|
|
3000
3005
|
* delays causing spikes of load to the backend.
|
|
3001
3006
|
*/
|
|
3002
|
-
class
|
|
3007
|
+
class He {
|
|
3003
3008
|
constructor(
|
|
3004
3009
|
/**
|
|
3005
3010
|
* The AsyncQueue to run backoff operations on.
|
|
@@ -3008,13 +3013,13 @@ class Jn {
|
|
|
3008
3013
|
/**
|
|
3009
3014
|
* The ID to use when scheduling backoff operations on the AsyncQueue.
|
|
3010
3015
|
*/
|
|
3011
|
-
|
|
3016
|
+
e,
|
|
3012
3017
|
/**
|
|
3013
3018
|
* The initial delay (used as the base delay on the first retry attempt).
|
|
3014
3019
|
* Note that jitter will still be applied, so the actual delay could be as
|
|
3015
3020
|
* little as 0.5*initialDelayMs.
|
|
3016
3021
|
*/
|
|
3017
|
-
|
|
3022
|
+
n = 1e3
|
|
3018
3023
|
/**
|
|
3019
3024
|
* The multiplier to use to determine the extended base delay after each
|
|
3020
3025
|
* attempt.
|
|
@@ -3024,7 +3029,7 @@ class Jn {
|
|
|
3024
3029
|
* Note that jitter will still be applied, so the actual delay could be as
|
|
3025
3030
|
* much as 1.5*maxDelayMs.
|
|
3026
3031
|
*/ , s = 6e4) {
|
|
3027
|
-
this.C = t, this.timerId =
|
|
3032
|
+
this.C = t, this.timerId = e, this.L = n, this.U = r, this.k = s, this.j = 0, this.M = null,
|
|
3028
3033
|
/** The last backoff attempt, as epoch milliseconds. */
|
|
3029
3034
|
this.B = Date.now(), this.reset();
|
|
3030
3035
|
}
|
|
@@ -3052,9 +3057,9 @@ class Jn {
|
|
|
3052
3057
|
this.cancel();
|
|
3053
3058
|
// First schedule using the current base (which may be 0 and should be
|
|
3054
3059
|
// honored as such).
|
|
3055
|
-
const
|
|
3060
|
+
const e = Math.floor(this.j + this.Y()), n = Math.max(0, Date.now() - this.B), r = Math.max(0, e - n);
|
|
3056
3061
|
// Guard against lastAttemptTime being in the future due to a clock change.
|
|
3057
|
-
r > 0 && m("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.j} ms, delay with jitter: ${
|
|
3062
|
+
r > 0 && m("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.j} ms, delay with jitter: ${e} ms, last attempt: ${n} ms ago)`),
|
|
3058
3063
|
this.M = this.C.enqueueAfterDelay(this.timerId, r, (() => (this.B = Date.now(),
|
|
3059
3064
|
t()))),
|
|
3060
3065
|
// Apply backoff factor to determine next delay and ensure it is within
|
|
@@ -3097,22 +3102,22 @@ class Jn {
|
|
|
3097
3102
|
* An implementation of Datastore that exposes additional state for internal
|
|
3098
3103
|
* consumption.
|
|
3099
3104
|
*/
|
|
3100
|
-
class
|
|
3101
|
-
constructor(t,
|
|
3102
|
-
super(), this.authCredentials = t, this.appCheckCredentials =
|
|
3105
|
+
class Ke extends class {} {
|
|
3106
|
+
constructor(t, e, n, r) {
|
|
3107
|
+
super(), this.authCredentials = t, this.appCheckCredentials = e, this.K = n, this.q = r,
|
|
3103
3108
|
this.J = !1;
|
|
3104
3109
|
}
|
|
3105
3110
|
X() {
|
|
3106
3111
|
if (this.J) throw new U(S, "The client has already been terminated.");
|
|
3107
3112
|
}
|
|
3108
|
-
/** Invokes the provided RPC with auth and AppCheck tokens. */ m(t,
|
|
3109
|
-
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.m(t,
|
|
3113
|
+
/** Invokes the provided RPC with auth and AppCheck tokens. */ m(t, e, n) {
|
|
3114
|
+
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.m(t, e, n, r, s))).catch((t => {
|
|
3110
3115
|
throw "FirebaseError" === t.name ? (t.code === N && (this.authCredentials.invalidateToken(),
|
|
3111
3116
|
this.appCheckCredentials.invalidateToken()), t) : new U(I, t.toString());
|
|
3112
3117
|
}));
|
|
3113
3118
|
}
|
|
3114
|
-
/** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */ T(t,
|
|
3115
|
-
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.T(t,
|
|
3119
|
+
/** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */ T(t, e, n) {
|
|
3120
|
+
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.T(t, e, n, r, s))).catch((t => {
|
|
3116
3121
|
throw "FirebaseError" === t.name ? (t.code === N && (this.authCredentials.invalidateToken(),
|
|
3117
3122
|
this.appCheckCredentials.invalidateToken()), t) : new U(I, t.toString());
|
|
3118
3123
|
}));
|
|
@@ -3124,40 +3129,40 @@ class Xn extends class {} {
|
|
|
3124
3129
|
|
|
3125
3130
|
// TODO(firestorexp): Make sure there is only one Datastore instance per
|
|
3126
3131
|
// firestore-exp client.
|
|
3127
|
-
async function
|
|
3128
|
-
const
|
|
3129
|
-
writes:
|
|
3132
|
+
async function Je(t, e) {
|
|
3133
|
+
const n = b(t), r = Le(n.q) + "/documents", s = {
|
|
3134
|
+
writes: e.map((t => je(n.q, t)))
|
|
3130
3135
|
};
|
|
3131
|
-
await
|
|
3136
|
+
await n.m("Commit", r, s);
|
|
3132
3137
|
}
|
|
3133
3138
|
|
|
3134
|
-
async function
|
|
3135
|
-
const
|
|
3136
|
-
documents:
|
|
3137
|
-
}, i = await
|
|
3139
|
+
async function Xe(t, e) {
|
|
3140
|
+
const n = b(t), r = Le(n.q) + "/documents", s = {
|
|
3141
|
+
documents: e.map((t => qe(n.q, t)))
|
|
3142
|
+
}, i = await n.T("BatchGetDocuments", r, s), o = new Map;
|
|
3138
3143
|
i.forEach((t => {
|
|
3139
|
-
const
|
|
3140
|
-
o.set(
|
|
3144
|
+
const e = ke(n.q, t);
|
|
3145
|
+
o.set(e.key.toString(), e);
|
|
3141
3146
|
}));
|
|
3142
3147
|
const u = [];
|
|
3143
|
-
return
|
|
3144
|
-
const
|
|
3145
|
-
|
|
3148
|
+
return e.forEach((t => {
|
|
3149
|
+
const e = o.get(t.toString());
|
|
3150
|
+
v(!!e), u.push(e);
|
|
3146
3151
|
})), u;
|
|
3147
3152
|
}
|
|
3148
3153
|
|
|
3149
|
-
async function
|
|
3150
|
-
const
|
|
3151
|
-
return (await
|
|
3154
|
+
async function Ze(t, e) {
|
|
3155
|
+
const n = b(t), r = Me(n.q, fe(e));
|
|
3156
|
+
return (await n.T("RunQuery", r.parent, {
|
|
3152
3157
|
structuredQuery: r.structuredQuery
|
|
3153
|
-
})).filter((t => !!t.document)).map((t => function(t,
|
|
3154
|
-
const r =
|
|
3158
|
+
})).filter((t => !!t.document)).map((t => function(t, e, n) {
|
|
3159
|
+
const r = Oe(t, e.name), s = Fe(e.updateTime), i = new Bt({
|
|
3155
3160
|
mapValue: {
|
|
3156
|
-
fields:
|
|
3161
|
+
fields: e.fields
|
|
3157
3162
|
}
|
|
3158
3163
|
}), o = zt.newFoundDocument(r, s, i);
|
|
3159
|
-
return
|
|
3160
|
-
}(
|
|
3164
|
+
return n && o.setHasCommittedMutations(), n ? o.setHasCommittedMutations() : o;
|
|
3165
|
+
}(n.q, t.document, void 0)));
|
|
3161
3166
|
}
|
|
3162
3167
|
|
|
3163
3168
|
/**
|
|
@@ -3175,7 +3180,7 @@ async function ne(t, n) {
|
|
|
3175
3180
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3176
3181
|
* See the License for the specific language governing permissions and
|
|
3177
3182
|
* limitations under the License.
|
|
3178
|
-
*/ const
|
|
3183
|
+
*/ const tn = new Map;
|
|
3179
3184
|
|
|
3180
3185
|
/**
|
|
3181
3186
|
* An instance map that ensures only one Datastore exists per Firestore
|
|
@@ -3186,19 +3191,19 @@ async function ne(t, n) {
|
|
|
3186
3191
|
* instance. Callers must invoke removeComponents() when the Firestore
|
|
3187
3192
|
* instance is terminated.
|
|
3188
3193
|
*/
|
|
3189
|
-
function
|
|
3194
|
+
function en(t) {
|
|
3190
3195
|
if (t._terminated) throw new U(S, "The client has already been terminated.");
|
|
3191
|
-
if (!
|
|
3196
|
+
if (!tn.has(t)) {
|
|
3192
3197
|
m("ComponentProvider", "Initializing Datastore");
|
|
3193
3198
|
const i = function(t) {
|
|
3194
3199
|
return new wt(t, fetch.bind(null));
|
|
3195
|
-
}((
|
|
3196
|
-
new H(
|
|
3197
|
-
return new
|
|
3200
|
+
}((e = t._databaseId, n = t.app.options.appId || "", r = t._persistenceKey, s = t._freezeSettings(),
|
|
3201
|
+
new H(e, n, r, s.host, s.ssl, s.experimentalForceLongPolling, s.experimentalAutoDetectLongPolling, s.useFetchStreams))), o = Ye(t._databaseId), u = function(t, e, n, r) {
|
|
3202
|
+
return new Ke(t, e, n, r);
|
|
3198
3203
|
}(t._authCredentials, t._appCheckCredentials, i, o);
|
|
3199
|
-
|
|
3204
|
+
tn.set(t, u);
|
|
3200
3205
|
}
|
|
3201
|
-
var
|
|
3206
|
+
var e, n, r, s;
|
|
3202
3207
|
/**
|
|
3203
3208
|
* @license
|
|
3204
3209
|
* Copyright 2018 Google LLC
|
|
@@ -3214,7 +3219,7 @@ function re(t) {
|
|
|
3214
3219
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3215
3220
|
* See the License for the specific language governing permissions and
|
|
3216
3221
|
* limitations under the License.
|
|
3217
|
-
*/ return
|
|
3222
|
+
*/ return tn.get(t);
|
|
3218
3223
|
}
|
|
3219
3224
|
|
|
3220
3225
|
/**
|
|
@@ -3226,21 +3231,21 @@ function re(t) {
|
|
|
3226
3231
|
* user-supplied `FirestoreSettings` object. This is a separate type so that
|
|
3227
3232
|
* defaults can be supplied and the value can be checked for equality.
|
|
3228
3233
|
*/
|
|
3229
|
-
class
|
|
3234
|
+
class nn {
|
|
3230
3235
|
constructor(t) {
|
|
3231
|
-
var
|
|
3236
|
+
var e;
|
|
3232
3237
|
if (void 0 === t.host) {
|
|
3233
3238
|
if (void 0 !== t.ssl) throw new U(A, "Can't provide ssl option if host option is not set");
|
|
3234
3239
|
this.host = "firestore.googleapis.com", this.ssl = true;
|
|
3235
|
-
} else this.host = t.host, this.ssl = null === (
|
|
3240
|
+
} else this.host = t.host, this.ssl = null === (e = t.ssl) || void 0 === e || e;
|
|
3236
3241
|
if (this.credentials = t.credentials, this.ignoreUndefinedProperties = !!t.ignoreUndefinedProperties,
|
|
3237
3242
|
void 0 === t.cacheSizeBytes) this.cacheSizeBytes = 41943040; else {
|
|
3238
3243
|
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new U(A, "cacheSizeBytes must be at least 1048576");
|
|
3239
3244
|
this.cacheSizeBytes = t.cacheSizeBytes;
|
|
3240
3245
|
}
|
|
3241
3246
|
this.experimentalForceLongPolling = !!t.experimentalForceLongPolling, this.experimentalAutoDetectLongPolling = !!t.experimentalAutoDetectLongPolling,
|
|
3242
|
-
this.useFetchStreams = !!t.useFetchStreams, function(t,
|
|
3243
|
-
if (!0 ===
|
|
3247
|
+
this.useFetchStreams = !!t.useFetchStreams, function(t, e, n, r) {
|
|
3248
|
+
if (!0 === e && !0 === r) throw new U(A, `${t} and ${n} cannot be used together.`);
|
|
3244
3249
|
}("experimentalForceLongPolling", t.experimentalForceLongPolling, "experimentalAutoDetectLongPolling", t.experimentalAutoDetectLongPolling);
|
|
3245
3250
|
}
|
|
3246
3251
|
isEqual(t) {
|
|
@@ -3268,14 +3273,14 @@ class se {
|
|
|
3268
3273
|
* The Cloud Firestore service interface.
|
|
3269
3274
|
*
|
|
3270
3275
|
* Do not call this constructor directly. Instead, use {@link getFirestore}.
|
|
3271
|
-
*/ class
|
|
3276
|
+
*/ class rn {
|
|
3272
3277
|
/** @hideconstructor */
|
|
3273
|
-
constructor(t,
|
|
3274
|
-
this._authCredentials =
|
|
3278
|
+
constructor(t, e, n) {
|
|
3279
|
+
this._authCredentials = e, this._appCheckCredentials = n,
|
|
3275
3280
|
/**
|
|
3276
3281
|
* Whether it's a Firestore or Firestore Lite instance.
|
|
3277
3282
|
*/
|
|
3278
|
-
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new
|
|
3283
|
+
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new nn({}),
|
|
3279
3284
|
this._settingsFrozen = !1, t instanceof K ? this._databaseId = t : (this._app = t,
|
|
3280
3285
|
this._databaseId = function(t) {
|
|
3281
3286
|
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new U(A, '"projectId" not provided in firebase.initializeApp.');
|
|
@@ -3308,14 +3313,14 @@ class se {
|
|
|
3308
3313
|
}
|
|
3309
3314
|
_setSettings(t) {
|
|
3310
3315
|
if (this._settingsFrozen) throw new U(S, "Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");
|
|
3311
|
-
this._settings = new
|
|
3316
|
+
this._settings = new nn(t), void 0 !== t.credentials && (this._authCredentials = function(t) {
|
|
3312
3317
|
if (!t) return new M;
|
|
3313
3318
|
switch (t.type) {
|
|
3314
3319
|
case "gapi":
|
|
3315
|
-
const
|
|
3320
|
+
const e = t.client;
|
|
3316
3321
|
// Make sure this really is a Gapi client.
|
|
3317
|
-
return
|
|
3318
|
-
new Q(
|
|
3322
|
+
return v(!("object" != typeof e || null === e || !e.auth || !e.auth.getAuthHeaderValueForFirstParty)),
|
|
3323
|
+
new Q(e, t.sessionIndex || "0", t.iamToken || null);
|
|
3319
3324
|
|
|
3320
3325
|
case "provider":
|
|
3321
3326
|
return t.client;
|
|
@@ -3349,17 +3354,17 @@ class se {
|
|
|
3349
3354
|
* Only ever called once.
|
|
3350
3355
|
*/ _terminate() {
|
|
3351
3356
|
return function(t) {
|
|
3352
|
-
const
|
|
3353
|
-
|
|
3357
|
+
const e = tn.get(t);
|
|
3358
|
+
e && (m("ComponentProvider", "Removing Datastore"), tn.delete(t), e.terminate());
|
|
3354
3359
|
}(this), Promise.resolve();
|
|
3355
3360
|
}
|
|
3356
3361
|
}
|
|
3357
3362
|
|
|
3358
|
-
function
|
|
3359
|
-
const
|
|
3360
|
-
if (
|
|
3361
|
-
return
|
|
3362
|
-
options:
|
|
3363
|
+
function sn(t, e) {
|
|
3364
|
+
const n = _getProvider(t, "firestore/lite");
|
|
3365
|
+
if (n.isInitialized()) throw new U(S, "Firestore can only be initialized once per app.");
|
|
3366
|
+
return n.initialize({
|
|
3367
|
+
options: e
|
|
3363
3368
|
});
|
|
3364
3369
|
}
|
|
3365
3370
|
|
|
@@ -3371,8 +3376,8 @@ function oe(t, n) {
|
|
|
3371
3376
|
* @param app - The {@link @firebase/app#FirebaseApp} instance that the returned `Firestore`
|
|
3372
3377
|
* instance is associated with.
|
|
3373
3378
|
* @returns The `Firestore` instance of the provided app.
|
|
3374
|
-
*/ function
|
|
3375
|
-
return _getProvider(
|
|
3379
|
+
*/ function on(e = getApp()) {
|
|
3380
|
+
return _getProvider(e, "firestore/lite").getImmediate();
|
|
3376
3381
|
}
|
|
3377
3382
|
|
|
3378
3383
|
/**
|
|
@@ -3387,24 +3392,24 @@ function oe(t, n) {
|
|
|
3387
3392
|
* @param port - the emulator port (ex: 9000).
|
|
3388
3393
|
* @param options.mockUserToken - the mock auth token to use for unit testing
|
|
3389
3394
|
* Security Rules.
|
|
3390
|
-
*/ function
|
|
3395
|
+
*/ function un(t, e, n, r = {}) {
|
|
3391
3396
|
var s;
|
|
3392
|
-
const i = (t = ot(t,
|
|
3393
|
-
if ("firestore.googleapis.com" !== i.host && i.host !==
|
|
3397
|
+
const i = (t = ot(t, rn))._getSettings();
|
|
3398
|
+
if ("firestore.googleapis.com" !== i.host && i.host !== e && y("Host has been set in both settings() and useEmulator(), emulator host will be used"),
|
|
3394
3399
|
t._setSettings(Object.assign(Object.assign({}, i), {
|
|
3395
|
-
host: `${
|
|
3400
|
+
host: `${e}:${n}`,
|
|
3396
3401
|
ssl: !1
|
|
3397
3402
|
})), r.mockUserToken) {
|
|
3398
|
-
let
|
|
3399
|
-
if ("string" == typeof r.mockUserToken)
|
|
3403
|
+
let e, n;
|
|
3404
|
+
if ("string" == typeof r.mockUserToken) e = r.mockUserToken, n = l.MOCK_USER; else {
|
|
3400
3405
|
// Let createMockUserToken validate first (catches common mistakes like
|
|
3401
3406
|
// invalid field "uid" and missing field "sub" / "user_id".)
|
|
3402
|
-
|
|
3407
|
+
e = createMockUserToken(r.mockUserToken, null === (s = t._app) || void 0 === s ? void 0 : s.options.projectId);
|
|
3403
3408
|
const i = r.mockUserToken.sub || r.mockUserToken.user_id;
|
|
3404
3409
|
if (!i) throw new U(A, "mockUserToken must contain 'sub' or 'user_id' field!");
|
|
3405
|
-
|
|
3410
|
+
n = new l(i);
|
|
3406
3411
|
}
|
|
3407
|
-
t._authCredentials = new B(new j(
|
|
3412
|
+
t._authCredentials = new B(new j(e, n));
|
|
3408
3413
|
}
|
|
3409
3414
|
}
|
|
3410
3415
|
|
|
@@ -3427,8 +3432,8 @@ function oe(t, n) {
|
|
|
3427
3432
|
* @param firestore - The `Firestore` instance to terminate.
|
|
3428
3433
|
* @returns A `Promise` that is resolved when the instance has been successfully
|
|
3429
3434
|
* terminated.
|
|
3430
|
-
*/ function
|
|
3431
|
-
return t = ot(t,
|
|
3435
|
+
*/ function cn(t) {
|
|
3436
|
+
return t = ot(t, rn), _removeServiceInstance(t.app, "firestore/lite"), t._delete();
|
|
3432
3437
|
}
|
|
3433
3438
|
|
|
3434
3439
|
/**
|
|
@@ -3468,14 +3473,14 @@ function oe(t, n) {
|
|
|
3468
3473
|
* and can be used to write, read, or listen to the location. The document at
|
|
3469
3474
|
* the referenced location may or may not exist.
|
|
3470
3475
|
*/
|
|
3471
|
-
class
|
|
3476
|
+
class an {
|
|
3472
3477
|
/** @hideconstructor */
|
|
3473
3478
|
constructor(t,
|
|
3474
3479
|
/**
|
|
3475
3480
|
* If provided, the `FirestoreDataConverter` associated with this instance.
|
|
3476
3481
|
*/
|
|
3477
|
-
|
|
3478
|
-
this.converter =
|
|
3482
|
+
e, n) {
|
|
3483
|
+
this.converter = e, this._key = n,
|
|
3479
3484
|
/** The type of this Firestore reference. */
|
|
3480
3485
|
this.type = "document", this.firestore = t;
|
|
3481
3486
|
}
|
|
@@ -3496,40 +3501,40 @@ class he {
|
|
|
3496
3501
|
/**
|
|
3497
3502
|
* The collection this `DocumentReference` belongs to.
|
|
3498
3503
|
*/ get parent() {
|
|
3499
|
-
return new
|
|
3504
|
+
return new ln(this.firestore, this.converter, this._key.path.popLast());
|
|
3500
3505
|
}
|
|
3501
3506
|
withConverter(t) {
|
|
3502
|
-
return new
|
|
3507
|
+
return new an(this.firestore, t, this._key);
|
|
3503
3508
|
}
|
|
3504
3509
|
}
|
|
3505
3510
|
|
|
3506
3511
|
/**
|
|
3507
3512
|
* A `Query` refers to a query which you can read or listen to. You can also
|
|
3508
3513
|
* construct refined `Query` objects by adding filters and ordering.
|
|
3509
|
-
*/ class
|
|
3514
|
+
*/ class hn {
|
|
3510
3515
|
// This is the lite version of the Query class in the main SDK.
|
|
3511
3516
|
/** @hideconstructor protected */
|
|
3512
3517
|
constructor(t,
|
|
3513
3518
|
/**
|
|
3514
3519
|
* If provided, the `FirestoreDataConverter` associated with this instance.
|
|
3515
3520
|
*/
|
|
3516
|
-
|
|
3517
|
-
this.converter =
|
|
3521
|
+
e, n) {
|
|
3522
|
+
this.converter = e, this._query = n,
|
|
3518
3523
|
/** The type of this Firestore reference. */
|
|
3519
3524
|
this.type = "query", this.firestore = t;
|
|
3520
3525
|
}
|
|
3521
3526
|
withConverter(t) {
|
|
3522
|
-
return new
|
|
3527
|
+
return new hn(this.firestore, t, this._query);
|
|
3523
3528
|
}
|
|
3524
3529
|
}
|
|
3525
3530
|
|
|
3526
3531
|
/**
|
|
3527
3532
|
* A `CollectionReference` object can be used for adding documents, getting
|
|
3528
3533
|
* document references, and querying for documents (using {@link query}).
|
|
3529
|
-
*/ class
|
|
3534
|
+
*/ class ln extends hn {
|
|
3530
3535
|
/** @hideconstructor */
|
|
3531
|
-
constructor(t,
|
|
3532
|
-
super(t,
|
|
3536
|
+
constructor(t, e, n) {
|
|
3537
|
+
super(t, e, new oe(n)), this._path = n,
|
|
3533
3538
|
/** The type of this Firestore reference. */
|
|
3534
3539
|
this.type = "collection";
|
|
3535
3540
|
}
|
|
@@ -3547,23 +3552,23 @@ class he {
|
|
|
3547
3552
|
* subcollection. If this isn't a subcollection, the reference is null.
|
|
3548
3553
|
*/ get parent() {
|
|
3549
3554
|
const t = this._path.popLast();
|
|
3550
|
-
return t.isEmpty() ? null : new
|
|
3551
|
-
/* converter= */ null, new
|
|
3555
|
+
return t.isEmpty() ? null : new an(this.firestore,
|
|
3556
|
+
/* converter= */ null, new et(t));
|
|
3552
3557
|
}
|
|
3553
3558
|
withConverter(t) {
|
|
3554
|
-
return new
|
|
3559
|
+
return new ln(this.firestore, t, this._path);
|
|
3555
3560
|
}
|
|
3556
3561
|
}
|
|
3557
3562
|
|
|
3558
|
-
function
|
|
3559
|
-
if (t = getModularInstance(t),
|
|
3560
|
-
const r = X.fromString(
|
|
3561
|
-
return st(r), new
|
|
3563
|
+
function fn(t, e, ...n) {
|
|
3564
|
+
if (t = getModularInstance(t), nt("collection", "path", e), t instanceof rn) {
|
|
3565
|
+
const r = X.fromString(e, ...n);
|
|
3566
|
+
return st(r), new ln(t, /* converter= */ null, r);
|
|
3562
3567
|
}
|
|
3563
3568
|
{
|
|
3564
|
-
if (!(t instanceof
|
|
3565
|
-
const r = t._path.child(X.fromString(
|
|
3566
|
-
return st(r), new
|
|
3569
|
+
if (!(t instanceof an || t instanceof ln)) throw new U(A, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3570
|
+
const r = t._path.child(X.fromString(e, ...n));
|
|
3571
|
+
return st(r), new ln(t.firestore,
|
|
3567
3572
|
/* converter= */ null, r);
|
|
3568
3573
|
}
|
|
3569
3574
|
}
|
|
@@ -3580,32 +3585,32 @@ function de(t, n, ...e) {
|
|
|
3580
3585
|
* collection or subcollection with this ID as the last segment of its path
|
|
3581
3586
|
* will be included. Cannot contain a slash.
|
|
3582
3587
|
* @returns The created `Query`.
|
|
3583
|
-
*/ function
|
|
3584
|
-
if (t = ot(t,
|
|
3585
|
-
return new
|
|
3588
|
+
*/ function dn(t, e) {
|
|
3589
|
+
if (t = ot(t, rn), nt("collectionGroup", "collection id", e), e.indexOf("/") >= 0) throw new U(A, `Invalid collection ID '${e}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);
|
|
3590
|
+
return new hn(t,
|
|
3586
3591
|
/* converter= */ null,
|
|
3587
3592
|
/**
|
|
3588
3593
|
* Creates a new Query for a collection group query that matches all documents
|
|
3589
3594
|
* within the provided collection group.
|
|
3590
3595
|
*/
|
|
3591
3596
|
function(t) {
|
|
3592
|
-
return new
|
|
3593
|
-
}(
|
|
3597
|
+
return new oe(X.emptyPath(), t);
|
|
3598
|
+
}(e));
|
|
3594
3599
|
}
|
|
3595
3600
|
|
|
3596
|
-
function
|
|
3601
|
+
function wn(t, e, ...n) {
|
|
3597
3602
|
if (t = getModularInstance(t),
|
|
3598
3603
|
// We allow omission of 'pathString' but explicitly prohibit passing in both
|
|
3599
3604
|
// 'undefined' and 'null'.
|
|
3600
|
-
1 === arguments.length && (
|
|
3601
|
-
const r = X.fromString(
|
|
3602
|
-
return rt(r), new
|
|
3603
|
-
/* converter= */ null, new
|
|
3605
|
+
1 === arguments.length && (e = pt.R()), nt("doc", "path", e), t instanceof rn) {
|
|
3606
|
+
const r = X.fromString(e, ...n);
|
|
3607
|
+
return rt(r), new an(t,
|
|
3608
|
+
/* converter= */ null, new et(r));
|
|
3604
3609
|
}
|
|
3605
3610
|
{
|
|
3606
|
-
if (!(t instanceof
|
|
3607
|
-
const r = t._path.child(X.fromString(
|
|
3608
|
-
return rt(r), new
|
|
3611
|
+
if (!(t instanceof an || t instanceof ln)) throw new U(A, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3612
|
+
const r = t._path.child(X.fromString(e, ...n));
|
|
3613
|
+
return rt(r), new an(t.firestore, t instanceof ln ? t.converter : null, new et(r));
|
|
3609
3614
|
}
|
|
3610
3615
|
}
|
|
3611
3616
|
|
|
@@ -3616,8 +3621,8 @@ function me(t, n, ...e) {
|
|
|
3616
3621
|
* @param right - A reference to compare.
|
|
3617
3622
|
* @returns true if the references point to the same location in the same
|
|
3618
3623
|
* Firestore database.
|
|
3619
|
-
*/ function
|
|
3620
|
-
return t = getModularInstance(t),
|
|
3624
|
+
*/ function mn(t, e) {
|
|
3625
|
+
return t = getModularInstance(t), e = getModularInstance(e), (t instanceof an || t instanceof ln) && (e instanceof an || e instanceof ln) && (t.firestore === e.firestore && t.path === e.path && t.converter === e.converter);
|
|
3621
3626
|
}
|
|
3622
3627
|
|
|
3623
3628
|
/**
|
|
@@ -3628,8 +3633,8 @@ function me(t, n, ...e) {
|
|
|
3628
3633
|
* @param right - A `Query` to compare.
|
|
3629
3634
|
* @returns true if the references point to the same location in the same
|
|
3630
3635
|
* Firestore database.
|
|
3631
|
-
*/ function
|
|
3632
|
-
return t = getModularInstance(t),
|
|
3636
|
+
*/ function pn(t, e) {
|
|
3637
|
+
return t = getModularInstance(t), e = getModularInstance(e), t instanceof hn && e instanceof hn && (t.firestore === e.firestore && de(t._query, e._query) && t.converter === e.converter);
|
|
3633
3638
|
}
|
|
3634
3639
|
|
|
3635
3640
|
/**
|
|
@@ -3655,7 +3660,7 @@ function me(t, n, ...e) {
|
|
|
3655
3660
|
*
|
|
3656
3661
|
* Create a `FieldPath` by providing field names. If more than one field
|
|
3657
3662
|
* name is provided, the path will point to a nested field in a document.
|
|
3658
|
-
*/ class
|
|
3663
|
+
*/ class yn {
|
|
3659
3664
|
/**
|
|
3660
3665
|
* Creates a `FieldPath` from the provided field names. If more than one field
|
|
3661
3666
|
* name is provided, the path will point to a nested field in a document.
|
|
@@ -3663,7 +3668,7 @@ function me(t, n, ...e) {
|
|
|
3663
3668
|
* @param fieldNames - A list of field names.
|
|
3664
3669
|
*/
|
|
3665
3670
|
constructor(...t) {
|
|
3666
|
-
for (let
|
|
3671
|
+
for (let e = 0; e < t.length; ++e) if (0 === t[e].length) throw new U(A, "Invalid field name at argument $(i + 1). Field names must not be empty.");
|
|
3667
3672
|
this._internalPath = new tt(t);
|
|
3668
3673
|
}
|
|
3669
3674
|
/**
|
|
@@ -3679,8 +3684,8 @@ function me(t, n, ...e) {
|
|
|
3679
3684
|
/**
|
|
3680
3685
|
* Returns a special sentinel `FieldPath` to refer to the ID of a document.
|
|
3681
3686
|
* It can be used in queries to sort or filter by the document ID.
|
|
3682
|
-
*/ function
|
|
3683
|
-
return new
|
|
3687
|
+
*/ function _n() {
|
|
3688
|
+
return new yn("__name__");
|
|
3684
3689
|
}
|
|
3685
3690
|
|
|
3686
3691
|
/**
|
|
@@ -3701,7 +3706,7 @@ function me(t, n, ...e) {
|
|
|
3701
3706
|
*/
|
|
3702
3707
|
/**
|
|
3703
3708
|
* An immutable object representing an array of bytes.
|
|
3704
|
-
*/ class
|
|
3709
|
+
*/ class gn {
|
|
3705
3710
|
/** @hideconstructor */
|
|
3706
3711
|
constructor(t) {
|
|
3707
3712
|
this._byteString = t;
|
|
@@ -3713,7 +3718,7 @@ function me(t, n, ...e) {
|
|
|
3713
3718
|
* @param base64 - The Base64 string used to create the `Bytes` object.
|
|
3714
3719
|
*/ static fromBase64String(t) {
|
|
3715
3720
|
try {
|
|
3716
|
-
return new
|
|
3721
|
+
return new gn(It.fromBase64String(t));
|
|
3717
3722
|
} catch (t) {
|
|
3718
3723
|
throw new U(A, "Failed to construct data from Base64 string: " + t);
|
|
3719
3724
|
}
|
|
@@ -3723,7 +3728,7 @@ function me(t, n, ...e) {
|
|
|
3723
3728
|
*
|
|
3724
3729
|
* @param array - The Uint8Array used to create the `Bytes` object.
|
|
3725
3730
|
*/ static fromUint8Array(t) {
|
|
3726
|
-
return new
|
|
3731
|
+
return new gn(It.fromUint8Array(t));
|
|
3727
3732
|
}
|
|
3728
3733
|
/**
|
|
3729
3734
|
* Returns the underlying bytes as a Base64-encoded string.
|
|
@@ -3775,7 +3780,7 @@ function me(t, n, ...e) {
|
|
|
3775
3780
|
/**
|
|
3776
3781
|
* Sentinel values that can be used when writing document fields with `set()`
|
|
3777
3782
|
* or `update()`.
|
|
3778
|
-
*/ class
|
|
3783
|
+
*/ class vn {
|
|
3779
3784
|
/**
|
|
3780
3785
|
* @param _methodName - The public API endpoint that returns this class.
|
|
3781
3786
|
* @hideconstructor
|
|
@@ -3807,17 +3812,17 @@ function me(t, n, ...e) {
|
|
|
3807
3812
|
*
|
|
3808
3813
|
* Latitude values are in the range of [-90, 90].
|
|
3809
3814
|
* Longitude values are in the range of [-180, 180].
|
|
3810
|
-
*/ class
|
|
3815
|
+
*/ class bn {
|
|
3811
3816
|
/**
|
|
3812
3817
|
* Creates a new immutable `GeoPoint` object with the provided latitude and
|
|
3813
3818
|
* longitude values.
|
|
3814
3819
|
* @param latitude - The latitude as number between -90 and 90.
|
|
3815
3820
|
* @param longitude - The longitude as number between -180 and 180.
|
|
3816
3821
|
*/
|
|
3817
|
-
constructor(t,
|
|
3822
|
+
constructor(t, e) {
|
|
3818
3823
|
if (!isFinite(t) || t < -90 || t > 90) throw new U(A, "Latitude must be a number between -90 and 90, but was: " + t);
|
|
3819
|
-
if (!isFinite(
|
|
3820
|
-
this._lat = t, this._long =
|
|
3824
|
+
if (!isFinite(e) || e < -180 || e > 180) throw new U(A, "Longitude must be a number between -180 and 180, but was: " + e);
|
|
3825
|
+
this._lat = t, this._long = e;
|
|
3821
3826
|
}
|
|
3822
3827
|
/**
|
|
3823
3828
|
* The latitude of this `GeoPoint` instance.
|
|
@@ -3866,29 +3871,29 @@ function me(t, n, ...e) {
|
|
|
3866
3871
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3867
3872
|
* See the License for the specific language governing permissions and
|
|
3868
3873
|
* limitations under the License.
|
|
3869
|
-
*/ const
|
|
3874
|
+
*/ const En = /^__.*__$/;
|
|
3870
3875
|
|
|
3871
|
-
/** The result of parsing document data (e.g. for a setData call). */ class
|
|
3872
|
-
constructor(t,
|
|
3873
|
-
this.data = t, this.fieldMask =
|
|
3876
|
+
/** The result of parsing document data (e.g. for a setData call). */ class Tn {
|
|
3877
|
+
constructor(t, e, n) {
|
|
3878
|
+
this.data = t, this.fieldMask = e, this.fieldTransforms = n;
|
|
3874
3879
|
}
|
|
3875
|
-
toMutation(t,
|
|
3876
|
-
return null !== this.fieldMask ? new
|
|
3880
|
+
toMutation(t, e) {
|
|
3881
|
+
return null !== this.fieldMask ? new Ie(t, this.data, this.fieldMask, e, this.fieldTransforms) : new Te(t, this.data, e, this.fieldTransforms);
|
|
3877
3882
|
}
|
|
3878
3883
|
}
|
|
3879
3884
|
|
|
3880
|
-
/** The result of parsing "update" data (i.e. for an updateData call). */ class
|
|
3885
|
+
/** The result of parsing "update" data (i.e. for an updateData call). */ class In {
|
|
3881
3886
|
constructor(t,
|
|
3882
3887
|
// The fieldMask does not include document transforms.
|
|
3883
|
-
|
|
3884
|
-
this.data = t, this.fieldMask =
|
|
3888
|
+
e, n) {
|
|
3889
|
+
this.data = t, this.fieldMask = e, this.fieldTransforms = n;
|
|
3885
3890
|
}
|
|
3886
|
-
toMutation(t,
|
|
3887
|
-
return new
|
|
3891
|
+
toMutation(t, e) {
|
|
3892
|
+
return new Ie(t, this.data, this.fieldMask, e, this.fieldTransforms);
|
|
3888
3893
|
}
|
|
3889
3894
|
}
|
|
3890
3895
|
|
|
3891
|
-
function
|
|
3896
|
+
function An(t) {
|
|
3892
3897
|
switch (t) {
|
|
3893
3898
|
case 0 /* Set */ :
|
|
3894
3899
|
// fall through
|
|
@@ -3906,7 +3911,7 @@ function Re(t) {
|
|
|
3906
3911
|
}
|
|
3907
3912
|
}
|
|
3908
3913
|
|
|
3909
|
-
/** A "context" object passed around while parsing user data. */ class
|
|
3914
|
+
/** A "context" object passed around while parsing user data. */ class Rn {
|
|
3910
3915
|
/**
|
|
3911
3916
|
* Initializes a ParseContext with the given source and path.
|
|
3912
3917
|
*
|
|
@@ -3925,8 +3930,8 @@ function Re(t) {
|
|
|
3925
3930
|
* which case certain features will not work and errors will be somewhat
|
|
3926
3931
|
* compromised).
|
|
3927
3932
|
*/
|
|
3928
|
-
constructor(t,
|
|
3929
|
-
this.settings = t, this.databaseId =
|
|
3933
|
+
constructor(t, e, n, r, s, i) {
|
|
3934
|
+
this.settings = t, this.databaseId = e, this.q = n, this.ignoreUndefinedProperties = r,
|
|
3930
3935
|
// Minor hack: If fieldTransforms is undefined, we assume this is an
|
|
3931
3936
|
// external call and we need to validate the entire path.
|
|
3932
3937
|
void 0 === s && this.Z(), this.fieldTransforms = s || [], this.fieldMask = i || [];
|
|
@@ -3937,21 +3942,21 @@ function Re(t) {
|
|
|
3937
3942
|
get tt() {
|
|
3938
3943
|
return this.settings.tt;
|
|
3939
3944
|
}
|
|
3940
|
-
/** Returns a new context with the specified settings overwritten. */
|
|
3941
|
-
return new
|
|
3945
|
+
/** Returns a new context with the specified settings overwritten. */ et(t) {
|
|
3946
|
+
return new Rn(Object.assign(Object.assign({}, this.settings), t), this.databaseId, this.q, this.ignoreUndefinedProperties, this.fieldTransforms, this.fieldMask);
|
|
3942
3947
|
}
|
|
3943
|
-
|
|
3944
|
-
var
|
|
3945
|
-
const
|
|
3946
|
-
path:
|
|
3948
|
+
nt(t) {
|
|
3949
|
+
var e;
|
|
3950
|
+
const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), r = this.et({
|
|
3951
|
+
path: n,
|
|
3947
3952
|
rt: !1
|
|
3948
3953
|
});
|
|
3949
3954
|
return r.st(t), r;
|
|
3950
3955
|
}
|
|
3951
3956
|
it(t) {
|
|
3952
|
-
var
|
|
3953
|
-
const
|
|
3954
|
-
path:
|
|
3957
|
+
var e;
|
|
3958
|
+
const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), r = this.et({
|
|
3959
|
+
path: n,
|
|
3955
3960
|
rt: !1
|
|
3956
3961
|
});
|
|
3957
3962
|
return r.Z(), r;
|
|
@@ -3959,16 +3964,16 @@ function Re(t) {
|
|
|
3959
3964
|
ot(t) {
|
|
3960
3965
|
// TODO(b/34871131): We don't support array paths right now; so make path
|
|
3961
3966
|
// undefined.
|
|
3962
|
-
return this.
|
|
3967
|
+
return this.et({
|
|
3963
3968
|
path: void 0,
|
|
3964
3969
|
rt: !0
|
|
3965
3970
|
});
|
|
3966
3971
|
}
|
|
3967
3972
|
ut(t) {
|
|
3968
|
-
return
|
|
3973
|
+
return Qn(t, this.settings.methodName, this.settings.ct || !1, this.path, this.settings.at);
|
|
3969
3974
|
}
|
|
3970
3975
|
/** Returns 'true' if 'fieldPath' was traversed when creating this context. */ contains(t) {
|
|
3971
|
-
return void 0 !== this.fieldMask.find((
|
|
3976
|
+
return void 0 !== this.fieldMask.find((e => t.isPrefixOf(e))) || void 0 !== this.fieldTransforms.find((e => t.isPrefixOf(e.field)));
|
|
3972
3977
|
}
|
|
3973
3978
|
Z() {
|
|
3974
3979
|
// TODO(b/34871131): Remove null check once we have proper paths for fields
|
|
@@ -3977,22 +3982,22 @@ function Re(t) {
|
|
|
3977
3982
|
}
|
|
3978
3983
|
st(t) {
|
|
3979
3984
|
if (0 === t.length) throw this.ut("Document fields must not be empty");
|
|
3980
|
-
if (
|
|
3985
|
+
if (An(this.tt) && En.test(t)) throw this.ut('Document fields cannot begin and end with "__"');
|
|
3981
3986
|
}
|
|
3982
3987
|
}
|
|
3983
3988
|
|
|
3984
3989
|
/**
|
|
3985
3990
|
* Helper for parsing raw user input (provided via the API) into internal model
|
|
3986
3991
|
* classes.
|
|
3987
|
-
*/ class
|
|
3988
|
-
constructor(t,
|
|
3989
|
-
this.databaseId = t, this.ignoreUndefinedProperties =
|
|
3992
|
+
*/ class Pn {
|
|
3993
|
+
constructor(t, e, n) {
|
|
3994
|
+
this.databaseId = t, this.ignoreUndefinedProperties = e, this.q = n || Ye(t);
|
|
3990
3995
|
}
|
|
3991
|
-
/** Creates a new top-level parse context. */ ht(t,
|
|
3992
|
-
return new
|
|
3996
|
+
/** Creates a new top-level parse context. */ ht(t, e, n, r = !1) {
|
|
3997
|
+
return new Rn({
|
|
3993
3998
|
tt: t,
|
|
3994
|
-
methodName:
|
|
3995
|
-
at:
|
|
3999
|
+
methodName: e,
|
|
4000
|
+
at: n,
|
|
3996
4001
|
path: tt.emptyPath(),
|
|
3997
4002
|
rt: !1,
|
|
3998
4003
|
ct: r
|
|
@@ -4000,29 +4005,29 @@ function Re(t) {
|
|
|
4000
4005
|
}
|
|
4001
4006
|
}
|
|
4002
4007
|
|
|
4003
|
-
function
|
|
4004
|
-
const
|
|
4005
|
-
return new
|
|
4008
|
+
function Vn(t) {
|
|
4009
|
+
const e = t._freezeSettings(), n = Ye(t._databaseId);
|
|
4010
|
+
return new Pn(t._databaseId, !!e.ignoreUndefinedProperties, n);
|
|
4006
4011
|
}
|
|
4007
4012
|
|
|
4008
|
-
/** Parse document data from a set() call. */ function
|
|
4009
|
-
const o = t.ht(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ ,
|
|
4010
|
-
|
|
4011
|
-
const u =
|
|
4013
|
+
/** Parse document data from a set() call. */ function Dn(t, e, n, r, s, i = {}) {
|
|
4014
|
+
const o = t.ht(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ , e, n, s);
|
|
4015
|
+
Mn("Data must be an object, but it was:", o, r);
|
|
4016
|
+
const u = kn(r, o);
|
|
4012
4017
|
let c, a;
|
|
4013
4018
|
if (i.merge) c = new Tt(o.fieldMask), a = o.fieldTransforms; else if (i.mergeFields) {
|
|
4014
4019
|
const t = [];
|
|
4015
4020
|
for (const r of i.mergeFields) {
|
|
4016
|
-
const s =
|
|
4021
|
+
const s = Bn(e, r, n);
|
|
4017
4022
|
if (!o.contains(s)) throw new U(A, `Field '${s}' is specified in your field mask but missing from your input data.`);
|
|
4018
|
-
|
|
4023
|
+
Wn(t, s) || t.push(s);
|
|
4019
4024
|
}
|
|
4020
4025
|
c = new Tt(t), a = o.fieldTransforms.filter((t => c.covers(t.field)));
|
|
4021
4026
|
} else c = null, a = o.fieldTransforms;
|
|
4022
|
-
return new
|
|
4027
|
+
return new Tn(new Bt(u), c, a);
|
|
4023
4028
|
}
|
|
4024
4029
|
|
|
4025
|
-
class
|
|
4030
|
+
class Nn extends vn {
|
|
4026
4031
|
_toFieldTransform(t) {
|
|
4027
4032
|
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}`);
|
|
4028
4033
|
// No transform to add for a delete, but we need to add it to our
|
|
@@ -4030,7 +4035,7 @@ class $e extends ve {
|
|
|
4030
4035
|
return t.fieldMask.push(t.path), null;
|
|
4031
4036
|
}
|
|
4032
4037
|
isEqual(t) {
|
|
4033
|
-
return t instanceof
|
|
4038
|
+
return t instanceof Nn;
|
|
4034
4039
|
}
|
|
4035
4040
|
}
|
|
4036
4041
|
|
|
@@ -4049,32 +4054,32 @@ class $e extends ve {
|
|
|
4049
4054
|
* context.
|
|
4050
4055
|
* @param context - The parent context.
|
|
4051
4056
|
* @param arrayElement - Whether or not the FieldValue has an array.
|
|
4052
|
-
*/ function
|
|
4053
|
-
return new
|
|
4057
|
+
*/ function $n(t, e, n) {
|
|
4058
|
+
return new Rn({
|
|
4054
4059
|
tt: 3 /* Argument */ ,
|
|
4055
|
-
at:
|
|
4060
|
+
at: e.settings.at,
|
|
4056
4061
|
methodName: t._methodName,
|
|
4057
|
-
rt:
|
|
4058
|
-
},
|
|
4062
|
+
rt: n
|
|
4063
|
+
}, e.databaseId, e.q, e.ignoreUndefinedProperties);
|
|
4059
4064
|
}
|
|
4060
4065
|
|
|
4061
|
-
class
|
|
4066
|
+
class Sn extends vn {
|
|
4062
4067
|
_toFieldTransform(t) {
|
|
4063
|
-
return new
|
|
4068
|
+
return new ve(t.path, new pe);
|
|
4064
4069
|
}
|
|
4065
4070
|
isEqual(t) {
|
|
4066
|
-
return t instanceof
|
|
4071
|
+
return t instanceof Sn;
|
|
4067
4072
|
}
|
|
4068
4073
|
}
|
|
4069
4074
|
|
|
4070
|
-
class
|
|
4071
|
-
constructor(t,
|
|
4072
|
-
super(t), this.lt =
|
|
4075
|
+
class Fn extends vn {
|
|
4076
|
+
constructor(t, e) {
|
|
4077
|
+
super(t), this.lt = e;
|
|
4073
4078
|
}
|
|
4074
4079
|
_toFieldTransform(t) {
|
|
4075
|
-
const
|
|
4076
|
-
/*array=*/ !0),
|
|
4077
|
-
return new
|
|
4080
|
+
const e = $n(this, t,
|
|
4081
|
+
/*array=*/ !0), n = this.lt.map((t => Un(t, e))), r = new ye(n);
|
|
4082
|
+
return new ve(t.path, r);
|
|
4078
4083
|
}
|
|
4079
4084
|
isEqual(t) {
|
|
4080
4085
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4082,14 +4087,14 @@ class xe extends ve {
|
|
|
4082
4087
|
}
|
|
4083
4088
|
}
|
|
4084
4089
|
|
|
4085
|
-
class
|
|
4086
|
-
constructor(t,
|
|
4087
|
-
super(t), this.lt =
|
|
4090
|
+
class xn extends vn {
|
|
4091
|
+
constructor(t, e) {
|
|
4092
|
+
super(t), this.lt = e;
|
|
4088
4093
|
}
|
|
4089
4094
|
_toFieldTransform(t) {
|
|
4090
|
-
const
|
|
4091
|
-
/*array=*/ !0),
|
|
4092
|
-
return new
|
|
4095
|
+
const e = $n(this, t,
|
|
4096
|
+
/*array=*/ !0), n = this.lt.map((t => Un(t, e))), r = new _e(n);
|
|
4097
|
+
return new ve(t.path, r);
|
|
4093
4098
|
}
|
|
4094
4099
|
isEqual(t) {
|
|
4095
4100
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4097,13 +4102,13 @@ class qe extends ve {
|
|
|
4097
4102
|
}
|
|
4098
4103
|
}
|
|
4099
4104
|
|
|
4100
|
-
class
|
|
4101
|
-
constructor(t,
|
|
4102
|
-
super(t), this.ft =
|
|
4105
|
+
class qn extends vn {
|
|
4106
|
+
constructor(t, e) {
|
|
4107
|
+
super(t), this.ft = e;
|
|
4103
4108
|
}
|
|
4104
4109
|
_toFieldTransform(t) {
|
|
4105
|
-
const
|
|
4106
|
-
return new
|
|
4110
|
+
const e = new ge(t.q, we(t.q, this.ft));
|
|
4111
|
+
return new ve(t.path, e);
|
|
4107
4112
|
}
|
|
4108
4113
|
isEqual(t) {
|
|
4109
4114
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4111,50 +4116,50 @@ class Oe extends ve {
|
|
|
4111
4116
|
}
|
|
4112
4117
|
}
|
|
4113
4118
|
|
|
4114
|
-
/** Parse update data from an update() call. */ function
|
|
4115
|
-
const s = t.ht(1 /* Update */ ,
|
|
4116
|
-
|
|
4119
|
+
/** Parse update data from an update() call. */ function On(t, e, n, r) {
|
|
4120
|
+
const s = t.ht(1 /* Update */ , e, n);
|
|
4121
|
+
Mn("Data must be an object, but it was:", s, r);
|
|
4117
4122
|
const i = [], o = Bt.empty();
|
|
4118
4123
|
Et(r, ((t, r) => {
|
|
4119
|
-
const u =
|
|
4124
|
+
const u = Gn(e, t, n);
|
|
4120
4125
|
// For Compat types, we have to "extract" the underlying types before
|
|
4121
4126
|
// performing validation.
|
|
4122
4127
|
r = getModularInstance(r);
|
|
4123
4128
|
const c = s.it(u);
|
|
4124
|
-
if (r instanceof
|
|
4129
|
+
if (r instanceof Nn)
|
|
4125
4130
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4126
4131
|
i.push(u); else {
|
|
4127
|
-
const t =
|
|
4132
|
+
const t = Un(r, c);
|
|
4128
4133
|
null != t && (i.push(u), o.set(u, t));
|
|
4129
4134
|
}
|
|
4130
4135
|
}));
|
|
4131
4136
|
const u = new Tt(i);
|
|
4132
|
-
return new
|
|
4137
|
+
return new In(o, u, s.fieldTransforms);
|
|
4133
4138
|
}
|
|
4134
4139
|
|
|
4135
|
-
/** Parse update data from a list of field/value arguments. */ function
|
|
4136
|
-
const o = t.ht(1 /* Update */ ,
|
|
4137
|
-
if (i.length % 2 != 0) throw new U(A, `Function ${
|
|
4138
|
-
for (let t = 0; t < i.length; t += 2) u.push(
|
|
4140
|
+
/** Parse update data from a list of field/value arguments. */ function Cn(t, e, n, r, s, i) {
|
|
4141
|
+
const o = t.ht(1 /* Update */ , e, n), u = [ Bn(e, r, n) ], c = [ s ];
|
|
4142
|
+
if (i.length % 2 != 0) throw new U(A, `Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);
|
|
4143
|
+
for (let t = 0; t < i.length; t += 2) u.push(Bn(e, i[t])), c.push(i[t + 1]);
|
|
4139
4144
|
const a = [], l = Bt.empty();
|
|
4140
4145
|
// We iterate in reverse order to pick the last value for a field if the
|
|
4141
4146
|
// user specified the field multiple times.
|
|
4142
|
-
for (let t = u.length - 1; t >= 0; --t) if (!
|
|
4143
|
-
const
|
|
4144
|
-
let
|
|
4147
|
+
for (let t = u.length - 1; t >= 0; --t) if (!Wn(a, u[t])) {
|
|
4148
|
+
const e = u[t];
|
|
4149
|
+
let n = c[t];
|
|
4145
4150
|
// For Compat types, we have to "extract" the underlying types before
|
|
4146
4151
|
// performing validation.
|
|
4147
|
-
|
|
4148
|
-
const r = o.it(
|
|
4149
|
-
if (
|
|
4152
|
+
n = getModularInstance(n);
|
|
4153
|
+
const r = o.it(e);
|
|
4154
|
+
if (n instanceof Nn)
|
|
4150
4155
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4151
|
-
a.push(
|
|
4152
|
-
const t =
|
|
4153
|
-
null != t && (a.push(
|
|
4156
|
+
a.push(e); else {
|
|
4157
|
+
const t = Un(n, r);
|
|
4158
|
+
null != t && (a.push(e), l.set(e, t));
|
|
4154
4159
|
}
|
|
4155
4160
|
}
|
|
4156
4161
|
const f = new Tt(a);
|
|
4157
|
-
return new
|
|
4162
|
+
return new In(l, f, o.fieldTransforms);
|
|
4158
4163
|
}
|
|
4159
4164
|
|
|
4160
4165
|
/**
|
|
@@ -4163,8 +4168,8 @@ class Oe extends ve {
|
|
|
4163
4168
|
*
|
|
4164
4169
|
* @param allowArrays - Whether the query value is an array that may directly
|
|
4165
4170
|
* contain additional arrays (e.g. the operand of an `in` query).
|
|
4166
|
-
*/ function
|
|
4167
|
-
return
|
|
4171
|
+
*/ function Ln(t, e, n, r = !1) {
|
|
4172
|
+
return Un(n, t.ht(r ? 4 /* ArrayArgument */ : 3 /* Argument */ , e));
|
|
4168
4173
|
}
|
|
4169
4174
|
|
|
4170
4175
|
/**
|
|
@@ -4175,12 +4180,12 @@ class Oe extends ve {
|
|
|
4175
4180
|
* the source of the data being parsed, etc.
|
|
4176
4181
|
* @returns The parsed value, or null if the value was a FieldValue sentinel
|
|
4177
4182
|
* that should not be included in the resulting parsed data.
|
|
4178
|
-
*/ function
|
|
4179
|
-
if (
|
|
4183
|
+
*/ function Un(t, e) {
|
|
4184
|
+
if (jn(
|
|
4180
4185
|
// Unwrap the API type from the Compat SDK. This will return the API type
|
|
4181
4186
|
// from firestore-exp.
|
|
4182
|
-
t = getModularInstance(t))) return
|
|
4183
|
-
if (t instanceof
|
|
4187
|
+
t = getModularInstance(t))) return Mn("Unsupported field value:", e, t), kn(t, e);
|
|
4188
|
+
if (t instanceof vn)
|
|
4184
4189
|
// FieldValues usually parse into transforms (except deleteField())
|
|
4185
4190
|
// in which case we do not want to include this field in our parsed data
|
|
4186
4191
|
// (as doing so will overwrite the field directly prior to the transform
|
|
@@ -4190,19 +4195,19 @@ class Oe extends ve {
|
|
|
4190
4195
|
* "Parses" the provided FieldValueImpl, adding any necessary transforms to
|
|
4191
4196
|
* context.fieldTransforms.
|
|
4192
4197
|
*/
|
|
4193
|
-
return function(t,
|
|
4198
|
+
return function(t, e) {
|
|
4194
4199
|
// Sentinels are only supported with writes, and not within arrays.
|
|
4195
|
-
if (!
|
|
4196
|
-
if (!
|
|
4197
|
-
const
|
|
4198
|
-
|
|
4200
|
+
if (!An(e.tt)) throw e.ut(`${t._methodName}() can only be used with update() and set()`);
|
|
4201
|
+
if (!e.path) throw e.ut(`${t._methodName}() is not currently supported inside arrays`);
|
|
4202
|
+
const n = t._toFieldTransform(e);
|
|
4203
|
+
n && e.fieldTransforms.push(n);
|
|
4199
4204
|
}
|
|
4200
4205
|
/**
|
|
4201
4206
|
* Helper to parse a scalar value (i.e. not an Object, Array, or FieldValue)
|
|
4202
4207
|
*
|
|
4203
4208
|
* @returns The parsed value
|
|
4204
|
-
*/ (t,
|
|
4205
|
-
if (void 0 === t &&
|
|
4209
|
+
*/ (t, e), null;
|
|
4210
|
+
if (void 0 === t && e.ignoreUndefinedProperties)
|
|
4206
4211
|
// If the input is undefined it can never participate in the fieldMask, so
|
|
4207
4212
|
// don't handle this below. If `ignoreUndefinedProperties` is false,
|
|
4208
4213
|
// `parseScalarValue` will reject an undefined value.
|
|
@@ -4210,38 +4215,38 @@ class Oe extends ve {
|
|
|
4210
4215
|
if (
|
|
4211
4216
|
// If context.path is null we are inside an array and we don't support
|
|
4212
4217
|
// field mask paths more granular than the top-level array.
|
|
4213
|
-
|
|
4218
|
+
e.path && e.fieldMask.push(e.path), t instanceof Array) {
|
|
4214
4219
|
// TODO(b/34871131): Include the path containing the array in the error
|
|
4215
4220
|
// message.
|
|
4216
4221
|
// In the case of IN queries, the parsed data is an array (representing
|
|
4217
4222
|
// the set of values to be included for the IN query) that may directly
|
|
4218
4223
|
// contain additional arrays (each representing an individual field
|
|
4219
4224
|
// value), so we disable this validation.
|
|
4220
|
-
if (
|
|
4221
|
-
return function(t,
|
|
4222
|
-
const
|
|
4225
|
+
if (e.settings.rt && 4 /* ArrayArgument */ !== e.tt) throw e.ut("Nested arrays are not supported");
|
|
4226
|
+
return function(t, e) {
|
|
4227
|
+
const n = [];
|
|
4223
4228
|
let r = 0;
|
|
4224
4229
|
for (const s of t) {
|
|
4225
|
-
let t =
|
|
4230
|
+
let t = Un(s, e.ot(r));
|
|
4226
4231
|
null == t && (
|
|
4227
4232
|
// Just include nulls in the array for fields being replaced with a
|
|
4228
4233
|
// sentinel.
|
|
4229
4234
|
t = {
|
|
4230
4235
|
nullValue: "NULL_VALUE"
|
|
4231
|
-
}),
|
|
4236
|
+
}), n.push(t), r++;
|
|
4232
4237
|
}
|
|
4233
4238
|
return {
|
|
4234
4239
|
arrayValue: {
|
|
4235
|
-
values:
|
|
4240
|
+
values: n
|
|
4236
4241
|
}
|
|
4237
4242
|
};
|
|
4238
|
-
}(t,
|
|
4243
|
+
}(t, e);
|
|
4239
4244
|
}
|
|
4240
|
-
return function(t,
|
|
4245
|
+
return function(t, e) {
|
|
4241
4246
|
if (null === (t = getModularInstance(t))) return {
|
|
4242
4247
|
nullValue: "NULL_VALUE"
|
|
4243
4248
|
};
|
|
4244
|
-
if ("number" == typeof t) return
|
|
4249
|
+
if ("number" == typeof t) return we(e.q, t);
|
|
4245
4250
|
if ("boolean" == typeof t) return {
|
|
4246
4251
|
booleanValue: t
|
|
4247
4252
|
};
|
|
@@ -4249,37 +4254,37 @@ class Oe extends ve {
|
|
|
4249
4254
|
stringValue: t
|
|
4250
4255
|
};
|
|
4251
4256
|
if (t instanceof Date) {
|
|
4252
|
-
const
|
|
4257
|
+
const n = gt.fromDate(t);
|
|
4253
4258
|
return {
|
|
4254
|
-
timestampValue:
|
|
4259
|
+
timestampValue: Ne(e.q, n)
|
|
4255
4260
|
};
|
|
4256
4261
|
}
|
|
4257
4262
|
if (t instanceof gt) {
|
|
4258
4263
|
// Firestore backend truncates precision down to microseconds. To ensure
|
|
4259
4264
|
// offline mode works the same with regards to truncation, perform the
|
|
4260
4265
|
// truncation immediately without waiting for the backend to do that.
|
|
4261
|
-
const
|
|
4266
|
+
const n = new gt(t.seconds, 1e3 * Math.floor(t.nanoseconds / 1e3));
|
|
4262
4267
|
return {
|
|
4263
|
-
timestampValue:
|
|
4268
|
+
timestampValue: Ne(e.q, n)
|
|
4264
4269
|
};
|
|
4265
4270
|
}
|
|
4266
|
-
if (t instanceof
|
|
4271
|
+
if (t instanceof bn) return {
|
|
4267
4272
|
geoPointValue: {
|
|
4268
4273
|
latitude: t.latitude,
|
|
4269
4274
|
longitude: t.longitude
|
|
4270
4275
|
}
|
|
4271
4276
|
};
|
|
4272
|
-
if (t instanceof
|
|
4273
|
-
bytesValue:
|
|
4277
|
+
if (t instanceof gn) return {
|
|
4278
|
+
bytesValue: $e(e.q, t._byteString)
|
|
4274
4279
|
};
|
|
4275
|
-
if (t instanceof
|
|
4276
|
-
const
|
|
4277
|
-
if (!r.isEqual(
|
|
4280
|
+
if (t instanceof an) {
|
|
4281
|
+
const n = e.databaseId, r = t.firestore._databaseId;
|
|
4282
|
+
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}`);
|
|
4278
4283
|
return {
|
|
4279
|
-
referenceValue:
|
|
4284
|
+
referenceValue: xe(t.firestore._databaseId || e.databaseId, t._key.path)
|
|
4280
4285
|
};
|
|
4281
4286
|
}
|
|
4282
|
-
throw
|
|
4287
|
+
throw e.ut(`Unsupported field value: ${it(t)}`);
|
|
4283
4288
|
}
|
|
4284
4289
|
/**
|
|
4285
4290
|
* Checks whether an object looks like a JSON object that should be converted
|
|
@@ -4287,56 +4292,56 @@ class Oe extends ve {
|
|
|
4287
4292
|
* JSON objects since they should be converted to a struct value. Arrays, Dates,
|
|
4288
4293
|
* GeoPoints, etc. are not considered to look like JSON objects since they map
|
|
4289
4294
|
* to specific FieldValue types other than ObjectValue.
|
|
4290
|
-
*/ (t,
|
|
4295
|
+
*/ (t, e);
|
|
4291
4296
|
}
|
|
4292
4297
|
|
|
4293
|
-
function
|
|
4294
|
-
const
|
|
4298
|
+
function kn(t, e) {
|
|
4299
|
+
const n = {};
|
|
4295
4300
|
return !function(t) {
|
|
4296
|
-
for (const
|
|
4301
|
+
for (const e in t) if (Object.prototype.hasOwnProperty.call(t, e)) return !1;
|
|
4297
4302
|
return !0;
|
|
4298
4303
|
}(t) ? Et(t, ((t, r) => {
|
|
4299
|
-
const s =
|
|
4300
|
-
null != s && (
|
|
4304
|
+
const s = Un(r, e.nt(t));
|
|
4305
|
+
null != s && (n[t] = s);
|
|
4301
4306
|
})) :
|
|
4302
4307
|
// If we encounter an empty object, we explicitly add it to the update
|
|
4303
4308
|
// mask to ensure that the server creates a map entry.
|
|
4304
|
-
|
|
4309
|
+
e.path && e.path.length > 0 && e.fieldMask.push(e.path), {
|
|
4305
4310
|
mapValue: {
|
|
4306
|
-
fields:
|
|
4311
|
+
fields: n
|
|
4307
4312
|
}
|
|
4308
4313
|
};
|
|
4309
4314
|
}
|
|
4310
4315
|
|
|
4311
|
-
function
|
|
4312
|
-
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof gt || t instanceof
|
|
4316
|
+
function jn(t) {
|
|
4317
|
+
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof gt || t instanceof bn || t instanceof gn || t instanceof an || t instanceof vn);
|
|
4313
4318
|
}
|
|
4314
4319
|
|
|
4315
|
-
function
|
|
4316
|
-
if (!
|
|
4320
|
+
function Mn(t, e, n) {
|
|
4321
|
+
if (!jn(n) || !function(t) {
|
|
4317
4322
|
return "object" == typeof t && null !== t && (Object.getPrototypeOf(t) === Object.prototype || null === Object.getPrototypeOf(t));
|
|
4318
|
-
}(
|
|
4319
|
-
const r = it(
|
|
4320
|
-
throw "an object" === r ?
|
|
4323
|
+
}(n)) {
|
|
4324
|
+
const r = it(n);
|
|
4325
|
+
throw "an object" === r ? e.ut(t + " a custom object") : e.ut(t + " " + r);
|
|
4321
4326
|
}
|
|
4322
4327
|
}
|
|
4323
4328
|
|
|
4324
4329
|
/**
|
|
4325
4330
|
* Helper that calls fromDotSeparatedString() but wraps any error thrown.
|
|
4326
|
-
*/ function
|
|
4331
|
+
*/ function Bn(t, e, n) {
|
|
4327
4332
|
if ((
|
|
4328
4333
|
// If required, replace the FieldPath Compat class with with the firestore-exp
|
|
4329
4334
|
// FieldPath.
|
|
4330
|
-
|
|
4331
|
-
if ("string" == typeof
|
|
4332
|
-
throw
|
|
4335
|
+
e = getModularInstance(e)) instanceof yn) return e._internalPath;
|
|
4336
|
+
if ("string" == typeof e) return Gn(t, e);
|
|
4337
|
+
throw Qn("Field path arguments must be of type string or ", t,
|
|
4333
4338
|
/* hasConverter= */ !1,
|
|
4334
|
-
/* path= */ void 0,
|
|
4339
|
+
/* path= */ void 0, n);
|
|
4335
4340
|
}
|
|
4336
4341
|
|
|
4337
4342
|
/**
|
|
4338
4343
|
* Matches any characters in a field path string that are reserved.
|
|
4339
|
-
*/ const
|
|
4344
|
+
*/ const zn = new RegExp("[~\\*/\\[\\]]");
|
|
4340
4345
|
|
|
4341
4346
|
/**
|
|
4342
4347
|
* Wraps fromDotSeparatedString with an error message about the method that
|
|
@@ -4346,30 +4351,30 @@ function Be(t, n, e) {
|
|
|
4346
4351
|
* split on dots.
|
|
4347
4352
|
* @param targetDoc - The document against which the field path will be
|
|
4348
4353
|
* evaluated.
|
|
4349
|
-
*/ function
|
|
4350
|
-
if (
|
|
4354
|
+
*/ function Gn(t, e, n) {
|
|
4355
|
+
if (e.search(zn) >= 0) throw Qn(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`, t,
|
|
4351
4356
|
/* hasConverter= */ !1,
|
|
4352
|
-
/* path= */ void 0,
|
|
4357
|
+
/* path= */ void 0, n);
|
|
4353
4358
|
try {
|
|
4354
|
-
return new
|
|
4359
|
+
return new yn(...e.split("."))._internalPath;
|
|
4355
4360
|
} catch (r) {
|
|
4356
|
-
throw
|
|
4361
|
+
throw Qn(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`, t,
|
|
4357
4362
|
/* hasConverter= */ !1,
|
|
4358
|
-
/* path= */ void 0,
|
|
4363
|
+
/* path= */ void 0, n);
|
|
4359
4364
|
}
|
|
4360
4365
|
}
|
|
4361
4366
|
|
|
4362
|
-
function
|
|
4367
|
+
function Qn(t, e, n, r, s) {
|
|
4363
4368
|
const i = r && !r.isEmpty(), o = void 0 !== s;
|
|
4364
|
-
let u = `Function ${
|
|
4365
|
-
|
|
4369
|
+
let u = `Function ${e}() called with invalid data`;
|
|
4370
|
+
n && (u += " (via `toFirestore()`)"), u += ". ";
|
|
4366
4371
|
let c = "";
|
|
4367
4372
|
return (i || o) && (c += " (found", i && (c += ` in field ${r}`), o && (c += ` in document ${s}`),
|
|
4368
4373
|
c += ")"), new U(A, u + t + c);
|
|
4369
4374
|
}
|
|
4370
4375
|
|
|
4371
|
-
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function
|
|
4372
|
-
return t.some((t => t.isEqual(
|
|
4376
|
+
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function Wn(t, e) {
|
|
4377
|
+
return t.some((t => t.isEqual(e)));
|
|
4373
4378
|
}
|
|
4374
4379
|
|
|
4375
4380
|
/**
|
|
@@ -4396,14 +4401,14 @@ function We(t, n, e, r, s) {
|
|
|
4396
4401
|
* For a `DocumentSnapshot` that points to a non-existing document, any data
|
|
4397
4402
|
* access will return 'undefined'. You can use the `exists()` method to
|
|
4398
4403
|
* explicitly verify a document's existence.
|
|
4399
|
-
*/ class
|
|
4404
|
+
*/ class Yn {
|
|
4400
4405
|
// Note: This class is stripped down version of the DocumentSnapshot in
|
|
4401
4406
|
// the legacy SDK. The changes are:
|
|
4402
4407
|
// - No support for SnapshotMetadata.
|
|
4403
4408
|
// - No support for SnapshotOptions.
|
|
4404
4409
|
/** @hideconstructor protected */
|
|
4405
|
-
constructor(t,
|
|
4406
|
-
this._firestore = t, this._userDataWriter =
|
|
4410
|
+
constructor(t, e, n, r, s) {
|
|
4411
|
+
this._firestore = t, this._userDataWriter = e, this._key = n, this._document = r,
|
|
4407
4412
|
this._converter = s;
|
|
4408
4413
|
}
|
|
4409
4414
|
/** Property of the `DocumentSnapshot` that provides the document's ID. */ get id() {
|
|
@@ -4412,7 +4417,7 @@ function We(t, n, e, r, s) {
|
|
|
4412
4417
|
/**
|
|
4413
4418
|
* The `DocumentReference` for the document included in the `DocumentSnapshot`.
|
|
4414
4419
|
*/ get ref() {
|
|
4415
|
-
return new
|
|
4420
|
+
return new an(this._firestore, this._converter, this._key);
|
|
4416
4421
|
}
|
|
4417
4422
|
/**
|
|
4418
4423
|
* Signals whether or not the document at the snapshot's location exists.
|
|
@@ -4432,7 +4437,7 @@ function We(t, n, e, r, s) {
|
|
|
4432
4437
|
if (this._converter) {
|
|
4433
4438
|
// We only want to use the converter and create a new DocumentSnapshot
|
|
4434
4439
|
// if a converter has been provided.
|
|
4435
|
-
const t = new
|
|
4440
|
+
const t = new Hn(this._firestore, this._userDataWriter, this._key, this._document,
|
|
4436
4441
|
/* converter= */ null);
|
|
4437
4442
|
return this._converter.fromFirestore(t);
|
|
4438
4443
|
}
|
|
@@ -4452,8 +4457,8 @@ function We(t, n, e, r, s) {
|
|
|
4452
4457
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4453
4458
|
get(t) {
|
|
4454
4459
|
if (this._document) {
|
|
4455
|
-
const
|
|
4456
|
-
if (null !==
|
|
4460
|
+
const e = this._document.data.field(Xn("DocumentSnapshot.get", t));
|
|
4461
|
+
if (null !== e) return this._userDataWriter.convertValue(e);
|
|
4457
4462
|
}
|
|
4458
4463
|
}
|
|
4459
4464
|
}
|
|
@@ -4468,7 +4473,7 @@ function We(t, n, e, r, s) {
|
|
|
4468
4473
|
* `DocumentSnapshot`. Since query results contain only existing documents, the
|
|
4469
4474
|
* `exists` property will always be true and `data()` will never return
|
|
4470
4475
|
* 'undefined'.
|
|
4471
|
-
*/ class
|
|
4476
|
+
*/ class Hn extends Yn {
|
|
4472
4477
|
/**
|
|
4473
4478
|
* Retrieves all fields in the document as an `Object`.
|
|
4474
4479
|
*
|
|
@@ -4486,10 +4491,10 @@ function We(t, n, e, r, s) {
|
|
|
4486
4491
|
* array via the `docs` property or enumerated using the `forEach` method. The
|
|
4487
4492
|
* number of documents can be determined via the `empty` and `size`
|
|
4488
4493
|
* properties.
|
|
4489
|
-
*/ class
|
|
4494
|
+
*/ class Kn {
|
|
4490
4495
|
/** @hideconstructor */
|
|
4491
|
-
constructor(t,
|
|
4492
|
-
this._docs =
|
|
4496
|
+
constructor(t, e) {
|
|
4497
|
+
this._docs = e, this.query = t;
|
|
4493
4498
|
}
|
|
4494
4499
|
/** An array of all the documents in the `QuerySnapshot`. */ get docs() {
|
|
4495
4500
|
return [ ...this._docs ];
|
|
@@ -4506,8 +4511,8 @@ function We(t, n, e, r, s) {
|
|
|
4506
4511
|
* @param callback - A callback to be called with a `QueryDocumentSnapshot` for
|
|
4507
4512
|
* each document in the snapshot.
|
|
4508
4513
|
* @param thisArg - The `this` binding for the callback.
|
|
4509
|
-
*/ forEach(t,
|
|
4510
|
-
this._docs.forEach(t,
|
|
4514
|
+
*/ forEach(t, e) {
|
|
4515
|
+
this._docs.forEach(t, e);
|
|
4511
4516
|
}
|
|
4512
4517
|
}
|
|
4513
4518
|
|
|
@@ -4517,14 +4522,14 @@ function We(t, n, e, r, s) {
|
|
|
4517
4522
|
* @param left - A snapshot to compare.
|
|
4518
4523
|
* @param right - A snapshot to compare.
|
|
4519
4524
|
* @returns true if the snapshots are equal.
|
|
4520
|
-
*/ function
|
|
4521
|
-
return t = getModularInstance(t),
|
|
4525
|
+
*/ function Jn(t, e) {
|
|
4526
|
+
return t = getModularInstance(t), e = getModularInstance(e), t instanceof Yn && e instanceof Yn ? 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 Kn && e instanceof Kn && (pn(t.query, e.query) && _t(t.docs, e.docs, Jn));
|
|
4522
4527
|
}
|
|
4523
4528
|
|
|
4524
4529
|
/**
|
|
4525
4530
|
* Helper that calls `fromDotSeparatedString()` but wraps any error thrown.
|
|
4526
|
-
*/ function
|
|
4527
|
-
return "string" == typeof
|
|
4531
|
+
*/ function Xn(t, e) {
|
|
4532
|
+
return "string" == typeof e ? Gn(t, e) : e instanceof yn ? e._internalPath : e._delegate._internalPath;
|
|
4528
4533
|
}
|
|
4529
4534
|
|
|
4530
4535
|
/**
|
|
@@ -4551,7 +4556,7 @@ function We(t, n, e, r, s) {
|
|
|
4551
4556
|
* can then be passed to {@link query} to create a new query instance that
|
|
4552
4557
|
* also contains this `QueryConstraint`.
|
|
4553
4558
|
*/
|
|
4554
|
-
class
|
|
4559
|
+
class Zn {}
|
|
4555
4560
|
|
|
4556
4561
|
/**
|
|
4557
4562
|
* Creates a new immutable instance of {@link Query} that is extended to also include
|
|
@@ -4561,43 +4566,43 @@ class tr {}
|
|
|
4561
4566
|
* @param queryConstraints - The list of {@link QueryConstraint}s to apply.
|
|
4562
4567
|
* @throws if any of the provided query constraints cannot be combined with the
|
|
4563
4568
|
* existing or new constraints.
|
|
4564
|
-
*/ function
|
|
4565
|
-
for (const
|
|
4569
|
+
*/ function tr(t, ...e) {
|
|
4570
|
+
for (const n of e) t = n._apply(t);
|
|
4566
4571
|
return t;
|
|
4567
4572
|
}
|
|
4568
4573
|
|
|
4569
|
-
class er extends
|
|
4570
|
-
constructor(t,
|
|
4571
|
-
super(), this.dt = t, this.wt =
|
|
4574
|
+
class er extends Zn {
|
|
4575
|
+
constructor(t, e, n) {
|
|
4576
|
+
super(), this.dt = t, this.wt = e, this.yt = n, this.type = "where";
|
|
4572
4577
|
}
|
|
4573
4578
|
_apply(t) {
|
|
4574
|
-
const
|
|
4579
|
+
const e = Vn(t.firestore), n = function(t, e, n, r, s, i, o) {
|
|
4575
4580
|
let u;
|
|
4576
4581
|
if (s.isKeyField()) {
|
|
4577
4582
|
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new U(A, `Invalid Query. You can't perform '${i}' queries on documentId().`);
|
|
4578
4583
|
if ("in" /* IN */ === i || "not-in" /* NOT_IN */ === i) {
|
|
4579
|
-
|
|
4580
|
-
const
|
|
4581
|
-
for (const
|
|
4584
|
+
pr(o, i);
|
|
4585
|
+
const e = [];
|
|
4586
|
+
for (const n of o) e.push(mr(r, t, n));
|
|
4582
4587
|
u = {
|
|
4583
4588
|
arrayValue: {
|
|
4584
|
-
values:
|
|
4589
|
+
values: e
|
|
4585
4590
|
}
|
|
4586
4591
|
};
|
|
4587
|
-
} else u =
|
|
4588
|
-
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i ||
|
|
4589
|
-
u =
|
|
4592
|
+
} else u = mr(r, t, o);
|
|
4593
|
+
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i || pr(o, i),
|
|
4594
|
+
u = Ln(n, e, o,
|
|
4590
4595
|
/* allowArrays= */ "in" /* IN */ === i || "not-in" /* NOT_IN */ === i);
|
|
4591
4596
|
const c = Wt.create(s, i, u);
|
|
4592
|
-
return function(t,
|
|
4593
|
-
if (
|
|
4594
|
-
const
|
|
4595
|
-
if (null !==
|
|
4596
|
-
const r =
|
|
4597
|
-
null !== r &&
|
|
4597
|
+
return function(t, e) {
|
|
4598
|
+
if (e.N()) {
|
|
4599
|
+
const n = ae(t);
|
|
4600
|
+
if (null !== n && !n.isEqual(e.field)) throw new U(A, `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()}'`);
|
|
4601
|
+
const r = ce(t);
|
|
4602
|
+
null !== r && yr(t, e.field, r);
|
|
4598
4603
|
}
|
|
4599
|
-
const
|
|
4600
|
-
for (const
|
|
4604
|
+
const n = function(t, e) {
|
|
4605
|
+
for (const n of t.filters) if (e.indexOf(n.op) >= 0) return n.op;
|
|
4601
4606
|
return null;
|
|
4602
4607
|
}(t,
|
|
4603
4608
|
/**
|
|
@@ -4632,16 +4637,16 @@ class er extends tr {
|
|
|
4632
4637
|
default:
|
|
4633
4638
|
return [];
|
|
4634
4639
|
}
|
|
4635
|
-
}(
|
|
4636
|
-
if (null !==
|
|
4640
|
+
}(e.op));
|
|
4641
|
+
if (null !== n)
|
|
4637
4642
|
// Special case when it's a duplicate op to give a slightly clearer error message.
|
|
4638
|
-
throw
|
|
4643
|
+
throw n === e.op ? new U(A, `Invalid query. You cannot use more than one '${e.op.toString()}' filter.`) : new U(A, `Invalid query. You cannot use '${e.op.toString()}' filters with '${n.toString()}' filters.`);
|
|
4639
4644
|
}(t, c), c;
|
|
4640
|
-
}(t._query, "where",
|
|
4641
|
-
return new
|
|
4642
|
-
const
|
|
4643
|
-
return new
|
|
4644
|
-
}(t._query,
|
|
4645
|
+
}(t._query, "where", e, t.firestore._databaseId, this.dt, this.wt, this.yt);
|
|
4646
|
+
return new hn(t.firestore, t.converter, function(t, e) {
|
|
4647
|
+
const n = t.filters.concat([ e ]);
|
|
4648
|
+
return new oe(t.path, t.collectionGroup, t.explicitOrderBy.slice(), n, t.limit, t.limitType, t.startAt, t.endAt);
|
|
4649
|
+
}(t._query, n));
|
|
4645
4650
|
}
|
|
4646
4651
|
}
|
|
4647
4652
|
|
|
@@ -4655,25 +4660,25 @@ class er extends tr {
|
|
|
4655
4660
|
* "<=", "!=").
|
|
4656
4661
|
* @param value - The value for comparison
|
|
4657
4662
|
* @returns The created {@link Query}.
|
|
4658
|
-
*/ function
|
|
4659
|
-
const r =
|
|
4660
|
-
return new er(s, r,
|
|
4663
|
+
*/ function nr(t, e, n) {
|
|
4664
|
+
const r = e, s = Xn("where", t);
|
|
4665
|
+
return new er(s, r, n);
|
|
4661
4666
|
}
|
|
4662
4667
|
|
|
4663
|
-
class
|
|
4664
|
-
constructor(t,
|
|
4665
|
-
super(), this.dt = t, this._t =
|
|
4668
|
+
class rr extends Zn {
|
|
4669
|
+
constructor(t, e) {
|
|
4670
|
+
super(), this.dt = t, this._t = e, this.type = "orderBy";
|
|
4666
4671
|
}
|
|
4667
4672
|
_apply(t) {
|
|
4668
|
-
const
|
|
4673
|
+
const e = function(t, e, n) {
|
|
4669
4674
|
if (null !== t.startAt) throw new U(A, "Invalid query. You must not call startAt() or startAfter() before calling orderBy().");
|
|
4670
4675
|
if (null !== t.endAt) throw new U(A, "Invalid query. You must not call endAt() or endBefore() before calling orderBy().");
|
|
4671
|
-
const r = new
|
|
4672
|
-
return function(t,
|
|
4673
|
-
if (null ===
|
|
4676
|
+
const r = new re(e, n);
|
|
4677
|
+
return function(t, e) {
|
|
4678
|
+
if (null === ce(t)) {
|
|
4674
4679
|
// This is the first order by. It must match any inequality.
|
|
4675
|
-
const
|
|
4676
|
-
null !==
|
|
4680
|
+
const n = ae(t);
|
|
4681
|
+
null !== n && yr(t, n, e.field);
|
|
4677
4682
|
}
|
|
4678
4683
|
}(t, r), r;
|
|
4679
4684
|
}
|
|
@@ -4688,11 +4693,11 @@ class sr extends tr {
|
|
|
4688
4693
|
* of the query or if any of the fields in the order by are an uncommitted
|
|
4689
4694
|
* server timestamp.
|
|
4690
4695
|
*/ (t._query, this.dt, this._t);
|
|
4691
|
-
return new
|
|
4696
|
+
return new hn(t.firestore, t.converter, function(t, e) {
|
|
4692
4697
|
// TODO(dimond): validate that orderBy does not list the same key twice.
|
|
4693
|
-
const
|
|
4694
|
-
return new
|
|
4695
|
-
}(t._query,
|
|
4698
|
+
const n = t.explicitOrderBy.concat([ e ]);
|
|
4699
|
+
return new oe(t.path, t.collectionGroup, n, t.filters.slice(), t.limit, t.limitType, t.startAt, t.endAt);
|
|
4700
|
+
}(t._query, e));
|
|
4696
4701
|
}
|
|
4697
4702
|
}
|
|
4698
4703
|
|
|
@@ -4704,19 +4709,19 @@ class sr extends tr {
|
|
|
4704
4709
|
* @param directionStr - Optional direction to sort by ('asc' or 'desc'). If
|
|
4705
4710
|
* not specified, order will be ascending.
|
|
4706
4711
|
* @returns The created {@link Query}.
|
|
4707
|
-
*/ function
|
|
4708
|
-
const
|
|
4709
|
-
return new
|
|
4712
|
+
*/ function sr(t, e = "asc") {
|
|
4713
|
+
const n = e, r = Xn("orderBy", t);
|
|
4714
|
+
return new rr(r, n);
|
|
4710
4715
|
}
|
|
4711
4716
|
|
|
4712
|
-
class
|
|
4713
|
-
constructor(t,
|
|
4714
|
-
super(), this.type = t, this.gt =
|
|
4717
|
+
class ir extends Zn {
|
|
4718
|
+
constructor(t, e, n) {
|
|
4719
|
+
super(), this.type = t, this.gt = e, this.vt = n;
|
|
4715
4720
|
}
|
|
4716
4721
|
_apply(t) {
|
|
4717
|
-
return new
|
|
4718
|
-
return new
|
|
4719
|
-
}(t._query, this.gt, this.
|
|
4722
|
+
return new hn(t.firestore, t.converter, function(t, e, n) {
|
|
4723
|
+
return new oe(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), e, n, t.startAt, t.endAt);
|
|
4724
|
+
}(t._query, this.gt, this.vt));
|
|
4720
4725
|
}
|
|
4721
4726
|
}
|
|
4722
4727
|
|
|
@@ -4725,8 +4730,8 @@ class or extends tr {
|
|
|
4725
4730
|
*
|
|
4726
4731
|
* @param limit - The maximum number of items to return.
|
|
4727
4732
|
* @returns The created {@link Query}.
|
|
4728
|
-
*/ function
|
|
4729
|
-
return ut("limit", t), new
|
|
4733
|
+
*/ function or(t) {
|
|
4734
|
+
return ut("limit", t), new ir("limit", t, "F" /* First */);
|
|
4730
4735
|
}
|
|
4731
4736
|
|
|
4732
4737
|
/**
|
|
@@ -4737,54 +4742,56 @@ class or extends tr {
|
|
|
4737
4742
|
*
|
|
4738
4743
|
* @param limit - The maximum number of items to return.
|
|
4739
4744
|
* @returns The created {@link Query}.
|
|
4740
|
-
*/ function
|
|
4741
|
-
return ut("limitToLast", t), new
|
|
4745
|
+
*/ function ur(t) {
|
|
4746
|
+
return ut("limitToLast", t), new ir("limitToLast", t, "L" /* Last */);
|
|
4742
4747
|
}
|
|
4743
4748
|
|
|
4744
|
-
class
|
|
4745
|
-
constructor(t,
|
|
4746
|
-
super(), this.type = t, this.
|
|
4749
|
+
class cr extends Zn {
|
|
4750
|
+
constructor(t, e, n) {
|
|
4751
|
+
super(), this.type = t, this.bt = e, this.Et = n;
|
|
4747
4752
|
}
|
|
4748
4753
|
_apply(t) {
|
|
4749
|
-
const
|
|
4750
|
-
return new
|
|
4751
|
-
return new
|
|
4752
|
-
}(t._query,
|
|
4754
|
+
const e = wr(t, this.type, this.bt, this.Et);
|
|
4755
|
+
return new hn(t.firestore, t.converter, function(t, e) {
|
|
4756
|
+
return new oe(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, e, t.endAt);
|
|
4757
|
+
}(t._query, e));
|
|
4753
4758
|
}
|
|
4754
4759
|
}
|
|
4755
4760
|
|
|
4756
|
-
function
|
|
4757
|
-
return new
|
|
4761
|
+
function ar(...t) {
|
|
4762
|
+
return new cr("startAt", t,
|
|
4763
|
+
/*inclusive=*/ !0);
|
|
4758
4764
|
}
|
|
4759
4765
|
|
|
4760
|
-
function
|
|
4761
|
-
return new
|
|
4762
|
-
/*
|
|
4766
|
+
function hr(...t) {
|
|
4767
|
+
return new cr("startAfter", t,
|
|
4768
|
+
/*inclusive=*/ !1);
|
|
4763
4769
|
}
|
|
4764
4770
|
|
|
4765
|
-
class
|
|
4766
|
-
constructor(t,
|
|
4767
|
-
super(), this.type = t, this.
|
|
4771
|
+
class lr extends Zn {
|
|
4772
|
+
constructor(t, e, n) {
|
|
4773
|
+
super(), this.type = t, this.bt = e, this.Et = n;
|
|
4768
4774
|
}
|
|
4769
4775
|
_apply(t) {
|
|
4770
|
-
const
|
|
4771
|
-
return new
|
|
4772
|
-
return new
|
|
4773
|
-
}(t._query,
|
|
4776
|
+
const e = wr(t, this.type, this.bt, this.Et);
|
|
4777
|
+
return new hn(t.firestore, t.converter, function(t, e) {
|
|
4778
|
+
return new oe(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, t.startAt, e);
|
|
4779
|
+
}(t._query, e));
|
|
4774
4780
|
}
|
|
4775
4781
|
}
|
|
4776
4782
|
|
|
4777
|
-
function
|
|
4778
|
-
return new
|
|
4783
|
+
function fr(...t) {
|
|
4784
|
+
return new lr("endBefore", t,
|
|
4785
|
+
/*inclusive=*/ !1);
|
|
4779
4786
|
}
|
|
4780
4787
|
|
|
4781
|
-
function
|
|
4782
|
-
return new
|
|
4788
|
+
function dr(...t) {
|
|
4789
|
+
return new lr("endAt", t, /*inclusive=*/ !0);
|
|
4783
4790
|
}
|
|
4784
4791
|
|
|
4785
|
-
/** Helper function to create a bound from a document or fields */ function
|
|
4786
|
-
if (
|
|
4787
|
-
if (!r) throw new U(P, `Can't use a DocumentSnapshot that doesn't exist for ${
|
|
4792
|
+
/** Helper function to create a bound from a document or fields */ function wr(t, e, n, r) {
|
|
4793
|
+
if (n[0] = getModularInstance(n[0]), n[0] instanceof Yn) return function(t, e, n, r, s) {
|
|
4794
|
+
if (!r) throw new U(P, `Can't use a DocumentSnapshot that doesn't exist for ${n}().`);
|
|
4788
4795
|
const i = [];
|
|
4789
4796
|
// Because people expect to continue/end a query at the exact document
|
|
4790
4797
|
// provided, we need to use the implicit sort order rather than the explicit
|
|
@@ -4793,23 +4800,23 @@ function wr(...t) {
|
|
|
4793
4800
|
// the provided document. Without the key (by using the explicit sort
|
|
4794
4801
|
// orders), multiple documents could match the position, yielding duplicate
|
|
4795
4802
|
// results.
|
|
4796
|
-
for (const
|
|
4797
|
-
const t = r.data.field(
|
|
4798
|
-
if (Dt(t)) throw new U(A, 'Invalid query. You are trying to start or end a query using a document for which the field "' +
|
|
4803
|
+
for (const n of le(t)) if (n.field.isKeyField()) i.push(Ct(e, r.key)); else {
|
|
4804
|
+
const t = r.data.field(n.field);
|
|
4805
|
+
if (Dt(t)) throw new U(A, '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.)');
|
|
4799
4806
|
if (null === t) {
|
|
4800
|
-
const t =
|
|
4807
|
+
const t = n.field.canonicalString();
|
|
4801
4808
|
throw new U(A, `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.`);
|
|
4802
4809
|
}
|
|
4803
4810
|
i.push(t);
|
|
4804
4811
|
}
|
|
4805
|
-
return new
|
|
4812
|
+
return new ne(i, s);
|
|
4806
4813
|
}
|
|
4807
4814
|
/**
|
|
4808
4815
|
* Converts a list of field values to a `Bound` for the given query.
|
|
4809
|
-
*/ (t._query, t.firestore._databaseId,
|
|
4816
|
+
*/ (t._query, t.firestore._databaseId, e, n[0]._document, r);
|
|
4810
4817
|
{
|
|
4811
|
-
const s =
|
|
4812
|
-
return function(t,
|
|
4818
|
+
const s = Vn(t.firestore);
|
|
4819
|
+
return function(t, e, n, r, s, i) {
|
|
4813
4820
|
// Use explicit order by's because it has to match the query the user made
|
|
4814
4821
|
const o = t.explicitOrderBy;
|
|
4815
4822
|
if (s.length > o.length) throw new U(A, `Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);
|
|
@@ -4818,48 +4825,48 @@ function wr(...t) {
|
|
|
4818
4825
|
const c = s[i];
|
|
4819
4826
|
if (o[i].field.isKeyField()) {
|
|
4820
4827
|
if ("string" != typeof c) throw new U(A, `Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);
|
|
4821
|
-
if (!
|
|
4822
|
-
const
|
|
4823
|
-
if (!
|
|
4824
|
-
const s = new
|
|
4825
|
-
u.push(Ct(
|
|
4828
|
+
if (!he(t) && -1 !== c.indexOf("/")) throw new U(A, `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.`);
|
|
4829
|
+
const n = t.path.child(X.fromString(c));
|
|
4830
|
+
if (!et.isDocumentKey(n)) throw new U(A, `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.`);
|
|
4831
|
+
const s = new et(n);
|
|
4832
|
+
u.push(Ct(e, s));
|
|
4826
4833
|
} else {
|
|
4827
|
-
const t =
|
|
4834
|
+
const t = Ln(n, r, c);
|
|
4828
4835
|
u.push(t);
|
|
4829
4836
|
}
|
|
4830
4837
|
}
|
|
4831
|
-
return new
|
|
4838
|
+
return new ne(u, i);
|
|
4832
4839
|
}
|
|
4833
4840
|
/**
|
|
4834
4841
|
* Parses the given `documentIdValue` into a `ReferenceValue`, throwing
|
|
4835
4842
|
* appropriate errors if the value is anything other than a `DocumentReference`
|
|
4836
4843
|
* or `string`, or if the string is malformed.
|
|
4837
|
-
*/ (t._query, t.firestore._databaseId, s,
|
|
4844
|
+
*/ (t._query, t.firestore._databaseId, s, e, n, r);
|
|
4838
4845
|
}
|
|
4839
4846
|
}
|
|
4840
4847
|
|
|
4841
|
-
function
|
|
4842
|
-
if ("string" == typeof (
|
|
4843
|
-
if ("" ===
|
|
4844
|
-
if (!
|
|
4845
|
-
const r =
|
|
4846
|
-
if (!
|
|
4847
|
-
return Ct(t, new
|
|
4848
|
+
function mr(t, e, n) {
|
|
4849
|
+
if ("string" == typeof (n = getModularInstance(n))) {
|
|
4850
|
+
if ("" === n) throw new U(A, "Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");
|
|
4851
|
+
if (!he(e) && -1 !== n.indexOf("/")) throw new U(A, `Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);
|
|
4852
|
+
const r = e.path.child(X.fromString(n));
|
|
4853
|
+
if (!et.isDocumentKey(r)) throw new U(A, `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}).`);
|
|
4854
|
+
return Ct(t, new et(r));
|
|
4848
4855
|
}
|
|
4849
|
-
if (
|
|
4850
|
-
throw new U(A, `Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${it(
|
|
4856
|
+
if (n instanceof an) return Ct(t, n._key);
|
|
4857
|
+
throw new U(A, `Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${it(n)}.`);
|
|
4851
4858
|
}
|
|
4852
4859
|
|
|
4853
4860
|
/**
|
|
4854
4861
|
* Validates that the value passed into a disjunctive filter satisfies all
|
|
4855
4862
|
* array requirements.
|
|
4856
|
-
*/ function
|
|
4857
|
-
if (!Array.isArray(t) || 0 === t.length) throw new U(A, `Invalid Query. A non-empty array is required for '${
|
|
4858
|
-
if (t.length > 10) throw new U(A, `Invalid Query. '${
|
|
4863
|
+
*/ function pr(t, e) {
|
|
4864
|
+
if (!Array.isArray(t) || 0 === t.length) throw new U(A, `Invalid Query. A non-empty array is required for '${e.toString()}' filters.`);
|
|
4865
|
+
if (t.length > 10) throw new U(A, `Invalid Query. '${e.toString()}' filters support a maximum of 10 elements in the value array.`);
|
|
4859
4866
|
}
|
|
4860
4867
|
|
|
4861
|
-
function
|
|
4862
|
-
if (!
|
|
4868
|
+
function yr(t, e, n) {
|
|
4869
|
+
if (!n.isEqual(e)) throw new U(A, `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.`);
|
|
4863
4870
|
}
|
|
4864
4871
|
|
|
4865
4872
|
/**
|
|
@@ -4909,17 +4916,17 @@ function _r(t, n, e) {
|
|
|
4909
4916
|
* their `set()` or fails due to invalid data originating from a `toFirestore()`
|
|
4910
4917
|
* call.
|
|
4911
4918
|
*/
|
|
4912
|
-
function
|
|
4919
|
+
function _r(t, e, n) {
|
|
4913
4920
|
let r;
|
|
4914
4921
|
// Cast to `any` in order to satisfy the union type constraint on
|
|
4915
4922
|
// toFirestore().
|
|
4916
4923
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4917
|
-
return r = t ?
|
|
4924
|
+
return r = t ? n && (n.merge || n.mergeFields) ? t.toFirestore(e, n) : t.toFirestore(e) : e,
|
|
4918
4925
|
r;
|
|
4919
4926
|
}
|
|
4920
4927
|
|
|
4921
|
-
class
|
|
4922
|
-
convertValue(t,
|
|
4928
|
+
class gr extends class {
|
|
4929
|
+
convertValue(t, e = "none") {
|
|
4923
4930
|
switch (St(t)) {
|
|
4924
4931
|
case 0 /* NullValue */ :
|
|
4925
4932
|
return null;
|
|
@@ -4934,7 +4941,7 @@ class br extends class {
|
|
|
4934
4941
|
return this.convertTimestamp(t.timestampValue);
|
|
4935
4942
|
|
|
4936
4943
|
case 4 /* ServerTimestampValue */ :
|
|
4937
|
-
return this.convertServerTimestamp(t,
|
|
4944
|
+
return this.convertServerTimestamp(t, e);
|
|
4938
4945
|
|
|
4939
4946
|
case 5 /* StringValue */ :
|
|
4940
4947
|
return t.stringValue;
|
|
@@ -4949,32 +4956,32 @@ class br extends class {
|
|
|
4949
4956
|
return this.convertGeoPoint(t.geoPointValue);
|
|
4950
4957
|
|
|
4951
4958
|
case 9 /* ArrayValue */ :
|
|
4952
|
-
return this.convertArray(t.arrayValue,
|
|
4959
|
+
return this.convertArray(t.arrayValue, e);
|
|
4953
4960
|
|
|
4954
4961
|
case 10 /* ObjectValue */ :
|
|
4955
|
-
return this.convertObject(t.mapValue,
|
|
4962
|
+
return this.convertObject(t.mapValue, e);
|
|
4956
4963
|
|
|
4957
4964
|
default:
|
|
4958
4965
|
throw g();
|
|
4959
4966
|
}
|
|
4960
4967
|
}
|
|
4961
|
-
convertObject(t,
|
|
4962
|
-
const
|
|
4968
|
+
convertObject(t, e) {
|
|
4969
|
+
const n = {};
|
|
4963
4970
|
return Et(t.fields, ((t, r) => {
|
|
4964
|
-
|
|
4965
|
-
})),
|
|
4971
|
+
n[t] = this.convertValue(r, e);
|
|
4972
|
+
})), n;
|
|
4966
4973
|
}
|
|
4967
4974
|
convertGeoPoint(t) {
|
|
4968
|
-
return new
|
|
4975
|
+
return new bn(Pt(t.latitude), Pt(t.longitude));
|
|
4969
4976
|
}
|
|
4970
|
-
convertArray(t,
|
|
4971
|
-
return (t.values || []).map((t => this.convertValue(t,
|
|
4977
|
+
convertArray(t, e) {
|
|
4978
|
+
return (t.values || []).map((t => this.convertValue(t, e)));
|
|
4972
4979
|
}
|
|
4973
|
-
convertServerTimestamp(t,
|
|
4974
|
-
switch (
|
|
4980
|
+
convertServerTimestamp(t, e) {
|
|
4981
|
+
switch (e) {
|
|
4975
4982
|
case "previous":
|
|
4976
|
-
const
|
|
4977
|
-
return null ==
|
|
4983
|
+
const n = Nt(t);
|
|
4984
|
+
return null == n ? null : this.convertValue(n, e);
|
|
4978
4985
|
|
|
4979
4986
|
case "estimate":
|
|
4980
4987
|
return this.convertTimestamp($t(t));
|
|
@@ -4984,16 +4991,16 @@ class br extends class {
|
|
|
4984
4991
|
}
|
|
4985
4992
|
}
|
|
4986
4993
|
convertTimestamp(t) {
|
|
4987
|
-
const
|
|
4988
|
-
return new gt(
|
|
4994
|
+
const e = Rt(t);
|
|
4995
|
+
return new gt(e.seconds, e.nanos);
|
|
4989
4996
|
}
|
|
4990
|
-
convertDocumentKey(t,
|
|
4991
|
-
const
|
|
4992
|
-
|
|
4993
|
-
const r = new K(
|
|
4994
|
-
return r.isEqual(
|
|
4997
|
+
convertDocumentKey(t, e) {
|
|
4998
|
+
const n = X.fromString(t);
|
|
4999
|
+
v(We(n));
|
|
5000
|
+
const r = new K(n.get(1), n.get(3)), s = new et(n.popFirst(5));
|
|
5001
|
+
return r.isEqual(e) ||
|
|
4995
5002
|
// TODO(b/64130202): Somehow support foreign references.
|
|
4996
|
-
p(`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 (${
|
|
5003
|
+
p(`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.`),
|
|
4997
5004
|
s;
|
|
4998
5005
|
}
|
|
4999
5006
|
} {
|
|
@@ -5001,11 +5008,11 @@ class br extends class {
|
|
|
5001
5008
|
super(), this.firestore = t;
|
|
5002
5009
|
}
|
|
5003
5010
|
convertBytes(t) {
|
|
5004
|
-
return new
|
|
5011
|
+
return new gn(t);
|
|
5005
5012
|
}
|
|
5006
5013
|
convertReference(t) {
|
|
5007
|
-
const
|
|
5008
|
-
return new
|
|
5014
|
+
const e = this.convertDocumentKey(t, this.firestore._databaseId);
|
|
5015
|
+
return new an(this.firestore, /* converter= */ null, e);
|
|
5009
5016
|
}
|
|
5010
5017
|
}
|
|
5011
5018
|
|
|
@@ -5022,11 +5029,11 @@ class br extends class {
|
|
|
5022
5029
|
* @returns A Promise resolved with a `DocumentSnapshot` containing the current
|
|
5023
5030
|
* document contents.
|
|
5024
5031
|
*/ function vr(t) {
|
|
5025
|
-
const
|
|
5026
|
-
return
|
|
5027
|
-
|
|
5028
|
-
const r =
|
|
5029
|
-
return new
|
|
5032
|
+
const e = en((t = ot(t, an)).firestore), n = new gr(t.firestore);
|
|
5033
|
+
return Xe(e, [ t._key ]).then((e => {
|
|
5034
|
+
v(1 === e.length);
|
|
5035
|
+
const r = e[0];
|
|
5036
|
+
return new Yn(t.firestore, n, t._key, r.isFoundDocument() ? r : null, t.converter);
|
|
5030
5037
|
}));
|
|
5031
5038
|
}
|
|
5032
5039
|
|
|
@@ -5041,33 +5048,33 @@ class br extends class {
|
|
|
5041
5048
|
*
|
|
5042
5049
|
* @param query - The `Query` to execute.
|
|
5043
5050
|
* @returns A Promise that will be resolved with the results of the query.
|
|
5044
|
-
*/ function
|
|
5051
|
+
*/ function br(t) {
|
|
5045
5052
|
!function(t) {
|
|
5046
|
-
if (
|
|
5047
|
-
}((t = ot(t,
|
|
5048
|
-
const
|
|
5049
|
-
return
|
|
5050
|
-
const r =
|
|
5051
|
-
return
|
|
5053
|
+
if (ue(t) && 0 === t.explicitOrderBy.length) throw new U(q, "limitToLast() queries require specifying at least one orderBy() clause");
|
|
5054
|
+
}((t = ot(t, hn))._query);
|
|
5055
|
+
const e = en(t.firestore), n = new gr(t.firestore);
|
|
5056
|
+
return Ze(e, t._query).then((e => {
|
|
5057
|
+
const r = e.map((e => new Hn(t.firestore, n, e.key, e, t.converter)));
|
|
5058
|
+
return ue(t._query) &&
|
|
5052
5059
|
// Limit to last queries reverse the orderBy constraint that was
|
|
5053
5060
|
// specified by the user. As such, we need to reverse the order of the
|
|
5054
5061
|
// results to return the documents in the expected order.
|
|
5055
|
-
r.reverse(), new
|
|
5062
|
+
r.reverse(), new Kn(t, r);
|
|
5056
5063
|
}));
|
|
5057
5064
|
}
|
|
5058
5065
|
|
|
5059
|
-
function
|
|
5060
|
-
const r =
|
|
5061
|
-
return
|
|
5066
|
+
function Er(t, e, n) {
|
|
5067
|
+
const r = _r((t = ot(t, an)).converter, e, n), s = Dn(Vn(t.firestore), "setDoc", t._key, r, null !== t.converter, n);
|
|
5068
|
+
return Je(en(t.firestore), [ s.toMutation(t._key, be.none()) ]);
|
|
5062
5069
|
}
|
|
5063
5070
|
|
|
5064
|
-
function
|
|
5065
|
-
const s =
|
|
5071
|
+
function Tr(t, e, n, ...r) {
|
|
5072
|
+
const s = Vn((t = ot(t, an)).firestore);
|
|
5066
5073
|
// For Compat types, we have to "extract" the underlying types before
|
|
5067
5074
|
// performing validation.
|
|
5068
5075
|
let i;
|
|
5069
|
-
i = "string" == typeof (
|
|
5070
|
-
return
|
|
5076
|
+
i = "string" == typeof (e = getModularInstance(e)) || e instanceof yn ? Cn(s, "updateDoc", t._key, e, n, r) : On(s, "updateDoc", t._key, e);
|
|
5077
|
+
return Je(en(t.firestore), [ i.toMutation(t._key, be.exists(!0)) ]);
|
|
5071
5078
|
}
|
|
5072
5079
|
|
|
5073
5080
|
/**
|
|
@@ -5081,8 +5088,8 @@ function Ir(t, n, e, ...r) {
|
|
|
5081
5088
|
* @param reference - A reference to the document to delete.
|
|
5082
5089
|
* @returns A `Promise` resolved once the document has been successfully
|
|
5083
5090
|
* deleted from the backend.
|
|
5084
|
-
*/ function
|
|
5085
|
-
return
|
|
5091
|
+
*/ function Ir(t) {
|
|
5092
|
+
return Je(en((t = ot(t, an)).firestore), [ new Ae(t._key, be.none()) ]);
|
|
5086
5093
|
}
|
|
5087
5094
|
|
|
5088
5095
|
/**
|
|
@@ -5099,9 +5106,9 @@ function Ir(t, n, e, ...r) {
|
|
|
5099
5106
|
* @throws Error - If the provided input is not a valid Firestore document.
|
|
5100
5107
|
* @returns A `Promise` resolved with a `DocumentReference` pointing to the
|
|
5101
5108
|
* newly created document after it has been written to the backend.
|
|
5102
|
-
*/ function
|
|
5103
|
-
const
|
|
5104
|
-
return
|
|
5109
|
+
*/ function Ar(t, e) {
|
|
5110
|
+
const n = wn(t = ot(t, ln)), r = _r(t.converter, e), s = Dn(Vn(t.firestore), "addDoc", n._key, r, null !== n.converter, {});
|
|
5111
|
+
return Je(en(t.firestore), [ s.toMutation(n._key, be.exists(!1)) ]).then((() => n));
|
|
5105
5112
|
}
|
|
5106
5113
|
|
|
5107
5114
|
/**
|
|
@@ -5123,15 +5130,15 @@ function Ir(t, n, e, ...r) {
|
|
|
5123
5130
|
/**
|
|
5124
5131
|
* Returns a sentinel for use with {@link @firebase/firestore/lite#(updateDoc:1)} or
|
|
5125
5132
|
* {@link @firebase/firestore/lite#(setDoc:1)} with `{merge: true}` to mark a field for deletion.
|
|
5126
|
-
*/ function
|
|
5127
|
-
return new
|
|
5133
|
+
*/ function Rr() {
|
|
5134
|
+
return new Nn("deleteField");
|
|
5128
5135
|
}
|
|
5129
5136
|
|
|
5130
5137
|
/**
|
|
5131
5138
|
* Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
|
|
5132
5139
|
* include a server-generated timestamp in the written data.
|
|
5133
|
-
*/ function
|
|
5134
|
-
return new
|
|
5140
|
+
*/ function Pr() {
|
|
5141
|
+
return new Sn("serverTimestamp");
|
|
5135
5142
|
}
|
|
5136
5143
|
|
|
5137
5144
|
/**
|
|
@@ -5145,10 +5152,10 @@ function Ir(t, n, e, ...r) {
|
|
|
5145
5152
|
* @param elements - The elements to union into the array.
|
|
5146
5153
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5147
5154
|
* `updateDoc()`.
|
|
5148
|
-
*/ function
|
|
5155
|
+
*/ function Vr(...t) {
|
|
5149
5156
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5150
5157
|
// update() since we'd need the Firestore instance to do this.
|
|
5151
|
-
return new
|
|
5158
|
+
return new Fn("arrayUnion", t);
|
|
5152
5159
|
}
|
|
5153
5160
|
|
|
5154
5161
|
/**
|
|
@@ -5161,10 +5168,10 @@ function Ir(t, n, e, ...r) {
|
|
|
5161
5168
|
* @param elements - The elements to remove from the array.
|
|
5162
5169
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5163
5170
|
* `updateDoc()`
|
|
5164
|
-
*/ function
|
|
5171
|
+
*/ function Dr(...t) {
|
|
5165
5172
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5166
5173
|
// update() since we'd need the Firestore instance to do this.
|
|
5167
|
-
return new
|
|
5174
|
+
return new xn("arrayRemove", t);
|
|
5168
5175
|
}
|
|
5169
5176
|
|
|
5170
5177
|
/**
|
|
@@ -5185,8 +5192,8 @@ function Ir(t, n, e, ...r) {
|
|
|
5185
5192
|
* @param n - The value to increment by.
|
|
5186
5193
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5187
5194
|
* `updateDoc()`
|
|
5188
|
-
*/ function
|
|
5189
|
-
return new
|
|
5195
|
+
*/ function Nr(t) {
|
|
5196
|
+
return new qn("increment", t);
|
|
5190
5197
|
}
|
|
5191
5198
|
|
|
5192
5199
|
/**
|
|
@@ -5212,25 +5219,25 @@ function Ir(t, n, e, ...r) {
|
|
|
5212
5219
|
* provides methods for adding writes to the write batch. None of the writes
|
|
5213
5220
|
* will be committed (or visible locally) until {@link WriteBatch.commit} is
|
|
5214
5221
|
* called.
|
|
5215
|
-
*/ class
|
|
5222
|
+
*/ class $r {
|
|
5216
5223
|
/** @hideconstructor */
|
|
5217
|
-
constructor(t,
|
|
5218
|
-
this._firestore = t, this._commitHandler =
|
|
5219
|
-
this._dataReader =
|
|
5224
|
+
constructor(t, e) {
|
|
5225
|
+
this._firestore = t, this._commitHandler = e, this._mutations = [], this._committed = !1,
|
|
5226
|
+
this._dataReader = Vn(t);
|
|
5220
5227
|
}
|
|
5221
|
-
set(t,
|
|
5228
|
+
set(t, e, n) {
|
|
5222
5229
|
this._verifyNotCommitted();
|
|
5223
|
-
const r =
|
|
5224
|
-
return this._mutations.push(i.toMutation(r._key,
|
|
5230
|
+
const r = Sr(t, this._firestore), s = _r(r.converter, e, n), i = Dn(this._dataReader, "WriteBatch.set", r._key, s, null !== r.converter, n);
|
|
5231
|
+
return this._mutations.push(i.toMutation(r._key, be.none())), this;
|
|
5225
5232
|
}
|
|
5226
|
-
update(t,
|
|
5233
|
+
update(t, e, n, ...r) {
|
|
5227
5234
|
this._verifyNotCommitted();
|
|
5228
|
-
const s =
|
|
5235
|
+
const s = Sr(t, this._firestore);
|
|
5229
5236
|
// For Compat types, we have to "extract" the underlying types before
|
|
5230
5237
|
// performing validation.
|
|
5231
5238
|
let i;
|
|
5232
|
-
return i = "string" == typeof (
|
|
5233
|
-
this._mutations.push(i.toMutation(s._key,
|
|
5239
|
+
return i = "string" == typeof (e = getModularInstance(e)) || e instanceof yn ? Cn(this._dataReader, "WriteBatch.update", s._key, e, n, r) : On(this._dataReader, "WriteBatch.update", s._key, e),
|
|
5240
|
+
this._mutations.push(i.toMutation(s._key, be.exists(!0))), this;
|
|
5234
5241
|
}
|
|
5235
5242
|
/**
|
|
5236
5243
|
* Deletes the document referred to by the provided {@link DocumentReference}.
|
|
@@ -5239,8 +5246,8 @@ function Ir(t, n, e, ...r) {
|
|
|
5239
5246
|
* @returns This `WriteBatch` instance. Used for chaining method calls.
|
|
5240
5247
|
*/ delete(t) {
|
|
5241
5248
|
this._verifyNotCommitted();
|
|
5242
|
-
const
|
|
5243
|
-
return this._mutations = this._mutations.concat(new
|
|
5249
|
+
const e = Sr(t, this._firestore);
|
|
5250
|
+
return this._mutations = this._mutations.concat(new Ae(e._key, be.none())), this;
|
|
5244
5251
|
}
|
|
5245
5252
|
/**
|
|
5246
5253
|
* Commits all of the writes in this write batch as a single atomic unit.
|
|
@@ -5261,8 +5268,8 @@ function Ir(t, n, e, ...r) {
|
|
|
5261
5268
|
}
|
|
5262
5269
|
}
|
|
5263
5270
|
|
|
5264
|
-
function
|
|
5265
|
-
if ((t = getModularInstance(t)).firestore !==
|
|
5271
|
+
function Sr(t, e) {
|
|
5272
|
+
if ((t = getModularInstance(t)).firestore !== e) throw new U(A, "Provided document reference is from a different Firestore instance.");
|
|
5266
5273
|
return t;
|
|
5267
5274
|
}
|
|
5268
5275
|
|
|
@@ -5278,9 +5285,9 @@ function Fr(t, n) {
|
|
|
5278
5285
|
*
|
|
5279
5286
|
* @returns A `WriteBatch` that can be used to atomically execute multiple
|
|
5280
5287
|
* writes.
|
|
5281
|
-
*/ function
|
|
5282
|
-
const
|
|
5283
|
-
return new
|
|
5288
|
+
*/ function Fr(t) {
|
|
5289
|
+
const e = en(t = ot(t, rn));
|
|
5290
|
+
return new $r(t, (t => Je(e, t)));
|
|
5284
5291
|
}
|
|
5285
5292
|
|
|
5286
5293
|
/**
|
|
@@ -5302,7 +5309,7 @@ function Fr(t, n) {
|
|
|
5302
5309
|
/**
|
|
5303
5310
|
* Internal transaction object responsible for accumulating the mutations to
|
|
5304
5311
|
* perform and the base versions for any documents read.
|
|
5305
|
-
*/ class
|
|
5312
|
+
*/ class xr {
|
|
5306
5313
|
constructor(t) {
|
|
5307
5314
|
this.datastore = t,
|
|
5308
5315
|
// The version of each document that was read during this transaction.
|
|
@@ -5322,66 +5329,66 @@ function Fr(t, n) {
|
|
|
5322
5329
|
}
|
|
5323
5330
|
async lookup(t) {
|
|
5324
5331
|
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new U(A, "Firestore transactions require all reads to be executed before all writes.");
|
|
5325
|
-
const
|
|
5326
|
-
return
|
|
5332
|
+
const e = await Xe(this.datastore, t);
|
|
5333
|
+
return e.forEach((t => this.recordVersion(t))), e;
|
|
5327
5334
|
}
|
|
5328
|
-
set(t,
|
|
5329
|
-
this.write(
|
|
5335
|
+
set(t, e) {
|
|
5336
|
+
this.write(e.toMutation(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5330
5337
|
}
|
|
5331
|
-
update(t,
|
|
5338
|
+
update(t, e) {
|
|
5332
5339
|
try {
|
|
5333
|
-
this.write(
|
|
5340
|
+
this.write(e.toMutation(t, this.preconditionForUpdate(t)));
|
|
5334
5341
|
} catch (t) {
|
|
5335
5342
|
this.lastWriteError = t;
|
|
5336
5343
|
}
|
|
5337
5344
|
this.writtenDocs.add(t.toString());
|
|
5338
5345
|
}
|
|
5339
5346
|
delete(t) {
|
|
5340
|
-
this.write(new
|
|
5347
|
+
this.write(new Ae(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5341
5348
|
}
|
|
5342
5349
|
async commit() {
|
|
5343
5350
|
if (this.ensureCommitNotCalled(), this.lastWriteError) throw this.lastWriteError;
|
|
5344
5351
|
const t = this.readVersions;
|
|
5345
5352
|
// For each mutation, note that the doc was written.
|
|
5346
|
-
this.mutations.forEach((
|
|
5347
|
-
t.delete(
|
|
5353
|
+
this.mutations.forEach((e => {
|
|
5354
|
+
t.delete(e.key.toString());
|
|
5348
5355
|
})),
|
|
5349
5356
|
// For each document that was read but not written to, we want to perform
|
|
5350
5357
|
// a `verify` operation.
|
|
5351
|
-
t.forEach(((t,
|
|
5352
|
-
const
|
|
5353
|
-
this.mutations.push(new
|
|
5354
|
-
})), await
|
|
5358
|
+
t.forEach(((t, e) => {
|
|
5359
|
+
const n = et.fromPath(e);
|
|
5360
|
+
this.mutations.push(new Re(n, this.precondition(n)));
|
|
5361
|
+
})), await Je(this.datastore, this.mutations), this.committed = !0;
|
|
5355
5362
|
}
|
|
5356
5363
|
recordVersion(t) {
|
|
5357
|
-
let
|
|
5358
|
-
if (t.isFoundDocument())
|
|
5364
|
+
let e;
|
|
5365
|
+
if (t.isFoundDocument()) e = t.version; else {
|
|
5359
5366
|
if (!t.isNoDocument()) throw g();
|
|
5360
5367
|
// For deleted docs, we must use baseVersion 0 when we overwrite them.
|
|
5361
|
-
|
|
5368
|
+
e = vt.min();
|
|
5362
5369
|
}
|
|
5363
|
-
const
|
|
5364
|
-
if (
|
|
5365
|
-
if (!
|
|
5370
|
+
const n = this.readVersions.get(t.key.toString());
|
|
5371
|
+
if (n) {
|
|
5372
|
+
if (!e.isEqual(n))
|
|
5366
5373
|
// This transaction will fail no matter what.
|
|
5367
5374
|
throw new U(F, "Document version changed between two reads.");
|
|
5368
|
-
} else this.readVersions.set(t.key.toString(),
|
|
5375
|
+
} else this.readVersions.set(t.key.toString(), e);
|
|
5369
5376
|
}
|
|
5370
5377
|
/**
|
|
5371
5378
|
* Returns the version of this document when it was read in this transaction,
|
|
5372
5379
|
* as a precondition, or no precondition if it was not read.
|
|
5373
5380
|
*/ precondition(t) {
|
|
5374
|
-
const
|
|
5375
|
-
return !this.writtenDocs.has(t.toString()) &&
|
|
5381
|
+
const e = this.readVersions.get(t.toString());
|
|
5382
|
+
return !this.writtenDocs.has(t.toString()) && e ? be.updateTime(e) : be.none();
|
|
5376
5383
|
}
|
|
5377
5384
|
/**
|
|
5378
5385
|
* Returns the precondition for a document if the operation is an update.
|
|
5379
5386
|
*/ preconditionForUpdate(t) {
|
|
5380
|
-
const
|
|
5387
|
+
const e = this.readVersions.get(t.toString());
|
|
5381
5388
|
// The first time a document is written, we want to take into account the
|
|
5382
5389
|
// read time and existence
|
|
5383
|
-
if (!this.writtenDocs.has(t.toString()) &&
|
|
5384
|
-
if (
|
|
5390
|
+
if (!this.writtenDocs.has(t.toString()) && e) {
|
|
5391
|
+
if (e.isEqual(vt.min()))
|
|
5385
5392
|
// The document doesn't exist, so fail the transaction.
|
|
5386
5393
|
// This has to be validated locally because you can't send a
|
|
5387
5394
|
// precondition that a document does not exist without changing the
|
|
@@ -5393,11 +5400,11 @@ function Fr(t, n) {
|
|
|
5393
5400
|
// transaction.
|
|
5394
5401
|
throw new U(A, "Can't update a document that doesn't exist.");
|
|
5395
5402
|
// Document exists, base precondition on document update time.
|
|
5396
|
-
return
|
|
5403
|
+
return be.updateTime(e);
|
|
5397
5404
|
}
|
|
5398
5405
|
// Document was not read, so we just use the preconditions for a blind
|
|
5399
5406
|
// update.
|
|
5400
|
-
return
|
|
5407
|
+
return be.exists(!0);
|
|
5401
5408
|
}
|
|
5402
5409
|
write(t) {
|
|
5403
5410
|
this.ensureCommitNotCalled(), this.mutations.push(t);
|
|
@@ -5425,20 +5432,20 @@ function Fr(t, n) {
|
|
|
5425
5432
|
* TransactionRunner encapsulates the logic needed to run and retry transactions
|
|
5426
5433
|
* with backoff.
|
|
5427
5434
|
*/
|
|
5428
|
-
class
|
|
5429
|
-
constructor(t,
|
|
5430
|
-
this.asyncQueue = t, this.datastore =
|
|
5431
|
-
this.Tt = 5, this.It = new
|
|
5435
|
+
class qr {
|
|
5436
|
+
constructor(t, e, n, r) {
|
|
5437
|
+
this.asyncQueue = t, this.datastore = e, this.updateFunction = n, this.deferred = r,
|
|
5438
|
+
this.Tt = 5, this.It = new He(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
|
|
5432
5439
|
}
|
|
5433
5440
|
/** Runs the transaction and sets the result on deferred. */ run() {
|
|
5434
5441
|
this.Tt -= 1, this.At();
|
|
5435
5442
|
}
|
|
5436
5443
|
At() {
|
|
5437
5444
|
this.It.W((async () => {
|
|
5438
|
-
const t = new
|
|
5439
|
-
|
|
5445
|
+
const t = new xr(this.datastore), e = this.Rt(t);
|
|
5446
|
+
e && e.then((e => {
|
|
5440
5447
|
this.asyncQueue.enqueueAndForget((() => t.commit().then((() => {
|
|
5441
|
-
this.deferred.resolve(
|
|
5448
|
+
this.deferred.resolve(e);
|
|
5442
5449
|
})).catch((t => {
|
|
5443
5450
|
this.Pt(t);
|
|
5444
5451
|
}))));
|
|
@@ -5449,8 +5456,8 @@ class Or {
|
|
|
5449
5456
|
}
|
|
5450
5457
|
Rt(t) {
|
|
5451
5458
|
try {
|
|
5452
|
-
const
|
|
5453
|
-
return !ct(
|
|
5459
|
+
const e = this.updateFunction(t);
|
|
5460
|
+
return !ct(e) && e.catch && e.then ? e : (this.deferred.reject(Error("Transaction callback must return a Promise")),
|
|
5454
5461
|
null);
|
|
5455
5462
|
} catch (t) {
|
|
5456
5463
|
// Do not retry errors thrown by user provided updateFunction.
|
|
@@ -5465,8 +5472,8 @@ class Or {
|
|
|
5465
5472
|
if ("FirebaseError" === t.name) {
|
|
5466
5473
|
// In transactions, the backend will fail outdated reads with FAILED_PRECONDITION and
|
|
5467
5474
|
// non-matching document versions with ABORTED. These errors should be retried.
|
|
5468
|
-
const
|
|
5469
|
-
return "aborted" ===
|
|
5475
|
+
const e = t.code;
|
|
5476
|
+
return "aborted" === e || "failed-precondition" === e || !
|
|
5470
5477
|
/**
|
|
5471
5478
|
* Determines whether an error code represents a permanent error when received
|
|
5472
5479
|
* in response to a non-write operation.
|
|
@@ -5503,7 +5510,7 @@ class Or {
|
|
|
5503
5510
|
case L:
|
|
5504
5511
|
return !0;
|
|
5505
5512
|
}
|
|
5506
|
-
}(
|
|
5513
|
+
}(e);
|
|
5507
5514
|
}
|
|
5508
5515
|
return !1;
|
|
5509
5516
|
}
|
|
@@ -5525,7 +5532,7 @@ class Or {
|
|
|
5525
5532
|
* See the License for the specific language governing permissions and
|
|
5526
5533
|
* limitations under the License.
|
|
5527
5534
|
*/
|
|
5528
|
-
/** The Platform's 'document' implementation or null if not available. */ function
|
|
5535
|
+
/** The Platform's 'document' implementation or null if not available. */ function Or() {
|
|
5529
5536
|
// `document` is not always available, e.g. in ReactNative and WebWorkers.
|
|
5530
5537
|
// eslint-disable-next-line no-restricted-globals
|
|
5531
5538
|
return "undefined" != typeof document ? document : null;
|
|
@@ -5557,9 +5564,9 @@ class Or {
|
|
|
5557
5564
|
* Note: We implement `PromiseLike` instead of `Promise`, as the `Promise` type
|
|
5558
5565
|
* in newer versions of TypeScript defines `finally`, which is not available in
|
|
5559
5566
|
* IE.
|
|
5560
|
-
*/ class
|
|
5561
|
-
constructor(t,
|
|
5562
|
-
this.asyncQueue = t, this.timerId =
|
|
5567
|
+
*/ class Cr {
|
|
5568
|
+
constructor(t, e, n, r, s) {
|
|
5569
|
+
this.asyncQueue = t, this.timerId = e, this.targetTimeMs = n, this.op = r, this.removalCallback = s,
|
|
5563
5570
|
this.deferred = new k, this.then = this.deferred.promise.then.bind(this.deferred.promise),
|
|
5564
5571
|
// It's normal for the deferred promise to be canceled (due to cancellation)
|
|
5565
5572
|
// and so we attach a dummy catch callback to avoid
|
|
@@ -5579,9 +5586,9 @@ class Or {
|
|
|
5579
5586
|
* from its delayedOperations list.
|
|
5580
5587
|
* PORTING NOTE: This exists to prevent making removeDelayedOperation() and
|
|
5581
5588
|
* the DelayedOperation class public.
|
|
5582
|
-
*/ static createAndSchedule(t,
|
|
5583
|
-
const i = Date.now() +
|
|
5584
|
-
return o.start(
|
|
5589
|
+
*/ static createAndSchedule(t, e, n, r, s) {
|
|
5590
|
+
const i = Date.now() + n, o = new Cr(t, e, i, r, s);
|
|
5591
|
+
return o.start(n), o;
|
|
5585
5592
|
}
|
|
5586
5593
|
/**
|
|
5587
5594
|
* Starts the timer. This is called immediately after construction by
|
|
@@ -5629,7 +5636,7 @@ class Or {
|
|
|
5629
5636
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5630
5637
|
* See the License for the specific language governing permissions and
|
|
5631
5638
|
* limitations under the License.
|
|
5632
|
-
*/ class
|
|
5639
|
+
*/ class Lr {
|
|
5633
5640
|
constructor() {
|
|
5634
5641
|
// The last promise in the queue.
|
|
5635
5642
|
this.Dt = Promise.resolve(),
|
|
@@ -5652,15 +5659,15 @@ class Or {
|
|
|
5652
5659
|
// List of TimerIds to fast-forward delays for.
|
|
5653
5660
|
this.Ot = [],
|
|
5654
5661
|
// Backoff timer used to schedule retries for retryable operations
|
|
5655
|
-
this.It = new
|
|
5662
|
+
this.It = new He(this, "async_queue_retry" /* AsyncQueueRetry */),
|
|
5656
5663
|
// Visibility handler that triggers an immediate retry of all retryable
|
|
5657
5664
|
// operations. Meant to speed up recovery when we regain file system access
|
|
5658
5665
|
// after page comes into foreground.
|
|
5659
5666
|
this.Ct = () => {
|
|
5660
|
-
const t =
|
|
5667
|
+
const t = Or();
|
|
5661
5668
|
t && m("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.It.H();
|
|
5662
5669
|
};
|
|
5663
|
-
const t =
|
|
5670
|
+
const t = Or();
|
|
5664
5671
|
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.Ct);
|
|
5665
5672
|
}
|
|
5666
5673
|
get isShuttingDown() {
|
|
@@ -5681,8 +5688,8 @@ class Or {
|
|
|
5681
5688
|
enterRestrictedMode(t) {
|
|
5682
5689
|
if (!this.$t) {
|
|
5683
5690
|
this.$t = !0, this.qt = t || !1;
|
|
5684
|
-
const
|
|
5685
|
-
|
|
5691
|
+
const e = Or();
|
|
5692
|
+
e && "function" == typeof e.removeEventListener && e.removeEventListener("visibilitychange", this.Ct);
|
|
5686
5693
|
}
|
|
5687
5694
|
}
|
|
5688
5695
|
enqueue(t) {
|
|
@@ -5692,9 +5699,9 @@ class Or {
|
|
|
5692
5699
|
// Create a deferred Promise that we can return to the callee. This
|
|
5693
5700
|
// allows us to return a "hanging Promise" only to the callee and still
|
|
5694
5701
|
// advance the queue even when the operation is not run.
|
|
5695
|
-
const
|
|
5696
|
-
return this.Ut((() => this.$t && this.qt ? Promise.resolve() : (t().then(
|
|
5697
|
-
|
|
5702
|
+
const e = new k;
|
|
5703
|
+
return this.Ut((() => this.$t && this.qt ? Promise.resolve() : (t().then(e.resolve, e.reject),
|
|
5704
|
+
e.promise))).then((() => e.promise));
|
|
5698
5705
|
}
|
|
5699
5706
|
enqueueRetryable(t) {
|
|
5700
5707
|
this.enqueueAndForget((() => (this.Nt.push(t), this.kt())));
|
|
@@ -5764,18 +5771,18 @@ class Or {
|
|
|
5764
5771
|
}
|
|
5765
5772
|
}
|
|
5766
5773
|
Ut(t) {
|
|
5767
|
-
const
|
|
5774
|
+
const e = this.Dt.then((() => (this.xt = !0, t().catch((t => {
|
|
5768
5775
|
this.Ft = t, this.xt = !1;
|
|
5769
|
-
const
|
|
5776
|
+
const e =
|
|
5770
5777
|
/**
|
|
5771
5778
|
* Chrome includes Error.message in Error.stack. Other browsers do not.
|
|
5772
5779
|
* This returns expected output of message + stack when available.
|
|
5773
5780
|
* @param error - Error or FirestoreError
|
|
5774
5781
|
*/
|
|
5775
5782
|
function(t) {
|
|
5776
|
-
let
|
|
5777
|
-
t.stack && (
|
|
5778
|
-
return
|
|
5783
|
+
let e = t.message || "";
|
|
5784
|
+
t.stack && (e = t.stack.includes(t.message) ? t.stack : t.message + "\n" + t.stack);
|
|
5785
|
+
return e;
|
|
5779
5786
|
}
|
|
5780
5787
|
/**
|
|
5781
5788
|
* @license
|
|
@@ -5805,15 +5812,15 @@ class Or {
|
|
|
5805
5812
|
// Re-throw the error so that this.tail becomes a rejected Promise and
|
|
5806
5813
|
// all further attempts to chain (via .then) will just short-circuit
|
|
5807
5814
|
// and return the rejected Promise.
|
|
5808
|
-
throw p("INTERNAL UNHANDLED ERROR: ",
|
|
5815
|
+
throw p("INTERNAL UNHANDLED ERROR: ", e), t;
|
|
5809
5816
|
})).then((t => (this.xt = !1, t))))));
|
|
5810
|
-
return this.Dt =
|
|
5817
|
+
return this.Dt = e, e;
|
|
5811
5818
|
}
|
|
5812
|
-
enqueueAfterDelay(t,
|
|
5819
|
+
enqueueAfterDelay(t, e, n) {
|
|
5813
5820
|
this.Lt(),
|
|
5814
5821
|
// Fast-forward delays for timerIds that have been overriden.
|
|
5815
|
-
this.Ot.indexOf(t) > -1 && (
|
|
5816
|
-
const r =
|
|
5822
|
+
this.Ot.indexOf(t) > -1 && (e = 0);
|
|
5823
|
+
const r = Cr.createAndSchedule(this, t, e, n, (t => this.jt(t)));
|
|
5817
5824
|
return this.St.push(r), r;
|
|
5818
5825
|
}
|
|
5819
5826
|
Lt() {
|
|
@@ -5837,7 +5844,7 @@ class Or {
|
|
|
5837
5844
|
* For Tests: Determine if a delayed operation with a particular TimerId
|
|
5838
5845
|
* exists.
|
|
5839
5846
|
*/ Bt(t) {
|
|
5840
|
-
for (const
|
|
5847
|
+
for (const e of this.St) if (e.timerId === t) return !0;
|
|
5841
5848
|
return !1;
|
|
5842
5849
|
}
|
|
5843
5850
|
/**
|
|
@@ -5850,8 +5857,8 @@ class Or {
|
|
|
5850
5857
|
// Note that draining may generate more delayed ops, so we do that first.
|
|
5851
5858
|
return this.Mt().then((() => {
|
|
5852
5859
|
// Run ops in the same order they'd run if they ran naturally.
|
|
5853
|
-
this.St.sort(((t,
|
|
5854
|
-
for (const
|
|
5860
|
+
this.St.sort(((t, e) => t.targetTimeMs - e.targetTimeMs));
|
|
5861
|
+
for (const e of this.St) if (e.skipDelay(), "all" /* All */ !== t && e.timerId === t) break;
|
|
5855
5862
|
return this.Mt();
|
|
5856
5863
|
}));
|
|
5857
5864
|
}
|
|
@@ -5862,15 +5869,15 @@ class Or {
|
|
|
5862
5869
|
}
|
|
5863
5870
|
/** Called once a DelayedOperation is run or canceled. */ jt(t) {
|
|
5864
5871
|
// NOTE: indexOf / slice are O(n), but delayedOperations is expected to be small.
|
|
5865
|
-
const
|
|
5866
|
-
this.St.splice(
|
|
5872
|
+
const e = this.St.indexOf(t);
|
|
5873
|
+
this.St.splice(e, 1);
|
|
5867
5874
|
}
|
|
5868
5875
|
}
|
|
5869
5876
|
|
|
5870
|
-
class
|
|
5877
|
+
class Ur {
|
|
5871
5878
|
/** @hideconstructor */
|
|
5872
|
-
constructor(t,
|
|
5873
|
-
this._firestore = t, this._transaction =
|
|
5879
|
+
constructor(t, e) {
|
|
5880
|
+
this._firestore = t, this._transaction = e, this._dataReader = Vn(t);
|
|
5874
5881
|
}
|
|
5875
5882
|
/**
|
|
5876
5883
|
* Reads the document referenced by the provided {@link DocumentReference}.
|
|
@@ -5878,25 +5885,25 @@ class kr {
|
|
|
5878
5885
|
* @param documentRef - A reference to the document to be read.
|
|
5879
5886
|
* @returns A `DocumentSnapshot` with the read data.
|
|
5880
5887
|
*/ get(t) {
|
|
5881
|
-
const
|
|
5882
|
-
return this._transaction.lookup([
|
|
5888
|
+
const e = Sr(t, this._firestore), n = new gr(this._firestore);
|
|
5889
|
+
return this._transaction.lookup([ e._key ]).then((t => {
|
|
5883
5890
|
if (!t || 1 !== t.length) return g();
|
|
5884
5891
|
const r = t[0];
|
|
5885
|
-
if (r.isFoundDocument()) return new
|
|
5886
|
-
if (r.isNoDocument()) return new
|
|
5892
|
+
if (r.isFoundDocument()) return new Yn(this._firestore, n, r.key, r, e.converter);
|
|
5893
|
+
if (r.isNoDocument()) return new Yn(this._firestore, n, e._key, null, e.converter);
|
|
5887
5894
|
throw g();
|
|
5888
5895
|
}));
|
|
5889
5896
|
}
|
|
5890
|
-
set(t,
|
|
5891
|
-
const r =
|
|
5897
|
+
set(t, e, n) {
|
|
5898
|
+
const r = Sr(t, this._firestore), s = _r(r.converter, e, n), i = Dn(this._dataReader, "Transaction.set", r._key, s, null !== r.converter, n);
|
|
5892
5899
|
return this._transaction.set(r._key, i), this;
|
|
5893
5900
|
}
|
|
5894
|
-
update(t,
|
|
5895
|
-
const s =
|
|
5901
|
+
update(t, e, n, ...r) {
|
|
5902
|
+
const s = Sr(t, this._firestore);
|
|
5896
5903
|
// For Compat types, we have to "extract" the underlying types before
|
|
5897
5904
|
// performing validation.
|
|
5898
5905
|
let i;
|
|
5899
|
-
return i = "string" == typeof (
|
|
5906
|
+
return i = "string" == typeof (e = getModularInstance(e)) || e instanceof yn ? Cn(this._dataReader, "Transaction.update", s._key, e, n, r) : On(this._dataReader, "Transaction.update", s._key, e),
|
|
5900
5907
|
this._transaction.update(s._key, i), this;
|
|
5901
5908
|
}
|
|
5902
5909
|
/**
|
|
@@ -5905,8 +5912,8 @@ class kr {
|
|
|
5905
5912
|
* @param documentRef - A reference to the document to be deleted.
|
|
5906
5913
|
* @returns This `Transaction` instance. Used for chaining method calls.
|
|
5907
5914
|
*/ delete(t) {
|
|
5908
|
-
const
|
|
5909
|
-
return this._transaction.delete(
|
|
5915
|
+
const e = Sr(t, this._firestore);
|
|
5916
|
+
return this._transaction.delete(e._key), this;
|
|
5910
5917
|
}
|
|
5911
5918
|
}
|
|
5912
5919
|
|
|
@@ -5926,9 +5933,9 @@ class kr {
|
|
|
5926
5933
|
* (the `updateFunction` returned a failed promise), the promise returned by the
|
|
5927
5934
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
5928
5935
|
* rejected promise with the corresponding failure error is returned.
|
|
5929
|
-
*/ function
|
|
5930
|
-
const
|
|
5931
|
-
return new
|
|
5936
|
+
*/ function kr(t, e) {
|
|
5937
|
+
const n = en(t = ot(t, rn)), r = new k;
|
|
5938
|
+
return new qr(new Lr, n, (n => e(new Ur(t, n))), r).run(), r.promise;
|
|
5932
5939
|
}
|
|
5933
5940
|
|
|
5934
5941
|
/**
|
|
@@ -5940,12 +5947,12 @@ class kr {
|
|
|
5940
5947
|
* @packageDocumentation
|
|
5941
5948
|
*/ !function(t) {
|
|
5942
5949
|
f = t;
|
|
5943
|
-
}(`${SDK_VERSION}_lite`), _registerComponent(new Component("firestore/lite", ((t, {options:
|
|
5944
|
-
const
|
|
5945
|
-
return
|
|
5950
|
+
}(`${SDK_VERSION}_lite`), _registerComponent(new Component("firestore/lite", ((t, {options: e}) => {
|
|
5951
|
+
const n = t.getProvider("app").getImmediate(), r = new rn(n, new z(t.getProvider("auth-internal")), new Y(t.getProvider("app-check-internal")));
|
|
5952
|
+
return e && r._setSettings(e), r;
|
|
5946
5953
|
}), "PUBLIC")),
|
|
5947
5954
|
// RUNTIME_ENV and BUILD_TARGET are replaced by real values during the compilation
|
|
5948
|
-
registerVersion("firestore-lite", "3.4.4-canary.
|
|
5955
|
+
registerVersion("firestore-lite", "3.4.4-canary.e8972ef49", ""), registerVersion("firestore-lite", "3.4.4-canary.e8972ef49", "esm2017");
|
|
5949
5956
|
|
|
5950
|
-
export {
|
|
5957
|
+
export { gn as Bytes, ln as CollectionReference, an as DocumentReference, Yn as DocumentSnapshot, yn as FieldPath, vn as FieldValue, rn as Firestore, U as FirestoreError, bn as GeoPoint, hn as Query, Zn as QueryConstraint, Hn as QueryDocumentSnapshot, Kn as QuerySnapshot, gt as Timestamp, Ur as Transaction, $r as WriteBatch, Ar as addDoc, Dr as arrayRemove, Vr as arrayUnion, fn as collection, dn as collectionGroup, un as connectFirestoreEmulator, Ir as deleteDoc, Rr as deleteField, wn as doc, _n as documentId, dr as endAt, fr as endBefore, vr as getDoc, br as getDocs, on as getFirestore, Nr as increment, sn as initializeFirestore, or as limit, ur as limitToLast, sr as orderBy, tr as query, pn as queryEqual, mn as refEqual, kr as runTransaction, Pr as serverTimestamp, Er as setDoc, w as setLogLevel, Jn as snapshotEqual, hr as startAfter, ar as startAt, cn as terminate, Tr as updateDoc, nr as where, Fr as writeBatch };
|
|
5951
5958
|
//# sourceMappingURL=index.browser.esm2017.js.map
|