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