@firebase/firestore 3.4.1 → 3.4.2-202205224240
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 +13 -0
- package/dist/firestore/src/index/directional_index_byte_encoder.d.ts +24 -0
- package/dist/firestore/src/index/firestore_index_value_writer.d.ts +33 -0
- package/dist/firestore/src/index/index_byte_encoder.d.ts +14 -0
- package/dist/firestore/src/index/ordered_code_writer.d.ts +60 -0
- package/dist/firestore/src/lite-api/reference.d.ts +4 -2
- package/dist/firestore/src/lite-api/reference_impl.d.ts +5 -0
- package/dist/firestore/src/lite-api/transaction.d.ts +4 -0
- package/dist/firestore/src/lite-api/write_batch.d.ts +3 -0
- package/dist/firestore/src/local/indexeddb_remote_document_cache.d.ts +5 -0
- package/dist/firestore/src/model/collections.d.ts +0 -4
- package/dist/firestore/src/model/document.d.ts +3 -1
- package/dist/firestore/src/model/values.d.ts +3 -0
- package/dist/firestore/src/util/byte_string.d.ts +1 -0
- package/dist/firestore/src/util/error.d.ts +2 -3
- package/dist/firestore/test/unit/index/ordered_code_writer.test.d.ts +1 -0
- package/dist/firestore/test/util/helpers.d.ts +1 -0
- package/dist/index.d.ts +13 -21
- package/dist/index.esm2017.js +2649 -2640
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +2640 -2630
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +42 -24
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +43 -25
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +2839 -2830
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +18 -22
- package/dist/lite/firestore/src/index/directional_index_byte_encoder.d.ts +24 -0
- package/dist/lite/firestore/src/index/firestore_index_value_writer.d.ts +33 -0
- package/dist/lite/firestore/src/index/index_byte_encoder.d.ts +14 -0
- package/dist/lite/firestore/src/index/ordered_code_writer.d.ts +60 -0
- package/dist/lite/firestore/src/lite-api/reference.d.ts +4 -2
- package/dist/lite/firestore/src/lite-api/reference_impl.d.ts +5 -0
- package/dist/lite/firestore/src/lite-api/transaction.d.ts +4 -0
- package/dist/lite/firestore/src/lite-api/write_batch.d.ts +3 -0
- package/dist/lite/firestore/src/local/indexeddb_remote_document_cache.d.ts +5 -0
- package/dist/lite/firestore/src/model/collections.d.ts +0 -4
- package/dist/lite/firestore/src/model/document.d.ts +3 -1
- package/dist/lite/firestore/src/model/values.d.ts +3 -0
- package/dist/lite/firestore/src/util/byte_string.d.ts +1 -0
- package/dist/lite/firestore/src/util/error.d.ts +2 -3
- package/dist/lite/firestore/test/unit/index/ordered_code_writer.test.d.ts +1 -0
- package/dist/lite/firestore/test/util/helpers.d.ts +1 -0
- package/dist/lite/index.browser.esm2017.js +1378 -1365
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +842 -828
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.d.ts +18 -21
- package/dist/lite/index.node.cjs.js +25 -7
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +26 -8
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +849 -836
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +86 -21
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +142 -141
- package/dist/lite/packages/firestore/src/index/directional_index_byte_encoder.d.ts +24 -0
- package/dist/lite/packages/firestore/src/index/firestore_index_value_writer.d.ts +33 -0
- package/dist/lite/packages/firestore/src/index/index_byte_encoder.d.ts +14 -0
- package/dist/lite/packages/firestore/src/index/ordered_code_writer.d.ts +60 -0
- package/dist/lite/packages/firestore/src/lite-api/reference.d.ts +4 -2
- package/dist/lite/packages/firestore/src/lite-api/reference_impl.d.ts +5 -0
- package/dist/lite/packages/firestore/src/lite-api/transaction.d.ts +4 -0
- package/dist/lite/packages/firestore/src/lite-api/write_batch.d.ts +3 -0
- package/dist/lite/packages/firestore/src/local/indexeddb_remote_document_cache.d.ts +5 -0
- package/dist/lite/packages/firestore/src/model/collections.d.ts +0 -4
- package/dist/lite/packages/firestore/src/model/document.d.ts +3 -1
- package/dist/lite/packages/firestore/src/model/values.d.ts +3 -0
- package/dist/lite/packages/firestore/src/util/byte_string.d.ts +1 -0
- package/dist/lite/packages/firestore/src/util/error.d.ts +2 -3
- package/dist/lite/packages/firestore/test/unit/index/ordered_code_writer.test.d.ts +1 -0
- package/dist/lite/packages/firestore/test/util/helpers.d.ts +1 -0
- package/dist/lite/private.d.ts +85 -21
- package/dist/packages/firestore/dist/index.esm2017.d.ts +152 -152
- package/dist/packages/firestore/src/index/directional_index_byte_encoder.d.ts +24 -0
- package/dist/packages/firestore/src/index/firestore_index_value_writer.d.ts +33 -0
- package/dist/packages/firestore/src/index/index_byte_encoder.d.ts +14 -0
- package/dist/packages/firestore/src/index/ordered_code_writer.d.ts +60 -0
- package/dist/packages/firestore/src/lite-api/reference.d.ts +4 -2
- package/dist/packages/firestore/src/lite-api/reference_impl.d.ts +5 -0
- package/dist/packages/firestore/src/lite-api/transaction.d.ts +4 -0
- package/dist/packages/firestore/src/lite-api/write_batch.d.ts +3 -0
- package/dist/packages/firestore/src/local/indexeddb_remote_document_cache.d.ts +5 -0
- package/dist/packages/firestore/src/model/collections.d.ts +0 -4
- package/dist/packages/firestore/src/model/document.d.ts +3 -1
- package/dist/packages/firestore/src/model/values.d.ts +3 -0
- package/dist/packages/firestore/src/util/byte_string.d.ts +1 -0
- package/dist/packages/firestore/src/util/error.d.ts +2 -3
- package/dist/packages/firestore/test/unit/index/ordered_code_writer.test.d.ts +1 -0
- package/dist/packages/firestore/test/util/helpers.d.ts +1 -0
- package/dist/private.d.ts +17 -22
- package/package.json +7 -7
|
@@ -4,7 +4,7 @@ import { Component as i } from "@firebase/component";
|
|
|
4
4
|
|
|
5
5
|
import { Logger as o, LogLevel as u } from "@firebase/logger";
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { FirebaseError as c, base64 as a, createMockUserToken as h, getModularInstance as l } from "@firebase/util";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @license
|
|
@@ -26,7 +26,7 @@ import { base64 as c, createMockUserToken as a, getModularInstance as h } from "
|
|
|
26
26
|
* Simple wrapper around a nullable UID. Mostly exists to make code more
|
|
27
27
|
* readable.
|
|
28
28
|
*/
|
|
29
|
-
class
|
|
29
|
+
class f {
|
|
30
30
|
constructor(t) {
|
|
31
31
|
this.uid = t;
|
|
32
32
|
}
|
|
@@ -44,11 +44,11 @@ class l {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
/** A user with a null UID. */
|
|
47
|
+
/** A user with a null UID. */ f.UNAUTHENTICATED = new f(null),
|
|
48
48
|
// TODO(mikelehen): Look into getting a proper uid-equivalent for
|
|
49
49
|
// non-FirebaseAuth providers.
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
f.GOOGLE_CREDENTIALS = new f("google-credentials-uid"), f.FIRST_PARTY = new f("first-party-uid"),
|
|
51
|
+
f.MOCK_USER = new f("mock-user");
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* @license
|
|
@@ -66,7 +66,7 @@ l.MOCK_USER = new l("mock-user");
|
|
|
66
66
|
* See the License for the specific language governing permissions and
|
|
67
67
|
* limitations under the License.
|
|
68
68
|
*/
|
|
69
|
-
let
|
|
69
|
+
let d = "9.6.2-202205224240";
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* @license
|
|
@@ -84,7 +84,7 @@ let f = "9.6.1";
|
|
|
84
84
|
* See the License for the specific language governing permissions and
|
|
85
85
|
* limitations under the License.
|
|
86
86
|
*/
|
|
87
|
-
const
|
|
87
|
+
const w = new o("@firebase/firestore");
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
90
|
* Sets the verbosity of Cloud Firestore logs (debug, error, or silent).
|
|
@@ -98,36 +98,36 @@ const d = new o("@firebase/firestore");
|
|
|
98
98
|
* <li>`error` to log errors only.</li>
|
|
99
99
|
* <li><code>`silent` to turn off logging.</li>
|
|
100
100
|
* </ul>
|
|
101
|
-
*/ function
|
|
102
|
-
|
|
101
|
+
*/ function m(t) {
|
|
102
|
+
w.setLogLevel(t);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
function
|
|
106
|
-
if (
|
|
107
|
-
const e = n.map(
|
|
108
|
-
|
|
105
|
+
function p(t, ...n) {
|
|
106
|
+
if (w.logLevel <= u.DEBUG) {
|
|
107
|
+
const e = n.map(g);
|
|
108
|
+
w.debug(`Firestore (${d}): ${t}`, ...e);
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
function
|
|
113
|
-
if (
|
|
114
|
-
const e = n.map(
|
|
115
|
-
|
|
112
|
+
function y(t, ...n) {
|
|
113
|
+
if (w.logLevel <= u.ERROR) {
|
|
114
|
+
const e = n.map(g);
|
|
115
|
+
w.error(`Firestore (${d}): ${t}`, ...e);
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
120
|
* @internal
|
|
121
|
-
*/ function
|
|
122
|
-
if (
|
|
123
|
-
const e = n.map(
|
|
124
|
-
|
|
121
|
+
*/ function _(t, ...n) {
|
|
122
|
+
if (w.logLevel <= u.WARN) {
|
|
123
|
+
const e = n.map(g);
|
|
124
|
+
w.warn(`Firestore (${d}): ${t}`, ...e);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
/**
|
|
129
129
|
* Converts an additional log parameter to a string representation.
|
|
130
|
-
*/ function
|
|
130
|
+
*/ function g(t) {
|
|
131
131
|
if ("string" == typeof t) return t;
|
|
132
132
|
try {
|
|
133
133
|
return n = t, JSON.stringify(n);
|
|
@@ -178,14 +178,14 @@ function p(t, ...n) {
|
|
|
178
178
|
* Returns `never` and can be used in expressions:
|
|
179
179
|
* @example
|
|
180
180
|
* let futureVar = fail('not implemented yet');
|
|
181
|
-
*/ function
|
|
181
|
+
*/ function v(t = "Unexpected state") {
|
|
182
182
|
// Log the failure in addition to throw an exception, just in case the
|
|
183
183
|
// exception is swallowed.
|
|
184
|
-
const n = `FIRESTORE (${
|
|
184
|
+
const n = `FIRESTORE (${d}) INTERNAL ASSERTION FAILED: ` + t;
|
|
185
185
|
// NOTE: We don't use FirestoreError here because these are internal failures
|
|
186
186
|
// that cannot be handled by the user. (Also it would create a circular
|
|
187
187
|
// dependency between the error and assert modules which doesn't work.)
|
|
188
|
-
throw
|
|
188
|
+
throw y(n), new Error(n);
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
/**
|
|
@@ -193,14 +193,14 @@ function p(t, ...n) {
|
|
|
193
193
|
* given message if it did.
|
|
194
194
|
*
|
|
195
195
|
* Messages are stripped in production builds.
|
|
196
|
-
*/ function
|
|
197
|
-
t ||
|
|
196
|
+
*/ function b(t, n) {
|
|
197
|
+
t || v();
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
/**
|
|
201
201
|
* Casts `obj` to `T`. In non-production builds, verifies that `obj` is an
|
|
202
202
|
* instance of `T` before casting.
|
|
203
|
-
*/ function
|
|
203
|
+
*/ function E(t,
|
|
204
204
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
205
205
|
n) {
|
|
206
206
|
return t;
|
|
@@ -221,9 +221,9 @@ n) {
|
|
|
221
221
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
222
222
|
* See the License for the specific language governing permissions and
|
|
223
223
|
* limitations under the License.
|
|
224
|
-
*/ const
|
|
224
|
+
*/ const T = "ok", I = "cancelled", A = "unknown", P = "invalid-argument", R = "deadline-exceeded", V = "not-found", N = "already-exists", D = "permission-denied", $ = "unauthenticated", F = "resource-exhausted", S = "failed-precondition", x = "aborted", q = "out-of-range", O = "unimplemented", C = "internal", L = "unavailable", k = "data-loss";
|
|
225
225
|
|
|
226
|
-
/** An error returned by a Firestore operation. */ class
|
|
226
|
+
/** An error returned by a Firestore operation. */ class U extends c {
|
|
227
227
|
/** @hideconstructor */
|
|
228
228
|
constructor(
|
|
229
229
|
/**
|
|
@@ -234,9 +234,7 @@ n) {
|
|
|
234
234
|
* A custom error description.
|
|
235
235
|
*/
|
|
236
236
|
n) {
|
|
237
|
-
super(n), this.code = t, this.message = n,
|
|
238
|
-
/** The custom name for all FirestoreErrors. */
|
|
239
|
-
this.name = "FirebaseError",
|
|
237
|
+
super(t, n), this.code = t, this.message = n,
|
|
240
238
|
// HACK: We write a toString property directly because Error is not a real
|
|
241
239
|
// class and so inheritance does not work correctly. We could alternatively
|
|
242
240
|
// do the same "back-door inheritance" trick that FirebaseError does.
|
|
@@ -259,7 +257,7 @@ n) {
|
|
|
259
257
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
260
258
|
* See the License for the specific language governing permissions and
|
|
261
259
|
* limitations under the License.
|
|
262
|
-
*/ class
|
|
260
|
+
*/ class j {
|
|
263
261
|
constructor() {
|
|
264
262
|
this.promise = new Promise(((t, n) => {
|
|
265
263
|
this.resolve = t, this.reject = n;
|
|
@@ -282,7 +280,7 @@ n) {
|
|
|
282
280
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
283
281
|
* See the License for the specific language governing permissions and
|
|
284
282
|
* limitations under the License.
|
|
285
|
-
*/ class
|
|
283
|
+
*/ class M {
|
|
286
284
|
constructor(t, n) {
|
|
287
285
|
this.user = n, this.type = "OAuth", this.headers = new Map, this.headers.set("Authorization", `Bearer ${t}`);
|
|
288
286
|
}
|
|
@@ -291,14 +289,14 @@ n) {
|
|
|
291
289
|
/**
|
|
292
290
|
* A CredentialsProvider that always yields an empty token.
|
|
293
291
|
* @internal
|
|
294
|
-
*/ class
|
|
292
|
+
*/ class B {
|
|
295
293
|
getToken() {
|
|
296
294
|
return Promise.resolve(null);
|
|
297
295
|
}
|
|
298
296
|
invalidateToken() {}
|
|
299
297
|
start(t, n) {
|
|
300
298
|
// Fire with initial user.
|
|
301
|
-
t.enqueueRetryable((() => n(
|
|
299
|
+
t.enqueueRetryable((() => n(f.UNAUTHENTICATED)));
|
|
302
300
|
}
|
|
303
301
|
shutdown() {}
|
|
304
302
|
}
|
|
@@ -306,7 +304,7 @@ n) {
|
|
|
306
304
|
/**
|
|
307
305
|
* A CredentialsProvider that always returns a constant token. Used for
|
|
308
306
|
* emulator token mocking.
|
|
309
|
-
*/ class
|
|
307
|
+
*/ class z {
|
|
310
308
|
constructor(t) {
|
|
311
309
|
this.token = t,
|
|
312
310
|
/**
|
|
@@ -330,15 +328,15 @@ n) {
|
|
|
330
328
|
}
|
|
331
329
|
}
|
|
332
330
|
|
|
333
|
-
/** Credential provider for the Lite SDK. */ class
|
|
331
|
+
/** Credential provider for the Lite SDK. */ class Q {
|
|
334
332
|
constructor(t) {
|
|
335
333
|
this.auth = null, t.onInit((t => {
|
|
336
334
|
this.auth = t;
|
|
337
335
|
}));
|
|
338
336
|
}
|
|
339
337
|
getToken() {
|
|
340
|
-
return this.auth ? this.auth.getToken().then((t => t ? (
|
|
341
|
-
new
|
|
338
|
+
return this.auth ? this.auth.getToken().then((t => t ? (b("string" == typeof t.accessToken),
|
|
339
|
+
new M(t.accessToken, new f(this.auth.getUid()))) : null)) : Promise.resolve(null);
|
|
342
340
|
}
|
|
343
341
|
invalidateToken() {}
|
|
344
342
|
start(t, n) {}
|
|
@@ -351,9 +349,9 @@ n) {
|
|
|
351
349
|
* Technically this may no longer be necessary since the SDK should gracefully
|
|
352
350
|
* recover from unauthenticated errors (see b/33147818 for context), but it's
|
|
353
351
|
* safer to keep the implementation as-is.
|
|
354
|
-
*/ class
|
|
352
|
+
*/ class G {
|
|
355
353
|
constructor(t, n, e) {
|
|
356
|
-
this.type = "FirstParty", this.user =
|
|
354
|
+
this.type = "FirstParty", this.user = f.FIRST_PARTY, this.headers = new Map, this.headers.set("X-Goog-AuthUser", n);
|
|
357
355
|
const r = t.auth.getAuthHeaderValueForFirstParty([]);
|
|
358
356
|
r && this.headers.set("Authorization", r), e && this.headers.set("X-Goog-Iam-Authorization-Token", e);
|
|
359
357
|
}
|
|
@@ -363,36 +361,36 @@ n) {
|
|
|
363
361
|
* Provides user credentials required for the Firestore JavaScript SDK
|
|
364
362
|
* to authenticate the user, using technique that is only available
|
|
365
363
|
* to applications hosted by Google.
|
|
366
|
-
*/ class
|
|
364
|
+
*/ class W {
|
|
367
365
|
constructor(t, n, e) {
|
|
368
366
|
this.t = t, this.i = n, this.o = e;
|
|
369
367
|
}
|
|
370
368
|
getToken() {
|
|
371
|
-
return Promise.resolve(new
|
|
369
|
+
return Promise.resolve(new G(this.t, this.i, this.o));
|
|
372
370
|
}
|
|
373
371
|
start(t, n) {
|
|
374
372
|
// Fire with initial uid.
|
|
375
|
-
t.enqueueRetryable((() => n(
|
|
373
|
+
t.enqueueRetryable((() => n(f.FIRST_PARTY)));
|
|
376
374
|
}
|
|
377
375
|
shutdown() {}
|
|
378
376
|
invalidateToken() {}
|
|
379
377
|
}
|
|
380
378
|
|
|
381
|
-
class
|
|
379
|
+
class Y {
|
|
382
380
|
constructor(t) {
|
|
383
381
|
this.value = t, this.type = "AppCheck", this.headers = new Map, t && t.length > 0 && this.headers.set("x-firebase-appcheck", this.value);
|
|
384
382
|
}
|
|
385
383
|
}
|
|
386
384
|
|
|
387
|
-
/** AppCheck token provider for the Lite SDK. */ class
|
|
385
|
+
/** AppCheck token provider for the Lite SDK. */ class H {
|
|
388
386
|
constructor(t) {
|
|
389
387
|
this.u = t, this.appCheck = null, t.onInit((t => {
|
|
390
388
|
this.appCheck = t;
|
|
391
389
|
}));
|
|
392
390
|
}
|
|
393
391
|
getToken() {
|
|
394
|
-
return this.appCheck ? this.appCheck.getToken().then((t => t ? (
|
|
395
|
-
new
|
|
392
|
+
return this.appCheck ? this.appCheck.getToken().then((t => t ? (b("string" == typeof t.token),
|
|
393
|
+
new Y(t.token)) : null)) : Promise.resolve(null);
|
|
396
394
|
}
|
|
397
395
|
invalidateToken() {}
|
|
398
396
|
start(t, n) {}
|
|
@@ -419,7 +417,7 @@ class W {
|
|
|
419
417
|
* See the License for the specific language governing permissions and
|
|
420
418
|
* limitations under the License.
|
|
421
419
|
*/
|
|
422
|
-
class
|
|
420
|
+
class K {
|
|
423
421
|
/**
|
|
424
422
|
* Constructs a DatabaseInfo using the provided host, databaseId and
|
|
425
423
|
* persistenceKey.
|
|
@@ -448,7 +446,7 @@ class H {
|
|
|
448
446
|
* Represents the database ID a Firestore client is associated with.
|
|
449
447
|
* @internal
|
|
450
448
|
*/
|
|
451
|
-
class
|
|
449
|
+
class J {
|
|
452
450
|
constructor(t, n) {
|
|
453
451
|
this.projectId = t, this.database = n || "(default)";
|
|
454
452
|
}
|
|
@@ -456,7 +454,7 @@ class K {
|
|
|
456
454
|
return "(default)" === this.database;
|
|
457
455
|
}
|
|
458
456
|
isEqual(t) {
|
|
459
|
-
return t instanceof
|
|
457
|
+
return t instanceof J && t.projectId === this.projectId && t.database === this.database;
|
|
460
458
|
}
|
|
461
459
|
}
|
|
462
460
|
|
|
@@ -479,20 +477,20 @@ class K {
|
|
|
479
477
|
/**
|
|
480
478
|
* Path represents an ordered sequence of string segments.
|
|
481
479
|
*/
|
|
482
|
-
class
|
|
480
|
+
class X {
|
|
483
481
|
constructor(t, n, e) {
|
|
484
|
-
void 0 === n ? n = 0 : n > t.length &&
|
|
482
|
+
void 0 === n ? n = 0 : n > t.length && v(), void 0 === e ? e = t.length - n : e > t.length - n && v(),
|
|
485
483
|
this.segments = t, this.offset = n, this.len = e;
|
|
486
484
|
}
|
|
487
485
|
get length() {
|
|
488
486
|
return this.len;
|
|
489
487
|
}
|
|
490
488
|
isEqual(t) {
|
|
491
|
-
return 0 ===
|
|
489
|
+
return 0 === X.comparator(this, t);
|
|
492
490
|
}
|
|
493
491
|
child(t) {
|
|
494
492
|
const n = this.segments.slice(this.offset, this.limit());
|
|
495
|
-
return t instanceof
|
|
493
|
+
return t instanceof X ? t.forEach((t => {
|
|
496
494
|
n.push(t);
|
|
497
495
|
})) : n.push(t), this.construct(n);
|
|
498
496
|
}
|
|
@@ -549,9 +547,9 @@ class J {
|
|
|
549
547
|
* within Firestore.
|
|
550
548
|
*
|
|
551
549
|
* @internal
|
|
552
|
-
*/ class
|
|
550
|
+
*/ class Z extends X {
|
|
553
551
|
construct(t, n, e) {
|
|
554
|
-
return new
|
|
552
|
+
return new Z(t, n, e);
|
|
555
553
|
}
|
|
556
554
|
canonicalString() {
|
|
557
555
|
// NOTE: The client is ignorant of any path segments containing escape
|
|
@@ -572,35 +570,35 @@ class J {
|
|
|
572
570
|
// for legacy reasons and should not be used frequently).
|
|
573
571
|
const n = [];
|
|
574
572
|
for (const e of t) {
|
|
575
|
-
if (e.indexOf("//") >= 0) throw new
|
|
573
|
+
if (e.indexOf("//") >= 0) throw new U(P, `Invalid segment (${e}). Paths must not contain // in them.`);
|
|
576
574
|
// Strip leading and traling slashed.
|
|
577
575
|
n.push(...e.split("/").filter((t => t.length > 0)));
|
|
578
576
|
}
|
|
579
|
-
return new
|
|
577
|
+
return new Z(n);
|
|
580
578
|
}
|
|
581
579
|
static emptyPath() {
|
|
582
|
-
return new
|
|
580
|
+
return new Z([]);
|
|
583
581
|
}
|
|
584
582
|
}
|
|
585
583
|
|
|
586
|
-
const
|
|
584
|
+
const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
587
585
|
|
|
588
586
|
/**
|
|
589
587
|
* A dot-separated path for navigating sub-objects within a document.
|
|
590
588
|
* @internal
|
|
591
|
-
*/ class
|
|
589
|
+
*/ class nt extends X {
|
|
592
590
|
construct(t, n, e) {
|
|
593
|
-
return new
|
|
591
|
+
return new nt(t, n, e);
|
|
594
592
|
}
|
|
595
593
|
/**
|
|
596
594
|
* Returns true if the string could be used as a segment in a field path
|
|
597
595
|
* without escaping.
|
|
598
596
|
*/ static isValidIdentifier(t) {
|
|
599
|
-
return
|
|
597
|
+
return tt.test(t);
|
|
600
598
|
}
|
|
601
599
|
canonicalString() {
|
|
602
600
|
return this.toArray().map((t => (t = t.replace(/\\/g, "\\\\").replace(/`/g, "\\`"),
|
|
603
|
-
|
|
601
|
+
nt.isValidIdentifier(t) || (t = "`" + t + "`"), t))).join(".");
|
|
604
602
|
}
|
|
605
603
|
toString() {
|
|
606
604
|
return this.canonicalString();
|
|
@@ -613,7 +611,7 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
613
611
|
/**
|
|
614
612
|
* The field designating the key of a document.
|
|
615
613
|
*/ static keyField() {
|
|
616
|
-
return new
|
|
614
|
+
return new nt([ "__name__" ]);
|
|
617
615
|
}
|
|
618
616
|
/**
|
|
619
617
|
* Parses a field string from the given server-formatted string.
|
|
@@ -628,24 +626,24 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
628
626
|
const n = [];
|
|
629
627
|
let e = "", r = 0;
|
|
630
628
|
const s = () => {
|
|
631
|
-
if (0 === e.length) throw new
|
|
629
|
+
if (0 === e.length) throw new U(P, `Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);
|
|
632
630
|
n.push(e), e = "";
|
|
633
631
|
};
|
|
634
632
|
let i = !1;
|
|
635
633
|
for (;r < t.length; ) {
|
|
636
634
|
const n = t[r];
|
|
637
635
|
if ("\\" === n) {
|
|
638
|
-
if (r + 1 === t.length) throw new
|
|
636
|
+
if (r + 1 === t.length) throw new U(P, "Path has trailing escape character: " + t);
|
|
639
637
|
const n = t[r + 1];
|
|
640
|
-
if ("\\" !== n && "." !== n && "`" !== n) throw new
|
|
638
|
+
if ("\\" !== n && "." !== n && "`" !== n) throw new U(P, "Path has invalid escape sequence: " + t);
|
|
641
639
|
e += n, r += 2;
|
|
642
640
|
} else "`" === n ? (i = !i, r++) : "." !== n || i ? (e += n, r++) : (s(), r++);
|
|
643
641
|
}
|
|
644
|
-
if (s(), i) throw new
|
|
645
|
-
return new
|
|
642
|
+
if (s(), i) throw new U(P, "Unterminated ` in path: " + t);
|
|
643
|
+
return new nt(n);
|
|
646
644
|
}
|
|
647
645
|
static emptyPath() {
|
|
648
|
-
return new
|
|
646
|
+
return new nt([]);
|
|
649
647
|
}
|
|
650
648
|
}
|
|
651
649
|
|
|
@@ -667,27 +665,27 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
667
665
|
*/
|
|
668
666
|
/**
|
|
669
667
|
* @internal
|
|
670
|
-
*/ class
|
|
668
|
+
*/ class et {
|
|
671
669
|
constructor(t) {
|
|
672
670
|
this.path = t;
|
|
673
671
|
}
|
|
674
672
|
static fromPath(t) {
|
|
675
|
-
return new
|
|
673
|
+
return new et(Z.fromString(t));
|
|
676
674
|
}
|
|
677
675
|
static fromName(t) {
|
|
678
|
-
return new
|
|
676
|
+
return new et(Z.fromString(t).popFirst(5));
|
|
679
677
|
}
|
|
680
678
|
/** Returns true if the document is in the specified collectionId. */ hasCollectionId(t) {
|
|
681
679
|
return this.path.length >= 2 && this.path.get(this.path.length - 2) === t;
|
|
682
680
|
}
|
|
683
681
|
isEqual(t) {
|
|
684
|
-
return null !== t && 0 ===
|
|
682
|
+
return null !== t && 0 === Z.comparator(this.path, t.path);
|
|
685
683
|
}
|
|
686
684
|
toString() {
|
|
687
685
|
return this.path.toString();
|
|
688
686
|
}
|
|
689
687
|
static comparator(t, n) {
|
|
690
|
-
return
|
|
688
|
+
return Z.comparator(t.path, n.path);
|
|
691
689
|
}
|
|
692
690
|
static isDocumentKey(t) {
|
|
693
691
|
return t.length % 2 == 0;
|
|
@@ -698,7 +696,7 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
698
696
|
* @param segments - The segments of the path to the document
|
|
699
697
|
* @returns A new instance of DocumentKey
|
|
700
698
|
*/ static fromSegments(t) {
|
|
701
|
-
return new
|
|
699
|
+
return new et(new Z(t.slice()));
|
|
702
700
|
}
|
|
703
701
|
}
|
|
704
702
|
|
|
@@ -717,8 +715,8 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
717
715
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
718
716
|
* See the License for the specific language governing permissions and
|
|
719
717
|
* limitations under the License.
|
|
720
|
-
*/ function
|
|
721
|
-
if (!e) throw new
|
|
718
|
+
*/ function rt(t, n, e) {
|
|
719
|
+
if (!e) throw new U(P, `Function ${t}() cannot be called with an empty ${n}.`);
|
|
722
720
|
}
|
|
723
721
|
|
|
724
722
|
/**
|
|
@@ -729,15 +727,15 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
729
727
|
* Validates that `path` refers to a document (indicated by the fact it contains
|
|
730
728
|
* an even numbers of segments).
|
|
731
729
|
*/
|
|
732
|
-
function
|
|
733
|
-
if (!
|
|
730
|
+
function st(t) {
|
|
731
|
+
if (!et.isDocumentKey(t)) throw new U(P, `Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`);
|
|
734
732
|
}
|
|
735
733
|
|
|
736
734
|
/**
|
|
737
735
|
* Validates that `path` refers to a collection (indicated by the fact it
|
|
738
736
|
* contains an odd numbers of segments).
|
|
739
|
-
*/ function
|
|
740
|
-
if (
|
|
737
|
+
*/ function it(t) {
|
|
738
|
+
if (et.isDocumentKey(t)) throw new U(P, `Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`);
|
|
741
739
|
}
|
|
742
740
|
|
|
743
741
|
/**
|
|
@@ -745,7 +743,7 @@ function rt(t) {
|
|
|
745
743
|
* (i.e. excludes Array, Date, etc.).
|
|
746
744
|
*/
|
|
747
745
|
/** Returns a string describing the type / value of the provided input. */
|
|
748
|
-
function
|
|
746
|
+
function ot(t) {
|
|
749
747
|
if (void 0 === t) return "undefined";
|
|
750
748
|
if (null === t) return "null";
|
|
751
749
|
if ("string" == typeof t) return t.length > 20 && (t = `${t.substring(0, 20)}...`),
|
|
@@ -771,27 +769,27 @@ function it(t) {
|
|
|
771
769
|
return n ? `a custom ${n} object` : "an object";
|
|
772
770
|
}
|
|
773
771
|
}
|
|
774
|
-
return "function" == typeof t ? "a function" :
|
|
772
|
+
return "function" == typeof t ? "a function" : v();
|
|
775
773
|
}
|
|
776
774
|
|
|
777
|
-
function
|
|
775
|
+
function ut(t,
|
|
778
776
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
779
777
|
n) {
|
|
780
778
|
if ("_delegate" in t && (
|
|
781
779
|
// Unwrap Compat types
|
|
782
780
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
783
781
|
t = t._delegate), !(t instanceof n)) {
|
|
784
|
-
if (n.name === t.constructor.name) throw new
|
|
782
|
+
if (n.name === t.constructor.name) throw new U(P, "Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");
|
|
785
783
|
{
|
|
786
|
-
const e =
|
|
787
|
-
throw new
|
|
784
|
+
const e = ot(t);
|
|
785
|
+
throw new U(P, `Expected type '${n.name}', but it was: ${e}`);
|
|
788
786
|
}
|
|
789
787
|
}
|
|
790
788
|
return t;
|
|
791
789
|
}
|
|
792
790
|
|
|
793
|
-
function
|
|
794
|
-
if (n <= 0) throw new
|
|
791
|
+
function ct(t, n) {
|
|
792
|
+
if (n <= 0) throw new U(P, `Function ${t}() requires a positive number, but it was: ${n}.`);
|
|
795
793
|
}
|
|
796
794
|
|
|
797
795
|
/**
|
|
@@ -812,11 +810,11 @@ function ut(t, n) {
|
|
|
812
810
|
*/
|
|
813
811
|
/**
|
|
814
812
|
* Returns whether a variable is either undefined or null.
|
|
815
|
-
*/ function
|
|
813
|
+
*/ function at(t) {
|
|
816
814
|
return null == t;
|
|
817
815
|
}
|
|
818
816
|
|
|
819
|
-
/** Returns whether the value represents -0. */ function
|
|
817
|
+
/** Returns whether the value represents -0. */ function ht(t) {
|
|
820
818
|
// Detect if the value is -0.0. Based on polyfill from
|
|
821
819
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
822
820
|
return 0 === t && 1 / t == -1 / 0;
|
|
@@ -842,7 +840,7 @@ function ut(t, n) {
|
|
|
842
840
|
* See the License for the specific language governing permissions and
|
|
843
841
|
* limitations under the License.
|
|
844
842
|
*/
|
|
845
|
-
const
|
|
843
|
+
const lt = {
|
|
846
844
|
BatchGetDocuments: "batchGet",
|
|
847
845
|
Commit: "commit",
|
|
848
846
|
RunQuery: "runQuery"
|
|
@@ -879,7 +877,7 @@ const ht = {
|
|
|
879
877
|
* are used for reverse lookups from the webchannel stream. Do NOT change the
|
|
880
878
|
* names of these identifiers or change this into a const enum.
|
|
881
879
|
*/
|
|
882
|
-
var
|
|
880
|
+
var ft, dt;
|
|
883
881
|
|
|
884
882
|
/**
|
|
885
883
|
* Converts an HTTP Status Code to the equivalent error code.
|
|
@@ -888,8 +886,8 @@ var lt, ft;
|
|
|
888
886
|
* @returns The equivalent Code. Unknown status codes are mapped to
|
|
889
887
|
* Code.UNKNOWN.
|
|
890
888
|
*/
|
|
891
|
-
function
|
|
892
|
-
if (void 0 === t) return
|
|
889
|
+
function wt(t) {
|
|
890
|
+
if (void 0 === t) return y("RPC_ERROR", "HTTP error has no status"), A;
|
|
893
891
|
// The canonical error codes for Google APIs [1] specify mapping onto HTTP
|
|
894
892
|
// status codes but the mapping is not bijective. In each case of ambiguity
|
|
895
893
|
// this function chooses a primary error.
|
|
@@ -899,30 +897,30 @@ function dt(t) {
|
|
|
899
897
|
switch (t) {
|
|
900
898
|
case 200:
|
|
901
899
|
// OK
|
|
902
|
-
return
|
|
900
|
+
return T;
|
|
903
901
|
|
|
904
902
|
case 400:
|
|
905
903
|
// Bad Request
|
|
906
|
-
return
|
|
904
|
+
return S;
|
|
907
905
|
|
|
908
906
|
// Other possibilities based on the forward mapping
|
|
909
907
|
// return Code.INVALID_ARGUMENT;
|
|
910
908
|
// return Code.OUT_OF_RANGE;
|
|
911
909
|
case 401:
|
|
912
910
|
// Unauthorized
|
|
913
|
-
return
|
|
911
|
+
return $;
|
|
914
912
|
|
|
915
913
|
case 403:
|
|
916
914
|
// Forbidden
|
|
917
|
-
return
|
|
915
|
+
return D;
|
|
918
916
|
|
|
919
917
|
case 404:
|
|
920
918
|
// Not Found
|
|
921
|
-
return
|
|
919
|
+
return V;
|
|
922
920
|
|
|
923
921
|
case 409:
|
|
924
922
|
// Conflict
|
|
925
|
-
return
|
|
923
|
+
return x;
|
|
926
924
|
|
|
927
925
|
// Other possibilities:
|
|
928
926
|
// return Code.ALREADY_EXISTS;
|
|
@@ -932,33 +930,33 @@ function dt(t) {
|
|
|
932
930
|
|
|
933
931
|
case 429:
|
|
934
932
|
// Too Many Requests
|
|
935
|
-
return
|
|
933
|
+
return F;
|
|
936
934
|
|
|
937
935
|
case 499:
|
|
938
936
|
// Client Closed Request
|
|
939
|
-
return
|
|
937
|
+
return I;
|
|
940
938
|
|
|
941
939
|
case 500:
|
|
942
940
|
// Internal Server Error
|
|
943
|
-
return
|
|
941
|
+
return A;
|
|
944
942
|
|
|
945
943
|
// Other possibilities:
|
|
946
944
|
// return Code.INTERNAL;
|
|
947
945
|
// return Code.DATA_LOSS;
|
|
948
946
|
case 501:
|
|
949
947
|
// Unimplemented
|
|
950
|
-
return
|
|
948
|
+
return O;
|
|
951
949
|
|
|
952
950
|
case 503:
|
|
953
951
|
// Service Unavailable
|
|
954
|
-
return
|
|
952
|
+
return L;
|
|
955
953
|
|
|
956
954
|
case 504:
|
|
957
955
|
// Gateway Timeout
|
|
958
|
-
return
|
|
956
|
+
return R;
|
|
959
957
|
|
|
960
958
|
default:
|
|
961
|
-
return t >= 200 && t < 300 ?
|
|
959
|
+
return t >= 200 && t < 300 ? T : t >= 400 && t < 500 ? S : t >= 500 && t < 600 ? C : A;
|
|
962
960
|
}
|
|
963
961
|
}
|
|
964
962
|
|
|
@@ -981,16 +979,16 @@ function dt(t) {
|
|
|
981
979
|
/**
|
|
982
980
|
* A Rest-based connection that relies on the native HTTP stack
|
|
983
981
|
* (e.g. `fetch` or a polyfill).
|
|
984
|
-
*/ (
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
982
|
+
*/ (dt = ft || (ft = {}))[dt.OK = 0] = "OK", dt[dt.CANCELLED = 1] = "CANCELLED",
|
|
983
|
+
dt[dt.UNKNOWN = 2] = "UNKNOWN", dt[dt.INVALID_ARGUMENT = 3] = "INVALID_ARGUMENT",
|
|
984
|
+
dt[dt.DEADLINE_EXCEEDED = 4] = "DEADLINE_EXCEEDED", dt[dt.NOT_FOUND = 5] = "NOT_FOUND",
|
|
985
|
+
dt[dt.ALREADY_EXISTS = 6] = "ALREADY_EXISTS", dt[dt.PERMISSION_DENIED = 7] = "PERMISSION_DENIED",
|
|
986
|
+
dt[dt.UNAUTHENTICATED = 16] = "UNAUTHENTICATED", dt[dt.RESOURCE_EXHAUSTED = 8] = "RESOURCE_EXHAUSTED",
|
|
987
|
+
dt[dt.FAILED_PRECONDITION = 9] = "FAILED_PRECONDITION", dt[dt.ABORTED = 10] = "ABORTED",
|
|
988
|
+
dt[dt.OUT_OF_RANGE = 11] = "OUT_OF_RANGE", dt[dt.UNIMPLEMENTED = 12] = "UNIMPLEMENTED",
|
|
989
|
+
dt[dt.INTERNAL = 13] = "INTERNAL", dt[dt.UNAVAILABLE = 14] = "UNAVAILABLE", dt[dt.DATA_LOSS = 15] = "DATA_LOSS";
|
|
992
990
|
|
|
993
|
-
class
|
|
991
|
+
class mt extends
|
|
994
992
|
/**
|
|
995
993
|
* Base class for all Rest-based connections to the backend (WebChannel and
|
|
996
994
|
* HTTP).
|
|
@@ -1003,11 +1001,11 @@ class {
|
|
|
1003
1001
|
}
|
|
1004
1002
|
m(t, n, e, r, s) {
|
|
1005
1003
|
const i = this.p(t, n);
|
|
1006
|
-
|
|
1004
|
+
p("RestConnection", "Sending: ", i, e);
|
|
1007
1005
|
const o = {};
|
|
1008
|
-
return this.g(o, r, s), this.v(t, i, o, e).then((t => (
|
|
1006
|
+
return this.g(o, r, s), this.v(t, i, o, e).then((t => (p("RestConnection", "Received: ", t),
|
|
1009
1007
|
t)), (n => {
|
|
1010
|
-
throw
|
|
1008
|
+
throw _("RestConnection", `${t} failed with error: `, n, "url: ", i, "request:", e),
|
|
1011
1009
|
n;
|
|
1012
1010
|
}));
|
|
1013
1011
|
}
|
|
@@ -1020,7 +1018,7 @@ class {
|
|
|
1020
1018
|
* Modifies the headers for a request, adding any authorization token if
|
|
1021
1019
|
* present and any additional headers for the request.
|
|
1022
1020
|
*/ g(t, n, e) {
|
|
1023
|
-
t["X-Goog-Api-Client"] = "gl-js/ fire/" +
|
|
1021
|
+
t["X-Goog-Api-Client"] = "gl-js/ fire/" + d,
|
|
1024
1022
|
// Content-Type: text/plain will avoid preflight requests which might
|
|
1025
1023
|
// mess with CORS and redirects by proxies. If we add custom headers
|
|
1026
1024
|
// we will need to change this code to potentially use the $httpOverwrite
|
|
@@ -1029,7 +1027,7 @@ class {
|
|
|
1029
1027
|
n && n.headers.forEach(((n, e) => t[e] = n)), e && e.headers.forEach(((n, e) => t[e] = n));
|
|
1030
1028
|
}
|
|
1031
1029
|
p(t, n) {
|
|
1032
|
-
const e =
|
|
1030
|
+
const e = lt[t];
|
|
1033
1031
|
return `${this.h}/v1/${n}:${e}`;
|
|
1034
1032
|
}
|
|
1035
1033
|
} {
|
|
@@ -1053,9 +1051,9 @@ class {
|
|
|
1053
1051
|
body: s
|
|
1054
1052
|
});
|
|
1055
1053
|
} catch (t) {
|
|
1056
|
-
throw new
|
|
1054
|
+
throw new U(wt(t.status), "Request failed with error: " + t.statusText);
|
|
1057
1055
|
}
|
|
1058
|
-
if (!i.ok) throw new
|
|
1056
|
+
if (!i.ok) throw new U(wt(i.status), "Request failed with error: " + i.statusText);
|
|
1059
1057
|
return i.json();
|
|
1060
1058
|
}
|
|
1061
1059
|
}
|
|
@@ -1098,7 +1096,7 @@ class {
|
|
|
1098
1096
|
*
|
|
1099
1097
|
* If `nBytes < 0` , an error will be thrown.
|
|
1100
1098
|
*/
|
|
1101
|
-
function
|
|
1099
|
+
function pt(t) {
|
|
1102
1100
|
// Polyfills for IE and WebWorker by using `self` and `msCrypto` when `crypto` is not available.
|
|
1103
1101
|
const n =
|
|
1104
1102
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1124,14 +1122,14 @@ function mt(t) {
|
|
|
1124
1122
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1125
1123
|
* See the License for the specific language governing permissions and
|
|
1126
1124
|
* limitations under the License.
|
|
1127
|
-
*/ class
|
|
1125
|
+
*/ class yt {
|
|
1128
1126
|
static P() {
|
|
1129
1127
|
// Alphanumeric characters
|
|
1130
1128
|
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", n = Math.floor(256 / t.length) * t.length;
|
|
1131
1129
|
// The largest byte value that is a multiple of `char.length`.
|
|
1132
1130
|
let e = "";
|
|
1133
1131
|
for (;e.length < 20; ) {
|
|
1134
|
-
const r =
|
|
1132
|
+
const r = pt(40);
|
|
1135
1133
|
for (let s = 0; s < r.length; ++s)
|
|
1136
1134
|
// Only accept values that are [0, maxMultiple), this ensures they can
|
|
1137
1135
|
// be evenly mapped to indices of `chars` via a modulo operation.
|
|
@@ -1141,11 +1139,11 @@ function mt(t) {
|
|
|
1141
1139
|
}
|
|
1142
1140
|
}
|
|
1143
1141
|
|
|
1144
|
-
function
|
|
1142
|
+
function _t(t, n) {
|
|
1145
1143
|
return t < n ? -1 : t > n ? 1 : 0;
|
|
1146
1144
|
}
|
|
1147
1145
|
|
|
1148
|
-
/** Helper to compare arrays using isEqual(). */ function
|
|
1146
|
+
/** Helper to compare arrays using isEqual(). */ function gt(t, n, e) {
|
|
1149
1147
|
return t.length === n.length && t.every(((t, r) => e(t, n[r])));
|
|
1150
1148
|
}
|
|
1151
1149
|
|
|
@@ -1180,7 +1178,7 @@ function yt(t, n) {
|
|
|
1180
1178
|
* For examples and further specifications, refer to the
|
|
1181
1179
|
* {@link https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto | Timestamp definition}.
|
|
1182
1180
|
*/
|
|
1183
|
-
class
|
|
1181
|
+
class vt {
|
|
1184
1182
|
/**
|
|
1185
1183
|
* Creates a new timestamp.
|
|
1186
1184
|
*
|
|
@@ -1201,18 +1199,18 @@ class gt {
|
|
|
1201
1199
|
* The fractions of a second at nanosecond resolution.*
|
|
1202
1200
|
*/
|
|
1203
1201
|
n) {
|
|
1204
|
-
if (this.seconds = t, this.nanoseconds = n, n < 0) throw new
|
|
1205
|
-
if (n >= 1e9) throw new
|
|
1206
|
-
if (t < -62135596800) throw new
|
|
1202
|
+
if (this.seconds = t, this.nanoseconds = n, n < 0) throw new U(P, "Timestamp nanoseconds out of range: " + n);
|
|
1203
|
+
if (n >= 1e9) throw new U(P, "Timestamp nanoseconds out of range: " + n);
|
|
1204
|
+
if (t < -62135596800) throw new U(P, "Timestamp seconds out of range: " + t);
|
|
1207
1205
|
// This will break in the year 10,000.
|
|
1208
|
-
if (t >= 253402300800) throw new
|
|
1206
|
+
if (t >= 253402300800) throw new U(P, "Timestamp seconds out of range: " + t);
|
|
1209
1207
|
}
|
|
1210
1208
|
/**
|
|
1211
1209
|
* Creates a new timestamp with the current date, with millisecond precision.
|
|
1212
1210
|
*
|
|
1213
1211
|
* @returns a new timestamp representing the current date.
|
|
1214
1212
|
*/ static now() {
|
|
1215
|
-
return
|
|
1213
|
+
return vt.fromMillis(Date.now());
|
|
1216
1214
|
}
|
|
1217
1215
|
/**
|
|
1218
1216
|
* Creates a new timestamp from the given date.
|
|
@@ -1221,7 +1219,7 @@ class gt {
|
|
|
1221
1219
|
* @returns A new `Timestamp` representing the same point in time as the given
|
|
1222
1220
|
* date.
|
|
1223
1221
|
*/ static fromDate(t) {
|
|
1224
|
-
return
|
|
1222
|
+
return vt.fromMillis(t.getTime());
|
|
1225
1223
|
}
|
|
1226
1224
|
/**
|
|
1227
1225
|
* Creates a new timestamp from the given number of milliseconds.
|
|
@@ -1232,7 +1230,7 @@ class gt {
|
|
|
1232
1230
|
* number of milliseconds.
|
|
1233
1231
|
*/ static fromMillis(t) {
|
|
1234
1232
|
const n = Math.floor(t / 1e3), e = Math.floor(1e6 * (t - 1e3 * n));
|
|
1235
|
-
return new
|
|
1233
|
+
return new vt(n, e);
|
|
1236
1234
|
}
|
|
1237
1235
|
/**
|
|
1238
1236
|
* Converts a `Timestamp` to a JavaScript `Date` object. This conversion
|
|
@@ -1254,7 +1252,7 @@ class gt {
|
|
|
1254
1252
|
return 1e3 * this.seconds + this.nanoseconds / 1e6;
|
|
1255
1253
|
}
|
|
1256
1254
|
_compareTo(t) {
|
|
1257
|
-
return this.seconds === t.seconds ?
|
|
1255
|
+
return this.seconds === t.seconds ? _t(this.nanoseconds, t.nanoseconds) : _t(this.seconds, t.seconds);
|
|
1258
1256
|
}
|
|
1259
1257
|
/**
|
|
1260
1258
|
* Returns true if this `Timestamp` is equal to the provided one.
|
|
@@ -1310,15 +1308,15 @@ class gt {
|
|
|
1310
1308
|
/**
|
|
1311
1309
|
* A version of a document in Firestore. This corresponds to the version
|
|
1312
1310
|
* timestamp, such as update_time or read_time.
|
|
1313
|
-
*/ class
|
|
1311
|
+
*/ class bt {
|
|
1314
1312
|
constructor(t) {
|
|
1315
1313
|
this.timestamp = t;
|
|
1316
1314
|
}
|
|
1317
1315
|
static fromTimestamp(t) {
|
|
1318
|
-
return new
|
|
1316
|
+
return new bt(t);
|
|
1319
1317
|
}
|
|
1320
1318
|
static min() {
|
|
1321
|
-
return new
|
|
1319
|
+
return new bt(new vt(0, 0));
|
|
1322
1320
|
}
|
|
1323
1321
|
compareTo(t) {
|
|
1324
1322
|
return this.timestamp._compareTo(t.timestamp);
|
|
@@ -1353,13 +1351,13 @@ class gt {
|
|
|
1353
1351
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1354
1352
|
* See the License for the specific language governing permissions and
|
|
1355
1353
|
* limitations under the License.
|
|
1356
|
-
*/ function
|
|
1354
|
+
*/ function Et(t) {
|
|
1357
1355
|
let n = 0;
|
|
1358
1356
|
for (const e in t) Object.prototype.hasOwnProperty.call(t, e) && n++;
|
|
1359
1357
|
return n;
|
|
1360
1358
|
}
|
|
1361
1359
|
|
|
1362
|
-
function
|
|
1360
|
+
function Tt(t, n) {
|
|
1363
1361
|
for (const e in t) Object.prototype.hasOwnProperty.call(t, e) && n(e, t[e]);
|
|
1364
1362
|
}
|
|
1365
1363
|
|
|
@@ -1389,12 +1387,12 @@ function Et(t, n) {
|
|
|
1389
1387
|
* If foo is not an object, foo is replaced with an object
|
|
1390
1388
|
* containing foo
|
|
1391
1389
|
*/
|
|
1392
|
-
class
|
|
1390
|
+
class It {
|
|
1393
1391
|
constructor(t) {
|
|
1394
1392
|
this.fields = t,
|
|
1395
1393
|
// TODO(dimond): validation of FieldMask
|
|
1396
1394
|
// Sort the field mask to support `FieldMask.isEqual()` and assert below.
|
|
1397
|
-
t.sort(
|
|
1395
|
+
t.sort(nt.comparator);
|
|
1398
1396
|
}
|
|
1399
1397
|
/**
|
|
1400
1398
|
* Verifies that `fieldPath` is included by at least one field in this field
|
|
@@ -1406,7 +1404,7 @@ class Tt {
|
|
|
1406
1404
|
return !1;
|
|
1407
1405
|
}
|
|
1408
1406
|
isEqual(t) {
|
|
1409
|
-
return
|
|
1407
|
+
return gt(this.fields, t.fields, ((t, n) => t.isEqual(n)));
|
|
1410
1408
|
}
|
|
1411
1409
|
}
|
|
1412
1410
|
|
|
@@ -1429,12 +1427,12 @@ class Tt {
|
|
|
1429
1427
|
// WebSafe uses a different URL-encoding safe alphabet that doesn't match
|
|
1430
1428
|
// the encoding used on the backend.
|
|
1431
1429
|
/** Converts a Base64 encoded string to a binary string. */
|
|
1432
|
-
function
|
|
1430
|
+
function At(t) {
|
|
1433
1431
|
return String.fromCharCode.apply(null,
|
|
1434
1432
|
// We use `decodeStringToByteArray()` instead of `decodeString()` since
|
|
1435
1433
|
// `decodeString()` returns Unicode strings, which doesn't match the values
|
|
1436
1434
|
// returned by `atob()`'s Latin1 representation.
|
|
1437
|
-
|
|
1435
|
+
a.decodeStringToByteArray(t, false));
|
|
1438
1436
|
}
|
|
1439
1437
|
|
|
1440
1438
|
/** Converts a binary string to a Base64 encoded string. */
|
|
@@ -1463,13 +1461,13 @@ function It(t) {
|
|
|
1463
1461
|
* before being sent as a proto.
|
|
1464
1462
|
* @internal
|
|
1465
1463
|
*/
|
|
1466
|
-
class
|
|
1464
|
+
class Pt {
|
|
1467
1465
|
constructor(t) {
|
|
1468
1466
|
this.binaryString = t;
|
|
1469
1467
|
}
|
|
1470
1468
|
static fromBase64String(t) {
|
|
1471
|
-
const n =
|
|
1472
|
-
return new
|
|
1469
|
+
const n = At(t);
|
|
1470
|
+
return new Pt(n);
|
|
1473
1471
|
}
|
|
1474
1472
|
static fromUint8Array(t) {
|
|
1475
1473
|
const n =
|
|
@@ -1484,13 +1482,25 @@ class At {
|
|
|
1484
1482
|
/**
|
|
1485
1483
|
* Helper function to convert a binary string to an Uint8Array.
|
|
1486
1484
|
*/ (t);
|
|
1487
|
-
return new
|
|
1485
|
+
return new Pt(n);
|
|
1486
|
+
}
|
|
1487
|
+
[Symbol.iterator]() {
|
|
1488
|
+
let t = 0;
|
|
1489
|
+
return {
|
|
1490
|
+
next: () => t < this.binaryString.length ? {
|
|
1491
|
+
value: this.binaryString.charCodeAt(t++),
|
|
1492
|
+
done: !1
|
|
1493
|
+
} : {
|
|
1494
|
+
value: void 0,
|
|
1495
|
+
done: !0
|
|
1496
|
+
}
|
|
1497
|
+
};
|
|
1488
1498
|
}
|
|
1489
1499
|
toBase64() {
|
|
1490
1500
|
return function(t) {
|
|
1491
1501
|
const n = [];
|
|
1492
1502
|
for (let e = 0; e < t.length; e++) n[e] = t.charCodeAt(e);
|
|
1493
|
-
return
|
|
1503
|
+
return a.encodeByteArray(n, !1);
|
|
1494
1504
|
}(this.binaryString);
|
|
1495
1505
|
}
|
|
1496
1506
|
toUint8Array() {
|
|
@@ -1522,31 +1532,31 @@ class At {
|
|
|
1522
1532
|
return 2 * this.binaryString.length;
|
|
1523
1533
|
}
|
|
1524
1534
|
compareTo(t) {
|
|
1525
|
-
return
|
|
1535
|
+
return _t(this.binaryString, t.binaryString);
|
|
1526
1536
|
}
|
|
1527
1537
|
isEqual(t) {
|
|
1528
1538
|
return this.binaryString === t.binaryString;
|
|
1529
1539
|
}
|
|
1530
1540
|
}
|
|
1531
1541
|
|
|
1532
|
-
|
|
1542
|
+
Pt.EMPTY_BYTE_STRING = new Pt("");
|
|
1533
1543
|
|
|
1534
|
-
const
|
|
1544
|
+
const Rt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
1535
1545
|
|
|
1536
1546
|
/**
|
|
1537
1547
|
* Converts the possible Proto values for a timestamp value into a "seconds and
|
|
1538
1548
|
* nanos" representation.
|
|
1539
|
-
*/ function
|
|
1549
|
+
*/ function Vt(t) {
|
|
1540
1550
|
// The json interface (for the browser) will return an iso timestamp string,
|
|
1541
1551
|
// while the proto js library (for node) will return a
|
|
1542
1552
|
// google.protobuf.Timestamp instance.
|
|
1543
|
-
if (
|
|
1553
|
+
if (b(!!t), "string" == typeof t) {
|
|
1544
1554
|
// The date string can have higher precision (nanos) than the Date class
|
|
1545
1555
|
// (millis), so we do some custom parsing here.
|
|
1546
1556
|
// Parse the nanos right out of the string.
|
|
1547
1557
|
let n = 0;
|
|
1548
|
-
const e =
|
|
1549
|
-
if (
|
|
1558
|
+
const e = Rt.exec(t);
|
|
1559
|
+
if (b(!!e), e[1]) {
|
|
1550
1560
|
// Pad the fraction out to 9 digits (nanos).
|
|
1551
1561
|
let t = e[1];
|
|
1552
1562
|
t = (t + "000000000").substr(0, 9), n = Number(t);
|
|
@@ -1559,21 +1569,21 @@ const Pt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1559
1569
|
};
|
|
1560
1570
|
}
|
|
1561
1571
|
return {
|
|
1562
|
-
seconds:
|
|
1563
|
-
nanos:
|
|
1572
|
+
seconds: Nt(t.seconds),
|
|
1573
|
+
nanos: Nt(t.nanos)
|
|
1564
1574
|
};
|
|
1565
1575
|
}
|
|
1566
1576
|
|
|
1567
1577
|
/**
|
|
1568
1578
|
* Converts the possible Proto types for numbers into a JavaScript number.
|
|
1569
1579
|
* Returns 0 if the value is not numeric.
|
|
1570
|
-
*/ function
|
|
1580
|
+
*/ function Nt(t) {
|
|
1571
1581
|
// TODO(bjornick): Handle int64 greater than 53 bits.
|
|
1572
1582
|
return "number" == typeof t ? t : "string" == typeof t ? Number(t) : 0;
|
|
1573
1583
|
}
|
|
1574
1584
|
|
|
1575
|
-
/** Converts the possible Proto types for Blobs into a ByteString. */ function
|
|
1576
|
-
return "string" == typeof t ?
|
|
1585
|
+
/** Converts the possible Proto types for Blobs into a ByteString. */ function Dt(t) {
|
|
1586
|
+
return "string" == typeof t ? Pt.fromBase64String(t) : Pt.fromUint8Array(t);
|
|
1577
1587
|
}
|
|
1578
1588
|
|
|
1579
1589
|
/**
|
|
@@ -1609,7 +1619,7 @@ const Pt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1609
1619
|
* FieldValueOptions to value().
|
|
1610
1620
|
* - With respect to other ServerTimestampValues, they sort by their
|
|
1611
1621
|
* localWriteTime.
|
|
1612
|
-
*/ function
|
|
1622
|
+
*/ function $t(t) {
|
|
1613
1623
|
var n, e;
|
|
1614
1624
|
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);
|
|
1615
1625
|
}
|
|
@@ -1619,16 +1629,16 @@ const Pt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1619
1629
|
*
|
|
1620
1630
|
* Preserving the previous values allows the user to display the last resoled
|
|
1621
1631
|
* value until the backend responds with the timestamp.
|
|
1622
|
-
*/ function
|
|
1632
|
+
*/ function Ft(t) {
|
|
1623
1633
|
const n = t.mapValue.fields.__previous_value__;
|
|
1624
|
-
return
|
|
1634
|
+
return $t(n) ? Ft(n) : n;
|
|
1625
1635
|
}
|
|
1626
1636
|
|
|
1627
1637
|
/**
|
|
1628
1638
|
* Returns the local time at which this timestamp was first set.
|
|
1629
|
-
*/ function
|
|
1630
|
-
const n =
|
|
1631
|
-
return new
|
|
1639
|
+
*/ function St(t) {
|
|
1640
|
+
const n = Vt(t.mapValue.fields.__local_write_time__.timestampValue);
|
|
1641
|
+
return new vt(n.seconds, n.nanos);
|
|
1632
1642
|
}
|
|
1633
1643
|
|
|
1634
1644
|
/**
|
|
@@ -1647,13 +1657,14 @@ const Pt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1647
1657
|
* See the License for the specific language governing permissions and
|
|
1648
1658
|
* limitations under the License.
|
|
1649
1659
|
*/
|
|
1650
|
-
/** Extracts the backend's type order for the provided value. */ function
|
|
1651
|
-
return "nullValue" in t ? 0 /* NullValue */ : "booleanValue" in t ? 1 /* BooleanValue */ : "integerValue" in t || "doubleValue" in t ? 2 /* NumberValue */ : "timestampValue" in t ? 3 /* TimestampValue */ : "stringValue" in t ? 5 /* StringValue */ : "bytesValue" in t ? 6 /* BlobValue */ : "referenceValue" in t ? 7 /* RefValue */ : "geoPointValue" in t ? 8 /* GeoPointValue */ : "arrayValue" in t ? 9 /* ArrayValue */ : "mapValue" in t ?
|
|
1660
|
+
/** Extracts the backend's type order for the provided value. */ function xt(t) {
|
|
1661
|
+
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 ? $t(t) ? 4 /* ServerTimestampValue */ : 10 /* ObjectValue */ : v();
|
|
1652
1662
|
}
|
|
1653
1663
|
|
|
1654
1664
|
/** Tests `left` and `right` for equality based on the backend semantics. */ function qt(t, n) {
|
|
1655
|
-
|
|
1656
|
-
|
|
1665
|
+
if (t === n) return !0;
|
|
1666
|
+
const e = xt(t);
|
|
1667
|
+
if (e !== xt(n)) return !1;
|
|
1657
1668
|
switch (e) {
|
|
1658
1669
|
case 0 /* NullValue */ :
|
|
1659
1670
|
return !0;
|
|
@@ -1662,14 +1673,14 @@ const Pt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1662
1673
|
return t.booleanValue === n.booleanValue;
|
|
1663
1674
|
|
|
1664
1675
|
case 4 /* ServerTimestampValue */ :
|
|
1665
|
-
return
|
|
1676
|
+
return St(t).isEqual(St(n));
|
|
1666
1677
|
|
|
1667
1678
|
case 3 /* TimestampValue */ :
|
|
1668
1679
|
return function(t, n) {
|
|
1669
1680
|
if ("string" == typeof t.timestampValue && "string" == typeof n.timestampValue && t.timestampValue.length === n.timestampValue.length)
|
|
1670
1681
|
// Use string equality for ISO 8601 timestamps
|
|
1671
1682
|
return t.timestampValue === n.timestampValue;
|
|
1672
|
-
const e =
|
|
1683
|
+
const e = Vt(t.timestampValue), r = Vt(n.timestampValue);
|
|
1673
1684
|
return e.seconds === r.seconds && e.nanos === r.nanos;
|
|
1674
1685
|
}(t, n);
|
|
1675
1686
|
|
|
@@ -1678,7 +1689,7 @@ const Pt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1678
1689
|
|
|
1679
1690
|
case 6 /* BlobValue */ :
|
|
1680
1691
|
return function(t, n) {
|
|
1681
|
-
return
|
|
1692
|
+
return Dt(t.bytesValue).isEqual(Dt(n.bytesValue));
|
|
1682
1693
|
}(t, n);
|
|
1683
1694
|
|
|
1684
1695
|
case 7 /* RefValue */ :
|
|
@@ -1686,70 +1697,71 @@ const Pt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1686
1697
|
|
|
1687
1698
|
case 8 /* GeoPointValue */ :
|
|
1688
1699
|
return function(t, n) {
|
|
1689
|
-
return
|
|
1700
|
+
return Nt(t.geoPointValue.latitude) === Nt(n.geoPointValue.latitude) && Nt(t.geoPointValue.longitude) === Nt(n.geoPointValue.longitude);
|
|
1690
1701
|
}(t, n);
|
|
1691
1702
|
|
|
1692
1703
|
case 2 /* NumberValue */ :
|
|
1693
1704
|
return function(t, n) {
|
|
1694
|
-
if ("integerValue" in t && "integerValue" in n) return
|
|
1705
|
+
if ("integerValue" in t && "integerValue" in n) return Nt(t.integerValue) === Nt(n.integerValue);
|
|
1695
1706
|
if ("doubleValue" in t && "doubleValue" in n) {
|
|
1696
|
-
const e =
|
|
1697
|
-
return e === r ?
|
|
1707
|
+
const e = Nt(t.doubleValue), r = Nt(n.doubleValue);
|
|
1708
|
+
return e === r ? ht(e) === ht(r) : isNaN(e) && isNaN(r);
|
|
1698
1709
|
}
|
|
1699
1710
|
return !1;
|
|
1700
1711
|
}(t, n);
|
|
1701
1712
|
|
|
1702
1713
|
case 9 /* ArrayValue */ :
|
|
1703
|
-
return
|
|
1714
|
+
return gt(t.arrayValue.values || [], n.arrayValue.values || [], qt);
|
|
1704
1715
|
|
|
1705
1716
|
case 10 /* ObjectValue */ :
|
|
1706
1717
|
return function(t, n) {
|
|
1707
1718
|
const e = t.mapValue.fields || {}, r = n.mapValue.fields || {};
|
|
1708
|
-
if (
|
|
1719
|
+
if (Et(e) !== Et(r)) return !1;
|
|
1709
1720
|
for (const t in e) if (e.hasOwnProperty(t) && (void 0 === r[t] || !qt(e[t], r[t]))) return !1;
|
|
1710
1721
|
return !0;
|
|
1711
1722
|
}
|
|
1712
1723
|
/** Returns true if the ArrayValue contains the specified element. */ (t, n);
|
|
1713
1724
|
|
|
1714
1725
|
default:
|
|
1715
|
-
return
|
|
1726
|
+
return v();
|
|
1716
1727
|
}
|
|
1717
1728
|
}
|
|
1718
1729
|
|
|
1719
|
-
function
|
|
1730
|
+
function Ot(t, n) {
|
|
1720
1731
|
return void 0 !== (t.values || []).find((t => qt(t, n)));
|
|
1721
1732
|
}
|
|
1722
1733
|
|
|
1723
|
-
function
|
|
1724
|
-
|
|
1725
|
-
|
|
1734
|
+
function Ct(t, n) {
|
|
1735
|
+
if (t === n) return 0;
|
|
1736
|
+
const e = xt(t), r = xt(n);
|
|
1737
|
+
if (e !== r) return _t(e, r);
|
|
1726
1738
|
switch (e) {
|
|
1727
1739
|
case 0 /* NullValue */ :
|
|
1728
1740
|
return 0;
|
|
1729
1741
|
|
|
1730
1742
|
case 1 /* BooleanValue */ :
|
|
1731
|
-
return
|
|
1743
|
+
return _t(t.booleanValue, n.booleanValue);
|
|
1732
1744
|
|
|
1733
1745
|
case 2 /* NumberValue */ :
|
|
1734
1746
|
return function(t, n) {
|
|
1735
|
-
const e =
|
|
1747
|
+
const e = Nt(t.integerValue || t.doubleValue), r = Nt(n.integerValue || n.doubleValue);
|
|
1736
1748
|
return e < r ? -1 : e > r ? 1 : e === r ? 0 :
|
|
1737
1749
|
// one or both are NaN.
|
|
1738
1750
|
isNaN(e) ? isNaN(r) ? 0 : -1 : 1;
|
|
1739
1751
|
}(t, n);
|
|
1740
1752
|
|
|
1741
1753
|
case 3 /* TimestampValue */ :
|
|
1742
|
-
return
|
|
1754
|
+
return Lt(t.timestampValue, n.timestampValue);
|
|
1743
1755
|
|
|
1744
1756
|
case 4 /* ServerTimestampValue */ :
|
|
1745
|
-
return
|
|
1757
|
+
return Lt(St(t), St(n));
|
|
1746
1758
|
|
|
1747
1759
|
case 5 /* StringValue */ :
|
|
1748
|
-
return
|
|
1760
|
+
return _t(t.stringValue, n.stringValue);
|
|
1749
1761
|
|
|
1750
1762
|
case 6 /* BlobValue */ :
|
|
1751
1763
|
return function(t, n) {
|
|
1752
|
-
const e =
|
|
1764
|
+
const e = Dt(t), r = Dt(n);
|
|
1753
1765
|
return e.compareTo(r);
|
|
1754
1766
|
}(t.bytesValue, n.bytesValue);
|
|
1755
1767
|
|
|
@@ -1757,27 +1769,27 @@ function Ot(t, n) {
|
|
|
1757
1769
|
return function(t, n) {
|
|
1758
1770
|
const e = t.split("/"), r = n.split("/");
|
|
1759
1771
|
for (let t = 0; t < e.length && t < r.length; t++) {
|
|
1760
|
-
const n =
|
|
1772
|
+
const n = _t(e[t], r[t]);
|
|
1761
1773
|
if (0 !== n) return n;
|
|
1762
1774
|
}
|
|
1763
|
-
return
|
|
1775
|
+
return _t(e.length, r.length);
|
|
1764
1776
|
}(t.referenceValue, n.referenceValue);
|
|
1765
1777
|
|
|
1766
1778
|
case 8 /* GeoPointValue */ :
|
|
1767
1779
|
return function(t, n) {
|
|
1768
|
-
const e =
|
|
1780
|
+
const e = _t(Nt(t.latitude), Nt(n.latitude));
|
|
1769
1781
|
if (0 !== e) return e;
|
|
1770
|
-
return
|
|
1782
|
+
return _t(Nt(t.longitude), Nt(n.longitude));
|
|
1771
1783
|
}(t.geoPointValue, n.geoPointValue);
|
|
1772
1784
|
|
|
1773
1785
|
case 9 /* ArrayValue */ :
|
|
1774
1786
|
return function(t, n) {
|
|
1775
1787
|
const e = t.values || [], r = n.values || [];
|
|
1776
1788
|
for (let t = 0; t < e.length && t < r.length; ++t) {
|
|
1777
|
-
const n =
|
|
1789
|
+
const n = Ct(e[t], r[t]);
|
|
1778
1790
|
if (n) return n;
|
|
1779
1791
|
}
|
|
1780
|
-
return
|
|
1792
|
+
return _t(e.length, r.length);
|
|
1781
1793
|
}(t.arrayValue, n.arrayValue);
|
|
1782
1794
|
|
|
1783
1795
|
case 10 /* ObjectValue */ :
|
|
@@ -1789,49 +1801,49 @@ function Ot(t, n) {
|
|
|
1789
1801
|
// canonical IDs are independent of insertion order.
|
|
1790
1802
|
r.sort(), i.sort();
|
|
1791
1803
|
for (let t = 0; t < r.length && t < i.length; ++t) {
|
|
1792
|
-
const n =
|
|
1804
|
+
const n = _t(r[t], i[t]);
|
|
1793
1805
|
if (0 !== n) return n;
|
|
1794
|
-
const o =
|
|
1806
|
+
const o = Ct(e[r[t]], s[i[t]]);
|
|
1795
1807
|
if (0 !== o) return o;
|
|
1796
1808
|
}
|
|
1797
|
-
return
|
|
1809
|
+
return _t(r.length, i.length);
|
|
1798
1810
|
}
|
|
1799
1811
|
/** Returns a reference value for the provided database and key. */ (t.mapValue, n.mapValue);
|
|
1800
1812
|
|
|
1801
1813
|
default:
|
|
1802
|
-
throw
|
|
1814
|
+
throw v();
|
|
1803
1815
|
}
|
|
1804
1816
|
}
|
|
1805
1817
|
|
|
1806
|
-
function
|
|
1807
|
-
if ("string" == typeof t && "string" == typeof n && t.length === n.length) return
|
|
1808
|
-
const e =
|
|
1809
|
-
return 0 !== s ? s :
|
|
1818
|
+
function Lt(t, n) {
|
|
1819
|
+
if ("string" == typeof t && "string" == typeof n && t.length === n.length) return _t(t, n);
|
|
1820
|
+
const e = Vt(t), r = Vt(n), s = _t(e.seconds, r.seconds);
|
|
1821
|
+
return 0 !== s ? s : _t(e.nanos, r.nanos);
|
|
1810
1822
|
}
|
|
1811
1823
|
|
|
1812
|
-
function
|
|
1824
|
+
function kt(t, n) {
|
|
1813
1825
|
return {
|
|
1814
1826
|
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${n.path.canonicalString()}`
|
|
1815
1827
|
};
|
|
1816
1828
|
}
|
|
1817
1829
|
|
|
1818
|
-
/** Returns true if `value` is an ArrayValue. */ function
|
|
1830
|
+
/** Returns true if `value` is an ArrayValue. */ function Ut(t) {
|
|
1819
1831
|
return !!t && "arrayValue" in t;
|
|
1820
1832
|
}
|
|
1821
1833
|
|
|
1822
|
-
/** Returns true if `value` is a NullValue. */ function
|
|
1834
|
+
/** Returns true if `value` is a NullValue. */ function jt(t) {
|
|
1823
1835
|
return !!t && "nullValue" in t;
|
|
1824
1836
|
}
|
|
1825
1837
|
|
|
1826
|
-
/** Returns true if `value` is NaN. */ function
|
|
1838
|
+
/** Returns true if `value` is NaN. */ function Mt(t) {
|
|
1827
1839
|
return !!t && "doubleValue" in t && isNaN(Number(t.doubleValue));
|
|
1828
1840
|
}
|
|
1829
1841
|
|
|
1830
|
-
/** Returns true if `value` is a MapValue. */ function
|
|
1842
|
+
/** Returns true if `value` is a MapValue. */ function Bt(t) {
|
|
1831
1843
|
return !!t && "mapValue" in t;
|
|
1832
1844
|
}
|
|
1833
1845
|
|
|
1834
|
-
/** Creates a deep copy of `source`. */ function
|
|
1846
|
+
/** Creates a deep copy of `source`. */ function zt(t) {
|
|
1835
1847
|
if (t.geoPointValue) return {
|
|
1836
1848
|
geoPointValue: Object.assign({}, t.geoPointValue)
|
|
1837
1849
|
};
|
|
@@ -1844,7 +1856,7 @@ function Lt(t, n) {
|
|
|
1844
1856
|
fields: {}
|
|
1845
1857
|
}
|
|
1846
1858
|
};
|
|
1847
|
-
return
|
|
1859
|
+
return Tt(t.mapValue.fields, ((t, e) => n.mapValue.fields[t] = zt(e))), n;
|
|
1848
1860
|
}
|
|
1849
1861
|
if (t.arrayValue) {
|
|
1850
1862
|
const n = {
|
|
@@ -1852,7 +1864,7 @@ function Lt(t, n) {
|
|
|
1852
1864
|
values: []
|
|
1853
1865
|
}
|
|
1854
1866
|
};
|
|
1855
|
-
for (let e = 0; e < (t.arrayValue.values || []).length; ++e) n.arrayValue.values[e] =
|
|
1867
|
+
for (let e = 0; e < (t.arrayValue.values || []).length; ++e) n.arrayValue.values[e] = zt(t.arrayValue.values[e]);
|
|
1856
1868
|
return n;
|
|
1857
1869
|
}
|
|
1858
1870
|
return Object.assign({}, t);
|
|
@@ -1877,12 +1889,12 @@ function Lt(t, n) {
|
|
|
1877
1889
|
/**
|
|
1878
1890
|
* An ObjectValue represents a MapValue in the Firestore Proto and offers the
|
|
1879
1891
|
* ability to add and remove fields (via the ObjectValueBuilder).
|
|
1880
|
-
*/ class
|
|
1892
|
+
*/ class Qt {
|
|
1881
1893
|
constructor(t) {
|
|
1882
1894
|
this.value = t;
|
|
1883
1895
|
}
|
|
1884
1896
|
static empty() {
|
|
1885
|
-
return new
|
|
1897
|
+
return new Qt({
|
|
1886
1898
|
mapValue: {}
|
|
1887
1899
|
});
|
|
1888
1900
|
}
|
|
@@ -1896,7 +1908,7 @@ function Lt(t, n) {
|
|
|
1896
1908
|
{
|
|
1897
1909
|
let n = this.value;
|
|
1898
1910
|
for (let e = 0; e < t.length - 1; ++e) if (n = (n.mapValue.fields || {})[t.get(e)],
|
|
1899
|
-
!
|
|
1911
|
+
!Bt(n)) return null;
|
|
1900
1912
|
return n = (n.mapValue.fields || {})[t.lastSegment()], n || null;
|
|
1901
1913
|
}
|
|
1902
1914
|
}
|
|
@@ -1906,21 +1918,21 @@ function Lt(t, n) {
|
|
|
1906
1918
|
* @param path - The field path to set.
|
|
1907
1919
|
* @param value - The value to set.
|
|
1908
1920
|
*/ set(t, n) {
|
|
1909
|
-
this.getFieldsMap(t.popLast())[t.lastSegment()] =
|
|
1921
|
+
this.getFieldsMap(t.popLast())[t.lastSegment()] = zt(n);
|
|
1910
1922
|
}
|
|
1911
1923
|
/**
|
|
1912
1924
|
* Sets the provided fields to the provided values.
|
|
1913
1925
|
*
|
|
1914
1926
|
* @param data - A map of fields to values (or null for deletes).
|
|
1915
1927
|
*/ setAll(t) {
|
|
1916
|
-
let n =
|
|
1928
|
+
let n = nt.emptyPath(), e = {}, r = [];
|
|
1917
1929
|
t.forEach(((t, s) => {
|
|
1918
1930
|
if (!n.isImmediateParentOf(s)) {
|
|
1919
1931
|
// Insert the accumulated changes at this parent location
|
|
1920
1932
|
const t = this.getFieldsMap(n);
|
|
1921
1933
|
this.applyChanges(t, e, r), e = {}, r = [], n = s.popLast();
|
|
1922
1934
|
}
|
|
1923
|
-
t ? e[s.lastSegment()] =
|
|
1935
|
+
t ? e[s.lastSegment()] = zt(t) : r.push(s.lastSegment());
|
|
1924
1936
|
}));
|
|
1925
1937
|
const s = this.getFieldsMap(n);
|
|
1926
1938
|
this.applyChanges(s, e, r);
|
|
@@ -1932,7 +1944,7 @@ function Lt(t, n) {
|
|
|
1932
1944
|
* @param path - The field path to remove.
|
|
1933
1945
|
*/ delete(t) {
|
|
1934
1946
|
const n = this.field(t.popLast());
|
|
1935
|
-
|
|
1947
|
+
Bt(n) && n.mapValue.fields && delete n.mapValue.fields[t.lastSegment()];
|
|
1936
1948
|
}
|
|
1937
1949
|
isEqual(t) {
|
|
1938
1950
|
return qt(this.value, t.value);
|
|
@@ -1947,7 +1959,7 @@ function Lt(t, n) {
|
|
|
1947
1959
|
});
|
|
1948
1960
|
for (let e = 0; e < t.length; ++e) {
|
|
1949
1961
|
let r = n.mapValue.fields[t.get(e)];
|
|
1950
|
-
|
|
1962
|
+
Bt(r) && r.mapValue.fields || (r = {
|
|
1951
1963
|
mapValue: {
|
|
1952
1964
|
fields: {}
|
|
1953
1965
|
}
|
|
@@ -1959,11 +1971,11 @@ function Lt(t, n) {
|
|
|
1959
1971
|
* Modifies `fieldsMap` by adding, replacing or deleting the specified
|
|
1960
1972
|
* entries.
|
|
1961
1973
|
*/ applyChanges(t, n, e) {
|
|
1962
|
-
|
|
1974
|
+
Tt(n, ((n, e) => t[n] = e));
|
|
1963
1975
|
for (const n of e) delete t[n];
|
|
1964
1976
|
}
|
|
1965
1977
|
clone() {
|
|
1966
|
-
return new zt(
|
|
1978
|
+
return new Qt(zt(this.value));
|
|
1967
1979
|
}
|
|
1968
1980
|
}
|
|
1969
1981
|
|
|
@@ -1992,7 +2004,7 @@ function Lt(t, n) {
|
|
|
1992
2004
|
* not transition to one of these states even after all mutations have been
|
|
1993
2005
|
* applied, `isValidDocument()` returns false and the document should be removed
|
|
1994
2006
|
* from all views.
|
|
1995
|
-
*/ class
|
|
2007
|
+
*/ class Gt {
|
|
1996
2008
|
constructor(t, n, e, r, s) {
|
|
1997
2009
|
this.key = t, this.documentType = n, this.version = e, this.data = r, this.documentState = s;
|
|
1998
2010
|
}
|
|
@@ -2000,23 +2012,23 @@ function Lt(t, n) {
|
|
|
2000
2012
|
* Creates a document with no known version or data, but which can serve as
|
|
2001
2013
|
* base document for mutations.
|
|
2002
2014
|
*/ static newInvalidDocument(t) {
|
|
2003
|
-
return new
|
|
2015
|
+
return new Gt(t, 0 /* INVALID */ , bt.min(), Qt.empty(), 0 /* SYNCED */);
|
|
2004
2016
|
}
|
|
2005
2017
|
/**
|
|
2006
2018
|
* Creates a new document that is known to exist with the given data at the
|
|
2007
2019
|
* given version.
|
|
2008
2020
|
*/ static newFoundDocument(t, n, e) {
|
|
2009
|
-
return new
|
|
2021
|
+
return new Gt(t, 1 /* FOUND_DOCUMENT */ , n, e, 0 /* SYNCED */);
|
|
2010
2022
|
}
|
|
2011
2023
|
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t, n) {
|
|
2012
|
-
return new
|
|
2024
|
+
return new Gt(t, 2 /* NO_DOCUMENT */ , n, Qt.empty(), 0 /* SYNCED */);
|
|
2013
2025
|
}
|
|
2014
2026
|
/**
|
|
2015
2027
|
* Creates a new document that is known to exist at the given version but
|
|
2016
2028
|
* whose data is not known (e.g. a document that was updated without a known
|
|
2017
2029
|
* base document).
|
|
2018
2030
|
*/ static newUnknownDocument(t, n) {
|
|
2019
|
-
return new
|
|
2031
|
+
return new Gt(t, 3 /* UNKNOWN_DOCUMENT */ , n, Qt.empty(), 2 /* HAS_COMMITTED_MUTATIONS */);
|
|
2020
2032
|
}
|
|
2021
2033
|
/**
|
|
2022
2034
|
* Changes the document type to indicate that it exists and that its version
|
|
@@ -2029,7 +2041,7 @@ function Lt(t, n) {
|
|
|
2029
2041
|
* Changes the document type to indicate that it doesn't exist at the given
|
|
2030
2042
|
* version.
|
|
2031
2043
|
*/ convertToNoDocument(t) {
|
|
2032
|
-
return this.version = t, this.documentType = 2 /* NO_DOCUMENT */ , this.data =
|
|
2044
|
+
return this.version = t, this.documentType = 2 /* NO_DOCUMENT */ , this.data = Qt.empty(),
|
|
2033
2045
|
this.documentState = 0 /* SYNCED */ , this;
|
|
2034
2046
|
}
|
|
2035
2047
|
/**
|
|
@@ -2037,7 +2049,7 @@ function Lt(t, n) {
|
|
|
2037
2049
|
* that its data is not known (e.g. a document that was updated without a known
|
|
2038
2050
|
* base document).
|
|
2039
2051
|
*/ convertToUnknownDocument(t) {
|
|
2040
|
-
return this.version = t, this.documentType = 3 /* UNKNOWN_DOCUMENT */ , this.data =
|
|
2052
|
+
return this.version = t, this.documentType = 3 /* UNKNOWN_DOCUMENT */ , this.data = Qt.empty(),
|
|
2041
2053
|
this.documentState = 2 /* HAS_COMMITTED_MUTATIONS */ , this;
|
|
2042
2054
|
}
|
|
2043
2055
|
setHasCommittedMutations() {
|
|
@@ -2068,10 +2080,10 @@ function Lt(t, n) {
|
|
|
2068
2080
|
return 3 /* UNKNOWN_DOCUMENT */ === this.documentType;
|
|
2069
2081
|
}
|
|
2070
2082
|
isEqual(t) {
|
|
2071
|
-
return t instanceof
|
|
2083
|
+
return t instanceof Gt && this.key.isEqual(t.key) && this.version.isEqual(t.version) && this.documentType === t.documentType && this.documentState === t.documentState && this.data.isEqual(t.data);
|
|
2072
2084
|
}
|
|
2073
|
-
|
|
2074
|
-
return new
|
|
2085
|
+
mutableCopy() {
|
|
2086
|
+
return new Gt(this.key, this.documentType, this.version, this.data.clone(), this.documentState);
|
|
2075
2087
|
}
|
|
2076
2088
|
toString() {
|
|
2077
2089
|
return `Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`;
|
|
@@ -2095,7 +2107,7 @@ function Lt(t, n) {
|
|
|
2095
2107
|
* limitations under the License.
|
|
2096
2108
|
*/
|
|
2097
2109
|
// Visible for testing
|
|
2098
|
-
class
|
|
2110
|
+
class Wt {
|
|
2099
2111
|
constructor(t, n = null, e = [], r = [], s = null, i = null, o = null) {
|
|
2100
2112
|
this.path = t, this.collectionGroup = n, this.orderBy = e, this.filters = r, this.limit = s,
|
|
2101
2113
|
this.startAt = i, this.endAt = o, this.R = null;
|
|
@@ -2109,26 +2121,26 @@ class Gt {
|
|
|
2109
2121
|
* NOTE: you should always construct `Target` from `Query.toTarget` instead of
|
|
2110
2122
|
* using this factory method, because `Query` provides an implicit `orderBy`
|
|
2111
2123
|
* property.
|
|
2112
|
-
*/ function
|
|
2113
|
-
return new
|
|
2124
|
+
*/ function Yt(t, n = null, e = [], r = [], s = null, i = null, o = null) {
|
|
2125
|
+
return new Wt(t, n, e, r, s, i, o);
|
|
2114
2126
|
}
|
|
2115
2127
|
|
|
2116
|
-
class
|
|
2128
|
+
class Ht extends class {} {
|
|
2117
2129
|
constructor(t, n, e) {
|
|
2118
2130
|
super(), this.field = t, this.op = n, this.value = e;
|
|
2119
2131
|
}
|
|
2120
2132
|
/**
|
|
2121
2133
|
* Creates a filter based on the provided arguments.
|
|
2122
2134
|
*/ static create(t, n, e) {
|
|
2123
|
-
return t.isKeyField() ? "in" /* IN */ === n || "not-in" /* NOT_IN */ === n ? this.V(t, n, e) : new
|
|
2135
|
+
return t.isKeyField() ? "in" /* IN */ === n || "not-in" /* NOT_IN */ === n ? this.V(t, n, e) : new Kt(t, n, e) : "array-contains" /* ARRAY_CONTAINS */ === n ? new tn(t, e) : "in" /* IN */ === n ? new nn(t, e) : "not-in" /* NOT_IN */ === n ? new en(t, e) : "array-contains-any" /* ARRAY_CONTAINS_ANY */ === n ? new rn(t, e) : new Ht(t, n, e);
|
|
2124
2136
|
}
|
|
2125
2137
|
static V(t, n, e) {
|
|
2126
|
-
return "in" /* IN */ === n ? new
|
|
2138
|
+
return "in" /* IN */ === n ? new Jt(t, e) : new Xt(t, e);
|
|
2127
2139
|
}
|
|
2128
2140
|
matches(t) {
|
|
2129
2141
|
const n = t.data.field(this.field);
|
|
2130
2142
|
// Types do not have to match in NOT_EQUAL filters.
|
|
2131
|
-
return "!=" /* NOT_EQUAL */ === this.op ? null !== n && this.N(
|
|
2143
|
+
return "!=" /* NOT_EQUAL */ === this.op ? null !== n && this.N(Ct(n, this.value)) : null !== n && xt(this.value) === xt(n) && this.N(Ct(n, this.value));
|
|
2132
2144
|
// Only compare types with matching backend order (such as double and int).
|
|
2133
2145
|
}
|
|
2134
2146
|
N(t) {
|
|
@@ -2152,7 +2164,7 @@ class Yt extends class {} {
|
|
|
2152
2164
|
return t >= 0;
|
|
2153
2165
|
|
|
2154
2166
|
default:
|
|
2155
|
-
return
|
|
2167
|
+
return v();
|
|
2156
2168
|
}
|
|
2157
2169
|
}
|
|
2158
2170
|
D() {
|
|
@@ -2161,79 +2173,79 @@ class Yt extends class {} {
|
|
|
2161
2173
|
}
|
|
2162
2174
|
|
|
2163
2175
|
/** Filter that matches on key fields (i.e. '__name__'). */
|
|
2164
|
-
class
|
|
2176
|
+
class Kt extends Ht {
|
|
2165
2177
|
constructor(t, n, e) {
|
|
2166
|
-
super(t, n, e), this.key =
|
|
2178
|
+
super(t, n, e), this.key = et.fromName(e.referenceValue);
|
|
2167
2179
|
}
|
|
2168
2180
|
matches(t) {
|
|
2169
|
-
const n =
|
|
2181
|
+
const n = et.comparator(t.key, this.key);
|
|
2170
2182
|
return this.N(n);
|
|
2171
2183
|
}
|
|
2172
2184
|
}
|
|
2173
2185
|
|
|
2174
|
-
/** Filter that matches on key fields within an array. */ class
|
|
2186
|
+
/** Filter that matches on key fields within an array. */ class Jt extends Ht {
|
|
2175
2187
|
constructor(t, n) {
|
|
2176
|
-
super(t, "in" /* IN */ , n), this.keys =
|
|
2188
|
+
super(t, "in" /* IN */ , n), this.keys = Zt("in" /* IN */ , n);
|
|
2177
2189
|
}
|
|
2178
2190
|
matches(t) {
|
|
2179
2191
|
return this.keys.some((n => n.isEqual(t.key)));
|
|
2180
2192
|
}
|
|
2181
2193
|
}
|
|
2182
2194
|
|
|
2183
|
-
/** Filter that matches on key fields not present within an array. */ class
|
|
2195
|
+
/** Filter that matches on key fields not present within an array. */ class Xt extends Ht {
|
|
2184
2196
|
constructor(t, n) {
|
|
2185
|
-
super(t, "not-in" /* NOT_IN */ , n), this.keys =
|
|
2197
|
+
super(t, "not-in" /* NOT_IN */ , n), this.keys = Zt("not-in" /* NOT_IN */ , n);
|
|
2186
2198
|
}
|
|
2187
2199
|
matches(t) {
|
|
2188
2200
|
return !this.keys.some((n => n.isEqual(t.key)));
|
|
2189
2201
|
}
|
|
2190
2202
|
}
|
|
2191
2203
|
|
|
2192
|
-
function
|
|
2204
|
+
function Zt(t, n) {
|
|
2193
2205
|
var e;
|
|
2194
|
-
return ((null === (e = n.arrayValue) || void 0 === e ? void 0 : e.values) || []).map((t =>
|
|
2206
|
+
return ((null === (e = n.arrayValue) || void 0 === e ? void 0 : e.values) || []).map((t => et.fromName(t.referenceValue)));
|
|
2195
2207
|
}
|
|
2196
2208
|
|
|
2197
|
-
/** A Filter that implements the array-contains operator. */ class
|
|
2209
|
+
/** A Filter that implements the array-contains operator. */ class tn extends Ht {
|
|
2198
2210
|
constructor(t, n) {
|
|
2199
2211
|
super(t, "array-contains" /* ARRAY_CONTAINS */ , n);
|
|
2200
2212
|
}
|
|
2201
2213
|
matches(t) {
|
|
2202
2214
|
const n = t.data.field(this.field);
|
|
2203
|
-
return
|
|
2215
|
+
return Ut(n) && Ot(n.arrayValue, this.value);
|
|
2204
2216
|
}
|
|
2205
2217
|
}
|
|
2206
2218
|
|
|
2207
|
-
/** A Filter that implements the IN operator. */ class
|
|
2219
|
+
/** A Filter that implements the IN operator. */ class nn extends Ht {
|
|
2208
2220
|
constructor(t, n) {
|
|
2209
2221
|
super(t, "in" /* IN */ , n);
|
|
2210
2222
|
}
|
|
2211
2223
|
matches(t) {
|
|
2212
2224
|
const n = t.data.field(this.field);
|
|
2213
|
-
return null !== n &&
|
|
2225
|
+
return null !== n && Ot(this.value.arrayValue, n);
|
|
2214
2226
|
}
|
|
2215
2227
|
}
|
|
2216
2228
|
|
|
2217
|
-
/** A Filter that implements the not-in operator. */ class
|
|
2229
|
+
/** A Filter that implements the not-in operator. */ class en extends Ht {
|
|
2218
2230
|
constructor(t, n) {
|
|
2219
2231
|
super(t, "not-in" /* NOT_IN */ , n);
|
|
2220
2232
|
}
|
|
2221
2233
|
matches(t) {
|
|
2222
|
-
if (
|
|
2234
|
+
if (Ot(this.value.arrayValue, {
|
|
2223
2235
|
nullValue: "NULL_VALUE"
|
|
2224
2236
|
})) return !1;
|
|
2225
2237
|
const n = t.data.field(this.field);
|
|
2226
|
-
return null !== n && !
|
|
2238
|
+
return null !== n && !Ot(this.value.arrayValue, n);
|
|
2227
2239
|
}
|
|
2228
2240
|
}
|
|
2229
2241
|
|
|
2230
|
-
/** A Filter that implements the array-contains-any operator. */ class
|
|
2242
|
+
/** A Filter that implements the array-contains-any operator. */ class rn extends Ht {
|
|
2231
2243
|
constructor(t, n) {
|
|
2232
2244
|
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ , n);
|
|
2233
2245
|
}
|
|
2234
2246
|
matches(t) {
|
|
2235
2247
|
const n = t.data.field(this.field);
|
|
2236
|
-
return !(!
|
|
2248
|
+
return !(!Ut(n) || !n.arrayValue.values) && n.arrayValue.values.some((t => Ot(this.value.arrayValue, t)));
|
|
2237
2249
|
}
|
|
2238
2250
|
}
|
|
2239
2251
|
|
|
@@ -2250,7 +2262,7 @@ function Xt(t, n) {
|
|
|
2250
2262
|
* Bound provides a function to determine whether a document comes before or
|
|
2251
2263
|
* after a bound. This is influenced by whether the position is just before or
|
|
2252
2264
|
* just after the provided values.
|
|
2253
|
-
*/ class
|
|
2265
|
+
*/ class sn {
|
|
2254
2266
|
constructor(t, n) {
|
|
2255
2267
|
this.position = t, this.before = n;
|
|
2256
2268
|
}
|
|
@@ -2258,17 +2270,17 @@ function Xt(t, n) {
|
|
|
2258
2270
|
|
|
2259
2271
|
/**
|
|
2260
2272
|
* An ordering on a field, in some Direction. Direction defaults to ASCENDING.
|
|
2261
|
-
*/ class
|
|
2273
|
+
*/ class on {
|
|
2262
2274
|
constructor(t, n = "asc" /* ASCENDING */) {
|
|
2263
2275
|
this.field = t, this.dir = n;
|
|
2264
2276
|
}
|
|
2265
2277
|
}
|
|
2266
2278
|
|
|
2267
|
-
function
|
|
2279
|
+
function un(t, n) {
|
|
2268
2280
|
return t.dir === n.dir && t.field.isEqual(n.field);
|
|
2269
2281
|
}
|
|
2270
2282
|
|
|
2271
|
-
function
|
|
2283
|
+
function cn(t, n) {
|
|
2272
2284
|
if (null === t) return null === n;
|
|
2273
2285
|
if (null === n) return !1;
|
|
2274
2286
|
if (t.before !== n.before || t.position.length !== n.position.length) return !1;
|
|
@@ -2300,7 +2312,7 @@ function un(t, n) {
|
|
|
2300
2312
|
* query the RemoteStore results.
|
|
2301
2313
|
*
|
|
2302
2314
|
* Visible for testing.
|
|
2303
|
-
*/ class
|
|
2315
|
+
*/ class an {
|
|
2304
2316
|
/**
|
|
2305
2317
|
* Initializes a Query with a path and optional additional query constraints.
|
|
2306
2318
|
* Path must currently be empty if this is a collection group query.
|
|
@@ -2313,15 +2325,15 @@ function un(t, n) {
|
|
|
2313
2325
|
}
|
|
2314
2326
|
}
|
|
2315
2327
|
|
|
2316
|
-
/** Creates a new Query for a query that matches all documents at `path` */ function
|
|
2317
|
-
return !
|
|
2328
|
+
/** Creates a new Query for a query that matches all documents at `path` */ function hn(t) {
|
|
2329
|
+
return !at(t.limit) && "L" /* Last */ === t.limitType;
|
|
2318
2330
|
}
|
|
2319
2331
|
|
|
2320
|
-
function
|
|
2332
|
+
function ln(t) {
|
|
2321
2333
|
return t.explicitOrderBy.length > 0 ? t.explicitOrderBy[0].field : null;
|
|
2322
2334
|
}
|
|
2323
2335
|
|
|
2324
|
-
function
|
|
2336
|
+
function fn(t) {
|
|
2325
2337
|
for (const n of t.filters) if (n.D()) return n.field;
|
|
2326
2338
|
return null;
|
|
2327
2339
|
}
|
|
@@ -2334,7 +2346,7 @@ function ln(t) {
|
|
|
2334
2346
|
* Returns whether the query matches a collection group rather than a specific
|
|
2335
2347
|
* collection.
|
|
2336
2348
|
*/
|
|
2337
|
-
function
|
|
2349
|
+
function dn(t) {
|
|
2338
2350
|
return null !== t.collectionGroup;
|
|
2339
2351
|
}
|
|
2340
2352
|
|
|
@@ -2342,23 +2354,23 @@ function fn(t) {
|
|
|
2342
2354
|
* Returns the implicit order by constraint that is used to execute the Query,
|
|
2343
2355
|
* which can be different from the order by constraints the user provided (e.g.
|
|
2344
2356
|
* the SDK and backend always orders by `__name__`).
|
|
2345
|
-
*/ function
|
|
2346
|
-
const n =
|
|
2357
|
+
*/ function wn(t) {
|
|
2358
|
+
const n = E(t);
|
|
2347
2359
|
if (null === n.$) {
|
|
2348
2360
|
n.$ = [];
|
|
2349
|
-
const t =
|
|
2361
|
+
const t = fn(n), e = ln(n);
|
|
2350
2362
|
if (null !== t && null === e)
|
|
2351
2363
|
// In order to implicitly add key ordering, we must also add the
|
|
2352
2364
|
// inequality filter field for it to be a valid query.
|
|
2353
2365
|
// Note that the default inequality field and key ordering is ascending.
|
|
2354
|
-
t.isKeyField() || n.$.push(new
|
|
2366
|
+
t.isKeyField() || n.$.push(new on(t)), n.$.push(new on(nt.keyField(), "asc" /* ASCENDING */)); else {
|
|
2355
2367
|
let t = !1;
|
|
2356
2368
|
for (const e of n.explicitOrderBy) n.$.push(e), e.field.isKeyField() && (t = !0);
|
|
2357
2369
|
if (!t) {
|
|
2358
2370
|
// The order of the implicit key ordering always matches the last
|
|
2359
2371
|
// explicit order by
|
|
2360
2372
|
const t = n.explicitOrderBy.length > 0 ? n.explicitOrderBy[n.explicitOrderBy.length - 1].dir : "asc" /* ASCENDING */;
|
|
2361
|
-
n.$.push(new
|
|
2373
|
+
n.$.push(new on(nt.keyField(), t));
|
|
2362
2374
|
}
|
|
2363
2375
|
}
|
|
2364
2376
|
}
|
|
@@ -2367,34 +2379,34 @@ function fn(t) {
|
|
|
2367
2379
|
|
|
2368
2380
|
/**
|
|
2369
2381
|
* Converts this `Query` instance to it's corresponding `Target` representation.
|
|
2370
|
-
*/ function
|
|
2371
|
-
const n =
|
|
2372
|
-
if (!n.F) if ("F" /* First */ === n.limitType) n.F =
|
|
2382
|
+
*/ function mn(t) {
|
|
2383
|
+
const n = E(t);
|
|
2384
|
+
if (!n.F) if ("F" /* First */ === n.limitType) n.F = Yt(n.path, n.collectionGroup, wn(n), n.filters, n.limit, n.startAt, n.endAt); else {
|
|
2373
2385
|
// Flip the orderBy directions since we want the last results
|
|
2374
2386
|
const t = [];
|
|
2375
|
-
for (const e of
|
|
2387
|
+
for (const e of wn(n)) {
|
|
2376
2388
|
const n = "desc" /* DESCENDING */ === e.dir ? "asc" /* ASCENDING */ : "desc" /* DESCENDING */;
|
|
2377
|
-
t.push(new
|
|
2389
|
+
t.push(new on(e.field, n));
|
|
2378
2390
|
}
|
|
2379
2391
|
// We need to swap the cursors to match the now-flipped query ordering.
|
|
2380
|
-
const e = n.endAt ? new
|
|
2392
|
+
const e = n.endAt ? new sn(n.endAt.position, !n.endAt.before) : null, r = n.startAt ? new sn(n.startAt.position, !n.startAt.before) : null;
|
|
2381
2393
|
// Now return as a LimitType.First query.
|
|
2382
|
-
n.F =
|
|
2394
|
+
n.F = Yt(n.path, n.collectionGroup, t, n.filters, n.limit, e, r);
|
|
2383
2395
|
}
|
|
2384
2396
|
return n.F;
|
|
2385
2397
|
}
|
|
2386
2398
|
|
|
2387
|
-
function
|
|
2399
|
+
function pn(t, n) {
|
|
2388
2400
|
return function(t, n) {
|
|
2389
2401
|
if (t.limit !== n.limit) return !1;
|
|
2390
2402
|
if (t.orderBy.length !== n.orderBy.length) return !1;
|
|
2391
|
-
for (let e = 0; e < t.orderBy.length; e++) if (!
|
|
2403
|
+
for (let e = 0; e < t.orderBy.length; e++) if (!un(t.orderBy[e], n.orderBy[e])) return !1;
|
|
2392
2404
|
if (t.filters.length !== n.filters.length) return !1;
|
|
2393
2405
|
for (let s = 0; s < t.filters.length; s++) if (e = t.filters[s], r = n.filters[s],
|
|
2394
2406
|
e.op !== r.op || !e.field.isEqual(r.field) || !qt(e.value, r.value)) return !1;
|
|
2395
2407
|
var e, r;
|
|
2396
|
-
return t.collectionGroup === n.collectionGroup && !!t.path.isEqual(n.path) && !!
|
|
2397
|
-
}(
|
|
2408
|
+
return t.collectionGroup === n.collectionGroup && !!t.path.isEqual(n.path) && !!cn(t.startAt, n.startAt) && cn(t.endAt, n.endAt);
|
|
2409
|
+
}(mn(t), mn(n)) && t.limitType === n.limitType;
|
|
2398
2410
|
}
|
|
2399
2411
|
|
|
2400
2412
|
/**
|
|
@@ -2422,9 +2434,9 @@ function mn(t, n) {
|
|
|
2422
2434
|
* The return value is an IntegerValue if it can safely represent the value,
|
|
2423
2435
|
* otherwise a DoubleValue is returned.
|
|
2424
2436
|
*/
|
|
2425
|
-
function
|
|
2437
|
+
function yn(t, n) {
|
|
2426
2438
|
return function(t) {
|
|
2427
|
-
return "number" == typeof t && Number.isInteger(t) && !
|
|
2439
|
+
return "number" == typeof t && Number.isInteger(t) && !ht(t) && t <= Number.MAX_SAFE_INTEGER && t >= Number.MIN_SAFE_INTEGER;
|
|
2428
2440
|
}(n) ?
|
|
2429
2441
|
/**
|
|
2430
2442
|
* Returns an IntegerValue for `value`.
|
|
@@ -2446,7 +2458,7 @@ function pn(t, n) {
|
|
|
2446
2458
|
};
|
|
2447
2459
|
}
|
|
2448
2460
|
return {
|
|
2449
|
-
doubleValue:
|
|
2461
|
+
doubleValue: ht(n) ? "-0" : n
|
|
2450
2462
|
};
|
|
2451
2463
|
}(t, n);
|
|
2452
2464
|
}
|
|
@@ -2467,7 +2479,7 @@ function pn(t, n) {
|
|
|
2467
2479
|
* See the License for the specific language governing permissions and
|
|
2468
2480
|
* limitations under the License.
|
|
2469
2481
|
*/
|
|
2470
|
-
/** Used to represent a field transform on a mutation. */ class
|
|
2482
|
+
/** Used to represent a field transform on a mutation. */ class _n {
|
|
2471
2483
|
constructor() {
|
|
2472
2484
|
// Make sure that the structural type of `TransformOperation` is unique.
|
|
2473
2485
|
// See https://github.com/microsoft/TypeScript/issues/5451
|
|
@@ -2475,15 +2487,15 @@ function pn(t, n) {
|
|
|
2475
2487
|
}
|
|
2476
2488
|
}
|
|
2477
2489
|
|
|
2478
|
-
/** Transforms a value into a server-generated timestamp. */ class
|
|
2490
|
+
/** Transforms a value into a server-generated timestamp. */ class gn extends _n {}
|
|
2479
2491
|
|
|
2480
|
-
/** Transforms an array value via a union operation. */ class
|
|
2492
|
+
/** Transforms an array value via a union operation. */ class vn extends _n {
|
|
2481
2493
|
constructor(t) {
|
|
2482
2494
|
super(), this.elements = t;
|
|
2483
2495
|
}
|
|
2484
2496
|
}
|
|
2485
2497
|
|
|
2486
|
-
/** Transforms an array value via a remove operation. */ class
|
|
2498
|
+
/** Transforms an array value via a remove operation. */ class bn extends _n {
|
|
2487
2499
|
constructor(t) {
|
|
2488
2500
|
super(), this.elements = t;
|
|
2489
2501
|
}
|
|
@@ -2494,7 +2506,7 @@ function pn(t, n) {
|
|
|
2494
2506
|
* transforms. Converts all field values to integers or doubles, but unlike the
|
|
2495
2507
|
* backend does not cap integer values at 2^63. Instead, JavaScript number
|
|
2496
2508
|
* arithmetic is used and precision loss can occur for values greater than 2^53.
|
|
2497
|
-
*/ class
|
|
2509
|
+
*/ class En extends _n {
|
|
2498
2510
|
constructor(t, n) {
|
|
2499
2511
|
super(), this.q = t, this.O = n;
|
|
2500
2512
|
}
|
|
@@ -2516,7 +2528,7 @@ function pn(t, n) {
|
|
|
2516
2528
|
* See the License for the specific language governing permissions and
|
|
2517
2529
|
* limitations under the License.
|
|
2518
2530
|
*/
|
|
2519
|
-
/** A field path and the TransformOperation to perform upon it. */ class
|
|
2531
|
+
/** A field path and the TransformOperation to perform upon it. */ class Tn {
|
|
2520
2532
|
constructor(t, n) {
|
|
2521
2533
|
this.field = t, this.transform = n;
|
|
2522
2534
|
}
|
|
@@ -2526,18 +2538,18 @@ function pn(t, n) {
|
|
|
2526
2538
|
* Encodes a precondition for a mutation. This follows the model that the
|
|
2527
2539
|
* backend accepts with the special case of an explicit "empty" precondition
|
|
2528
2540
|
* (meaning no precondition).
|
|
2529
|
-
*/ class
|
|
2541
|
+
*/ class In {
|
|
2530
2542
|
constructor(t, n) {
|
|
2531
2543
|
this.updateTime = t, this.exists = n;
|
|
2532
2544
|
}
|
|
2533
2545
|
/** Creates a new empty Precondition. */ static none() {
|
|
2534
|
-
return new
|
|
2546
|
+
return new In;
|
|
2535
2547
|
}
|
|
2536
2548
|
/** Creates a new Precondition with an exists flag. */ static exists(t) {
|
|
2537
|
-
return new
|
|
2549
|
+
return new In(void 0, t);
|
|
2538
2550
|
}
|
|
2539
2551
|
/** Creates a new Precondition based on a version a document exists at. */ static updateTime(t) {
|
|
2540
|
-
return new
|
|
2552
|
+
return new In(t);
|
|
2541
2553
|
}
|
|
2542
2554
|
/** Returns whether this Precondition is empty. */ get isNone() {
|
|
2543
2555
|
return void 0 === this.updateTime && void 0 === this.exists;
|
|
@@ -2590,12 +2602,12 @@ function pn(t, n) {
|
|
|
2590
2602
|
* applyToLocalView() to implement the actual behavior of applying the mutation
|
|
2591
2603
|
* to some source document (see `setMutationApplyToRemoteDocument()` for an
|
|
2592
2604
|
* example).
|
|
2593
|
-
*/ class
|
|
2605
|
+
*/ class An {}
|
|
2594
2606
|
|
|
2595
2607
|
/**
|
|
2596
2608
|
* A mutation that creates or replaces the document at the given key with the
|
|
2597
2609
|
* object value contents.
|
|
2598
|
-
*/ class
|
|
2610
|
+
*/ class Pn extends An {
|
|
2599
2611
|
constructor(t, n, e, r = []) {
|
|
2600
2612
|
super(), this.key = t, this.value = n, this.precondition = e, this.fieldTransforms = r,
|
|
2601
2613
|
this.type = 0 /* Set */;
|
|
@@ -2614,14 +2626,14 @@ function pn(t, n) {
|
|
|
2614
2626
|
* is deleted.
|
|
2615
2627
|
* * When a field is not in the mask but is in the values, the values map is
|
|
2616
2628
|
* ignored.
|
|
2617
|
-
*/ class
|
|
2629
|
+
*/ class Rn extends An {
|
|
2618
2630
|
constructor(t, n, e, r, s = []) {
|
|
2619
2631
|
super(), this.key = t, this.data = n, this.fieldMask = e, this.precondition = r,
|
|
2620
2632
|
this.fieldTransforms = s, this.type = 1 /* Patch */;
|
|
2621
2633
|
}
|
|
2622
2634
|
}
|
|
2623
2635
|
|
|
2624
|
-
/** A mutation that deletes the document at the given key. */ class
|
|
2636
|
+
/** A mutation that deletes the document at the given key. */ class Vn extends An {
|
|
2625
2637
|
constructor(t, n) {
|
|
2626
2638
|
super(), this.key = t, this.precondition = n, this.type = 2 /* Delete */ , this.fieldTransforms = [];
|
|
2627
2639
|
}
|
|
@@ -2633,7 +2645,7 @@ function pn(t, n) {
|
|
|
2633
2645
|
*
|
|
2634
2646
|
* The `verify` operation is only used in Transactions, and this class serves
|
|
2635
2647
|
* primarily to facilitate serialization into protos.
|
|
2636
|
-
*/ class
|
|
2648
|
+
*/ class Nn extends An {
|
|
2637
2649
|
constructor(t, n) {
|
|
2638
2650
|
super(), this.key = t, this.precondition = n, this.type = 3 /* Verify */ , this.fieldTransforms = [];
|
|
2639
2651
|
}
|
|
@@ -2654,13 +2666,13 @@ function pn(t, n) {
|
|
|
2654
2666
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2655
2667
|
* See the License for the specific language governing permissions and
|
|
2656
2668
|
* limitations under the License.
|
|
2657
|
-
*/ const
|
|
2669
|
+
*/ const Dn = (() => {
|
|
2658
2670
|
const t = {
|
|
2659
2671
|
asc: "ASCENDING",
|
|
2660
2672
|
desc: "DESCENDING"
|
|
2661
2673
|
};
|
|
2662
2674
|
return t;
|
|
2663
|
-
})(),
|
|
2675
|
+
})(), $n = (() => {
|
|
2664
2676
|
const t = {
|
|
2665
2677
|
"<": "LESS_THAN",
|
|
2666
2678
|
"<=": "LESS_THAN_OR_EQUAL",
|
|
@@ -2690,7 +2702,7 @@ function pn(t, n) {
|
|
|
2690
2702
|
* TODO(klimt): We can remove the databaseId argument if we keep the full
|
|
2691
2703
|
* resource name in documents.
|
|
2692
2704
|
*/
|
|
2693
|
-
class
|
|
2705
|
+
class Fn {
|
|
2694
2706
|
constructor(t, n) {
|
|
2695
2707
|
this.databaseId = t, this.S = n;
|
|
2696
2708
|
}
|
|
@@ -2707,7 +2719,7 @@ class $n {
|
|
|
2707
2719
|
/**
|
|
2708
2720
|
* Returns a value for a Date that's appropriate to put into a proto.
|
|
2709
2721
|
*/
|
|
2710
|
-
function
|
|
2722
|
+
function Sn(t, n) {
|
|
2711
2723
|
if (t.S) {
|
|
2712
2724
|
return `${new Date(1e3 * n.seconds).toISOString().replace(/\.\d*/, "").replace("Z", "")}.${("000000000" + n.nanoseconds).slice(-9)}Z`;
|
|
2713
2725
|
}
|
|
@@ -2722,129 +2734,129 @@ function Fn(t, n) {
|
|
|
2722
2734
|
*
|
|
2723
2735
|
* Visible for testing.
|
|
2724
2736
|
*/
|
|
2725
|
-
function
|
|
2737
|
+
function xn(t, n) {
|
|
2726
2738
|
return t.S ? n.toBase64() : n.toUint8Array();
|
|
2727
2739
|
}
|
|
2728
2740
|
|
|
2729
2741
|
function qn(t, n) {
|
|
2730
|
-
return
|
|
2742
|
+
return Sn(t, n.toTimestamp());
|
|
2731
2743
|
}
|
|
2732
2744
|
|
|
2733
|
-
function
|
|
2734
|
-
return
|
|
2735
|
-
const n =
|
|
2736
|
-
return new
|
|
2745
|
+
function On(t) {
|
|
2746
|
+
return b(!!t), bt.fromTimestamp(function(t) {
|
|
2747
|
+
const n = Vt(t);
|
|
2748
|
+
return new vt(n.seconds, n.nanos);
|
|
2737
2749
|
}(t));
|
|
2738
2750
|
}
|
|
2739
2751
|
|
|
2740
|
-
function
|
|
2752
|
+
function Cn(t, n) {
|
|
2741
2753
|
return function(t) {
|
|
2742
|
-
return new
|
|
2754
|
+
return new Z([ "projects", t.projectId, "databases", t.database ]);
|
|
2743
2755
|
}(t).child("documents").child(n).canonicalString();
|
|
2744
2756
|
}
|
|
2745
2757
|
|
|
2746
|
-
function
|
|
2747
|
-
return
|
|
2758
|
+
function Ln(t, n) {
|
|
2759
|
+
return Cn(t.databaseId, n.path);
|
|
2748
2760
|
}
|
|
2749
2761
|
|
|
2750
|
-
function
|
|
2762
|
+
function kn(t, n) {
|
|
2751
2763
|
const e = function(t) {
|
|
2752
|
-
const n =
|
|
2753
|
-
return
|
|
2764
|
+
const n = Z.fromString(t);
|
|
2765
|
+
return b(Jn(n)), n;
|
|
2754
2766
|
}(n);
|
|
2755
|
-
if (e.get(1) !== t.databaseId.projectId) throw new
|
|
2756
|
-
if (e.get(3) !== t.databaseId.database) throw new
|
|
2757
|
-
return new
|
|
2767
|
+
if (e.get(1) !== t.databaseId.projectId) throw new U(P, "Tried to deserialize key from different project: " + e.get(1) + " vs " + t.databaseId.projectId);
|
|
2768
|
+
if (e.get(3) !== t.databaseId.database) throw new U(P, "Tried to deserialize key from different database: " + e.get(3) + " vs " + t.databaseId.database);
|
|
2769
|
+
return new et((b((r = e).length > 4 && "documents" === r.get(4)), r.popFirst(5)));
|
|
2758
2770
|
var r;
|
|
2759
2771
|
/** Creates a Document proto from key and fields (but no create/update time) */}
|
|
2760
2772
|
|
|
2761
|
-
function
|
|
2762
|
-
return
|
|
2773
|
+
function Un(t, n) {
|
|
2774
|
+
return Cn(t.databaseId, n);
|
|
2763
2775
|
}
|
|
2764
2776
|
|
|
2765
|
-
function
|
|
2766
|
-
return new
|
|
2777
|
+
function jn(t) {
|
|
2778
|
+
return new Z([ "projects", t.databaseId.projectId, "databases", t.databaseId.database ]).canonicalString();
|
|
2767
2779
|
}
|
|
2768
2780
|
|
|
2769
|
-
function
|
|
2781
|
+
function Mn(t, n, e) {
|
|
2770
2782
|
return {
|
|
2771
|
-
name:
|
|
2783
|
+
name: Ln(t, n),
|
|
2772
2784
|
fields: e.value.mapValue.fields
|
|
2773
2785
|
};
|
|
2774
2786
|
}
|
|
2775
2787
|
|
|
2776
|
-
function
|
|
2788
|
+
function Bn(t, n) {
|
|
2777
2789
|
return "found" in n ? function(t, n) {
|
|
2778
|
-
|
|
2779
|
-
const e =
|
|
2790
|
+
b(!!n.found), n.found.name, n.found.updateTime;
|
|
2791
|
+
const e = kn(t, n.found.name), r = On(n.found.updateTime), s = new Qt({
|
|
2780
2792
|
mapValue: {
|
|
2781
2793
|
fields: n.found.fields
|
|
2782
2794
|
}
|
|
2783
2795
|
});
|
|
2784
|
-
return
|
|
2796
|
+
return Gt.newFoundDocument(e, r, s);
|
|
2785
2797
|
}(t, n) : "missing" in n ? function(t, n) {
|
|
2786
|
-
|
|
2787
|
-
const e =
|
|
2788
|
-
return
|
|
2789
|
-
}(t, n) :
|
|
2798
|
+
b(!!n.missing), b(!!n.readTime);
|
|
2799
|
+
const e = kn(t, n.missing), r = On(n.readTime);
|
|
2800
|
+
return Gt.newNoDocument(e, r);
|
|
2801
|
+
}(t, n) : v();
|
|
2790
2802
|
}
|
|
2791
2803
|
|
|
2792
|
-
function
|
|
2804
|
+
function zn(t, n) {
|
|
2793
2805
|
let e;
|
|
2794
|
-
if (n instanceof
|
|
2795
|
-
update:
|
|
2806
|
+
if (n instanceof Pn) e = {
|
|
2807
|
+
update: Mn(t, n.key, n.value)
|
|
2808
|
+
}; else if (n instanceof Vn) e = {
|
|
2809
|
+
delete: Ln(t, n.key)
|
|
2796
2810
|
}; else if (n instanceof Rn) e = {
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
update: jn(t, n.key, n.data),
|
|
2800
|
-
updateMask: Hn(n.fieldMask)
|
|
2811
|
+
update: Mn(t, n.key, n.data),
|
|
2812
|
+
updateMask: Kn(n.fieldMask)
|
|
2801
2813
|
}; else {
|
|
2802
|
-
if (!(n instanceof
|
|
2814
|
+
if (!(n instanceof Nn)) return v();
|
|
2803
2815
|
e = {
|
|
2804
|
-
verify:
|
|
2816
|
+
verify: Ln(t, n.key)
|
|
2805
2817
|
};
|
|
2806
2818
|
}
|
|
2807
2819
|
return n.fieldTransforms.length > 0 && (e.updateTransforms = n.fieldTransforms.map((t => function(t, n) {
|
|
2808
2820
|
const e = n.transform;
|
|
2809
|
-
if (e instanceof
|
|
2821
|
+
if (e instanceof gn) return {
|
|
2810
2822
|
fieldPath: n.field.canonicalString(),
|
|
2811
2823
|
setToServerValue: "REQUEST_TIME"
|
|
2812
2824
|
};
|
|
2813
|
-
if (e instanceof
|
|
2825
|
+
if (e instanceof vn) return {
|
|
2814
2826
|
fieldPath: n.field.canonicalString(),
|
|
2815
2827
|
appendMissingElements: {
|
|
2816
2828
|
values: e.elements
|
|
2817
2829
|
}
|
|
2818
2830
|
};
|
|
2819
|
-
if (e instanceof
|
|
2831
|
+
if (e instanceof bn) return {
|
|
2820
2832
|
fieldPath: n.field.canonicalString(),
|
|
2821
2833
|
removeAllFromArray: {
|
|
2822
2834
|
values: e.elements
|
|
2823
2835
|
}
|
|
2824
2836
|
};
|
|
2825
|
-
if (e instanceof
|
|
2837
|
+
if (e instanceof En) return {
|
|
2826
2838
|
fieldPath: n.field.canonicalString(),
|
|
2827
2839
|
increment: e.O
|
|
2828
2840
|
};
|
|
2829
|
-
throw
|
|
2841
|
+
throw v();
|
|
2830
2842
|
}(0, t)))), n.precondition.isNone || (e.currentDocument = function(t, n) {
|
|
2831
2843
|
return void 0 !== n.updateTime ? {
|
|
2832
2844
|
updateTime: qn(t, n.updateTime)
|
|
2833
2845
|
} : void 0 !== n.exists ? {
|
|
2834
2846
|
exists: n.exists
|
|
2835
|
-
} :
|
|
2847
|
+
} : v();
|
|
2836
2848
|
}(t, n.precondition)), e;
|
|
2837
2849
|
}
|
|
2838
2850
|
|
|
2839
|
-
function
|
|
2851
|
+
function Qn(t, n) {
|
|
2840
2852
|
// Dissect the path into parent, collectionId, and optional key filter.
|
|
2841
2853
|
const e = {
|
|
2842
2854
|
structuredQuery: {}
|
|
2843
2855
|
}, r = n.path;
|
|
2844
|
-
null !== n.collectionGroup ? (e.parent =
|
|
2856
|
+
null !== n.collectionGroup ? (e.parent = Un(t, r), e.structuredQuery.from = [ {
|
|
2845
2857
|
collectionId: n.collectionGroup,
|
|
2846
2858
|
allDescendants: !0
|
|
2847
|
-
} ]) : (e.parent =
|
|
2859
|
+
} ]) : (e.parent = Un(t, r.popLast()), e.structuredQuery.from = [ {
|
|
2848
2860
|
collectionId: r.lastSegment()
|
|
2849
2861
|
} ]);
|
|
2850
2862
|
const s = function(t) {
|
|
@@ -2853,36 +2865,36 @@ function zn(t, n) {
|
|
|
2853
2865
|
// visible for testing
|
|
2854
2866
|
function(t) {
|
|
2855
2867
|
if ("==" /* EQUAL */ === t.op) {
|
|
2856
|
-
if (
|
|
2868
|
+
if (Mt(t.value)) return {
|
|
2857
2869
|
unaryFilter: {
|
|
2858
|
-
field:
|
|
2870
|
+
field: Hn(t.field),
|
|
2859
2871
|
op: "IS_NAN"
|
|
2860
2872
|
}
|
|
2861
2873
|
};
|
|
2862
|
-
if (
|
|
2874
|
+
if (jt(t.value)) return {
|
|
2863
2875
|
unaryFilter: {
|
|
2864
|
-
field:
|
|
2876
|
+
field: Hn(t.field),
|
|
2865
2877
|
op: "IS_NULL"
|
|
2866
2878
|
}
|
|
2867
2879
|
};
|
|
2868
2880
|
} else if ("!=" /* NOT_EQUAL */ === t.op) {
|
|
2869
|
-
if (
|
|
2881
|
+
if (Mt(t.value)) return {
|
|
2870
2882
|
unaryFilter: {
|
|
2871
|
-
field:
|
|
2883
|
+
field: Hn(t.field),
|
|
2872
2884
|
op: "IS_NOT_NAN"
|
|
2873
2885
|
}
|
|
2874
2886
|
};
|
|
2875
|
-
if (
|
|
2887
|
+
if (jt(t.value)) return {
|
|
2876
2888
|
unaryFilter: {
|
|
2877
|
-
field:
|
|
2889
|
+
field: Hn(t.field),
|
|
2878
2890
|
op: "IS_NOT_NULL"
|
|
2879
2891
|
}
|
|
2880
2892
|
};
|
|
2881
2893
|
}
|
|
2882
2894
|
return {
|
|
2883
2895
|
fieldFilter: {
|
|
2884
|
-
field:
|
|
2885
|
-
op:
|
|
2896
|
+
field: Hn(t.field),
|
|
2897
|
+
op: Yn(t.op),
|
|
2886
2898
|
value: t.value
|
|
2887
2899
|
}
|
|
2888
2900
|
};
|
|
@@ -2902,52 +2914,52 @@ function zn(t, n) {
|
|
|
2902
2914
|
// visible for testing
|
|
2903
2915
|
function(t) {
|
|
2904
2916
|
return {
|
|
2905
|
-
field:
|
|
2906
|
-
direction:
|
|
2917
|
+
field: Hn(t.field),
|
|
2918
|
+
direction: Wn(t.dir)
|
|
2907
2919
|
};
|
|
2908
2920
|
}(t)));
|
|
2909
2921
|
}(n.orderBy);
|
|
2910
2922
|
i && (e.structuredQuery.orderBy = i);
|
|
2911
2923
|
const o = function(t, n) {
|
|
2912
|
-
return t.S ||
|
|
2924
|
+
return t.S || at(n) ? n : {
|
|
2913
2925
|
value: n
|
|
2914
2926
|
};
|
|
2915
2927
|
}(t, n.limit);
|
|
2916
|
-
return null !== o && (e.structuredQuery.limit = o), n.startAt && (e.structuredQuery.startAt =
|
|
2917
|
-
n.endAt && (e.structuredQuery.endAt =
|
|
2928
|
+
return null !== o && (e.structuredQuery.limit = o), n.startAt && (e.structuredQuery.startAt = Gn(n.startAt)),
|
|
2929
|
+
n.endAt && (e.structuredQuery.endAt = Gn(n.endAt)), e;
|
|
2918
2930
|
}
|
|
2919
2931
|
|
|
2920
|
-
function
|
|
2932
|
+
function Gn(t) {
|
|
2921
2933
|
return {
|
|
2922
2934
|
before: t.before,
|
|
2923
2935
|
values: t.position
|
|
2924
2936
|
};
|
|
2925
2937
|
}
|
|
2926
2938
|
|
|
2927
|
-
// visible for testing
|
|
2928
|
-
function Gn(t) {
|
|
2929
|
-
return Nn[t];
|
|
2930
|
-
}
|
|
2931
|
-
|
|
2932
2939
|
// visible for testing
|
|
2933
2940
|
function Wn(t) {
|
|
2934
2941
|
return Dn[t];
|
|
2935
2942
|
}
|
|
2936
2943
|
|
|
2944
|
+
// visible for testing
|
|
2937
2945
|
function Yn(t) {
|
|
2946
|
+
return $n[t];
|
|
2947
|
+
}
|
|
2948
|
+
|
|
2949
|
+
function Hn(t) {
|
|
2938
2950
|
return {
|
|
2939
2951
|
fieldPath: t.canonicalString()
|
|
2940
2952
|
};
|
|
2941
2953
|
}
|
|
2942
2954
|
|
|
2943
|
-
function
|
|
2955
|
+
function Kn(t) {
|
|
2944
2956
|
const n = [];
|
|
2945
2957
|
return t.fields.forEach((t => n.push(t.canonicalString()))), {
|
|
2946
2958
|
fieldPaths: n
|
|
2947
2959
|
};
|
|
2948
2960
|
}
|
|
2949
2961
|
|
|
2950
|
-
function
|
|
2962
|
+
function Jn(t) {
|
|
2951
2963
|
// Resource names have at least 4 components (project ID, database ID)
|
|
2952
2964
|
return t.length >= 4 && "projects" === t.get(0) && "databases" === t.get(2);
|
|
2953
2965
|
}
|
|
@@ -2967,8 +2979,8 @@ function Kn(t) {
|
|
|
2967
2979
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2968
2980
|
* See the License for the specific language governing permissions and
|
|
2969
2981
|
* limitations under the License.
|
|
2970
|
-
*/ function
|
|
2971
|
-
return new
|
|
2982
|
+
*/ function Xn(t) {
|
|
2983
|
+
return new Fn(t, /* useProto3Json= */ !0);
|
|
2972
2984
|
}
|
|
2973
2985
|
|
|
2974
2986
|
/**
|
|
@@ -2996,7 +3008,7 @@ function Kn(t) {
|
|
|
2996
3008
|
* base delay. This prevents clients from accidentally synchronizing their
|
|
2997
3009
|
* delays causing spikes of load to the backend.
|
|
2998
3010
|
*/
|
|
2999
|
-
class
|
|
3011
|
+
class Zn {
|
|
3000
3012
|
constructor(
|
|
3001
3013
|
/**
|
|
3002
3014
|
* The AsyncQueue to run backoff operations on.
|
|
@@ -3051,7 +3063,7 @@ class Xn {
|
|
|
3051
3063
|
// honored as such).
|
|
3052
3064
|
const n = Math.floor(this.j + this.Y()), e = Math.max(0, Date.now() - this.B), r = Math.max(0, n - e);
|
|
3053
3065
|
// Guard against lastAttemptTime being in the future due to a clock change.
|
|
3054
|
-
r > 0 &&
|
|
3066
|
+
r > 0 && p("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.j} ms, delay with jitter: ${n} ms, last attempt: ${e} ms ago)`),
|
|
3055
3067
|
this.M = this.C.enqueueAfterDelay(this.timerId, r, (() => (this.B = Date.now(),
|
|
3056
3068
|
t()))),
|
|
3057
3069
|
// Apply backoff factor to determine next delay and ensure it is within
|
|
@@ -3094,24 +3106,24 @@ class Xn {
|
|
|
3094
3106
|
* An implementation of Datastore that exposes additional state for internal
|
|
3095
3107
|
* consumption.
|
|
3096
3108
|
*/
|
|
3097
|
-
class
|
|
3109
|
+
class te extends class {} {
|
|
3098
3110
|
constructor(t, n, e, r) {
|
|
3099
3111
|
super(), this.authCredentials = t, this.appCheckCredentials = n, this.K = e, this.q = r,
|
|
3100
3112
|
this.J = !1;
|
|
3101
3113
|
}
|
|
3102
3114
|
X() {
|
|
3103
|
-
if (this.J) throw new
|
|
3115
|
+
if (this.J) throw new U(S, "The client has already been terminated.");
|
|
3104
3116
|
}
|
|
3105
3117
|
/** Invokes the provided RPC with auth and AppCheck tokens. */ m(t, n, e) {
|
|
3106
3118
|
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.m(t, n, e, r, s))).catch((t => {
|
|
3107
|
-
throw "FirebaseError" === t.name ? (t.code ===
|
|
3108
|
-
this.appCheckCredentials.invalidateToken()), t) : new
|
|
3119
|
+
throw "FirebaseError" === t.name ? (t.code === $ && (this.authCredentials.invalidateToken(),
|
|
3120
|
+
this.appCheckCredentials.invalidateToken()), t) : new U(A, t.toString());
|
|
3109
3121
|
}));
|
|
3110
3122
|
}
|
|
3111
3123
|
/** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */ T(t, n, e) {
|
|
3112
3124
|
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.T(t, n, e, r, s))).catch((t => {
|
|
3113
|
-
throw "FirebaseError" === t.name ? (t.code ===
|
|
3114
|
-
this.appCheckCredentials.invalidateToken()), t) : new
|
|
3125
|
+
throw "FirebaseError" === t.name ? (t.code === $ && (this.authCredentials.invalidateToken(),
|
|
3126
|
+
this.appCheckCredentials.invalidateToken()), t) : new U(A, t.toString());
|
|
3115
3127
|
}));
|
|
3116
3128
|
}
|
|
3117
3129
|
terminate() {
|
|
@@ -3121,38 +3133,38 @@ class Zn extends class {} {
|
|
|
3121
3133
|
|
|
3122
3134
|
// TODO(firestorexp): Make sure there is only one Datastore instance per
|
|
3123
3135
|
// firestore-exp client.
|
|
3124
|
-
async function
|
|
3125
|
-
const e =
|
|
3126
|
-
writes: n.map((t =>
|
|
3136
|
+
async function ne(t, n) {
|
|
3137
|
+
const e = E(t), r = jn(e.q) + "/documents", s = {
|
|
3138
|
+
writes: n.map((t => zn(e.q, t)))
|
|
3127
3139
|
};
|
|
3128
3140
|
await e.m("Commit", r, s);
|
|
3129
3141
|
}
|
|
3130
3142
|
|
|
3131
|
-
async function
|
|
3132
|
-
const e =
|
|
3133
|
-
documents: n.map((t =>
|
|
3143
|
+
async function ee(t, n) {
|
|
3144
|
+
const e = E(t), r = jn(e.q) + "/documents", s = {
|
|
3145
|
+
documents: n.map((t => Ln(e.q, t)))
|
|
3134
3146
|
}, i = await e.T("BatchGetDocuments", r, s), o = new Map;
|
|
3135
3147
|
i.forEach((t => {
|
|
3136
|
-
const n =
|
|
3148
|
+
const n = Bn(e.q, t);
|
|
3137
3149
|
o.set(n.key.toString(), n);
|
|
3138
3150
|
}));
|
|
3139
3151
|
const u = [];
|
|
3140
3152
|
return n.forEach((t => {
|
|
3141
3153
|
const n = o.get(t.toString());
|
|
3142
|
-
|
|
3154
|
+
b(!!n), u.push(n);
|
|
3143
3155
|
})), u;
|
|
3144
3156
|
}
|
|
3145
3157
|
|
|
3146
|
-
async function
|
|
3147
|
-
const e =
|
|
3158
|
+
async function re(t, n) {
|
|
3159
|
+
const e = E(t), r = Qn(e.q, mn(n));
|
|
3148
3160
|
return (await e.T("RunQuery", r.parent, {
|
|
3149
3161
|
structuredQuery: r.structuredQuery
|
|
3150
3162
|
})).filter((t => !!t.document)).map((t => function(t, n, e) {
|
|
3151
|
-
const r =
|
|
3163
|
+
const r = kn(t, n.name), s = On(n.updateTime), i = new Qt({
|
|
3152
3164
|
mapValue: {
|
|
3153
3165
|
fields: n.fields
|
|
3154
3166
|
}
|
|
3155
|
-
}), o =
|
|
3167
|
+
}), o = Gt.newFoundDocument(r, s, i);
|
|
3156
3168
|
return e && o.setHasCommittedMutations(), e ? o.setHasCommittedMutations() : o;
|
|
3157
3169
|
}(e.q, t.document, void 0)));
|
|
3158
3170
|
}
|
|
@@ -3172,7 +3184,7 @@ async function ee(t, n) {
|
|
|
3172
3184
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3173
3185
|
* See the License for the specific language governing permissions and
|
|
3174
3186
|
* limitations under the License.
|
|
3175
|
-
*/ const
|
|
3187
|
+
*/ const se = new Map;
|
|
3176
3188
|
|
|
3177
3189
|
/**
|
|
3178
3190
|
* An instance map that ensures only one Datastore exists per Firestore
|
|
@@ -3183,17 +3195,17 @@ async function ee(t, n) {
|
|
|
3183
3195
|
* instance. Callers must invoke removeComponents() when the Firestore
|
|
3184
3196
|
* instance is terminated.
|
|
3185
3197
|
*/
|
|
3186
|
-
function
|
|
3187
|
-
if (t._terminated) throw new
|
|
3188
|
-
if (!
|
|
3189
|
-
|
|
3198
|
+
function ie(t) {
|
|
3199
|
+
if (t._terminated) throw new U(S, "The client has already been terminated.");
|
|
3200
|
+
if (!se.has(t)) {
|
|
3201
|
+
p("ComponentProvider", "Initializing Datastore");
|
|
3190
3202
|
const i = function(t) {
|
|
3191
|
-
return new
|
|
3203
|
+
return new mt(t, fetch.bind(null));
|
|
3192
3204
|
}((n = t._databaseId, e = t.app.options.appId || "", r = t._persistenceKey, s = t._freezeSettings(),
|
|
3193
|
-
new
|
|
3194
|
-
return new
|
|
3205
|
+
new K(n, e, r, s.host, s.ssl, s.experimentalForceLongPolling, s.experimentalAutoDetectLongPolling, s.useFetchStreams))), o = Xn(t._databaseId), u = function(t, n, e, r) {
|
|
3206
|
+
return new te(t, n, e, r);
|
|
3195
3207
|
}(t._authCredentials, t._appCheckCredentials, i, o);
|
|
3196
|
-
|
|
3208
|
+
se.set(t, u);
|
|
3197
3209
|
}
|
|
3198
3210
|
var n, e, r, s;
|
|
3199
3211
|
/**
|
|
@@ -3211,7 +3223,7 @@ function se(t) {
|
|
|
3211
3223
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3212
3224
|
* See the License for the specific language governing permissions and
|
|
3213
3225
|
* limitations under the License.
|
|
3214
|
-
*/ return
|
|
3226
|
+
*/ return se.get(t);
|
|
3215
3227
|
}
|
|
3216
3228
|
|
|
3217
3229
|
/**
|
|
@@ -3223,21 +3235,21 @@ function se(t) {
|
|
|
3223
3235
|
* user-supplied `FirestoreSettings` object. This is a separate type so that
|
|
3224
3236
|
* defaults can be supplied and the value can be checked for equality.
|
|
3225
3237
|
*/
|
|
3226
|
-
class
|
|
3238
|
+
class oe {
|
|
3227
3239
|
constructor(t) {
|
|
3228
3240
|
var n;
|
|
3229
3241
|
if (void 0 === t.host) {
|
|
3230
|
-
if (void 0 !== t.ssl) throw new
|
|
3242
|
+
if (void 0 !== t.ssl) throw new U(P, "Can't provide ssl option if host option is not set");
|
|
3231
3243
|
this.host = "firestore.googleapis.com", this.ssl = true;
|
|
3232
3244
|
} else this.host = t.host, this.ssl = null === (n = t.ssl) || void 0 === n || n;
|
|
3233
3245
|
if (this.credentials = t.credentials, this.ignoreUndefinedProperties = !!t.ignoreUndefinedProperties,
|
|
3234
3246
|
void 0 === t.cacheSizeBytes) this.cacheSizeBytes = 41943040; else {
|
|
3235
|
-
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new
|
|
3247
|
+
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new U(P, "cacheSizeBytes must be at least 1048576");
|
|
3236
3248
|
this.cacheSizeBytes = t.cacheSizeBytes;
|
|
3237
3249
|
}
|
|
3238
3250
|
this.experimentalForceLongPolling = !!t.experimentalForceLongPolling, this.experimentalAutoDetectLongPolling = !!t.experimentalAutoDetectLongPolling,
|
|
3239
3251
|
this.useFetchStreams = !!t.useFetchStreams, function(t, n, e, r) {
|
|
3240
|
-
if (!0 === n && !0 === r) throw new
|
|
3252
|
+
if (!0 === n && !0 === r) throw new U(P, `${t} and ${e} cannot be used together.`);
|
|
3241
3253
|
}("experimentalForceLongPolling", t.experimentalForceLongPolling, "experimentalAutoDetectLongPolling", t.experimentalAutoDetectLongPolling);
|
|
3242
3254
|
}
|
|
3243
3255
|
isEqual(t) {
|
|
@@ -3265,18 +3277,18 @@ class ie {
|
|
|
3265
3277
|
* The Cloud Firestore service interface.
|
|
3266
3278
|
*
|
|
3267
3279
|
* Do not call this constructor directly. Instead, use {@link getFirestore}.
|
|
3268
|
-
*/ class
|
|
3280
|
+
*/ class ue {
|
|
3269
3281
|
/** @hideconstructor */
|
|
3270
3282
|
constructor(t, n, e) {
|
|
3271
3283
|
this._authCredentials = n, this._appCheckCredentials = e,
|
|
3272
3284
|
/**
|
|
3273
3285
|
* Whether it's a Firestore or Firestore Lite instance.
|
|
3274
3286
|
*/
|
|
3275
|
-
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new
|
|
3276
|
-
this._settingsFrozen = !1, t instanceof
|
|
3287
|
+
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new oe({}),
|
|
3288
|
+
this._settingsFrozen = !1, t instanceof J ? this._databaseId = t : (this._app = t,
|
|
3277
3289
|
this._databaseId = function(t) {
|
|
3278
|
-
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new
|
|
3279
|
-
return new
|
|
3290
|
+
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new U(P, '"projectId" not provided in firebase.initializeApp.');
|
|
3291
|
+
return new J(t.options.projectId);
|
|
3280
3292
|
}
|
|
3281
3293
|
/**
|
|
3282
3294
|
* Initializes a new instance of Cloud Firestore with the provided settings.
|
|
@@ -3294,7 +3306,7 @@ class ie {
|
|
|
3294
3306
|
* The {@link @firebase/app#FirebaseApp} associated with this `Firestore` service
|
|
3295
3307
|
* instance.
|
|
3296
3308
|
*/ get app() {
|
|
3297
|
-
if (!this._app) throw new
|
|
3309
|
+
if (!this._app) throw new U(S, "Firestore was not initialized using the Firebase SDK. 'app' is not available");
|
|
3298
3310
|
return this._app;
|
|
3299
3311
|
}
|
|
3300
3312
|
get _initialized() {
|
|
@@ -3304,21 +3316,21 @@ class ie {
|
|
|
3304
3316
|
return void 0 !== this._terminateTask;
|
|
3305
3317
|
}
|
|
3306
3318
|
_setSettings(t) {
|
|
3307
|
-
if (this._settingsFrozen) throw new
|
|
3308
|
-
this._settings = new
|
|
3309
|
-
if (!t) return new
|
|
3319
|
+
if (this._settingsFrozen) throw new U(S, "Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");
|
|
3320
|
+
this._settings = new oe(t), void 0 !== t.credentials && (this._authCredentials = function(t) {
|
|
3321
|
+
if (!t) return new B;
|
|
3310
3322
|
switch (t.type) {
|
|
3311
3323
|
case "gapi":
|
|
3312
3324
|
const n = t.client;
|
|
3313
3325
|
// Make sure this really is a Gapi client.
|
|
3314
|
-
return
|
|
3315
|
-
new
|
|
3326
|
+
return b(!("object" != typeof n || null === n || !n.auth || !n.auth.getAuthHeaderValueForFirstParty)),
|
|
3327
|
+
new W(n, t.sessionIndex || "0", t.iamToken || null);
|
|
3316
3328
|
|
|
3317
3329
|
case "provider":
|
|
3318
3330
|
return t.client;
|
|
3319
3331
|
|
|
3320
3332
|
default:
|
|
3321
|
-
throw new
|
|
3333
|
+
throw new U(P, "makeAuthCredentialsProvider failed due to invalid credential type");
|
|
3322
3334
|
}
|
|
3323
3335
|
}(t.credentials));
|
|
3324
3336
|
}
|
|
@@ -3346,15 +3358,15 @@ class ie {
|
|
|
3346
3358
|
* Only ever called once.
|
|
3347
3359
|
*/ _terminate() {
|
|
3348
3360
|
return function(t) {
|
|
3349
|
-
const n =
|
|
3350
|
-
n && (
|
|
3361
|
+
const n = se.get(t);
|
|
3362
|
+
n && (p("ComponentProvider", "Removing Datastore"), se.delete(t), n.terminate());
|
|
3351
3363
|
}(this), Promise.resolve();
|
|
3352
3364
|
}
|
|
3353
3365
|
}
|
|
3354
3366
|
|
|
3355
|
-
function
|
|
3367
|
+
function ce(t, n) {
|
|
3356
3368
|
const e = _getProvider(t, "firestore/lite");
|
|
3357
|
-
if (e.isInitialized()) throw new
|
|
3369
|
+
if (e.isInitialized()) throw new U(S, "Firestore can only be initialized once per app.");
|
|
3358
3370
|
return e.initialize({
|
|
3359
3371
|
options: n
|
|
3360
3372
|
});
|
|
@@ -3368,7 +3380,7 @@ function ue(t, n) {
|
|
|
3368
3380
|
* @param app - The {@link @firebase/app#FirebaseApp} instance that the returned `Firestore`
|
|
3369
3381
|
* instance is associated with.
|
|
3370
3382
|
* @returns The `Firestore` instance of the provided app.
|
|
3371
|
-
*/ function
|
|
3383
|
+
*/ function ae(n = t()) {
|
|
3372
3384
|
return _getProvider(n, "firestore/lite").getImmediate();
|
|
3373
3385
|
}
|
|
3374
3386
|
|
|
@@ -3384,24 +3396,24 @@ function ue(t, n) {
|
|
|
3384
3396
|
* @param port - the emulator port (ex: 9000).
|
|
3385
3397
|
* @param options.mockUserToken - the mock auth token to use for unit testing
|
|
3386
3398
|
* Security Rules.
|
|
3387
|
-
*/ function
|
|
3399
|
+
*/ function he(t, n, e, r = {}) {
|
|
3388
3400
|
var s;
|
|
3389
|
-
const i = (t =
|
|
3390
|
-
if ("firestore.googleapis.com" !== i.host && i.host !== n &&
|
|
3401
|
+
const i = (t = ut(t, ue))._getSettings();
|
|
3402
|
+
if ("firestore.googleapis.com" !== i.host && i.host !== n && _("Host has been set in both settings() and useEmulator(), emulator host will be used"),
|
|
3391
3403
|
t._setSettings(Object.assign(Object.assign({}, i), {
|
|
3392
3404
|
host: `${n}:${e}`,
|
|
3393
3405
|
ssl: !1
|
|
3394
3406
|
})), r.mockUserToken) {
|
|
3395
3407
|
let n, e;
|
|
3396
|
-
if ("string" == typeof r.mockUserToken) n = r.mockUserToken, e =
|
|
3408
|
+
if ("string" == typeof r.mockUserToken) n = r.mockUserToken, e = f.MOCK_USER; else {
|
|
3397
3409
|
// Let createMockUserToken validate first (catches common mistakes like
|
|
3398
3410
|
// invalid field "uid" and missing field "sub" / "user_id".)
|
|
3399
|
-
n =
|
|
3411
|
+
n = h(r.mockUserToken, null === (s = t._app) || void 0 === s ? void 0 : s.options.projectId);
|
|
3400
3412
|
const i = r.mockUserToken.sub || r.mockUserToken.user_id;
|
|
3401
|
-
if (!i) throw new
|
|
3402
|
-
e = new
|
|
3413
|
+
if (!i) throw new U(P, "mockUserToken must contain 'sub' or 'user_id' field!");
|
|
3414
|
+
e = new f(i);
|
|
3403
3415
|
}
|
|
3404
|
-
t._authCredentials = new
|
|
3416
|
+
t._authCredentials = new z(new M(n, e));
|
|
3405
3417
|
}
|
|
3406
3418
|
}
|
|
3407
3419
|
|
|
@@ -3424,8 +3436,8 @@ function ue(t, n) {
|
|
|
3424
3436
|
* @param firestore - The `Firestore` instance to terminate.
|
|
3425
3437
|
* @returns A `Promise` that is resolved when the instance has been successfully
|
|
3426
3438
|
* terminated.
|
|
3427
|
-
*/ function
|
|
3428
|
-
return t =
|
|
3439
|
+
*/ function le(t) {
|
|
3440
|
+
return t = ut(t, ue), n(t.app, "firestore/lite"), t._delete();
|
|
3429
3441
|
}
|
|
3430
3442
|
|
|
3431
3443
|
/**
|
|
@@ -3465,7 +3477,7 @@ function ue(t, n) {
|
|
|
3465
3477
|
* and can be used to write, read, or listen to the location. The document at
|
|
3466
3478
|
* the referenced location may or may not exist.
|
|
3467
3479
|
*/
|
|
3468
|
-
class
|
|
3480
|
+
class fe {
|
|
3469
3481
|
/** @hideconstructor */
|
|
3470
3482
|
constructor(t,
|
|
3471
3483
|
/**
|
|
@@ -3493,17 +3505,17 @@ class le {
|
|
|
3493
3505
|
/**
|
|
3494
3506
|
* The collection this `DocumentReference` belongs to.
|
|
3495
3507
|
*/ get parent() {
|
|
3496
|
-
return new
|
|
3508
|
+
return new we(this.firestore, this.converter, this._key.path.popLast());
|
|
3497
3509
|
}
|
|
3498
3510
|
withConverter(t) {
|
|
3499
|
-
return new
|
|
3511
|
+
return new fe(this.firestore, t, this._key);
|
|
3500
3512
|
}
|
|
3501
3513
|
}
|
|
3502
3514
|
|
|
3503
3515
|
/**
|
|
3504
3516
|
* A `Query` refers to a query which you can read or listen to. You can also
|
|
3505
3517
|
* construct refined `Query` objects by adding filters and ordering.
|
|
3506
|
-
*/ class
|
|
3518
|
+
*/ class de {
|
|
3507
3519
|
// This is the lite version of the Query class in the main SDK.
|
|
3508
3520
|
/** @hideconstructor protected */
|
|
3509
3521
|
constructor(t,
|
|
@@ -3516,17 +3528,17 @@ class le {
|
|
|
3516
3528
|
this.type = "query", this.firestore = t;
|
|
3517
3529
|
}
|
|
3518
3530
|
withConverter(t) {
|
|
3519
|
-
return new
|
|
3531
|
+
return new de(this.firestore, t, this._query);
|
|
3520
3532
|
}
|
|
3521
3533
|
}
|
|
3522
3534
|
|
|
3523
3535
|
/**
|
|
3524
3536
|
* A `CollectionReference` object can be used for adding documents, getting
|
|
3525
3537
|
* document references, and querying for documents (using {@link query}).
|
|
3526
|
-
*/ class
|
|
3538
|
+
*/ class we extends de {
|
|
3527
3539
|
/** @hideconstructor */
|
|
3528
3540
|
constructor(t, n, e) {
|
|
3529
|
-
super(t, n, new
|
|
3541
|
+
super(t, n, new an(e)), this._path = e,
|
|
3530
3542
|
/** The type of this Firestore reference. */
|
|
3531
3543
|
this.type = "collection";
|
|
3532
3544
|
}
|
|
@@ -3544,23 +3556,23 @@ class le {
|
|
|
3544
3556
|
* subcollection. If this isn't a subcollection, the reference is null.
|
|
3545
3557
|
*/ get parent() {
|
|
3546
3558
|
const t = this._path.popLast();
|
|
3547
|
-
return t.isEmpty() ? null : new
|
|
3548
|
-
/* converter= */ null, new
|
|
3559
|
+
return t.isEmpty() ? null : new fe(this.firestore,
|
|
3560
|
+
/* converter= */ null, new et(t));
|
|
3549
3561
|
}
|
|
3550
3562
|
withConverter(t) {
|
|
3551
|
-
return new
|
|
3563
|
+
return new we(this.firestore, t, this._path);
|
|
3552
3564
|
}
|
|
3553
3565
|
}
|
|
3554
3566
|
|
|
3555
|
-
function
|
|
3556
|
-
if (t =
|
|
3557
|
-
const r =
|
|
3558
|
-
return
|
|
3567
|
+
function me(t, n, ...e) {
|
|
3568
|
+
if (t = l(t), rt("collection", "path", n), t instanceof ue) {
|
|
3569
|
+
const r = Z.fromString(n, ...e);
|
|
3570
|
+
return it(r), new we(t, /* converter= */ null, r);
|
|
3559
3571
|
}
|
|
3560
3572
|
{
|
|
3561
|
-
if (!(t instanceof
|
|
3562
|
-
const r = t._path.child(
|
|
3563
|
-
return
|
|
3573
|
+
if (!(t instanceof fe || t instanceof we)) throw new U(P, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3574
|
+
const r = t._path.child(Z.fromString(n, ...e));
|
|
3575
|
+
return it(r), new we(t.firestore,
|
|
3564
3576
|
/* converter= */ null, r);
|
|
3565
3577
|
}
|
|
3566
3578
|
}
|
|
@@ -3577,32 +3589,32 @@ function we(t, n, ...e) {
|
|
|
3577
3589
|
* collection or subcollection with this ID as the last segment of its path
|
|
3578
3590
|
* will be included. Cannot contain a slash.
|
|
3579
3591
|
* @returns The created `Query`.
|
|
3580
|
-
*/ function
|
|
3581
|
-
if (t =
|
|
3582
|
-
return new
|
|
3592
|
+
*/ function pe(t, n) {
|
|
3593
|
+
if (t = ut(t, ue), rt("collectionGroup", "collection id", n), n.indexOf("/") >= 0) throw new U(P, `Invalid collection ID '${n}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);
|
|
3594
|
+
return new de(t,
|
|
3583
3595
|
/* converter= */ null,
|
|
3584
3596
|
/**
|
|
3585
3597
|
* Creates a new Query for a collection group query that matches all documents
|
|
3586
3598
|
* within the provided collection group.
|
|
3587
3599
|
*/
|
|
3588
3600
|
function(t) {
|
|
3589
|
-
return new
|
|
3601
|
+
return new an(Z.emptyPath(), t);
|
|
3590
3602
|
}(n));
|
|
3591
3603
|
}
|
|
3592
3604
|
|
|
3593
|
-
function
|
|
3594
|
-
if (t =
|
|
3605
|
+
function ye(t, n, ...e) {
|
|
3606
|
+
if (t = l(t),
|
|
3595
3607
|
// We allow omission of 'pathString' but explicitly prohibit passing in both
|
|
3596
3608
|
// 'undefined' and 'null'.
|
|
3597
|
-
1 === arguments.length && (n =
|
|
3598
|
-
const r =
|
|
3599
|
-
return
|
|
3600
|
-
/* converter= */ null, new
|
|
3609
|
+
1 === arguments.length && (n = yt.P()), rt("doc", "path", n), t instanceof ue) {
|
|
3610
|
+
const r = Z.fromString(n, ...e);
|
|
3611
|
+
return st(r), new fe(t,
|
|
3612
|
+
/* converter= */ null, new et(r));
|
|
3601
3613
|
}
|
|
3602
3614
|
{
|
|
3603
|
-
if (!(t instanceof
|
|
3604
|
-
const r = t._path.child(
|
|
3605
|
-
return
|
|
3615
|
+
if (!(t instanceof fe || t instanceof we)) throw new U(P, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3616
|
+
const r = t._path.child(Z.fromString(n, ...e));
|
|
3617
|
+
return st(r), new fe(t.firestore, t instanceof we ? t.converter : null, new et(r));
|
|
3606
3618
|
}
|
|
3607
3619
|
}
|
|
3608
3620
|
|
|
@@ -3613,8 +3625,8 @@ function pe(t, n, ...e) {
|
|
|
3613
3625
|
* @param right - A reference to compare.
|
|
3614
3626
|
* @returns true if the references point to the same location in the same
|
|
3615
3627
|
* Firestore database.
|
|
3616
|
-
*/ function
|
|
3617
|
-
return t =
|
|
3628
|
+
*/ function _e(t, n) {
|
|
3629
|
+
return t = l(t), n = l(n), (t instanceof fe || t instanceof we) && (n instanceof fe || n instanceof we) && (t.firestore === n.firestore && t.path === n.path && t.converter === n.converter);
|
|
3618
3630
|
}
|
|
3619
3631
|
|
|
3620
3632
|
/**
|
|
@@ -3625,8 +3637,8 @@ function pe(t, n, ...e) {
|
|
|
3625
3637
|
* @param right - A `Query` to compare.
|
|
3626
3638
|
* @returns true if the references point to the same location in the same
|
|
3627
3639
|
* Firestore database.
|
|
3628
|
-
*/ function
|
|
3629
|
-
return t =
|
|
3640
|
+
*/ function ge(t, n) {
|
|
3641
|
+
return t = l(t), n = l(n), t instanceof de && n instanceof de && (t.firestore === n.firestore && pn(t._query, n._query) && t.converter === n.converter);
|
|
3630
3642
|
}
|
|
3631
3643
|
|
|
3632
3644
|
/**
|
|
@@ -3652,7 +3664,7 @@ function pe(t, n, ...e) {
|
|
|
3652
3664
|
*
|
|
3653
3665
|
* Create a `FieldPath` by providing field names. If more than one field
|
|
3654
3666
|
* name is provided, the path will point to a nested field in a document.
|
|
3655
|
-
*/ class
|
|
3667
|
+
*/ class ve {
|
|
3656
3668
|
/**
|
|
3657
3669
|
* Creates a `FieldPath` from the provided field names. If more than one field
|
|
3658
3670
|
* name is provided, the path will point to a nested field in a document.
|
|
@@ -3660,8 +3672,8 @@ function pe(t, n, ...e) {
|
|
|
3660
3672
|
* @param fieldNames - A list of field names.
|
|
3661
3673
|
*/
|
|
3662
3674
|
constructor(...t) {
|
|
3663
|
-
for (let n = 0; n < t.length; ++n) if (0 === t[n].length) throw new
|
|
3664
|
-
this._internalPath = new
|
|
3675
|
+
for (let n = 0; n < t.length; ++n) if (0 === t[n].length) throw new U(P, "Invalid field name at argument $(i + 1). Field names must not be empty.");
|
|
3676
|
+
this._internalPath = new nt(t);
|
|
3665
3677
|
}
|
|
3666
3678
|
/**
|
|
3667
3679
|
* Returns true if this `FieldPath` is equal to the provided one.
|
|
@@ -3676,8 +3688,8 @@ function pe(t, n, ...e) {
|
|
|
3676
3688
|
/**
|
|
3677
3689
|
* Returns a special sentinel `FieldPath` to refer to the ID of a document.
|
|
3678
3690
|
* It can be used in queries to sort or filter by the document ID.
|
|
3679
|
-
*/ function
|
|
3680
|
-
return new
|
|
3691
|
+
*/ function be() {
|
|
3692
|
+
return new ve("__name__");
|
|
3681
3693
|
}
|
|
3682
3694
|
|
|
3683
3695
|
/**
|
|
@@ -3698,7 +3710,7 @@ function pe(t, n, ...e) {
|
|
|
3698
3710
|
*/
|
|
3699
3711
|
/**
|
|
3700
3712
|
* An immutable object representing an array of bytes.
|
|
3701
|
-
*/ class
|
|
3713
|
+
*/ class Ee {
|
|
3702
3714
|
/** @hideconstructor */
|
|
3703
3715
|
constructor(t) {
|
|
3704
3716
|
this._byteString = t;
|
|
@@ -3710,9 +3722,9 @@ function pe(t, n, ...e) {
|
|
|
3710
3722
|
* @param base64 - The Base64 string used to create the `Bytes` object.
|
|
3711
3723
|
*/ static fromBase64String(t) {
|
|
3712
3724
|
try {
|
|
3713
|
-
return new
|
|
3725
|
+
return new Ee(Pt.fromBase64String(t));
|
|
3714
3726
|
} catch (t) {
|
|
3715
|
-
throw new
|
|
3727
|
+
throw new U(P, "Failed to construct data from Base64 string: " + t);
|
|
3716
3728
|
}
|
|
3717
3729
|
}
|
|
3718
3730
|
/**
|
|
@@ -3720,7 +3732,7 @@ function pe(t, n, ...e) {
|
|
|
3720
3732
|
*
|
|
3721
3733
|
* @param array - The Uint8Array used to create the `Bytes` object.
|
|
3722
3734
|
*/ static fromUint8Array(t) {
|
|
3723
|
-
return new
|
|
3735
|
+
return new Ee(Pt.fromUint8Array(t));
|
|
3724
3736
|
}
|
|
3725
3737
|
/**
|
|
3726
3738
|
* Returns the underlying bytes as a Base64-encoded string.
|
|
@@ -3772,7 +3784,7 @@ function pe(t, n, ...e) {
|
|
|
3772
3784
|
/**
|
|
3773
3785
|
* Sentinel values that can be used when writing document fields with `set()`
|
|
3774
3786
|
* or `update()`.
|
|
3775
|
-
*/ class
|
|
3787
|
+
*/ class Te {
|
|
3776
3788
|
/**
|
|
3777
3789
|
* @param _methodName - The public API endpoint that returns this class.
|
|
3778
3790
|
* @hideconstructor
|
|
@@ -3804,7 +3816,7 @@ function pe(t, n, ...e) {
|
|
|
3804
3816
|
*
|
|
3805
3817
|
* Latitude values are in the range of [-90, 90].
|
|
3806
3818
|
* Longitude values are in the range of [-180, 180].
|
|
3807
|
-
*/ class
|
|
3819
|
+
*/ class Ie {
|
|
3808
3820
|
/**
|
|
3809
3821
|
* Creates a new immutable `GeoPoint` object with the provided latitude and
|
|
3810
3822
|
* longitude values.
|
|
@@ -3812,8 +3824,8 @@ function pe(t, n, ...e) {
|
|
|
3812
3824
|
* @param longitude - The longitude as number between -180 and 180.
|
|
3813
3825
|
*/
|
|
3814
3826
|
constructor(t, n) {
|
|
3815
|
-
if (!isFinite(t) || t < -90 || t > 90) throw new
|
|
3816
|
-
if (!isFinite(n) || n < -180 || n > 180) throw new
|
|
3827
|
+
if (!isFinite(t) || t < -90 || t > 90) throw new U(P, "Latitude must be a number between -90 and 90, but was: " + t);
|
|
3828
|
+
if (!isFinite(n) || n < -180 || n > 180) throw new U(P, "Longitude must be a number between -180 and 180, but was: " + n);
|
|
3817
3829
|
this._lat = t, this._long = n;
|
|
3818
3830
|
}
|
|
3819
3831
|
/**
|
|
@@ -3844,7 +3856,7 @@ function pe(t, n, ...e) {
|
|
|
3844
3856
|
* Actually private to JS consumers of our API, so this function is prefixed
|
|
3845
3857
|
* with an underscore.
|
|
3846
3858
|
*/ _compareTo(t) {
|
|
3847
|
-
return
|
|
3859
|
+
return _t(this._lat, t._lat) || _t(this._long, t._long);
|
|
3848
3860
|
}
|
|
3849
3861
|
}
|
|
3850
3862
|
|
|
@@ -3863,29 +3875,29 @@ function pe(t, n, ...e) {
|
|
|
3863
3875
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3864
3876
|
* See the License for the specific language governing permissions and
|
|
3865
3877
|
* limitations under the License.
|
|
3866
|
-
*/ const
|
|
3878
|
+
*/ const Ae = /^__.*__$/;
|
|
3867
3879
|
|
|
3868
|
-
/** The result of parsing document data (e.g. for a setData call). */ class
|
|
3880
|
+
/** The result of parsing document data (e.g. for a setData call). */ class Pe {
|
|
3869
3881
|
constructor(t, n, e) {
|
|
3870
3882
|
this.data = t, this.fieldMask = n, this.fieldTransforms = e;
|
|
3871
3883
|
}
|
|
3872
3884
|
toMutation(t, n) {
|
|
3873
|
-
return null !== this.fieldMask ? new
|
|
3885
|
+
return null !== this.fieldMask ? new Rn(t, this.data, this.fieldMask, n, this.fieldTransforms) : new Pn(t, this.data, n, this.fieldTransforms);
|
|
3874
3886
|
}
|
|
3875
3887
|
}
|
|
3876
3888
|
|
|
3877
|
-
/** The result of parsing "update" data (i.e. for an updateData call). */ class
|
|
3889
|
+
/** The result of parsing "update" data (i.e. for an updateData call). */ class Re {
|
|
3878
3890
|
constructor(t,
|
|
3879
3891
|
// The fieldMask does not include document transforms.
|
|
3880
3892
|
n, e) {
|
|
3881
3893
|
this.data = t, this.fieldMask = n, this.fieldTransforms = e;
|
|
3882
3894
|
}
|
|
3883
3895
|
toMutation(t, n) {
|
|
3884
|
-
return new
|
|
3896
|
+
return new Rn(t, this.data, this.fieldMask, n, this.fieldTransforms);
|
|
3885
3897
|
}
|
|
3886
3898
|
}
|
|
3887
3899
|
|
|
3888
|
-
function
|
|
3900
|
+
function Ve(t) {
|
|
3889
3901
|
switch (t) {
|
|
3890
3902
|
case 0 /* Set */ :
|
|
3891
3903
|
// fall through
|
|
@@ -3899,11 +3911,11 @@ function Re(t) {
|
|
|
3899
3911
|
return !1;
|
|
3900
3912
|
|
|
3901
3913
|
default:
|
|
3902
|
-
throw
|
|
3914
|
+
throw v();
|
|
3903
3915
|
}
|
|
3904
3916
|
}
|
|
3905
3917
|
|
|
3906
|
-
/** A "context" object passed around while parsing user data. */ class
|
|
3918
|
+
/** A "context" object passed around while parsing user data. */ class Ne {
|
|
3907
3919
|
/**
|
|
3908
3920
|
* Initializes a ParseContext with the given source and path.
|
|
3909
3921
|
*
|
|
@@ -3935,7 +3947,7 @@ function Re(t) {
|
|
|
3935
3947
|
return this.settings.tt;
|
|
3936
3948
|
}
|
|
3937
3949
|
/** Returns a new context with the specified settings overwritten. */ nt(t) {
|
|
3938
|
-
return new
|
|
3950
|
+
return new Ne(Object.assign(Object.assign({}, this.settings), t), this.databaseId, this.q, this.ignoreUndefinedProperties, this.fieldTransforms, this.fieldMask);
|
|
3939
3951
|
}
|
|
3940
3952
|
et(t) {
|
|
3941
3953
|
var n;
|
|
@@ -3962,7 +3974,7 @@ function Re(t) {
|
|
|
3962
3974
|
});
|
|
3963
3975
|
}
|
|
3964
3976
|
ut(t) {
|
|
3965
|
-
return
|
|
3977
|
+
return He(t, this.settings.methodName, this.settings.ct || !1, this.path, this.settings.at);
|
|
3966
3978
|
}
|
|
3967
3979
|
/** Returns 'true' if 'fieldPath' was traversed when creating this context. */ contains(t) {
|
|
3968
3980
|
return void 0 !== this.fieldMask.find((n => t.isPrefixOf(n))) || void 0 !== this.fieldTransforms.find((n => t.isPrefixOf(n.field)));
|
|
@@ -3974,52 +3986,52 @@ function Re(t) {
|
|
|
3974
3986
|
}
|
|
3975
3987
|
st(t) {
|
|
3976
3988
|
if (0 === t.length) throw this.ut("Document fields must not be empty");
|
|
3977
|
-
if (
|
|
3989
|
+
if (Ve(this.tt) && Ae.test(t)) throw this.ut('Document fields cannot begin and end with "__"');
|
|
3978
3990
|
}
|
|
3979
3991
|
}
|
|
3980
3992
|
|
|
3981
3993
|
/**
|
|
3982
3994
|
* Helper for parsing raw user input (provided via the API) into internal model
|
|
3983
3995
|
* classes.
|
|
3984
|
-
*/ class
|
|
3996
|
+
*/ class De {
|
|
3985
3997
|
constructor(t, n, e) {
|
|
3986
|
-
this.databaseId = t, this.ignoreUndefinedProperties = n, this.q = e ||
|
|
3998
|
+
this.databaseId = t, this.ignoreUndefinedProperties = n, this.q = e || Xn(t);
|
|
3987
3999
|
}
|
|
3988
4000
|
/** Creates a new top-level parse context. */ ht(t, n, e, r = !1) {
|
|
3989
|
-
return new
|
|
4001
|
+
return new Ne({
|
|
3990
4002
|
tt: t,
|
|
3991
4003
|
methodName: n,
|
|
3992
4004
|
at: e,
|
|
3993
|
-
path:
|
|
4005
|
+
path: nt.emptyPath(),
|
|
3994
4006
|
rt: !1,
|
|
3995
4007
|
ct: r
|
|
3996
4008
|
}, this.databaseId, this.q, this.ignoreUndefinedProperties);
|
|
3997
4009
|
}
|
|
3998
4010
|
}
|
|
3999
4011
|
|
|
4000
|
-
function
|
|
4001
|
-
const n = t._freezeSettings(), e =
|
|
4002
|
-
return new
|
|
4012
|
+
function $e(t) {
|
|
4013
|
+
const n = t._freezeSettings(), e = Xn(t._databaseId);
|
|
4014
|
+
return new De(t._databaseId, !!n.ignoreUndefinedProperties, e);
|
|
4003
4015
|
}
|
|
4004
4016
|
|
|
4005
|
-
/** Parse document data from a set() call. */ function
|
|
4017
|
+
/** Parse document data from a set() call. */ function Fe(t, n, e, r, s, i = {}) {
|
|
4006
4018
|
const o = t.ht(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ , n, e, s);
|
|
4007
|
-
|
|
4008
|
-
const u =
|
|
4019
|
+
Qe("Data must be an object, but it was:", o, r);
|
|
4020
|
+
const u = Be(r, o);
|
|
4009
4021
|
let c, a;
|
|
4010
|
-
if (i.merge) c = new
|
|
4022
|
+
if (i.merge) c = new It(o.fieldMask), a = o.fieldTransforms; else if (i.mergeFields) {
|
|
4011
4023
|
const t = [];
|
|
4012
4024
|
for (const r of i.mergeFields) {
|
|
4013
|
-
const s =
|
|
4014
|
-
if (!o.contains(s)) throw new
|
|
4015
|
-
|
|
4025
|
+
const s = Ge(n, r, e);
|
|
4026
|
+
if (!o.contains(s)) throw new U(P, `Field '${s}' is specified in your field mask but missing from your input data.`);
|
|
4027
|
+
Ke(t, s) || t.push(s);
|
|
4016
4028
|
}
|
|
4017
|
-
c = new
|
|
4029
|
+
c = new It(t), a = o.fieldTransforms.filter((t => c.covers(t.field)));
|
|
4018
4030
|
} else c = null, a = o.fieldTransforms;
|
|
4019
|
-
return new
|
|
4031
|
+
return new Pe(new Qt(u), c, a);
|
|
4020
4032
|
}
|
|
4021
4033
|
|
|
4022
|
-
class
|
|
4034
|
+
class Se extends Te {
|
|
4023
4035
|
_toFieldTransform(t) {
|
|
4024
4036
|
if (2 /* MergeSet */ !== t.tt) throw 1 /* Update */ === t.tt ? t.ut(`${this._methodName}() can only appear at the top level of your update data`) : t.ut(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);
|
|
4025
4037
|
// No transform to add for a delete, but we need to add it to our
|
|
@@ -4027,7 +4039,7 @@ class Fe extends Ee {
|
|
|
4027
4039
|
return t.fieldMask.push(t.path), null;
|
|
4028
4040
|
}
|
|
4029
4041
|
isEqual(t) {
|
|
4030
|
-
return t instanceof
|
|
4042
|
+
return t instanceof Se;
|
|
4031
4043
|
}
|
|
4032
4044
|
}
|
|
4033
4045
|
|
|
@@ -4046,8 +4058,8 @@ class Fe extends Ee {
|
|
|
4046
4058
|
* context.
|
|
4047
4059
|
* @param context - The parent context.
|
|
4048
4060
|
* @param arrayElement - Whether or not the FieldValue has an array.
|
|
4049
|
-
*/ function
|
|
4050
|
-
return new
|
|
4061
|
+
*/ function xe(t, n, e) {
|
|
4062
|
+
return new Ne({
|
|
4051
4063
|
tt: 3 /* Argument */ ,
|
|
4052
4064
|
at: n.settings.at,
|
|
4053
4065
|
methodName: t._methodName,
|
|
@@ -4055,23 +4067,23 @@ class Fe extends Ee {
|
|
|
4055
4067
|
}, n.databaseId, n.q, n.ignoreUndefinedProperties);
|
|
4056
4068
|
}
|
|
4057
4069
|
|
|
4058
|
-
class qe extends
|
|
4070
|
+
class qe extends Te {
|
|
4059
4071
|
_toFieldTransform(t) {
|
|
4060
|
-
return new
|
|
4072
|
+
return new Tn(t.path, new gn);
|
|
4061
4073
|
}
|
|
4062
4074
|
isEqual(t) {
|
|
4063
4075
|
return t instanceof qe;
|
|
4064
4076
|
}
|
|
4065
4077
|
}
|
|
4066
4078
|
|
|
4067
|
-
class
|
|
4079
|
+
class Oe extends Te {
|
|
4068
4080
|
constructor(t, n) {
|
|
4069
4081
|
super(t), this.lt = n;
|
|
4070
4082
|
}
|
|
4071
4083
|
_toFieldTransform(t) {
|
|
4072
|
-
const n =
|
|
4073
|
-
/*array=*/ !0), e = this.lt.map((t =>
|
|
4074
|
-
return new
|
|
4084
|
+
const n = xe(this, t,
|
|
4085
|
+
/*array=*/ !0), e = this.lt.map((t => Me(t, n))), r = new vn(e);
|
|
4086
|
+
return new Tn(t.path, r);
|
|
4075
4087
|
}
|
|
4076
4088
|
isEqual(t) {
|
|
4077
4089
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4079,14 +4091,14 @@ class xe extends Ee {
|
|
|
4079
4091
|
}
|
|
4080
4092
|
}
|
|
4081
4093
|
|
|
4082
|
-
class
|
|
4094
|
+
class Ce extends Te {
|
|
4083
4095
|
constructor(t, n) {
|
|
4084
4096
|
super(t), this.lt = n;
|
|
4085
4097
|
}
|
|
4086
4098
|
_toFieldTransform(t) {
|
|
4087
|
-
const n =
|
|
4088
|
-
/*array=*/ !0), e = this.lt.map((t =>
|
|
4089
|
-
return new
|
|
4099
|
+
const n = xe(this, t,
|
|
4100
|
+
/*array=*/ !0), e = this.lt.map((t => Me(t, n))), r = new bn(e);
|
|
4101
|
+
return new Tn(t.path, r);
|
|
4090
4102
|
}
|
|
4091
4103
|
isEqual(t) {
|
|
4092
4104
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4094,13 +4106,13 @@ class Oe extends Ee {
|
|
|
4094
4106
|
}
|
|
4095
4107
|
}
|
|
4096
4108
|
|
|
4097
|
-
class
|
|
4109
|
+
class Le extends Te {
|
|
4098
4110
|
constructor(t, n) {
|
|
4099
4111
|
super(t), this.ft = n;
|
|
4100
4112
|
}
|
|
4101
4113
|
_toFieldTransform(t) {
|
|
4102
|
-
const n = new
|
|
4103
|
-
return new
|
|
4114
|
+
const n = new En(t.q, yn(t.q, this.ft));
|
|
4115
|
+
return new Tn(t.path, n);
|
|
4104
4116
|
}
|
|
4105
4117
|
isEqual(t) {
|
|
4106
4118
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4108,50 +4120,50 @@ class Ce extends Ee {
|
|
|
4108
4120
|
}
|
|
4109
4121
|
}
|
|
4110
4122
|
|
|
4111
|
-
/** Parse update data from an update() call. */ function
|
|
4123
|
+
/** Parse update data from an update() call. */ function ke(t, n, e, r) {
|
|
4112
4124
|
const s = t.ht(1 /* Update */ , n, e);
|
|
4113
|
-
|
|
4114
|
-
const i = [], o =
|
|
4115
|
-
|
|
4116
|
-
const u =
|
|
4125
|
+
Qe("Data must be an object, but it was:", s, r);
|
|
4126
|
+
const i = [], o = Qt.empty();
|
|
4127
|
+
Tt(r, ((t, r) => {
|
|
4128
|
+
const u = Ye(n, t, e);
|
|
4117
4129
|
// For Compat types, we have to "extract" the underlying types before
|
|
4118
4130
|
// performing validation.
|
|
4119
|
-
r =
|
|
4131
|
+
r = l(r);
|
|
4120
4132
|
const c = s.it(u);
|
|
4121
|
-
if (r instanceof
|
|
4133
|
+
if (r instanceof Se)
|
|
4122
4134
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4123
4135
|
i.push(u); else {
|
|
4124
|
-
const t =
|
|
4136
|
+
const t = Me(r, c);
|
|
4125
4137
|
null != t && (i.push(u), o.set(u, t));
|
|
4126
4138
|
}
|
|
4127
4139
|
}));
|
|
4128
|
-
const u = new
|
|
4129
|
-
return new
|
|
4140
|
+
const u = new It(i);
|
|
4141
|
+
return new Re(o, u, s.fieldTransforms);
|
|
4130
4142
|
}
|
|
4131
4143
|
|
|
4132
|
-
/** Parse update data from a list of field/value arguments. */ function
|
|
4133
|
-
const o = t.ht(1 /* Update */ , n, e), u = [
|
|
4134
|
-
if (i.length % 2 != 0) throw new
|
|
4135
|
-
for (let t = 0; t < i.length; t += 2) u.push(
|
|
4136
|
-
const a = [],
|
|
4144
|
+
/** Parse update data from a list of field/value arguments. */ function Ue(t, n, e, r, s, i) {
|
|
4145
|
+
const o = t.ht(1 /* Update */ , n, e), u = [ Ge(n, r, e) ], c = [ s ];
|
|
4146
|
+
if (i.length % 2 != 0) throw new U(P, `Function ${n}() needs to be called with an even number of arguments that alternate between field names and values.`);
|
|
4147
|
+
for (let t = 0; t < i.length; t += 2) u.push(Ge(n, i[t])), c.push(i[t + 1]);
|
|
4148
|
+
const a = [], h = Qt.empty();
|
|
4137
4149
|
// We iterate in reverse order to pick the last value for a field if the
|
|
4138
4150
|
// user specified the field multiple times.
|
|
4139
|
-
for (let t = u.length - 1; t >= 0; --t) if (!
|
|
4151
|
+
for (let t = u.length - 1; t >= 0; --t) if (!Ke(a, u[t])) {
|
|
4140
4152
|
const n = u[t];
|
|
4141
4153
|
let e = c[t];
|
|
4142
4154
|
// For Compat types, we have to "extract" the underlying types before
|
|
4143
4155
|
// performing validation.
|
|
4144
|
-
e =
|
|
4156
|
+
e = l(e);
|
|
4145
4157
|
const r = o.it(n);
|
|
4146
|
-
if (e instanceof
|
|
4158
|
+
if (e instanceof Se)
|
|
4147
4159
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4148
4160
|
a.push(n); else {
|
|
4149
|
-
const t =
|
|
4150
|
-
null != t && (a.push(n),
|
|
4161
|
+
const t = Me(e, r);
|
|
4162
|
+
null != t && (a.push(n), h.set(n, t));
|
|
4151
4163
|
}
|
|
4152
4164
|
}
|
|
4153
|
-
const f = new
|
|
4154
|
-
return new
|
|
4165
|
+
const f = new It(a);
|
|
4166
|
+
return new Re(h, f, o.fieldTransforms);
|
|
4155
4167
|
}
|
|
4156
4168
|
|
|
4157
4169
|
/**
|
|
@@ -4160,8 +4172,8 @@ class Ce extends Ee {
|
|
|
4160
4172
|
*
|
|
4161
4173
|
* @param allowArrays - Whether the query value is an array that may directly
|
|
4162
4174
|
* contain additional arrays (e.g. the operand of an `in` query).
|
|
4163
|
-
*/ function
|
|
4164
|
-
return
|
|
4175
|
+
*/ function je(t, n, e, r = !1) {
|
|
4176
|
+
return Me(e, t.ht(r ? 4 /* ArrayArgument */ : 3 /* Argument */ , n));
|
|
4165
4177
|
}
|
|
4166
4178
|
|
|
4167
4179
|
/**
|
|
@@ -4172,12 +4184,12 @@ class Ce extends Ee {
|
|
|
4172
4184
|
* the source of the data being parsed, etc.
|
|
4173
4185
|
* @returns The parsed value, or null if the value was a FieldValue sentinel
|
|
4174
4186
|
* that should not be included in the resulting parsed data.
|
|
4175
|
-
*/ function
|
|
4176
|
-
if (
|
|
4187
|
+
*/ function Me(t, n) {
|
|
4188
|
+
if (ze(
|
|
4177
4189
|
// Unwrap the API type from the Compat SDK. This will return the API type
|
|
4178
4190
|
// from firestore-exp.
|
|
4179
|
-
t =
|
|
4180
|
-
if (t instanceof
|
|
4191
|
+
t = l(t))) return Qe("Unsupported field value:", n, t), Be(t, n);
|
|
4192
|
+
if (t instanceof Te)
|
|
4181
4193
|
// FieldValues usually parse into transforms (except FieldValue.delete())
|
|
4182
4194
|
// in which case we do not want to include this field in our parsed data
|
|
4183
4195
|
// (as doing so will overwrite the field directly prior to the transform
|
|
@@ -4189,7 +4201,7 @@ class Ce extends Ee {
|
|
|
4189
4201
|
*/
|
|
4190
4202
|
return function(t, n) {
|
|
4191
4203
|
// Sentinels are only supported with writes, and not within arrays.
|
|
4192
|
-
if (!
|
|
4204
|
+
if (!Ve(n.tt)) throw n.ut(`${t._methodName}() can only be used with update() and set()`);
|
|
4193
4205
|
if (!n.path) throw n.ut(`${t._methodName}() is not currently supported inside arrays`);
|
|
4194
4206
|
const e = t._toFieldTransform(n);
|
|
4195
4207
|
e && n.fieldTransforms.push(e);
|
|
@@ -4219,7 +4231,7 @@ class Ce extends Ee {
|
|
|
4219
4231
|
const e = [];
|
|
4220
4232
|
let r = 0;
|
|
4221
4233
|
for (const s of t) {
|
|
4222
|
-
let t =
|
|
4234
|
+
let t = Me(s, n.ot(r));
|
|
4223
4235
|
null == t && (
|
|
4224
4236
|
// Just include nulls in the array for fields being replaced with a
|
|
4225
4237
|
// sentinel.
|
|
@@ -4235,10 +4247,10 @@ class Ce extends Ee {
|
|
|
4235
4247
|
}(t, n);
|
|
4236
4248
|
}
|
|
4237
4249
|
return function(t, n) {
|
|
4238
|
-
if (null === (t =
|
|
4250
|
+
if (null === (t = l(t))) return {
|
|
4239
4251
|
nullValue: "NULL_VALUE"
|
|
4240
4252
|
};
|
|
4241
|
-
if ("number" == typeof t) return
|
|
4253
|
+
if ("number" == typeof t) return yn(n.q, t);
|
|
4242
4254
|
if ("boolean" == typeof t) return {
|
|
4243
4255
|
booleanValue: t
|
|
4244
4256
|
};
|
|
@@ -4246,37 +4258,37 @@ class Ce extends Ee {
|
|
|
4246
4258
|
stringValue: t
|
|
4247
4259
|
};
|
|
4248
4260
|
if (t instanceof Date) {
|
|
4249
|
-
const e =
|
|
4261
|
+
const e = vt.fromDate(t);
|
|
4250
4262
|
return {
|
|
4251
|
-
timestampValue:
|
|
4263
|
+
timestampValue: Sn(n.q, e)
|
|
4252
4264
|
};
|
|
4253
4265
|
}
|
|
4254
|
-
if (t instanceof
|
|
4266
|
+
if (t instanceof vt) {
|
|
4255
4267
|
// Firestore backend truncates precision down to microseconds. To ensure
|
|
4256
4268
|
// offline mode works the same with regards to truncation, perform the
|
|
4257
4269
|
// truncation immediately without waiting for the backend to do that.
|
|
4258
|
-
const e = new
|
|
4270
|
+
const e = new vt(t.seconds, 1e3 * Math.floor(t.nanoseconds / 1e3));
|
|
4259
4271
|
return {
|
|
4260
|
-
timestampValue:
|
|
4272
|
+
timestampValue: Sn(n.q, e)
|
|
4261
4273
|
};
|
|
4262
4274
|
}
|
|
4263
|
-
if (t instanceof
|
|
4275
|
+
if (t instanceof Ie) return {
|
|
4264
4276
|
geoPointValue: {
|
|
4265
4277
|
latitude: t.latitude,
|
|
4266
4278
|
longitude: t.longitude
|
|
4267
4279
|
}
|
|
4268
4280
|
};
|
|
4269
|
-
if (t instanceof
|
|
4270
|
-
bytesValue:
|
|
4281
|
+
if (t instanceof Ee) return {
|
|
4282
|
+
bytesValue: xn(n.q, t._byteString)
|
|
4271
4283
|
};
|
|
4272
|
-
if (t instanceof
|
|
4284
|
+
if (t instanceof fe) {
|
|
4273
4285
|
const e = n.databaseId, r = t.firestore._databaseId;
|
|
4274
4286
|
if (!r.isEqual(e)) throw n.ut(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${e.projectId}/${e.database}`);
|
|
4275
4287
|
return {
|
|
4276
|
-
referenceValue:
|
|
4288
|
+
referenceValue: Cn(t.firestore._databaseId || n.databaseId, t._key.path)
|
|
4277
4289
|
};
|
|
4278
4290
|
}
|
|
4279
|
-
throw n.ut(`Unsupported field value: ${
|
|
4291
|
+
throw n.ut(`Unsupported field value: ${ot(t)}`);
|
|
4280
4292
|
}
|
|
4281
4293
|
/**
|
|
4282
4294
|
* Checks whether an object looks like a JSON object that should be converted
|
|
@@ -4287,13 +4299,13 @@ class Ce extends Ee {
|
|
|
4287
4299
|
*/ (t, n);
|
|
4288
4300
|
}
|
|
4289
4301
|
|
|
4290
|
-
function
|
|
4302
|
+
function Be(t, n) {
|
|
4291
4303
|
const e = {};
|
|
4292
4304
|
return !function(t) {
|
|
4293
4305
|
for (const n in t) if (Object.prototype.hasOwnProperty.call(t, n)) return !1;
|
|
4294
4306
|
return !0;
|
|
4295
|
-
}(t) ?
|
|
4296
|
-
const s =
|
|
4307
|
+
}(t) ? Tt(t, ((t, r) => {
|
|
4308
|
+
const s = Me(r, n.et(t));
|
|
4297
4309
|
null != s && (e[t] = s);
|
|
4298
4310
|
})) :
|
|
4299
4311
|
// If we encounter an empty object, we explicitly add it to the update
|
|
@@ -4305,35 +4317,35 @@ function Me(t, n) {
|
|
|
4305
4317
|
};
|
|
4306
4318
|
}
|
|
4307
4319
|
|
|
4308
|
-
function
|
|
4309
|
-
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof
|
|
4320
|
+
function ze(t) {
|
|
4321
|
+
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof vt || t instanceof Ie || t instanceof Ee || t instanceof fe || t instanceof Te);
|
|
4310
4322
|
}
|
|
4311
4323
|
|
|
4312
|
-
function
|
|
4313
|
-
if (!
|
|
4324
|
+
function Qe(t, n, e) {
|
|
4325
|
+
if (!ze(e) || !function(t) {
|
|
4314
4326
|
return "object" == typeof t && null !== t && (Object.getPrototypeOf(t) === Object.prototype || null === Object.getPrototypeOf(t));
|
|
4315
4327
|
}(e)) {
|
|
4316
|
-
const r =
|
|
4328
|
+
const r = ot(e);
|
|
4317
4329
|
throw "an object" === r ? n.ut(t + " a custom object") : n.ut(t + " " + r);
|
|
4318
4330
|
}
|
|
4319
4331
|
}
|
|
4320
4332
|
|
|
4321
4333
|
/**
|
|
4322
4334
|
* Helper that calls fromDotSeparatedString() but wraps any error thrown.
|
|
4323
|
-
*/ function
|
|
4335
|
+
*/ function Ge(t, n, e) {
|
|
4324
4336
|
if ((
|
|
4325
4337
|
// If required, replace the FieldPath Compat class with with the firestore-exp
|
|
4326
4338
|
// FieldPath.
|
|
4327
|
-
n =
|
|
4328
|
-
if ("string" == typeof n) return
|
|
4329
|
-
throw
|
|
4339
|
+
n = l(n)) instanceof ve) return n._internalPath;
|
|
4340
|
+
if ("string" == typeof n) return Ye(t, n);
|
|
4341
|
+
throw He("Field path arguments must be of type string or FieldPath.", t,
|
|
4330
4342
|
/* hasConverter= */ !1,
|
|
4331
4343
|
/* path= */ void 0, e);
|
|
4332
4344
|
}
|
|
4333
4345
|
|
|
4334
4346
|
/**
|
|
4335
4347
|
* Matches any characters in a field path string that are reserved.
|
|
4336
|
-
*/ const
|
|
4348
|
+
*/ const We = new RegExp("[~\\*/\\[\\]]");
|
|
4337
4349
|
|
|
4338
4350
|
/**
|
|
4339
4351
|
* Wraps fromDotSeparatedString with an error message about the method that
|
|
@@ -4343,29 +4355,29 @@ function ze(t, n, e) {
|
|
|
4343
4355
|
* split on dots.
|
|
4344
4356
|
* @param targetDoc - The document against which the field path will be
|
|
4345
4357
|
* evaluated.
|
|
4346
|
-
*/ function
|
|
4347
|
-
if (n.search(
|
|
4358
|
+
*/ function Ye(t, n, e) {
|
|
4359
|
+
if (n.search(We) >= 0) throw He(`Invalid field path (${n}). Paths must not contain '~', '*', '/', '[', or ']'`, t,
|
|
4348
4360
|
/* hasConverter= */ !1,
|
|
4349
4361
|
/* path= */ void 0, e);
|
|
4350
4362
|
try {
|
|
4351
|
-
return new
|
|
4363
|
+
return new ve(...n.split("."))._internalPath;
|
|
4352
4364
|
} catch (r) {
|
|
4353
|
-
throw
|
|
4365
|
+
throw He(`Invalid field path (${n}). Paths must not be empty, begin with '.', end with '.', or contain '..'`, t,
|
|
4354
4366
|
/* hasConverter= */ !1,
|
|
4355
4367
|
/* path= */ void 0, e);
|
|
4356
4368
|
}
|
|
4357
4369
|
}
|
|
4358
4370
|
|
|
4359
|
-
function
|
|
4371
|
+
function He(t, n, e, r, s) {
|
|
4360
4372
|
const i = r && !r.isEmpty(), o = void 0 !== s;
|
|
4361
4373
|
let u = `Function ${n}() called with invalid data`;
|
|
4362
4374
|
e && (u += " (via `toFirestore()`)"), u += ". ";
|
|
4363
4375
|
let c = "";
|
|
4364
4376
|
return (i || o) && (c += " (found", i && (c += ` in field ${r}`), o && (c += ` in document ${s}`),
|
|
4365
|
-
c += ")"), new
|
|
4377
|
+
c += ")"), new U(P, u + t + c);
|
|
4366
4378
|
}
|
|
4367
4379
|
|
|
4368
|
-
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function
|
|
4380
|
+
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function Ke(t, n) {
|
|
4369
4381
|
return t.some((t => t.isEqual(n)));
|
|
4370
4382
|
}
|
|
4371
4383
|
|
|
@@ -4393,7 +4405,7 @@ function Ye(t, n, e, r, s) {
|
|
|
4393
4405
|
* For a `DocumentSnapshot` that points to a non-existing document, any data
|
|
4394
4406
|
* access will return 'undefined'. You can use the `exists()` method to
|
|
4395
4407
|
* explicitly verify a document's existence.
|
|
4396
|
-
*/ class
|
|
4408
|
+
*/ class Je {
|
|
4397
4409
|
// Note: This class is stripped down version of the DocumentSnapshot in
|
|
4398
4410
|
// the legacy SDK. The changes are:
|
|
4399
4411
|
// - No support for SnapshotMetadata.
|
|
@@ -4409,7 +4421,7 @@ function Ye(t, n, e, r, s) {
|
|
|
4409
4421
|
/**
|
|
4410
4422
|
* The `DocumentReference` for the document included in the `DocumentSnapshot`.
|
|
4411
4423
|
*/ get ref() {
|
|
4412
|
-
return new
|
|
4424
|
+
return new fe(this._firestore, this._converter, this._key);
|
|
4413
4425
|
}
|
|
4414
4426
|
/**
|
|
4415
4427
|
* Signals whether or not the document at the snapshot's location exists.
|
|
@@ -4429,7 +4441,7 @@ function Ye(t, n, e, r, s) {
|
|
|
4429
4441
|
if (this._converter) {
|
|
4430
4442
|
// We only want to use the converter and create a new DocumentSnapshot
|
|
4431
4443
|
// if a converter has been provided.
|
|
4432
|
-
const t = new
|
|
4444
|
+
const t = new Xe(this._firestore, this._userDataWriter, this._key, this._document,
|
|
4433
4445
|
/* converter= */ null);
|
|
4434
4446
|
return this._converter.fromFirestore(t);
|
|
4435
4447
|
}
|
|
@@ -4449,7 +4461,7 @@ function Ye(t, n, e, r, s) {
|
|
|
4449
4461
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4450
4462
|
get(t) {
|
|
4451
4463
|
if (this._document) {
|
|
4452
|
-
const n = this._document.data.field(
|
|
4464
|
+
const n = this._document.data.field(nr("DocumentSnapshot.get", t));
|
|
4453
4465
|
if (null !== n) return this._userDataWriter.convertValue(n);
|
|
4454
4466
|
}
|
|
4455
4467
|
}
|
|
@@ -4465,7 +4477,7 @@ function Ye(t, n, e, r, s) {
|
|
|
4465
4477
|
* `DocumentSnapshot`. Since query results contain only existing documents, the
|
|
4466
4478
|
* `exists` property will always be true and `data()` will never return
|
|
4467
4479
|
* 'undefined'.
|
|
4468
|
-
*/ class
|
|
4480
|
+
*/ class Xe extends Je {
|
|
4469
4481
|
/**
|
|
4470
4482
|
* Retrieves all fields in the document as an `Object`.
|
|
4471
4483
|
*
|
|
@@ -4483,7 +4495,7 @@ function Ye(t, n, e, r, s) {
|
|
|
4483
4495
|
* array via the `docs` property or enumerated using the `forEach` method. The
|
|
4484
4496
|
* number of documents can be determined via the `empty` and `size`
|
|
4485
4497
|
* properties.
|
|
4486
|
-
*/ class
|
|
4498
|
+
*/ class Ze {
|
|
4487
4499
|
/** @hideconstructor */
|
|
4488
4500
|
constructor(t, n) {
|
|
4489
4501
|
this._docs = n, this.query = t;
|
|
@@ -4514,14 +4526,14 @@ function Ye(t, n, e, r, s) {
|
|
|
4514
4526
|
* @param left - A snapshot to compare.
|
|
4515
4527
|
* @param right - A snapshot to compare.
|
|
4516
4528
|
* @returns true if the snapshots are equal.
|
|
4517
|
-
*/ function
|
|
4518
|
-
return t =
|
|
4529
|
+
*/ function tr(t, n) {
|
|
4530
|
+
return t = l(t), n = l(n), t instanceof Je && n instanceof Je ? 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 Ze && n instanceof Ze && (ge(t.query, n.query) && gt(t.docs, n.docs, tr));
|
|
4519
4531
|
}
|
|
4520
4532
|
|
|
4521
4533
|
/**
|
|
4522
4534
|
* Helper that calls `fromDotSeparatedString()` but wraps any error thrown.
|
|
4523
|
-
*/ function
|
|
4524
|
-
return "string" == typeof n ?
|
|
4535
|
+
*/ function nr(t, n) {
|
|
4536
|
+
return "string" == typeof n ? Ye(t, n) : n instanceof ve ? n._internalPath : n._delegate._internalPath;
|
|
4525
4537
|
}
|
|
4526
4538
|
|
|
4527
4539
|
/**
|
|
@@ -4548,7 +4560,7 @@ function Ye(t, n, e, r, s) {
|
|
|
4548
4560
|
* can then be passed to {@link query} to create a new query instance that
|
|
4549
4561
|
* also contains this `QueryConstraint`.
|
|
4550
4562
|
*/
|
|
4551
|
-
class
|
|
4563
|
+
class er {}
|
|
4552
4564
|
|
|
4553
4565
|
/**
|
|
4554
4566
|
* Creates a new immutable instance of {@link Query} that is extended to also include
|
|
@@ -4558,40 +4570,40 @@ class nr {}
|
|
|
4558
4570
|
* @param queryConstraints - The list of {@link QueryConstraint}s to apply.
|
|
4559
4571
|
* @throws if any of the provided query constraints cannot be combined with the
|
|
4560
4572
|
* existing or new constraints.
|
|
4561
|
-
*/ function
|
|
4573
|
+
*/ function rr(t, ...n) {
|
|
4562
4574
|
for (const e of n) t = e._apply(t);
|
|
4563
4575
|
return t;
|
|
4564
4576
|
}
|
|
4565
4577
|
|
|
4566
|
-
class
|
|
4578
|
+
class sr extends er {
|
|
4567
4579
|
constructor(t, n, e) {
|
|
4568
4580
|
super(), this.dt = t, this.wt = n, this.yt = e, this.type = "where";
|
|
4569
4581
|
}
|
|
4570
4582
|
_apply(t) {
|
|
4571
|
-
const n =
|
|
4583
|
+
const n = $e(t.firestore), e = function(t, n, e, r, s, i, o) {
|
|
4572
4584
|
let u;
|
|
4573
4585
|
if (s.isKeyField()) {
|
|
4574
|
-
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new
|
|
4586
|
+
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new U(P, `Invalid Query. You can't perform '${i}' queries on FieldPath.documentId().`);
|
|
4575
4587
|
if ("in" /* IN */ === i || "not-in" /* NOT_IN */ === i) {
|
|
4576
|
-
|
|
4588
|
+
gr(o, i);
|
|
4577
4589
|
const n = [];
|
|
4578
|
-
for (const e of o) n.push(
|
|
4590
|
+
for (const e of o) n.push(_r(r, t, e));
|
|
4579
4591
|
u = {
|
|
4580
4592
|
arrayValue: {
|
|
4581
4593
|
values: n
|
|
4582
4594
|
}
|
|
4583
4595
|
};
|
|
4584
|
-
} else u =
|
|
4585
|
-
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i ||
|
|
4586
|
-
u =
|
|
4596
|
+
} else u = _r(r, t, o);
|
|
4597
|
+
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i || gr(o, i),
|
|
4598
|
+
u = je(e, n, o,
|
|
4587
4599
|
/* allowArrays= */ "in" /* IN */ === i || "not-in" /* NOT_IN */ === i);
|
|
4588
|
-
const c =
|
|
4600
|
+
const c = Ht.create(s, i, u);
|
|
4589
4601
|
return function(t, n) {
|
|
4590
4602
|
if (n.D()) {
|
|
4591
|
-
const e =
|
|
4592
|
-
if (null !== e && !e.isEqual(n.field)) throw new
|
|
4593
|
-
const r =
|
|
4594
|
-
null !== r &&
|
|
4603
|
+
const e = fn(t);
|
|
4604
|
+
if (null !== e && !e.isEqual(n.field)) throw new U(P, `Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '${e.toString()}' and '${n.field.toString()}'`);
|
|
4605
|
+
const r = ln(t);
|
|
4606
|
+
null !== r && vr(t, n.field, r);
|
|
4595
4607
|
}
|
|
4596
4608
|
const e = function(t, n) {
|
|
4597
4609
|
for (const e of t.filters) if (n.indexOf(e.op) >= 0) return e.op;
|
|
@@ -4632,12 +4644,12 @@ class rr extends nr {
|
|
|
4632
4644
|
}(n.op));
|
|
4633
4645
|
if (null !== e)
|
|
4634
4646
|
// Special case when it's a duplicate op to give a slightly clearer error message.
|
|
4635
|
-
throw e === n.op ? new
|
|
4647
|
+
throw e === n.op ? new U(P, `Invalid query. You cannot use more than one '${n.op.toString()}' filter.`) : new U(P, `Invalid query. You cannot use '${n.op.toString()}' filters with '${e.toString()}' filters.`);
|
|
4636
4648
|
}(t, c), c;
|
|
4637
4649
|
}(t._query, "where", n, t.firestore._databaseId, this.dt, this.wt, this.yt);
|
|
4638
|
-
return new
|
|
4650
|
+
return new de(t.firestore, t.converter, function(t, n) {
|
|
4639
4651
|
const e = t.filters.concat([ n ]);
|
|
4640
|
-
return new
|
|
4652
|
+
return new an(t.path, t.collectionGroup, t.explicitOrderBy.slice(), e, t.limit, t.limitType, t.startAt, t.endAt);
|
|
4641
4653
|
}(t._query, e));
|
|
4642
4654
|
}
|
|
4643
4655
|
}
|
|
@@ -4652,25 +4664,25 @@ class rr extends nr {
|
|
|
4652
4664
|
* "<=", "!=").
|
|
4653
4665
|
* @param value - The value for comparison
|
|
4654
4666
|
* @returns The created {@link Query}.
|
|
4655
|
-
*/ function
|
|
4656
|
-
const r = n, s =
|
|
4657
|
-
return new
|
|
4667
|
+
*/ function ir(t, n, e) {
|
|
4668
|
+
const r = n, s = nr("where", t);
|
|
4669
|
+
return new sr(s, r, e);
|
|
4658
4670
|
}
|
|
4659
4671
|
|
|
4660
|
-
class
|
|
4672
|
+
class or extends er {
|
|
4661
4673
|
constructor(t, n) {
|
|
4662
4674
|
super(), this.dt = t, this._t = n, this.type = "orderBy";
|
|
4663
4675
|
}
|
|
4664
4676
|
_apply(t) {
|
|
4665
4677
|
const n = function(t, n, e) {
|
|
4666
|
-
if (null !== t.startAt) throw new
|
|
4667
|
-
if (null !== t.endAt) throw new
|
|
4668
|
-
const r = new
|
|
4678
|
+
if (null !== t.startAt) throw new U(P, "Invalid query. You must not call startAt() or startAfter() before calling orderBy().");
|
|
4679
|
+
if (null !== t.endAt) throw new U(P, "Invalid query. You must not call endAt() or endBefore() before calling orderBy().");
|
|
4680
|
+
const r = new on(n, e);
|
|
4669
4681
|
return function(t, n) {
|
|
4670
|
-
if (null ===
|
|
4682
|
+
if (null === ln(t)) {
|
|
4671
4683
|
// This is the first order by. It must match any inequality.
|
|
4672
|
-
const e =
|
|
4673
|
-
null !== e &&
|
|
4684
|
+
const e = fn(t);
|
|
4685
|
+
null !== e && vr(t, e, n.field);
|
|
4674
4686
|
}
|
|
4675
4687
|
}(t, r), r;
|
|
4676
4688
|
}
|
|
@@ -4685,10 +4697,10 @@ class ir extends nr {
|
|
|
4685
4697
|
* of the query or if any of the fields in the order by are an uncommitted
|
|
4686
4698
|
* server timestamp.
|
|
4687
4699
|
*/ (t._query, this.dt, this._t);
|
|
4688
|
-
return new
|
|
4700
|
+
return new de(t.firestore, t.converter, function(t, n) {
|
|
4689
4701
|
// TODO(dimond): validate that orderBy does not list the same key twice.
|
|
4690
4702
|
const e = t.explicitOrderBy.concat([ n ]);
|
|
4691
|
-
return new
|
|
4703
|
+
return new an(t.path, t.collectionGroup, e, t.filters.slice(), t.limit, t.limitType, t.startAt, t.endAt);
|
|
4692
4704
|
}(t._query, n));
|
|
4693
4705
|
}
|
|
4694
4706
|
}
|
|
@@ -4701,18 +4713,18 @@ class ir extends nr {
|
|
|
4701
4713
|
* @param directionStr - Optional direction to sort by ('asc' or 'desc'). If
|
|
4702
4714
|
* not specified, order will be ascending.
|
|
4703
4715
|
* @returns The created {@link Query}.
|
|
4704
|
-
*/ function
|
|
4705
|
-
const e = n, r =
|
|
4706
|
-
return new
|
|
4716
|
+
*/ function ur(t, n = "asc") {
|
|
4717
|
+
const e = n, r = nr("orderBy", t);
|
|
4718
|
+
return new or(r, e);
|
|
4707
4719
|
}
|
|
4708
4720
|
|
|
4709
|
-
class
|
|
4721
|
+
class cr extends er {
|
|
4710
4722
|
constructor(t, n, e) {
|
|
4711
4723
|
super(), this.type = t, this.gt = n, this.vt = e;
|
|
4712
4724
|
}
|
|
4713
4725
|
_apply(t) {
|
|
4714
|
-
return new
|
|
4715
|
-
return new
|
|
4726
|
+
return new de(t.firestore, t.converter, function(t, n, e) {
|
|
4727
|
+
return new an(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), n, e, t.startAt, t.endAt);
|
|
4716
4728
|
}(t._query, this.gt, this.vt));
|
|
4717
4729
|
}
|
|
4718
4730
|
}
|
|
@@ -4722,8 +4734,8 @@ class ur extends nr {
|
|
|
4722
4734
|
*
|
|
4723
4735
|
* @param limit - The maximum number of items to return.
|
|
4724
4736
|
* @returns The created {@link Query}.
|
|
4725
|
-
*/ function
|
|
4726
|
-
return
|
|
4737
|
+
*/ function ar(t) {
|
|
4738
|
+
return ct("limit", t), new cr("limit", t, "F" /* First */);
|
|
4727
4739
|
}
|
|
4728
4740
|
|
|
4729
4741
|
/**
|
|
@@ -4734,54 +4746,54 @@ class ur extends nr {
|
|
|
4734
4746
|
*
|
|
4735
4747
|
* @param limit - The maximum number of items to return.
|
|
4736
4748
|
* @returns The created {@link Query}.
|
|
4737
|
-
*/ function
|
|
4738
|
-
return
|
|
4749
|
+
*/ function hr(t) {
|
|
4750
|
+
return ct("limitToLast", t), new cr("limitToLast", t, "L" /* Last */);
|
|
4739
4751
|
}
|
|
4740
4752
|
|
|
4741
|
-
class
|
|
4753
|
+
class lr extends er {
|
|
4742
4754
|
constructor(t, n, e) {
|
|
4743
4755
|
super(), this.type = t, this.bt = n, this.Et = e;
|
|
4744
4756
|
}
|
|
4745
4757
|
_apply(t) {
|
|
4746
|
-
const n =
|
|
4747
|
-
return new
|
|
4748
|
-
return new
|
|
4758
|
+
const n = yr(t, this.type, this.bt, this.Et);
|
|
4759
|
+
return new de(t.firestore, t.converter, function(t, n) {
|
|
4760
|
+
return new an(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, n, t.endAt);
|
|
4749
4761
|
}(t._query, n));
|
|
4750
4762
|
}
|
|
4751
4763
|
}
|
|
4752
4764
|
|
|
4753
|
-
function
|
|
4754
|
-
return new
|
|
4765
|
+
function fr(...t) {
|
|
4766
|
+
return new lr("startAt", t, /*before=*/ !0);
|
|
4755
4767
|
}
|
|
4756
4768
|
|
|
4757
|
-
function
|
|
4758
|
-
return new
|
|
4769
|
+
function dr(...t) {
|
|
4770
|
+
return new lr("startAfter", t,
|
|
4759
4771
|
/*before=*/ !1);
|
|
4760
4772
|
}
|
|
4761
4773
|
|
|
4762
|
-
class
|
|
4774
|
+
class wr extends er {
|
|
4763
4775
|
constructor(t, n, e) {
|
|
4764
4776
|
super(), this.type = t, this.bt = n, this.Et = e;
|
|
4765
4777
|
}
|
|
4766
4778
|
_apply(t) {
|
|
4767
|
-
const n =
|
|
4768
|
-
return new
|
|
4769
|
-
return new
|
|
4779
|
+
const n = yr(t, this.type, this.bt, this.Et);
|
|
4780
|
+
return new de(t.firestore, t.converter, function(t, n) {
|
|
4781
|
+
return new an(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, t.startAt, n);
|
|
4770
4782
|
}(t._query, n));
|
|
4771
4783
|
}
|
|
4772
4784
|
}
|
|
4773
4785
|
|
|
4774
|
-
function
|
|
4775
|
-
return new
|
|
4786
|
+
function mr(...t) {
|
|
4787
|
+
return new wr("endBefore", t, /*before=*/ !0);
|
|
4776
4788
|
}
|
|
4777
4789
|
|
|
4778
|
-
function
|
|
4779
|
-
return new
|
|
4790
|
+
function pr(...t) {
|
|
4791
|
+
return new wr("endAt", t, /*before=*/ !1);
|
|
4780
4792
|
}
|
|
4781
4793
|
|
|
4782
|
-
/** Helper function to create a bound from a document or fields */ function
|
|
4783
|
-
if (e[0] =
|
|
4784
|
-
if (!r) throw new
|
|
4794
|
+
/** Helper function to create a bound from a document or fields */ function yr(t, n, e, r) {
|
|
4795
|
+
if (e[0] = l(e[0]), e[0] instanceof Je) return function(t, n, e, r, s) {
|
|
4796
|
+
if (!r) throw new U(V, `Can't use a DocumentSnapshot that doesn't exist for ${e}().`);
|
|
4785
4797
|
const i = [];
|
|
4786
4798
|
// Because people expect to continue/end a query at the exact document
|
|
4787
4799
|
// provided, we need to use the implicit sort order rather than the explicit
|
|
@@ -4790,42 +4802,42 @@ function mr(...t) {
|
|
|
4790
4802
|
// the provided document. Without the key (by using the explicit sort
|
|
4791
4803
|
// orders), multiple documents could match the position, yielding duplicate
|
|
4792
4804
|
// results.
|
|
4793
|
-
for (const e of
|
|
4805
|
+
for (const e of wn(t)) if (e.field.isKeyField()) i.push(kt(n, r.key)); else {
|
|
4794
4806
|
const t = r.data.field(e.field);
|
|
4795
|
-
if (
|
|
4807
|
+
if ($t(t)) throw new U(P, '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.)');
|
|
4796
4808
|
if (null === t) {
|
|
4797
4809
|
const t = e.field.canonicalString();
|
|
4798
|
-
throw new
|
|
4810
|
+
throw new U(P, `Invalid query. You are trying to start or end a query using a document for which the field '${t}' (used as the orderBy) does not exist.`);
|
|
4799
4811
|
}
|
|
4800
4812
|
i.push(t);
|
|
4801
4813
|
}
|
|
4802
|
-
return new
|
|
4814
|
+
return new sn(i, s);
|
|
4803
4815
|
}
|
|
4804
4816
|
/**
|
|
4805
4817
|
* Converts a list of field values to a `Bound` for the given query.
|
|
4806
4818
|
*/ (t._query, t.firestore._databaseId, n, e[0]._document, r);
|
|
4807
4819
|
{
|
|
4808
|
-
const s =
|
|
4820
|
+
const s = $e(t.firestore);
|
|
4809
4821
|
return function(t, n, e, r, s, i) {
|
|
4810
4822
|
// Use explicit order by's because it has to match the query the user made
|
|
4811
4823
|
const o = t.explicitOrderBy;
|
|
4812
|
-
if (s.length > o.length) throw new
|
|
4824
|
+
if (s.length > o.length) throw new U(P, `Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);
|
|
4813
4825
|
const u = [];
|
|
4814
4826
|
for (let i = 0; i < s.length; i++) {
|
|
4815
4827
|
const c = s[i];
|
|
4816
4828
|
if (o[i].field.isKeyField()) {
|
|
4817
|
-
if ("string" != typeof c) throw new
|
|
4818
|
-
if (!
|
|
4819
|
-
const e = t.path.child(
|
|
4820
|
-
if (!
|
|
4821
|
-
const s = new
|
|
4822
|
-
u.push(
|
|
4829
|
+
if ("string" != typeof c) throw new U(P, `Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);
|
|
4830
|
+
if (!dn(t) && -1 !== c.indexOf("/")) throw new U(P, `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.`);
|
|
4831
|
+
const e = t.path.child(Z.fromString(c));
|
|
4832
|
+
if (!et.isDocumentKey(e)) throw new U(P, `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.`);
|
|
4833
|
+
const s = new et(e);
|
|
4834
|
+
u.push(kt(n, s));
|
|
4823
4835
|
} else {
|
|
4824
|
-
const t =
|
|
4836
|
+
const t = je(e, r, c);
|
|
4825
4837
|
u.push(t);
|
|
4826
4838
|
}
|
|
4827
4839
|
}
|
|
4828
|
-
return new
|
|
4840
|
+
return new sn(u, i);
|
|
4829
4841
|
}
|
|
4830
4842
|
/**
|
|
4831
4843
|
* Parses the given `documentIdValue` into a `ReferenceValue`, throwing
|
|
@@ -4835,28 +4847,28 @@ function mr(...t) {
|
|
|
4835
4847
|
}
|
|
4836
4848
|
}
|
|
4837
4849
|
|
|
4838
|
-
function
|
|
4839
|
-
if ("string" == typeof (e =
|
|
4840
|
-
if ("" === e) throw new
|
|
4841
|
-
if (!
|
|
4842
|
-
const r = n.path.child(
|
|
4843
|
-
if (!
|
|
4844
|
-
return
|
|
4850
|
+
function _r(t, n, e) {
|
|
4851
|
+
if ("string" == typeof (e = l(e))) {
|
|
4852
|
+
if ("" === e) throw new U(P, "Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.");
|
|
4853
|
+
if (!dn(n) && -1 !== e.indexOf("/")) throw new U(P, `Invalid query. When querying a collection by FieldPath.documentId(), you must provide a plain document ID, but '${e}' contains a '/' character.`);
|
|
4854
|
+
const r = n.path.child(Z.fromString(e));
|
|
4855
|
+
if (!et.isDocumentKey(r)) throw new U(P, `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}).`);
|
|
4856
|
+
return kt(t, new et(r));
|
|
4845
4857
|
}
|
|
4846
|
-
if (e instanceof
|
|
4847
|
-
throw new
|
|
4858
|
+
if (e instanceof fe) return kt(t, e._key);
|
|
4859
|
+
throw new U(P, `Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: ${ot(e)}.`);
|
|
4848
4860
|
}
|
|
4849
4861
|
|
|
4850
4862
|
/**
|
|
4851
4863
|
* Validates that the value passed into a disjunctive filter satisfies all
|
|
4852
4864
|
* array requirements.
|
|
4853
|
-
*/ function
|
|
4854
|
-
if (!Array.isArray(t) || 0 === t.length) throw new
|
|
4855
|
-
if (t.length > 10) throw new
|
|
4865
|
+
*/ function gr(t, n) {
|
|
4866
|
+
if (!Array.isArray(t) || 0 === t.length) throw new U(P, `Invalid Query. A non-empty array is required for '${n.toString()}' filters.`);
|
|
4867
|
+
if (t.length > 10) throw new U(P, `Invalid Query. '${n.toString()}' filters support a maximum of 10 elements in the value array.`);
|
|
4856
4868
|
}
|
|
4857
4869
|
|
|
4858
|
-
function
|
|
4859
|
-
if (!e.isEqual(n)) throw new
|
|
4870
|
+
function vr(t, n, e) {
|
|
4871
|
+
if (!e.isEqual(n)) throw new U(P, `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.`);
|
|
4860
4872
|
}
|
|
4861
4873
|
|
|
4862
4874
|
/**
|
|
@@ -4906,7 +4918,7 @@ function gr(t, n, e) {
|
|
|
4906
4918
|
* their `set()` or fails due to invalid data originating from a `toFirestore()`
|
|
4907
4919
|
* call.
|
|
4908
4920
|
*/
|
|
4909
|
-
function
|
|
4921
|
+
function br(t, n, e) {
|
|
4910
4922
|
let r;
|
|
4911
4923
|
// Cast to `any` in order to satisfy the union type constraint on
|
|
4912
4924
|
// toFirestore().
|
|
@@ -4915,9 +4927,9 @@ function vr(t, n, e) {
|
|
|
4915
4927
|
r;
|
|
4916
4928
|
}
|
|
4917
4929
|
|
|
4918
|
-
class
|
|
4930
|
+
class Er extends class {
|
|
4919
4931
|
convertValue(t, n = "none") {
|
|
4920
|
-
switch (
|
|
4932
|
+
switch (xt(t)) {
|
|
4921
4933
|
case 0 /* NullValue */ :
|
|
4922
4934
|
return null;
|
|
4923
4935
|
|
|
@@ -4925,7 +4937,7 @@ class br extends class {
|
|
|
4925
4937
|
return t.booleanValue;
|
|
4926
4938
|
|
|
4927
4939
|
case 2 /* NumberValue */ :
|
|
4928
|
-
return
|
|
4940
|
+
return Nt(t.integerValue || t.doubleValue);
|
|
4929
4941
|
|
|
4930
4942
|
case 3 /* TimestampValue */ :
|
|
4931
4943
|
return this.convertTimestamp(t.timestampValue);
|
|
@@ -4937,7 +4949,7 @@ class br extends class {
|
|
|
4937
4949
|
return t.stringValue;
|
|
4938
4950
|
|
|
4939
4951
|
case 6 /* BlobValue */ :
|
|
4940
|
-
return this.convertBytes(
|
|
4952
|
+
return this.convertBytes(Dt(t.bytesValue));
|
|
4941
4953
|
|
|
4942
4954
|
case 7 /* RefValue */ :
|
|
4943
4955
|
return this.convertReference(t.referenceValue);
|
|
@@ -4952,17 +4964,17 @@ class br extends class {
|
|
|
4952
4964
|
return this.convertObject(t.mapValue, n);
|
|
4953
4965
|
|
|
4954
4966
|
default:
|
|
4955
|
-
throw
|
|
4967
|
+
throw v();
|
|
4956
4968
|
}
|
|
4957
4969
|
}
|
|
4958
4970
|
convertObject(t, n) {
|
|
4959
4971
|
const e = {};
|
|
4960
|
-
return
|
|
4972
|
+
return Tt(t.fields, ((t, r) => {
|
|
4961
4973
|
e[t] = this.convertValue(r, n);
|
|
4962
4974
|
})), e;
|
|
4963
4975
|
}
|
|
4964
4976
|
convertGeoPoint(t) {
|
|
4965
|
-
return new
|
|
4977
|
+
return new Ie(Nt(t.latitude), Nt(t.longitude));
|
|
4966
4978
|
}
|
|
4967
4979
|
convertArray(t, n) {
|
|
4968
4980
|
return (t.values || []).map((t => this.convertValue(t, n)));
|
|
@@ -4970,27 +4982,27 @@ class br extends class {
|
|
|
4970
4982
|
convertServerTimestamp(t, n) {
|
|
4971
4983
|
switch (n) {
|
|
4972
4984
|
case "previous":
|
|
4973
|
-
const e =
|
|
4985
|
+
const e = Ft(t);
|
|
4974
4986
|
return null == e ? null : this.convertValue(e, n);
|
|
4975
4987
|
|
|
4976
4988
|
case "estimate":
|
|
4977
|
-
return this.convertTimestamp(
|
|
4989
|
+
return this.convertTimestamp(St(t));
|
|
4978
4990
|
|
|
4979
4991
|
default:
|
|
4980
4992
|
return null;
|
|
4981
4993
|
}
|
|
4982
4994
|
}
|
|
4983
4995
|
convertTimestamp(t) {
|
|
4984
|
-
const n =
|
|
4985
|
-
return new
|
|
4996
|
+
const n = Vt(t);
|
|
4997
|
+
return new vt(n.seconds, n.nanos);
|
|
4986
4998
|
}
|
|
4987
4999
|
convertDocumentKey(t, n) {
|
|
4988
|
-
const e =
|
|
4989
|
-
|
|
4990
|
-
const r = new
|
|
5000
|
+
const e = Z.fromString(t);
|
|
5001
|
+
b(Jn(e));
|
|
5002
|
+
const r = new J(e.get(1), e.get(3)), s = new et(e.popFirst(5));
|
|
4991
5003
|
return r.isEqual(n) ||
|
|
4992
5004
|
// TODO(b/64130202): Somehow support foreign references.
|
|
4993
|
-
|
|
5005
|
+
y(`Document ${s} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${n.projectId}/${n.database}) instead.`),
|
|
4994
5006
|
s;
|
|
4995
5007
|
}
|
|
4996
5008
|
} {
|
|
@@ -4998,11 +5010,11 @@ class br extends class {
|
|
|
4998
5010
|
super(), this.firestore = t;
|
|
4999
5011
|
}
|
|
5000
5012
|
convertBytes(t) {
|
|
5001
|
-
return new
|
|
5013
|
+
return new Ee(t);
|
|
5002
5014
|
}
|
|
5003
5015
|
convertReference(t) {
|
|
5004
5016
|
const n = this.convertDocumentKey(t, this.firestore._databaseId);
|
|
5005
|
-
return new
|
|
5017
|
+
return new fe(this.firestore, /* converter= */ null, n);
|
|
5006
5018
|
}
|
|
5007
5019
|
}
|
|
5008
5020
|
|
|
@@ -5018,12 +5030,12 @@ class br extends class {
|
|
|
5018
5030
|
* @param reference - The reference of the document to fetch.
|
|
5019
5031
|
* @returns A Promise resolved with a `DocumentSnapshot` containing the current
|
|
5020
5032
|
* document contents.
|
|
5021
|
-
*/ function
|
|
5022
|
-
const n =
|
|
5023
|
-
return
|
|
5024
|
-
|
|
5033
|
+
*/ function Tr(t) {
|
|
5034
|
+
const n = ie((t = ut(t, fe)).firestore), e = new Er(t.firestore);
|
|
5035
|
+
return ee(n, [ t._key ]).then((n => {
|
|
5036
|
+
b(1 === n.length);
|
|
5025
5037
|
const r = n[0];
|
|
5026
|
-
return new
|
|
5038
|
+
return new Je(t.firestore, e, t._key, r.isFoundDocument() ? r : null, t.converter);
|
|
5027
5039
|
}));
|
|
5028
5040
|
}
|
|
5029
5041
|
|
|
@@ -5038,33 +5050,33 @@ class br extends class {
|
|
|
5038
5050
|
*
|
|
5039
5051
|
* @param query - The `Query` to execute.
|
|
5040
5052
|
* @returns A Promise that will be resolved with the results of the query.
|
|
5041
|
-
*/ function
|
|
5053
|
+
*/ function Ir(t) {
|
|
5042
5054
|
!function(t) {
|
|
5043
|
-
if (
|
|
5044
|
-
}((t =
|
|
5045
|
-
const n =
|
|
5046
|
-
return
|
|
5047
|
-
const r = n.map((n => new
|
|
5048
|
-
return
|
|
5055
|
+
if (hn(t) && 0 === t.explicitOrderBy.length) throw new U(O, "limitToLast() queries require specifying at least one orderBy() clause");
|
|
5056
|
+
}((t = ut(t, de))._query);
|
|
5057
|
+
const n = ie(t.firestore), e = new Er(t.firestore);
|
|
5058
|
+
return re(n, t._query).then((n => {
|
|
5059
|
+
const r = n.map((n => new Xe(t.firestore, e, n.key, n, t.converter)));
|
|
5060
|
+
return hn(t._query) &&
|
|
5049
5061
|
// Limit to last queries reverse the orderBy constraint that was
|
|
5050
5062
|
// specified by the user. As such, we need to reverse the order of the
|
|
5051
5063
|
// results to return the documents in the expected order.
|
|
5052
|
-
r.reverse(), new
|
|
5064
|
+
r.reverse(), new Ze(t, r);
|
|
5053
5065
|
}));
|
|
5054
5066
|
}
|
|
5055
5067
|
|
|
5056
|
-
function
|
|
5057
|
-
const r =
|
|
5058
|
-
return
|
|
5068
|
+
function Ar(t, n, e) {
|
|
5069
|
+
const r = br((t = ut(t, fe)).converter, n, e), s = Fe($e(t.firestore), "setDoc", t._key, r, null !== t.converter, e);
|
|
5070
|
+
return ne(ie(t.firestore), [ s.toMutation(t._key, In.none()) ]);
|
|
5059
5071
|
}
|
|
5060
5072
|
|
|
5061
|
-
function
|
|
5062
|
-
const s =
|
|
5073
|
+
function Pr(t, n, e, ...r) {
|
|
5074
|
+
const s = $e((t = ut(t, fe)).firestore);
|
|
5063
5075
|
// For Compat types, we have to "extract" the underlying types before
|
|
5064
5076
|
// performing validation.
|
|
5065
5077
|
let i;
|
|
5066
|
-
i = "string" == typeof (n =
|
|
5067
|
-
return
|
|
5078
|
+
i = "string" == typeof (n = l(n)) || n instanceof ve ? Ue(s, "updateDoc", t._key, n, e, r) : ke(s, "updateDoc", t._key, n);
|
|
5079
|
+
return ne(ie(t.firestore), [ i.toMutation(t._key, In.exists(!0)) ]);
|
|
5068
5080
|
}
|
|
5069
5081
|
|
|
5070
5082
|
/**
|
|
@@ -5078,8 +5090,8 @@ function Ar(t, n, e, ...r) {
|
|
|
5078
5090
|
* @param reference - A reference to the document to delete.
|
|
5079
5091
|
* @returns A `Promise` resolved once the document has been successfully
|
|
5080
5092
|
* deleted from the backend.
|
|
5081
|
-
*/ function
|
|
5082
|
-
return
|
|
5093
|
+
*/ function Rr(t) {
|
|
5094
|
+
return ne(ie((t = ut(t, fe)).firestore), [ new Vn(t._key, In.none()) ]);
|
|
5083
5095
|
}
|
|
5084
5096
|
|
|
5085
5097
|
/**
|
|
@@ -5093,11 +5105,12 @@ function Ar(t, n, e, ...r) {
|
|
|
5093
5105
|
*
|
|
5094
5106
|
* @param reference - A reference to the collection to add this document to.
|
|
5095
5107
|
* @param data - An Object containing the data for the new document.
|
|
5108
|
+
* @throws Error - If the provided input is not a valid Firestore document.
|
|
5096
5109
|
* @returns A `Promise` resolved with a `DocumentReference` pointing to the
|
|
5097
5110
|
* newly created document after it has been written to the backend.
|
|
5098
|
-
*/ function
|
|
5099
|
-
const e =
|
|
5100
|
-
return
|
|
5111
|
+
*/ function Vr(t, n) {
|
|
5112
|
+
const e = ye(t = ut(t, we)), r = br(t.converter, n), s = Fe($e(t.firestore), "addDoc", e._key, r, null !== e.converter, {});
|
|
5113
|
+
return ne(ie(t.firestore), [ s.toMutation(e._key, In.exists(!1)) ]).then((() => e));
|
|
5101
5114
|
}
|
|
5102
5115
|
|
|
5103
5116
|
/**
|
|
@@ -5119,14 +5132,14 @@ function Ar(t, n, e, ...r) {
|
|
|
5119
5132
|
/**
|
|
5120
5133
|
* Returns a sentinel for use with {@link @firebase/firestore/lite#(updateDoc:1)} or
|
|
5121
5134
|
* {@link @firebase/firestore/lite#(setDoc:1)} with `{merge: true}` to mark a field for deletion.
|
|
5122
|
-
*/ function
|
|
5123
|
-
return new
|
|
5135
|
+
*/ function Nr() {
|
|
5136
|
+
return new Se("deleteField");
|
|
5124
5137
|
}
|
|
5125
5138
|
|
|
5126
5139
|
/**
|
|
5127
5140
|
* Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
|
|
5128
5141
|
* include a server-generated timestamp in the written data.
|
|
5129
|
-
*/ function
|
|
5142
|
+
*/ function Dr() {
|
|
5130
5143
|
return new qe("serverTimestamp");
|
|
5131
5144
|
}
|
|
5132
5145
|
|
|
@@ -5141,10 +5154,10 @@ function Ar(t, n, e, ...r) {
|
|
|
5141
5154
|
* @param elements - The elements to union into the array.
|
|
5142
5155
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5143
5156
|
* `updateDoc()`.
|
|
5144
|
-
*/ function
|
|
5157
|
+
*/ function $r(...t) {
|
|
5145
5158
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5146
5159
|
// update() since we'd need the Firestore instance to do this.
|
|
5147
|
-
return new
|
|
5160
|
+
return new Oe("arrayUnion", t);
|
|
5148
5161
|
}
|
|
5149
5162
|
|
|
5150
5163
|
/**
|
|
@@ -5157,10 +5170,10 @@ function Ar(t, n, e, ...r) {
|
|
|
5157
5170
|
* @param elements - The elements to remove from the array.
|
|
5158
5171
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5159
5172
|
* `updateDoc()`
|
|
5160
|
-
*/ function
|
|
5173
|
+
*/ function Fr(...t) {
|
|
5161
5174
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5162
5175
|
// update() since we'd need the Firestore instance to do this.
|
|
5163
|
-
return new
|
|
5176
|
+
return new Ce("arrayRemove", t);
|
|
5164
5177
|
}
|
|
5165
5178
|
|
|
5166
5179
|
/**
|
|
@@ -5181,8 +5194,8 @@ function Ar(t, n, e, ...r) {
|
|
|
5181
5194
|
* @param n - The value to increment by.
|
|
5182
5195
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5183
5196
|
* `updateDoc()`
|
|
5184
|
-
*/ function
|
|
5185
|
-
return new
|
|
5197
|
+
*/ function Sr(t) {
|
|
5198
|
+
return new Le("increment", t);
|
|
5186
5199
|
}
|
|
5187
5200
|
|
|
5188
5201
|
/**
|
|
@@ -5208,16 +5221,16 @@ function Ar(t, n, e, ...r) {
|
|
|
5208
5221
|
* provides methods for adding writes to the write batch. None of the writes
|
|
5209
5222
|
* will be committed (or visible locally) until {@link WriteBatch.commit} is
|
|
5210
5223
|
* called.
|
|
5211
|
-
*/ class
|
|
5224
|
+
*/ class xr {
|
|
5212
5225
|
/** @hideconstructor */
|
|
5213
5226
|
constructor(t, n) {
|
|
5214
5227
|
this._firestore = t, this._commitHandler = n, this._mutations = [], this._committed = !1,
|
|
5215
|
-
this._dataReader =
|
|
5228
|
+
this._dataReader = $e(t);
|
|
5216
5229
|
}
|
|
5217
5230
|
set(t, n, e) {
|
|
5218
5231
|
this._verifyNotCommitted();
|
|
5219
|
-
const r = qr(t, this._firestore), s =
|
|
5220
|
-
return this._mutations.push(i.toMutation(r._key,
|
|
5232
|
+
const r = qr(t, this._firestore), s = br(r.converter, n, e), i = Fe(this._dataReader, "WriteBatch.set", r._key, s, null !== r.converter, e);
|
|
5233
|
+
return this._mutations.push(i.toMutation(r._key, In.none())), this;
|
|
5221
5234
|
}
|
|
5222
5235
|
update(t, n, e, ...r) {
|
|
5223
5236
|
this._verifyNotCommitted();
|
|
@@ -5225,8 +5238,8 @@ function Ar(t, n, e, ...r) {
|
|
|
5225
5238
|
// For Compat types, we have to "extract" the underlying types before
|
|
5226
5239
|
// performing validation.
|
|
5227
5240
|
let i;
|
|
5228
|
-
return i = "string" == typeof (n =
|
|
5229
|
-
this._mutations.push(i.toMutation(s._key,
|
|
5241
|
+
return i = "string" == typeof (n = l(n)) || n instanceof ve ? Ue(this._dataReader, "WriteBatch.update", s._key, n, e, r) : ke(this._dataReader, "WriteBatch.update", s._key, n),
|
|
5242
|
+
this._mutations.push(i.toMutation(s._key, In.exists(!0))), this;
|
|
5230
5243
|
}
|
|
5231
5244
|
/**
|
|
5232
5245
|
* Deletes the document referred to by the provided {@link DocumentReference}.
|
|
@@ -5236,7 +5249,7 @@ function Ar(t, n, e, ...r) {
|
|
|
5236
5249
|
*/ delete(t) {
|
|
5237
5250
|
this._verifyNotCommitted();
|
|
5238
5251
|
const n = qr(t, this._firestore);
|
|
5239
|
-
return this._mutations = this._mutations.concat(new
|
|
5252
|
+
return this._mutations = this._mutations.concat(new Vn(n._key, In.none())), this;
|
|
5240
5253
|
}
|
|
5241
5254
|
/**
|
|
5242
5255
|
* Commits all of the writes in this write batch as a single atomic unit.
|
|
@@ -5253,12 +5266,12 @@ function Ar(t, n, e, ...r) {
|
|
|
5253
5266
|
return this._verifyNotCommitted(), this._committed = !0, this._mutations.length > 0 ? this._commitHandler(this._mutations) : Promise.resolve();
|
|
5254
5267
|
}
|
|
5255
5268
|
_verifyNotCommitted() {
|
|
5256
|
-
if (this._committed) throw new
|
|
5269
|
+
if (this._committed) throw new U(S, "A write batch can no longer be used after commit() has been called.");
|
|
5257
5270
|
}
|
|
5258
5271
|
}
|
|
5259
5272
|
|
|
5260
5273
|
function qr(t, n) {
|
|
5261
|
-
if ((t =
|
|
5274
|
+
if ((t = l(t)).firestore !== n) throw new U(P, "Provided document reference is from a different Firestore instance.");
|
|
5262
5275
|
return t;
|
|
5263
5276
|
}
|
|
5264
5277
|
|
|
@@ -5274,9 +5287,9 @@ function qr(t, n) {
|
|
|
5274
5287
|
*
|
|
5275
5288
|
* @returns A `WriteBatch` that can be used to atomically execute multiple
|
|
5276
5289
|
* writes.
|
|
5277
|
-
*/ function
|
|
5278
|
-
const n =
|
|
5279
|
-
return new
|
|
5290
|
+
*/ function Or(t) {
|
|
5291
|
+
const n = ie(t = ut(t, ue));
|
|
5292
|
+
return new xr(t, (t => ne(n, t)));
|
|
5280
5293
|
}
|
|
5281
5294
|
|
|
5282
5295
|
/**
|
|
@@ -5298,7 +5311,7 @@ function qr(t, n) {
|
|
|
5298
5311
|
/**
|
|
5299
5312
|
* Internal transaction object responsible for accumulating the mutations to
|
|
5300
5313
|
* perform and the base versions for any documents read.
|
|
5301
|
-
*/ class
|
|
5314
|
+
*/ class Cr {
|
|
5302
5315
|
constructor(t) {
|
|
5303
5316
|
this.datastore = t,
|
|
5304
5317
|
// The version of each document that was read during this transaction.
|
|
@@ -5317,8 +5330,8 @@ function qr(t, n) {
|
|
|
5317
5330
|
this.writtenDocs = new Set;
|
|
5318
5331
|
}
|
|
5319
5332
|
async lookup(t) {
|
|
5320
|
-
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new
|
|
5321
|
-
const n = await
|
|
5333
|
+
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new U(P, "Firestore transactions require all reads to be executed before all writes.");
|
|
5334
|
+
const n = await ee(this.datastore, t);
|
|
5322
5335
|
return n.forEach((t => this.recordVersion(t))), n;
|
|
5323
5336
|
}
|
|
5324
5337
|
set(t, n) {
|
|
@@ -5333,7 +5346,7 @@ function qr(t, n) {
|
|
|
5333
5346
|
this.writtenDocs.add(t.toString());
|
|
5334
5347
|
}
|
|
5335
5348
|
delete(t) {
|
|
5336
|
-
this.write(new
|
|
5349
|
+
this.write(new Vn(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5337
5350
|
}
|
|
5338
5351
|
async commit() {
|
|
5339
5352
|
if (this.ensureCommitNotCalled(), this.lastWriteError) throw this.lastWriteError;
|
|
@@ -5345,22 +5358,22 @@ function qr(t, n) {
|
|
|
5345
5358
|
// For each document that was read but not written to, we want to perform
|
|
5346
5359
|
// a `verify` operation.
|
|
5347
5360
|
t.forEach(((t, n) => {
|
|
5348
|
-
const e =
|
|
5349
|
-
this.mutations.push(new
|
|
5350
|
-
})), await
|
|
5361
|
+
const e = et.fromPath(n);
|
|
5362
|
+
this.mutations.push(new Nn(e, this.precondition(e)));
|
|
5363
|
+
})), await ne(this.datastore, this.mutations), this.committed = !0;
|
|
5351
5364
|
}
|
|
5352
5365
|
recordVersion(t) {
|
|
5353
5366
|
let n;
|
|
5354
5367
|
if (t.isFoundDocument()) n = t.version; else {
|
|
5355
|
-
if (!t.isNoDocument()) throw
|
|
5368
|
+
if (!t.isNoDocument()) throw v();
|
|
5356
5369
|
// For deleted docs, we must use baseVersion 0 when we overwrite them.
|
|
5357
|
-
n =
|
|
5370
|
+
n = bt.min();
|
|
5358
5371
|
}
|
|
5359
5372
|
const e = this.readVersions.get(t.key.toString());
|
|
5360
5373
|
if (e) {
|
|
5361
5374
|
if (!n.isEqual(e))
|
|
5362
5375
|
// This transaction will fail no matter what.
|
|
5363
|
-
throw new
|
|
5376
|
+
throw new U(x, "Document version changed between two reads.");
|
|
5364
5377
|
} else this.readVersions.set(t.key.toString(), n);
|
|
5365
5378
|
}
|
|
5366
5379
|
/**
|
|
@@ -5368,7 +5381,7 @@ function qr(t, n) {
|
|
|
5368
5381
|
* as a precondition, or no precondition if it was not read.
|
|
5369
5382
|
*/ precondition(t) {
|
|
5370
5383
|
const n = this.readVersions.get(t.toString());
|
|
5371
|
-
return !this.writtenDocs.has(t.toString()) && n ?
|
|
5384
|
+
return !this.writtenDocs.has(t.toString()) && n ? In.updateTime(n) : In.none();
|
|
5372
5385
|
}
|
|
5373
5386
|
/**
|
|
5374
5387
|
* Returns the precondition for a document if the operation is an update.
|
|
@@ -5377,7 +5390,7 @@ function qr(t, n) {
|
|
|
5377
5390
|
// The first time a document is written, we want to take into account the
|
|
5378
5391
|
// read time and existence
|
|
5379
5392
|
if (!this.writtenDocs.has(t.toString()) && n) {
|
|
5380
|
-
if (n.isEqual(
|
|
5393
|
+
if (n.isEqual(bt.min()))
|
|
5381
5394
|
// The document doesn't exist, so fail the transaction.
|
|
5382
5395
|
// This has to be validated locally because you can't send a
|
|
5383
5396
|
// precondition that a document does not exist without changing the
|
|
@@ -5387,13 +5400,13 @@ function qr(t, n) {
|
|
|
5387
5400
|
// express that to the backend, we have to validate locally.
|
|
5388
5401
|
// Note: this can change once we can send separate verify writes in the
|
|
5389
5402
|
// transaction.
|
|
5390
|
-
throw new
|
|
5403
|
+
throw new U(P, "Can't update a document that doesn't exist.");
|
|
5391
5404
|
// Document exists, base precondition on document update time.
|
|
5392
|
-
return
|
|
5405
|
+
return In.updateTime(n);
|
|
5393
5406
|
}
|
|
5394
5407
|
// Document was not read, so we just use the preconditions for a blind
|
|
5395
5408
|
// update.
|
|
5396
|
-
return
|
|
5409
|
+
return In.exists(!0);
|
|
5397
5410
|
}
|
|
5398
5411
|
write(t) {
|
|
5399
5412
|
this.ensureCommitNotCalled(), this.mutations.push(t);
|
|
@@ -5421,17 +5434,17 @@ function qr(t, n) {
|
|
|
5421
5434
|
* TransactionRunner encapsulates the logic needed to run and retry transactions
|
|
5422
5435
|
* with backoff.
|
|
5423
5436
|
*/
|
|
5424
|
-
class
|
|
5437
|
+
class Lr {
|
|
5425
5438
|
constructor(t, n, e, r) {
|
|
5426
5439
|
this.asyncQueue = t, this.datastore = n, this.updateFunction = e, this.deferred = r,
|
|
5427
|
-
this.Tt = 5, this.It = new
|
|
5440
|
+
this.Tt = 5, this.It = new Zn(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
|
|
5428
5441
|
}
|
|
5429
5442
|
/** Runs the transaction and sets the result on deferred. */ run() {
|
|
5430
5443
|
this.Tt -= 1, this.At();
|
|
5431
5444
|
}
|
|
5432
5445
|
At() {
|
|
5433
5446
|
this.It.W((async () => {
|
|
5434
|
-
const t = new
|
|
5447
|
+
const t = new Cr(this.datastore), n = this.Pt(t);
|
|
5435
5448
|
n && n.then((n => {
|
|
5436
5449
|
this.asyncQueue.enqueueAndForget((() => t.commit().then((() => {
|
|
5437
5450
|
this.deferred.resolve(n);
|
|
@@ -5446,7 +5459,7 @@ class Cr {
|
|
|
5446
5459
|
Pt(t) {
|
|
5447
5460
|
try {
|
|
5448
5461
|
const n = this.updateFunction(t);
|
|
5449
|
-
return !
|
|
5462
|
+
return !at(n) && n.catch && n.then ? n : (this.deferred.reject(Error("Transaction callback must return a Promise")),
|
|
5450
5463
|
null);
|
|
5451
5464
|
} catch (t) {
|
|
5452
5465
|
// Do not retry errors thrown by user provided updateFunction.
|
|
@@ -5472,31 +5485,31 @@ class Cr {
|
|
|
5472
5485
|
function(t) {
|
|
5473
5486
|
switch (t) {
|
|
5474
5487
|
default:
|
|
5475
|
-
return
|
|
5488
|
+
return v();
|
|
5476
5489
|
|
|
5477
|
-
case T:
|
|
5478
5490
|
case I:
|
|
5479
|
-
case
|
|
5480
|
-
case
|
|
5481
|
-
case
|
|
5491
|
+
case A:
|
|
5492
|
+
case R:
|
|
5493
|
+
case F:
|
|
5482
5494
|
case C:
|
|
5495
|
+
case L:
|
|
5483
5496
|
// Unauthenticated means something went wrong with our token and we need
|
|
5484
5497
|
// to retry with new credentials which will happen automatically.
|
|
5485
|
-
case
|
|
5498
|
+
case $:
|
|
5486
5499
|
return !1;
|
|
5487
5500
|
|
|
5488
|
-
case
|
|
5489
|
-
case R:
|
|
5501
|
+
case P:
|
|
5490
5502
|
case V:
|
|
5491
5503
|
case N:
|
|
5492
|
-
case
|
|
5504
|
+
case D:
|
|
5505
|
+
case S:
|
|
5493
5506
|
// Aborted might be retried in some scenarios, but that is dependant on
|
|
5494
5507
|
// the context and should handled individually by the calling code.
|
|
5495
5508
|
// See https://cloud.google.com/apis/design/errors.
|
|
5496
|
-
case
|
|
5509
|
+
case x:
|
|
5497
5510
|
case q:
|
|
5498
|
-
case
|
|
5499
|
-
case
|
|
5511
|
+
case O:
|
|
5512
|
+
case k:
|
|
5500
5513
|
return !0;
|
|
5501
5514
|
}
|
|
5502
5515
|
}(n);
|
|
@@ -5521,7 +5534,7 @@ class Cr {
|
|
|
5521
5534
|
* See the License for the specific language governing permissions and
|
|
5522
5535
|
* limitations under the License.
|
|
5523
5536
|
*/
|
|
5524
|
-
/** The Platform's 'document' implementation or null if not available. */ function
|
|
5537
|
+
/** The Platform's 'document' implementation or null if not available. */ function kr() {
|
|
5525
5538
|
// `document` is not always available, e.g. in ReactNative and WebWorkers.
|
|
5526
5539
|
// eslint-disable-next-line no-restricted-globals
|
|
5527
5540
|
return "undefined" != typeof document ? document : null;
|
|
@@ -5553,10 +5566,10 @@ class Cr {
|
|
|
5553
5566
|
* Note: We implement `PromiseLike` instead of `Promise`, as the `Promise` type
|
|
5554
5567
|
* in newer versions of TypeScript defines `finally`, which is not available in
|
|
5555
5568
|
* IE.
|
|
5556
|
-
*/ class
|
|
5569
|
+
*/ class Ur {
|
|
5557
5570
|
constructor(t, n, e, r, s) {
|
|
5558
5571
|
this.asyncQueue = t, this.timerId = n, this.targetTimeMs = e, this.op = r, this.removalCallback = s,
|
|
5559
|
-
this.deferred = new
|
|
5572
|
+
this.deferred = new j, this.then = this.deferred.promise.then.bind(this.deferred.promise),
|
|
5560
5573
|
// It's normal for the deferred promise to be canceled (due to cancellation)
|
|
5561
5574
|
// and so we attach a dummy catch callback to avoid
|
|
5562
5575
|
// 'UnhandledPromiseRejectionWarning' log spam.
|
|
@@ -5576,7 +5589,7 @@ class Cr {
|
|
|
5576
5589
|
* PORTING NOTE: This exists to prevent making removeDelayedOperation() and
|
|
5577
5590
|
* the DelayedOperation class public.
|
|
5578
5591
|
*/ static createAndSchedule(t, n, e, r, s) {
|
|
5579
|
-
const i = Date.now() + e, o = new
|
|
5592
|
+
const i = Date.now() + e, o = new Ur(t, n, i, r, s);
|
|
5580
5593
|
return o.start(e), o;
|
|
5581
5594
|
}
|
|
5582
5595
|
/**
|
|
@@ -5598,7 +5611,7 @@ class Cr {
|
|
|
5598
5611
|
* As long as the operation has not yet been run, calling cancel() provides a
|
|
5599
5612
|
* guarantee that the operation will not be run.
|
|
5600
5613
|
*/ cancel(t) {
|
|
5601
|
-
null !== this.timerHandle && (this.clearTimeout(), this.deferred.reject(new
|
|
5614
|
+
null !== this.timerHandle && (this.clearTimeout(), this.deferred.reject(new U(I, "Operation cancelled" + (t ? ": " + t : ""))));
|
|
5602
5615
|
}
|
|
5603
5616
|
handleDelayElapsed() {
|
|
5604
5617
|
this.asyncQueue.enqueueAndForget((() => null !== this.timerHandle ? (this.clearTimeout(),
|
|
@@ -5625,7 +5638,7 @@ class Cr {
|
|
|
5625
5638
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5626
5639
|
* See the License for the specific language governing permissions and
|
|
5627
5640
|
* limitations under the License.
|
|
5628
|
-
*/ class
|
|
5641
|
+
*/ class jr {
|
|
5629
5642
|
constructor() {
|
|
5630
5643
|
// The last promise in the queue.
|
|
5631
5644
|
this.Nt = Promise.resolve(),
|
|
@@ -5642,21 +5655,21 @@ class Cr {
|
|
|
5642
5655
|
this.St = null,
|
|
5643
5656
|
// Flag set while there's an outstanding AsyncQueue operation, used for
|
|
5644
5657
|
// assertion sanity-checks.
|
|
5645
|
-
this.qt = !1,
|
|
5646
|
-
// Enabled during shutdown on Safari to prevent future access to IndexedDB.
|
|
5647
5658
|
this.xt = !1,
|
|
5659
|
+
// Enabled during shutdown on Safari to prevent future access to IndexedDB.
|
|
5660
|
+
this.qt = !1,
|
|
5648
5661
|
// List of TimerIds to fast-forward delays for.
|
|
5649
5662
|
this.Ot = [],
|
|
5650
5663
|
// Backoff timer used to schedule retries for retryable operations
|
|
5651
|
-
this.It = new
|
|
5664
|
+
this.It = new Zn(this, "async_queue_retry" /* AsyncQueueRetry */),
|
|
5652
5665
|
// Visibility handler that triggers an immediate retry of all retryable
|
|
5653
5666
|
// operations. Meant to speed up recovery when we regain file system access
|
|
5654
5667
|
// after page comes into foreground.
|
|
5655
5668
|
this.Ct = () => {
|
|
5656
|
-
const t =
|
|
5657
|
-
t &&
|
|
5669
|
+
const t = kr();
|
|
5670
|
+
t && p("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.It.H();
|
|
5658
5671
|
};
|
|
5659
|
-
const t =
|
|
5672
|
+
const t = kr();
|
|
5660
5673
|
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.Ct);
|
|
5661
5674
|
}
|
|
5662
5675
|
get isShuttingDown() {
|
|
@@ -5676,8 +5689,8 @@ class Cr {
|
|
|
5676
5689
|
}
|
|
5677
5690
|
enterRestrictedMode(t) {
|
|
5678
5691
|
if (!this.$t) {
|
|
5679
|
-
this.$t = !0, this.
|
|
5680
|
-
const n =
|
|
5692
|
+
this.$t = !0, this.qt = t || !1;
|
|
5693
|
+
const n = kr();
|
|
5681
5694
|
n && "function" == typeof n.removeEventListener && n.removeEventListener("visibilitychange", this.Ct);
|
|
5682
5695
|
}
|
|
5683
5696
|
}
|
|
@@ -5688,8 +5701,8 @@ class Cr {
|
|
|
5688
5701
|
// Create a deferred Promise that we can return to the callee. This
|
|
5689
5702
|
// allows us to return a "hanging Promise" only to the callee and still
|
|
5690
5703
|
// advance the queue even when the operation is not run.
|
|
5691
|
-
const n = new
|
|
5692
|
-
return this.kt((() => this.$t && this.
|
|
5704
|
+
const n = new j;
|
|
5705
|
+
return this.kt((() => this.$t && this.qt ? Promise.resolve() : (t().then(n.resolve, n.reject),
|
|
5693
5706
|
n.promise))).then((() => n.promise));
|
|
5694
5707
|
}
|
|
5695
5708
|
enqueueRetryable(t) {
|
|
@@ -5743,7 +5756,7 @@ class Cr {
|
|
|
5743
5756
|
* limitations under the License.
|
|
5744
5757
|
*/ (t)) throw t;
|
|
5745
5758
|
// Failure will be handled by AsyncQueue
|
|
5746
|
-
|
|
5759
|
+
p("AsyncQueue", "Operation failed with retryable error: " + t);
|
|
5747
5760
|
}
|
|
5748
5761
|
this.Dt.length > 0 &&
|
|
5749
5762
|
// If there are additional operations, we re-schedule `retryNextOp()`.
|
|
@@ -5760,8 +5773,8 @@ class Cr {
|
|
|
5760
5773
|
}
|
|
5761
5774
|
}
|
|
5762
5775
|
kt(t) {
|
|
5763
|
-
const n = this.Nt.then((() => (this.
|
|
5764
|
-
this.St = t, this.
|
|
5776
|
+
const n = this.Nt.then((() => (this.xt = !0, t().catch((t => {
|
|
5777
|
+
this.St = t, this.xt = !1;
|
|
5765
5778
|
const n =
|
|
5766
5779
|
/**
|
|
5767
5780
|
* Chrome includes Error.message in Error.stack. Other browsers do not.
|
|
@@ -5801,19 +5814,19 @@ class Cr {
|
|
|
5801
5814
|
// Re-throw the error so that this.tail becomes a rejected Promise and
|
|
5802
5815
|
// all further attempts to chain (via .then) will just short-circuit
|
|
5803
5816
|
// and return the rejected Promise.
|
|
5804
|
-
throw
|
|
5805
|
-
})).then((t => (this.
|
|
5817
|
+
throw y("INTERNAL UNHANDLED ERROR: ", n), t;
|
|
5818
|
+
})).then((t => (this.xt = !1, t))))));
|
|
5806
5819
|
return this.Nt = n, n;
|
|
5807
5820
|
}
|
|
5808
5821
|
enqueueAfterDelay(t, n, e) {
|
|
5809
5822
|
this.Lt(),
|
|
5810
5823
|
// Fast-forward delays for timerIds that have been overriden.
|
|
5811
5824
|
this.Ot.indexOf(t) > -1 && (n = 0);
|
|
5812
|
-
const r =
|
|
5825
|
+
const r = Ur.createAndSchedule(this, t, n, e, (t => this.jt(t)));
|
|
5813
5826
|
return this.Ft.push(r), r;
|
|
5814
5827
|
}
|
|
5815
5828
|
Lt() {
|
|
5816
|
-
this.St &&
|
|
5829
|
+
this.St && v();
|
|
5817
5830
|
}
|
|
5818
5831
|
verifyOperationInProgress() {}
|
|
5819
5832
|
/**
|
|
@@ -5863,10 +5876,10 @@ class Cr {
|
|
|
5863
5876
|
}
|
|
5864
5877
|
}
|
|
5865
5878
|
|
|
5866
|
-
class
|
|
5879
|
+
class Mr {
|
|
5867
5880
|
/** @hideconstructor */
|
|
5868
5881
|
constructor(t, n) {
|
|
5869
|
-
this._firestore = t, this._transaction = n, this._dataReader =
|
|
5882
|
+
this._firestore = t, this._transaction = n, this._dataReader = $e(t);
|
|
5870
5883
|
}
|
|
5871
5884
|
/**
|
|
5872
5885
|
* Reads the document referenced by the provided {@link DocumentReference}.
|
|
@@ -5874,17 +5887,17 @@ class jr {
|
|
|
5874
5887
|
* @param documentRef - A reference to the document to be read.
|
|
5875
5888
|
* @returns A `DocumentSnapshot` with the read data.
|
|
5876
5889
|
*/ get(t) {
|
|
5877
|
-
const n = qr(t, this._firestore), e = new
|
|
5890
|
+
const n = qr(t, this._firestore), e = new Er(this._firestore);
|
|
5878
5891
|
return this._transaction.lookup([ n._key ]).then((t => {
|
|
5879
|
-
if (!t || 1 !== t.length) return
|
|
5892
|
+
if (!t || 1 !== t.length) return v();
|
|
5880
5893
|
const r = t[0];
|
|
5881
|
-
if (r.isFoundDocument()) return new
|
|
5882
|
-
if (r.isNoDocument()) return new
|
|
5883
|
-
throw
|
|
5894
|
+
if (r.isFoundDocument()) return new Je(this._firestore, e, r.key, r, n.converter);
|
|
5895
|
+
if (r.isNoDocument()) return new Je(this._firestore, e, n._key, null, n.converter);
|
|
5896
|
+
throw v();
|
|
5884
5897
|
}));
|
|
5885
5898
|
}
|
|
5886
5899
|
set(t, n, e) {
|
|
5887
|
-
const r = qr(t, this._firestore), s =
|
|
5900
|
+
const r = qr(t, this._firestore), s = br(r.converter, n, e), i = Fe(this._dataReader, "Transaction.set", r._key, s, null !== r.converter, e);
|
|
5888
5901
|
return this._transaction.set(r._key, i), this;
|
|
5889
5902
|
}
|
|
5890
5903
|
update(t, n, e, ...r) {
|
|
@@ -5892,7 +5905,7 @@ class jr {
|
|
|
5892
5905
|
// For Compat types, we have to "extract" the underlying types before
|
|
5893
5906
|
// performing validation.
|
|
5894
5907
|
let i;
|
|
5895
|
-
return i = "string" == typeof (n =
|
|
5908
|
+
return i = "string" == typeof (n = l(n)) || n instanceof ve ? Ue(this._dataReader, "Transaction.update", s._key, n, e, r) : ke(this._dataReader, "Transaction.update", s._key, n),
|
|
5896
5909
|
this._transaction.update(s._key, i), this;
|
|
5897
5910
|
}
|
|
5898
5911
|
/**
|
|
@@ -5922,9 +5935,9 @@ class jr {
|
|
|
5922
5935
|
* (the `updateFunction` returned a failed promise), the promise returned by the
|
|
5923
5936
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
5924
5937
|
* rejected promise with the corresponding failure error is returned.
|
|
5925
|
-
*/ function
|
|
5926
|
-
const e =
|
|
5927
|
-
return new
|
|
5938
|
+
*/ function Br(t, n) {
|
|
5939
|
+
const e = ie(t = ut(t, ue)), r = new j;
|
|
5940
|
+
return new Lr(new jr, e, (e => n(new Mr(t, e))), r).run(), r.promise;
|
|
5928
5941
|
}
|
|
5929
5942
|
|
|
5930
5943
|
/**
|
|
@@ -5935,13 +5948,13 @@ class jr {
|
|
|
5935
5948
|
* directly to the backend, and `onSnapshot()` APIs are not supported.
|
|
5936
5949
|
* @packageDocumentation
|
|
5937
5950
|
*/ !function(t) {
|
|
5938
|
-
|
|
5951
|
+
d = t;
|
|
5939
5952
|
}(`${s}_lite`), e(new i("firestore/lite", ((t, {options: n}) => {
|
|
5940
|
-
const e = t.getProvider("app").getImmediate(), r = new
|
|
5953
|
+
const e = t.getProvider("app").getImmediate(), r = new ue(e, new Q(t.getProvider("auth-internal")), new H(t.getProvider("app-check-internal")));
|
|
5941
5954
|
return n && r._setSettings(n), r;
|
|
5942
5955
|
}), "PUBLIC")),
|
|
5943
5956
|
// RUNTIME_ENV and BUILD_TARGET are replaced by real values during the compilation
|
|
5944
|
-
r("firestore-lite", "3.4.
|
|
5957
|
+
r("firestore-lite", "3.4.2-202205224240", "rn"), r("firestore-lite", "3.4.2-202205224240", "esm2017");
|
|
5945
5958
|
|
|
5946
|
-
export {
|
|
5959
|
+
export { Ee as Bytes, we as CollectionReference, fe as DocumentReference, Je as DocumentSnapshot, ve as FieldPath, Te as FieldValue, ue as Firestore, U as FirestoreError, Ie as GeoPoint, de as Query, er as QueryConstraint, Xe as QueryDocumentSnapshot, Ze as QuerySnapshot, vt as Timestamp, Mr as Transaction, xr as WriteBatch, Vr as addDoc, Fr as arrayRemove, $r as arrayUnion, me as collection, pe as collectionGroup, he as connectFirestoreEmulator, Rr as deleteDoc, Nr as deleteField, ye as doc, be as documentId, pr as endAt, mr as endBefore, Tr as getDoc, Ir as getDocs, ae as getFirestore, Sr as increment, ce as initializeFirestore, ar as limit, hr as limitToLast, ur as orderBy, rr as query, ge as queryEqual, _e as refEqual, Br as runTransaction, Dr as serverTimestamp, Ar as setDoc, m as setLogLevel, tr as snapshotEqual, dr as startAfter, fr as startAt, le as terminate, Pr as updateDoc, ir as where, Or as writeBatch };
|
|
5947
5960
|
//# sourceMappingURL=index.rn.esm2017.js.map
|