@firebase/firestore 3.1.0 → 3.1.1-canary.4594d3fd6
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/CHANGELOG.md +6 -0
- package/dist/firestore/src/register.d.ts +1 -1
- package/dist/firestore/src/remote/persistent_stream.d.ts +5 -1
- package/dist/firestore/src/util/async_queue.d.ts +4 -2
- package/dist/index.esm2017.js +2997 -2993
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +2861 -2851
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +7051 -9102
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/{index.node.cjs.esm2017.js → index.node.mjs} +56 -23
- package/dist/index.node.mjs.map +1 -0
- package/dist/index.rn.js +2973 -2965
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +4 -2
- package/dist/lite/firestore/src/register.d.ts +1 -1
- package/dist/lite/firestore/src/remote/persistent_stream.d.ts +5 -1
- package/dist/lite/firestore/src/util/async_queue.d.ts +4 -2
- package/dist/lite/index.browser.esm2017.js +1188 -1191
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +797 -796
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.node.cjs.js +1807 -2262
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/{index.node.esm2017.js → index.node.mjs} +6 -4
- package/dist/lite/index.node.mjs.map +1 -0
- package/dist/lite/index.rn.esm2017.js +11 -11
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +4 -2
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +115 -115
- package/dist/lite/packages/firestore/src/register.d.ts +1 -1
- package/dist/lite/packages/firestore/src/remote/persistent_stream.d.ts +5 -1
- package/dist/lite/packages/firestore/src/util/async_queue.d.ts +4 -2
- package/dist/lite/private.d.ts +4 -2
- package/dist/packages/firestore/dist/index.esm2017.d.ts +187 -187
- package/dist/packages/firestore/src/register.d.ts +1 -1
- package/dist/packages/firestore/src/remote/persistent_stream.d.ts +5 -1
- package/dist/packages/firestore/src/util/async_queue.d.ts +4 -2
- package/dist/private.d.ts +4 -2
- package/lite/package.json +1 -1
- package/package.json +22 -16
- package/dist/index.node.cjs.esm2017.js.map +0 -1
- package/dist/lite/firestore/dist/lite/index.node.esm2017.d.ts +0 -1195
- package/dist/lite/index.node.esm2017.js.map +0 -1
- package/dist/packages/firestore/dist/index.node.cjs.esm2017.d.ts +0 -1844
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { Logger as o, LogLevel as u } from "@firebase/logger";
|
|
6
|
-
|
|
7
|
-
import { createMockUserToken as c, getModularInstance as a } from "@firebase/util";
|
|
1
|
+
import { _registerComponent, registerVersion, _getProvider, getApp, _removeServiceInstance, SDK_VERSION } from '@firebase/app';
|
|
2
|
+
import { Component } from '@firebase/component';
|
|
3
|
+
import { Logger, LogLevel } from '@firebase/logger';
|
|
4
|
+
import { createMockUserToken, getModularInstance } from '@firebase/util';
|
|
8
5
|
|
|
9
6
|
/**
|
|
10
7
|
* @license
|
|
@@ -66,7 +63,7 @@ h.MOCK_USER = new h("mock-user");
|
|
|
66
63
|
* See the License for the specific language governing permissions and
|
|
67
64
|
* limitations under the License.
|
|
68
65
|
*/
|
|
69
|
-
let l = "9.1.
|
|
66
|
+
let l = "9.1.3-canary.4594d3fd6";
|
|
70
67
|
|
|
71
68
|
/**
|
|
72
69
|
* @license
|
|
@@ -84,7 +81,7 @@ let l = "9.1.0";
|
|
|
84
81
|
* See the License for the specific language governing permissions and
|
|
85
82
|
* limitations under the License.
|
|
86
83
|
*/
|
|
87
|
-
const f = new
|
|
84
|
+
const f = new Logger("@firebase/firestore");
|
|
88
85
|
|
|
89
86
|
/**
|
|
90
87
|
* Sets the verbosity of Cloud Firestore logs (debug, error, or silent).
|
|
@@ -102,26 +99,26 @@ const f = new o("@firebase/firestore");
|
|
|
102
99
|
f.setLogLevel(t);
|
|
103
100
|
}
|
|
104
101
|
|
|
105
|
-
function w(t, ...
|
|
106
|
-
if (f.logLevel <=
|
|
107
|
-
const
|
|
108
|
-
f.debug(`Firestore (${l}): ${t}`, ...
|
|
102
|
+
function w(t, ...n) {
|
|
103
|
+
if (f.logLevel <= LogLevel.DEBUG) {
|
|
104
|
+
const e = n.map(y);
|
|
105
|
+
f.debug(`Firestore (${l}): ${t}`, ...e);
|
|
109
106
|
}
|
|
110
107
|
}
|
|
111
108
|
|
|
112
|
-
function m(t, ...
|
|
113
|
-
if (f.logLevel <=
|
|
114
|
-
const
|
|
115
|
-
f.error(`Firestore (${l}): ${t}`, ...
|
|
109
|
+
function m(t, ...n) {
|
|
110
|
+
if (f.logLevel <= LogLevel.ERROR) {
|
|
111
|
+
const e = n.map(y);
|
|
112
|
+
f.error(`Firestore (${l}): ${t}`, ...e);
|
|
116
113
|
}
|
|
117
114
|
}
|
|
118
115
|
|
|
119
116
|
/**
|
|
120
117
|
* @internal
|
|
121
|
-
*/ function p(t, ...
|
|
122
|
-
if (f.logLevel <=
|
|
123
|
-
const
|
|
124
|
-
f.warn(`Firestore (${l}): ${t}`, ...
|
|
118
|
+
*/ function p(t, ...n) {
|
|
119
|
+
if (f.logLevel <= LogLevel.WARN) {
|
|
120
|
+
const e = n.map(y);
|
|
121
|
+
f.warn(`Firestore (${l}): ${t}`, ...e);
|
|
125
122
|
}
|
|
126
123
|
}
|
|
127
124
|
|
|
@@ -130,8 +127,8 @@ function m(t, ...e) {
|
|
|
130
127
|
*/ function y(t) {
|
|
131
128
|
if ("string" == typeof t) return t;
|
|
132
129
|
try {
|
|
133
|
-
return
|
|
134
|
-
} catch (
|
|
130
|
+
return n = t, JSON.stringify(n);
|
|
131
|
+
} catch (n) {
|
|
135
132
|
// Converting to JSON failed, just log the object directly
|
|
136
133
|
return t;
|
|
137
134
|
}
|
|
@@ -152,7 +149,7 @@ function m(t, ...e) {
|
|
|
152
149
|
* limitations under the License.
|
|
153
150
|
*/
|
|
154
151
|
/** Formats an object as a JSON string, suitable for logging. */
|
|
155
|
-
var
|
|
152
|
+
var n;
|
|
156
153
|
}
|
|
157
154
|
|
|
158
155
|
/**
|
|
@@ -181,11 +178,11 @@ function m(t, ...e) {
|
|
|
181
178
|
*/ function _(t = "Unexpected state") {
|
|
182
179
|
// Log the failure in addition to throw an exception, just in case the
|
|
183
180
|
// exception is swallowed.
|
|
184
|
-
const
|
|
181
|
+
const n = `FIRESTORE (${l}) INTERNAL ASSERTION FAILED: ` + t;
|
|
185
182
|
// NOTE: We don't use FirestoreError here because these are internal failures
|
|
186
183
|
// that cannot be handled by the user. (Also it would create a circular
|
|
187
184
|
// dependency between the error and assert modules which doesn't work.)
|
|
188
|
-
throw m(
|
|
185
|
+
throw m(n), new Error(n);
|
|
189
186
|
}
|
|
190
187
|
|
|
191
188
|
/**
|
|
@@ -193,7 +190,7 @@ function m(t, ...e) {
|
|
|
193
190
|
* given message if it did.
|
|
194
191
|
*
|
|
195
192
|
* Messages are stripped in production builds.
|
|
196
|
-
*/ function g(t,
|
|
193
|
+
*/ function g(t, n) {
|
|
197
194
|
t || _();
|
|
198
195
|
}
|
|
199
196
|
|
|
@@ -202,7 +199,7 @@ function m(t, ...e) {
|
|
|
202
199
|
* instance of `T` before casting.
|
|
203
200
|
*/ function b(t,
|
|
204
201
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
205
|
-
|
|
202
|
+
n) {
|
|
206
203
|
return t;
|
|
207
204
|
}
|
|
208
205
|
|
|
@@ -221,7 +218,7 @@ e) {
|
|
|
221
218
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
222
219
|
* See the License for the specific language governing permissions and
|
|
223
220
|
* limitations under the License.
|
|
224
|
-
*/ const v = "ok", E = "cancelled",
|
|
221
|
+
*/ const v = "ok", E = "cancelled", T = "unknown", I = "invalid-argument", A = "deadline-exceeded", P = "not-found", R = "already-exists", V = "permission-denied", D = "unauthenticated", N = "resource-exhausted", $ = "failed-precondition", F = "aborted", S = "out-of-range", q = "unimplemented", x = "internal", O = "unavailable", C = "data-loss";
|
|
225
222
|
|
|
226
223
|
/** An error returned by a Firestore operation. */ class L extends Error {
|
|
227
224
|
/** @hideconstructor */
|
|
@@ -233,8 +230,8 @@ e) {
|
|
|
233
230
|
/**
|
|
234
231
|
* A custom error description.
|
|
235
232
|
*/
|
|
236
|
-
|
|
237
|
-
super(
|
|
233
|
+
n) {
|
|
234
|
+
super(n), this.code = t, this.message = n,
|
|
238
235
|
/** The custom name for all FirestoreErrors. */
|
|
239
236
|
this.name = "FirebaseError",
|
|
240
237
|
// HACK: We write a toString property directly because Error is not a real
|
|
@@ -261,8 +258,8 @@ e) {
|
|
|
261
258
|
* limitations under the License.
|
|
262
259
|
*/ class U {
|
|
263
260
|
constructor() {
|
|
264
|
-
this.promise = new Promise(((t,
|
|
265
|
-
this.resolve = t, this.reject =
|
|
261
|
+
this.promise = new Promise(((t, n) => {
|
|
262
|
+
this.resolve = t, this.reject = n;
|
|
266
263
|
}));
|
|
267
264
|
}
|
|
268
265
|
}
|
|
@@ -283,8 +280,8 @@ e) {
|
|
|
283
280
|
* See the License for the specific language governing permissions and
|
|
284
281
|
* limitations under the License.
|
|
285
282
|
*/ class j {
|
|
286
|
-
constructor(t,
|
|
287
|
-
this.user =
|
|
283
|
+
constructor(t, n) {
|
|
284
|
+
this.user = n, this.type = "OAuth", this.authHeaders = {},
|
|
288
285
|
// Set the headers using Object Literal notation to avoid minification
|
|
289
286
|
this.authHeaders.Authorization = `Bearer ${t}`;
|
|
290
287
|
}
|
|
@@ -298,9 +295,9 @@ e) {
|
|
|
298
295
|
return Promise.resolve(null);
|
|
299
296
|
}
|
|
300
297
|
invalidateToken() {}
|
|
301
|
-
start(t,
|
|
298
|
+
start(t, n) {
|
|
302
299
|
// Fire with initial user.
|
|
303
|
-
t.enqueueRetryable((() =>
|
|
300
|
+
t.enqueueRetryable((() => n(h.UNAUTHENTICATED)));
|
|
304
301
|
}
|
|
305
302
|
shutdown() {}
|
|
306
303
|
}
|
|
@@ -308,7 +305,7 @@ e) {
|
|
|
308
305
|
/**
|
|
309
306
|
* A CredentialsProvider that always returns a constant token. Used for
|
|
310
307
|
* emulator token mocking.
|
|
311
|
-
*/ class
|
|
308
|
+
*/ class B {
|
|
312
309
|
constructor(t) {
|
|
313
310
|
this.token = t,
|
|
314
311
|
/**
|
|
@@ -322,17 +319,17 @@ e) {
|
|
|
322
319
|
return Promise.resolve(this.token);
|
|
323
320
|
}
|
|
324
321
|
invalidateToken() {}
|
|
325
|
-
start(t,
|
|
326
|
-
this.changeListener =
|
|
322
|
+
start(t, n) {
|
|
323
|
+
this.changeListener = n,
|
|
327
324
|
// Fire with initial user.
|
|
328
|
-
t.enqueueRetryable((() =>
|
|
325
|
+
t.enqueueRetryable((() => n(this.token.user)));
|
|
329
326
|
}
|
|
330
327
|
shutdown() {
|
|
331
328
|
this.changeListener = null;
|
|
332
329
|
}
|
|
333
330
|
}
|
|
334
331
|
|
|
335
|
-
/** Credential provider for the Lite SDK. */ class
|
|
332
|
+
/** Credential provider for the Lite SDK. */ class M {
|
|
336
333
|
constructor(t) {
|
|
337
334
|
this.auth = null, t.onInit((t => {
|
|
338
335
|
this.auth = t;
|
|
@@ -343,7 +340,7 @@ e) {
|
|
|
343
340
|
new j(t.accessToken, new h(this.auth.getUid()))) : null)) : Promise.resolve(null);
|
|
344
341
|
}
|
|
345
342
|
invalidateToken() {}
|
|
346
|
-
start(t,
|
|
343
|
+
start(t, n) {}
|
|
347
344
|
shutdown() {}
|
|
348
345
|
}
|
|
349
346
|
|
|
@@ -354,15 +351,15 @@ e) {
|
|
|
354
351
|
* recover from unauthenticated errors (see b/33147818 for context), but it's
|
|
355
352
|
* safer to keep the implementation as-is.
|
|
356
353
|
*/ class Q {
|
|
357
|
-
constructor(t,
|
|
358
|
-
this.t = t, this.i =
|
|
354
|
+
constructor(t, n, e) {
|
|
355
|
+
this.t = t, this.i = n, this.o = e, this.type = "FirstParty", this.user = h.FIRST_PARTY;
|
|
359
356
|
}
|
|
360
357
|
get authHeaders() {
|
|
361
358
|
const t = {
|
|
362
359
|
"X-Goog-AuthUser": this.i
|
|
363
|
-
},
|
|
360
|
+
}, n = this.t.auth.getAuthHeaderValueForFirstParty([]);
|
|
364
361
|
// Use array notation to prevent minification
|
|
365
|
-
return
|
|
362
|
+
return n && (t.Authorization = n), this.o && (t["X-Goog-Iam-Authorization-Token"] = this.o),
|
|
366
363
|
t;
|
|
367
364
|
}
|
|
368
365
|
}
|
|
@@ -372,15 +369,15 @@ e) {
|
|
|
372
369
|
* to authenticate the user, using technique that is only available
|
|
373
370
|
* to applications hosted by Google.
|
|
374
371
|
*/ class z {
|
|
375
|
-
constructor(t,
|
|
376
|
-
this.t = t, this.i =
|
|
372
|
+
constructor(t, n, e) {
|
|
373
|
+
this.t = t, this.i = n, this.o = e;
|
|
377
374
|
}
|
|
378
375
|
getToken() {
|
|
379
376
|
return Promise.resolve(new Q(this.t, this.i, this.o));
|
|
380
377
|
}
|
|
381
|
-
start(t,
|
|
378
|
+
start(t, n) {
|
|
382
379
|
// Fire with initial uid.
|
|
383
|
-
t.enqueueRetryable((() =>
|
|
380
|
+
t.enqueueRetryable((() => n(h.FIRST_PARTY)));
|
|
384
381
|
}
|
|
385
382
|
shutdown() {}
|
|
386
383
|
invalidateToken() {}
|
|
@@ -406,7 +403,7 @@ e) {
|
|
|
406
403
|
* See the License for the specific language governing permissions and
|
|
407
404
|
* limitations under the License.
|
|
408
405
|
*/
|
|
409
|
-
class
|
|
406
|
+
class G {
|
|
410
407
|
/**
|
|
411
408
|
* Constructs a DatabaseInfo using the provided host, databaseId and
|
|
412
409
|
* persistenceKey.
|
|
@@ -424,8 +421,8 @@ class W {
|
|
|
424
421
|
* @param useFetchStreams Whether to use the Fetch API instead of
|
|
425
422
|
* XMLHTTPRequest
|
|
426
423
|
*/
|
|
427
|
-
constructor(t,
|
|
428
|
-
this.databaseId = t, this.appId =
|
|
424
|
+
constructor(t, n, e, r, s, i, o, u) {
|
|
425
|
+
this.databaseId = t, this.appId = n, this.persistenceKey = e, this.host = r, this.ssl = s,
|
|
429
426
|
this.forceLongPolling = i, this.autoDetectLongPolling = o, this.useFetchStreams = u;
|
|
430
427
|
}
|
|
431
428
|
}
|
|
@@ -435,15 +432,15 @@ class W {
|
|
|
435
432
|
* Represents the database ID a Firestore client is associated with.
|
|
436
433
|
* @internal
|
|
437
434
|
*/
|
|
438
|
-
class
|
|
439
|
-
constructor(t,
|
|
440
|
-
this.projectId = t, this.database =
|
|
435
|
+
class W {
|
|
436
|
+
constructor(t, n) {
|
|
437
|
+
this.projectId = t, this.database = n || "(default)";
|
|
441
438
|
}
|
|
442
439
|
get isDefaultDatabase() {
|
|
443
440
|
return "(default)" === this.database;
|
|
444
441
|
}
|
|
445
442
|
isEqual(t) {
|
|
446
|
-
return t instanceof
|
|
443
|
+
return t instanceof W && t.projectId === this.projectId && t.database === this.database;
|
|
447
444
|
}
|
|
448
445
|
}
|
|
449
446
|
|
|
@@ -467,9 +464,9 @@ class G {
|
|
|
467
464
|
* Path represents an ordered sequence of string segments.
|
|
468
465
|
*/
|
|
469
466
|
class H {
|
|
470
|
-
constructor(t,
|
|
471
|
-
void 0 ===
|
|
472
|
-
this.segments = t, this.offset =
|
|
467
|
+
constructor(t, n, e) {
|
|
468
|
+
void 0 === n ? n = 0 : n > t.length && _(), void 0 === e ? e = t.length - n : e > t.length - n && _(),
|
|
469
|
+
this.segments = t, this.offset = n, this.len = e;
|
|
473
470
|
}
|
|
474
471
|
get length() {
|
|
475
472
|
return this.len;
|
|
@@ -478,10 +475,10 @@ class H {
|
|
|
478
475
|
return 0 === H.comparator(this, t);
|
|
479
476
|
}
|
|
480
477
|
child(t) {
|
|
481
|
-
const
|
|
478
|
+
const n = this.segments.slice(this.offset, this.limit());
|
|
482
479
|
return t instanceof H ? t.forEach((t => {
|
|
483
|
-
|
|
484
|
-
})) :
|
|
480
|
+
n.push(t);
|
|
481
|
+
})) : n.push(t), this.construct(n);
|
|
485
482
|
}
|
|
486
483
|
/** The index of one past the last segment of the path. */ limit() {
|
|
487
484
|
return this.offset + this.length;
|
|
@@ -506,28 +503,28 @@ class H {
|
|
|
506
503
|
}
|
|
507
504
|
isPrefixOf(t) {
|
|
508
505
|
if (t.length < this.length) return !1;
|
|
509
|
-
for (let
|
|
506
|
+
for (let n = 0; n < this.length; n++) if (this.get(n) !== t.get(n)) return !1;
|
|
510
507
|
return !0;
|
|
511
508
|
}
|
|
512
509
|
isImmediateParentOf(t) {
|
|
513
510
|
if (this.length + 1 !== t.length) return !1;
|
|
514
|
-
for (let
|
|
511
|
+
for (let n = 0; n < this.length; n++) if (this.get(n) !== t.get(n)) return !1;
|
|
515
512
|
return !0;
|
|
516
513
|
}
|
|
517
514
|
forEach(t) {
|
|
518
|
-
for (let
|
|
515
|
+
for (let n = this.offset, e = this.limit(); n < e; n++) t(this.segments[n]);
|
|
519
516
|
}
|
|
520
517
|
toArray() {
|
|
521
518
|
return this.segments.slice(this.offset, this.limit());
|
|
522
519
|
}
|
|
523
|
-
static comparator(t,
|
|
524
|
-
const
|
|
525
|
-
for (let r = 0; r <
|
|
526
|
-
const
|
|
527
|
-
if (
|
|
528
|
-
if (
|
|
520
|
+
static comparator(t, n) {
|
|
521
|
+
const e = Math.min(t.length, n.length);
|
|
522
|
+
for (let r = 0; r < e; r++) {
|
|
523
|
+
const e = t.get(r), s = n.get(r);
|
|
524
|
+
if (e < s) return -1;
|
|
525
|
+
if (e > s) return 1;
|
|
529
526
|
}
|
|
530
|
-
return t.length <
|
|
527
|
+
return t.length < n.length ? -1 : t.length > n.length ? 1 : 0;
|
|
531
528
|
}
|
|
532
529
|
}
|
|
533
530
|
|
|
@@ -537,8 +534,8 @@ class H {
|
|
|
537
534
|
*
|
|
538
535
|
* @internal
|
|
539
536
|
*/ class Y extends H {
|
|
540
|
-
construct(t,
|
|
541
|
-
return new Y(t,
|
|
537
|
+
construct(t, n, e) {
|
|
538
|
+
return new Y(t, n, e);
|
|
542
539
|
}
|
|
543
540
|
canonicalString() {
|
|
544
541
|
// NOTE: The client is ignorant of any path segments containing escape
|
|
@@ -557,13 +554,13 @@ class H {
|
|
|
557
554
|
// NOTE: The client is ignorant of any path segments containing escape
|
|
558
555
|
// sequences (e.g. __id123__) and just passes them through raw (they exist
|
|
559
556
|
// for legacy reasons and should not be used frequently).
|
|
560
|
-
const
|
|
561
|
-
for (const
|
|
562
|
-
if (
|
|
557
|
+
const n = [];
|
|
558
|
+
for (const e of t) {
|
|
559
|
+
if (e.indexOf("//") >= 0) throw new L(I, `Invalid segment (${e}). Paths must not contain // in them.`);
|
|
563
560
|
// Strip leading and traling slashed.
|
|
564
|
-
|
|
561
|
+
n.push(...e.split("/").filter((t => t.length > 0)));
|
|
565
562
|
}
|
|
566
|
-
return new Y(
|
|
563
|
+
return new Y(n);
|
|
567
564
|
}
|
|
568
565
|
static emptyPath() {
|
|
569
566
|
return new Y([]);
|
|
@@ -576,8 +573,8 @@ const K = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
576
573
|
* A dot-separated path for navigating sub-objects within a document.
|
|
577
574
|
* @internal
|
|
578
575
|
*/ class J extends H {
|
|
579
|
-
construct(t,
|
|
580
|
-
return new J(t,
|
|
576
|
+
construct(t, n, e) {
|
|
577
|
+
return new J(t, n, e);
|
|
581
578
|
}
|
|
582
579
|
/**
|
|
583
580
|
* Returns true if the string could be used as a segment in a field path
|
|
@@ -612,24 +609,24 @@ const K = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
612
609
|
* TODO(b/37244157): we should make this more strict. Right now, it allows
|
|
613
610
|
* non-identifier path components, even if they aren't escaped.
|
|
614
611
|
*/ static fromServerFormat(t) {
|
|
615
|
-
const
|
|
616
|
-
let
|
|
612
|
+
const n = [];
|
|
613
|
+
let e = "", r = 0;
|
|
617
614
|
const s = () => {
|
|
618
|
-
if (0 ===
|
|
619
|
-
|
|
615
|
+
if (0 === e.length) throw new L(I, `Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);
|
|
616
|
+
n.push(e), e = "";
|
|
620
617
|
};
|
|
621
618
|
let i = !1;
|
|
622
619
|
for (;r < t.length; ) {
|
|
623
|
-
const
|
|
624
|
-
if ("\\" ===
|
|
625
|
-
if (r + 1 === t.length) throw new L(
|
|
626
|
-
const
|
|
627
|
-
if ("\\" !==
|
|
628
|
-
|
|
629
|
-
} else "`" ===
|
|
620
|
+
const n = t[r];
|
|
621
|
+
if ("\\" === n) {
|
|
622
|
+
if (r + 1 === t.length) throw new L(I, "Path has trailing escape character: " + t);
|
|
623
|
+
const n = t[r + 1];
|
|
624
|
+
if ("\\" !== n && "." !== n && "`" !== n) throw new L(I, "Path has invalid escape sequence: " + t);
|
|
625
|
+
e += n, r += 2;
|
|
626
|
+
} else "`" === n ? (i = !i, r++) : "." !== n || i ? (e += n, r++) : (s(), r++);
|
|
630
627
|
}
|
|
631
|
-
if (s(), i) throw new L(
|
|
632
|
-
return new J(
|
|
628
|
+
if (s(), i) throw new L(I, "Unterminated ` in path: " + t);
|
|
629
|
+
return new J(n);
|
|
633
630
|
}
|
|
634
631
|
static emptyPath() {
|
|
635
632
|
return new J([]);
|
|
@@ -673,8 +670,8 @@ const K = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
673
670
|
toString() {
|
|
674
671
|
return this.path.toString();
|
|
675
672
|
}
|
|
676
|
-
static comparator(t,
|
|
677
|
-
return Y.comparator(t.path,
|
|
673
|
+
static comparator(t, n) {
|
|
674
|
+
return Y.comparator(t.path, n.path);
|
|
678
675
|
}
|
|
679
676
|
static isDocumentKey(t) {
|
|
680
677
|
return t.length % 2 == 0;
|
|
@@ -704,8 +701,8 @@ const K = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
704
701
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
705
702
|
* See the License for the specific language governing permissions and
|
|
706
703
|
* limitations under the License.
|
|
707
|
-
*/ function X(t,
|
|
708
|
-
if (!
|
|
704
|
+
*/ function X(t, n, e) {
|
|
705
|
+
if (!e) throw new L(I, `Function ${t}() cannot be called with an empty ${n}.`);
|
|
709
706
|
}
|
|
710
707
|
|
|
711
708
|
/**
|
|
@@ -717,14 +714,14 @@ const K = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
717
714
|
* an even numbers of segments).
|
|
718
715
|
*/
|
|
719
716
|
function tt(t) {
|
|
720
|
-
if (!Z.isDocumentKey(t)) throw new L(
|
|
717
|
+
if (!Z.isDocumentKey(t)) throw new L(I, `Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`);
|
|
721
718
|
}
|
|
722
719
|
|
|
723
720
|
/**
|
|
724
721
|
* Validates that `path` refers to a collection (indicated by the fact it
|
|
725
722
|
* contains an odd numbers of segments).
|
|
726
|
-
*/ function
|
|
727
|
-
if (Z.isDocumentKey(t)) throw new L(
|
|
723
|
+
*/ function nt(t) {
|
|
724
|
+
if (Z.isDocumentKey(t)) throw new L(I, `Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`);
|
|
728
725
|
}
|
|
729
726
|
|
|
730
727
|
/**
|
|
@@ -732,7 +729,7 @@ function tt(t) {
|
|
|
732
729
|
* (i.e. excludes Array, Date, etc.).
|
|
733
730
|
*/
|
|
734
731
|
/** Returns a string describing the type / value of the provided input. */
|
|
735
|
-
function
|
|
732
|
+
function et(t) {
|
|
736
733
|
if (void 0 === t) return "undefined";
|
|
737
734
|
if (null === t) return "null";
|
|
738
735
|
if ("string" == typeof t) return t.length > 20 && (t = `${t.substring(0, 20)}...`),
|
|
@@ -741,7 +738,7 @@ function nt(t) {
|
|
|
741
738
|
if ("object" == typeof t) {
|
|
742
739
|
if (t instanceof Array) return "an array";
|
|
743
740
|
{
|
|
744
|
-
const
|
|
741
|
+
const n =
|
|
745
742
|
/** try to get the constructor name for an object. */
|
|
746
743
|
function(t) {
|
|
747
744
|
if (t.constructor) return t.constructor.name;
|
|
@@ -755,7 +752,7 @@ function nt(t) {
|
|
|
755
752
|
* arguments passed to the public API.
|
|
756
753
|
* @internal
|
|
757
754
|
*/ (t);
|
|
758
|
-
return
|
|
755
|
+
return n ? `a custom ${n} object` : "an object";
|
|
759
756
|
}
|
|
760
757
|
}
|
|
761
758
|
return "function" == typeof t ? "a function" : _();
|
|
@@ -763,22 +760,22 @@ function nt(t) {
|
|
|
763
760
|
|
|
764
761
|
function rt(t,
|
|
765
762
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
766
|
-
|
|
763
|
+
n) {
|
|
767
764
|
if ("_delegate" in t && (
|
|
768
765
|
// Unwrap Compat types
|
|
769
766
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
770
|
-
t = t._delegate), !(t instanceof
|
|
771
|
-
if (
|
|
767
|
+
t = t._delegate), !(t instanceof n)) {
|
|
768
|
+
if (n.name === t.constructor.name) throw new L(I, "Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");
|
|
772
769
|
{
|
|
773
|
-
const
|
|
774
|
-
throw new L(
|
|
770
|
+
const e = et(t);
|
|
771
|
+
throw new L(I, `Expected type '${n.name}', but it was: ${e}`);
|
|
775
772
|
}
|
|
776
773
|
}
|
|
777
774
|
return t;
|
|
778
775
|
}
|
|
779
776
|
|
|
780
|
-
function st(t,
|
|
781
|
-
if (
|
|
777
|
+
function st(t, n) {
|
|
778
|
+
if (n <= 0) throw new L(I, `Function ${t}() requires a positive number, but it was: ${n}.`);
|
|
782
779
|
}
|
|
783
780
|
|
|
784
781
|
/**
|
|
@@ -876,7 +873,7 @@ var ct, at;
|
|
|
876
873
|
* Code.UNKNOWN.
|
|
877
874
|
*/
|
|
878
875
|
function ht(t) {
|
|
879
|
-
if (void 0 === t) return m("RPC_ERROR", "HTTP error has no status"),
|
|
876
|
+
if (void 0 === t) return m("RPC_ERROR", "HTTP error has no status"), T;
|
|
880
877
|
// The canonical error codes for Google APIs [1] specify mapping onto HTTP
|
|
881
878
|
// status codes but the mapping is not bijective. In each case of ambiguity
|
|
882
879
|
// this function chooses a primary error.
|
|
@@ -897,7 +894,7 @@ function ht(t) {
|
|
|
897
894
|
// return Code.OUT_OF_RANGE;
|
|
898
895
|
case 401:
|
|
899
896
|
// Unauthorized
|
|
900
|
-
return
|
|
897
|
+
return D;
|
|
901
898
|
|
|
902
899
|
case 403:
|
|
903
900
|
// Forbidden
|
|
@@ -919,7 +916,7 @@ function ht(t) {
|
|
|
919
916
|
|
|
920
917
|
case 429:
|
|
921
918
|
// Too Many Requests
|
|
922
|
-
return
|
|
919
|
+
return N;
|
|
923
920
|
|
|
924
921
|
case 499:
|
|
925
922
|
// Client Closed Request
|
|
@@ -927,7 +924,7 @@ function ht(t) {
|
|
|
927
924
|
|
|
928
925
|
case 500:
|
|
929
926
|
// Internal Server Error
|
|
930
|
-
return
|
|
927
|
+
return T;
|
|
931
928
|
|
|
932
929
|
// Other possibilities:
|
|
933
930
|
// return Code.INTERNAL;
|
|
@@ -945,7 +942,7 @@ function ht(t) {
|
|
|
945
942
|
return A;
|
|
946
943
|
|
|
947
944
|
default:
|
|
948
|
-
return t >= 200 && t < 300 ? v : t >= 400 && t < 500 ? $ : t >= 500 && t < 600 ? x :
|
|
945
|
+
return t >= 200 && t < 300 ? v : t >= 400 && t < 500 ? $ : t >= 500 && t < 600 ? x : T;
|
|
949
946
|
}
|
|
950
947
|
}
|
|
951
948
|
|
|
@@ -985,58 +982,58 @@ class lt extends
|
|
|
985
982
|
class {
|
|
986
983
|
constructor(t) {
|
|
987
984
|
this.databaseInfo = t, this.databaseId = t.databaseId;
|
|
988
|
-
const
|
|
989
|
-
this.u =
|
|
985
|
+
const n = t.ssl ? "https" : "http";
|
|
986
|
+
this.u = n + "://" + t.host, this.h = "projects/" + this.databaseId.projectId + "/databases/" + this.databaseId.database + "/documents";
|
|
990
987
|
}
|
|
991
|
-
l(t,
|
|
992
|
-
const s = this.m(t,
|
|
993
|
-
w("RestConnection", "Sending: ", s,
|
|
988
|
+
l(t, n, e, r) {
|
|
989
|
+
const s = this.m(t, n);
|
|
990
|
+
w("RestConnection", "Sending: ", s, e);
|
|
994
991
|
const i = {};
|
|
995
|
-
return this.p(i, r), this.g(t, s, i,
|
|
996
|
-
t)), (
|
|
997
|
-
throw p("RestConnection", `${t} failed with error: `,
|
|
998
|
-
|
|
992
|
+
return this.p(i, r), this.g(t, s, i, e).then((t => (w("RestConnection", "Received: ", t),
|
|
993
|
+
t)), (n => {
|
|
994
|
+
throw p("RestConnection", `${t} failed with error: `, n, "url: ", s, "request:", e),
|
|
995
|
+
n;
|
|
999
996
|
}));
|
|
1000
997
|
}
|
|
1001
|
-
v(t,
|
|
998
|
+
v(t, n, e, r) {
|
|
1002
999
|
// The REST API automatically aggregates all of the streamed results, so we
|
|
1003
1000
|
// can just use the normal invoke() method.
|
|
1004
|
-
return this.l(t,
|
|
1001
|
+
return this.l(t, n, e, r);
|
|
1005
1002
|
}
|
|
1006
1003
|
/**
|
|
1007
1004
|
* Modifies the headers for a request, adding any authorization token if
|
|
1008
1005
|
* present and any additional headers for the request.
|
|
1009
|
-
*/ p(t,
|
|
1006
|
+
*/ p(t, n) {
|
|
1010
1007
|
if (t["X-Goog-Api-Client"] = "gl-js/ fire/" + l,
|
|
1011
1008
|
// Content-Type: text/plain will avoid preflight requests which might
|
|
1012
1009
|
// mess with CORS and redirects by proxies. If we add custom headers
|
|
1013
1010
|
// we will need to change this code to potentially use the $httpOverwrite
|
|
1014
1011
|
// parameter supported by ESF to avoid triggering preflight requests.
|
|
1015
1012
|
t["Content-Type"] = "text/plain", this.databaseInfo.appId && (t["X-Firebase-GMPID"] = this.databaseInfo.appId),
|
|
1016
|
-
|
|
1013
|
+
n) for (const e in n.authHeaders) n.authHeaders.hasOwnProperty(e) && (t[e] = n.authHeaders[e]);
|
|
1017
1014
|
}
|
|
1018
|
-
m(t,
|
|
1019
|
-
const
|
|
1020
|
-
return `${this.u}/v1/${
|
|
1015
|
+
m(t, n) {
|
|
1016
|
+
const e = ut[t];
|
|
1017
|
+
return `${this.u}/v1/${n}:${e}`;
|
|
1021
1018
|
}
|
|
1022
1019
|
} {
|
|
1023
1020
|
/**
|
|
1024
1021
|
* @param databaseInfo - The connection info.
|
|
1025
1022
|
* @param fetchImpl - `fetch` or a Polyfill that implements the fetch API.
|
|
1026
1023
|
*/
|
|
1027
|
-
constructor(t,
|
|
1028
|
-
super(t), this.
|
|
1024
|
+
constructor(t, n) {
|
|
1025
|
+
super(t), this.T = n;
|
|
1029
1026
|
}
|
|
1030
|
-
|
|
1027
|
+
I(t, n) {
|
|
1031
1028
|
throw new Error("Not supported by FetchConnection");
|
|
1032
1029
|
}
|
|
1033
|
-
async g(t,
|
|
1030
|
+
async g(t, n, e, r) {
|
|
1034
1031
|
const s = JSON.stringify(r);
|
|
1035
1032
|
let i;
|
|
1036
1033
|
try {
|
|
1037
|
-
i = await this.
|
|
1034
|
+
i = await this.T(n, {
|
|
1038
1035
|
method: "POST",
|
|
1039
|
-
headers:
|
|
1036
|
+
headers: e,
|
|
1040
1037
|
body: s
|
|
1041
1038
|
});
|
|
1042
1039
|
} catch (t) {
|
|
@@ -1087,13 +1084,13 @@ class {
|
|
|
1087
1084
|
*/
|
|
1088
1085
|
function ft(t) {
|
|
1089
1086
|
// Polyfills for IE and WebWorker by using `self` and `msCrypto` when `crypto` is not available.
|
|
1090
|
-
const
|
|
1087
|
+
const n =
|
|
1091
1088
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1092
|
-
"undefined" != typeof self && (self.crypto || self.msCrypto),
|
|
1093
|
-
if (
|
|
1089
|
+
"undefined" != typeof self && (self.crypto || self.msCrypto), e = new Uint8Array(t);
|
|
1090
|
+
if (n && "function" == typeof n.getRandomValues) n.getRandomValues(e); else
|
|
1094
1091
|
// Falls back to Math.random
|
|
1095
|
-
for (let
|
|
1096
|
-
return
|
|
1092
|
+
for (let n = 0; n < t; n++) e[n] = Math.floor(256 * Math.random());
|
|
1093
|
+
return e;
|
|
1097
1094
|
}
|
|
1098
1095
|
|
|
1099
1096
|
/**
|
|
@@ -1114,26 +1111,26 @@ function ft(t) {
|
|
|
1114
1111
|
*/ class dt {
|
|
1115
1112
|
static A() {
|
|
1116
1113
|
// Alphanumeric characters
|
|
1117
|
-
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
|
|
1114
|
+
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", n = Math.floor(256 / t.length) * t.length;
|
|
1118
1115
|
// The largest byte value that is a multiple of `char.length`.
|
|
1119
|
-
let
|
|
1120
|
-
for (;
|
|
1116
|
+
let e = "";
|
|
1117
|
+
for (;e.length < 20; ) {
|
|
1121
1118
|
const r = ft(40);
|
|
1122
1119
|
for (let s = 0; s < r.length; ++s)
|
|
1123
1120
|
// Only accept values that are [0, maxMultiple), this ensures they can
|
|
1124
1121
|
// be evenly mapped to indices of `chars` via a modulo operation.
|
|
1125
|
-
|
|
1122
|
+
e.length < 20 && r[s] < n && (e += t.charAt(r[s] % t.length));
|
|
1126
1123
|
}
|
|
1127
|
-
return
|
|
1124
|
+
return e;
|
|
1128
1125
|
}
|
|
1129
1126
|
}
|
|
1130
1127
|
|
|
1131
|
-
function wt(t,
|
|
1132
|
-
return t <
|
|
1128
|
+
function wt(t, n) {
|
|
1129
|
+
return t < n ? -1 : t > n ? 1 : 0;
|
|
1133
1130
|
}
|
|
1134
1131
|
|
|
1135
|
-
/** Helper to compare arrays using isEqual(). */ function mt(t,
|
|
1136
|
-
return t.length ===
|
|
1132
|
+
/** Helper to compare arrays using isEqual(). */ function mt(t, n, e) {
|
|
1133
|
+
return t.length === n.length && t.every(((t, r) => e(t, n[r])));
|
|
1137
1134
|
}
|
|
1138
1135
|
|
|
1139
1136
|
/**
|
|
@@ -1187,12 +1184,12 @@ class pt {
|
|
|
1187
1184
|
/**
|
|
1188
1185
|
* The fractions of a second at nanosecond resolution.*
|
|
1189
1186
|
*/
|
|
1190
|
-
|
|
1191
|
-
if (this.seconds = t, this.nanoseconds =
|
|
1192
|
-
if (
|
|
1193
|
-
if (t < -62135596800) throw new L(
|
|
1187
|
+
n) {
|
|
1188
|
+
if (this.seconds = t, this.nanoseconds = n, n < 0) throw new L(I, "Timestamp nanoseconds out of range: " + n);
|
|
1189
|
+
if (n >= 1e9) throw new L(I, "Timestamp nanoseconds out of range: " + n);
|
|
1190
|
+
if (t < -62135596800) throw new L(I, "Timestamp seconds out of range: " + t);
|
|
1194
1191
|
// This will break in the year 10,000.
|
|
1195
|
-
if (t >= 253402300800) throw new L(
|
|
1192
|
+
if (t >= 253402300800) throw new L(I, "Timestamp seconds out of range: " + t);
|
|
1196
1193
|
}
|
|
1197
1194
|
/**
|
|
1198
1195
|
* Creates a new timestamp with the current date, with millisecond precision.
|
|
@@ -1218,8 +1215,8 @@ class pt {
|
|
|
1218
1215
|
* @returns A new `Timestamp` representing the same point in time as the given
|
|
1219
1216
|
* number of milliseconds.
|
|
1220
1217
|
*/ static fromMillis(t) {
|
|
1221
|
-
const
|
|
1222
|
-
return new pt(
|
|
1218
|
+
const n = Math.floor(t / 1e3), e = Math.floor(1e6 * (t - 1e3 * n));
|
|
1219
|
+
return new pt(n, e);
|
|
1223
1220
|
}
|
|
1224
1221
|
/**
|
|
1225
1222
|
* Converts a `Timestamp` to a JavaScript `Date` object. This conversion
|
|
@@ -1341,13 +1338,13 @@ class pt {
|
|
|
1341
1338
|
* See the License for the specific language governing permissions and
|
|
1342
1339
|
* limitations under the License.
|
|
1343
1340
|
*/ function _t(t) {
|
|
1344
|
-
let
|
|
1345
|
-
for (const
|
|
1346
|
-
return
|
|
1341
|
+
let n = 0;
|
|
1342
|
+
for (const e in t) Object.prototype.hasOwnProperty.call(t, e) && n++;
|
|
1343
|
+
return n;
|
|
1347
1344
|
}
|
|
1348
1345
|
|
|
1349
|
-
function gt(t,
|
|
1350
|
-
for (const
|
|
1346
|
+
function gt(t, n) {
|
|
1347
|
+
for (const e in t) Object.prototype.hasOwnProperty.call(t, e) && n(e, t[e]);
|
|
1351
1348
|
}
|
|
1352
1349
|
|
|
1353
1350
|
/**
|
|
@@ -1389,11 +1386,11 @@ class bt {
|
|
|
1389
1386
|
*
|
|
1390
1387
|
* This is an O(n) operation, where `n` is the size of the field mask.
|
|
1391
1388
|
*/ covers(t) {
|
|
1392
|
-
for (const
|
|
1389
|
+
for (const n of this.fields) if (n.isPrefixOf(t)) return !0;
|
|
1393
1390
|
return !1;
|
|
1394
1391
|
}
|
|
1395
1392
|
isEqual(t) {
|
|
1396
|
-
return mt(this.fields, t.fields, ((t,
|
|
1393
|
+
return mt(this.fields, t.fields, ((t, n) => t.isEqual(n)));
|
|
1397
1394
|
}
|
|
1398
1395
|
}
|
|
1399
1396
|
|
|
@@ -1444,23 +1441,23 @@ class vt {
|
|
|
1444
1441
|
this.binaryString = t;
|
|
1445
1442
|
}
|
|
1446
1443
|
static fromBase64String(t) {
|
|
1447
|
-
const
|
|
1448
|
-
return new vt(
|
|
1444
|
+
const n = atob(t);
|
|
1445
|
+
return new vt(n);
|
|
1449
1446
|
}
|
|
1450
1447
|
static fromUint8Array(t) {
|
|
1451
|
-
const
|
|
1448
|
+
const n =
|
|
1452
1449
|
/**
|
|
1453
1450
|
* Helper function to convert an Uint8array to a binary string.
|
|
1454
1451
|
*/
|
|
1455
1452
|
function(t) {
|
|
1456
|
-
let
|
|
1457
|
-
for (let
|
|
1458
|
-
return
|
|
1453
|
+
let n = "";
|
|
1454
|
+
for (let e = 0; e < t.length; ++e) n += String.fromCharCode(t[e]);
|
|
1455
|
+
return n;
|
|
1459
1456
|
}
|
|
1460
1457
|
/**
|
|
1461
1458
|
* Helper function to convert a binary string to an Uint8Array.
|
|
1462
1459
|
*/ (t);
|
|
1463
|
-
return new vt(
|
|
1460
|
+
return new vt(n);
|
|
1464
1461
|
}
|
|
1465
1462
|
toBase64() {
|
|
1466
1463
|
return t = this.binaryString, btoa(t);
|
|
@@ -1469,9 +1466,9 @@ class vt {
|
|
|
1469
1466
|
}
|
|
1470
1467
|
toUint8Array() {
|
|
1471
1468
|
return function(t) {
|
|
1472
|
-
const
|
|
1473
|
-
for (let
|
|
1474
|
-
return
|
|
1469
|
+
const n = new Uint8Array(t.length);
|
|
1470
|
+
for (let e = 0; e < t.length; e++) n[e] = t.charCodeAt(e);
|
|
1471
|
+
return n;
|
|
1475
1472
|
}
|
|
1476
1473
|
/**
|
|
1477
1474
|
* @license
|
|
@@ -1510,7 +1507,7 @@ const Et = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1510
1507
|
/**
|
|
1511
1508
|
* Converts the possible Proto values for a timestamp value into a "seconds and
|
|
1512
1509
|
* nanos" representation.
|
|
1513
|
-
*/ function
|
|
1510
|
+
*/ function Tt(t) {
|
|
1514
1511
|
// The json interface (for the browser) will return an iso timestamp string,
|
|
1515
1512
|
// while the proto js library (for node) will return a
|
|
1516
1513
|
// google.protobuf.Timestamp instance.
|
|
@@ -1518,30 +1515,30 @@ const Et = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1518
1515
|
// The date string can have higher precision (nanos) than the Date class
|
|
1519
1516
|
// (millis), so we do some custom parsing here.
|
|
1520
1517
|
// Parse the nanos right out of the string.
|
|
1521
|
-
let
|
|
1522
|
-
const
|
|
1523
|
-
if (g(!!
|
|
1518
|
+
let n = 0;
|
|
1519
|
+
const e = Et.exec(t);
|
|
1520
|
+
if (g(!!e), e[1]) {
|
|
1524
1521
|
// Pad the fraction out to 9 digits (nanos).
|
|
1525
|
-
let t =
|
|
1526
|
-
t = (t + "000000000").substr(0, 9),
|
|
1522
|
+
let t = e[1];
|
|
1523
|
+
t = (t + "000000000").substr(0, 9), n = Number(t);
|
|
1527
1524
|
}
|
|
1528
1525
|
// Parse the date to get the seconds.
|
|
1529
1526
|
const r = new Date(t);
|
|
1530
1527
|
return {
|
|
1531
1528
|
seconds: Math.floor(r.getTime() / 1e3),
|
|
1532
|
-
nanos:
|
|
1529
|
+
nanos: n
|
|
1533
1530
|
};
|
|
1534
1531
|
}
|
|
1535
1532
|
return {
|
|
1536
|
-
seconds:
|
|
1537
|
-
nanos:
|
|
1533
|
+
seconds: It(t.seconds),
|
|
1534
|
+
nanos: It(t.nanos)
|
|
1538
1535
|
};
|
|
1539
1536
|
}
|
|
1540
1537
|
|
|
1541
1538
|
/**
|
|
1542
1539
|
* Converts the possible Proto types for numbers into a JavaScript number.
|
|
1543
1540
|
* Returns 0 if the value is not numeric.
|
|
1544
|
-
*/ function
|
|
1541
|
+
*/ function It(t) {
|
|
1545
1542
|
// TODO(bjornick): Handle int64 greater than 53 bits.
|
|
1546
1543
|
return "number" == typeof t ? t : "string" == typeof t ? Number(t) : 0;
|
|
1547
1544
|
}
|
|
@@ -1584,8 +1581,8 @@ const Et = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1584
1581
|
* - With respect to other ServerTimestampValues, they sort by their
|
|
1585
1582
|
* localWriteTime.
|
|
1586
1583
|
*/ function Pt(t) {
|
|
1587
|
-
var
|
|
1588
|
-
return "server_timestamp" === (null === (
|
|
1584
|
+
var n, e;
|
|
1585
|
+
return "server_timestamp" === (null === (e = ((null === (n = null == t ? void 0 : t.mapValue) || void 0 === n ? void 0 : n.fields) || {}).__type__) || void 0 === e ? void 0 : e.stringValue);
|
|
1589
1586
|
}
|
|
1590
1587
|
|
|
1591
1588
|
/**
|
|
@@ -1594,15 +1591,15 @@ const Et = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1594
1591
|
* Preserving the previous values allows the user to display the last resoled
|
|
1595
1592
|
* value until the backend responds with the timestamp.
|
|
1596
1593
|
*/ function Rt(t) {
|
|
1597
|
-
const
|
|
1598
|
-
return Pt(
|
|
1594
|
+
const n = t.mapValue.fields.__previous_value__;
|
|
1595
|
+
return Pt(n) ? Rt(n) : n;
|
|
1599
1596
|
}
|
|
1600
1597
|
|
|
1601
1598
|
/**
|
|
1602
1599
|
* Returns the local time at which this timestamp was first set.
|
|
1603
1600
|
*/ function Vt(t) {
|
|
1604
|
-
const
|
|
1605
|
-
return new pt(
|
|
1601
|
+
const n = Tt(t.mapValue.fields.__local_write_time__.timestampValue);
|
|
1602
|
+
return new pt(n.seconds, n.nanos);
|
|
1606
1603
|
}
|
|
1607
1604
|
|
|
1608
1605
|
/**
|
|
@@ -1621,171 +1618,171 @@ const Et = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1621
1618
|
* See the License for the specific language governing permissions and
|
|
1622
1619
|
* limitations under the License.
|
|
1623
1620
|
*/
|
|
1624
|
-
/** Extracts the backend's type order for the provided value. */ function
|
|
1621
|
+
/** Extracts the backend's type order for the provided value. */ function Dt(t) {
|
|
1625
1622
|
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 ? Pt(t) ? 4 /* ServerTimestampValue */ : 10 /* ObjectValue */ : _();
|
|
1626
1623
|
}
|
|
1627
1624
|
|
|
1628
|
-
/** Tests `left` and `right` for equality based on the backend semantics. */ function
|
|
1629
|
-
const
|
|
1630
|
-
if (
|
|
1631
|
-
switch (
|
|
1625
|
+
/** Tests `left` and `right` for equality based on the backend semantics. */ function Nt(t, n) {
|
|
1626
|
+
const e = Dt(t);
|
|
1627
|
+
if (e !== Dt(n)) return !1;
|
|
1628
|
+
switch (e) {
|
|
1632
1629
|
case 0 /* NullValue */ :
|
|
1633
1630
|
return !0;
|
|
1634
1631
|
|
|
1635
1632
|
case 1 /* BooleanValue */ :
|
|
1636
|
-
return t.booleanValue ===
|
|
1633
|
+
return t.booleanValue === n.booleanValue;
|
|
1637
1634
|
|
|
1638
1635
|
case 4 /* ServerTimestampValue */ :
|
|
1639
|
-
return Vt(t).isEqual(Vt(
|
|
1636
|
+
return Vt(t).isEqual(Vt(n));
|
|
1640
1637
|
|
|
1641
1638
|
case 3 /* TimestampValue */ :
|
|
1642
|
-
return function(t,
|
|
1643
|
-
if ("string" == typeof t.timestampValue && "string" == typeof
|
|
1639
|
+
return function(t, n) {
|
|
1640
|
+
if ("string" == typeof t.timestampValue && "string" == typeof n.timestampValue && t.timestampValue.length === n.timestampValue.length)
|
|
1644
1641
|
// Use string equality for ISO 8601 timestamps
|
|
1645
|
-
return t.timestampValue ===
|
|
1646
|
-
const
|
|
1647
|
-
return
|
|
1648
|
-
}(t,
|
|
1642
|
+
return t.timestampValue === n.timestampValue;
|
|
1643
|
+
const e = Tt(t.timestampValue), r = Tt(n.timestampValue);
|
|
1644
|
+
return e.seconds === r.seconds && e.nanos === r.nanos;
|
|
1645
|
+
}(t, n);
|
|
1649
1646
|
|
|
1650
1647
|
case 5 /* StringValue */ :
|
|
1651
|
-
return t.stringValue ===
|
|
1648
|
+
return t.stringValue === n.stringValue;
|
|
1652
1649
|
|
|
1653
1650
|
case 6 /* BlobValue */ :
|
|
1654
|
-
return function(t,
|
|
1655
|
-
return At(t.bytesValue).isEqual(At(
|
|
1656
|
-
}(t,
|
|
1651
|
+
return function(t, n) {
|
|
1652
|
+
return At(t.bytesValue).isEqual(At(n.bytesValue));
|
|
1653
|
+
}(t, n);
|
|
1657
1654
|
|
|
1658
1655
|
case 7 /* RefValue */ :
|
|
1659
|
-
return t.referenceValue ===
|
|
1656
|
+
return t.referenceValue === n.referenceValue;
|
|
1660
1657
|
|
|
1661
1658
|
case 8 /* GeoPointValue */ :
|
|
1662
|
-
return function(t,
|
|
1663
|
-
return
|
|
1664
|
-
}(t,
|
|
1659
|
+
return function(t, n) {
|
|
1660
|
+
return It(t.geoPointValue.latitude) === It(n.geoPointValue.latitude) && It(t.geoPointValue.longitude) === It(n.geoPointValue.longitude);
|
|
1661
|
+
}(t, n);
|
|
1665
1662
|
|
|
1666
1663
|
case 2 /* NumberValue */ :
|
|
1667
|
-
return function(t,
|
|
1668
|
-
if ("integerValue" in t && "integerValue" in
|
|
1669
|
-
if ("doubleValue" in t && "doubleValue" in
|
|
1670
|
-
const
|
|
1671
|
-
return
|
|
1664
|
+
return function(t, n) {
|
|
1665
|
+
if ("integerValue" in t && "integerValue" in n) return It(t.integerValue) === It(n.integerValue);
|
|
1666
|
+
if ("doubleValue" in t && "doubleValue" in n) {
|
|
1667
|
+
const e = It(t.doubleValue), r = It(n.doubleValue);
|
|
1668
|
+
return e === r ? ot(e) === ot(r) : isNaN(e) && isNaN(r);
|
|
1672
1669
|
}
|
|
1673
1670
|
return !1;
|
|
1674
|
-
}(t,
|
|
1671
|
+
}(t, n);
|
|
1675
1672
|
|
|
1676
1673
|
case 9 /* ArrayValue */ :
|
|
1677
|
-
return mt(t.arrayValue.values || [],
|
|
1674
|
+
return mt(t.arrayValue.values || [], n.arrayValue.values || [], Nt);
|
|
1678
1675
|
|
|
1679
1676
|
case 10 /* ObjectValue */ :
|
|
1680
|
-
return function(t,
|
|
1681
|
-
const
|
|
1682
|
-
if (_t(
|
|
1683
|
-
for (const t in
|
|
1677
|
+
return function(t, n) {
|
|
1678
|
+
const e = t.mapValue.fields || {}, r = n.mapValue.fields || {};
|
|
1679
|
+
if (_t(e) !== _t(r)) return !1;
|
|
1680
|
+
for (const t in e) if (e.hasOwnProperty(t) && (void 0 === r[t] || !Nt(e[t], r[t]))) return !1;
|
|
1684
1681
|
return !0;
|
|
1685
1682
|
}
|
|
1686
|
-
/** Returns true if the ArrayValue contains the specified element. */ (t,
|
|
1683
|
+
/** Returns true if the ArrayValue contains the specified element. */ (t, n);
|
|
1687
1684
|
|
|
1688
1685
|
default:
|
|
1689
1686
|
return _();
|
|
1690
1687
|
}
|
|
1691
1688
|
}
|
|
1692
1689
|
|
|
1693
|
-
function $t(t,
|
|
1694
|
-
return void 0 !== (t.values || []).find((t =>
|
|
1690
|
+
function $t(t, n) {
|
|
1691
|
+
return void 0 !== (t.values || []).find((t => Nt(t, n)));
|
|
1695
1692
|
}
|
|
1696
1693
|
|
|
1697
|
-
function Ft(t,
|
|
1698
|
-
const
|
|
1699
|
-
if (
|
|
1700
|
-
switch (
|
|
1694
|
+
function Ft(t, n) {
|
|
1695
|
+
const e = Dt(t), r = Dt(n);
|
|
1696
|
+
if (e !== r) return wt(e, r);
|
|
1697
|
+
switch (e) {
|
|
1701
1698
|
case 0 /* NullValue */ :
|
|
1702
1699
|
return 0;
|
|
1703
1700
|
|
|
1704
1701
|
case 1 /* BooleanValue */ :
|
|
1705
|
-
return wt(t.booleanValue,
|
|
1702
|
+
return wt(t.booleanValue, n.booleanValue);
|
|
1706
1703
|
|
|
1707
1704
|
case 2 /* NumberValue */ :
|
|
1708
|
-
return function(t,
|
|
1709
|
-
const
|
|
1710
|
-
return
|
|
1705
|
+
return function(t, n) {
|
|
1706
|
+
const e = It(t.integerValue || t.doubleValue), r = It(n.integerValue || n.doubleValue);
|
|
1707
|
+
return e < r ? -1 : e > r ? 1 : e === r ? 0 :
|
|
1711
1708
|
// one or both are NaN.
|
|
1712
|
-
isNaN(
|
|
1713
|
-
}(t,
|
|
1709
|
+
isNaN(e) ? isNaN(r) ? 0 : -1 : 1;
|
|
1710
|
+
}(t, n);
|
|
1714
1711
|
|
|
1715
1712
|
case 3 /* TimestampValue */ :
|
|
1716
|
-
return St(t.timestampValue,
|
|
1713
|
+
return St(t.timestampValue, n.timestampValue);
|
|
1717
1714
|
|
|
1718
1715
|
case 4 /* ServerTimestampValue */ :
|
|
1719
|
-
return St(Vt(t), Vt(
|
|
1716
|
+
return St(Vt(t), Vt(n));
|
|
1720
1717
|
|
|
1721
1718
|
case 5 /* StringValue */ :
|
|
1722
|
-
return wt(t.stringValue,
|
|
1719
|
+
return wt(t.stringValue, n.stringValue);
|
|
1723
1720
|
|
|
1724
1721
|
case 6 /* BlobValue */ :
|
|
1725
|
-
return function(t,
|
|
1726
|
-
const
|
|
1727
|
-
return
|
|
1728
|
-
}(t.bytesValue,
|
|
1722
|
+
return function(t, n) {
|
|
1723
|
+
const e = At(t), r = At(n);
|
|
1724
|
+
return e.compareTo(r);
|
|
1725
|
+
}(t.bytesValue, n.bytesValue);
|
|
1729
1726
|
|
|
1730
1727
|
case 7 /* RefValue */ :
|
|
1731
|
-
return function(t,
|
|
1732
|
-
const
|
|
1733
|
-
for (let t = 0; t <
|
|
1734
|
-
const
|
|
1735
|
-
if (0 !==
|
|
1728
|
+
return function(t, n) {
|
|
1729
|
+
const e = t.split("/"), r = n.split("/");
|
|
1730
|
+
for (let t = 0; t < e.length && t < r.length; t++) {
|
|
1731
|
+
const n = wt(e[t], r[t]);
|
|
1732
|
+
if (0 !== n) return n;
|
|
1736
1733
|
}
|
|
1737
|
-
return wt(
|
|
1738
|
-
}(t.referenceValue,
|
|
1734
|
+
return wt(e.length, r.length);
|
|
1735
|
+
}(t.referenceValue, n.referenceValue);
|
|
1739
1736
|
|
|
1740
1737
|
case 8 /* GeoPointValue */ :
|
|
1741
|
-
return function(t,
|
|
1742
|
-
const
|
|
1743
|
-
if (0 !==
|
|
1744
|
-
return wt(
|
|
1745
|
-
}(t.geoPointValue,
|
|
1738
|
+
return function(t, n) {
|
|
1739
|
+
const e = wt(It(t.latitude), It(n.latitude));
|
|
1740
|
+
if (0 !== e) return e;
|
|
1741
|
+
return wt(It(t.longitude), It(n.longitude));
|
|
1742
|
+
}(t.geoPointValue, n.geoPointValue);
|
|
1746
1743
|
|
|
1747
1744
|
case 9 /* ArrayValue */ :
|
|
1748
|
-
return function(t,
|
|
1749
|
-
const
|
|
1750
|
-
for (let t = 0; t <
|
|
1751
|
-
const
|
|
1752
|
-
if (
|
|
1745
|
+
return function(t, n) {
|
|
1746
|
+
const e = t.values || [], r = n.values || [];
|
|
1747
|
+
for (let t = 0; t < e.length && t < r.length; ++t) {
|
|
1748
|
+
const n = Ft(e[t], r[t]);
|
|
1749
|
+
if (n) return n;
|
|
1753
1750
|
}
|
|
1754
|
-
return wt(
|
|
1755
|
-
}(t.arrayValue,
|
|
1751
|
+
return wt(e.length, r.length);
|
|
1752
|
+
}(t.arrayValue, n.arrayValue);
|
|
1756
1753
|
|
|
1757
1754
|
case 10 /* ObjectValue */ :
|
|
1758
|
-
return function(t,
|
|
1759
|
-
const
|
|
1755
|
+
return function(t, n) {
|
|
1756
|
+
const e = t.fields || {}, r = Object.keys(e), s = n.fields || {}, i = Object.keys(s);
|
|
1760
1757
|
// Even though MapValues are likely sorted correctly based on their insertion
|
|
1761
1758
|
// order (e.g. when received from the backend), local modifications can bring
|
|
1762
1759
|
// elements out of order. We need to re-sort the elements to ensure that
|
|
1763
1760
|
// canonical IDs are independent of insertion order.
|
|
1764
1761
|
r.sort(), i.sort();
|
|
1765
1762
|
for (let t = 0; t < r.length && t < i.length; ++t) {
|
|
1766
|
-
const
|
|
1767
|
-
if (0 !==
|
|
1768
|
-
const o = Ft(
|
|
1763
|
+
const n = wt(r[t], i[t]);
|
|
1764
|
+
if (0 !== n) return n;
|
|
1765
|
+
const o = Ft(e[r[t]], s[i[t]]);
|
|
1769
1766
|
if (0 !== o) return o;
|
|
1770
1767
|
}
|
|
1771
1768
|
return wt(r.length, i.length);
|
|
1772
1769
|
}
|
|
1773
|
-
/** Returns a reference value for the provided database and key. */ (t.mapValue,
|
|
1770
|
+
/** Returns a reference value for the provided database and key. */ (t.mapValue, n.mapValue);
|
|
1774
1771
|
|
|
1775
1772
|
default:
|
|
1776
1773
|
throw _();
|
|
1777
1774
|
}
|
|
1778
1775
|
}
|
|
1779
1776
|
|
|
1780
|
-
function St(t,
|
|
1781
|
-
if ("string" == typeof t && "string" == typeof
|
|
1782
|
-
const
|
|
1783
|
-
return 0 !== s ? s : wt(
|
|
1777
|
+
function St(t, n) {
|
|
1778
|
+
if ("string" == typeof t && "string" == typeof n && t.length === n.length) return wt(t, n);
|
|
1779
|
+
const e = Tt(t), r = Tt(n), s = wt(e.seconds, r.seconds);
|
|
1780
|
+
return 0 !== s ? s : wt(e.nanos, r.nanos);
|
|
1784
1781
|
}
|
|
1785
1782
|
|
|
1786
|
-
function qt(t,
|
|
1783
|
+
function qt(t, n) {
|
|
1787
1784
|
return {
|
|
1788
|
-
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${
|
|
1785
|
+
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${n.path.canonicalString()}`
|
|
1789
1786
|
};
|
|
1790
1787
|
}
|
|
1791
1788
|
|
|
@@ -1813,21 +1810,21 @@ function qt(t, e) {
|
|
|
1813
1810
|
timestampValue: Object.assign({}, t.timestampValue)
|
|
1814
1811
|
};
|
|
1815
1812
|
if (t.mapValue) {
|
|
1816
|
-
const
|
|
1813
|
+
const n = {
|
|
1817
1814
|
mapValue: {
|
|
1818
1815
|
fields: {}
|
|
1819
1816
|
}
|
|
1820
1817
|
};
|
|
1821
|
-
return gt(t.mapValue.fields, ((t,
|
|
1818
|
+
return gt(t.mapValue.fields, ((t, e) => n.mapValue.fields[t] = Ut(e))), n;
|
|
1822
1819
|
}
|
|
1823
1820
|
if (t.arrayValue) {
|
|
1824
|
-
const
|
|
1821
|
+
const n = {
|
|
1825
1822
|
arrayValue: {
|
|
1826
1823
|
values: []
|
|
1827
1824
|
}
|
|
1828
1825
|
};
|
|
1829
|
-
for (let
|
|
1830
|
-
return
|
|
1826
|
+
for (let e = 0; e < (t.arrayValue.values || []).length; ++e) n.arrayValue.values[e] = Ut(t.arrayValue.values[e]);
|
|
1827
|
+
return n;
|
|
1831
1828
|
}
|
|
1832
1829
|
return Object.assign({}, t);
|
|
1833
1830
|
}
|
|
@@ -1868,10 +1865,10 @@ function qt(t, e) {
|
|
|
1868
1865
|
*/ field(t) {
|
|
1869
1866
|
if (t.isEmpty()) return this.value;
|
|
1870
1867
|
{
|
|
1871
|
-
let
|
|
1872
|
-
for (let
|
|
1873
|
-
!Lt(
|
|
1874
|
-
return
|
|
1868
|
+
let n = this.value;
|
|
1869
|
+
for (let e = 0; e < t.length - 1; ++e) if (n = (n.mapValue.fields || {})[t.get(e)],
|
|
1870
|
+
!Lt(n)) return null;
|
|
1871
|
+
return n = (n.mapValue.fields || {})[t.lastSegment()], n || null;
|
|
1875
1872
|
}
|
|
1876
1873
|
}
|
|
1877
1874
|
/**
|
|
@@ -1879,25 +1876,25 @@ function qt(t, e) {
|
|
|
1879
1876
|
*
|
|
1880
1877
|
* @param path - The field path to set.
|
|
1881
1878
|
* @param value - The value to set.
|
|
1882
|
-
*/ set(t,
|
|
1883
|
-
this.getFieldsMap(t.popLast())[t.lastSegment()] = Ut(
|
|
1879
|
+
*/ set(t, n) {
|
|
1880
|
+
this.getFieldsMap(t.popLast())[t.lastSegment()] = Ut(n);
|
|
1884
1881
|
}
|
|
1885
1882
|
/**
|
|
1886
1883
|
* Sets the provided fields to the provided values.
|
|
1887
1884
|
*
|
|
1888
1885
|
* @param data - A map of fields to values (or null for deletes).
|
|
1889
1886
|
*/ setAll(t) {
|
|
1890
|
-
let
|
|
1887
|
+
let n = J.emptyPath(), e = {}, r = [];
|
|
1891
1888
|
t.forEach(((t, s) => {
|
|
1892
|
-
if (!
|
|
1889
|
+
if (!n.isImmediateParentOf(s)) {
|
|
1893
1890
|
// Insert the accumulated changes at this parent location
|
|
1894
|
-
const t = this.getFieldsMap(
|
|
1895
|
-
this.applyChanges(t,
|
|
1891
|
+
const t = this.getFieldsMap(n);
|
|
1892
|
+
this.applyChanges(t, e, r), e = {}, r = [], n = s.popLast();
|
|
1896
1893
|
}
|
|
1897
|
-
t ?
|
|
1894
|
+
t ? e[s.lastSegment()] = Ut(t) : r.push(s.lastSegment());
|
|
1898
1895
|
}));
|
|
1899
|
-
const s = this.getFieldsMap(
|
|
1900
|
-
this.applyChanges(s,
|
|
1896
|
+
const s = this.getFieldsMap(n);
|
|
1897
|
+
this.applyChanges(s, e, r);
|
|
1901
1898
|
}
|
|
1902
1899
|
/**
|
|
1903
1900
|
* Removes the field at the specified path. If there is no field at the
|
|
@@ -1905,36 +1902,36 @@ function qt(t, e) {
|
|
|
1905
1902
|
*
|
|
1906
1903
|
* @param path - The field path to remove.
|
|
1907
1904
|
*/ delete(t) {
|
|
1908
|
-
const
|
|
1909
|
-
Lt(
|
|
1905
|
+
const n = this.field(t.popLast());
|
|
1906
|
+
Lt(n) && n.mapValue.fields && delete n.mapValue.fields[t.lastSegment()];
|
|
1910
1907
|
}
|
|
1911
1908
|
isEqual(t) {
|
|
1912
|
-
return
|
|
1909
|
+
return Nt(this.value, t.value);
|
|
1913
1910
|
}
|
|
1914
1911
|
/**
|
|
1915
1912
|
* Returns the map that contains the leaf element of `path`. If the parent
|
|
1916
1913
|
* entry does not yet exist, or if it is not a map, a new map will be created.
|
|
1917
1914
|
*/ getFieldsMap(t) {
|
|
1918
|
-
let
|
|
1919
|
-
|
|
1915
|
+
let n = this.value;
|
|
1916
|
+
n.mapValue.fields || (n.mapValue = {
|
|
1920
1917
|
fields: {}
|
|
1921
1918
|
});
|
|
1922
|
-
for (let
|
|
1923
|
-
let r =
|
|
1919
|
+
for (let e = 0; e < t.length; ++e) {
|
|
1920
|
+
let r = n.mapValue.fields[t.get(e)];
|
|
1924
1921
|
Lt(r) && r.mapValue.fields || (r = {
|
|
1925
1922
|
mapValue: {
|
|
1926
1923
|
fields: {}
|
|
1927
1924
|
}
|
|
1928
|
-
},
|
|
1925
|
+
}, n.mapValue.fields[t.get(e)] = r), n = r;
|
|
1929
1926
|
}
|
|
1930
|
-
return
|
|
1927
|
+
return n.mapValue.fields;
|
|
1931
1928
|
}
|
|
1932
1929
|
/**
|
|
1933
1930
|
* Modifies `fieldsMap` by adding, replacing or deleting the specified
|
|
1934
1931
|
* entries.
|
|
1935
|
-
*/ applyChanges(t,
|
|
1936
|
-
gt(
|
|
1937
|
-
for (const
|
|
1932
|
+
*/ applyChanges(t, n, e) {
|
|
1933
|
+
gt(n, ((n, e) => t[n] = e));
|
|
1934
|
+
for (const n of e) delete t[n];
|
|
1938
1935
|
}
|
|
1939
1936
|
clone() {
|
|
1940
1937
|
return new jt(Ut(this.value));
|
|
@@ -1967,8 +1964,8 @@ function qt(t, e) {
|
|
|
1967
1964
|
* applied, `isValidDocument()` returns false and the document should be removed
|
|
1968
1965
|
* from all views.
|
|
1969
1966
|
*/ class kt {
|
|
1970
|
-
constructor(t,
|
|
1971
|
-
this.key = t, this.documentType =
|
|
1967
|
+
constructor(t, n, e, r, s) {
|
|
1968
|
+
this.key = t, this.documentType = n, this.version = e, this.data = r, this.documentState = s;
|
|
1972
1969
|
}
|
|
1973
1970
|
/**
|
|
1974
1971
|
* Creates a document with no known version or data, but which can serve as
|
|
@@ -1979,24 +1976,24 @@ function qt(t, e) {
|
|
|
1979
1976
|
/**
|
|
1980
1977
|
* Creates a new document that is known to exist with the given data at the
|
|
1981
1978
|
* given version.
|
|
1982
|
-
*/ static newFoundDocument(t,
|
|
1983
|
-
return new kt(t, 1 /* FOUND_DOCUMENT */ ,
|
|
1979
|
+
*/ static newFoundDocument(t, n, e) {
|
|
1980
|
+
return new kt(t, 1 /* FOUND_DOCUMENT */ , n, e, 0 /* SYNCED */);
|
|
1984
1981
|
}
|
|
1985
|
-
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t,
|
|
1986
|
-
return new kt(t, 2 /* NO_DOCUMENT */ ,
|
|
1982
|
+
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t, n) {
|
|
1983
|
+
return new kt(t, 2 /* NO_DOCUMENT */ , n, jt.empty(), 0 /* SYNCED */);
|
|
1987
1984
|
}
|
|
1988
1985
|
/**
|
|
1989
1986
|
* Creates a new document that is known to exist at the given version but
|
|
1990
1987
|
* whose data is not known (e.g. a document that was updated without a known
|
|
1991
1988
|
* base document).
|
|
1992
|
-
*/ static newUnknownDocument(t,
|
|
1993
|
-
return new kt(t, 3 /* UNKNOWN_DOCUMENT */ ,
|
|
1989
|
+
*/ static newUnknownDocument(t, n) {
|
|
1990
|
+
return new kt(t, 3 /* UNKNOWN_DOCUMENT */ , n, jt.empty(), 2 /* HAS_COMMITTED_MUTATIONS */);
|
|
1994
1991
|
}
|
|
1995
1992
|
/**
|
|
1996
1993
|
* Changes the document type to indicate that it exists and that its version
|
|
1997
1994
|
* and data are known.
|
|
1998
|
-
*/ convertToFoundDocument(t,
|
|
1999
|
-
return this.version = t, this.documentType = 1 /* FOUND_DOCUMENT */ , this.data =
|
|
1995
|
+
*/ convertToFoundDocument(t, n) {
|
|
1996
|
+
return this.version = t, this.documentType = 1 /* FOUND_DOCUMENT */ , this.data = n,
|
|
2000
1997
|
this.documentState = 0 /* SYNCED */ , this;
|
|
2001
1998
|
}
|
|
2002
1999
|
/**
|
|
@@ -2069,9 +2066,9 @@ function qt(t, e) {
|
|
|
2069
2066
|
* limitations under the License.
|
|
2070
2067
|
*/
|
|
2071
2068
|
// Visible for testing
|
|
2072
|
-
class
|
|
2073
|
-
constructor(t,
|
|
2074
|
-
this.path = t, this.collectionGroup =
|
|
2069
|
+
class Bt {
|
|
2070
|
+
constructor(t, n = null, e = [], r = [], s = null, i = null, o = null) {
|
|
2071
|
+
this.path = t, this.collectionGroup = n, this.orderBy = e, this.filters = r, this.limit = s,
|
|
2075
2072
|
this.startAt = i, this.endAt = o, this.P = null;
|
|
2076
2073
|
}
|
|
2077
2074
|
}
|
|
@@ -2083,26 +2080,26 @@ class Mt {
|
|
|
2083
2080
|
* NOTE: you should always construct `Target` from `Query.toTarget` instead of
|
|
2084
2081
|
* using this factory method, because `Query` provides an implicit `orderBy`
|
|
2085
2082
|
* property.
|
|
2086
|
-
*/ function
|
|
2087
|
-
return new
|
|
2083
|
+
*/ function Mt(t, n = null, e = [], r = [], s = null, i = null, o = null) {
|
|
2084
|
+
return new Bt(t, n, e, r, s, i, o);
|
|
2088
2085
|
}
|
|
2089
2086
|
|
|
2090
2087
|
class Qt extends class {} {
|
|
2091
|
-
constructor(t,
|
|
2092
|
-
super(), this.field = t, this.op =
|
|
2088
|
+
constructor(t, n, e) {
|
|
2089
|
+
super(), this.field = t, this.op = n, this.value = e;
|
|
2093
2090
|
}
|
|
2094
2091
|
/**
|
|
2095
2092
|
* Creates a filter based on the provided arguments.
|
|
2096
|
-
*/ static create(t,
|
|
2097
|
-
return t.isKeyField() ? "in" /* IN */ ===
|
|
2093
|
+
*/ static create(t, n, e) {
|
|
2094
|
+
return t.isKeyField() ? "in" /* IN */ === n || "not-in" /* NOT_IN */ === n ? this.R(t, n, e) : new zt(t, n, e) : "array-contains" /* ARRAY_CONTAINS */ === n ? new Yt(t, e) : "in" /* IN */ === n ? new Kt(t, e) : "not-in" /* NOT_IN */ === n ? new Jt(t, e) : "array-contains-any" /* ARRAY_CONTAINS_ANY */ === n ? new Zt(t, e) : new Qt(t, n, e);
|
|
2098
2095
|
}
|
|
2099
|
-
static R(t,
|
|
2100
|
-
return "in" /* IN */ ===
|
|
2096
|
+
static R(t, n, e) {
|
|
2097
|
+
return "in" /* IN */ === n ? new Gt(t, e) : new Wt(t, e);
|
|
2101
2098
|
}
|
|
2102
2099
|
matches(t) {
|
|
2103
|
-
const
|
|
2100
|
+
const n = t.data.field(this.field);
|
|
2104
2101
|
// Types do not have to match in NOT_EQUAL filters.
|
|
2105
|
-
return "!=" /* NOT_EQUAL */ === this.op ? null !==
|
|
2102
|
+
return "!=" /* NOT_EQUAL */ === this.op ? null !== n && this.V(Ft(n, this.value)) : null !== n && Dt(this.value) === Dt(n) && this.V(Ft(n, this.value));
|
|
2106
2103
|
// Only compare types with matching backend order (such as double and int).
|
|
2107
2104
|
}
|
|
2108
2105
|
V(t) {
|
|
@@ -2129,85 +2126,85 @@ class Qt extends class {} {
|
|
|
2129
2126
|
return _();
|
|
2130
2127
|
}
|
|
2131
2128
|
}
|
|
2132
|
-
|
|
2129
|
+
D() {
|
|
2133
2130
|
return [ "<" /* LESS_THAN */ , "<=" /* LESS_THAN_OR_EQUAL */ , ">" /* GREATER_THAN */ , ">=" /* GREATER_THAN_OR_EQUAL */ , "!=" /* NOT_EQUAL */ , "not-in" /* NOT_IN */ ].indexOf(this.op) >= 0;
|
|
2134
2131
|
}
|
|
2135
2132
|
}
|
|
2136
2133
|
|
|
2137
2134
|
/** Filter that matches on key fields (i.e. '__name__'). */
|
|
2138
2135
|
class zt extends Qt {
|
|
2139
|
-
constructor(t,
|
|
2140
|
-
super(t,
|
|
2136
|
+
constructor(t, n, e) {
|
|
2137
|
+
super(t, n, e), this.key = Z.fromName(e.referenceValue);
|
|
2141
2138
|
}
|
|
2142
2139
|
matches(t) {
|
|
2143
|
-
const
|
|
2144
|
-
return this.V(
|
|
2140
|
+
const n = Z.comparator(t.key, this.key);
|
|
2141
|
+
return this.V(n);
|
|
2145
2142
|
}
|
|
2146
2143
|
}
|
|
2147
2144
|
|
|
2148
|
-
/** Filter that matches on key fields within an array. */ class
|
|
2149
|
-
constructor(t,
|
|
2150
|
-
super(t, "in" /* IN */ ,
|
|
2145
|
+
/** Filter that matches on key fields within an array. */ class Gt extends Qt {
|
|
2146
|
+
constructor(t, n) {
|
|
2147
|
+
super(t, "in" /* IN */ , n), this.keys = Ht("in" /* IN */ , n);
|
|
2151
2148
|
}
|
|
2152
2149
|
matches(t) {
|
|
2153
|
-
return this.keys.some((
|
|
2150
|
+
return this.keys.some((n => n.isEqual(t.key)));
|
|
2154
2151
|
}
|
|
2155
2152
|
}
|
|
2156
2153
|
|
|
2157
|
-
/** Filter that matches on key fields not present within an array. */ class
|
|
2158
|
-
constructor(t,
|
|
2159
|
-
super(t, "not-in" /* NOT_IN */ ,
|
|
2154
|
+
/** Filter that matches on key fields not present within an array. */ class Wt extends Qt {
|
|
2155
|
+
constructor(t, n) {
|
|
2156
|
+
super(t, "not-in" /* NOT_IN */ , n), this.keys = Ht("not-in" /* NOT_IN */ , n);
|
|
2160
2157
|
}
|
|
2161
2158
|
matches(t) {
|
|
2162
|
-
return !this.keys.some((
|
|
2159
|
+
return !this.keys.some((n => n.isEqual(t.key)));
|
|
2163
2160
|
}
|
|
2164
2161
|
}
|
|
2165
2162
|
|
|
2166
|
-
function Ht(t,
|
|
2167
|
-
var
|
|
2168
|
-
return ((null === (
|
|
2163
|
+
function Ht(t, n) {
|
|
2164
|
+
var e;
|
|
2165
|
+
return ((null === (e = n.arrayValue) || void 0 === e ? void 0 : e.values) || []).map((t => Z.fromName(t.referenceValue)));
|
|
2169
2166
|
}
|
|
2170
2167
|
|
|
2171
2168
|
/** A Filter that implements the array-contains operator. */ class Yt extends Qt {
|
|
2172
|
-
constructor(t,
|
|
2173
|
-
super(t, "array-contains" /* ARRAY_CONTAINS */ ,
|
|
2169
|
+
constructor(t, n) {
|
|
2170
|
+
super(t, "array-contains" /* ARRAY_CONTAINS */ , n);
|
|
2174
2171
|
}
|
|
2175
2172
|
matches(t) {
|
|
2176
|
-
const
|
|
2177
|
-
return xt(
|
|
2173
|
+
const n = t.data.field(this.field);
|
|
2174
|
+
return xt(n) && $t(n.arrayValue, this.value);
|
|
2178
2175
|
}
|
|
2179
2176
|
}
|
|
2180
2177
|
|
|
2181
2178
|
/** A Filter that implements the IN operator. */ class Kt extends Qt {
|
|
2182
|
-
constructor(t,
|
|
2183
|
-
super(t, "in" /* IN */ ,
|
|
2179
|
+
constructor(t, n) {
|
|
2180
|
+
super(t, "in" /* IN */ , n);
|
|
2184
2181
|
}
|
|
2185
2182
|
matches(t) {
|
|
2186
|
-
const
|
|
2187
|
-
return null !==
|
|
2183
|
+
const n = t.data.field(this.field);
|
|
2184
|
+
return null !== n && $t(this.value.arrayValue, n);
|
|
2188
2185
|
}
|
|
2189
2186
|
}
|
|
2190
2187
|
|
|
2191
2188
|
/** A Filter that implements the not-in operator. */ class Jt extends Qt {
|
|
2192
|
-
constructor(t,
|
|
2193
|
-
super(t, "not-in" /* NOT_IN */ ,
|
|
2189
|
+
constructor(t, n) {
|
|
2190
|
+
super(t, "not-in" /* NOT_IN */ , n);
|
|
2194
2191
|
}
|
|
2195
2192
|
matches(t) {
|
|
2196
2193
|
if ($t(this.value.arrayValue, {
|
|
2197
2194
|
nullValue: "NULL_VALUE"
|
|
2198
2195
|
})) return !1;
|
|
2199
|
-
const
|
|
2200
|
-
return null !==
|
|
2196
|
+
const n = t.data.field(this.field);
|
|
2197
|
+
return null !== n && !$t(this.value.arrayValue, n);
|
|
2201
2198
|
}
|
|
2202
2199
|
}
|
|
2203
2200
|
|
|
2204
2201
|
/** A Filter that implements the array-contains-any operator. */ class Zt extends Qt {
|
|
2205
|
-
constructor(t,
|
|
2206
|
-
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ ,
|
|
2202
|
+
constructor(t, n) {
|
|
2203
|
+
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ , n);
|
|
2207
2204
|
}
|
|
2208
2205
|
matches(t) {
|
|
2209
|
-
const
|
|
2210
|
-
return !(!xt(
|
|
2206
|
+
const n = t.data.field(this.field);
|
|
2207
|
+
return !(!xt(n) || !n.arrayValue.values) && n.arrayValue.values.some((t => $t(this.value.arrayValue, t)));
|
|
2211
2208
|
}
|
|
2212
2209
|
}
|
|
2213
2210
|
|
|
@@ -2225,29 +2222,29 @@ function Ht(t, e) {
|
|
|
2225
2222
|
* after a bound. This is influenced by whether the position is just before or
|
|
2226
2223
|
* just after the provided values.
|
|
2227
2224
|
*/ class Xt {
|
|
2228
|
-
constructor(t,
|
|
2229
|
-
this.position = t, this.before =
|
|
2225
|
+
constructor(t, n) {
|
|
2226
|
+
this.position = t, this.before = n;
|
|
2230
2227
|
}
|
|
2231
2228
|
}
|
|
2232
2229
|
|
|
2233
2230
|
/**
|
|
2234
2231
|
* An ordering on a field, in some Direction. Direction defaults to ASCENDING.
|
|
2235
|
-
*/ class
|
|
2236
|
-
constructor(t,
|
|
2237
|
-
this.field = t, this.dir =
|
|
2232
|
+
*/ class tn {
|
|
2233
|
+
constructor(t, n = "asc" /* ASCENDING */) {
|
|
2234
|
+
this.field = t, this.dir = n;
|
|
2238
2235
|
}
|
|
2239
2236
|
}
|
|
2240
2237
|
|
|
2241
|
-
function
|
|
2242
|
-
return t.dir ===
|
|
2238
|
+
function nn(t, n) {
|
|
2239
|
+
return t.dir === n.dir && t.field.isEqual(n.field);
|
|
2243
2240
|
}
|
|
2244
2241
|
|
|
2245
|
-
function
|
|
2246
|
-
if (null === t) return null ===
|
|
2247
|
-
if (null ===
|
|
2248
|
-
if (t.before !==
|
|
2249
|
-
for (let
|
|
2250
|
-
if (!
|
|
2242
|
+
function en(t, n) {
|
|
2243
|
+
if (null === t) return null === n;
|
|
2244
|
+
if (null === n) return !1;
|
|
2245
|
+
if (t.before !== n.before || t.position.length !== n.position.length) return !1;
|
|
2246
|
+
for (let e = 0; e < t.position.length; e++) {
|
|
2247
|
+
if (!Nt(t.position[e], n.position[e])) return !1;
|
|
2251
2248
|
}
|
|
2252
2249
|
return !0;
|
|
2253
2250
|
}
|
|
@@ -2274,29 +2271,29 @@ function ne(t, e) {
|
|
|
2274
2271
|
* query the RemoteStore results.
|
|
2275
2272
|
*
|
|
2276
2273
|
* Visible for testing.
|
|
2277
|
-
*/ class
|
|
2274
|
+
*/ class rn {
|
|
2278
2275
|
/**
|
|
2279
2276
|
* Initializes a Query with a path and optional additional query constraints.
|
|
2280
2277
|
* Path must currently be empty if this is a collection group query.
|
|
2281
2278
|
*/
|
|
2282
|
-
constructor(t,
|
|
2283
|
-
this.path = t, this.collectionGroup =
|
|
2284
|
-
this.limit = s, this.limitType = i, this.startAt = o, this.endAt = u, this.
|
|
2279
|
+
constructor(t, n = null, e = [], r = [], s = null, i = "F" /* First */ , o = null, u = null) {
|
|
2280
|
+
this.path = t, this.collectionGroup = n, this.explicitOrderBy = e, this.filters = r,
|
|
2281
|
+
this.limit = s, this.limitType = i, this.startAt = o, this.endAt = u, this.N = null,
|
|
2285
2282
|
// The corresponding `Target` of this `Query` instance.
|
|
2286
2283
|
this.$ = null, this.startAt, this.endAt;
|
|
2287
2284
|
}
|
|
2288
2285
|
}
|
|
2289
2286
|
|
|
2290
|
-
/** Creates a new Query for a query that matches all documents at `path` */ function
|
|
2287
|
+
/** Creates a new Query for a query that matches all documents at `path` */ function sn(t) {
|
|
2291
2288
|
return !it(t.limit) && "L" /* Last */ === t.limitType;
|
|
2292
2289
|
}
|
|
2293
2290
|
|
|
2294
|
-
function
|
|
2291
|
+
function on(t) {
|
|
2295
2292
|
return t.explicitOrderBy.length > 0 ? t.explicitOrderBy[0].field : null;
|
|
2296
2293
|
}
|
|
2297
2294
|
|
|
2298
|
-
function
|
|
2299
|
-
for (const
|
|
2295
|
+
function un(t) {
|
|
2296
|
+
for (const n of t.filters) if (n.D()) return n.field;
|
|
2300
2297
|
return null;
|
|
2301
2298
|
}
|
|
2302
2299
|
|
|
@@ -2308,7 +2305,7 @@ function oe(t) {
|
|
|
2308
2305
|
* Returns whether the query matches a collection group rather than a specific
|
|
2309
2306
|
* collection.
|
|
2310
2307
|
*/
|
|
2311
|
-
function
|
|
2308
|
+
function cn(t) {
|
|
2312
2309
|
return null !== t.collectionGroup;
|
|
2313
2310
|
}
|
|
2314
2311
|
|
|
@@ -2316,59 +2313,59 @@ function ue(t) {
|
|
|
2316
2313
|
* Returns the implicit order by constraint that is used to execute the Query,
|
|
2317
2314
|
* which can be different from the order by constraints the user provided (e.g.
|
|
2318
2315
|
* the SDK and backend always orders by `__name__`).
|
|
2319
|
-
*/ function
|
|
2320
|
-
const
|
|
2321
|
-
if (null ===
|
|
2322
|
-
|
|
2323
|
-
const t =
|
|
2324
|
-
if (null !== t && null ===
|
|
2316
|
+
*/ function an(t) {
|
|
2317
|
+
const n = b(t);
|
|
2318
|
+
if (null === n.N) {
|
|
2319
|
+
n.N = [];
|
|
2320
|
+
const t = un(n), e = on(n);
|
|
2321
|
+
if (null !== t && null === e)
|
|
2325
2322
|
// In order to implicitly add key ordering, we must also add the
|
|
2326
2323
|
// inequality filter field for it to be a valid query.
|
|
2327
2324
|
// Note that the default inequality field and key ordering is ascending.
|
|
2328
|
-
t.isKeyField() ||
|
|
2325
|
+
t.isKeyField() || n.N.push(new tn(t)), n.N.push(new tn(J.keyField(), "asc" /* ASCENDING */)); else {
|
|
2329
2326
|
let t = !1;
|
|
2330
|
-
for (const
|
|
2327
|
+
for (const e of n.explicitOrderBy) n.N.push(e), e.field.isKeyField() && (t = !0);
|
|
2331
2328
|
if (!t) {
|
|
2332
2329
|
// The order of the implicit key ordering always matches the last
|
|
2333
2330
|
// explicit order by
|
|
2334
|
-
const t =
|
|
2335
|
-
|
|
2331
|
+
const t = n.explicitOrderBy.length > 0 ? n.explicitOrderBy[n.explicitOrderBy.length - 1].dir : "asc" /* ASCENDING */;
|
|
2332
|
+
n.N.push(new tn(J.keyField(), t));
|
|
2336
2333
|
}
|
|
2337
2334
|
}
|
|
2338
2335
|
}
|
|
2339
|
-
return
|
|
2336
|
+
return n.N;
|
|
2340
2337
|
}
|
|
2341
2338
|
|
|
2342
2339
|
/**
|
|
2343
2340
|
* Converts this `Query` instance to it's corresponding `Target` representation.
|
|
2344
|
-
*/ function
|
|
2345
|
-
const
|
|
2346
|
-
if (!
|
|
2341
|
+
*/ function hn(t) {
|
|
2342
|
+
const n = b(t);
|
|
2343
|
+
if (!n.$) if ("F" /* First */ === n.limitType) n.$ = Mt(n.path, n.collectionGroup, an(n), n.filters, n.limit, n.startAt, n.endAt); else {
|
|
2347
2344
|
// Flip the orderBy directions since we want the last results
|
|
2348
2345
|
const t = [];
|
|
2349
|
-
for (const
|
|
2350
|
-
const
|
|
2351
|
-
t.push(new
|
|
2346
|
+
for (const e of an(n)) {
|
|
2347
|
+
const n = "desc" /* DESCENDING */ === e.dir ? "asc" /* ASCENDING */ : "desc" /* DESCENDING */;
|
|
2348
|
+
t.push(new tn(e.field, n));
|
|
2352
2349
|
}
|
|
2353
2350
|
// We need to swap the cursors to match the now-flipped query ordering.
|
|
2354
|
-
const
|
|
2351
|
+
const e = n.endAt ? new Xt(n.endAt.position, !n.endAt.before) : null, r = n.startAt ? new Xt(n.startAt.position, !n.startAt.before) : null;
|
|
2355
2352
|
// Now return as a LimitType.First query.
|
|
2356
|
-
|
|
2353
|
+
n.$ = Mt(n.path, n.collectionGroup, t, n.filters, n.limit, e, r);
|
|
2357
2354
|
}
|
|
2358
|
-
return
|
|
2355
|
+
return n.$;
|
|
2359
2356
|
}
|
|
2360
2357
|
|
|
2361
|
-
function
|
|
2362
|
-
return function(t,
|
|
2363
|
-
if (t.limit !==
|
|
2364
|
-
if (t.orderBy.length !==
|
|
2365
|
-
for (let
|
|
2366
|
-
if (t.filters.length !==
|
|
2367
|
-
for (let s = 0; s < t.filters.length; s++) if (
|
|
2368
|
-
|
|
2369
|
-
var
|
|
2370
|
-
return t.collectionGroup ===
|
|
2371
|
-
}(
|
|
2358
|
+
function ln(t, n) {
|
|
2359
|
+
return function(t, n) {
|
|
2360
|
+
if (t.limit !== n.limit) return !1;
|
|
2361
|
+
if (t.orderBy.length !== n.orderBy.length) return !1;
|
|
2362
|
+
for (let e = 0; e < t.orderBy.length; e++) if (!nn(t.orderBy[e], n.orderBy[e])) return !1;
|
|
2363
|
+
if (t.filters.length !== n.filters.length) return !1;
|
|
2364
|
+
for (let s = 0; s < t.filters.length; s++) if (e = t.filters[s], r = n.filters[s],
|
|
2365
|
+
e.op !== r.op || !e.field.isEqual(r.field) || !Nt(e.value, r.value)) return !1;
|
|
2366
|
+
var e, r;
|
|
2367
|
+
return t.collectionGroup === n.collectionGroup && !!t.path.isEqual(n.path) && !!en(t.startAt, n.startAt) && en(t.endAt, n.endAt);
|
|
2368
|
+
}(hn(t), hn(n)) && t.limitType === n.limitType;
|
|
2372
2369
|
}
|
|
2373
2370
|
|
|
2374
2371
|
/**
|
|
@@ -2396,10 +2393,10 @@ function he(t, e) {
|
|
|
2396
2393
|
* The return value is an IntegerValue if it can safely represent the value,
|
|
2397
2394
|
* otherwise a DoubleValue is returned.
|
|
2398
2395
|
*/
|
|
2399
|
-
function
|
|
2396
|
+
function fn(t, n) {
|
|
2400
2397
|
return function(t) {
|
|
2401
2398
|
return "number" == typeof t && Number.isInteger(t) && !ot(t) && t <= Number.MAX_SAFE_INTEGER && t >= Number.MIN_SAFE_INTEGER;
|
|
2402
|
-
}(
|
|
2399
|
+
}(n) ?
|
|
2403
2400
|
/**
|
|
2404
2401
|
* Returns an IntegerValue for `value`.
|
|
2405
2402
|
*/
|
|
@@ -2407,22 +2404,22 @@ function le(t, e) {
|
|
|
2407
2404
|
return {
|
|
2408
2405
|
integerValue: "" + t
|
|
2409
2406
|
};
|
|
2410
|
-
}(
|
|
2407
|
+
}(n) : function(t, n) {
|
|
2411
2408
|
if (t.F) {
|
|
2412
|
-
if (isNaN(
|
|
2409
|
+
if (isNaN(n)) return {
|
|
2413
2410
|
doubleValue: "NaN"
|
|
2414
2411
|
};
|
|
2415
|
-
if (
|
|
2412
|
+
if (n === 1 / 0) return {
|
|
2416
2413
|
doubleValue: "Infinity"
|
|
2417
2414
|
};
|
|
2418
|
-
if (
|
|
2415
|
+
if (n === -1 / 0) return {
|
|
2419
2416
|
doubleValue: "-Infinity"
|
|
2420
2417
|
};
|
|
2421
2418
|
}
|
|
2422
2419
|
return {
|
|
2423
|
-
doubleValue: ot(
|
|
2420
|
+
doubleValue: ot(n) ? "-0" : n
|
|
2424
2421
|
};
|
|
2425
|
-
}(t,
|
|
2422
|
+
}(t, n);
|
|
2426
2423
|
}
|
|
2427
2424
|
|
|
2428
2425
|
/**
|
|
@@ -2441,7 +2438,7 @@ function le(t, e) {
|
|
|
2441
2438
|
* See the License for the specific language governing permissions and
|
|
2442
2439
|
* limitations under the License.
|
|
2443
2440
|
*/
|
|
2444
|
-
/** Used to represent a field transform on a mutation. */ class
|
|
2441
|
+
/** Used to represent a field transform on a mutation. */ class dn {
|
|
2445
2442
|
constructor() {
|
|
2446
2443
|
// Make sure that the structural type of `TransformOperation` is unique.
|
|
2447
2444
|
// See https://github.com/microsoft/TypeScript/issues/5451
|
|
@@ -2449,15 +2446,15 @@ function le(t, e) {
|
|
|
2449
2446
|
}
|
|
2450
2447
|
}
|
|
2451
2448
|
|
|
2452
|
-
/** Transforms a value into a server-generated timestamp. */ class
|
|
2449
|
+
/** Transforms a value into a server-generated timestamp. */ class wn extends dn {}
|
|
2453
2450
|
|
|
2454
|
-
/** Transforms an array value via a union operation. */ class
|
|
2451
|
+
/** Transforms an array value via a union operation. */ class mn extends dn {
|
|
2455
2452
|
constructor(t) {
|
|
2456
2453
|
super(), this.elements = t;
|
|
2457
2454
|
}
|
|
2458
2455
|
}
|
|
2459
2456
|
|
|
2460
|
-
/** Transforms an array value via a remove operation. */ class
|
|
2457
|
+
/** Transforms an array value via a remove operation. */ class pn extends dn {
|
|
2461
2458
|
constructor(t) {
|
|
2462
2459
|
super(), this.elements = t;
|
|
2463
2460
|
}
|
|
@@ -2468,9 +2465,9 @@ function le(t, e) {
|
|
|
2468
2465
|
* transforms. Converts all field values to integers or doubles, but unlike the
|
|
2469
2466
|
* backend does not cap integer values at 2^63. Instead, JavaScript number
|
|
2470
2467
|
* arithmetic is used and precision loss can occur for values greater than 2^53.
|
|
2471
|
-
*/ class
|
|
2472
|
-
constructor(t,
|
|
2473
|
-
super(), this.S = t, this.q =
|
|
2468
|
+
*/ class yn extends dn {
|
|
2469
|
+
constructor(t, n) {
|
|
2470
|
+
super(), this.S = t, this.q = n;
|
|
2474
2471
|
}
|
|
2475
2472
|
}
|
|
2476
2473
|
|
|
@@ -2490,9 +2487,9 @@ function le(t, e) {
|
|
|
2490
2487
|
* See the License for the specific language governing permissions and
|
|
2491
2488
|
* limitations under the License.
|
|
2492
2489
|
*/
|
|
2493
|
-
/** A field path and the TransformOperation to perform upon it. */ class
|
|
2494
|
-
constructor(t,
|
|
2495
|
-
this.field = t, this.transform =
|
|
2490
|
+
/** A field path and the TransformOperation to perform upon it. */ class _n {
|
|
2491
|
+
constructor(t, n) {
|
|
2492
|
+
this.field = t, this.transform = n;
|
|
2496
2493
|
}
|
|
2497
2494
|
}
|
|
2498
2495
|
|
|
@@ -2500,18 +2497,18 @@ function le(t, e) {
|
|
|
2500
2497
|
* Encodes a precondition for a mutation. This follows the model that the
|
|
2501
2498
|
* backend accepts with the special case of an explicit "empty" precondition
|
|
2502
2499
|
* (meaning no precondition).
|
|
2503
|
-
*/ class
|
|
2504
|
-
constructor(t,
|
|
2505
|
-
this.updateTime = t, this.exists =
|
|
2500
|
+
*/ class gn {
|
|
2501
|
+
constructor(t, n) {
|
|
2502
|
+
this.updateTime = t, this.exists = n;
|
|
2506
2503
|
}
|
|
2507
2504
|
/** Creates a new empty Precondition. */ static none() {
|
|
2508
|
-
return new
|
|
2505
|
+
return new gn;
|
|
2509
2506
|
}
|
|
2510
2507
|
/** Creates a new Precondition with an exists flag. */ static exists(t) {
|
|
2511
|
-
return new
|
|
2508
|
+
return new gn(void 0, t);
|
|
2512
2509
|
}
|
|
2513
2510
|
/** Creates a new Precondition based on a version a document exists at. */ static updateTime(t) {
|
|
2514
|
-
return new
|
|
2511
|
+
return new gn(t);
|
|
2515
2512
|
}
|
|
2516
2513
|
/** Returns whether this Precondition is empty. */ get isNone() {
|
|
2517
2514
|
return void 0 === this.updateTime && void 0 === this.exists;
|
|
@@ -2564,14 +2561,14 @@ function le(t, e) {
|
|
|
2564
2561
|
* applyToLocalView() to implement the actual behavior of applying the mutation
|
|
2565
2562
|
* to some source document (see `setMutationApplyToRemoteDocument()` for an
|
|
2566
2563
|
* example).
|
|
2567
|
-
*/ class
|
|
2564
|
+
*/ class bn {}
|
|
2568
2565
|
|
|
2569
2566
|
/**
|
|
2570
2567
|
* A mutation that creates or replaces the document at the given key with the
|
|
2571
2568
|
* object value contents.
|
|
2572
|
-
*/ class
|
|
2573
|
-
constructor(t,
|
|
2574
|
-
super(), this.key = t, this.value =
|
|
2569
|
+
*/ class vn extends bn {
|
|
2570
|
+
constructor(t, n, e, r = []) {
|
|
2571
|
+
super(), this.key = t, this.value = n, this.precondition = e, this.fieldTransforms = r,
|
|
2575
2572
|
this.type = 0 /* Set */;
|
|
2576
2573
|
}
|
|
2577
2574
|
}
|
|
@@ -2588,16 +2585,16 @@ function le(t, e) {
|
|
|
2588
2585
|
* is deleted.
|
|
2589
2586
|
* * When a field is not in the mask but is in the values, the values map is
|
|
2590
2587
|
* ignored.
|
|
2591
|
-
*/ class
|
|
2592
|
-
constructor(t,
|
|
2593
|
-
super(), this.key = t, this.data =
|
|
2588
|
+
*/ class En extends bn {
|
|
2589
|
+
constructor(t, n, e, r, s = []) {
|
|
2590
|
+
super(), this.key = t, this.data = n, this.fieldMask = e, this.precondition = r,
|
|
2594
2591
|
this.fieldTransforms = s, this.type = 1 /* Patch */;
|
|
2595
2592
|
}
|
|
2596
2593
|
}
|
|
2597
2594
|
|
|
2598
|
-
/** A mutation that deletes the document at the given key. */ class
|
|
2599
|
-
constructor(t,
|
|
2600
|
-
super(), this.key = t, this.precondition =
|
|
2595
|
+
/** A mutation that deletes the document at the given key. */ class Tn extends bn {
|
|
2596
|
+
constructor(t, n) {
|
|
2597
|
+
super(), this.key = t, this.precondition = n, this.type = 2 /* Delete */ , this.fieldTransforms = [];
|
|
2601
2598
|
}
|
|
2602
2599
|
}
|
|
2603
2600
|
|
|
@@ -2607,9 +2604,9 @@ function le(t, e) {
|
|
|
2607
2604
|
*
|
|
2608
2605
|
* The `verify` operation is only used in Transactions, and this class serves
|
|
2609
2606
|
* primarily to facilitate serialization into protos.
|
|
2610
|
-
*/ class
|
|
2611
|
-
constructor(t,
|
|
2612
|
-
super(), this.key = t, this.precondition =
|
|
2607
|
+
*/ class In extends bn {
|
|
2608
|
+
constructor(t, n) {
|
|
2609
|
+
super(), this.key = t, this.precondition = n, this.type = 3 /* Verify */ , this.fieldTransforms = [];
|
|
2613
2610
|
}
|
|
2614
2611
|
}
|
|
2615
2612
|
|
|
@@ -2628,13 +2625,13 @@ function le(t, e) {
|
|
|
2628
2625
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2629
2626
|
* See the License for the specific language governing permissions and
|
|
2630
2627
|
* limitations under the License.
|
|
2631
|
-
*/ const
|
|
2628
|
+
*/ const An = (() => {
|
|
2632
2629
|
const t = {
|
|
2633
2630
|
asc: "ASCENDING",
|
|
2634
2631
|
desc: "DESCENDING"
|
|
2635
2632
|
};
|
|
2636
2633
|
return t;
|
|
2637
|
-
})(),
|
|
2634
|
+
})(), Pn = (() => {
|
|
2638
2635
|
const t = {
|
|
2639
2636
|
"<": "LESS_THAN",
|
|
2640
2637
|
"<=": "LESS_THAN_OR_EQUAL",
|
|
@@ -2664,9 +2661,9 @@ function le(t, e) {
|
|
|
2664
2661
|
* TODO(klimt): We can remove the databaseId argument if we keep the full
|
|
2665
2662
|
* resource name in documents.
|
|
2666
2663
|
*/
|
|
2667
|
-
class
|
|
2668
|
-
constructor(t,
|
|
2669
|
-
this.databaseId = t, this.F =
|
|
2664
|
+
class Rn {
|
|
2665
|
+
constructor(t, n) {
|
|
2666
|
+
this.databaseId = t, this.F = n;
|
|
2670
2667
|
}
|
|
2671
2668
|
}
|
|
2672
2669
|
|
|
@@ -2681,13 +2678,13 @@ class Pe {
|
|
|
2681
2678
|
/**
|
|
2682
2679
|
* Returns a value for a Date that's appropriate to put into a proto.
|
|
2683
2680
|
*/
|
|
2684
|
-
function
|
|
2681
|
+
function Vn(t, n) {
|
|
2685
2682
|
if (t.F) {
|
|
2686
|
-
return `${new Date(1e3 *
|
|
2683
|
+
return `${new Date(1e3 * n.seconds).toISOString().replace(/\.\d*/, "").replace("Z", "")}.${("000000000" + n.nanoseconds).slice(-9)}Z`;
|
|
2687
2684
|
}
|
|
2688
2685
|
return {
|
|
2689
|
-
seconds: "" +
|
|
2690
|
-
nanos:
|
|
2686
|
+
seconds: "" + n.seconds,
|
|
2687
|
+
nanos: n.nanoseconds
|
|
2691
2688
|
};
|
|
2692
2689
|
}
|
|
2693
2690
|
|
|
@@ -2696,202 +2693,202 @@ function Re(t, e) {
|
|
|
2696
2693
|
*
|
|
2697
2694
|
* Visible for testing.
|
|
2698
2695
|
*/
|
|
2699
|
-
function
|
|
2700
|
-
return t.F ?
|
|
2696
|
+
function Dn(t, n) {
|
|
2697
|
+
return t.F ? n.toBase64() : n.toUint8Array();
|
|
2701
2698
|
}
|
|
2702
2699
|
|
|
2703
|
-
function
|
|
2704
|
-
return
|
|
2700
|
+
function Nn(t, n) {
|
|
2701
|
+
return Vn(t, n.toTimestamp());
|
|
2705
2702
|
}
|
|
2706
2703
|
|
|
2707
|
-
function
|
|
2704
|
+
function $n(t) {
|
|
2708
2705
|
return g(!!t), yt.fromTimestamp(function(t) {
|
|
2709
|
-
const
|
|
2710
|
-
return new pt(
|
|
2706
|
+
const n = Tt(t);
|
|
2707
|
+
return new pt(n.seconds, n.nanos);
|
|
2711
2708
|
}(t));
|
|
2712
2709
|
}
|
|
2713
2710
|
|
|
2714
|
-
function
|
|
2711
|
+
function Fn(t, n) {
|
|
2715
2712
|
return function(t) {
|
|
2716
2713
|
return new Y([ "projects", t.projectId, "databases", t.database ]);
|
|
2717
|
-
}(t).child("documents").child(
|
|
2714
|
+
}(t).child("documents").child(n).canonicalString();
|
|
2718
2715
|
}
|
|
2719
2716
|
|
|
2720
|
-
function
|
|
2721
|
-
return
|
|
2717
|
+
function Sn(t, n) {
|
|
2718
|
+
return Fn(t.databaseId, n.path);
|
|
2722
2719
|
}
|
|
2723
2720
|
|
|
2724
|
-
function
|
|
2725
|
-
const
|
|
2726
|
-
const
|
|
2727
|
-
return g(
|
|
2728
|
-
}(
|
|
2729
|
-
if (
|
|
2730
|
-
if (
|
|
2731
|
-
return new Z((g((r =
|
|
2721
|
+
function qn(t, n) {
|
|
2722
|
+
const e = function(t) {
|
|
2723
|
+
const n = Y.fromString(t);
|
|
2724
|
+
return g(Gn(n)), n;
|
|
2725
|
+
}(n);
|
|
2726
|
+
if (e.get(1) !== t.databaseId.projectId) throw new L(I, "Tried to deserialize key from different project: " + e.get(1) + " vs " + t.databaseId.projectId);
|
|
2727
|
+
if (e.get(3) !== t.databaseId.database) throw new L(I, "Tried to deserialize key from different database: " + e.get(3) + " vs " + t.databaseId.database);
|
|
2728
|
+
return new Z((g((r = e).length > 4 && "documents" === r.get(4)), r.popFirst(5)));
|
|
2732
2729
|
var r;
|
|
2733
2730
|
/** Creates a Document proto from key and fields (but no create/update time) */}
|
|
2734
2731
|
|
|
2735
|
-
function
|
|
2736
|
-
return
|
|
2732
|
+
function xn(t, n) {
|
|
2733
|
+
return Fn(t.databaseId, n);
|
|
2737
2734
|
}
|
|
2738
2735
|
|
|
2739
|
-
function
|
|
2736
|
+
function On(t) {
|
|
2740
2737
|
return new Y([ "projects", t.databaseId.projectId, "databases", t.databaseId.database ]).canonicalString();
|
|
2741
2738
|
}
|
|
2742
2739
|
|
|
2743
|
-
function
|
|
2740
|
+
function Cn(t, n, e) {
|
|
2744
2741
|
return {
|
|
2745
|
-
name:
|
|
2746
|
-
fields:
|
|
2742
|
+
name: Sn(t, n),
|
|
2743
|
+
fields: e.value.mapValue.fields
|
|
2747
2744
|
};
|
|
2748
2745
|
}
|
|
2749
2746
|
|
|
2750
|
-
function
|
|
2751
|
-
return "found" in
|
|
2752
|
-
g(!!
|
|
2753
|
-
const
|
|
2747
|
+
function Ln(t, n) {
|
|
2748
|
+
return "found" in n ? function(t, n) {
|
|
2749
|
+
g(!!n.found), n.found.name, n.found.updateTime;
|
|
2750
|
+
const e = qn(t, n.found.name), r = $n(n.found.updateTime), s = new jt({
|
|
2754
2751
|
mapValue: {
|
|
2755
|
-
fields:
|
|
2752
|
+
fields: n.found.fields
|
|
2756
2753
|
}
|
|
2757
2754
|
});
|
|
2758
|
-
return kt.newFoundDocument(
|
|
2759
|
-
}(t,
|
|
2760
|
-
g(!!
|
|
2761
|
-
const
|
|
2762
|
-
return kt.newNoDocument(
|
|
2763
|
-
}(t,
|
|
2764
|
-
}
|
|
2765
|
-
|
|
2766
|
-
function
|
|
2767
|
-
let
|
|
2768
|
-
if (
|
|
2769
|
-
update:
|
|
2770
|
-
}; else if (
|
|
2771
|
-
delete:
|
|
2772
|
-
}; else if (
|
|
2773
|
-
update:
|
|
2774
|
-
updateMask:
|
|
2755
|
+
return kt.newFoundDocument(e, r, s);
|
|
2756
|
+
}(t, n) : "missing" in n ? function(t, n) {
|
|
2757
|
+
g(!!n.missing), g(!!n.readTime);
|
|
2758
|
+
const e = qn(t, n.missing), r = $n(n.readTime);
|
|
2759
|
+
return kt.newNoDocument(e, r);
|
|
2760
|
+
}(t, n) : _();
|
|
2761
|
+
}
|
|
2762
|
+
|
|
2763
|
+
function Un(t, n) {
|
|
2764
|
+
let e;
|
|
2765
|
+
if (n instanceof vn) e = {
|
|
2766
|
+
update: Cn(t, n.key, n.value)
|
|
2767
|
+
}; else if (n instanceof Tn) e = {
|
|
2768
|
+
delete: Sn(t, n.key)
|
|
2769
|
+
}; else if (n instanceof En) e = {
|
|
2770
|
+
update: Cn(t, n.key, n.data),
|
|
2771
|
+
updateMask: zn(n.fieldMask)
|
|
2775
2772
|
}; else {
|
|
2776
|
-
if (!(
|
|
2777
|
-
|
|
2778
|
-
verify:
|
|
2773
|
+
if (!(n instanceof In)) return _();
|
|
2774
|
+
e = {
|
|
2775
|
+
verify: Sn(t, n.key)
|
|
2779
2776
|
};
|
|
2780
2777
|
}
|
|
2781
|
-
return
|
|
2782
|
-
const
|
|
2783
|
-
if (
|
|
2784
|
-
fieldPath:
|
|
2778
|
+
return n.fieldTransforms.length > 0 && (e.updateTransforms = n.fieldTransforms.map((t => function(t, n) {
|
|
2779
|
+
const e = n.transform;
|
|
2780
|
+
if (e instanceof wn) return {
|
|
2781
|
+
fieldPath: n.field.canonicalString(),
|
|
2785
2782
|
setToServerValue: "REQUEST_TIME"
|
|
2786
2783
|
};
|
|
2787
|
-
if (
|
|
2788
|
-
fieldPath:
|
|
2784
|
+
if (e instanceof mn) return {
|
|
2785
|
+
fieldPath: n.field.canonicalString(),
|
|
2789
2786
|
appendMissingElements: {
|
|
2790
|
-
values:
|
|
2787
|
+
values: e.elements
|
|
2791
2788
|
}
|
|
2792
2789
|
};
|
|
2793
|
-
if (
|
|
2794
|
-
fieldPath:
|
|
2790
|
+
if (e instanceof pn) return {
|
|
2791
|
+
fieldPath: n.field.canonicalString(),
|
|
2795
2792
|
removeAllFromArray: {
|
|
2796
|
-
values:
|
|
2793
|
+
values: e.elements
|
|
2797
2794
|
}
|
|
2798
2795
|
};
|
|
2799
|
-
if (
|
|
2800
|
-
fieldPath:
|
|
2801
|
-
increment:
|
|
2796
|
+
if (e instanceof yn) return {
|
|
2797
|
+
fieldPath: n.field.canonicalString(),
|
|
2798
|
+
increment: e.q
|
|
2802
2799
|
};
|
|
2803
2800
|
throw _();
|
|
2804
|
-
}(0, t)))),
|
|
2805
|
-
return void 0 !==
|
|
2806
|
-
updateTime:
|
|
2807
|
-
} : void 0 !==
|
|
2808
|
-
exists:
|
|
2801
|
+
}(0, t)))), n.precondition.isNone || (e.currentDocument = function(t, n) {
|
|
2802
|
+
return void 0 !== n.updateTime ? {
|
|
2803
|
+
updateTime: Nn(t, n.updateTime)
|
|
2804
|
+
} : void 0 !== n.exists ? {
|
|
2805
|
+
exists: n.exists
|
|
2809
2806
|
} : _();
|
|
2810
|
-
}(t,
|
|
2807
|
+
}(t, n.precondition)), e;
|
|
2811
2808
|
}
|
|
2812
2809
|
|
|
2813
|
-
function
|
|
2810
|
+
function jn(t, n) {
|
|
2814
2811
|
// Dissect the path into parent, collectionId, and optional key filter.
|
|
2815
|
-
const
|
|
2812
|
+
const e = {
|
|
2816
2813
|
structuredQuery: {}
|
|
2817
|
-
}, r =
|
|
2818
|
-
null !==
|
|
2819
|
-
collectionId:
|
|
2814
|
+
}, r = n.path;
|
|
2815
|
+
null !== n.collectionGroup ? (e.parent = xn(t, r), e.structuredQuery.from = [ {
|
|
2816
|
+
collectionId: n.collectionGroup,
|
|
2820
2817
|
allDescendants: !0
|
|
2821
|
-
} ]) : (
|
|
2818
|
+
} ]) : (e.parent = xn(t, r.popLast()), e.structuredQuery.from = [ {
|
|
2822
2819
|
collectionId: r.lastSegment()
|
|
2823
2820
|
} ]);
|
|
2824
2821
|
const s = function(t) {
|
|
2825
2822
|
if (0 === t.length) return;
|
|
2826
|
-
const
|
|
2823
|
+
const n = t.map((t =>
|
|
2827
2824
|
// visible for testing
|
|
2828
2825
|
function(t) {
|
|
2829
2826
|
if ("==" /* EQUAL */ === t.op) {
|
|
2830
2827
|
if (Ct(t.value)) return {
|
|
2831
2828
|
unaryFilter: {
|
|
2832
|
-
field:
|
|
2829
|
+
field: Qn(t.field),
|
|
2833
2830
|
op: "IS_NAN"
|
|
2834
2831
|
}
|
|
2835
2832
|
};
|
|
2836
2833
|
if (Ot(t.value)) return {
|
|
2837
2834
|
unaryFilter: {
|
|
2838
|
-
field:
|
|
2835
|
+
field: Qn(t.field),
|
|
2839
2836
|
op: "IS_NULL"
|
|
2840
2837
|
}
|
|
2841
2838
|
};
|
|
2842
2839
|
} else if ("!=" /* NOT_EQUAL */ === t.op) {
|
|
2843
2840
|
if (Ct(t.value)) return {
|
|
2844
2841
|
unaryFilter: {
|
|
2845
|
-
field:
|
|
2842
|
+
field: Qn(t.field),
|
|
2846
2843
|
op: "IS_NOT_NAN"
|
|
2847
2844
|
}
|
|
2848
2845
|
};
|
|
2849
2846
|
if (Ot(t.value)) return {
|
|
2850
2847
|
unaryFilter: {
|
|
2851
|
-
field:
|
|
2848
|
+
field: Qn(t.field),
|
|
2852
2849
|
op: "IS_NOT_NULL"
|
|
2853
2850
|
}
|
|
2854
2851
|
};
|
|
2855
2852
|
}
|
|
2856
2853
|
return {
|
|
2857
2854
|
fieldFilter: {
|
|
2858
|
-
field:
|
|
2859
|
-
op:
|
|
2855
|
+
field: Qn(t.field),
|
|
2856
|
+
op: Mn(t.op),
|
|
2860
2857
|
value: t.value
|
|
2861
2858
|
}
|
|
2862
2859
|
};
|
|
2863
2860
|
}(t)));
|
|
2864
|
-
if (1 ===
|
|
2861
|
+
if (1 === n.length) return n[0];
|
|
2865
2862
|
return {
|
|
2866
2863
|
compositeFilter: {
|
|
2867
2864
|
op: "AND",
|
|
2868
|
-
filters:
|
|
2865
|
+
filters: n
|
|
2869
2866
|
}
|
|
2870
2867
|
};
|
|
2871
|
-
}(
|
|
2872
|
-
s && (
|
|
2868
|
+
}(n.filters);
|
|
2869
|
+
s && (e.structuredQuery.where = s);
|
|
2873
2870
|
const i = function(t) {
|
|
2874
2871
|
if (0 === t.length) return;
|
|
2875
2872
|
return t.map((t =>
|
|
2876
2873
|
// visible for testing
|
|
2877
2874
|
function(t) {
|
|
2878
2875
|
return {
|
|
2879
|
-
field:
|
|
2880
|
-
direction:
|
|
2876
|
+
field: Qn(t.field),
|
|
2877
|
+
direction: Bn(t.dir)
|
|
2881
2878
|
};
|
|
2882
2879
|
}(t)));
|
|
2883
|
-
}(
|
|
2884
|
-
i && (
|
|
2885
|
-
const o = function(t,
|
|
2886
|
-
return t.F || it(
|
|
2887
|
-
value:
|
|
2880
|
+
}(n.orderBy);
|
|
2881
|
+
i && (e.structuredQuery.orderBy = i);
|
|
2882
|
+
const o = function(t, n) {
|
|
2883
|
+
return t.F || it(n) ? n : {
|
|
2884
|
+
value: n
|
|
2888
2885
|
};
|
|
2889
|
-
}(t,
|
|
2890
|
-
return null !== o && (
|
|
2891
|
-
|
|
2886
|
+
}(t, n.limit);
|
|
2887
|
+
return null !== o && (e.structuredQuery.limit = o), n.startAt && (e.structuredQuery.startAt = kn(n.startAt)),
|
|
2888
|
+
n.endAt && (e.structuredQuery.endAt = kn(n.endAt)), e;
|
|
2892
2889
|
}
|
|
2893
2890
|
|
|
2894
|
-
function
|
|
2891
|
+
function kn(t) {
|
|
2895
2892
|
return {
|
|
2896
2893
|
before: t.before,
|
|
2897
2894
|
values: t.position
|
|
@@ -2899,29 +2896,29 @@ function je(t) {
|
|
|
2899
2896
|
}
|
|
2900
2897
|
|
|
2901
2898
|
// visible for testing
|
|
2902
|
-
function
|
|
2903
|
-
return
|
|
2899
|
+
function Bn(t) {
|
|
2900
|
+
return An[t];
|
|
2904
2901
|
}
|
|
2905
2902
|
|
|
2906
2903
|
// visible for testing
|
|
2907
|
-
function
|
|
2908
|
-
return
|
|
2904
|
+
function Mn(t) {
|
|
2905
|
+
return Pn[t];
|
|
2909
2906
|
}
|
|
2910
2907
|
|
|
2911
|
-
function
|
|
2908
|
+
function Qn(t) {
|
|
2912
2909
|
return {
|
|
2913
2910
|
fieldPath: t.canonicalString()
|
|
2914
2911
|
};
|
|
2915
2912
|
}
|
|
2916
2913
|
|
|
2917
|
-
function
|
|
2918
|
-
const
|
|
2919
|
-
return t.fields.forEach((t =>
|
|
2920
|
-
fieldPaths:
|
|
2914
|
+
function zn(t) {
|
|
2915
|
+
const n = [];
|
|
2916
|
+
return t.fields.forEach((t => n.push(t.canonicalString()))), {
|
|
2917
|
+
fieldPaths: n
|
|
2921
2918
|
};
|
|
2922
2919
|
}
|
|
2923
2920
|
|
|
2924
|
-
function
|
|
2921
|
+
function Gn(t) {
|
|
2925
2922
|
// Resource names have at least 4 components (project ID, database ID)
|
|
2926
2923
|
return t.length >= 4 && "projects" === t.get(0) && "databases" === t.get(2);
|
|
2927
2924
|
}
|
|
@@ -2941,8 +2938,8 @@ function ze(t) {
|
|
|
2941
2938
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2942
2939
|
* See the License for the specific language governing permissions and
|
|
2943
2940
|
* limitations under the License.
|
|
2944
|
-
*/ function
|
|
2945
|
-
return new
|
|
2941
|
+
*/ function Wn(t) {
|
|
2942
|
+
return new Rn(t, /* useProto3Json= */ !0);
|
|
2946
2943
|
}
|
|
2947
2944
|
|
|
2948
2945
|
/**
|
|
@@ -2970,7 +2967,7 @@ function ze(t) {
|
|
|
2970
2967
|
* base delay. This prevents clients from accidentally synchronizing their
|
|
2971
2968
|
* delays causing spikes of load to the backend.
|
|
2972
2969
|
*/
|
|
2973
|
-
class
|
|
2970
|
+
class Hn {
|
|
2974
2971
|
constructor(
|
|
2975
2972
|
/**
|
|
2976
2973
|
* The AsyncQueue to run backoff operations on.
|
|
@@ -2979,13 +2976,13 @@ class Ge {
|
|
|
2979
2976
|
/**
|
|
2980
2977
|
* The ID to use when scheduling backoff operations on the AsyncQueue.
|
|
2981
2978
|
*/
|
|
2982
|
-
|
|
2979
|
+
n,
|
|
2983
2980
|
/**
|
|
2984
2981
|
* The initial delay (used as the base delay on the first retry attempt).
|
|
2985
2982
|
* Note that jitter will still be applied, so the actual delay could be as
|
|
2986
2983
|
* little as 0.5*initialDelayMs.
|
|
2987
2984
|
*/
|
|
2988
|
-
|
|
2985
|
+
e = 1e3
|
|
2989
2986
|
/**
|
|
2990
2987
|
* The multiplier to use to determine the extended base delay after each
|
|
2991
2988
|
* attempt.
|
|
@@ -2995,9 +2992,9 @@ class Ge {
|
|
|
2995
2992
|
* Note that jitter will still be applied, so the actual delay could be as
|
|
2996
2993
|
* much as 1.5*maxDelayMs.
|
|
2997
2994
|
*/ , s = 6e4) {
|
|
2998
|
-
this.O = t, this.timerId =
|
|
2995
|
+
this.O = t, this.timerId = n, this.C = e, this.L = r, this.U = s, this.j = 0, this.k = null,
|
|
2999
2996
|
/** The last backoff attempt, as epoch milliseconds. */
|
|
3000
|
-
this.
|
|
2997
|
+
this.B = Date.now(), this.reset();
|
|
3001
2998
|
}
|
|
3002
2999
|
/**
|
|
3003
3000
|
* Resets the backoff delay.
|
|
@@ -3011,22 +3008,22 @@ class Ge {
|
|
|
3011
3008
|
/**
|
|
3012
3009
|
* Resets the backoff delay to the maximum delay (e.g. for use after a
|
|
3013
3010
|
* RESOURCE_EXHAUSTED error).
|
|
3014
|
-
*/
|
|
3011
|
+
*/ M() {
|
|
3015
3012
|
this.j = this.U;
|
|
3016
3013
|
}
|
|
3017
3014
|
/**
|
|
3018
3015
|
* Returns a promise that resolves after currentDelayMs, and increases the
|
|
3019
3016
|
* delay for any subsequent attempts. If there was a pending backoff operation
|
|
3020
3017
|
* already, it will be canceled.
|
|
3021
|
-
*/
|
|
3018
|
+
*/ G(t) {
|
|
3022
3019
|
// Cancel any pending backoff operation.
|
|
3023
3020
|
this.cancel();
|
|
3024
3021
|
// First schedule using the current base (which may be 0 and should be
|
|
3025
3022
|
// honored as such).
|
|
3026
|
-
const
|
|
3023
|
+
const n = Math.floor(this.j + this.W()), e = Math.max(0, Date.now() - this.B), r = Math.max(0, n - e);
|
|
3027
3024
|
// Guard against lastAttemptTime being in the future due to a clock change.
|
|
3028
|
-
r > 0 && w("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.j} ms, delay with jitter: ${
|
|
3029
|
-
this.k = this.O.enqueueAfterDelay(this.timerId, r, (() => (this.
|
|
3025
|
+
r > 0 && w("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.j} ms, delay with jitter: ${n} ms, last attempt: ${e} ms ago)`),
|
|
3026
|
+
this.k = this.O.enqueueAfterDelay(this.timerId, r, (() => (this.B = Date.now(),
|
|
3030
3027
|
t()))),
|
|
3031
3028
|
// Apply backoff factor to determine next delay and ensure it is within
|
|
3032
3029
|
// bounds.
|
|
@@ -3038,7 +3035,7 @@ class Ge {
|
|
|
3038
3035
|
cancel() {
|
|
3039
3036
|
null !== this.k && (this.k.cancel(), this.k = null);
|
|
3040
3037
|
}
|
|
3041
|
-
/** Returns a random value in the range [-currentBaseMs/2, currentBaseMs/2] */
|
|
3038
|
+
/** Returns a random value in the range [-currentBaseMs/2, currentBaseMs/2] */ W() {
|
|
3042
3039
|
return (Math.random() - .5) * this.j;
|
|
3043
3040
|
}
|
|
3044
3041
|
}
|
|
@@ -3068,23 +3065,23 @@ class Ge {
|
|
|
3068
3065
|
* An implementation of Datastore that exposes additional state for internal
|
|
3069
3066
|
* consumption.
|
|
3070
3067
|
*/
|
|
3071
|
-
class
|
|
3072
|
-
constructor(t,
|
|
3073
|
-
super(), this.credentials = t, this.Y =
|
|
3068
|
+
class Yn extends class {} {
|
|
3069
|
+
constructor(t, n, e) {
|
|
3070
|
+
super(), this.credentials = t, this.Y = n, this.S = e, this.K = !1;
|
|
3074
3071
|
}
|
|
3075
3072
|
J() {
|
|
3076
3073
|
if (this.K) throw new L($, "The client has already been terminated.");
|
|
3077
3074
|
}
|
|
3078
|
-
/** Gets an auth token and invokes the provided RPC. */ l(t,
|
|
3079
|
-
return this.J(), this.credentials.getToken().then((r => this.Y.l(t,
|
|
3080
|
-
throw "FirebaseError" === t.name ? (t.code ===
|
|
3081
|
-
t) : new L(
|
|
3075
|
+
/** Gets an auth token and invokes the provided RPC. */ l(t, n, e) {
|
|
3076
|
+
return this.J(), this.credentials.getToken().then((r => this.Y.l(t, n, e, r))).catch((t => {
|
|
3077
|
+
throw "FirebaseError" === t.name ? (t.code === D && this.credentials.invalidateToken(),
|
|
3078
|
+
t) : new L(T, t.toString());
|
|
3082
3079
|
}));
|
|
3083
3080
|
}
|
|
3084
|
-
/** Gets an auth token and invokes the provided RPC with streamed results. */ v(t,
|
|
3085
|
-
return this.J(), this.credentials.getToken().then((r => this.Y.v(t,
|
|
3086
|
-
throw "FirebaseError" === t.name ? (t.code ===
|
|
3087
|
-
t) : new L(
|
|
3081
|
+
/** Gets an auth token and invokes the provided RPC with streamed results. */ v(t, n, e) {
|
|
3082
|
+
return this.J(), this.credentials.getToken().then((r => this.Y.v(t, n, e, r))).catch((t => {
|
|
3083
|
+
throw "FirebaseError" === t.name ? (t.code === D && this.credentials.invalidateToken(),
|
|
3084
|
+
t) : new L(T, t.toString());
|
|
3088
3085
|
}));
|
|
3089
3086
|
}
|
|
3090
3087
|
terminate() {
|
|
@@ -3094,40 +3091,40 @@ class He extends class {} {
|
|
|
3094
3091
|
|
|
3095
3092
|
// TODO(firestorexp): Make sure there is only one Datastore instance per
|
|
3096
3093
|
// firestore-exp client.
|
|
3097
|
-
async function
|
|
3098
|
-
const
|
|
3099
|
-
writes:
|
|
3094
|
+
async function Kn(t, n) {
|
|
3095
|
+
const e = b(t), r = On(e.S) + "/documents", s = {
|
|
3096
|
+
writes: n.map((t => Un(e.S, t)))
|
|
3100
3097
|
};
|
|
3101
|
-
await
|
|
3098
|
+
await e.l("Commit", r, s);
|
|
3102
3099
|
}
|
|
3103
3100
|
|
|
3104
|
-
async function
|
|
3105
|
-
const
|
|
3106
|
-
documents:
|
|
3107
|
-
}, i = await
|
|
3101
|
+
async function Jn(t, n) {
|
|
3102
|
+
const e = b(t), r = On(e.S) + "/documents", s = {
|
|
3103
|
+
documents: n.map((t => Sn(e.S, t)))
|
|
3104
|
+
}, i = await e.v("BatchGetDocuments", r, s), o = new Map;
|
|
3108
3105
|
i.forEach((t => {
|
|
3109
|
-
const
|
|
3110
|
-
o.set(
|
|
3106
|
+
const n = Ln(e.S, t);
|
|
3107
|
+
o.set(n.key.toString(), n);
|
|
3111
3108
|
}));
|
|
3112
3109
|
const u = [];
|
|
3113
|
-
return
|
|
3114
|
-
const
|
|
3115
|
-
g(!!
|
|
3110
|
+
return n.forEach((t => {
|
|
3111
|
+
const n = o.get(t.toString());
|
|
3112
|
+
g(!!n), u.push(n);
|
|
3116
3113
|
})), u;
|
|
3117
3114
|
}
|
|
3118
3115
|
|
|
3119
|
-
async function
|
|
3120
|
-
const
|
|
3121
|
-
return (await
|
|
3116
|
+
async function Zn(t, n) {
|
|
3117
|
+
const e = b(t), r = jn(e.S, hn(n));
|
|
3118
|
+
return (await e.v("RunQuery", r.parent, {
|
|
3122
3119
|
structuredQuery: r.structuredQuery
|
|
3123
|
-
})).filter((t => !!t.document)).map((t => function(t,
|
|
3124
|
-
const r =
|
|
3120
|
+
})).filter((t => !!t.document)).map((t => function(t, n, e) {
|
|
3121
|
+
const r = qn(t, n.name), s = $n(n.updateTime), i = new jt({
|
|
3125
3122
|
mapValue: {
|
|
3126
|
-
fields:
|
|
3123
|
+
fields: n.fields
|
|
3127
3124
|
}
|
|
3128
3125
|
}), o = kt.newFoundDocument(r, s, i);
|
|
3129
|
-
return
|
|
3130
|
-
}(
|
|
3126
|
+
return e && o.setHasCommittedMutations(), e ? o.setHasCommittedMutations() : o;
|
|
3127
|
+
}(e.S, t.document, void 0)));
|
|
3131
3128
|
}
|
|
3132
3129
|
|
|
3133
3130
|
/**
|
|
@@ -3145,7 +3142,7 @@ async function Je(t, e) {
|
|
|
3145
3142
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3146
3143
|
* See the License for the specific language governing permissions and
|
|
3147
3144
|
* limitations under the License.
|
|
3148
|
-
*/ const
|
|
3145
|
+
*/ const Xn = new Map;
|
|
3149
3146
|
|
|
3150
3147
|
/**
|
|
3151
3148
|
* An instance map that ensures only one Datastore exists per Firestore
|
|
@@ -3156,19 +3153,19 @@ async function Je(t, e) {
|
|
|
3156
3153
|
* instance. Callers must invoke removeComponents() when the Firestore
|
|
3157
3154
|
* instance is terminated.
|
|
3158
3155
|
*/
|
|
3159
|
-
function
|
|
3156
|
+
function te(t) {
|
|
3160
3157
|
if (t._terminated) throw new L($, "The client has already been terminated.");
|
|
3161
|
-
if (!
|
|
3158
|
+
if (!Xn.has(t)) {
|
|
3162
3159
|
w("ComponentProvider", "Initializing Datastore");
|
|
3163
3160
|
const i = function(t) {
|
|
3164
3161
|
return new lt(t, fetch.bind(null));
|
|
3165
|
-
}((
|
|
3166
|
-
new
|
|
3167
|
-
return new
|
|
3162
|
+
}((n = t._databaseId, e = t.app.options.appId || "", r = t._persistenceKey, s = t._freezeSettings(),
|
|
3163
|
+
new G(n, e, r, s.host, s.ssl, s.experimentalForceLongPolling, s.experimentalAutoDetectLongPolling, s.useFetchStreams))), o = Wn(t._databaseId), u = function(t, n, e) {
|
|
3164
|
+
return new Yn(t, n, e);
|
|
3168
3165
|
}(t._credentials, i, o);
|
|
3169
|
-
|
|
3166
|
+
Xn.set(t, u);
|
|
3170
3167
|
}
|
|
3171
|
-
var
|
|
3168
|
+
var n, e, r, s;
|
|
3172
3169
|
/**
|
|
3173
3170
|
* @license
|
|
3174
3171
|
* Copyright 2018 Google LLC
|
|
@@ -3184,7 +3181,7 @@ function Xe(t) {
|
|
|
3184
3181
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3185
3182
|
* See the License for the specific language governing permissions and
|
|
3186
3183
|
* limitations under the License.
|
|
3187
|
-
*/ return
|
|
3184
|
+
*/ return Xn.get(t);
|
|
3188
3185
|
}
|
|
3189
3186
|
|
|
3190
3187
|
/**
|
|
@@ -3196,21 +3193,21 @@ function Xe(t) {
|
|
|
3196
3193
|
* user-supplied `FirestoreSettings` object. This is a separate type so that
|
|
3197
3194
|
* defaults can be supplied and the value can be checked for equality.
|
|
3198
3195
|
*/
|
|
3199
|
-
class
|
|
3196
|
+
class ne {
|
|
3200
3197
|
constructor(t) {
|
|
3201
|
-
var
|
|
3198
|
+
var n;
|
|
3202
3199
|
if (void 0 === t.host) {
|
|
3203
|
-
if (void 0 !== t.ssl) throw new L(
|
|
3200
|
+
if (void 0 !== t.ssl) throw new L(I, "Can't provide ssl option if host option is not set");
|
|
3204
3201
|
this.host = "firestore.googleapis.com", this.ssl = true;
|
|
3205
|
-
} else this.host = t.host, this.ssl = null === (
|
|
3202
|
+
} else this.host = t.host, this.ssl = null === (n = t.ssl) || void 0 === n || n;
|
|
3206
3203
|
if (this.credentials = t.credentials, this.ignoreUndefinedProperties = !!t.ignoreUndefinedProperties,
|
|
3207
3204
|
void 0 === t.cacheSizeBytes) this.cacheSizeBytes = 41943040; else {
|
|
3208
|
-
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new L(
|
|
3205
|
+
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new L(I, "cacheSizeBytes must be at least 1048576");
|
|
3209
3206
|
this.cacheSizeBytes = t.cacheSizeBytes;
|
|
3210
3207
|
}
|
|
3211
3208
|
this.experimentalForceLongPolling = !!t.experimentalForceLongPolling, this.experimentalAutoDetectLongPolling = !!t.experimentalAutoDetectLongPolling,
|
|
3212
|
-
this.useFetchStreams = !!t.useFetchStreams, function(t,
|
|
3213
|
-
if (!0 ===
|
|
3209
|
+
this.useFetchStreams = !!t.useFetchStreams, function(t, n, e, r) {
|
|
3210
|
+
if (!0 === n && !0 === r) throw new L(I, `${t} and ${e} cannot be used together.`);
|
|
3214
3211
|
}("experimentalForceLongPolling", t.experimentalForceLongPolling, "experimentalAutoDetectLongPolling", t.experimentalAutoDetectLongPolling);
|
|
3215
3212
|
}
|
|
3216
3213
|
isEqual(t) {
|
|
@@ -3238,18 +3235,18 @@ class tn {
|
|
|
3238
3235
|
* The Cloud Firestore service interface.
|
|
3239
3236
|
*
|
|
3240
3237
|
* Do not call this constructor directly. Instead, use {@link getFirestore}.
|
|
3241
|
-
*/ class
|
|
3238
|
+
*/ class ee {
|
|
3242
3239
|
/** @hideconstructor */
|
|
3243
|
-
constructor(t,
|
|
3244
|
-
this._credentials =
|
|
3240
|
+
constructor(t, n) {
|
|
3241
|
+
this._credentials = n,
|
|
3245
3242
|
/**
|
|
3246
3243
|
* Whether it's a Firestore or Firestore Lite instance.
|
|
3247
3244
|
*/
|
|
3248
|
-
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new
|
|
3249
|
-
this._settingsFrozen = !1, t instanceof
|
|
3245
|
+
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new ne({}),
|
|
3246
|
+
this._settingsFrozen = !1, t instanceof W ? this._databaseId = t : (this._app = t,
|
|
3250
3247
|
this._databaseId = function(t) {
|
|
3251
|
-
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new L(
|
|
3252
|
-
return new
|
|
3248
|
+
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new L(I, '"projectId" not provided in firebase.initializeApp.');
|
|
3249
|
+
return new W(t.options.projectId);
|
|
3253
3250
|
}
|
|
3254
3251
|
/**
|
|
3255
3252
|
* Initializes a new instance of Cloud Firestore with the provided settings.
|
|
@@ -3278,20 +3275,20 @@ class tn {
|
|
|
3278
3275
|
}
|
|
3279
3276
|
_setSettings(t) {
|
|
3280
3277
|
if (this._settingsFrozen) throw new L($, "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.");
|
|
3281
|
-
this._settings = new
|
|
3278
|
+
this._settings = new ne(t), void 0 !== t.credentials && (this._credentials = function(t) {
|
|
3282
3279
|
if (!t) return new k;
|
|
3283
3280
|
switch (t.type) {
|
|
3284
3281
|
case "gapi":
|
|
3285
|
-
const
|
|
3282
|
+
const n = t.client;
|
|
3286
3283
|
// Make sure this really is a Gapi client.
|
|
3287
|
-
return g(!("object" != typeof
|
|
3288
|
-
new z(
|
|
3284
|
+
return g(!("object" != typeof n || null === n || !n.auth || !n.auth.getAuthHeaderValueForFirstParty)),
|
|
3285
|
+
new z(n, t.sessionIndex || "0", t.iamToken || null);
|
|
3289
3286
|
|
|
3290
3287
|
case "provider":
|
|
3291
3288
|
return t.client;
|
|
3292
3289
|
|
|
3293
3290
|
default:
|
|
3294
|
-
throw new L(
|
|
3291
|
+
throw new L(I, "makeCredentialsProvider failed due to invalid credential type");
|
|
3295
3292
|
}
|
|
3296
3293
|
}(t.credentials));
|
|
3297
3294
|
}
|
|
@@ -3319,17 +3316,17 @@ class tn {
|
|
|
3319
3316
|
* Only ever called once.
|
|
3320
3317
|
*/ _terminate() {
|
|
3321
3318
|
return function(t) {
|
|
3322
|
-
const
|
|
3323
|
-
|
|
3319
|
+
const n = Xn.get(t);
|
|
3320
|
+
n && (w("ComponentProvider", "Removing Datastore"), Xn.delete(t), n.terminate());
|
|
3324
3321
|
}(this), Promise.resolve();
|
|
3325
3322
|
}
|
|
3326
3323
|
}
|
|
3327
3324
|
|
|
3328
|
-
function
|
|
3329
|
-
const
|
|
3330
|
-
if (
|
|
3331
|
-
return
|
|
3332
|
-
options:
|
|
3325
|
+
function re(t, n) {
|
|
3326
|
+
const e = _getProvider(t, "firestore/lite");
|
|
3327
|
+
if (e.isInitialized()) throw new L($, "Firestore can only be initialized once per app.");
|
|
3328
|
+
return e.initialize({
|
|
3329
|
+
options: n
|
|
3333
3330
|
});
|
|
3334
3331
|
}
|
|
3335
3332
|
|
|
@@ -3341,8 +3338,8 @@ function nn(t, e) {
|
|
|
3341
3338
|
* @param app - The {@link @firebase/app#FirebaseApp} instance that the returned `Firestore`
|
|
3342
3339
|
* instance is associated with.
|
|
3343
3340
|
* @returns The `Firestore` instance of the provided app.
|
|
3344
|
-
*/ function
|
|
3345
|
-
return _getProvider(
|
|
3341
|
+
*/ function se(n = getApp()) {
|
|
3342
|
+
return _getProvider(n, "firestore/lite").getImmediate();
|
|
3346
3343
|
}
|
|
3347
3344
|
|
|
3348
3345
|
/**
|
|
@@ -3357,24 +3354,24 @@ function nn(t, e) {
|
|
|
3357
3354
|
* @param port - the emulator port (ex: 9000).
|
|
3358
3355
|
* @param options.mockUserToken - the mock auth token to use for unit testing
|
|
3359
3356
|
* Security Rules.
|
|
3360
|
-
*/ function
|
|
3357
|
+
*/ function ie(t, n, e, r = {}) {
|
|
3361
3358
|
var s;
|
|
3362
|
-
const i = (t = rt(t,
|
|
3363
|
-
if ("firestore.googleapis.com" !== i.host && i.host !==
|
|
3359
|
+
const i = (t = rt(t, ee))._getSettings();
|
|
3360
|
+
if ("firestore.googleapis.com" !== i.host && i.host !== n && p("Host has been set in both settings() and useEmulator(), emulator host will be used"),
|
|
3364
3361
|
t._setSettings(Object.assign(Object.assign({}, i), {
|
|
3365
|
-
host: `${
|
|
3362
|
+
host: `${n}:${e}`,
|
|
3366
3363
|
ssl: !1
|
|
3367
3364
|
})), r.mockUserToken) {
|
|
3368
|
-
let
|
|
3369
|
-
if ("string" == typeof r.mockUserToken)
|
|
3365
|
+
let n, e;
|
|
3366
|
+
if ("string" == typeof r.mockUserToken) n = r.mockUserToken, e = h.MOCK_USER; else {
|
|
3370
3367
|
// Let createMockUserToken validate first (catches common mistakes like
|
|
3371
3368
|
// invalid field "uid" and missing field "sub" / "user_id".)
|
|
3372
|
-
|
|
3369
|
+
n = createMockUserToken(r.mockUserToken, null === (s = t._app) || void 0 === s ? void 0 : s.options.projectId);
|
|
3373
3370
|
const i = r.mockUserToken.sub || r.mockUserToken.user_id;
|
|
3374
|
-
if (!i) throw new L(
|
|
3375
|
-
|
|
3371
|
+
if (!i) throw new L(I, "mockUserToken must contain 'sub' or 'user_id' field!");
|
|
3372
|
+
e = new h(i);
|
|
3376
3373
|
}
|
|
3377
|
-
t._credentials = new
|
|
3374
|
+
t._credentials = new B(new j(n, e));
|
|
3378
3375
|
}
|
|
3379
3376
|
}
|
|
3380
3377
|
|
|
@@ -3397,8 +3394,8 @@ function nn(t, e) {
|
|
|
3397
3394
|
* @param firestore - The `Firestore` instance to terminate.
|
|
3398
3395
|
* @returns A `Promise` that is resolved when the instance has been successfully
|
|
3399
3396
|
* terminated.
|
|
3400
|
-
*/ function
|
|
3401
|
-
return t = rt(t,
|
|
3397
|
+
*/ function oe(t) {
|
|
3398
|
+
return t = rt(t, ee), _removeServiceInstance(t.app, "firestore/lite"), t._delete();
|
|
3402
3399
|
}
|
|
3403
3400
|
|
|
3404
3401
|
/**
|
|
@@ -3438,14 +3435,14 @@ function nn(t, e) {
|
|
|
3438
3435
|
* and can be used to write, read, or listen to the location. The document at
|
|
3439
3436
|
* the referenced location may or may not exist.
|
|
3440
3437
|
*/
|
|
3441
|
-
class
|
|
3438
|
+
class ue {
|
|
3442
3439
|
/** @hideconstructor */
|
|
3443
3440
|
constructor(t,
|
|
3444
3441
|
/**
|
|
3445
3442
|
* If provided, the `FirestoreDataConverter` associated with this instance.
|
|
3446
3443
|
*/
|
|
3447
|
-
|
|
3448
|
-
this.converter =
|
|
3444
|
+
n, e) {
|
|
3445
|
+
this.converter = n, this._key = e,
|
|
3449
3446
|
/** The type of this Firestore reference. */
|
|
3450
3447
|
this.type = "document", this.firestore = t;
|
|
3451
3448
|
}
|
|
@@ -3466,40 +3463,40 @@ class un {
|
|
|
3466
3463
|
/**
|
|
3467
3464
|
* The collection this `DocumentReference` belongs to.
|
|
3468
3465
|
*/ get parent() {
|
|
3469
|
-
return new
|
|
3466
|
+
return new ae(this.firestore, this.converter, this._key.path.popLast());
|
|
3470
3467
|
}
|
|
3471
3468
|
withConverter(t) {
|
|
3472
|
-
return new
|
|
3469
|
+
return new ue(this.firestore, t, this._key);
|
|
3473
3470
|
}
|
|
3474
3471
|
}
|
|
3475
3472
|
|
|
3476
3473
|
/**
|
|
3477
3474
|
* A `Query` refers to a query which you can read or listen to. You can also
|
|
3478
3475
|
* construct refined `Query` objects by adding filters and ordering.
|
|
3479
|
-
*/ class
|
|
3476
|
+
*/ class ce {
|
|
3480
3477
|
// This is the lite version of the Query class in the main SDK.
|
|
3481
3478
|
/** @hideconstructor protected */
|
|
3482
3479
|
constructor(t,
|
|
3483
3480
|
/**
|
|
3484
3481
|
* If provided, the `FirestoreDataConverter` associated with this instance.
|
|
3485
3482
|
*/
|
|
3486
|
-
|
|
3487
|
-
this.converter =
|
|
3483
|
+
n, e) {
|
|
3484
|
+
this.converter = n, this._query = e,
|
|
3488
3485
|
/** The type of this Firestore reference. */
|
|
3489
3486
|
this.type = "query", this.firestore = t;
|
|
3490
3487
|
}
|
|
3491
3488
|
withConverter(t) {
|
|
3492
|
-
return new
|
|
3489
|
+
return new ce(this.firestore, t, this._query);
|
|
3493
3490
|
}
|
|
3494
3491
|
}
|
|
3495
3492
|
|
|
3496
3493
|
/**
|
|
3497
3494
|
* A `CollectionReference` object can be used for adding documents, getting
|
|
3498
3495
|
* document references, and querying for documents (using {@link query}).
|
|
3499
|
-
*/ class
|
|
3496
|
+
*/ class ae extends ce {
|
|
3500
3497
|
/** @hideconstructor */
|
|
3501
|
-
constructor(t,
|
|
3502
|
-
super(t,
|
|
3498
|
+
constructor(t, n, e) {
|
|
3499
|
+
super(t, n, new rn(e)), this._path = e,
|
|
3503
3500
|
/** The type of this Firestore reference. */
|
|
3504
3501
|
this.type = "collection";
|
|
3505
3502
|
}
|
|
@@ -3517,23 +3514,23 @@ class un {
|
|
|
3517
3514
|
* subcollection. If this isn't a subcollection, the reference is null.
|
|
3518
3515
|
*/ get parent() {
|
|
3519
3516
|
const t = this._path.popLast();
|
|
3520
|
-
return t.isEmpty() ? null : new
|
|
3517
|
+
return t.isEmpty() ? null : new ue(this.firestore,
|
|
3521
3518
|
/* converter= */ null, new Z(t));
|
|
3522
3519
|
}
|
|
3523
3520
|
withConverter(t) {
|
|
3524
|
-
return new
|
|
3521
|
+
return new ae(this.firestore, t, this._path);
|
|
3525
3522
|
}
|
|
3526
3523
|
}
|
|
3527
3524
|
|
|
3528
|
-
function
|
|
3529
|
-
if (t =
|
|
3530
|
-
const r = Y.fromString(
|
|
3531
|
-
return
|
|
3525
|
+
function he(t, n, ...e) {
|
|
3526
|
+
if (t = getModularInstance(t), X("collection", "path", n), t instanceof ee) {
|
|
3527
|
+
const r = Y.fromString(n, ...e);
|
|
3528
|
+
return nt(r), new ae(t, /* converter= */ null, r);
|
|
3532
3529
|
}
|
|
3533
3530
|
{
|
|
3534
|
-
if (!(t instanceof
|
|
3535
|
-
const r = t._path.child(Y.fromString(
|
|
3536
|
-
return
|
|
3531
|
+
if (!(t instanceof ue || t instanceof ae)) throw new L(I, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3532
|
+
const r = t._path.child(Y.fromString(n, ...e));
|
|
3533
|
+
return nt(r), new ae(t.firestore,
|
|
3537
3534
|
/* converter= */ null, r);
|
|
3538
3535
|
}
|
|
3539
3536
|
}
|
|
@@ -3550,32 +3547,32 @@ function hn(t, e, ...n) {
|
|
|
3550
3547
|
* collection or subcollection with this ID as the last segment of its path
|
|
3551
3548
|
* will be included. Cannot contain a slash.
|
|
3552
3549
|
* @returns The created `Query`.
|
|
3553
|
-
*/ function
|
|
3554
|
-
if (t = rt(t,
|
|
3555
|
-
return new
|
|
3550
|
+
*/ function le(t, n) {
|
|
3551
|
+
if (t = rt(t, ee), X("collectionGroup", "collection id", n), n.indexOf("/") >= 0) throw new L(I, `Invalid collection ID '${n}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);
|
|
3552
|
+
return new ce(t,
|
|
3556
3553
|
/* converter= */ null,
|
|
3557
3554
|
/**
|
|
3558
3555
|
* Creates a new Query for a collection group query that matches all documents
|
|
3559
3556
|
* within the provided collection group.
|
|
3560
3557
|
*/
|
|
3561
3558
|
function(t) {
|
|
3562
|
-
return new
|
|
3563
|
-
}(
|
|
3559
|
+
return new rn(Y.emptyPath(), t);
|
|
3560
|
+
}(n));
|
|
3564
3561
|
}
|
|
3565
3562
|
|
|
3566
|
-
function
|
|
3567
|
-
if (t =
|
|
3563
|
+
function fe(t, n, ...e) {
|
|
3564
|
+
if (t = getModularInstance(t),
|
|
3568
3565
|
// We allow omission of 'pathString' but explicitly prohibit passing in both
|
|
3569
3566
|
// 'undefined' and 'null'.
|
|
3570
|
-
1 === arguments.length && (
|
|
3571
|
-
const r = Y.fromString(
|
|
3572
|
-
return tt(r), new
|
|
3567
|
+
1 === arguments.length && (n = dt.A()), X("doc", "path", n), t instanceof ee) {
|
|
3568
|
+
const r = Y.fromString(n, ...e);
|
|
3569
|
+
return tt(r), new ue(t,
|
|
3573
3570
|
/* converter= */ null, new Z(r));
|
|
3574
3571
|
}
|
|
3575
3572
|
{
|
|
3576
|
-
if (!(t instanceof
|
|
3577
|
-
const r = t._path.child(Y.fromString(
|
|
3578
|
-
return tt(r), new
|
|
3573
|
+
if (!(t instanceof ue || t instanceof ae)) throw new L(I, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3574
|
+
const r = t._path.child(Y.fromString(n, ...e));
|
|
3575
|
+
return tt(r), new ue(t.firestore, t instanceof ae ? t.converter : null, new Z(r));
|
|
3579
3576
|
}
|
|
3580
3577
|
}
|
|
3581
3578
|
|
|
@@ -3586,8 +3583,8 @@ function fn(t, e, ...n) {
|
|
|
3586
3583
|
* @param right - A reference to compare.
|
|
3587
3584
|
* @returns true if the references point to the same location in the same
|
|
3588
3585
|
* Firestore database.
|
|
3589
|
-
*/ function
|
|
3590
|
-
return t =
|
|
3586
|
+
*/ function de(t, n) {
|
|
3587
|
+
return t = getModularInstance(t), n = getModularInstance(n), (t instanceof ue || t instanceof ae) && (n instanceof ue || n instanceof ae) && (t.firestore === n.firestore && t.path === n.path && t.converter === n.converter);
|
|
3591
3588
|
}
|
|
3592
3589
|
|
|
3593
3590
|
/**
|
|
@@ -3598,8 +3595,8 @@ function fn(t, e, ...n) {
|
|
|
3598
3595
|
* @param right - A `Query` to compare.
|
|
3599
3596
|
* @returns true if the references point to the same location in the same
|
|
3600
3597
|
* Firestore database.
|
|
3601
|
-
*/ function
|
|
3602
|
-
return t =
|
|
3598
|
+
*/ function we(t, n) {
|
|
3599
|
+
return t = getModularInstance(t), n = getModularInstance(n), t instanceof ce && n instanceof ce && (t.firestore === n.firestore && ln(t._query, n._query) && t.converter === n.converter);
|
|
3603
3600
|
}
|
|
3604
3601
|
|
|
3605
3602
|
/**
|
|
@@ -3625,7 +3622,7 @@ function fn(t, e, ...n) {
|
|
|
3625
3622
|
*
|
|
3626
3623
|
* Create a `FieldPath` by providing field names. If more than one field
|
|
3627
3624
|
* name is provided, the path will point to a nested field in a document.
|
|
3628
|
-
*/ class
|
|
3625
|
+
*/ class me {
|
|
3629
3626
|
/**
|
|
3630
3627
|
* Creates a `FieldPath` from the provided field names. If more than one field
|
|
3631
3628
|
* name is provided, the path will point to a nested field in a document.
|
|
@@ -3633,7 +3630,7 @@ function fn(t, e, ...n) {
|
|
|
3633
3630
|
* @param fieldNames - A list of field names.
|
|
3634
3631
|
*/
|
|
3635
3632
|
constructor(...t) {
|
|
3636
|
-
for (let
|
|
3633
|
+
for (let n = 0; n < t.length; ++n) if (0 === t[n].length) throw new L(I, "Invalid field name at argument $(i + 1). Field names must not be empty.");
|
|
3637
3634
|
this._internalPath = new J(t);
|
|
3638
3635
|
}
|
|
3639
3636
|
/**
|
|
@@ -3649,8 +3646,8 @@ function fn(t, e, ...n) {
|
|
|
3649
3646
|
/**
|
|
3650
3647
|
* Returns a special sentinel `FieldPath` to refer to the ID of a document.
|
|
3651
3648
|
* It can be used in queries to sort or filter by the document ID.
|
|
3652
|
-
*/ function
|
|
3653
|
-
return new
|
|
3649
|
+
*/ function pe() {
|
|
3650
|
+
return new me("__name__");
|
|
3654
3651
|
}
|
|
3655
3652
|
|
|
3656
3653
|
/**
|
|
@@ -3671,7 +3668,7 @@ function fn(t, e, ...n) {
|
|
|
3671
3668
|
*/
|
|
3672
3669
|
/**
|
|
3673
3670
|
* An immutable object representing an array of bytes.
|
|
3674
|
-
*/ class
|
|
3671
|
+
*/ class ye {
|
|
3675
3672
|
/** @hideconstructor */
|
|
3676
3673
|
constructor(t) {
|
|
3677
3674
|
this._byteString = t;
|
|
@@ -3683,9 +3680,9 @@ function fn(t, e, ...n) {
|
|
|
3683
3680
|
* @param base64 - The Base64 string used to create the `Bytes` object.
|
|
3684
3681
|
*/ static fromBase64String(t) {
|
|
3685
3682
|
try {
|
|
3686
|
-
return new
|
|
3683
|
+
return new ye(vt.fromBase64String(t));
|
|
3687
3684
|
} catch (t) {
|
|
3688
|
-
throw new L(
|
|
3685
|
+
throw new L(I, "Failed to construct data from Base64 string: " + t);
|
|
3689
3686
|
}
|
|
3690
3687
|
}
|
|
3691
3688
|
/**
|
|
@@ -3693,7 +3690,7 @@ function fn(t, e, ...n) {
|
|
|
3693
3690
|
*
|
|
3694
3691
|
* @param array - The Uint8Array used to create the `Bytes` object.
|
|
3695
3692
|
*/ static fromUint8Array(t) {
|
|
3696
|
-
return new
|
|
3693
|
+
return new ye(vt.fromUint8Array(t));
|
|
3697
3694
|
}
|
|
3698
3695
|
/**
|
|
3699
3696
|
* Returns the underlying bytes as a Base64-encoded string.
|
|
@@ -3745,7 +3742,7 @@ function fn(t, e, ...n) {
|
|
|
3745
3742
|
/**
|
|
3746
3743
|
* Sentinel values that can be used when writing document fields with `set()`
|
|
3747
3744
|
* or `update()`.
|
|
3748
|
-
*/ class
|
|
3745
|
+
*/ class _e {
|
|
3749
3746
|
/**
|
|
3750
3747
|
* @param _methodName - The public API endpoint that returns this class.
|
|
3751
3748
|
* @hideconstructor
|
|
@@ -3777,17 +3774,17 @@ function fn(t, e, ...n) {
|
|
|
3777
3774
|
*
|
|
3778
3775
|
* Latitude values are in the range of [-90, 90].
|
|
3779
3776
|
* Longitude values are in the range of [-180, 180].
|
|
3780
|
-
*/ class
|
|
3777
|
+
*/ class ge {
|
|
3781
3778
|
/**
|
|
3782
3779
|
* Creates a new immutable `GeoPoint` object with the provided latitude and
|
|
3783
3780
|
* longitude values.
|
|
3784
3781
|
* @param latitude - The latitude as number between -90 and 90.
|
|
3785
3782
|
* @param longitude - The longitude as number between -180 and 180.
|
|
3786
3783
|
*/
|
|
3787
|
-
constructor(t,
|
|
3788
|
-
if (!isFinite(t) || t < -90 || t > 90) throw new L(
|
|
3789
|
-
if (!isFinite(
|
|
3790
|
-
this._lat = t, this._long =
|
|
3784
|
+
constructor(t, n) {
|
|
3785
|
+
if (!isFinite(t) || t < -90 || t > 90) throw new L(I, "Latitude must be a number between -90 and 90, but was: " + t);
|
|
3786
|
+
if (!isFinite(n) || n < -180 || n > 180) throw new L(I, "Longitude must be a number between -180 and 180, but was: " + n);
|
|
3787
|
+
this._lat = t, this._long = n;
|
|
3791
3788
|
}
|
|
3792
3789
|
/**
|
|
3793
3790
|
* The latitude of this `GeoPoint` instance.
|
|
@@ -3836,29 +3833,29 @@ function fn(t, e, ...n) {
|
|
|
3836
3833
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3837
3834
|
* See the License for the specific language governing permissions and
|
|
3838
3835
|
* limitations under the License.
|
|
3839
|
-
*/ const
|
|
3836
|
+
*/ const be = /^__.*__$/;
|
|
3840
3837
|
|
|
3841
|
-
/** The result of parsing document data (e.g. for a setData call). */ class
|
|
3842
|
-
constructor(t,
|
|
3843
|
-
this.data = t, this.fieldMask =
|
|
3838
|
+
/** The result of parsing document data (e.g. for a setData call). */ class ve {
|
|
3839
|
+
constructor(t, n, e) {
|
|
3840
|
+
this.data = t, this.fieldMask = n, this.fieldTransforms = e;
|
|
3844
3841
|
}
|
|
3845
|
-
toMutation(t,
|
|
3846
|
-
return null !== this.fieldMask ? new
|
|
3842
|
+
toMutation(t, n) {
|
|
3843
|
+
return null !== this.fieldMask ? new En(t, this.data, this.fieldMask, n, this.fieldTransforms) : new vn(t, this.data, n, this.fieldTransforms);
|
|
3847
3844
|
}
|
|
3848
3845
|
}
|
|
3849
3846
|
|
|
3850
|
-
/** The result of parsing "update" data (i.e. for an updateData call). */ class
|
|
3847
|
+
/** The result of parsing "update" data (i.e. for an updateData call). */ class Ee {
|
|
3851
3848
|
constructor(t,
|
|
3852
3849
|
// The fieldMask does not include document transforms.
|
|
3853
|
-
|
|
3854
|
-
this.data = t, this.fieldMask =
|
|
3850
|
+
n, e) {
|
|
3851
|
+
this.data = t, this.fieldMask = n, this.fieldTransforms = e;
|
|
3855
3852
|
}
|
|
3856
|
-
toMutation(t,
|
|
3857
|
-
return new
|
|
3853
|
+
toMutation(t, n) {
|
|
3854
|
+
return new En(t, this.data, this.fieldMask, n, this.fieldTransforms);
|
|
3858
3855
|
}
|
|
3859
3856
|
}
|
|
3860
3857
|
|
|
3861
|
-
function
|
|
3858
|
+
function Te(t) {
|
|
3862
3859
|
switch (t) {
|
|
3863
3860
|
case 0 /* Set */ :
|
|
3864
3861
|
// fall through
|
|
@@ -3876,7 +3873,7 @@ function In(t) {
|
|
|
3876
3873
|
}
|
|
3877
3874
|
}
|
|
3878
3875
|
|
|
3879
|
-
/** A "context" object passed around while parsing user data. */ class
|
|
3876
|
+
/** A "context" object passed around while parsing user data. */ class Ie {
|
|
3880
3877
|
/**
|
|
3881
3878
|
* Initializes a ParseContext with the given source and path.
|
|
3882
3879
|
*
|
|
@@ -3895,8 +3892,8 @@ function In(t) {
|
|
|
3895
3892
|
* which case certain features will not work and errors will be somewhat
|
|
3896
3893
|
* compromised).
|
|
3897
3894
|
*/
|
|
3898
|
-
constructor(t,
|
|
3899
|
-
this.settings = t, this.databaseId =
|
|
3895
|
+
constructor(t, n, e, r, s, i) {
|
|
3896
|
+
this.settings = t, this.databaseId = n, this.S = e, this.ignoreUndefinedProperties = r,
|
|
3900
3897
|
// Minor hack: If fieldTransforms is undefined, we assume this is an
|
|
3901
3898
|
// external call and we need to validate the entire path.
|
|
3902
3899
|
void 0 === s && this.Z(), this.fieldTransforms = s || [], this.fieldMask = i || [];
|
|
@@ -3908,21 +3905,21 @@ function In(t) {
|
|
|
3908
3905
|
return this.settings.X;
|
|
3909
3906
|
}
|
|
3910
3907
|
/** Returns a new context with the specified settings overwritten. */ tt(t) {
|
|
3911
|
-
return new
|
|
3908
|
+
return new Ie(Object.assign(Object.assign({}, this.settings), t), this.databaseId, this.S, this.ignoreUndefinedProperties, this.fieldTransforms, this.fieldMask);
|
|
3912
3909
|
}
|
|
3913
|
-
|
|
3914
|
-
var
|
|
3915
|
-
const
|
|
3916
|
-
path:
|
|
3917
|
-
|
|
3910
|
+
nt(t) {
|
|
3911
|
+
var n;
|
|
3912
|
+
const e = null === (n = this.path) || void 0 === n ? void 0 : n.child(t), r = this.tt({
|
|
3913
|
+
path: e,
|
|
3914
|
+
et: !1
|
|
3918
3915
|
});
|
|
3919
3916
|
return r.rt(t), r;
|
|
3920
3917
|
}
|
|
3921
3918
|
st(t) {
|
|
3922
|
-
var
|
|
3923
|
-
const
|
|
3924
|
-
path:
|
|
3925
|
-
|
|
3919
|
+
var n;
|
|
3920
|
+
const e = null === (n = this.path) || void 0 === n ? void 0 : n.child(t), r = this.tt({
|
|
3921
|
+
path: e,
|
|
3922
|
+
et: !1
|
|
3926
3923
|
});
|
|
3927
3924
|
return r.Z(), r;
|
|
3928
3925
|
}
|
|
@@ -3931,14 +3928,14 @@ function In(t) {
|
|
|
3931
3928
|
// undefined.
|
|
3932
3929
|
return this.tt({
|
|
3933
3930
|
path: void 0,
|
|
3934
|
-
|
|
3931
|
+
et: !0
|
|
3935
3932
|
});
|
|
3936
3933
|
}
|
|
3937
3934
|
ot(t) {
|
|
3938
|
-
return
|
|
3935
|
+
return Qe(t, this.settings.methodName, this.settings.ut || !1, this.path, this.settings.ct);
|
|
3939
3936
|
}
|
|
3940
3937
|
/** Returns 'true' if 'fieldPath' was traversed when creating this context. */ contains(t) {
|
|
3941
|
-
return void 0 !== this.fieldMask.find((
|
|
3938
|
+
return void 0 !== this.fieldMask.find((n => t.isPrefixOf(n))) || void 0 !== this.fieldTransforms.find((n => t.isPrefixOf(n.field)));
|
|
3942
3939
|
}
|
|
3943
3940
|
Z() {
|
|
3944
3941
|
// TODO(b/34871131): Remove null check once we have proper paths for fields
|
|
@@ -3947,52 +3944,52 @@ function In(t) {
|
|
|
3947
3944
|
}
|
|
3948
3945
|
rt(t) {
|
|
3949
3946
|
if (0 === t.length) throw this.ot("Document fields must not be empty");
|
|
3950
|
-
if (
|
|
3947
|
+
if (Te(this.X) && be.test(t)) throw this.ot('Document fields cannot begin and end with "__"');
|
|
3951
3948
|
}
|
|
3952
3949
|
}
|
|
3953
3950
|
|
|
3954
3951
|
/**
|
|
3955
3952
|
* Helper for parsing raw user input (provided via the API) into internal model
|
|
3956
3953
|
* classes.
|
|
3957
|
-
*/ class
|
|
3958
|
-
constructor(t,
|
|
3959
|
-
this.databaseId = t, this.ignoreUndefinedProperties =
|
|
3954
|
+
*/ class Ae {
|
|
3955
|
+
constructor(t, n, e) {
|
|
3956
|
+
this.databaseId = t, this.ignoreUndefinedProperties = n, this.S = e || Wn(t);
|
|
3960
3957
|
}
|
|
3961
|
-
/** Creates a new top-level parse context. */ at(t,
|
|
3962
|
-
return new
|
|
3958
|
+
/** Creates a new top-level parse context. */ at(t, n, e, r = !1) {
|
|
3959
|
+
return new Ie({
|
|
3963
3960
|
X: t,
|
|
3964
|
-
methodName:
|
|
3965
|
-
ct:
|
|
3961
|
+
methodName: n,
|
|
3962
|
+
ct: e,
|
|
3966
3963
|
path: J.emptyPath(),
|
|
3967
|
-
|
|
3964
|
+
et: !1,
|
|
3968
3965
|
ut: r
|
|
3969
3966
|
}, this.databaseId, this.S, this.ignoreUndefinedProperties);
|
|
3970
3967
|
}
|
|
3971
3968
|
}
|
|
3972
3969
|
|
|
3973
|
-
function
|
|
3974
|
-
const
|
|
3975
|
-
return new
|
|
3970
|
+
function Pe(t) {
|
|
3971
|
+
const n = t._freezeSettings(), e = Wn(t._databaseId);
|
|
3972
|
+
return new Ae(t._databaseId, !!n.ignoreUndefinedProperties, e);
|
|
3976
3973
|
}
|
|
3977
3974
|
|
|
3978
|
-
/** Parse document data from a set() call. */ function
|
|
3979
|
-
const o = t.at(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ ,
|
|
3980
|
-
|
|
3981
|
-
const u =
|
|
3975
|
+
/** Parse document data from a set() call. */ function Re(t, n, e, r, s, i = {}) {
|
|
3976
|
+
const o = t.at(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ , n, e, s);
|
|
3977
|
+
je("Data must be an object, but it was:", o, r);
|
|
3978
|
+
const u = Le(r, o);
|
|
3982
3979
|
let c, a;
|
|
3983
3980
|
if (i.merge) c = new bt(o.fieldMask), a = o.fieldTransforms; else if (i.mergeFields) {
|
|
3984
3981
|
const t = [];
|
|
3985
3982
|
for (const r of i.mergeFields) {
|
|
3986
|
-
const s =
|
|
3987
|
-
if (!o.contains(s)) throw new L(
|
|
3988
|
-
|
|
3983
|
+
const s = ke(n, r, e);
|
|
3984
|
+
if (!o.contains(s)) throw new L(I, `Field '${s}' is specified in your field mask but missing from your input data.`);
|
|
3985
|
+
ze(t, s) || t.push(s);
|
|
3989
3986
|
}
|
|
3990
3987
|
c = new bt(t), a = o.fieldTransforms.filter((t => c.covers(t.field)));
|
|
3991
3988
|
} else c = null, a = o.fieldTransforms;
|
|
3992
|
-
return new
|
|
3989
|
+
return new ve(new jt(u), c, a);
|
|
3993
3990
|
}
|
|
3994
3991
|
|
|
3995
|
-
class
|
|
3992
|
+
class Ve extends _e {
|
|
3996
3993
|
_toFieldTransform(t) {
|
|
3997
3994
|
if (2 /* MergeSet */ !== t.X) throw 1 /* Update */ === t.X ? t.ot(`${this._methodName}() can only appear at the top level of your update data`) : t.ot(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);
|
|
3998
3995
|
// No transform to add for a delete, but we need to add it to our
|
|
@@ -4000,7 +3997,7 @@ class Vn extends _n {
|
|
|
4000
3997
|
return t.fieldMask.push(t.path), null;
|
|
4001
3998
|
}
|
|
4002
3999
|
isEqual(t) {
|
|
4003
|
-
return t instanceof
|
|
4000
|
+
return t instanceof Ve;
|
|
4004
4001
|
}
|
|
4005
4002
|
}
|
|
4006
4003
|
|
|
@@ -4019,32 +4016,32 @@ class Vn extends _n {
|
|
|
4019
4016
|
* context.
|
|
4020
4017
|
* @param context - The parent context.
|
|
4021
4018
|
* @param arrayElement - Whether or not the FieldValue has an array.
|
|
4022
|
-
*/ function
|
|
4023
|
-
return new
|
|
4019
|
+
*/ function De(t, n, e) {
|
|
4020
|
+
return new Ie({
|
|
4024
4021
|
X: 3 /* Argument */ ,
|
|
4025
|
-
ct:
|
|
4022
|
+
ct: n.settings.ct,
|
|
4026
4023
|
methodName: t._methodName,
|
|
4027
|
-
|
|
4028
|
-
},
|
|
4024
|
+
et: e
|
|
4025
|
+
}, n.databaseId, n.S, n.ignoreUndefinedProperties);
|
|
4029
4026
|
}
|
|
4030
4027
|
|
|
4031
|
-
class
|
|
4028
|
+
class Ne extends _e {
|
|
4032
4029
|
_toFieldTransform(t) {
|
|
4033
|
-
return new
|
|
4030
|
+
return new _n(t.path, new wn);
|
|
4034
4031
|
}
|
|
4035
4032
|
isEqual(t) {
|
|
4036
|
-
return t instanceof
|
|
4033
|
+
return t instanceof Ne;
|
|
4037
4034
|
}
|
|
4038
4035
|
}
|
|
4039
4036
|
|
|
4040
|
-
class $
|
|
4041
|
-
constructor(t,
|
|
4042
|
-
super(t), this.ht =
|
|
4037
|
+
class $e extends _e {
|
|
4038
|
+
constructor(t, n) {
|
|
4039
|
+
super(t), this.ht = n;
|
|
4043
4040
|
}
|
|
4044
4041
|
_toFieldTransform(t) {
|
|
4045
|
-
const
|
|
4046
|
-
/*array=*/ !0),
|
|
4047
|
-
return new
|
|
4042
|
+
const n = De(this, t,
|
|
4043
|
+
/*array=*/ !0), e = this.ht.map((t => Ce(t, n))), r = new mn(e);
|
|
4044
|
+
return new _n(t.path, r);
|
|
4048
4045
|
}
|
|
4049
4046
|
isEqual(t) {
|
|
4050
4047
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4052,14 +4049,14 @@ class $n extends _n {
|
|
|
4052
4049
|
}
|
|
4053
4050
|
}
|
|
4054
4051
|
|
|
4055
|
-
class
|
|
4056
|
-
constructor(t,
|
|
4057
|
-
super(t), this.ht =
|
|
4052
|
+
class Fe extends _e {
|
|
4053
|
+
constructor(t, n) {
|
|
4054
|
+
super(t), this.ht = n;
|
|
4058
4055
|
}
|
|
4059
4056
|
_toFieldTransform(t) {
|
|
4060
|
-
const
|
|
4061
|
-
/*array=*/ !0),
|
|
4062
|
-
return new
|
|
4057
|
+
const n = De(this, t,
|
|
4058
|
+
/*array=*/ !0), e = this.ht.map((t => Ce(t, n))), r = new pn(e);
|
|
4059
|
+
return new _n(t.path, r);
|
|
4063
4060
|
}
|
|
4064
4061
|
isEqual(t) {
|
|
4065
4062
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4067,13 +4064,13 @@ class Fn extends _n {
|
|
|
4067
4064
|
}
|
|
4068
4065
|
}
|
|
4069
4066
|
|
|
4070
|
-
class
|
|
4071
|
-
constructor(t,
|
|
4072
|
-
super(t), this.lt =
|
|
4067
|
+
class Se extends _e {
|
|
4068
|
+
constructor(t, n) {
|
|
4069
|
+
super(t), this.lt = n;
|
|
4073
4070
|
}
|
|
4074
4071
|
_toFieldTransform(t) {
|
|
4075
|
-
const
|
|
4076
|
-
return new
|
|
4072
|
+
const n = new yn(t.S, fn(t.S, this.lt));
|
|
4073
|
+
return new _n(t.path, n);
|
|
4077
4074
|
}
|
|
4078
4075
|
isEqual(t) {
|
|
4079
4076
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4081,50 +4078,50 @@ class Sn extends _n {
|
|
|
4081
4078
|
}
|
|
4082
4079
|
}
|
|
4083
4080
|
|
|
4084
|
-
/** Parse update data from an update() call. */ function
|
|
4085
|
-
const s = t.at(1 /* Update */ ,
|
|
4086
|
-
|
|
4081
|
+
/** Parse update data from an update() call. */ function qe(t, n, e, r) {
|
|
4082
|
+
const s = t.at(1 /* Update */ , n, e);
|
|
4083
|
+
je("Data must be an object, but it was:", s, r);
|
|
4087
4084
|
const i = [], o = jt.empty();
|
|
4088
4085
|
gt(r, ((t, r) => {
|
|
4089
|
-
const u =
|
|
4086
|
+
const u = Me(n, t, e);
|
|
4090
4087
|
// For Compat types, we have to "extract" the underlying types before
|
|
4091
4088
|
// performing validation.
|
|
4092
|
-
r =
|
|
4089
|
+
r = getModularInstance(r);
|
|
4093
4090
|
const c = s.st(u);
|
|
4094
|
-
if (r instanceof
|
|
4091
|
+
if (r instanceof Ve)
|
|
4095
4092
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4096
4093
|
i.push(u); else {
|
|
4097
|
-
const t =
|
|
4094
|
+
const t = Ce(r, c);
|
|
4098
4095
|
null != t && (i.push(u), o.set(u, t));
|
|
4099
4096
|
}
|
|
4100
4097
|
}));
|
|
4101
4098
|
const u = new bt(i);
|
|
4102
|
-
return new
|
|
4099
|
+
return new Ee(o, u, s.fieldTransforms);
|
|
4103
4100
|
}
|
|
4104
4101
|
|
|
4105
|
-
/** Parse update data from a list of field/value arguments. */ function
|
|
4106
|
-
const o = t.at(1 /* Update */ ,
|
|
4107
|
-
if (i.length % 2 != 0) throw new L(
|
|
4108
|
-
for (let t = 0; t < i.length; t += 2) u.push(
|
|
4102
|
+
/** Parse update data from a list of field/value arguments. */ function xe(t, n, e, r, s, i) {
|
|
4103
|
+
const o = t.at(1 /* Update */ , n, e), u = [ ke(n, r, e) ], c = [ s ];
|
|
4104
|
+
if (i.length % 2 != 0) throw new L(I, `Function ${n}() needs to be called with an even number of arguments that alternate between field names and values.`);
|
|
4105
|
+
for (let t = 0; t < i.length; t += 2) u.push(ke(n, i[t])), c.push(i[t + 1]);
|
|
4109
4106
|
const h = [], l = jt.empty();
|
|
4110
4107
|
// We iterate in reverse order to pick the last value for a field if the
|
|
4111
4108
|
// user specified the field multiple times.
|
|
4112
|
-
for (let t = u.length - 1; t >= 0; --t) if (!
|
|
4113
|
-
const
|
|
4114
|
-
let
|
|
4109
|
+
for (let t = u.length - 1; t >= 0; --t) if (!ze(h, u[t])) {
|
|
4110
|
+
const n = u[t];
|
|
4111
|
+
let e = c[t];
|
|
4115
4112
|
// For Compat types, we have to "extract" the underlying types before
|
|
4116
4113
|
// performing validation.
|
|
4117
|
-
|
|
4118
|
-
const r = o.st(
|
|
4119
|
-
if (
|
|
4114
|
+
e = getModularInstance(e);
|
|
4115
|
+
const r = o.st(n);
|
|
4116
|
+
if (e instanceof Ve)
|
|
4120
4117
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4121
|
-
h.push(
|
|
4122
|
-
const t =
|
|
4123
|
-
null != t && (h.push(
|
|
4118
|
+
h.push(n); else {
|
|
4119
|
+
const t = Ce(e, r);
|
|
4120
|
+
null != t && (h.push(n), l.set(n, t));
|
|
4124
4121
|
}
|
|
4125
4122
|
}
|
|
4126
4123
|
const f = new bt(h);
|
|
4127
|
-
return new
|
|
4124
|
+
return new Ee(l, f, o.fieldTransforms);
|
|
4128
4125
|
}
|
|
4129
4126
|
|
|
4130
4127
|
/**
|
|
@@ -4133,8 +4130,8 @@ class Sn extends _n {
|
|
|
4133
4130
|
*
|
|
4134
4131
|
* @param allowArrays - Whether the query value is an array that may directly
|
|
4135
4132
|
* contain additional arrays (e.g. the operand of an `in` query).
|
|
4136
|
-
*/ function
|
|
4137
|
-
return
|
|
4133
|
+
*/ function Oe(t, n, e, r = !1) {
|
|
4134
|
+
return Ce(e, t.at(r ? 4 /* ArrayArgument */ : 3 /* Argument */ , n));
|
|
4138
4135
|
}
|
|
4139
4136
|
|
|
4140
4137
|
/**
|
|
@@ -4145,12 +4142,12 @@ class Sn extends _n {
|
|
|
4145
4142
|
* the source of the data being parsed, etc.
|
|
4146
4143
|
* @returns The parsed value, or null if the value was a FieldValue sentinel
|
|
4147
4144
|
* that should not be included in the resulting parsed data.
|
|
4148
|
-
*/ function
|
|
4149
|
-
if (
|
|
4145
|
+
*/ function Ce(t, n) {
|
|
4146
|
+
if (Ue(
|
|
4150
4147
|
// Unwrap the API type from the Compat SDK. This will return the API type
|
|
4151
4148
|
// from firestore-exp.
|
|
4152
|
-
t =
|
|
4153
|
-
if (t instanceof
|
|
4149
|
+
t = getModularInstance(t))) return je("Unsupported field value:", n, t), Le(t, n);
|
|
4150
|
+
if (t instanceof _e)
|
|
4154
4151
|
// FieldValues usually parse into transforms (except FieldValue.delete())
|
|
4155
4152
|
// in which case we do not want to include this field in our parsed data
|
|
4156
4153
|
// (as doing so will overwrite the field directly prior to the transform
|
|
@@ -4160,19 +4157,19 @@ class Sn extends _n {
|
|
|
4160
4157
|
* "Parses" the provided FieldValueImpl, adding any necessary transforms to
|
|
4161
4158
|
* context.fieldTransforms.
|
|
4162
4159
|
*/
|
|
4163
|
-
return function(t,
|
|
4160
|
+
return function(t, n) {
|
|
4164
4161
|
// Sentinels are only supported with writes, and not within arrays.
|
|
4165
|
-
if (!
|
|
4166
|
-
if (!
|
|
4167
|
-
const
|
|
4168
|
-
|
|
4162
|
+
if (!Te(n.X)) throw n.ot(`${t._methodName}() can only be used with update() and set()`);
|
|
4163
|
+
if (!n.path) throw n.ot(`${t._methodName}() is not currently supported inside arrays`);
|
|
4164
|
+
const e = t._toFieldTransform(n);
|
|
4165
|
+
e && n.fieldTransforms.push(e);
|
|
4169
4166
|
}
|
|
4170
4167
|
/**
|
|
4171
4168
|
* Helper to parse a scalar value (i.e. not an Object, Array, or FieldValue)
|
|
4172
4169
|
*
|
|
4173
4170
|
* @returns The parsed value
|
|
4174
|
-
*/ (t,
|
|
4175
|
-
if (void 0 === t &&
|
|
4171
|
+
*/ (t, n), null;
|
|
4172
|
+
if (void 0 === t && n.ignoreUndefinedProperties)
|
|
4176
4173
|
// If the input is undefined it can never participate in the fieldMask, so
|
|
4177
4174
|
// don't handle this below. If `ignoreUndefinedProperties` is false,
|
|
4178
4175
|
// `parseScalarValue` will reject an undefined value.
|
|
@@ -4180,38 +4177,38 @@ class Sn extends _n {
|
|
|
4180
4177
|
if (
|
|
4181
4178
|
// If context.path is null we are inside an array and we don't support
|
|
4182
4179
|
// field mask paths more granular than the top-level array.
|
|
4183
|
-
|
|
4180
|
+
n.path && n.fieldMask.push(n.path), t instanceof Array) {
|
|
4184
4181
|
// TODO(b/34871131): Include the path containing the array in the error
|
|
4185
4182
|
// message.
|
|
4186
4183
|
// In the case of IN queries, the parsed data is an array (representing
|
|
4187
4184
|
// the set of values to be included for the IN query) that may directly
|
|
4188
4185
|
// contain additional arrays (each representing an individual field
|
|
4189
4186
|
// value), so we disable this validation.
|
|
4190
|
-
if (
|
|
4191
|
-
return function(t,
|
|
4192
|
-
const
|
|
4187
|
+
if (n.settings.et && 4 /* ArrayArgument */ !== n.X) throw n.ot("Nested arrays are not supported");
|
|
4188
|
+
return function(t, n) {
|
|
4189
|
+
const e = [];
|
|
4193
4190
|
let r = 0;
|
|
4194
4191
|
for (const s of t) {
|
|
4195
|
-
let t =
|
|
4192
|
+
let t = Ce(s, n.it(r));
|
|
4196
4193
|
null == t && (
|
|
4197
4194
|
// Just include nulls in the array for fields being replaced with a
|
|
4198
4195
|
// sentinel.
|
|
4199
4196
|
t = {
|
|
4200
4197
|
nullValue: "NULL_VALUE"
|
|
4201
|
-
}),
|
|
4198
|
+
}), e.push(t), r++;
|
|
4202
4199
|
}
|
|
4203
4200
|
return {
|
|
4204
4201
|
arrayValue: {
|
|
4205
|
-
values:
|
|
4202
|
+
values: e
|
|
4206
4203
|
}
|
|
4207
4204
|
};
|
|
4208
|
-
}(t,
|
|
4205
|
+
}(t, n);
|
|
4209
4206
|
}
|
|
4210
|
-
return function(t,
|
|
4211
|
-
if (null === (t =
|
|
4207
|
+
return function(t, n) {
|
|
4208
|
+
if (null === (t = getModularInstance(t))) return {
|
|
4212
4209
|
nullValue: "NULL_VALUE"
|
|
4213
4210
|
};
|
|
4214
|
-
if ("number" == typeof t) return
|
|
4211
|
+
if ("number" == typeof t) return fn(n.S, t);
|
|
4215
4212
|
if ("boolean" == typeof t) return {
|
|
4216
4213
|
booleanValue: t
|
|
4217
4214
|
};
|
|
@@ -4219,37 +4216,37 @@ class Sn extends _n {
|
|
|
4219
4216
|
stringValue: t
|
|
4220
4217
|
};
|
|
4221
4218
|
if (t instanceof Date) {
|
|
4222
|
-
const
|
|
4219
|
+
const e = pt.fromDate(t);
|
|
4223
4220
|
return {
|
|
4224
|
-
timestampValue:
|
|
4221
|
+
timestampValue: Vn(n.S, e)
|
|
4225
4222
|
};
|
|
4226
4223
|
}
|
|
4227
4224
|
if (t instanceof pt) {
|
|
4228
4225
|
// Firestore backend truncates precision down to microseconds. To ensure
|
|
4229
4226
|
// offline mode works the same with regards to truncation, perform the
|
|
4230
4227
|
// truncation immediately without waiting for the backend to do that.
|
|
4231
|
-
const
|
|
4228
|
+
const e = new pt(t.seconds, 1e3 * Math.floor(t.nanoseconds / 1e3));
|
|
4232
4229
|
return {
|
|
4233
|
-
timestampValue:
|
|
4230
|
+
timestampValue: Vn(n.S, e)
|
|
4234
4231
|
};
|
|
4235
4232
|
}
|
|
4236
|
-
if (t instanceof
|
|
4233
|
+
if (t instanceof ge) return {
|
|
4237
4234
|
geoPointValue: {
|
|
4238
4235
|
latitude: t.latitude,
|
|
4239
4236
|
longitude: t.longitude
|
|
4240
4237
|
}
|
|
4241
4238
|
};
|
|
4242
|
-
if (t instanceof
|
|
4243
|
-
bytesValue:
|
|
4239
|
+
if (t instanceof ye) return {
|
|
4240
|
+
bytesValue: Dn(n.S, t._byteString)
|
|
4244
4241
|
};
|
|
4245
|
-
if (t instanceof
|
|
4246
|
-
const
|
|
4247
|
-
if (!r.isEqual(
|
|
4242
|
+
if (t instanceof ue) {
|
|
4243
|
+
const e = n.databaseId, r = t.firestore._databaseId;
|
|
4244
|
+
if (!r.isEqual(e)) throw n.ot(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${e.projectId}/${e.database}`);
|
|
4248
4245
|
return {
|
|
4249
|
-
referenceValue:
|
|
4246
|
+
referenceValue: Fn(t.firestore._databaseId || n.databaseId, t._key.path)
|
|
4250
4247
|
};
|
|
4251
4248
|
}
|
|
4252
|
-
throw
|
|
4249
|
+
throw n.ot(`Unsupported field value: ${et(t)}`);
|
|
4253
4250
|
}
|
|
4254
4251
|
/**
|
|
4255
4252
|
* Checks whether an object looks like a JSON object that should be converted
|
|
@@ -4257,56 +4254,56 @@ class Sn extends _n {
|
|
|
4257
4254
|
* JSON objects since they should be converted to a struct value. Arrays, Dates,
|
|
4258
4255
|
* GeoPoints, etc. are not considered to look like JSON objects since they map
|
|
4259
4256
|
* to specific FieldValue types other than ObjectValue.
|
|
4260
|
-
*/ (t,
|
|
4257
|
+
*/ (t, n);
|
|
4261
4258
|
}
|
|
4262
4259
|
|
|
4263
|
-
function
|
|
4264
|
-
const
|
|
4260
|
+
function Le(t, n) {
|
|
4261
|
+
const e = {};
|
|
4265
4262
|
return !function(t) {
|
|
4266
|
-
for (const
|
|
4263
|
+
for (const n in t) if (Object.prototype.hasOwnProperty.call(t, n)) return !1;
|
|
4267
4264
|
return !0;
|
|
4268
4265
|
}(t) ? gt(t, ((t, r) => {
|
|
4269
|
-
const s =
|
|
4270
|
-
null != s && (
|
|
4266
|
+
const s = Ce(r, n.nt(t));
|
|
4267
|
+
null != s && (e[t] = s);
|
|
4271
4268
|
})) :
|
|
4272
4269
|
// If we encounter an empty object, we explicitly add it to the update
|
|
4273
4270
|
// mask to ensure that the server creates a map entry.
|
|
4274
|
-
|
|
4271
|
+
n.path && n.path.length > 0 && n.fieldMask.push(n.path), {
|
|
4275
4272
|
mapValue: {
|
|
4276
|
-
fields:
|
|
4273
|
+
fields: e
|
|
4277
4274
|
}
|
|
4278
4275
|
};
|
|
4279
4276
|
}
|
|
4280
4277
|
|
|
4281
|
-
function
|
|
4282
|
-
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof pt || t instanceof
|
|
4278
|
+
function Ue(t) {
|
|
4279
|
+
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof pt || t instanceof ge || t instanceof ye || t instanceof ue || t instanceof _e);
|
|
4283
4280
|
}
|
|
4284
4281
|
|
|
4285
|
-
function
|
|
4286
|
-
if (!
|
|
4282
|
+
function je(t, n, e) {
|
|
4283
|
+
if (!Ue(e) || !function(t) {
|
|
4287
4284
|
return "object" == typeof t && null !== t && (Object.getPrototypeOf(t) === Object.prototype || null === Object.getPrototypeOf(t));
|
|
4288
|
-
}(
|
|
4289
|
-
const r =
|
|
4290
|
-
throw "an object" === r ?
|
|
4285
|
+
}(e)) {
|
|
4286
|
+
const r = et(e);
|
|
4287
|
+
throw "an object" === r ? n.ot(t + " a custom object") : n.ot(t + " " + r);
|
|
4291
4288
|
}
|
|
4292
4289
|
}
|
|
4293
4290
|
|
|
4294
4291
|
/**
|
|
4295
4292
|
* Helper that calls fromDotSeparatedString() but wraps any error thrown.
|
|
4296
|
-
*/ function
|
|
4293
|
+
*/ function ke(t, n, e) {
|
|
4297
4294
|
if ((
|
|
4298
4295
|
// If required, replace the FieldPath Compat class with with the firestore-exp
|
|
4299
4296
|
// FieldPath.
|
|
4300
|
-
|
|
4301
|
-
if ("string" == typeof
|
|
4302
|
-
throw
|
|
4297
|
+
n = getModularInstance(n)) instanceof me) return n._internalPath;
|
|
4298
|
+
if ("string" == typeof n) return Me(t, n);
|
|
4299
|
+
throw Qe("Field path arguments must be of type string or FieldPath.", t,
|
|
4303
4300
|
/* hasConverter= */ !1,
|
|
4304
|
-
/* path= */ void 0,
|
|
4301
|
+
/* path= */ void 0, e);
|
|
4305
4302
|
}
|
|
4306
4303
|
|
|
4307
4304
|
/**
|
|
4308
4305
|
* Matches any characters in a field path string that are reserved.
|
|
4309
|
-
*/ const
|
|
4306
|
+
*/ const Be = new RegExp("[~\\*/\\[\\]]");
|
|
4310
4307
|
|
|
4311
4308
|
/**
|
|
4312
4309
|
* Wraps fromDotSeparatedString with an error message about the method that
|
|
@@ -4316,30 +4313,30 @@ function jn(t, e, n) {
|
|
|
4316
4313
|
* split on dots.
|
|
4317
4314
|
* @param targetDoc - The document against which the field path will be
|
|
4318
4315
|
* evaluated.
|
|
4319
|
-
*/ function
|
|
4320
|
-
if (
|
|
4316
|
+
*/ function Me(t, n, e) {
|
|
4317
|
+
if (n.search(Be) >= 0) throw Qe(`Invalid field path (${n}). Paths must not contain '~', '*', '/', '[', or ']'`, t,
|
|
4321
4318
|
/* hasConverter= */ !1,
|
|
4322
|
-
/* path= */ void 0,
|
|
4319
|
+
/* path= */ void 0, e);
|
|
4323
4320
|
try {
|
|
4324
|
-
return new
|
|
4321
|
+
return new me(...n.split("."))._internalPath;
|
|
4325
4322
|
} catch (r) {
|
|
4326
|
-
throw
|
|
4323
|
+
throw Qe(`Invalid field path (${n}). Paths must not be empty, begin with '.', end with '.', or contain '..'`, t,
|
|
4327
4324
|
/* hasConverter= */ !1,
|
|
4328
|
-
/* path= */ void 0,
|
|
4325
|
+
/* path= */ void 0, e);
|
|
4329
4326
|
}
|
|
4330
4327
|
}
|
|
4331
4328
|
|
|
4332
|
-
function
|
|
4329
|
+
function Qe(t, n, e, r, s) {
|
|
4333
4330
|
const i = r && !r.isEmpty(), o = void 0 !== s;
|
|
4334
|
-
let u = `Function ${
|
|
4335
|
-
|
|
4331
|
+
let u = `Function ${n}() called with invalid data`;
|
|
4332
|
+
e && (u += " (via `toFirestore()`)"), u += ". ";
|
|
4336
4333
|
let c = "";
|
|
4337
4334
|
return (i || o) && (c += " (found", i && (c += ` in field ${r}`), o && (c += ` in document ${s}`),
|
|
4338
|
-
c += ")"), new L(
|
|
4335
|
+
c += ")"), new L(I, u + t + c);
|
|
4339
4336
|
}
|
|
4340
4337
|
|
|
4341
|
-
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function
|
|
4342
|
-
return t.some((t => t.isEqual(
|
|
4338
|
+
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function ze(t, n) {
|
|
4339
|
+
return t.some((t => t.isEqual(n)));
|
|
4343
4340
|
}
|
|
4344
4341
|
|
|
4345
4342
|
/**
|
|
@@ -4366,14 +4363,14 @@ function Qn(t, e, n, r, s) {
|
|
|
4366
4363
|
* For a `DocumentSnapshot` that points to a non-existing document, any data
|
|
4367
4364
|
* access will return 'undefined'. You can use the `exists()` method to
|
|
4368
4365
|
* explicitly verify a document's existence.
|
|
4369
|
-
*/ class
|
|
4366
|
+
*/ class Ge {
|
|
4370
4367
|
// Note: This class is stripped down version of the DocumentSnapshot in
|
|
4371
4368
|
// the legacy SDK. The changes are:
|
|
4372
4369
|
// - No support for SnapshotMetadata.
|
|
4373
4370
|
// - No support for SnapshotOptions.
|
|
4374
4371
|
/** @hideconstructor protected */
|
|
4375
|
-
constructor(t,
|
|
4376
|
-
this._firestore = t, this._userDataWriter =
|
|
4372
|
+
constructor(t, n, e, r, s) {
|
|
4373
|
+
this._firestore = t, this._userDataWriter = n, this._key = e, this._document = r,
|
|
4377
4374
|
this._converter = s;
|
|
4378
4375
|
}
|
|
4379
4376
|
/** Property of the `DocumentSnapshot` that provides the document's ID. */ get id() {
|
|
@@ -4382,7 +4379,7 @@ function Qn(t, e, n, r, s) {
|
|
|
4382
4379
|
/**
|
|
4383
4380
|
* The `DocumentReference` for the document included in the `DocumentSnapshot`.
|
|
4384
4381
|
*/ get ref() {
|
|
4385
|
-
return new
|
|
4382
|
+
return new ue(this._firestore, this._converter, this._key);
|
|
4386
4383
|
}
|
|
4387
4384
|
/**
|
|
4388
4385
|
* Signals whether or not the document at the snapshot's location exists.
|
|
@@ -4402,7 +4399,7 @@ function Qn(t, e, n, r, s) {
|
|
|
4402
4399
|
if (this._converter) {
|
|
4403
4400
|
// We only want to use the converter and create a new DocumentSnapshot
|
|
4404
4401
|
// if a converter has been provided.
|
|
4405
|
-
const t = new
|
|
4402
|
+
const t = new We(this._firestore, this._userDataWriter, this._key, this._document,
|
|
4406
4403
|
/* converter= */ null);
|
|
4407
4404
|
return this._converter.fromFirestore(t);
|
|
4408
4405
|
}
|
|
@@ -4422,8 +4419,8 @@ function Qn(t, e, n, r, s) {
|
|
|
4422
4419
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4423
4420
|
get(t) {
|
|
4424
4421
|
if (this._document) {
|
|
4425
|
-
const
|
|
4426
|
-
if (null !==
|
|
4422
|
+
const n = this._document.data.field(Ke("DocumentSnapshot.get", t));
|
|
4423
|
+
if (null !== n) return this._userDataWriter.convertValue(n);
|
|
4427
4424
|
}
|
|
4428
4425
|
}
|
|
4429
4426
|
}
|
|
@@ -4438,7 +4435,7 @@ function Qn(t, e, n, r, s) {
|
|
|
4438
4435
|
* `DocumentSnapshot`. Since query results contain only existing documents, the
|
|
4439
4436
|
* `exists` property will always be true and `data()` will never return
|
|
4440
4437
|
* 'undefined'.
|
|
4441
|
-
*/ class
|
|
4438
|
+
*/ class We extends Ge {
|
|
4442
4439
|
/**
|
|
4443
4440
|
* Retrieves all fields in the document as an `Object`.
|
|
4444
4441
|
*
|
|
@@ -4456,10 +4453,10 @@ function Qn(t, e, n, r, s) {
|
|
|
4456
4453
|
* array via the `docs` property or enumerated using the `forEach` method. The
|
|
4457
4454
|
* number of documents can be determined via the `empty` and `size`
|
|
4458
4455
|
* properties.
|
|
4459
|
-
*/ class
|
|
4456
|
+
*/ class He {
|
|
4460
4457
|
/** @hideconstructor */
|
|
4461
|
-
constructor(t,
|
|
4462
|
-
this._docs =
|
|
4458
|
+
constructor(t, n) {
|
|
4459
|
+
this._docs = n, this.query = t;
|
|
4463
4460
|
}
|
|
4464
4461
|
/** An array of all the documents in the `QuerySnapshot`. */ get docs() {
|
|
4465
4462
|
return [ ...this._docs ];
|
|
@@ -4476,8 +4473,8 @@ function Qn(t, e, n, r, s) {
|
|
|
4476
4473
|
* @param callback - A callback to be called with a `QueryDocumentSnapshot` for
|
|
4477
4474
|
* each document in the snapshot.
|
|
4478
4475
|
* @param thisArg - The `this` binding for the callback.
|
|
4479
|
-
*/ forEach(t,
|
|
4480
|
-
this._docs.forEach(t,
|
|
4476
|
+
*/ forEach(t, n) {
|
|
4477
|
+
this._docs.forEach(t, n);
|
|
4481
4478
|
}
|
|
4482
4479
|
}
|
|
4483
4480
|
|
|
@@ -4487,14 +4484,14 @@ function Qn(t, e, n, r, s) {
|
|
|
4487
4484
|
* @param left - A snapshot to compare.
|
|
4488
4485
|
* @param right - A snapshot to compare.
|
|
4489
4486
|
* @returns true if the snapshots are equal.
|
|
4490
|
-
*/ function
|
|
4491
|
-
return t =
|
|
4487
|
+
*/ function Ye(t, n) {
|
|
4488
|
+
return t = getModularInstance(t), n = getModularInstance(n), t instanceof Ge && n instanceof Ge ? t._firestore === n._firestore && t._key.isEqual(n._key) && (null === t._document ? null === n._document : t._document.isEqual(n._document)) && t._converter === n._converter : t instanceof He && n instanceof He && (we(t.query, n.query) && mt(t.docs, n.docs, Ye));
|
|
4492
4489
|
}
|
|
4493
4490
|
|
|
4494
4491
|
/**
|
|
4495
4492
|
* Helper that calls `fromDotSeparatedString()` but wraps any error thrown.
|
|
4496
|
-
*/ function
|
|
4497
|
-
return "string" == typeof
|
|
4493
|
+
*/ function Ke(t, n) {
|
|
4494
|
+
return "string" == typeof n ? Me(t, n) : n instanceof me ? n._internalPath : n._delegate._internalPath;
|
|
4498
4495
|
}
|
|
4499
4496
|
|
|
4500
4497
|
/**
|
|
@@ -4521,7 +4518,7 @@ function Qn(t, e, n, r, s) {
|
|
|
4521
4518
|
* can then be passed to {@link query} to create a new query instance that
|
|
4522
4519
|
* also contains this `QueryConstraint`.
|
|
4523
4520
|
*/
|
|
4524
|
-
class
|
|
4521
|
+
class Je {}
|
|
4525
4522
|
|
|
4526
4523
|
/**
|
|
4527
4524
|
* Creates a new immutable instance of {@link Query} that is extended to also include
|
|
@@ -4531,43 +4528,43 @@ class Jn {}
|
|
|
4531
4528
|
* @param queryConstraints - The list of {@link QueryConstraint}s to apply.
|
|
4532
4529
|
* @throws if any of the provided query constraints cannot be combined with the
|
|
4533
4530
|
* existing or new constraints.
|
|
4534
|
-
*/ function
|
|
4535
|
-
for (const
|
|
4531
|
+
*/ function Ze(t, ...n) {
|
|
4532
|
+
for (const e of n) t = e._apply(t);
|
|
4536
4533
|
return t;
|
|
4537
4534
|
}
|
|
4538
4535
|
|
|
4539
|
-
class
|
|
4540
|
-
constructor(t,
|
|
4541
|
-
super(), this.ft = t, this.dt =
|
|
4536
|
+
class Xe extends Je {
|
|
4537
|
+
constructor(t, n, e) {
|
|
4538
|
+
super(), this.ft = t, this.dt = n, this.wt = e, this.type = "where";
|
|
4542
4539
|
}
|
|
4543
4540
|
_apply(t) {
|
|
4544
|
-
const
|
|
4541
|
+
const n = Pe(t.firestore), e = function(t, n, e, r, s, i, o) {
|
|
4545
4542
|
let u;
|
|
4546
4543
|
if (s.isKeyField()) {
|
|
4547
|
-
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new L(
|
|
4544
|
+
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new L(I, `Invalid Query. You can't perform '${i}' queries on FieldPath.documentId().`);
|
|
4548
4545
|
if ("in" /* IN */ === i || "not-in" /* NOT_IN */ === i) {
|
|
4549
4546
|
wr(o, i);
|
|
4550
|
-
const
|
|
4551
|
-
for (const
|
|
4547
|
+
const n = [];
|
|
4548
|
+
for (const e of o) n.push(dr(r, t, e));
|
|
4552
4549
|
u = {
|
|
4553
4550
|
arrayValue: {
|
|
4554
|
-
values:
|
|
4551
|
+
values: n
|
|
4555
4552
|
}
|
|
4556
4553
|
};
|
|
4557
4554
|
} else u = dr(r, t, o);
|
|
4558
4555
|
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i || wr(o, i),
|
|
4559
|
-
u =
|
|
4556
|
+
u = Oe(e, n, o,
|
|
4560
4557
|
/* allowArrays= */ "in" /* IN */ === i || "not-in" /* NOT_IN */ === i);
|
|
4561
4558
|
const c = Qt.create(s, i, u);
|
|
4562
|
-
return function(t,
|
|
4563
|
-
if (
|
|
4564
|
-
const
|
|
4565
|
-
if (null !==
|
|
4566
|
-
const r =
|
|
4567
|
-
null !== r && mr(t,
|
|
4559
|
+
return function(t, n) {
|
|
4560
|
+
if (n.D()) {
|
|
4561
|
+
const e = un(t);
|
|
4562
|
+
if (null !== e && !e.isEqual(n.field)) throw new L(I, `Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '${e.toString()}' and '${n.field.toString()}'`);
|
|
4563
|
+
const r = on(t);
|
|
4564
|
+
null !== r && mr(t, n.field, r);
|
|
4568
4565
|
}
|
|
4569
|
-
const
|
|
4570
|
-
for (const
|
|
4566
|
+
const e = function(t, n) {
|
|
4567
|
+
for (const e of t.filters) if (n.indexOf(e.op) >= 0) return e.op;
|
|
4571
4568
|
return null;
|
|
4572
4569
|
}(t,
|
|
4573
4570
|
/**
|
|
@@ -4602,16 +4599,16 @@ class Xn extends Jn {
|
|
|
4602
4599
|
default:
|
|
4603
4600
|
return [];
|
|
4604
4601
|
}
|
|
4605
|
-
}(
|
|
4606
|
-
if (null !==
|
|
4602
|
+
}(n.op));
|
|
4603
|
+
if (null !== e)
|
|
4607
4604
|
// Special case when it's a duplicate op to give a slightly clearer error message.
|
|
4608
|
-
throw
|
|
4605
|
+
throw e === n.op ? new L(I, `Invalid query. You cannot use more than one '${n.op.toString()}' filter.`) : new L(I, `Invalid query. You cannot use '${n.op.toString()}' filters with '${e.toString()}' filters.`);
|
|
4609
4606
|
}(t, c), c;
|
|
4610
|
-
}(t._query, "where",
|
|
4611
|
-
return new
|
|
4612
|
-
const
|
|
4613
|
-
return new
|
|
4614
|
-
}(t._query,
|
|
4607
|
+
}(t._query, "where", n, t.firestore._databaseId, this.ft, this.dt, this.wt);
|
|
4608
|
+
return new ce(t.firestore, t.converter, function(t, n) {
|
|
4609
|
+
const e = t.filters.concat([ n ]);
|
|
4610
|
+
return new rn(t.path, t.collectionGroup, t.explicitOrderBy.slice(), e, t.limit, t.limitType, t.startAt, t.endAt);
|
|
4611
|
+
}(t._query, e));
|
|
4615
4612
|
}
|
|
4616
4613
|
}
|
|
4617
4614
|
|
|
@@ -4625,25 +4622,25 @@ class Xn extends Jn {
|
|
|
4625
4622
|
* "<=", "!=").
|
|
4626
4623
|
* @param value - The value for comparison
|
|
4627
4624
|
* @returns The created {@link Query}.
|
|
4628
|
-
*/ function tr(t,
|
|
4629
|
-
const r =
|
|
4630
|
-
return new
|
|
4625
|
+
*/ function tr(t, n, e) {
|
|
4626
|
+
const r = n, s = Ke("where", t);
|
|
4627
|
+
return new Xe(s, r, e);
|
|
4631
4628
|
}
|
|
4632
4629
|
|
|
4633
|
-
class
|
|
4634
|
-
constructor(t,
|
|
4635
|
-
super(), this.ft = t, this.yt =
|
|
4630
|
+
class nr extends Je {
|
|
4631
|
+
constructor(t, n) {
|
|
4632
|
+
super(), this.ft = t, this.yt = n, this.type = "orderBy";
|
|
4636
4633
|
}
|
|
4637
4634
|
_apply(t) {
|
|
4638
|
-
const
|
|
4639
|
-
if (null !== t.startAt) throw new L(
|
|
4640
|
-
if (null !== t.endAt) throw new L(
|
|
4641
|
-
const r = new
|
|
4642
|
-
return function(t,
|
|
4643
|
-
if (null ===
|
|
4635
|
+
const n = function(t, n, e) {
|
|
4636
|
+
if (null !== t.startAt) throw new L(I, "Invalid query. You must not call startAt() or startAfter() before calling orderBy().");
|
|
4637
|
+
if (null !== t.endAt) throw new L(I, "Invalid query. You must not call endAt() or endBefore() before calling orderBy().");
|
|
4638
|
+
const r = new tn(n, e);
|
|
4639
|
+
return function(t, n) {
|
|
4640
|
+
if (null === on(t)) {
|
|
4644
4641
|
// This is the first order by. It must match any inequality.
|
|
4645
|
-
const
|
|
4646
|
-
null !==
|
|
4642
|
+
const e = un(t);
|
|
4643
|
+
null !== e && mr(t, e, n.field);
|
|
4647
4644
|
}
|
|
4648
4645
|
}(t, r), r;
|
|
4649
4646
|
}
|
|
@@ -4658,11 +4655,11 @@ class er extends Jn {
|
|
|
4658
4655
|
* of the query or if any of the fields in the order by are an uncommitted
|
|
4659
4656
|
* server timestamp.
|
|
4660
4657
|
*/ (t._query, this.ft, this.yt);
|
|
4661
|
-
return new
|
|
4658
|
+
return new ce(t.firestore, t.converter, function(t, n) {
|
|
4662
4659
|
// TODO(dimond): validate that orderBy does not list the same key twice.
|
|
4663
|
-
const
|
|
4664
|
-
return new
|
|
4665
|
-
}(t._query,
|
|
4660
|
+
const e = t.explicitOrderBy.concat([ n ]);
|
|
4661
|
+
return new rn(t.path, t.collectionGroup, e, t.filters.slice(), t.limit, t.limitType, t.startAt, t.endAt);
|
|
4662
|
+
}(t._query, n));
|
|
4666
4663
|
}
|
|
4667
4664
|
}
|
|
4668
4665
|
|
|
@@ -4674,18 +4671,18 @@ class er extends Jn {
|
|
|
4674
4671
|
* @param directionStr - Optional direction to sort by ('asc' or 'desc'). If
|
|
4675
4672
|
* not specified, order will be ascending.
|
|
4676
4673
|
* @returns The created {@link Query}.
|
|
4677
|
-
*/ function
|
|
4678
|
-
const
|
|
4679
|
-
return new
|
|
4674
|
+
*/ function er(t, n = "asc") {
|
|
4675
|
+
const e = n, r = Ke("orderBy", t);
|
|
4676
|
+
return new nr(r, e);
|
|
4680
4677
|
}
|
|
4681
4678
|
|
|
4682
|
-
class rr extends
|
|
4683
|
-
constructor(t,
|
|
4684
|
-
super(), this.type = t, this._t =
|
|
4679
|
+
class rr extends Je {
|
|
4680
|
+
constructor(t, n, e) {
|
|
4681
|
+
super(), this.type = t, this._t = n, this.gt = e;
|
|
4685
4682
|
}
|
|
4686
4683
|
_apply(t) {
|
|
4687
|
-
return new
|
|
4688
|
-
return new
|
|
4684
|
+
return new ce(t.firestore, t.converter, function(t, n, e) {
|
|
4685
|
+
return new rn(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), n, e, t.startAt, t.endAt);
|
|
4689
4686
|
}(t._query, this._t, this.gt));
|
|
4690
4687
|
}
|
|
4691
4688
|
}
|
|
@@ -4711,15 +4708,15 @@ class rr extends Jn {
|
|
|
4711
4708
|
return st("limitToLast", t), new rr("limitToLast", t, "L" /* Last */);
|
|
4712
4709
|
}
|
|
4713
4710
|
|
|
4714
|
-
class or extends
|
|
4715
|
-
constructor(t,
|
|
4716
|
-
super(), this.type = t, this.bt =
|
|
4711
|
+
class or extends Je {
|
|
4712
|
+
constructor(t, n, e) {
|
|
4713
|
+
super(), this.type = t, this.bt = n, this.vt = e;
|
|
4717
4714
|
}
|
|
4718
4715
|
_apply(t) {
|
|
4719
|
-
const
|
|
4720
|
-
return new
|
|
4721
|
-
return new
|
|
4722
|
-
}(t._query,
|
|
4716
|
+
const n = fr(t, this.type, this.bt, this.vt);
|
|
4717
|
+
return new ce(t.firestore, t.converter, function(t, n) {
|
|
4718
|
+
return new rn(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, n, t.endAt);
|
|
4719
|
+
}(t._query, n));
|
|
4723
4720
|
}
|
|
4724
4721
|
}
|
|
4725
4722
|
|
|
@@ -4732,15 +4729,15 @@ function cr(...t) {
|
|
|
4732
4729
|
/*before=*/ !1);
|
|
4733
4730
|
}
|
|
4734
4731
|
|
|
4735
|
-
class ar extends
|
|
4736
|
-
constructor(t,
|
|
4737
|
-
super(), this.type = t, this.bt =
|
|
4732
|
+
class ar extends Je {
|
|
4733
|
+
constructor(t, n, e) {
|
|
4734
|
+
super(), this.type = t, this.bt = n, this.vt = e;
|
|
4738
4735
|
}
|
|
4739
4736
|
_apply(t) {
|
|
4740
|
-
const
|
|
4741
|
-
return new
|
|
4742
|
-
return new
|
|
4743
|
-
}(t._query,
|
|
4737
|
+
const n = fr(t, this.type, this.bt, this.vt);
|
|
4738
|
+
return new ce(t.firestore, t.converter, function(t, n) {
|
|
4739
|
+
return new rn(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, t.startAt, n);
|
|
4740
|
+
}(t._query, n));
|
|
4744
4741
|
}
|
|
4745
4742
|
}
|
|
4746
4743
|
|
|
@@ -4752,9 +4749,9 @@ function lr(...t) {
|
|
|
4752
4749
|
return new ar("endAt", t, /*before=*/ !1);
|
|
4753
4750
|
}
|
|
4754
4751
|
|
|
4755
|
-
/** Helper function to create a bound from a document or fields */ function fr(t,
|
|
4756
|
-
if (
|
|
4757
|
-
if (!r) throw new L(P, `Can't use a DocumentSnapshot that doesn't exist for ${
|
|
4752
|
+
/** Helper function to create a bound from a document or fields */ function fr(t, n, e, r) {
|
|
4753
|
+
if (e[0] = getModularInstance(e[0]), e[0] instanceof Ge) return function(t, n, e, r, s) {
|
|
4754
|
+
if (!r) throw new L(P, `Can't use a DocumentSnapshot that doesn't exist for ${e}().`);
|
|
4758
4755
|
const i = [];
|
|
4759
4756
|
// Because people expect to continue/end a query at the exact document
|
|
4760
4757
|
// provided, we need to use the implicit sort order rather than the explicit
|
|
@@ -4763,12 +4760,12 @@ function lr(...t) {
|
|
|
4763
4760
|
// the provided document. Without the key (by using the explicit sort
|
|
4764
4761
|
// orders), multiple documents could match the position, yielding duplicate
|
|
4765
4762
|
// results.
|
|
4766
|
-
for (const
|
|
4767
|
-
const t = r.data.field(
|
|
4768
|
-
if (Pt(t)) throw new L(
|
|
4763
|
+
for (const e of an(t)) if (e.field.isKeyField()) i.push(qt(n, r.key)); else {
|
|
4764
|
+
const t = r.data.field(e.field);
|
|
4765
|
+
if (Pt(t)) throw new L(I, 'Invalid query. You are trying to start or end a query using a document for which the field "' + e.field + '" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');
|
|
4769
4766
|
if (null === t) {
|
|
4770
|
-
const t =
|
|
4771
|
-
throw new L(
|
|
4767
|
+
const t = e.field.canonicalString();
|
|
4768
|
+
throw new L(I, `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.`);
|
|
4772
4769
|
}
|
|
4773
4770
|
i.push(t);
|
|
4774
4771
|
}
|
|
@@ -4776,25 +4773,25 @@ function lr(...t) {
|
|
|
4776
4773
|
}
|
|
4777
4774
|
/**
|
|
4778
4775
|
* Converts a list of field values to a `Bound` for the given query.
|
|
4779
|
-
*/ (t._query, t.firestore._databaseId,
|
|
4776
|
+
*/ (t._query, t.firestore._databaseId, n, e[0]._document, r);
|
|
4780
4777
|
{
|
|
4781
|
-
const s =
|
|
4782
|
-
return function(t,
|
|
4778
|
+
const s = Pe(t.firestore);
|
|
4779
|
+
return function(t, n, e, r, s, i) {
|
|
4783
4780
|
// Use explicit order by's because it has to match the query the user made
|
|
4784
4781
|
const o = t.explicitOrderBy;
|
|
4785
|
-
if (s.length > o.length) throw new L(
|
|
4782
|
+
if (s.length > o.length) throw new L(I, `Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);
|
|
4786
4783
|
const u = [];
|
|
4787
4784
|
for (let i = 0; i < s.length; i++) {
|
|
4788
4785
|
const c = s[i];
|
|
4789
4786
|
if (o[i].field.isKeyField()) {
|
|
4790
|
-
if ("string" != typeof c) throw new L(
|
|
4791
|
-
if (!
|
|
4792
|
-
const
|
|
4793
|
-
if (!Z.isDocumentKey(
|
|
4794
|
-
const s = new Z(
|
|
4795
|
-
u.push(qt(
|
|
4787
|
+
if ("string" != typeof c) throw new L(I, `Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);
|
|
4788
|
+
if (!cn(t) && -1 !== c.indexOf("/")) throw new L(I, `Invalid query. When querying a collection and ordering by FieldPath.documentId(), the value passed to ${r}() must be a plain document ID, but '${c}' contains a slash.`);
|
|
4789
|
+
const e = t.path.child(Y.fromString(c));
|
|
4790
|
+
if (!Z.isDocumentKey(e)) throw new L(I, `Invalid query. When querying a collection group and ordering by FieldPath.documentId(), the value passed to ${r}() must result in a valid document path, but '${e}' is not because it contains an odd number of segments.`);
|
|
4791
|
+
const s = new Z(e);
|
|
4792
|
+
u.push(qt(n, s));
|
|
4796
4793
|
} else {
|
|
4797
|
-
const t =
|
|
4794
|
+
const t = Oe(e, r, c);
|
|
4798
4795
|
u.push(t);
|
|
4799
4796
|
}
|
|
4800
4797
|
}
|
|
@@ -4804,32 +4801,32 @@ function lr(...t) {
|
|
|
4804
4801
|
* Parses the given `documentIdValue` into a `ReferenceValue`, throwing
|
|
4805
4802
|
* appropriate errors if the value is anything other than a `DocumentReference`
|
|
4806
4803
|
* or `string`, or if the string is malformed.
|
|
4807
|
-
*/ (t._query, t.firestore._databaseId, s,
|
|
4804
|
+
*/ (t._query, t.firestore._databaseId, s, n, e, r);
|
|
4808
4805
|
}
|
|
4809
4806
|
}
|
|
4810
4807
|
|
|
4811
|
-
function dr(t,
|
|
4812
|
-
if ("string" == typeof (
|
|
4813
|
-
if ("" ===
|
|
4814
|
-
if (!
|
|
4815
|
-
const r =
|
|
4816
|
-
if (!Z.isDocumentKey(r)) throw new L(
|
|
4808
|
+
function dr(t, n, e) {
|
|
4809
|
+
if ("string" == typeof (e = getModularInstance(e))) {
|
|
4810
|
+
if ("" === e) throw new L(I, "Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.");
|
|
4811
|
+
if (!cn(n) && -1 !== e.indexOf("/")) throw new L(I, `Invalid query. When querying a collection by FieldPath.documentId(), you must provide a plain document ID, but '${e}' contains a '/' character.`);
|
|
4812
|
+
const r = n.path.child(Y.fromString(e));
|
|
4813
|
+
if (!Z.isDocumentKey(r)) throw new L(I, `Invalid query. When querying a collection group by FieldPath.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}).`);
|
|
4817
4814
|
return qt(t, new Z(r));
|
|
4818
4815
|
}
|
|
4819
|
-
if (
|
|
4820
|
-
throw new L(
|
|
4816
|
+
if (e instanceof ue) return qt(t, e._key);
|
|
4817
|
+
throw new L(I, `Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: ${et(e)}.`);
|
|
4821
4818
|
}
|
|
4822
4819
|
|
|
4823
4820
|
/**
|
|
4824
4821
|
* Validates that the value passed into a disjunctive filter satisfies all
|
|
4825
4822
|
* array requirements.
|
|
4826
|
-
*/ function wr(t,
|
|
4827
|
-
if (!Array.isArray(t) || 0 === t.length) throw new L(
|
|
4828
|
-
if (t.length > 10) throw new L(
|
|
4823
|
+
*/ function wr(t, n) {
|
|
4824
|
+
if (!Array.isArray(t) || 0 === t.length) throw new L(I, `Invalid Query. A non-empty array is required for '${n.toString()}' filters.`);
|
|
4825
|
+
if (t.length > 10) throw new L(I, `Invalid Query. '${n.toString()}' filters support a maximum of 10 elements in the value array.`);
|
|
4829
4826
|
}
|
|
4830
4827
|
|
|
4831
|
-
function mr(t,
|
|
4832
|
-
if (!
|
|
4828
|
+
function mr(t, n, e) {
|
|
4829
|
+
if (!e.isEqual(n)) throw new L(I, `Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '${n.toString()}' and so you must also use '${n.toString()}' as your first argument to orderBy(), but your first orderBy() is on field '${e.toString()}' instead.`);
|
|
4833
4830
|
}
|
|
4834
4831
|
|
|
4835
4832
|
/**
|
|
@@ -4879,18 +4876,18 @@ function mr(t, e, n) {
|
|
|
4879
4876
|
* their `set()` or fails due to invalid data originating from a `toFirestore()`
|
|
4880
4877
|
* call.
|
|
4881
4878
|
*/
|
|
4882
|
-
function pr(t,
|
|
4879
|
+
function pr(t, n, e) {
|
|
4883
4880
|
let r;
|
|
4884
4881
|
// Cast to `any` in order to satisfy the union type constraint on
|
|
4885
4882
|
// toFirestore().
|
|
4886
4883
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4887
|
-
return r = t ?
|
|
4884
|
+
return r = t ? e && (e.merge || e.mergeFields) ? t.toFirestore(n, e) : t.toFirestore(n) : n,
|
|
4888
4885
|
r;
|
|
4889
4886
|
}
|
|
4890
4887
|
|
|
4891
4888
|
class yr extends class {
|
|
4892
|
-
convertValue(t,
|
|
4893
|
-
switch (
|
|
4889
|
+
convertValue(t, n = "none") {
|
|
4890
|
+
switch (Dt(t)) {
|
|
4894
4891
|
case 0 /* NullValue */ :
|
|
4895
4892
|
return null;
|
|
4896
4893
|
|
|
@@ -4898,13 +4895,13 @@ class yr extends class {
|
|
|
4898
4895
|
return t.booleanValue;
|
|
4899
4896
|
|
|
4900
4897
|
case 2 /* NumberValue */ :
|
|
4901
|
-
return
|
|
4898
|
+
return It(t.integerValue || t.doubleValue);
|
|
4902
4899
|
|
|
4903
4900
|
case 3 /* TimestampValue */ :
|
|
4904
4901
|
return this.convertTimestamp(t.timestampValue);
|
|
4905
4902
|
|
|
4906
4903
|
case 4 /* ServerTimestampValue */ :
|
|
4907
|
-
return this.convertServerTimestamp(t,
|
|
4904
|
+
return this.convertServerTimestamp(t, n);
|
|
4908
4905
|
|
|
4909
4906
|
case 5 /* StringValue */ :
|
|
4910
4907
|
return t.stringValue;
|
|
@@ -4919,32 +4916,32 @@ class yr extends class {
|
|
|
4919
4916
|
return this.convertGeoPoint(t.geoPointValue);
|
|
4920
4917
|
|
|
4921
4918
|
case 9 /* ArrayValue */ :
|
|
4922
|
-
return this.convertArray(t.arrayValue,
|
|
4919
|
+
return this.convertArray(t.arrayValue, n);
|
|
4923
4920
|
|
|
4924
4921
|
case 10 /* ObjectValue */ :
|
|
4925
|
-
return this.convertObject(t.mapValue,
|
|
4922
|
+
return this.convertObject(t.mapValue, n);
|
|
4926
4923
|
|
|
4927
4924
|
default:
|
|
4928
4925
|
throw _();
|
|
4929
4926
|
}
|
|
4930
4927
|
}
|
|
4931
|
-
convertObject(t,
|
|
4932
|
-
const
|
|
4928
|
+
convertObject(t, n) {
|
|
4929
|
+
const e = {};
|
|
4933
4930
|
return gt(t.fields, ((t, r) => {
|
|
4934
|
-
|
|
4935
|
-
})),
|
|
4931
|
+
e[t] = this.convertValue(r, n);
|
|
4932
|
+
})), e;
|
|
4936
4933
|
}
|
|
4937
4934
|
convertGeoPoint(t) {
|
|
4938
|
-
return new
|
|
4935
|
+
return new ge(It(t.latitude), It(t.longitude));
|
|
4939
4936
|
}
|
|
4940
|
-
convertArray(t,
|
|
4941
|
-
return (t.values || []).map((t => this.convertValue(t,
|
|
4937
|
+
convertArray(t, n) {
|
|
4938
|
+
return (t.values || []).map((t => this.convertValue(t, n)));
|
|
4942
4939
|
}
|
|
4943
|
-
convertServerTimestamp(t,
|
|
4944
|
-
switch (
|
|
4940
|
+
convertServerTimestamp(t, n) {
|
|
4941
|
+
switch (n) {
|
|
4945
4942
|
case "previous":
|
|
4946
|
-
const
|
|
4947
|
-
return null ==
|
|
4943
|
+
const e = Rt(t);
|
|
4944
|
+
return null == e ? null : this.convertValue(e, n);
|
|
4948
4945
|
|
|
4949
4946
|
case "estimate":
|
|
4950
4947
|
return this.convertTimestamp(Vt(t));
|
|
@@ -4954,16 +4951,16 @@ class yr extends class {
|
|
|
4954
4951
|
}
|
|
4955
4952
|
}
|
|
4956
4953
|
convertTimestamp(t) {
|
|
4957
|
-
const
|
|
4958
|
-
return new pt(
|
|
4954
|
+
const n = Tt(t);
|
|
4955
|
+
return new pt(n.seconds, n.nanos);
|
|
4959
4956
|
}
|
|
4960
|
-
convertDocumentKey(t,
|
|
4961
|
-
const
|
|
4962
|
-
g(
|
|
4963
|
-
const r = new
|
|
4964
|
-
return r.isEqual(
|
|
4957
|
+
convertDocumentKey(t, n) {
|
|
4958
|
+
const e = Y.fromString(t);
|
|
4959
|
+
g(Gn(e));
|
|
4960
|
+
const r = new W(e.get(1), e.get(3)), s = new Z(e.popFirst(5));
|
|
4961
|
+
return r.isEqual(n) ||
|
|
4965
4962
|
// TODO(b/64130202): Somehow support foreign references.
|
|
4966
|
-
m(`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 (${
|
|
4963
|
+
m(`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 (${n.projectId}/${n.database}) instead.`),
|
|
4967
4964
|
s;
|
|
4968
4965
|
}
|
|
4969
4966
|
} {
|
|
@@ -4971,11 +4968,11 @@ class yr extends class {
|
|
|
4971
4968
|
super(), this.firestore = t;
|
|
4972
4969
|
}
|
|
4973
4970
|
convertBytes(t) {
|
|
4974
|
-
return new
|
|
4971
|
+
return new ye(t);
|
|
4975
4972
|
}
|
|
4976
4973
|
convertReference(t) {
|
|
4977
|
-
const
|
|
4978
|
-
return new
|
|
4974
|
+
const n = this.convertDocumentKey(t, this.firestore._databaseId);
|
|
4975
|
+
return new ue(this.firestore, /* converter= */ null, n);
|
|
4979
4976
|
}
|
|
4980
4977
|
}
|
|
4981
4978
|
|
|
@@ -4992,11 +4989,11 @@ class yr extends class {
|
|
|
4992
4989
|
* @returns A Promise resolved with a `DocumentSnapshot` containing the current
|
|
4993
4990
|
* document contents.
|
|
4994
4991
|
*/ function _r(t) {
|
|
4995
|
-
const
|
|
4996
|
-
return
|
|
4997
|
-
g(1 ===
|
|
4998
|
-
const r =
|
|
4999
|
-
return new
|
|
4992
|
+
const n = te((t = rt(t, ue)).firestore), e = new yr(t.firestore);
|
|
4993
|
+
return Jn(n, [ t._key ]).then((n => {
|
|
4994
|
+
g(1 === n.length);
|
|
4995
|
+
const r = n[0];
|
|
4996
|
+
return new Ge(t.firestore, e, t._key, r.isFoundDocument() ? r : null, t.converter);
|
|
5000
4997
|
}));
|
|
5001
4998
|
}
|
|
5002
4999
|
|
|
@@ -5013,31 +5010,31 @@ class yr extends class {
|
|
|
5013
5010
|
* @returns A Promise that will be resolved with the results of the query.
|
|
5014
5011
|
*/ function gr(t) {
|
|
5015
5012
|
!function(t) {
|
|
5016
|
-
if (
|
|
5017
|
-
}((t = rt(t,
|
|
5018
|
-
const
|
|
5019
|
-
return
|
|
5020
|
-
const r =
|
|
5021
|
-
return
|
|
5013
|
+
if (sn(t) && 0 === t.explicitOrderBy.length) throw new L(q, "limitToLast() queries require specifying at least one orderBy() clause");
|
|
5014
|
+
}((t = rt(t, ce))._query);
|
|
5015
|
+
const n = te(t.firestore), e = new yr(t.firestore);
|
|
5016
|
+
return Zn(n, t._query).then((n => {
|
|
5017
|
+
const r = n.map((n => new We(t.firestore, e, n.key, n, t.converter)));
|
|
5018
|
+
return sn(t._query) &&
|
|
5022
5019
|
// Limit to last queries reverse the orderBy constraint that was
|
|
5023
5020
|
// specified by the user. As such, we need to reverse the order of the
|
|
5024
5021
|
// results to return the documents in the expected order.
|
|
5025
|
-
r.reverse(), new
|
|
5022
|
+
r.reverse(), new He(t, r);
|
|
5026
5023
|
}));
|
|
5027
5024
|
}
|
|
5028
5025
|
|
|
5029
|
-
function br(t,
|
|
5030
|
-
const r = pr((t = rt(t,
|
|
5031
|
-
return
|
|
5026
|
+
function br(t, n, e) {
|
|
5027
|
+
const r = pr((t = rt(t, ue)).converter, n, e), s = Re(Pe(t.firestore), "setDoc", t._key, r, null !== t.converter, e);
|
|
5028
|
+
return Kn(te(t.firestore), [ s.toMutation(t._key, gn.none()) ]);
|
|
5032
5029
|
}
|
|
5033
5030
|
|
|
5034
|
-
function vr(t,
|
|
5035
|
-
const s =
|
|
5031
|
+
function vr(t, n, e, ...r) {
|
|
5032
|
+
const s = Pe((t = rt(t, ue)).firestore);
|
|
5036
5033
|
// For Compat types, we have to "extract" the underlying types before
|
|
5037
5034
|
// performing validation.
|
|
5038
5035
|
let i;
|
|
5039
|
-
i = "string" == typeof (
|
|
5040
|
-
return
|
|
5036
|
+
i = "string" == typeof (n = getModularInstance(n)) || n instanceof me ? xe(s, "updateDoc", t._key, n, e, r) : qe(s, "updateDoc", t._key, n);
|
|
5037
|
+
return Kn(te(t.firestore), [ i.toMutation(t._key, gn.exists(!0)) ]);
|
|
5041
5038
|
}
|
|
5042
5039
|
|
|
5043
5040
|
/**
|
|
@@ -5052,7 +5049,7 @@ function vr(t, e, n, ...r) {
|
|
|
5052
5049
|
* @returns A `Promise` resolved once the document has been successfully
|
|
5053
5050
|
* deleted from the backend.
|
|
5054
5051
|
*/ function Er(t) {
|
|
5055
|
-
return
|
|
5052
|
+
return Kn(te((t = rt(t, ue)).firestore), [ new Tn(t._key, gn.none()) ]);
|
|
5056
5053
|
}
|
|
5057
5054
|
|
|
5058
5055
|
/**
|
|
@@ -5068,9 +5065,9 @@ function vr(t, e, n, ...r) {
|
|
|
5068
5065
|
* @param data - An Object containing the data for the new document.
|
|
5069
5066
|
* @returns A `Promise` resolved with a `DocumentReference` pointing to the
|
|
5070
5067
|
* newly created document after it has been written to the backend.
|
|
5071
|
-
*/ function
|
|
5072
|
-
const
|
|
5073
|
-
return
|
|
5068
|
+
*/ function Tr(t, n) {
|
|
5069
|
+
const e = fe(t = rt(t, ae)), r = pr(t.converter, n), s = Re(Pe(t.firestore), "addDoc", e._key, r, null !== e.converter, {});
|
|
5070
|
+
return Kn(te(t.firestore), [ s.toMutation(e._key, gn.exists(!1)) ]).then((() => e));
|
|
5074
5071
|
}
|
|
5075
5072
|
|
|
5076
5073
|
/**
|
|
@@ -5092,15 +5089,15 @@ function vr(t, e, n, ...r) {
|
|
|
5092
5089
|
/**
|
|
5093
5090
|
* Returns a sentinel for use with {@link @firebase/firestore/lite#(updateDoc:1)} or
|
|
5094
5091
|
* {@link @firebase/firestore/lite#(setDoc:1)} with `{merge: true}` to mark a field for deletion.
|
|
5095
|
-
*/ function
|
|
5096
|
-
return new
|
|
5092
|
+
*/ function Ir() {
|
|
5093
|
+
return new Ve("deleteField");
|
|
5097
5094
|
}
|
|
5098
5095
|
|
|
5099
5096
|
/**
|
|
5100
5097
|
* Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
|
|
5101
5098
|
* include a server-generated timestamp in the written data.
|
|
5102
5099
|
*/ function Ar() {
|
|
5103
|
-
return new
|
|
5100
|
+
return new Ne("serverTimestamp");
|
|
5104
5101
|
}
|
|
5105
5102
|
|
|
5106
5103
|
/**
|
|
@@ -5117,7 +5114,7 @@ function vr(t, e, n, ...r) {
|
|
|
5117
5114
|
*/ function Pr(...t) {
|
|
5118
5115
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5119
5116
|
// update() since we'd need the Firestore instance to do this.
|
|
5120
|
-
return new $
|
|
5117
|
+
return new $e("arrayUnion", t);
|
|
5121
5118
|
}
|
|
5122
5119
|
|
|
5123
5120
|
/**
|
|
@@ -5133,7 +5130,7 @@ function vr(t, e, n, ...r) {
|
|
|
5133
5130
|
*/ function Rr(...t) {
|
|
5134
5131
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5135
5132
|
// update() since we'd need the Firestore instance to do this.
|
|
5136
|
-
return new
|
|
5133
|
+
return new Fe("arrayRemove", t);
|
|
5137
5134
|
}
|
|
5138
5135
|
|
|
5139
5136
|
/**
|
|
@@ -5155,7 +5152,7 @@ function vr(t, e, n, ...r) {
|
|
|
5155
5152
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5156
5153
|
* `updateDoc()`
|
|
5157
5154
|
*/ function Vr(t) {
|
|
5158
|
-
return new
|
|
5155
|
+
return new Se("increment", t);
|
|
5159
5156
|
}
|
|
5160
5157
|
|
|
5161
5158
|
/**
|
|
@@ -5181,25 +5178,25 @@ function vr(t, e, n, ...r) {
|
|
|
5181
5178
|
* provides methods for adding writes to the write batch. None of the writes
|
|
5182
5179
|
* will be committed (or visible locally) until {@link WriteBatch.commit} is
|
|
5183
5180
|
* called.
|
|
5184
|
-
*/ class
|
|
5181
|
+
*/ class Dr {
|
|
5185
5182
|
/** @hideconstructor */
|
|
5186
|
-
constructor(t,
|
|
5187
|
-
this._firestore = t, this._commitHandler =
|
|
5188
|
-
this._dataReader =
|
|
5183
|
+
constructor(t, n) {
|
|
5184
|
+
this._firestore = t, this._commitHandler = n, this._mutations = [], this._committed = !1,
|
|
5185
|
+
this._dataReader = Pe(t);
|
|
5189
5186
|
}
|
|
5190
|
-
set(t,
|
|
5187
|
+
set(t, n, e) {
|
|
5191
5188
|
this._verifyNotCommitted();
|
|
5192
|
-
const r =
|
|
5193
|
-
return this._mutations.push(i.toMutation(r._key,
|
|
5189
|
+
const r = Nr(t, this._firestore), s = pr(r.converter, n, e), i = Re(this._dataReader, "WriteBatch.set", r._key, s, null !== r.converter, e);
|
|
5190
|
+
return this._mutations.push(i.toMutation(r._key, gn.none())), this;
|
|
5194
5191
|
}
|
|
5195
|
-
update(t,
|
|
5192
|
+
update(t, n, e, ...r) {
|
|
5196
5193
|
this._verifyNotCommitted();
|
|
5197
|
-
const s =
|
|
5194
|
+
const s = Nr(t, this._firestore);
|
|
5198
5195
|
// For Compat types, we have to "extract" the underlying types before
|
|
5199
5196
|
// performing validation.
|
|
5200
5197
|
let i;
|
|
5201
|
-
return i = "string" == typeof (
|
|
5202
|
-
this._mutations.push(i.toMutation(s._key,
|
|
5198
|
+
return i = "string" == typeof (n = getModularInstance(n)) || n instanceof me ? xe(this._dataReader, "WriteBatch.update", s._key, n, e, r) : qe(this._dataReader, "WriteBatch.update", s._key, n),
|
|
5199
|
+
this._mutations.push(i.toMutation(s._key, gn.exists(!0))), this;
|
|
5203
5200
|
}
|
|
5204
5201
|
/**
|
|
5205
5202
|
* Deletes the document referred to by the provided {@link DocumentReference}.
|
|
@@ -5208,8 +5205,8 @@ function vr(t, e, n, ...r) {
|
|
|
5208
5205
|
* @returns This `WriteBatch` instance. Used for chaining method calls.
|
|
5209
5206
|
*/ delete(t) {
|
|
5210
5207
|
this._verifyNotCommitted();
|
|
5211
|
-
const
|
|
5212
|
-
return this._mutations = this._mutations.concat(new
|
|
5208
|
+
const n = Nr(t, this._firestore);
|
|
5209
|
+
return this._mutations = this._mutations.concat(new Tn(n._key, gn.none())), this;
|
|
5213
5210
|
}
|
|
5214
5211
|
/**
|
|
5215
5212
|
* Commits all of the writes in this write batch as a single atomic unit.
|
|
@@ -5230,8 +5227,8 @@ function vr(t, e, n, ...r) {
|
|
|
5230
5227
|
}
|
|
5231
5228
|
}
|
|
5232
5229
|
|
|
5233
|
-
function
|
|
5234
|
-
if ((t =
|
|
5230
|
+
function Nr(t, n) {
|
|
5231
|
+
if ((t = getModularInstance(t)).firestore !== n) throw new L(I, "Provided document reference is from a different Firestore instance.");
|
|
5235
5232
|
return t;
|
|
5236
5233
|
}
|
|
5237
5234
|
|
|
@@ -5248,8 +5245,8 @@ function Dr(t, e) {
|
|
|
5248
5245
|
* @returns A `WriteBatch` that can be used to atomically execute multiple
|
|
5249
5246
|
* writes.
|
|
5250
5247
|
*/ function $r(t) {
|
|
5251
|
-
const
|
|
5252
|
-
return new
|
|
5248
|
+
const n = te(t = rt(t, ee));
|
|
5249
|
+
return new Dr(t, (t => Kn(n, t)));
|
|
5253
5250
|
}
|
|
5254
5251
|
|
|
5255
5252
|
/**
|
|
@@ -5290,67 +5287,67 @@ function Dr(t, e) {
|
|
|
5290
5287
|
this.writtenDocs = new Set;
|
|
5291
5288
|
}
|
|
5292
5289
|
async lookup(t) {
|
|
5293
|
-
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new L(
|
|
5294
|
-
const
|
|
5295
|
-
return
|
|
5290
|
+
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new L(I, "Firestore transactions require all reads to be executed before all writes.");
|
|
5291
|
+
const n = await Jn(this.datastore, t);
|
|
5292
|
+
return n.forEach((t => this.recordVersion(t))), n;
|
|
5296
5293
|
}
|
|
5297
|
-
set(t,
|
|
5298
|
-
this.write(
|
|
5294
|
+
set(t, n) {
|
|
5295
|
+
this.write(n.toMutation(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5299
5296
|
}
|
|
5300
|
-
update(t,
|
|
5297
|
+
update(t, n) {
|
|
5301
5298
|
try {
|
|
5302
|
-
this.write(
|
|
5299
|
+
this.write(n.toMutation(t, this.preconditionForUpdate(t)));
|
|
5303
5300
|
} catch (t) {
|
|
5304
5301
|
this.lastWriteError = t;
|
|
5305
5302
|
}
|
|
5306
5303
|
this.writtenDocs.add(t.toString());
|
|
5307
5304
|
}
|
|
5308
5305
|
delete(t) {
|
|
5309
|
-
this.write(new
|
|
5306
|
+
this.write(new Tn(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5310
5307
|
}
|
|
5311
5308
|
async commit() {
|
|
5312
5309
|
if (this.ensureCommitNotCalled(), this.lastWriteError) throw this.lastWriteError;
|
|
5313
5310
|
const t = this.readVersions;
|
|
5314
5311
|
// For each mutation, note that the doc was written.
|
|
5315
|
-
this.mutations.forEach((
|
|
5316
|
-
t.delete(
|
|
5312
|
+
this.mutations.forEach((n => {
|
|
5313
|
+
t.delete(n.key.toString());
|
|
5317
5314
|
})),
|
|
5318
5315
|
// For each document that was read but not written to, we want to perform
|
|
5319
5316
|
// a `verify` operation.
|
|
5320
|
-
t.forEach(((t,
|
|
5321
|
-
const
|
|
5322
|
-
this.mutations.push(new
|
|
5323
|
-
})), await
|
|
5317
|
+
t.forEach(((t, n) => {
|
|
5318
|
+
const e = Z.fromPath(n);
|
|
5319
|
+
this.mutations.push(new In(e, this.precondition(e)));
|
|
5320
|
+
})), await Kn(this.datastore, this.mutations), this.committed = !0;
|
|
5324
5321
|
}
|
|
5325
5322
|
recordVersion(t) {
|
|
5326
|
-
let
|
|
5327
|
-
if (t.isFoundDocument())
|
|
5323
|
+
let n;
|
|
5324
|
+
if (t.isFoundDocument()) n = t.version; else {
|
|
5328
5325
|
if (!t.isNoDocument()) throw _();
|
|
5329
5326
|
// For deleted docs, we must use baseVersion 0 when we overwrite them.
|
|
5330
|
-
|
|
5327
|
+
n = yt.min();
|
|
5331
5328
|
}
|
|
5332
|
-
const
|
|
5333
|
-
if (
|
|
5334
|
-
if (!
|
|
5329
|
+
const e = this.readVersions.get(t.key.toString());
|
|
5330
|
+
if (e) {
|
|
5331
|
+
if (!n.isEqual(e))
|
|
5335
5332
|
// This transaction will fail no matter what.
|
|
5336
5333
|
throw new L(F, "Document version changed between two reads.");
|
|
5337
|
-
} else this.readVersions.set(t.key.toString(),
|
|
5334
|
+
} else this.readVersions.set(t.key.toString(), n);
|
|
5338
5335
|
}
|
|
5339
5336
|
/**
|
|
5340
5337
|
* Returns the version of this document when it was read in this transaction,
|
|
5341
5338
|
* as a precondition, or no precondition if it was not read.
|
|
5342
5339
|
*/ precondition(t) {
|
|
5343
|
-
const
|
|
5344
|
-
return !this.writtenDocs.has(t.toString()) &&
|
|
5340
|
+
const n = this.readVersions.get(t.toString());
|
|
5341
|
+
return !this.writtenDocs.has(t.toString()) && n ? gn.updateTime(n) : gn.none();
|
|
5345
5342
|
}
|
|
5346
5343
|
/**
|
|
5347
5344
|
* Returns the precondition for a document if the operation is an update.
|
|
5348
5345
|
*/ preconditionForUpdate(t) {
|
|
5349
|
-
const
|
|
5346
|
+
const n = this.readVersions.get(t.toString());
|
|
5350
5347
|
// The first time a document is written, we want to take into account the
|
|
5351
5348
|
// read time and existence
|
|
5352
|
-
if (!this.writtenDocs.has(t.toString()) &&
|
|
5353
|
-
if (
|
|
5349
|
+
if (!this.writtenDocs.has(t.toString()) && n) {
|
|
5350
|
+
if (n.isEqual(yt.min()))
|
|
5354
5351
|
// The document doesn't exist, so fail the transaction.
|
|
5355
5352
|
// This has to be validated locally because you can't send a
|
|
5356
5353
|
// precondition that a document does not exist without changing the
|
|
@@ -5360,13 +5357,13 @@ function Dr(t, e) {
|
|
|
5360
5357
|
// express that to the backend, we have to validate locally.
|
|
5361
5358
|
// Note: this can change once we can send separate verify writes in the
|
|
5362
5359
|
// transaction.
|
|
5363
|
-
throw new L(
|
|
5360
|
+
throw new L(I, "Can't update a document that doesn't exist.");
|
|
5364
5361
|
// Document exists, base precondition on document update time.
|
|
5365
|
-
return
|
|
5362
|
+
return gn.updateTime(n);
|
|
5366
5363
|
}
|
|
5367
5364
|
// Document was not read, so we just use the preconditions for a blind
|
|
5368
5365
|
// update.
|
|
5369
|
-
return
|
|
5366
|
+
return gn.exists(!0);
|
|
5370
5367
|
}
|
|
5371
5368
|
write(t) {
|
|
5372
5369
|
this.ensureCommitNotCalled(), this.mutations.push(t);
|
|
@@ -5395,19 +5392,19 @@ function Dr(t, e) {
|
|
|
5395
5392
|
* with backoff.
|
|
5396
5393
|
*/
|
|
5397
5394
|
class Sr {
|
|
5398
|
-
constructor(t,
|
|
5399
|
-
this.asyncQueue = t, this.datastore =
|
|
5400
|
-
this.Et = 5, this.
|
|
5395
|
+
constructor(t, n, e, r) {
|
|
5396
|
+
this.asyncQueue = t, this.datastore = n, this.updateFunction = e, this.deferred = r,
|
|
5397
|
+
this.Et = 5, this.Tt = new Hn(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
|
|
5401
5398
|
}
|
|
5402
5399
|
/** Runs the transaction and sets the result on deferred. */ run() {
|
|
5403
|
-
this.Et -= 1, this.
|
|
5400
|
+
this.Et -= 1, this.It();
|
|
5404
5401
|
}
|
|
5405
|
-
|
|
5406
|
-
this.
|
|
5407
|
-
const t = new Fr(this.datastore),
|
|
5408
|
-
|
|
5402
|
+
It() {
|
|
5403
|
+
this.Tt.G((async () => {
|
|
5404
|
+
const t = new Fr(this.datastore), n = this.At(t);
|
|
5405
|
+
n && n.then((n => {
|
|
5409
5406
|
this.asyncQueue.enqueueAndForget((() => t.commit().then((() => {
|
|
5410
|
-
this.deferred.resolve(
|
|
5407
|
+
this.deferred.resolve(n);
|
|
5411
5408
|
})).catch((t => {
|
|
5412
5409
|
this.Pt(t);
|
|
5413
5410
|
}))));
|
|
@@ -5418,8 +5415,8 @@ class Sr {
|
|
|
5418
5415
|
}
|
|
5419
5416
|
At(t) {
|
|
5420
5417
|
try {
|
|
5421
|
-
const
|
|
5422
|
-
return !it(
|
|
5418
|
+
const n = this.updateFunction(t);
|
|
5419
|
+
return !it(n) && n.catch && n.then ? n : (this.deferred.reject(Error("Transaction callback must return a Promise")),
|
|
5423
5420
|
null);
|
|
5424
5421
|
} catch (t) {
|
|
5425
5422
|
// Do not retry errors thrown by user provided updateFunction.
|
|
@@ -5427,15 +5424,15 @@ class Sr {
|
|
|
5427
5424
|
}
|
|
5428
5425
|
}
|
|
5429
5426
|
Pt(t) {
|
|
5430
|
-
this.Et > 0 && this.Rt(t) ? (this.Et -= 1, this.asyncQueue.enqueueAndForget((() => (this.
|
|
5427
|
+
this.Et > 0 && this.Rt(t) ? (this.Et -= 1, this.asyncQueue.enqueueAndForget((() => (this.It(),
|
|
5431
5428
|
Promise.resolve())))) : this.deferred.reject(t);
|
|
5432
5429
|
}
|
|
5433
5430
|
Rt(t) {
|
|
5434
5431
|
if ("FirebaseError" === t.name) {
|
|
5435
5432
|
// In transactions, the backend will fail outdated reads with FAILED_PRECONDITION and
|
|
5436
5433
|
// non-matching document versions with ABORTED. These errors should be retried.
|
|
5437
|
-
const
|
|
5438
|
-
return "aborted" ===
|
|
5434
|
+
const n = t.code;
|
|
5435
|
+
return "aborted" === n || "failed-precondition" === n || !
|
|
5439
5436
|
/**
|
|
5440
5437
|
* Determines whether an error code represents a permanent error when received
|
|
5441
5438
|
* in response to a non-write operation.
|
|
@@ -5444,21 +5441,21 @@ class Sr {
|
|
|
5444
5441
|
*/
|
|
5445
5442
|
function(t) {
|
|
5446
5443
|
switch (t) {
|
|
5447
|
-
|
|
5444
|
+
default:
|
|
5448
5445
|
return _();
|
|
5449
5446
|
|
|
5450
5447
|
case E:
|
|
5451
|
-
case
|
|
5448
|
+
case T:
|
|
5452
5449
|
case A:
|
|
5453
|
-
case
|
|
5450
|
+
case N:
|
|
5454
5451
|
case x:
|
|
5455
5452
|
case O:
|
|
5456
5453
|
// Unauthenticated means something went wrong with our token and we need
|
|
5457
5454
|
// to retry with new credentials which will happen automatically.
|
|
5458
|
-
case
|
|
5455
|
+
case D:
|
|
5459
5456
|
return !1;
|
|
5460
5457
|
|
|
5461
|
-
case
|
|
5458
|
+
case I:
|
|
5462
5459
|
case P:
|
|
5463
5460
|
case R:
|
|
5464
5461
|
case V:
|
|
@@ -5471,11 +5468,8 @@ class Sr {
|
|
|
5471
5468
|
case q:
|
|
5472
5469
|
case C:
|
|
5473
5470
|
return !0;
|
|
5474
|
-
|
|
5475
|
-
default:
|
|
5476
|
-
return _();
|
|
5477
5471
|
}
|
|
5478
|
-
}(
|
|
5472
|
+
}(n);
|
|
5479
5473
|
}
|
|
5480
5474
|
return !1;
|
|
5481
5475
|
}
|
|
@@ -5530,8 +5524,8 @@ class Sr {
|
|
|
5530
5524
|
* in newer versions of TypeScript defines `finally`, which is not available in
|
|
5531
5525
|
* IE.
|
|
5532
5526
|
*/ class xr {
|
|
5533
|
-
constructor(t,
|
|
5534
|
-
this.asyncQueue = t, this.timerId =
|
|
5527
|
+
constructor(t, n, e, r, s) {
|
|
5528
|
+
this.asyncQueue = t, this.timerId = n, this.targetTimeMs = e, this.op = r, this.removalCallback = s,
|
|
5535
5529
|
this.deferred = new U, this.then = this.deferred.promise.then.bind(this.deferred.promise),
|
|
5536
5530
|
// It's normal for the deferred promise to be canceled (due to cancellation)
|
|
5537
5531
|
// and so we attach a dummy catch callback to avoid
|
|
@@ -5551,9 +5545,9 @@ class Sr {
|
|
|
5551
5545
|
* from its delayedOperations list.
|
|
5552
5546
|
* PORTING NOTE: This exists to prevent making removeDelayedOperation() and
|
|
5553
5547
|
* the DelayedOperation class public.
|
|
5554
|
-
*/ static createAndSchedule(t,
|
|
5555
|
-
const i = Date.now() +
|
|
5556
|
-
return o.start(
|
|
5548
|
+
*/ static createAndSchedule(t, n, e, r, s) {
|
|
5549
|
+
const i = Date.now() + e, o = new xr(t, n, i, r, s);
|
|
5550
|
+
return o.start(e), o;
|
|
5557
5551
|
}
|
|
5558
5552
|
/**
|
|
5559
5553
|
* Starts the timer. This is called immediately after construction by
|
|
@@ -5607,10 +5601,10 @@ class Sr {
|
|
|
5607
5601
|
this.Vt = Promise.resolve(),
|
|
5608
5602
|
// A list of retryable operations. Retryable operations are run in order and
|
|
5609
5603
|
// retried with backoff.
|
|
5610
|
-
this.
|
|
5604
|
+
this.Dt = [],
|
|
5611
5605
|
// Is this AsyncQueue being shut down? Once it is set to true, it will not
|
|
5612
5606
|
// be changed again.
|
|
5613
|
-
this.
|
|
5607
|
+
this.Nt = !1,
|
|
5614
5608
|
// Operations scheduled to be queued in the future. Operations are
|
|
5615
5609
|
// automatically removed after they are run or canceled.
|
|
5616
5610
|
this.$t = [],
|
|
@@ -5624,19 +5618,19 @@ class Sr {
|
|
|
5624
5618
|
// List of TimerIds to fast-forward delays for.
|
|
5625
5619
|
this.xt = [],
|
|
5626
5620
|
// Backoff timer used to schedule retries for retryable operations
|
|
5627
|
-
this.
|
|
5621
|
+
this.Tt = new Hn(this, "async_queue_retry" /* AsyncQueueRetry */),
|
|
5628
5622
|
// Visibility handler that triggers an immediate retry of all retryable
|
|
5629
5623
|
// operations. Meant to speed up recovery when we regain file system access
|
|
5630
5624
|
// after page comes into foreground.
|
|
5631
5625
|
this.Ot = () => {
|
|
5632
5626
|
const t = qr();
|
|
5633
|
-
t && w("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.
|
|
5627
|
+
t && w("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.Tt.H();
|
|
5634
5628
|
};
|
|
5635
5629
|
const t = qr();
|
|
5636
5630
|
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.Ot);
|
|
5637
5631
|
}
|
|
5638
5632
|
get isShuttingDown() {
|
|
5639
|
-
return this.
|
|
5633
|
+
return this.Nt;
|
|
5640
5634
|
}
|
|
5641
5635
|
/**
|
|
5642
5636
|
* Adds a new operation to the queue without waiting for it to complete (i.e.
|
|
@@ -5651,33 +5645,33 @@ class Sr {
|
|
|
5651
5645
|
this.Lt(t);
|
|
5652
5646
|
}
|
|
5653
5647
|
enterRestrictedMode(t) {
|
|
5654
|
-
if (!this.
|
|
5655
|
-
this.
|
|
5656
|
-
const
|
|
5657
|
-
|
|
5648
|
+
if (!this.Nt) {
|
|
5649
|
+
this.Nt = !0, this.qt = t || !1;
|
|
5650
|
+
const n = qr();
|
|
5651
|
+
n && "function" == typeof n.removeEventListener && n.removeEventListener("visibilitychange", this.Ot);
|
|
5658
5652
|
}
|
|
5659
5653
|
}
|
|
5660
5654
|
enqueue(t) {
|
|
5661
|
-
if (this.Ct(), this.
|
|
5655
|
+
if (this.Ct(), this.Nt)
|
|
5662
5656
|
// Return a Promise which never resolves.
|
|
5663
5657
|
return new Promise((() => {}));
|
|
5664
5658
|
// Create a deferred Promise that we can return to the callee. This
|
|
5665
5659
|
// allows us to return a "hanging Promise" only to the callee and still
|
|
5666
5660
|
// advance the queue even when the operation is not run.
|
|
5667
|
-
const
|
|
5668
|
-
return this.Lt((() => this.
|
|
5669
|
-
|
|
5661
|
+
const n = new U;
|
|
5662
|
+
return this.Lt((() => this.Nt && this.qt ? Promise.resolve() : (t().then(n.resolve, n.reject),
|
|
5663
|
+
n.promise))).then((() => n.promise));
|
|
5670
5664
|
}
|
|
5671
5665
|
enqueueRetryable(t) {
|
|
5672
|
-
this.enqueueAndForget((() => (this.
|
|
5666
|
+
this.enqueueAndForget((() => (this.Dt.push(t), this.Ut())));
|
|
5673
5667
|
}
|
|
5674
5668
|
/**
|
|
5675
5669
|
* Runs the next operation from the retryable queue. If the operation fails,
|
|
5676
5670
|
* reschedules with backoff.
|
|
5677
5671
|
*/ async Ut() {
|
|
5678
|
-
if (0 !== this.
|
|
5672
|
+
if (0 !== this.Dt.length) {
|
|
5679
5673
|
try {
|
|
5680
|
-
await this.
|
|
5674
|
+
await this.Dt[0](), this.Dt.shift(), this.Tt.reset();
|
|
5681
5675
|
} catch (t) {
|
|
5682
5676
|
if (!
|
|
5683
5677
|
/**
|
|
@@ -5721,7 +5715,7 @@ class Sr {
|
|
|
5721
5715
|
// Failure will be handled by AsyncQueue
|
|
5722
5716
|
w("AsyncQueue", "Operation failed with retryable error: " + t);
|
|
5723
5717
|
}
|
|
5724
|
-
this.
|
|
5718
|
+
this.Dt.length > 0 &&
|
|
5725
5719
|
// If there are additional operations, we re-schedule `retryNextOp()`.
|
|
5726
5720
|
// This is necessary to run retryable operations that failed during
|
|
5727
5721
|
// their initial attempt since we don't know whether they are already
|
|
@@ -5732,25 +5726,22 @@ class Sr {
|
|
|
5732
5726
|
// Since `backoffAndRun()` cancels an existing backoff and schedules a
|
|
5733
5727
|
// new backoff on every call, there is only ever a single additional
|
|
5734
5728
|
// operation in the queue.
|
|
5735
|
-
this.
|
|
5729
|
+
this.Tt.G((() => this.Ut()));
|
|
5736
5730
|
}
|
|
5737
5731
|
}
|
|
5738
5732
|
Lt(t) {
|
|
5739
|
-
const
|
|
5733
|
+
const n = this.Vt.then((() => (this.St = !0, t().catch((t => {
|
|
5740
5734
|
this.Ft = t, this.St = !1;
|
|
5741
|
-
|
|
5742
|
-
// all further attempts to chain (via .then) will just short-circuit
|
|
5743
|
-
// and return the rejected Promise.
|
|
5744
|
-
throw m("INTERNAL UNHANDLED ERROR: ",
|
|
5735
|
+
const n =
|
|
5745
5736
|
/**
|
|
5746
5737
|
* Chrome includes Error.message in Error.stack. Other browsers do not.
|
|
5747
5738
|
* This returns expected output of message + stack when available.
|
|
5748
5739
|
* @param error - Error or FirestoreError
|
|
5749
5740
|
*/
|
|
5750
5741
|
function(t) {
|
|
5751
|
-
let
|
|
5752
|
-
t.stack && (
|
|
5753
|
-
return
|
|
5742
|
+
let n = t.message || "";
|
|
5743
|
+
t.stack && (n = t.stack.includes(t.message) ? t.stack : t.message + "\n" + t.stack);
|
|
5744
|
+
return n;
|
|
5754
5745
|
}
|
|
5755
5746
|
/**
|
|
5756
5747
|
* @license
|
|
@@ -5776,15 +5767,19 @@ class Sr {
|
|
|
5776
5767
|
* The `Transaction` object passed to a transaction's `updateFunction` provides
|
|
5777
5768
|
* the methods to read and write data within the transaction context. See
|
|
5778
5769
|
* {@link runTransaction}.
|
|
5779
|
-
*/ (t)
|
|
5770
|
+
*/ (t);
|
|
5771
|
+
// Re-throw the error so that this.tail becomes a rejected Promise and
|
|
5772
|
+
// all further attempts to chain (via .then) will just short-circuit
|
|
5773
|
+
// and return the rejected Promise.
|
|
5774
|
+
throw m("INTERNAL UNHANDLED ERROR: ", n), t;
|
|
5780
5775
|
})).then((t => (this.St = !1, t))))));
|
|
5781
|
-
return this.Vt =
|
|
5776
|
+
return this.Vt = n, n;
|
|
5782
5777
|
}
|
|
5783
|
-
enqueueAfterDelay(t,
|
|
5778
|
+
enqueueAfterDelay(t, n, e) {
|
|
5784
5779
|
this.Ct(),
|
|
5785
5780
|
// Fast-forward delays for timerIds that have been overriden.
|
|
5786
|
-
this.xt.indexOf(t) > -1 && (
|
|
5787
|
-
const r = xr.createAndSchedule(this, t,
|
|
5781
|
+
this.xt.indexOf(t) > -1 && (n = 0);
|
|
5782
|
+
const r = xr.createAndSchedule(this, t, n, e, (t => this.jt(t)));
|
|
5788
5783
|
return this.$t.push(r), r;
|
|
5789
5784
|
}
|
|
5790
5785
|
Ct() {
|
|
@@ -5807,8 +5802,8 @@ class Sr {
|
|
|
5807
5802
|
/**
|
|
5808
5803
|
* For Tests: Determine if a delayed operation with a particular TimerId
|
|
5809
5804
|
* exists.
|
|
5810
|
-
*/
|
|
5811
|
-
for (const
|
|
5805
|
+
*/ Bt(t) {
|
|
5806
|
+
for (const n of this.$t) if (n.timerId === t) return !0;
|
|
5812
5807
|
return !1;
|
|
5813
5808
|
}
|
|
5814
5809
|
/**
|
|
@@ -5817,12 +5812,12 @@ class Sr {
|
|
|
5817
5812
|
* @param lastTimerId - Delayed operations up to and including this TimerId
|
|
5818
5813
|
* will be drained. Pass TimerId.All to run all delayed operations.
|
|
5819
5814
|
* @returns a Promise that resolves once all operations have been run.
|
|
5820
|
-
*/
|
|
5815
|
+
*/ Mt(t) {
|
|
5821
5816
|
// Note that draining may generate more delayed ops, so we do that first.
|
|
5822
5817
|
return this.kt().then((() => {
|
|
5823
5818
|
// Run ops in the same order they'd run if they ran naturally.
|
|
5824
|
-
this.$t.sort(((t,
|
|
5825
|
-
for (const
|
|
5819
|
+
this.$t.sort(((t, n) => t.targetTimeMs - n.targetTimeMs));
|
|
5820
|
+
for (const n of this.$t) if (n.skipDelay(), "all" /* All */ !== t && n.timerId === t) break;
|
|
5826
5821
|
return this.kt();
|
|
5827
5822
|
}));
|
|
5828
5823
|
}
|
|
@@ -5833,15 +5828,15 @@ class Sr {
|
|
|
5833
5828
|
}
|
|
5834
5829
|
/** Called once a DelayedOperation is run or canceled. */ jt(t) {
|
|
5835
5830
|
// NOTE: indexOf / slice are O(n), but delayedOperations is expected to be small.
|
|
5836
|
-
const
|
|
5837
|
-
this.$t.splice(
|
|
5831
|
+
const n = this.$t.indexOf(t);
|
|
5832
|
+
this.$t.splice(n, 1);
|
|
5838
5833
|
}
|
|
5839
5834
|
}
|
|
5840
5835
|
|
|
5841
5836
|
class Cr {
|
|
5842
5837
|
/** @hideconstructor */
|
|
5843
|
-
constructor(t,
|
|
5844
|
-
this._firestore = t, this._transaction =
|
|
5838
|
+
constructor(t, n) {
|
|
5839
|
+
this._firestore = t, this._transaction = n, this._dataReader = Pe(t);
|
|
5845
5840
|
}
|
|
5846
5841
|
/**
|
|
5847
5842
|
* Reads the document referenced by the provided {@link DocumentReference}.
|
|
@@ -5849,25 +5844,25 @@ class Cr {
|
|
|
5849
5844
|
* @param documentRef - A reference to the document to be read.
|
|
5850
5845
|
* @returns A `DocumentSnapshot` with the read data.
|
|
5851
5846
|
*/ get(t) {
|
|
5852
|
-
const
|
|
5853
|
-
return this._transaction.lookup([
|
|
5847
|
+
const n = Nr(t, this._firestore), e = new yr(this._firestore);
|
|
5848
|
+
return this._transaction.lookup([ n._key ]).then((t => {
|
|
5854
5849
|
if (!t || 1 !== t.length) return _();
|
|
5855
5850
|
const r = t[0];
|
|
5856
|
-
if (r.isFoundDocument()) return new
|
|
5857
|
-
if (r.isNoDocument()) return new
|
|
5851
|
+
if (r.isFoundDocument()) return new Ge(this._firestore, e, r.key, r, n.converter);
|
|
5852
|
+
if (r.isNoDocument()) return new Ge(this._firestore, e, n._key, null, n.converter);
|
|
5858
5853
|
throw _();
|
|
5859
5854
|
}));
|
|
5860
5855
|
}
|
|
5861
|
-
set(t,
|
|
5862
|
-
const r =
|
|
5856
|
+
set(t, n, e) {
|
|
5857
|
+
const r = Nr(t, this._firestore), s = pr(r.converter, n, e), i = Re(this._dataReader, "Transaction.set", r._key, s, null !== r.converter, e);
|
|
5863
5858
|
return this._transaction.set(r._key, i), this;
|
|
5864
5859
|
}
|
|
5865
|
-
update(t,
|
|
5866
|
-
const s =
|
|
5860
|
+
update(t, n, e, ...r) {
|
|
5861
|
+
const s = Nr(t, this._firestore);
|
|
5867
5862
|
// For Compat types, we have to "extract" the underlying types before
|
|
5868
5863
|
// performing validation.
|
|
5869
5864
|
let i;
|
|
5870
|
-
return i = "string" == typeof (
|
|
5865
|
+
return i = "string" == typeof (n = getModularInstance(n)) || n instanceof me ? xe(this._dataReader, "Transaction.update", s._key, n, e, r) : qe(this._dataReader, "Transaction.update", s._key, n),
|
|
5871
5866
|
this._transaction.update(s._key, i), this;
|
|
5872
5867
|
}
|
|
5873
5868
|
/**
|
|
@@ -5876,8 +5871,8 @@ class Cr {
|
|
|
5876
5871
|
* @param documentRef - A reference to the document to be deleted.
|
|
5877
5872
|
* @returns This `Transaction` instance. Used for chaining method calls.
|
|
5878
5873
|
*/ delete(t) {
|
|
5879
|
-
const
|
|
5880
|
-
return this._transaction.delete(
|
|
5874
|
+
const n = Nr(t, this._firestore);
|
|
5875
|
+
return this._transaction.delete(n._key), this;
|
|
5881
5876
|
}
|
|
5882
5877
|
}
|
|
5883
5878
|
|
|
@@ -5897,9 +5892,9 @@ class Cr {
|
|
|
5897
5892
|
* (the `updateFunction` returned a failed promise), the promise returned by the
|
|
5898
5893
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
5899
5894
|
* rejected promise with the corresponding failure error is returned.
|
|
5900
|
-
*/ function Lr(t,
|
|
5901
|
-
const
|
|
5902
|
-
return new Sr(new Or,
|
|
5895
|
+
*/ function Lr(t, n) {
|
|
5896
|
+
const e = te(t = rt(t, ee)), r = new U;
|
|
5897
|
+
return new Sr(new Or, e, (e => n(new Cr(t, e))), r).run(), r.promise;
|
|
5903
5898
|
}
|
|
5904
5899
|
|
|
5905
5900
|
/**
|
|
@@ -5911,10 +5906,12 @@ class Cr {
|
|
|
5911
5906
|
* @packageDocumentation
|
|
5912
5907
|
*/ !function(t) {
|
|
5913
5908
|
l = t;
|
|
5914
|
-
}(`${
|
|
5915
|
-
const
|
|
5916
|
-
return
|
|
5917
|
-
}), "PUBLIC" /* PUBLIC */)),
|
|
5918
|
-
|
|
5919
|
-
|
|
5909
|
+
}(`${SDK_VERSION}_lite`), _registerComponent(new Component("firestore/lite", ((t, {options: n}) => {
|
|
5910
|
+
const e = t.getProvider("app").getImmediate(), r = new ee(e, new M(t.getProvider("auth-internal")));
|
|
5911
|
+
return n && r._setSettings(n), r;
|
|
5912
|
+
}), "PUBLIC" /* PUBLIC */)),
|
|
5913
|
+
// RUNTIME_ENV and BUILD_TARGET are replaced by real values during the compilation
|
|
5914
|
+
registerVersion("firestore-lite", "3.1.1-canary.4594d3fd6", ""), registerVersion("firestore-lite", "3.1.1-canary.4594d3fd6", "esm2017");
|
|
5915
|
+
|
|
5916
|
+
export { ye as Bytes, ae as CollectionReference, ue as DocumentReference, Ge as DocumentSnapshot, me as FieldPath, _e as FieldValue, ee as Firestore, L as FirestoreError, ge as GeoPoint, ce as Query, Je as QueryConstraint, We as QueryDocumentSnapshot, He as QuerySnapshot, pt as Timestamp, Cr as Transaction, Dr as WriteBatch, Tr as addDoc, Rr as arrayRemove, Pr as arrayUnion, he as collection, le as collectionGroup, ie as connectFirestoreEmulator, Er as deleteDoc, Ir as deleteField, fe as doc, pe as documentId, lr as endAt, hr as endBefore, _r as getDoc, gr as getDocs, se as getFirestore, Vr as increment, re as initializeFirestore, sr as limit, ir as limitToLast, er as orderBy, Ze as query, we as queryEqual, de as refEqual, Lr as runTransaction, Ar as serverTimestamp, br as setDoc, d as setLogLevel, Ye as snapshotEqual, cr as startAfter, ur as startAt, oe as terminate, vr as updateDoc, tr as where, $r as writeBatch };
|
|
5920
5917
|
//# sourceMappingURL=index.browser.esm2017.js.map
|