@firebase/firestore 3.4.9 → 3.4.10-canary.ebc17e27f
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 +14 -0
- package/dist/firestore/src/api/transaction.d.ts +2 -0
- package/dist/firestore/src/core/component_provider.d.ts +11 -6
- package/dist/firestore/src/lite-api/transaction.d.ts +2 -0
- package/dist/firestore/src/local/document_overlay_cache.d.ts +5 -0
- package/dist/firestore/src/local/index_backfiller.d.ts +44 -0
- package/dist/firestore/src/local/index_manager.d.ts +2 -0
- package/dist/firestore/src/local/indexeddb_document_overlay_cache.d.ts +1 -0
- package/dist/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
- package/dist/firestore/src/local/indexeddb_schema.d.ts +3 -2
- package/dist/firestore/src/local/indexeddb_schema_converter.d.ts +1 -0
- package/dist/firestore/src/local/indexeddb_sentinels.d.ts +1 -0
- package/dist/firestore/src/local/local_documents_view.d.ts +64 -9
- package/dist/firestore/src/local/local_store.d.ts +9 -0
- package/dist/firestore/src/local/lru_garbage_collector_impl.d.ts +5 -5
- package/dist/firestore/src/local/memory_document_overlay_cache.d.ts +1 -0
- package/dist/firestore/src/local/memory_index_manager.d.ts +1 -0
- package/dist/firestore/src/local/overlayed_document.d.ts +36 -0
- package/dist/firestore/src/local/persistence.d.ts +3 -5
- package/dist/firestore/src/local/persistence_promise.d.ts +11 -0
- package/dist/firestore/src/local/query_engine.d.ts +1 -1
- package/dist/firestore/src/model/collections.d.ts +8 -2
- package/dist/firestore/src/model/field_mask.d.ts +6 -0
- package/dist/firestore/src/model/mutation.d.ts +19 -1
- package/dist/firestore/src/model/mutation_batch.d.ts +8 -4
- package/dist/firestore/src/tsdoc-metadata.json +11 -11
- package/dist/firestore/src/util/async_queue.d.ts +5 -1
- package/dist/firestore/test/unit/local/index_backfiller.test.d.ts +17 -0
- package/dist/firestore/test/unit/local/test_document_overlay_cache.d.ts +1 -0
- package/dist/firestore/test/unit/specs/spec_test_components.d.ts +5 -3
- package/dist/firestore/test/util/helpers.d.ts +13 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.esm2017.js +10689 -10296
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +9353 -8844
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +6738 -6123
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +6738 -6123
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +9818 -9424
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +6137 -5964
- package/dist/lite/firestore/src/api/transaction.d.ts +2 -0
- package/dist/lite/firestore/src/core/component_provider.d.ts +11 -6
- package/dist/lite/firestore/src/lite-api/transaction.d.ts +2 -0
- package/dist/lite/firestore/src/local/document_overlay_cache.d.ts +5 -0
- package/dist/lite/firestore/src/local/index_backfiller.d.ts +44 -0
- package/dist/lite/firestore/src/local/index_manager.d.ts +2 -0
- package/dist/lite/firestore/src/local/indexeddb_document_overlay_cache.d.ts +1 -0
- package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
- package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +3 -2
- package/dist/lite/firestore/src/local/indexeddb_schema_converter.d.ts +1 -0
- package/dist/lite/firestore/src/local/indexeddb_sentinels.d.ts +1 -0
- package/dist/lite/firestore/src/local/local_documents_view.d.ts +64 -9
- package/dist/lite/firestore/src/local/local_store.d.ts +9 -0
- package/dist/lite/firestore/src/local/lru_garbage_collector_impl.d.ts +5 -5
- package/dist/lite/firestore/src/local/memory_document_overlay_cache.d.ts +1 -0
- package/dist/lite/firestore/src/local/memory_index_manager.d.ts +1 -0
- package/dist/lite/firestore/src/local/overlayed_document.d.ts +36 -0
- package/dist/lite/firestore/src/local/persistence.d.ts +3 -5
- package/dist/lite/firestore/src/local/persistence_promise.d.ts +11 -0
- package/dist/lite/firestore/src/local/query_engine.d.ts +1 -1
- package/dist/lite/firestore/src/model/collections.d.ts +8 -2
- package/dist/lite/firestore/src/model/field_mask.d.ts +6 -0
- package/dist/lite/firestore/src/model/mutation.d.ts +19 -1
- package/dist/lite/firestore/src/model/mutation_batch.d.ts +8 -4
- package/dist/lite/firestore/src/util/async_queue.d.ts +5 -1
- package/dist/lite/firestore/test/unit/local/index_backfiller.test.d.ts +17 -0
- package/dist/lite/firestore/test/unit/local/test_document_overlay_cache.d.ts +1 -0
- package/dist/lite/firestore/test/unit/specs/spec_test_components.d.ts +5 -3
- package/dist/lite/firestore/test/util/helpers.d.ts +13 -0
- package/dist/lite/index.browser.esm2017.js +1220 -738
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +1156 -764
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.d.ts +2 -0
- package/dist/lite/index.node.cjs.js +655 -2
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +655 -2
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +1184 -702
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +2916 -2898
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +106 -104
- package/dist/lite/packages/firestore/src/api/transaction.d.ts +2 -0
- package/dist/lite/packages/firestore/src/core/component_provider.d.ts +11 -6
- package/dist/lite/packages/firestore/src/lite-api/transaction.d.ts +2 -0
- package/dist/lite/packages/firestore/src/local/document_overlay_cache.d.ts +5 -0
- package/dist/lite/packages/firestore/src/local/index_backfiller.d.ts +44 -0
- package/dist/lite/packages/firestore/src/local/index_manager.d.ts +2 -0
- package/dist/lite/packages/firestore/src/local/indexeddb_document_overlay_cache.d.ts +1 -0
- package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
- package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +3 -2
- package/dist/lite/packages/firestore/src/local/indexeddb_schema_converter.d.ts +1 -0
- package/dist/lite/packages/firestore/src/local/indexeddb_sentinels.d.ts +1 -0
- package/dist/lite/packages/firestore/src/local/local_documents_view.d.ts +64 -9
- package/dist/lite/packages/firestore/src/local/local_store.d.ts +9 -0
- package/dist/lite/packages/firestore/src/local/lru_garbage_collector_impl.d.ts +5 -5
- package/dist/lite/packages/firestore/src/local/memory_document_overlay_cache.d.ts +1 -0
- package/dist/lite/packages/firestore/src/local/memory_index_manager.d.ts +1 -0
- package/dist/lite/packages/firestore/src/local/overlayed_document.d.ts +36 -0
- package/dist/lite/packages/firestore/src/local/persistence.d.ts +3 -5
- package/dist/lite/packages/firestore/src/local/persistence_promise.d.ts +11 -0
- package/dist/lite/packages/firestore/src/local/query_engine.d.ts +1 -1
- package/dist/lite/packages/firestore/src/model/collections.d.ts +8 -2
- package/dist/lite/packages/firestore/src/model/field_mask.d.ts +6 -0
- package/dist/lite/packages/firestore/src/model/mutation.d.ts +19 -1
- package/dist/lite/packages/firestore/src/model/mutation_batch.d.ts +8 -4
- package/dist/lite/packages/firestore/src/util/async_queue.d.ts +5 -1
- package/dist/lite/packages/firestore/test/unit/local/index_backfiller.test.d.ts +17 -0
- package/dist/lite/packages/firestore/test/unit/local/test_document_overlay_cache.d.ts +1 -0
- package/dist/lite/packages/firestore/test/unit/specs/spec_test_components.d.ts +5 -3
- package/dist/lite/packages/firestore/test/util/helpers.d.ts +13 -0
- package/dist/lite/private.d.ts +2776 -2758
- package/dist/packages/firestore/dist/index.esm2017.d.ts +203 -201
- package/dist/packages/firestore/src/api/transaction.d.ts +2 -0
- package/dist/packages/firestore/src/core/component_provider.d.ts +11 -6
- package/dist/packages/firestore/src/lite-api/transaction.d.ts +2 -0
- package/dist/packages/firestore/src/local/document_overlay_cache.d.ts +5 -0
- package/dist/packages/firestore/src/local/index_backfiller.d.ts +44 -0
- package/dist/packages/firestore/src/local/index_manager.d.ts +2 -0
- package/dist/packages/firestore/src/local/indexeddb_document_overlay_cache.d.ts +1 -0
- package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +1 -0
- package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +3 -2
- package/dist/packages/firestore/src/local/indexeddb_schema_converter.d.ts +1 -0
- package/dist/packages/firestore/src/local/indexeddb_sentinels.d.ts +1 -0
- package/dist/packages/firestore/src/local/local_documents_view.d.ts +64 -9
- package/dist/packages/firestore/src/local/local_store.d.ts +9 -0
- package/dist/packages/firestore/src/local/lru_garbage_collector_impl.d.ts +5 -5
- package/dist/packages/firestore/src/local/memory_document_overlay_cache.d.ts +1 -0
- package/dist/packages/firestore/src/local/memory_index_manager.d.ts +1 -0
- package/dist/packages/firestore/src/local/overlayed_document.d.ts +36 -0
- package/dist/packages/firestore/src/local/persistence.d.ts +3 -5
- package/dist/packages/firestore/src/local/persistence_promise.d.ts +11 -0
- package/dist/packages/firestore/src/local/query_engine.d.ts +1 -1
- package/dist/packages/firestore/src/model/collections.d.ts +8 -2
- package/dist/packages/firestore/src/model/field_mask.d.ts +6 -0
- package/dist/packages/firestore/src/model/mutation.d.ts +19 -1
- package/dist/packages/firestore/src/model/mutation_batch.d.ts +8 -4
- package/dist/packages/firestore/src/util/async_queue.d.ts +5 -1
- package/dist/packages/firestore/test/unit/local/index_backfiller.test.d.ts +17 -0
- package/dist/packages/firestore/test/unit/local/test_document_overlay_cache.d.ts +1 -0
- package/dist/packages/firestore/test/unit/specs/spec_test_components.d.ts +5 -3
- package/dist/packages/firestore/test/util/helpers.d.ts +13 -0
- package/dist/private.d.ts +5845 -5672
- package/package.json +19 -17
|
@@ -63,7 +63,7 @@ l.MOCK_USER = new l("mock-user");
|
|
|
63
63
|
* See the License for the specific language governing permissions and
|
|
64
64
|
* limitations under the License.
|
|
65
65
|
*/
|
|
66
|
-
let f = "9.8.
|
|
66
|
+
let f = "9.8.3-canary.ebc17e27f";
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* @license
|
|
@@ -190,14 +190,14 @@ function p(t, ...e) {
|
|
|
190
190
|
* given message if it did.
|
|
191
191
|
*
|
|
192
192
|
* Messages are stripped in production builds.
|
|
193
|
-
*/ function
|
|
193
|
+
*/ function v(t, e) {
|
|
194
194
|
t || g();
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
/**
|
|
198
198
|
* Casts `obj` to `T`. In non-production builds, verifies that `obj` is an
|
|
199
199
|
* instance of `T` before casting.
|
|
200
|
-
*/ function
|
|
200
|
+
*/ function b(t,
|
|
201
201
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
202
202
|
e) {
|
|
203
203
|
return t;
|
|
@@ -218,9 +218,9 @@ e) {
|
|
|
218
218
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
219
219
|
* See the License for the specific language governing permissions and
|
|
220
220
|
* limitations under the License.
|
|
221
|
-
*/ const E = "ok", T = "cancelled",
|
|
221
|
+
*/ const E = "ok", T = "cancelled", I = "unknown", A = "invalid-argument", R = "deadline-exceeded", P = "not-found", V = "already-exists", N = "permission-denied", D = "unauthenticated", $ = "resource-exhausted", x = "failed-precondition", F = "aborted", S = "out-of-range", q = "unimplemented", O = "internal", k = "unavailable", C = "data-loss";
|
|
222
222
|
|
|
223
|
-
/** An error returned by a Firestore operation. */ class
|
|
223
|
+
/** An error returned by a Firestore operation. */ class L extends FirebaseError {
|
|
224
224
|
/** @hideconstructor */
|
|
225
225
|
constructor(
|
|
226
226
|
/**
|
|
@@ -254,7 +254,7 @@ e) {
|
|
|
254
254
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
255
255
|
* See the License for the specific language governing permissions and
|
|
256
256
|
* limitations under the License.
|
|
257
|
-
*/ class
|
|
257
|
+
*/ class M {
|
|
258
258
|
constructor() {
|
|
259
259
|
this.promise = new Promise(((t, e) => {
|
|
260
260
|
this.resolve = t, this.reject = e;
|
|
@@ -277,7 +277,7 @@ e) {
|
|
|
277
277
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
278
278
|
* See the License for the specific language governing permissions and
|
|
279
279
|
* limitations under the License.
|
|
280
|
-
*/ class
|
|
280
|
+
*/ class U {
|
|
281
281
|
constructor(t, e) {
|
|
282
282
|
this.user = e, this.type = "OAuth", this.headers = new Map, this.headers.set("Authorization", `Bearer ${t}`);
|
|
283
283
|
}
|
|
@@ -286,7 +286,7 @@ e) {
|
|
|
286
286
|
/**
|
|
287
287
|
* A CredentialsProvider that always yields an empty token.
|
|
288
288
|
* @internal
|
|
289
|
-
*/ class
|
|
289
|
+
*/ class j {
|
|
290
290
|
getToken() {
|
|
291
291
|
return Promise.resolve(null);
|
|
292
292
|
}
|
|
@@ -332,8 +332,8 @@ e) {
|
|
|
332
332
|
}));
|
|
333
333
|
}
|
|
334
334
|
getToken() {
|
|
335
|
-
return this.auth ? this.auth.getToken().then((t => t ? (
|
|
336
|
-
new
|
|
335
|
+
return this.auth ? this.auth.getToken().then((t => t ? (v("string" == typeof t.accessToken),
|
|
336
|
+
new U(t.accessToken, new l(this.auth.getUid()))) : null)) : Promise.resolve(null);
|
|
337
337
|
}
|
|
338
338
|
invalidateToken() {}
|
|
339
339
|
start(t, e) {}
|
|
@@ -358,7 +358,7 @@ e) {
|
|
|
358
358
|
* Provides user credentials required for the Firestore JavaScript SDK
|
|
359
359
|
* to authenticate the user, using technique that is only available
|
|
360
360
|
* to applications hosted by Google.
|
|
361
|
-
*/ class
|
|
361
|
+
*/ class W {
|
|
362
362
|
constructor(t, e, n) {
|
|
363
363
|
this.t = t, this.i = e, this.o = n;
|
|
364
364
|
}
|
|
@@ -373,21 +373,21 @@ e) {
|
|
|
373
373
|
invalidateToken() {}
|
|
374
374
|
}
|
|
375
375
|
|
|
376
|
-
class
|
|
376
|
+
class K {
|
|
377
377
|
constructor(t) {
|
|
378
378
|
this.value = t, this.type = "AppCheck", this.headers = new Map, t && t.length > 0 && this.headers.set("x-firebase-appcheck", this.value);
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
-
/** AppCheck token provider for the Lite SDK. */ class
|
|
382
|
+
/** AppCheck token provider for the Lite SDK. */ class Q {
|
|
383
383
|
constructor(t) {
|
|
384
384
|
this.u = t, this.appCheck = null, t.onInit((t => {
|
|
385
385
|
this.appCheck = t;
|
|
386
386
|
}));
|
|
387
387
|
}
|
|
388
388
|
getToken() {
|
|
389
|
-
return this.appCheck ? this.appCheck.getToken().then((t => t ? (
|
|
390
|
-
new
|
|
389
|
+
return this.appCheck ? this.appCheck.getToken().then((t => t ? (v("string" == typeof t.token),
|
|
390
|
+
new K(t.token)) : null)) : Promise.resolve(null);
|
|
391
391
|
}
|
|
392
392
|
invalidateToken() {}
|
|
393
393
|
start(t, e) {}
|
|
@@ -414,7 +414,7 @@ class W {
|
|
|
414
414
|
* See the License for the specific language governing permissions and
|
|
415
415
|
* limitations under the License.
|
|
416
416
|
*/
|
|
417
|
-
class
|
|
417
|
+
class Y {
|
|
418
418
|
/**
|
|
419
419
|
* Constructs a DatabaseInfo using the provided host, databaseId and
|
|
420
420
|
* persistenceKey.
|
|
@@ -443,18 +443,18 @@ class H {
|
|
|
443
443
|
* Represents the database ID a Firestore client is associated with.
|
|
444
444
|
* @internal
|
|
445
445
|
*/
|
|
446
|
-
class
|
|
446
|
+
class H {
|
|
447
447
|
constructor(t, e) {
|
|
448
448
|
this.projectId = t, this.database = e || "(default)";
|
|
449
449
|
}
|
|
450
450
|
static empty() {
|
|
451
|
-
return new
|
|
451
|
+
return new H("", "");
|
|
452
452
|
}
|
|
453
453
|
get isDefaultDatabase() {
|
|
454
454
|
return "(default)" === this.database;
|
|
455
455
|
}
|
|
456
456
|
isEqual(t) {
|
|
457
|
-
return t instanceof
|
|
457
|
+
return t instanceof H && t.projectId === this.projectId && t.database === this.database;
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
460
|
|
|
@@ -570,7 +570,7 @@ class J {
|
|
|
570
570
|
// for legacy reasons and should not be used frequently).
|
|
571
571
|
const e = [];
|
|
572
572
|
for (const n of t) {
|
|
573
|
-
if (n.indexOf("//") >= 0) throw new
|
|
573
|
+
if (n.indexOf("//") >= 0) throw new L(A, `Invalid segment (${n}). Paths must not contain // in them.`);
|
|
574
574
|
// Strip leading and traling slashed.
|
|
575
575
|
e.push(...n.split("/").filter((t => t.length > 0)));
|
|
576
576
|
}
|
|
@@ -626,20 +626,20 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
626
626
|
const e = [];
|
|
627
627
|
let n = "", r = 0;
|
|
628
628
|
const s = () => {
|
|
629
|
-
if (0 === n.length) throw new
|
|
629
|
+
if (0 === n.length) throw new L(A, `Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);
|
|
630
630
|
e.push(n), n = "";
|
|
631
631
|
};
|
|
632
632
|
let i = !1;
|
|
633
633
|
for (;r < t.length; ) {
|
|
634
634
|
const e = t[r];
|
|
635
635
|
if ("\\" === e) {
|
|
636
|
-
if (r + 1 === t.length) throw new
|
|
636
|
+
if (r + 1 === t.length) throw new L(A, "Path has trailing escape character: " + t);
|
|
637
637
|
const e = t[r + 1];
|
|
638
|
-
if ("\\" !== e && "." !== e && "`" !== e) throw new
|
|
638
|
+
if ("\\" !== e && "." !== e && "`" !== e) throw new L(A, "Path has invalid escape sequence: " + t);
|
|
639
639
|
n += e, r += 2;
|
|
640
640
|
} else "`" === e ? (i = !i, r++) : "." !== e || i ? (n += e, r++) : (s(), r++);
|
|
641
641
|
}
|
|
642
|
-
if (s(), i) throw new
|
|
642
|
+
if (s(), i) throw new L(A, "Unterminated ` in path: " + t);
|
|
643
643
|
return new tt(e);
|
|
644
644
|
}
|
|
645
645
|
static emptyPath() {
|
|
@@ -728,7 +728,7 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
728
728
|
* See the License for the specific language governing permissions and
|
|
729
729
|
* limitations under the License.
|
|
730
730
|
*/ function nt(t, e, n) {
|
|
731
|
-
if (!n) throw new
|
|
731
|
+
if (!n) throw new L(A, `Function ${t}() cannot be called with an empty ${e}.`);
|
|
732
732
|
}
|
|
733
733
|
|
|
734
734
|
/**
|
|
@@ -740,14 +740,14 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
740
740
|
* an even numbers of segments).
|
|
741
741
|
*/
|
|
742
742
|
function rt(t) {
|
|
743
|
-
if (!et.isDocumentKey(t)) throw new
|
|
743
|
+
if (!et.isDocumentKey(t)) throw new L(A, `Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`);
|
|
744
744
|
}
|
|
745
745
|
|
|
746
746
|
/**
|
|
747
747
|
* Validates that `path` refers to a collection (indicated by the fact it
|
|
748
748
|
* contains an odd numbers of segments).
|
|
749
749
|
*/ function st(t) {
|
|
750
|
-
if (et.isDocumentKey(t)) throw new
|
|
750
|
+
if (et.isDocumentKey(t)) throw new L(A, `Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`);
|
|
751
751
|
}
|
|
752
752
|
|
|
753
753
|
/**
|
|
@@ -791,17 +791,17 @@ e) {
|
|
|
791
791
|
// Unwrap Compat types
|
|
792
792
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
793
793
|
t = t._delegate), !(t instanceof e)) {
|
|
794
|
-
if (e.name === t.constructor.name) throw new
|
|
794
|
+
if (e.name === t.constructor.name) throw new L(A, "Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");
|
|
795
795
|
{
|
|
796
796
|
const n = it(t);
|
|
797
|
-
throw new
|
|
797
|
+
throw new L(A, `Expected type '${e.name}', but it was: ${n}`);
|
|
798
798
|
}
|
|
799
799
|
}
|
|
800
800
|
return t;
|
|
801
801
|
}
|
|
802
802
|
|
|
803
803
|
function ut(t, e) {
|
|
804
|
-
if (e <= 0) throw new
|
|
804
|
+
if (e <= 0) throw new L(A, `Function ${t}() requires a positive number, but it was: ${e}.`);
|
|
805
805
|
}
|
|
806
806
|
|
|
807
807
|
/**
|
|
@@ -899,7 +899,7 @@ var lt, ft;
|
|
|
899
899
|
* Code.UNKNOWN.
|
|
900
900
|
*/
|
|
901
901
|
function dt(t) {
|
|
902
|
-
if (void 0 === t) return p("RPC_ERROR", "HTTP error has no status"),
|
|
902
|
+
if (void 0 === t) return p("RPC_ERROR", "HTTP error has no status"), I;
|
|
903
903
|
// The canonical error codes for Google APIs [1] specify mapping onto HTTP
|
|
904
904
|
// status codes but the mapping is not bijective. In each case of ambiguity
|
|
905
905
|
// this function chooses a primary error.
|
|
@@ -913,18 +913,18 @@ function dt(t) {
|
|
|
913
913
|
|
|
914
914
|
case 400:
|
|
915
915
|
// Bad Request
|
|
916
|
-
return
|
|
916
|
+
return x;
|
|
917
917
|
|
|
918
918
|
// Other possibilities based on the forward mapping
|
|
919
919
|
// return Code.INVALID_ARGUMENT;
|
|
920
920
|
// return Code.OUT_OF_RANGE;
|
|
921
921
|
case 401:
|
|
922
922
|
// Unauthorized
|
|
923
|
-
return
|
|
923
|
+
return D;
|
|
924
924
|
|
|
925
925
|
case 403:
|
|
926
926
|
// Forbidden
|
|
927
|
-
return
|
|
927
|
+
return N;
|
|
928
928
|
|
|
929
929
|
case 404:
|
|
930
930
|
// Not Found
|
|
@@ -932,13 +932,13 @@ function dt(t) {
|
|
|
932
932
|
|
|
933
933
|
case 409:
|
|
934
934
|
// Conflict
|
|
935
|
-
return
|
|
935
|
+
return F;
|
|
936
936
|
|
|
937
937
|
// Other possibilities:
|
|
938
938
|
// return Code.ALREADY_EXISTS;
|
|
939
939
|
case 416:
|
|
940
940
|
// Range Not Satisfiable
|
|
941
|
-
return
|
|
941
|
+
return S;
|
|
942
942
|
|
|
943
943
|
case 429:
|
|
944
944
|
// Too Many Requests
|
|
@@ -950,7 +950,7 @@ function dt(t) {
|
|
|
950
950
|
|
|
951
951
|
case 500:
|
|
952
952
|
// Internal Server Error
|
|
953
|
-
return
|
|
953
|
+
return I;
|
|
954
954
|
|
|
955
955
|
// Other possibilities:
|
|
956
956
|
// return Code.INTERNAL;
|
|
@@ -961,14 +961,14 @@ function dt(t) {
|
|
|
961
961
|
|
|
962
962
|
case 503:
|
|
963
963
|
// Service Unavailable
|
|
964
|
-
return
|
|
964
|
+
return k;
|
|
965
965
|
|
|
966
966
|
case 504:
|
|
967
967
|
// Gateway Timeout
|
|
968
968
|
return R;
|
|
969
969
|
|
|
970
970
|
default:
|
|
971
|
-
return t >= 200 && t < 300 ? E : t >= 400 && t < 500 ?
|
|
971
|
+
return t >= 200 && t < 300 ? E : t >= 400 && t < 500 ? x : t >= 500 && t < 600 ? O : I;
|
|
972
972
|
}
|
|
973
973
|
}
|
|
974
974
|
|
|
@@ -1048,24 +1048,24 @@ class {
|
|
|
1048
1048
|
* @param fetchImpl - `fetch` or a Polyfill that implements the fetch API.
|
|
1049
1049
|
*/
|
|
1050
1050
|
constructor(t, e) {
|
|
1051
|
-
super(t), this.
|
|
1051
|
+
super(t), this.I = e;
|
|
1052
1052
|
}
|
|
1053
|
-
|
|
1053
|
+
A(t, e) {
|
|
1054
1054
|
throw new Error("Not supported by FetchConnection");
|
|
1055
1055
|
}
|
|
1056
1056
|
async v(t, e, n, r) {
|
|
1057
1057
|
const s = JSON.stringify(r);
|
|
1058
1058
|
let i;
|
|
1059
1059
|
try {
|
|
1060
|
-
i = await this.
|
|
1060
|
+
i = await this.I(e, {
|
|
1061
1061
|
method: "POST",
|
|
1062
1062
|
headers: n,
|
|
1063
1063
|
body: s
|
|
1064
1064
|
});
|
|
1065
1065
|
} catch (t) {
|
|
1066
|
-
throw new
|
|
1066
|
+
throw new L(dt(t.status), "Request failed with error: " + t.statusText);
|
|
1067
1067
|
}
|
|
1068
|
-
if (!i.ok) throw new
|
|
1068
|
+
if (!i.ok) throw new L(dt(i.status), "Request failed with error: " + i.statusText);
|
|
1069
1069
|
return i.json();
|
|
1070
1070
|
}
|
|
1071
1071
|
}
|
|
@@ -1211,11 +1211,11 @@ class gt {
|
|
|
1211
1211
|
* The fractions of a second at nanosecond resolution.*
|
|
1212
1212
|
*/
|
|
1213
1213
|
e) {
|
|
1214
|
-
if (this.seconds = t, this.nanoseconds = e, e < 0) throw new
|
|
1215
|
-
if (e >= 1e9) throw new
|
|
1216
|
-
if (t < -62135596800) throw new
|
|
1214
|
+
if (this.seconds = t, this.nanoseconds = e, e < 0) throw new L(A, "Timestamp nanoseconds out of range: " + e);
|
|
1215
|
+
if (e >= 1e9) throw new L(A, "Timestamp nanoseconds out of range: " + e);
|
|
1216
|
+
if (t < -62135596800) throw new L(A, "Timestamp seconds out of range: " + t);
|
|
1217
1217
|
// This will break in the year 10,000.
|
|
1218
|
-
if (t >= 253402300800) throw new
|
|
1218
|
+
if (t >= 253402300800) throw new L(A, "Timestamp seconds out of range: " + t);
|
|
1219
1219
|
}
|
|
1220
1220
|
/**
|
|
1221
1221
|
* Creates a new timestamp with the current date, with millisecond precision.
|
|
@@ -1320,18 +1320,18 @@ class gt {
|
|
|
1320
1320
|
/**
|
|
1321
1321
|
* A version of a document in Firestore. This corresponds to the version
|
|
1322
1322
|
* timestamp, such as update_time or read_time.
|
|
1323
|
-
*/ class
|
|
1323
|
+
*/ class vt {
|
|
1324
1324
|
constructor(t) {
|
|
1325
1325
|
this.timestamp = t;
|
|
1326
1326
|
}
|
|
1327
1327
|
static fromTimestamp(t) {
|
|
1328
|
-
return new
|
|
1328
|
+
return new vt(t);
|
|
1329
1329
|
}
|
|
1330
1330
|
static min() {
|
|
1331
|
-
return new
|
|
1331
|
+
return new vt(new gt(0, 0));
|
|
1332
1332
|
}
|
|
1333
1333
|
static max() {
|
|
1334
|
-
return new
|
|
1334
|
+
return new vt(new gt(253402300799, 999999999));
|
|
1335
1335
|
}
|
|
1336
1336
|
compareTo(t) {
|
|
1337
1337
|
return this.timestamp._compareTo(t.timestamp);
|
|
@@ -1366,7 +1366,7 @@ class gt {
|
|
|
1366
1366
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1367
1367
|
* See the License for the specific language governing permissions and
|
|
1368
1368
|
* limitations under the License.
|
|
1369
|
-
*/ function
|
|
1369
|
+
*/ function bt(t) {
|
|
1370
1370
|
let e = 0;
|
|
1371
1371
|
for (const n in t) Object.prototype.hasOwnProperty.call(t, n) && e++;
|
|
1372
1372
|
return e;
|
|
@@ -1376,6 +1376,462 @@ function Et(t, e) {
|
|
|
1376
1376
|
for (const n in t) Object.prototype.hasOwnProperty.call(t, n) && e(n, t[n]);
|
|
1377
1377
|
}
|
|
1378
1378
|
|
|
1379
|
+
/**
|
|
1380
|
+
* @license
|
|
1381
|
+
* Copyright 2017 Google LLC
|
|
1382
|
+
*
|
|
1383
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1384
|
+
* you may not use this file except in compliance with the License.
|
|
1385
|
+
* You may obtain a copy of the License at
|
|
1386
|
+
*
|
|
1387
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1388
|
+
*
|
|
1389
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1390
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1391
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1392
|
+
* See the License for the specific language governing permissions and
|
|
1393
|
+
* limitations under the License.
|
|
1394
|
+
*/
|
|
1395
|
+
// An immutable sorted map implementation, based on a Left-leaning Red-Black
|
|
1396
|
+
// tree.
|
|
1397
|
+
class Tt {
|
|
1398
|
+
constructor(t, e) {
|
|
1399
|
+
this.comparator = t, this.root = e || At.EMPTY;
|
|
1400
|
+
}
|
|
1401
|
+
// Returns a copy of the map, with the specified key/value added or replaced.
|
|
1402
|
+
insert(t, e) {
|
|
1403
|
+
return new Tt(this.comparator, this.root.insert(t, e, this.comparator).copy(null, null, At.BLACK, null, null));
|
|
1404
|
+
}
|
|
1405
|
+
// Returns a copy of the map, with the specified key removed.
|
|
1406
|
+
remove(t) {
|
|
1407
|
+
return new Tt(this.comparator, this.root.remove(t, this.comparator).copy(null, null, At.BLACK, null, null));
|
|
1408
|
+
}
|
|
1409
|
+
// Returns the value of the node with the given key, or null.
|
|
1410
|
+
get(t) {
|
|
1411
|
+
let e = this.root;
|
|
1412
|
+
for (;!e.isEmpty(); ) {
|
|
1413
|
+
const n = this.comparator(t, e.key);
|
|
1414
|
+
if (0 === n) return e.value;
|
|
1415
|
+
n < 0 ? e = e.left : n > 0 && (e = e.right);
|
|
1416
|
+
}
|
|
1417
|
+
return null;
|
|
1418
|
+
}
|
|
1419
|
+
// Returns the index of the element in this sorted map, or -1 if it doesn't
|
|
1420
|
+
// exist.
|
|
1421
|
+
indexOf(t) {
|
|
1422
|
+
// Number of nodes that were pruned when descending right
|
|
1423
|
+
let e = 0, n = this.root;
|
|
1424
|
+
for (;!n.isEmpty(); ) {
|
|
1425
|
+
const r = this.comparator(t, n.key);
|
|
1426
|
+
if (0 === r) return e + n.left.size;
|
|
1427
|
+
r < 0 ? n = n.left : (
|
|
1428
|
+
// Count all nodes left of the node plus the node itself
|
|
1429
|
+
e += n.left.size + 1, n = n.right);
|
|
1430
|
+
}
|
|
1431
|
+
// Node not found
|
|
1432
|
+
return -1;
|
|
1433
|
+
}
|
|
1434
|
+
isEmpty() {
|
|
1435
|
+
return this.root.isEmpty();
|
|
1436
|
+
}
|
|
1437
|
+
// Returns the total number of nodes in the map.
|
|
1438
|
+
get size() {
|
|
1439
|
+
return this.root.size;
|
|
1440
|
+
}
|
|
1441
|
+
// Returns the minimum key in the map.
|
|
1442
|
+
minKey() {
|
|
1443
|
+
return this.root.minKey();
|
|
1444
|
+
}
|
|
1445
|
+
// Returns the maximum key in the map.
|
|
1446
|
+
maxKey() {
|
|
1447
|
+
return this.root.maxKey();
|
|
1448
|
+
}
|
|
1449
|
+
// Traverses the map in key order and calls the specified action function
|
|
1450
|
+
// for each key/value pair. If action returns true, traversal is aborted.
|
|
1451
|
+
// Returns the first truthy value returned by action, or the last falsey
|
|
1452
|
+
// value returned by action.
|
|
1453
|
+
inorderTraversal(t) {
|
|
1454
|
+
return this.root.inorderTraversal(t);
|
|
1455
|
+
}
|
|
1456
|
+
forEach(t) {
|
|
1457
|
+
this.inorderTraversal(((e, n) => (t(e, n), !1)));
|
|
1458
|
+
}
|
|
1459
|
+
toString() {
|
|
1460
|
+
const t = [];
|
|
1461
|
+
return this.inorderTraversal(((e, n) => (t.push(`${e}:${n}`), !1))), `{${t.join(", ")}}`;
|
|
1462
|
+
}
|
|
1463
|
+
// Traverses the map in reverse key order and calls the specified action
|
|
1464
|
+
// function for each key/value pair. If action returns true, traversal is
|
|
1465
|
+
// aborted.
|
|
1466
|
+
// Returns the first truthy value returned by action, or the last falsey
|
|
1467
|
+
// value returned by action.
|
|
1468
|
+
reverseTraversal(t) {
|
|
1469
|
+
return this.root.reverseTraversal(t);
|
|
1470
|
+
}
|
|
1471
|
+
// Returns an iterator over the SortedMap.
|
|
1472
|
+
getIterator() {
|
|
1473
|
+
return new It(this.root, null, this.comparator, !1);
|
|
1474
|
+
}
|
|
1475
|
+
getIteratorFrom(t) {
|
|
1476
|
+
return new It(this.root, t, this.comparator, !1);
|
|
1477
|
+
}
|
|
1478
|
+
getReverseIterator() {
|
|
1479
|
+
return new It(this.root, null, this.comparator, !0);
|
|
1480
|
+
}
|
|
1481
|
+
getReverseIteratorFrom(t) {
|
|
1482
|
+
return new It(this.root, t, this.comparator, !0);
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
// end SortedMap
|
|
1487
|
+
// An iterator over an LLRBNode.
|
|
1488
|
+
class It {
|
|
1489
|
+
constructor(t, e, n, r) {
|
|
1490
|
+
this.isReverse = r, this.nodeStack = [];
|
|
1491
|
+
let s = 1;
|
|
1492
|
+
for (;!t.isEmpty(); ) if (s = e ? n(t.key, e) : 1,
|
|
1493
|
+
// flip the comparison if we're going in reverse
|
|
1494
|
+
e && r && (s *= -1), s < 0)
|
|
1495
|
+
// This node is less than our start key. ignore it
|
|
1496
|
+
t = this.isReverse ? t.left : t.right; else {
|
|
1497
|
+
if (0 === s) {
|
|
1498
|
+
// This node is exactly equal to our start key. Push it on the stack,
|
|
1499
|
+
// but stop iterating;
|
|
1500
|
+
this.nodeStack.push(t);
|
|
1501
|
+
break;
|
|
1502
|
+
}
|
|
1503
|
+
// This node is greater than our start key, add it to the stack and move
|
|
1504
|
+
// to the next one
|
|
1505
|
+
this.nodeStack.push(t), t = this.isReverse ? t.right : t.left;
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
getNext() {
|
|
1509
|
+
let t = this.nodeStack.pop();
|
|
1510
|
+
const e = {
|
|
1511
|
+
key: t.key,
|
|
1512
|
+
value: t.value
|
|
1513
|
+
};
|
|
1514
|
+
if (this.isReverse) for (t = t.left; !t.isEmpty(); ) this.nodeStack.push(t), t = t.right; else for (t = t.right; !t.isEmpty(); ) this.nodeStack.push(t),
|
|
1515
|
+
t = t.left;
|
|
1516
|
+
return e;
|
|
1517
|
+
}
|
|
1518
|
+
hasNext() {
|
|
1519
|
+
return this.nodeStack.length > 0;
|
|
1520
|
+
}
|
|
1521
|
+
peek() {
|
|
1522
|
+
if (0 === this.nodeStack.length) return null;
|
|
1523
|
+
const t = this.nodeStack[this.nodeStack.length - 1];
|
|
1524
|
+
return {
|
|
1525
|
+
key: t.key,
|
|
1526
|
+
value: t.value
|
|
1527
|
+
};
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
// end SortedMapIterator
|
|
1532
|
+
// Represents a node in a Left-leaning Red-Black tree.
|
|
1533
|
+
class At {
|
|
1534
|
+
constructor(t, e, n, r, s) {
|
|
1535
|
+
this.key = t, this.value = e, this.color = null != n ? n : At.RED, this.left = null != r ? r : At.EMPTY,
|
|
1536
|
+
this.right = null != s ? s : At.EMPTY, this.size = this.left.size + 1 + this.right.size;
|
|
1537
|
+
}
|
|
1538
|
+
// Returns a copy of the current node, optionally replacing pieces of it.
|
|
1539
|
+
copy(t, e, n, r, s) {
|
|
1540
|
+
return new At(null != t ? t : this.key, null != e ? e : this.value, null != n ? n : this.color, null != r ? r : this.left, null != s ? s : this.right);
|
|
1541
|
+
}
|
|
1542
|
+
isEmpty() {
|
|
1543
|
+
return !1;
|
|
1544
|
+
}
|
|
1545
|
+
// Traverses the tree in key order and calls the specified action function
|
|
1546
|
+
// for each node. If action returns true, traversal is aborted.
|
|
1547
|
+
// Returns the first truthy value returned by action, or the last falsey
|
|
1548
|
+
// value returned by action.
|
|
1549
|
+
inorderTraversal(t) {
|
|
1550
|
+
return this.left.inorderTraversal(t) || t(this.key, this.value) || this.right.inorderTraversal(t);
|
|
1551
|
+
}
|
|
1552
|
+
// Traverses the tree in reverse key order and calls the specified action
|
|
1553
|
+
// function for each node. If action returns true, traversal is aborted.
|
|
1554
|
+
// Returns the first truthy value returned by action, or the last falsey
|
|
1555
|
+
// value returned by action.
|
|
1556
|
+
reverseTraversal(t) {
|
|
1557
|
+
return this.right.reverseTraversal(t) || t(this.key, this.value) || this.left.reverseTraversal(t);
|
|
1558
|
+
}
|
|
1559
|
+
// Returns the minimum node in the tree.
|
|
1560
|
+
min() {
|
|
1561
|
+
return this.left.isEmpty() ? this : this.left.min();
|
|
1562
|
+
}
|
|
1563
|
+
// Returns the maximum key in the tree.
|
|
1564
|
+
minKey() {
|
|
1565
|
+
return this.min().key;
|
|
1566
|
+
}
|
|
1567
|
+
// Returns the maximum key in the tree.
|
|
1568
|
+
maxKey() {
|
|
1569
|
+
return this.right.isEmpty() ? this.key : this.right.maxKey();
|
|
1570
|
+
}
|
|
1571
|
+
// Returns new tree, with the key/value added.
|
|
1572
|
+
insert(t, e, n) {
|
|
1573
|
+
let r = this;
|
|
1574
|
+
const s = n(t, r.key);
|
|
1575
|
+
return r = s < 0 ? r.copy(null, null, null, r.left.insert(t, e, n), null) : 0 === s ? r.copy(null, e, null, null, null) : r.copy(null, null, null, null, r.right.insert(t, e, n)),
|
|
1576
|
+
r.fixUp();
|
|
1577
|
+
}
|
|
1578
|
+
removeMin() {
|
|
1579
|
+
if (this.left.isEmpty()) return At.EMPTY;
|
|
1580
|
+
let t = this;
|
|
1581
|
+
return t.left.isRed() || t.left.left.isRed() || (t = t.moveRedLeft()), t = t.copy(null, null, null, t.left.removeMin(), null),
|
|
1582
|
+
t.fixUp();
|
|
1583
|
+
}
|
|
1584
|
+
// Returns new tree, with the specified item removed.
|
|
1585
|
+
remove(t, e) {
|
|
1586
|
+
let n, r = this;
|
|
1587
|
+
if (e(t, r.key) < 0) r.left.isEmpty() || r.left.isRed() || r.left.left.isRed() || (r = r.moveRedLeft()),
|
|
1588
|
+
r = r.copy(null, null, null, r.left.remove(t, e), null); else {
|
|
1589
|
+
if (r.left.isRed() && (r = r.rotateRight()), r.right.isEmpty() || r.right.isRed() || r.right.left.isRed() || (r = r.moveRedRight()),
|
|
1590
|
+
0 === e(t, r.key)) {
|
|
1591
|
+
if (r.right.isEmpty()) return At.EMPTY;
|
|
1592
|
+
n = r.right.min(), r = r.copy(n.key, n.value, null, null, r.right.removeMin());
|
|
1593
|
+
}
|
|
1594
|
+
r = r.copy(null, null, null, null, r.right.remove(t, e));
|
|
1595
|
+
}
|
|
1596
|
+
return r.fixUp();
|
|
1597
|
+
}
|
|
1598
|
+
isRed() {
|
|
1599
|
+
return this.color;
|
|
1600
|
+
}
|
|
1601
|
+
// Returns new tree after performing any needed rotations.
|
|
1602
|
+
fixUp() {
|
|
1603
|
+
let t = this;
|
|
1604
|
+
return t.right.isRed() && !t.left.isRed() && (t = t.rotateLeft()), t.left.isRed() && t.left.left.isRed() && (t = t.rotateRight()),
|
|
1605
|
+
t.left.isRed() && t.right.isRed() && (t = t.colorFlip()), t;
|
|
1606
|
+
}
|
|
1607
|
+
moveRedLeft() {
|
|
1608
|
+
let t = this.colorFlip();
|
|
1609
|
+
return t.right.left.isRed() && (t = t.copy(null, null, null, null, t.right.rotateRight()),
|
|
1610
|
+
t = t.rotateLeft(), t = t.colorFlip()), t;
|
|
1611
|
+
}
|
|
1612
|
+
moveRedRight() {
|
|
1613
|
+
let t = this.colorFlip();
|
|
1614
|
+
return t.left.left.isRed() && (t = t.rotateRight(), t = t.colorFlip()), t;
|
|
1615
|
+
}
|
|
1616
|
+
rotateLeft() {
|
|
1617
|
+
const t = this.copy(null, null, At.RED, null, this.right.left);
|
|
1618
|
+
return this.right.copy(null, null, this.color, t, null);
|
|
1619
|
+
}
|
|
1620
|
+
rotateRight() {
|
|
1621
|
+
const t = this.copy(null, null, At.RED, this.left.right, null);
|
|
1622
|
+
return this.left.copy(null, null, this.color, null, t);
|
|
1623
|
+
}
|
|
1624
|
+
colorFlip() {
|
|
1625
|
+
const t = this.left.copy(null, null, !this.left.color, null, null), e = this.right.copy(null, null, !this.right.color, null, null);
|
|
1626
|
+
return this.copy(null, null, !this.color, t, e);
|
|
1627
|
+
}
|
|
1628
|
+
// For testing.
|
|
1629
|
+
checkMaxDepth() {
|
|
1630
|
+
const t = this.check();
|
|
1631
|
+
return Math.pow(2, t) <= this.size + 1;
|
|
1632
|
+
}
|
|
1633
|
+
// In a balanced RB tree, the black-depth (number of black nodes) from root to
|
|
1634
|
+
// leaves is equal on both sides. This function verifies that or asserts.
|
|
1635
|
+
check() {
|
|
1636
|
+
if (this.isRed() && this.left.isRed()) throw g();
|
|
1637
|
+
if (this.right.isRed()) throw g();
|
|
1638
|
+
const t = this.left.check();
|
|
1639
|
+
if (t !== this.right.check()) throw g();
|
|
1640
|
+
return t + (this.isRed() ? 0 : 1);
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
// end LLRBNode
|
|
1645
|
+
// Empty node is shared between all LLRB trees.
|
|
1646
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1647
|
+
At.EMPTY = null, At.RED = !0, At.BLACK = !1;
|
|
1648
|
+
|
|
1649
|
+
// end LLRBEmptyNode
|
|
1650
|
+
At.EMPTY = new
|
|
1651
|
+
// Represents an empty node (a leaf node in the Red-Black Tree).
|
|
1652
|
+
class {
|
|
1653
|
+
constructor() {
|
|
1654
|
+
this.size = 0;
|
|
1655
|
+
}
|
|
1656
|
+
get key() {
|
|
1657
|
+
throw g();
|
|
1658
|
+
}
|
|
1659
|
+
get value() {
|
|
1660
|
+
throw g();
|
|
1661
|
+
}
|
|
1662
|
+
get color() {
|
|
1663
|
+
throw g();
|
|
1664
|
+
}
|
|
1665
|
+
get left() {
|
|
1666
|
+
throw g();
|
|
1667
|
+
}
|
|
1668
|
+
get right() {
|
|
1669
|
+
throw g();
|
|
1670
|
+
}
|
|
1671
|
+
// Returns a copy of the current node.
|
|
1672
|
+
copy(t, e, n, r, s) {
|
|
1673
|
+
return this;
|
|
1674
|
+
}
|
|
1675
|
+
// Returns a copy of the tree, with the specified key/value added.
|
|
1676
|
+
insert(t, e, n) {
|
|
1677
|
+
return new At(t, e);
|
|
1678
|
+
}
|
|
1679
|
+
// Returns a copy of the tree, with the specified key removed.
|
|
1680
|
+
remove(t, e) {
|
|
1681
|
+
return this;
|
|
1682
|
+
}
|
|
1683
|
+
isEmpty() {
|
|
1684
|
+
return !0;
|
|
1685
|
+
}
|
|
1686
|
+
inorderTraversal(t) {
|
|
1687
|
+
return !1;
|
|
1688
|
+
}
|
|
1689
|
+
reverseTraversal(t) {
|
|
1690
|
+
return !1;
|
|
1691
|
+
}
|
|
1692
|
+
minKey() {
|
|
1693
|
+
return null;
|
|
1694
|
+
}
|
|
1695
|
+
maxKey() {
|
|
1696
|
+
return null;
|
|
1697
|
+
}
|
|
1698
|
+
isRed() {
|
|
1699
|
+
return !1;
|
|
1700
|
+
}
|
|
1701
|
+
// For testing.
|
|
1702
|
+
checkMaxDepth() {
|
|
1703
|
+
return !0;
|
|
1704
|
+
}
|
|
1705
|
+
check() {
|
|
1706
|
+
return 0;
|
|
1707
|
+
}
|
|
1708
|
+
};
|
|
1709
|
+
|
|
1710
|
+
/**
|
|
1711
|
+
* @license
|
|
1712
|
+
* Copyright 2017 Google LLC
|
|
1713
|
+
*
|
|
1714
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1715
|
+
* you may not use this file except in compliance with the License.
|
|
1716
|
+
* You may obtain a copy of the License at
|
|
1717
|
+
*
|
|
1718
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1719
|
+
*
|
|
1720
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1721
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1722
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1723
|
+
* See the License for the specific language governing permissions and
|
|
1724
|
+
* limitations under the License.
|
|
1725
|
+
*/
|
|
1726
|
+
/**
|
|
1727
|
+
* SortedSet is an immutable (copy-on-write) collection that holds elements
|
|
1728
|
+
* in order specified by the provided comparator.
|
|
1729
|
+
*
|
|
1730
|
+
* NOTE: if provided comparator returns 0 for two elements, we consider them to
|
|
1731
|
+
* be equal!
|
|
1732
|
+
*/
|
|
1733
|
+
class Rt {
|
|
1734
|
+
constructor(t) {
|
|
1735
|
+
this.comparator = t, this.data = new Tt(this.comparator);
|
|
1736
|
+
}
|
|
1737
|
+
has(t) {
|
|
1738
|
+
return null !== this.data.get(t);
|
|
1739
|
+
}
|
|
1740
|
+
first() {
|
|
1741
|
+
return this.data.minKey();
|
|
1742
|
+
}
|
|
1743
|
+
last() {
|
|
1744
|
+
return this.data.maxKey();
|
|
1745
|
+
}
|
|
1746
|
+
get size() {
|
|
1747
|
+
return this.data.size;
|
|
1748
|
+
}
|
|
1749
|
+
indexOf(t) {
|
|
1750
|
+
return this.data.indexOf(t);
|
|
1751
|
+
}
|
|
1752
|
+
/** Iterates elements in order defined by "comparator" */ forEach(t) {
|
|
1753
|
+
this.data.inorderTraversal(((e, n) => (t(e), !1)));
|
|
1754
|
+
}
|
|
1755
|
+
/** Iterates over `elem`s such that: range[0] <= elem < range[1]. */ forEachInRange(t, e) {
|
|
1756
|
+
const n = this.data.getIteratorFrom(t[0]);
|
|
1757
|
+
for (;n.hasNext(); ) {
|
|
1758
|
+
const r = n.getNext();
|
|
1759
|
+
if (this.comparator(r.key, t[1]) >= 0) return;
|
|
1760
|
+
e(r.key);
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
/**
|
|
1764
|
+
* Iterates over `elem`s such that: start <= elem until false is returned.
|
|
1765
|
+
*/ forEachWhile(t, e) {
|
|
1766
|
+
let n;
|
|
1767
|
+
for (n = void 0 !== e ? this.data.getIteratorFrom(e) : this.data.getIterator(); n.hasNext(); ) {
|
|
1768
|
+
if (!t(n.getNext().key)) return;
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
/** Finds the least element greater than or equal to `elem`. */ firstAfterOrEqual(t) {
|
|
1772
|
+
const e = this.data.getIteratorFrom(t);
|
|
1773
|
+
return e.hasNext() ? e.getNext().key : null;
|
|
1774
|
+
}
|
|
1775
|
+
getIterator() {
|
|
1776
|
+
return new Pt(this.data.getIterator());
|
|
1777
|
+
}
|
|
1778
|
+
getIteratorFrom(t) {
|
|
1779
|
+
return new Pt(this.data.getIteratorFrom(t));
|
|
1780
|
+
}
|
|
1781
|
+
/** Inserts or updates an element */ add(t) {
|
|
1782
|
+
return this.copy(this.data.remove(t).insert(t, !0));
|
|
1783
|
+
}
|
|
1784
|
+
/** Deletes an element */ delete(t) {
|
|
1785
|
+
return this.has(t) ? this.copy(this.data.remove(t)) : this;
|
|
1786
|
+
}
|
|
1787
|
+
isEmpty() {
|
|
1788
|
+
return this.data.isEmpty();
|
|
1789
|
+
}
|
|
1790
|
+
unionWith(t) {
|
|
1791
|
+
let e = this;
|
|
1792
|
+
// Make sure `result` always refers to the larger one of the two sets.
|
|
1793
|
+
return e.size < t.size && (e = t, t = this), t.forEach((t => {
|
|
1794
|
+
e = e.add(t);
|
|
1795
|
+
})), e;
|
|
1796
|
+
}
|
|
1797
|
+
isEqual(t) {
|
|
1798
|
+
if (!(t instanceof Rt)) return !1;
|
|
1799
|
+
if (this.size !== t.size) return !1;
|
|
1800
|
+
const e = this.data.getIterator(), n = t.data.getIterator();
|
|
1801
|
+
for (;e.hasNext(); ) {
|
|
1802
|
+
const t = e.getNext().key, r = n.getNext().key;
|
|
1803
|
+
if (0 !== this.comparator(t, r)) return !1;
|
|
1804
|
+
}
|
|
1805
|
+
return !0;
|
|
1806
|
+
}
|
|
1807
|
+
toArray() {
|
|
1808
|
+
const t = [];
|
|
1809
|
+
return this.forEach((e => {
|
|
1810
|
+
t.push(e);
|
|
1811
|
+
})), t;
|
|
1812
|
+
}
|
|
1813
|
+
toString() {
|
|
1814
|
+
const t = [];
|
|
1815
|
+
return this.forEach((e => t.push(e))), "SortedSet(" + t.toString() + ")";
|
|
1816
|
+
}
|
|
1817
|
+
copy(t) {
|
|
1818
|
+
const e = new Rt(this.comparator);
|
|
1819
|
+
return e.data = t, e;
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1823
|
+
class Pt {
|
|
1824
|
+
constructor(t) {
|
|
1825
|
+
this.iter = t;
|
|
1826
|
+
}
|
|
1827
|
+
getNext() {
|
|
1828
|
+
return this.iter.getNext().key;
|
|
1829
|
+
}
|
|
1830
|
+
hasNext() {
|
|
1831
|
+
return this.iter.hasNext();
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1379
1835
|
/**
|
|
1380
1836
|
* @license
|
|
1381
1837
|
* Copyright 2020 Google LLC
|
|
@@ -1401,14 +1857,25 @@ function Et(t, e) {
|
|
|
1401
1857
|
* foo.bar - Overwrites only the field bar of the object foo.
|
|
1402
1858
|
* If foo is not an object, foo is replaced with an object
|
|
1403
1859
|
* containing foo
|
|
1404
|
-
*/
|
|
1405
|
-
class Tt {
|
|
1860
|
+
*/ class Vt {
|
|
1406
1861
|
constructor(t) {
|
|
1407
1862
|
this.fields = t,
|
|
1408
1863
|
// TODO(dimond): validation of FieldMask
|
|
1409
1864
|
// Sort the field mask to support `FieldMask.isEqual()` and assert below.
|
|
1410
1865
|
t.sort(tt.comparator);
|
|
1411
1866
|
}
|
|
1867
|
+
static empty() {
|
|
1868
|
+
return new Vt([]);
|
|
1869
|
+
}
|
|
1870
|
+
/**
|
|
1871
|
+
* Returns a new FieldMask object that is the result of adding all the given
|
|
1872
|
+
* fields paths to this field mask.
|
|
1873
|
+
*/ unionWith(t) {
|
|
1874
|
+
let e = new Rt(tt.comparator);
|
|
1875
|
+
for (const t of this.fields) e = e.add(t);
|
|
1876
|
+
for (const n of t) e = e.add(n);
|
|
1877
|
+
return new Vt(e.toArray());
|
|
1878
|
+
}
|
|
1412
1879
|
/**
|
|
1413
1880
|
* Verifies that `fieldPath` is included by at least one field in this field
|
|
1414
1881
|
* mask.
|
|
@@ -1465,13 +1932,13 @@ class Tt {
|
|
|
1465
1932
|
* before being sent as a proto.
|
|
1466
1933
|
* @internal
|
|
1467
1934
|
*/
|
|
1468
|
-
class
|
|
1935
|
+
class Nt {
|
|
1469
1936
|
constructor(t) {
|
|
1470
1937
|
this.binaryString = t;
|
|
1471
1938
|
}
|
|
1472
1939
|
static fromBase64String(t) {
|
|
1473
1940
|
const e = atob(t);
|
|
1474
|
-
return new
|
|
1941
|
+
return new Nt(e);
|
|
1475
1942
|
}
|
|
1476
1943
|
static fromUint8Array(t) {
|
|
1477
1944
|
// TODO(indexing); Remove the copy of the byte string here as this method
|
|
@@ -1488,7 +1955,7 @@ class At {
|
|
|
1488
1955
|
/**
|
|
1489
1956
|
* Helper function to convert a binary string to an Uint8Array.
|
|
1490
1957
|
*/ (t);
|
|
1491
|
-
return new
|
|
1958
|
+
return new Nt(e);
|
|
1492
1959
|
}
|
|
1493
1960
|
[Symbol.iterator]() {
|
|
1494
1961
|
let t = 0;
|
|
@@ -1543,24 +2010,24 @@ class At {
|
|
|
1543
2010
|
}
|
|
1544
2011
|
}
|
|
1545
2012
|
|
|
1546
|
-
|
|
2013
|
+
Nt.EMPTY_BYTE_STRING = new Nt("");
|
|
1547
2014
|
|
|
1548
|
-
const
|
|
2015
|
+
const Dt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
1549
2016
|
|
|
1550
2017
|
/**
|
|
1551
2018
|
* Converts the possible Proto values for a timestamp value into a "seconds and
|
|
1552
2019
|
* nanos" representation.
|
|
1553
|
-
*/ function
|
|
2020
|
+
*/ function $t(t) {
|
|
1554
2021
|
// The json interface (for the browser) will return an iso timestamp string,
|
|
1555
2022
|
// while the proto js library (for node) will return a
|
|
1556
2023
|
// google.protobuf.Timestamp instance.
|
|
1557
|
-
if (
|
|
2024
|
+
if (v(!!t), "string" == typeof t) {
|
|
1558
2025
|
// The date string can have higher precision (nanos) than the Date class
|
|
1559
2026
|
// (millis), so we do some custom parsing here.
|
|
1560
2027
|
// Parse the nanos right out of the string.
|
|
1561
2028
|
let e = 0;
|
|
1562
|
-
const n =
|
|
1563
|
-
if (
|
|
2029
|
+
const n = Dt.exec(t);
|
|
2030
|
+
if (v(!!n), n[1]) {
|
|
1564
2031
|
// Pad the fraction out to 9 digits (nanos).
|
|
1565
2032
|
let t = n[1];
|
|
1566
2033
|
t = (t + "000000000").substr(0, 9), e = Number(t);
|
|
@@ -1573,21 +2040,21 @@ const It = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1573
2040
|
};
|
|
1574
2041
|
}
|
|
1575
2042
|
return {
|
|
1576
|
-
seconds:
|
|
1577
|
-
nanos:
|
|
2043
|
+
seconds: xt(t.seconds),
|
|
2044
|
+
nanos: xt(t.nanos)
|
|
1578
2045
|
};
|
|
1579
2046
|
}
|
|
1580
2047
|
|
|
1581
2048
|
/**
|
|
1582
2049
|
* Converts the possible Proto types for numbers into a JavaScript number.
|
|
1583
2050
|
* Returns 0 if the value is not numeric.
|
|
1584
|
-
*/ function
|
|
2051
|
+
*/ function xt(t) {
|
|
1585
2052
|
// TODO(bjornick): Handle int64 greater than 53 bits.
|
|
1586
2053
|
return "number" == typeof t ? t : "string" == typeof t ? Number(t) : 0;
|
|
1587
2054
|
}
|
|
1588
2055
|
|
|
1589
|
-
/** Converts the possible Proto types for Blobs into a ByteString. */ function
|
|
1590
|
-
return "string" == typeof t ?
|
|
2056
|
+
/** Converts the possible Proto types for Blobs into a ByteString. */ function Ft(t) {
|
|
2057
|
+
return "string" == typeof t ? Nt.fromBase64String(t) : Nt.fromUint8Array(t);
|
|
1591
2058
|
}
|
|
1592
2059
|
|
|
1593
2060
|
/**
|
|
@@ -1623,7 +2090,7 @@ const It = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1623
2090
|
* FieldValueOptions to value().
|
|
1624
2091
|
* - With respect to other ServerTimestampValues, they sort by their
|
|
1625
2092
|
* localWriteTime.
|
|
1626
|
-
*/ function
|
|
2093
|
+
*/ function St(t) {
|
|
1627
2094
|
var e, n;
|
|
1628
2095
|
return "server_timestamp" === (null === (n = ((null === (e = null == t ? void 0 : t.mapValue) || void 0 === e ? void 0 : e.fields) || {}).__type__) || void 0 === n ? void 0 : n.stringValue);
|
|
1629
2096
|
}
|
|
@@ -1633,15 +2100,15 @@ const It = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1633
2100
|
*
|
|
1634
2101
|
* Preserving the previous values allows the user to display the last resoled
|
|
1635
2102
|
* value until the backend responds with the timestamp.
|
|
1636
|
-
*/ function
|
|
2103
|
+
*/ function qt(t) {
|
|
1637
2104
|
const e = t.mapValue.fields.__previous_value__;
|
|
1638
|
-
return
|
|
2105
|
+
return St(e) ? qt(e) : e;
|
|
1639
2106
|
}
|
|
1640
2107
|
|
|
1641
2108
|
/**
|
|
1642
2109
|
* Returns the local time at which this timestamp was first set.
|
|
1643
|
-
*/ function
|
|
1644
|
-
const e =
|
|
2110
|
+
*/ function Ot(t) {
|
|
2111
|
+
const e = $t(t.mapValue.fields.__local_write_time__.timestampValue);
|
|
1645
2112
|
return new gt(e.seconds, e.nanos);
|
|
1646
2113
|
}
|
|
1647
2114
|
|
|
@@ -1660,7 +2127,7 @@ const It = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1660
2127
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1661
2128
|
* See the License for the specific language governing permissions and
|
|
1662
2129
|
* limitations under the License.
|
|
1663
|
-
*/ const
|
|
2130
|
+
*/ const kt = {
|
|
1664
2131
|
fields: {
|
|
1665
2132
|
__type__: {
|
|
1666
2133
|
stringValue: "__max__"
|
|
@@ -1669,8 +2136,8 @@ const It = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1669
2136
|
};
|
|
1670
2137
|
|
|
1671
2138
|
/** Extracts the backend's type order for the provided value. */
|
|
1672
|
-
function
|
|
1673
|
-
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 ?
|
|
2139
|
+
function Ct(t) {
|
|
2140
|
+
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 ? St(t) ? 4 /* ServerTimestampValue */ :
|
|
1674
2141
|
/** Returns true if the Value represents the canonical {@link #MAX_VALUE} . */
|
|
1675
2142
|
function(t) {
|
|
1676
2143
|
return "__max__" === (((t.mapValue || {}).fields || {}).__type__ || {}).stringValue;
|
|
@@ -1697,10 +2164,10 @@ function xt(t) {
|
|
|
1697
2164
|
*/ (t) ? 9007199254740991 /* MaxValue */ : 10 /* ObjectValue */ : g();
|
|
1698
2165
|
}
|
|
1699
2166
|
|
|
1700
|
-
/** Tests `left` and `right` for equality based on the backend semantics. */ function
|
|
2167
|
+
/** Tests `left` and `right` for equality based on the backend semantics. */ function Lt(t, e) {
|
|
1701
2168
|
if (t === e) return !0;
|
|
1702
|
-
const n =
|
|
1703
|
-
if (n !==
|
|
2169
|
+
const n = Ct(t);
|
|
2170
|
+
if (n !== Ct(e)) return !1;
|
|
1704
2171
|
switch (n) {
|
|
1705
2172
|
case 0 /* NullValue */ :
|
|
1706
2173
|
case 9007199254740991 /* MaxValue */ :
|
|
@@ -1710,14 +2177,14 @@ function xt(t) {
|
|
|
1710
2177
|
return t.booleanValue === e.booleanValue;
|
|
1711
2178
|
|
|
1712
2179
|
case 4 /* ServerTimestampValue */ :
|
|
1713
|
-
return
|
|
2180
|
+
return Ot(t).isEqual(Ot(e));
|
|
1714
2181
|
|
|
1715
2182
|
case 3 /* TimestampValue */ :
|
|
1716
2183
|
return function(t, e) {
|
|
1717
2184
|
if ("string" == typeof t.timestampValue && "string" == typeof e.timestampValue && t.timestampValue.length === e.timestampValue.length)
|
|
1718
2185
|
// Use string equality for ISO 8601 timestamps
|
|
1719
2186
|
return t.timestampValue === e.timestampValue;
|
|
1720
|
-
const n =
|
|
2187
|
+
const n = $t(t.timestampValue), r = $t(e.timestampValue);
|
|
1721
2188
|
return n.seconds === r.seconds && n.nanos === r.nanos;
|
|
1722
2189
|
}(t, e);
|
|
1723
2190
|
|
|
@@ -1726,7 +2193,7 @@ function xt(t) {
|
|
|
1726
2193
|
|
|
1727
2194
|
case 6 /* BlobValue */ :
|
|
1728
2195
|
return function(t, e) {
|
|
1729
|
-
return
|
|
2196
|
+
return Ft(t.bytesValue).isEqual(Ft(e.bytesValue));
|
|
1730
2197
|
}(t, e);
|
|
1731
2198
|
|
|
1732
2199
|
case 7 /* RefValue */ :
|
|
@@ -1734,27 +2201,27 @@ function xt(t) {
|
|
|
1734
2201
|
|
|
1735
2202
|
case 8 /* GeoPointValue */ :
|
|
1736
2203
|
return function(t, e) {
|
|
1737
|
-
return
|
|
2204
|
+
return xt(t.geoPointValue.latitude) === xt(e.geoPointValue.latitude) && xt(t.geoPointValue.longitude) === xt(e.geoPointValue.longitude);
|
|
1738
2205
|
}(t, e);
|
|
1739
2206
|
|
|
1740
2207
|
case 2 /* NumberValue */ :
|
|
1741
2208
|
return function(t, e) {
|
|
1742
|
-
if ("integerValue" in t && "integerValue" in e) return
|
|
2209
|
+
if ("integerValue" in t && "integerValue" in e) return xt(t.integerValue) === xt(e.integerValue);
|
|
1743
2210
|
if ("doubleValue" in t && "doubleValue" in e) {
|
|
1744
|
-
const n =
|
|
2211
|
+
const n = xt(t.doubleValue), r = xt(e.doubleValue);
|
|
1745
2212
|
return n === r ? at(n) === at(r) : isNaN(n) && isNaN(r);
|
|
1746
2213
|
}
|
|
1747
2214
|
return !1;
|
|
1748
2215
|
}(t, e);
|
|
1749
2216
|
|
|
1750
2217
|
case 9 /* ArrayValue */ :
|
|
1751
|
-
return _t(t.arrayValue.values || [], e.arrayValue.values || [],
|
|
2218
|
+
return _t(t.arrayValue.values || [], e.arrayValue.values || [], Lt);
|
|
1752
2219
|
|
|
1753
2220
|
case 10 /* ObjectValue */ :
|
|
1754
2221
|
return function(t, e) {
|
|
1755
2222
|
const n = t.mapValue.fields || {}, r = e.mapValue.fields || {};
|
|
1756
|
-
if (
|
|
1757
|
-
for (const t in n) if (n.hasOwnProperty(t) && (void 0 === r[t] || !
|
|
2223
|
+
if (bt(n) !== bt(r)) return !1;
|
|
2224
|
+
for (const t in n) if (n.hasOwnProperty(t) && (void 0 === r[t] || !Lt(n[t], r[t]))) return !1;
|
|
1758
2225
|
return !0;
|
|
1759
2226
|
}
|
|
1760
2227
|
/** Returns true if the ArrayValue contains the specified element. */ (t, e);
|
|
@@ -1764,13 +2231,13 @@ function xt(t) {
|
|
|
1764
2231
|
}
|
|
1765
2232
|
}
|
|
1766
2233
|
|
|
1767
|
-
function
|
|
1768
|
-
return void 0 !== (t.values || []).find((t =>
|
|
2234
|
+
function Mt(t, e) {
|
|
2235
|
+
return void 0 !== (t.values || []).find((t => Lt(t, e)));
|
|
1769
2236
|
}
|
|
1770
2237
|
|
|
1771
|
-
function
|
|
2238
|
+
function Ut(t, e) {
|
|
1772
2239
|
if (t === e) return 0;
|
|
1773
|
-
const n =
|
|
2240
|
+
const n = Ct(t), r = Ct(e);
|
|
1774
2241
|
if (n !== r) return yt(n, r);
|
|
1775
2242
|
switch (n) {
|
|
1776
2243
|
case 0 /* NullValue */ :
|
|
@@ -1782,24 +2249,24 @@ function Ot(t, e) {
|
|
|
1782
2249
|
|
|
1783
2250
|
case 2 /* NumberValue */ :
|
|
1784
2251
|
return function(t, e) {
|
|
1785
|
-
const n =
|
|
2252
|
+
const n = xt(t.integerValue || t.doubleValue), r = xt(e.integerValue || e.doubleValue);
|
|
1786
2253
|
return n < r ? -1 : n > r ? 1 : n === r ? 0 :
|
|
1787
2254
|
// one or both are NaN.
|
|
1788
2255
|
isNaN(n) ? isNaN(r) ? 0 : -1 : 1;
|
|
1789
2256
|
}(t, e);
|
|
1790
2257
|
|
|
1791
2258
|
case 3 /* TimestampValue */ :
|
|
1792
|
-
return
|
|
2259
|
+
return jt(t.timestampValue, e.timestampValue);
|
|
1793
2260
|
|
|
1794
2261
|
case 4 /* ServerTimestampValue */ :
|
|
1795
|
-
return
|
|
2262
|
+
return jt(Ot(t), Ot(e));
|
|
1796
2263
|
|
|
1797
2264
|
case 5 /* StringValue */ :
|
|
1798
2265
|
return yt(t.stringValue, e.stringValue);
|
|
1799
2266
|
|
|
1800
2267
|
case 6 /* BlobValue */ :
|
|
1801
2268
|
return function(t, e) {
|
|
1802
|
-
const n =
|
|
2269
|
+
const n = Ft(t), r = Ft(e);
|
|
1803
2270
|
return n.compareTo(r);
|
|
1804
2271
|
}(t.bytesValue, e.bytesValue);
|
|
1805
2272
|
|
|
@@ -1815,16 +2282,16 @@ function Ot(t, e) {
|
|
|
1815
2282
|
|
|
1816
2283
|
case 8 /* GeoPointValue */ :
|
|
1817
2284
|
return function(t, e) {
|
|
1818
|
-
const n = yt(
|
|
2285
|
+
const n = yt(xt(t.latitude), xt(e.latitude));
|
|
1819
2286
|
if (0 !== n) return n;
|
|
1820
|
-
return yt(
|
|
2287
|
+
return yt(xt(t.longitude), xt(e.longitude));
|
|
1821
2288
|
}(t.geoPointValue, e.geoPointValue);
|
|
1822
2289
|
|
|
1823
2290
|
case 9 /* ArrayValue */ :
|
|
1824
2291
|
return function(t, e) {
|
|
1825
2292
|
const n = t.values || [], r = e.values || [];
|
|
1826
2293
|
for (let t = 0; t < n.length && t < r.length; ++t) {
|
|
1827
|
-
const e =
|
|
2294
|
+
const e = Ut(n[t], r[t]);
|
|
1828
2295
|
if (e) return e;
|
|
1829
2296
|
}
|
|
1830
2297
|
return yt(n.length, r.length);
|
|
@@ -1832,9 +2299,9 @@ function Ot(t, e) {
|
|
|
1832
2299
|
|
|
1833
2300
|
case 10 /* ObjectValue */ :
|
|
1834
2301
|
return function(t, e) {
|
|
1835
|
-
if (t ===
|
|
1836
|
-
if (t ===
|
|
1837
|
-
if (e ===
|
|
2302
|
+
if (t === kt && e === kt) return 0;
|
|
2303
|
+
if (t === kt) return 1;
|
|
2304
|
+
if (e === kt) return -1;
|
|
1838
2305
|
const n = t.fields || {}, r = Object.keys(n), s = e.fields || {}, i = Object.keys(s);
|
|
1839
2306
|
// Even though MapValues are likely sorted correctly based on their insertion
|
|
1840
2307
|
// order (e.g. when received from the backend), local modifications can bring
|
|
@@ -1844,7 +2311,7 @@ function Ot(t, e) {
|
|
|
1844
2311
|
for (let t = 0; t < r.length && t < i.length; ++t) {
|
|
1845
2312
|
const e = yt(r[t], i[t]);
|
|
1846
2313
|
if (0 !== e) return e;
|
|
1847
|
-
const o =
|
|
2314
|
+
const o = Ut(n[r[t]], s[i[t]]);
|
|
1848
2315
|
if (0 !== o) return o;
|
|
1849
2316
|
}
|
|
1850
2317
|
return yt(r.length, i.length);
|
|
@@ -1856,35 +2323,35 @@ function Ot(t, e) {
|
|
|
1856
2323
|
}
|
|
1857
2324
|
}
|
|
1858
2325
|
|
|
1859
|
-
function
|
|
2326
|
+
function jt(t, e) {
|
|
1860
2327
|
if ("string" == typeof t && "string" == typeof e && t.length === e.length) return yt(t, e);
|
|
1861
|
-
const n =
|
|
2328
|
+
const n = $t(t), r = $t(e), s = yt(n.seconds, r.seconds);
|
|
1862
2329
|
return 0 !== s ? s : yt(n.nanos, r.nanos);
|
|
1863
2330
|
}
|
|
1864
2331
|
|
|
1865
|
-
function
|
|
2332
|
+
function Bt(t, e) {
|
|
1866
2333
|
return {
|
|
1867
2334
|
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${e.path.canonicalString()}`
|
|
1868
2335
|
};
|
|
1869
2336
|
}
|
|
1870
2337
|
|
|
1871
|
-
/** Returns true if `value` is an ArrayValue. */ function
|
|
2338
|
+
/** Returns true if `value` is an ArrayValue. */ function zt(t) {
|
|
1872
2339
|
return !!t && "arrayValue" in t;
|
|
1873
2340
|
}
|
|
1874
2341
|
|
|
1875
|
-
/** Returns true if `value` is a NullValue. */ function
|
|
2342
|
+
/** Returns true if `value` is a NullValue. */ function Gt(t) {
|
|
1876
2343
|
return !!t && "nullValue" in t;
|
|
1877
2344
|
}
|
|
1878
2345
|
|
|
1879
|
-
/** Returns true if `value` is NaN. */ function
|
|
2346
|
+
/** Returns true if `value` is NaN. */ function Wt(t) {
|
|
1880
2347
|
return !!t && "doubleValue" in t && isNaN(Number(t.doubleValue));
|
|
1881
2348
|
}
|
|
1882
2349
|
|
|
1883
|
-
/** Returns true if `value` is a MapValue. */ function
|
|
2350
|
+
/** Returns true if `value` is a MapValue. */ function Kt(t) {
|
|
1884
2351
|
return !!t && "mapValue" in t;
|
|
1885
2352
|
}
|
|
1886
2353
|
|
|
1887
|
-
/** Creates a deep copy of `source`. */ function
|
|
2354
|
+
/** Creates a deep copy of `source`. */ function Qt(t) {
|
|
1888
2355
|
if (t.geoPointValue) return {
|
|
1889
2356
|
geoPointValue: Object.assign({}, t.geoPointValue)
|
|
1890
2357
|
};
|
|
@@ -1897,7 +2364,7 @@ function Lt(t, e) {
|
|
|
1897
2364
|
fields: {}
|
|
1898
2365
|
}
|
|
1899
2366
|
};
|
|
1900
|
-
return Et(t.mapValue.fields, ((t, n) => e.mapValue.fields[t] =
|
|
2367
|
+
return Et(t.mapValue.fields, ((t, n) => e.mapValue.fields[t] = Qt(n))), e;
|
|
1901
2368
|
}
|
|
1902
2369
|
if (t.arrayValue) {
|
|
1903
2370
|
const e = {
|
|
@@ -1905,18 +2372,18 @@ function Lt(t, e) {
|
|
|
1905
2372
|
values: []
|
|
1906
2373
|
}
|
|
1907
2374
|
};
|
|
1908
|
-
for (let n = 0; n < (t.arrayValue.values || []).length; ++n) e.arrayValue.values[n] =
|
|
2375
|
+
for (let n = 0; n < (t.arrayValue.values || []).length; ++n) e.arrayValue.values[n] = Qt(t.arrayValue.values[n]);
|
|
1909
2376
|
return e;
|
|
1910
2377
|
}
|
|
1911
2378
|
return Object.assign({}, t);
|
|
1912
2379
|
}
|
|
1913
2380
|
|
|
1914
|
-
class
|
|
2381
|
+
class Yt {
|
|
1915
2382
|
constructor(t) {
|
|
1916
2383
|
this.value = t;
|
|
1917
2384
|
}
|
|
1918
2385
|
static empty() {
|
|
1919
|
-
return new
|
|
2386
|
+
return new Yt({
|
|
1920
2387
|
mapValue: {}
|
|
1921
2388
|
});
|
|
1922
2389
|
}
|
|
@@ -1930,7 +2397,7 @@ class zt {
|
|
|
1930
2397
|
{
|
|
1931
2398
|
let e = this.value;
|
|
1932
2399
|
for (let n = 0; n < t.length - 1; ++n) if (e = (e.mapValue.fields || {})[t.get(n)],
|
|
1933
|
-
!
|
|
2400
|
+
!Kt(e)) return null;
|
|
1934
2401
|
return e = (e.mapValue.fields || {})[t.lastSegment()], e || null;
|
|
1935
2402
|
}
|
|
1936
2403
|
}
|
|
@@ -1940,7 +2407,7 @@ class zt {
|
|
|
1940
2407
|
* @param path - The field path to set.
|
|
1941
2408
|
* @param value - The value to set.
|
|
1942
2409
|
*/ set(t, e) {
|
|
1943
|
-
this.getFieldsMap(t.popLast())[t.lastSegment()] =
|
|
2410
|
+
this.getFieldsMap(t.popLast())[t.lastSegment()] = Qt(e);
|
|
1944
2411
|
}
|
|
1945
2412
|
/**
|
|
1946
2413
|
* Sets the provided fields to the provided values.
|
|
@@ -1954,7 +2421,7 @@ class zt {
|
|
|
1954
2421
|
const t = this.getFieldsMap(e);
|
|
1955
2422
|
this.applyChanges(t, n, r), n = {}, r = [], e = s.popLast();
|
|
1956
2423
|
}
|
|
1957
|
-
t ? n[s.lastSegment()] =
|
|
2424
|
+
t ? n[s.lastSegment()] = Qt(t) : r.push(s.lastSegment());
|
|
1958
2425
|
}));
|
|
1959
2426
|
const s = this.getFieldsMap(e);
|
|
1960
2427
|
this.applyChanges(s, n, r);
|
|
@@ -1966,10 +2433,10 @@ class zt {
|
|
|
1966
2433
|
* @param path - The field path to remove.
|
|
1967
2434
|
*/ delete(t) {
|
|
1968
2435
|
const e = this.field(t.popLast());
|
|
1969
|
-
|
|
2436
|
+
Kt(e) && e.mapValue.fields && delete e.mapValue.fields[t.lastSegment()];
|
|
1970
2437
|
}
|
|
1971
2438
|
isEqual(t) {
|
|
1972
|
-
return
|
|
2439
|
+
return Lt(this.value, t.value);
|
|
1973
2440
|
}
|
|
1974
2441
|
/**
|
|
1975
2442
|
* Returns the map that contains the leaf element of `path`. If the parent
|
|
@@ -1981,7 +2448,7 @@ class zt {
|
|
|
1981
2448
|
});
|
|
1982
2449
|
for (let n = 0; n < t.length; ++n) {
|
|
1983
2450
|
let r = e.mapValue.fields[t.get(n)];
|
|
1984
|
-
|
|
2451
|
+
Kt(r) && r.mapValue.fields || (r = {
|
|
1985
2452
|
mapValue: {
|
|
1986
2453
|
fields: {}
|
|
1987
2454
|
}
|
|
@@ -1997,7 +2464,7 @@ class zt {
|
|
|
1997
2464
|
for (const e of n) delete t[e];
|
|
1998
2465
|
}
|
|
1999
2466
|
clone() {
|
|
2000
|
-
return new
|
|
2467
|
+
return new Yt(Qt(this.value));
|
|
2001
2468
|
}
|
|
2002
2469
|
}
|
|
2003
2470
|
|
|
@@ -2026,7 +2493,7 @@ class zt {
|
|
|
2026
2493
|
* not transition to one of these states even after all mutations have been
|
|
2027
2494
|
* applied, `isValidDocument()` returns false and the document should be removed
|
|
2028
2495
|
* from all views.
|
|
2029
|
-
*/ class
|
|
2496
|
+
*/ class Ht {
|
|
2030
2497
|
constructor(t, e, n, r, s, i) {
|
|
2031
2498
|
this.key = t, this.documentType = e, this.version = n, this.readTime = r, this.data = s,
|
|
2032
2499
|
this.documentState = i;
|
|
@@ -2035,23 +2502,23 @@ class zt {
|
|
|
2035
2502
|
* Creates a document with no known version or data, but which can serve as
|
|
2036
2503
|
* base document for mutations.
|
|
2037
2504
|
*/ static newInvalidDocument(t) {
|
|
2038
|
-
return new
|
|
2505
|
+
return new Ht(t, 0 /* INVALID */ , vt.min(), vt.min(), Yt.empty(), 0 /* SYNCED */);
|
|
2039
2506
|
}
|
|
2040
2507
|
/**
|
|
2041
2508
|
* Creates a new document that is known to exist with the given data at the
|
|
2042
2509
|
* given version.
|
|
2043
2510
|
*/ static newFoundDocument(t, e, n) {
|
|
2044
|
-
return new
|
|
2511
|
+
return new Ht(t, 1 /* FOUND_DOCUMENT */ , e, vt.min(), n, 0 /* SYNCED */);
|
|
2045
2512
|
}
|
|
2046
2513
|
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t, e) {
|
|
2047
|
-
return new
|
|
2514
|
+
return new Ht(t, 2 /* NO_DOCUMENT */ , e, vt.min(), Yt.empty(), 0 /* SYNCED */);
|
|
2048
2515
|
}
|
|
2049
2516
|
/**
|
|
2050
2517
|
* Creates a new document that is known to exist at the given version but
|
|
2051
2518
|
* whose data is not known (e.g. a document that was updated without a known
|
|
2052
2519
|
* base document).
|
|
2053
2520
|
*/ static newUnknownDocument(t, e) {
|
|
2054
|
-
return new
|
|
2521
|
+
return new Ht(t, 3 /* UNKNOWN_DOCUMENT */ , e, vt.min(), Yt.empty(), 2 /* HAS_COMMITTED_MUTATIONS */);
|
|
2055
2522
|
}
|
|
2056
2523
|
/**
|
|
2057
2524
|
* Changes the document type to indicate that it exists and that its version
|
|
@@ -2064,7 +2531,7 @@ class zt {
|
|
|
2064
2531
|
* Changes the document type to indicate that it doesn't exist at the given
|
|
2065
2532
|
* version.
|
|
2066
2533
|
*/ convertToNoDocument(t) {
|
|
2067
|
-
return this.version = t, this.documentType = 2 /* NO_DOCUMENT */ , this.data =
|
|
2534
|
+
return this.version = t, this.documentType = 2 /* NO_DOCUMENT */ , this.data = Yt.empty(),
|
|
2068
2535
|
this.documentState = 0 /* SYNCED */ , this;
|
|
2069
2536
|
}
|
|
2070
2537
|
/**
|
|
@@ -2072,14 +2539,15 @@ class zt {
|
|
|
2072
2539
|
* that its data is not known (e.g. a document that was updated without a known
|
|
2073
2540
|
* base document).
|
|
2074
2541
|
*/ convertToUnknownDocument(t) {
|
|
2075
|
-
return this.version = t, this.documentType = 3 /* UNKNOWN_DOCUMENT */ , this.data =
|
|
2542
|
+
return this.version = t, this.documentType = 3 /* UNKNOWN_DOCUMENT */ , this.data = Yt.empty(),
|
|
2076
2543
|
this.documentState = 2 /* HAS_COMMITTED_MUTATIONS */ , this;
|
|
2077
2544
|
}
|
|
2078
2545
|
setHasCommittedMutations() {
|
|
2079
2546
|
return this.documentState = 2 /* HAS_COMMITTED_MUTATIONS */ , this;
|
|
2080
2547
|
}
|
|
2081
2548
|
setHasLocalMutations() {
|
|
2082
|
-
return this.documentState = 1 /* HAS_LOCAL_MUTATIONS */ , this
|
|
2549
|
+
return this.documentState = 1 /* HAS_LOCAL_MUTATIONS */ , this.version = vt.min(),
|
|
2550
|
+
this;
|
|
2083
2551
|
}
|
|
2084
2552
|
setReadTime(t) {
|
|
2085
2553
|
return this.readTime = t, this;
|
|
@@ -2106,10 +2574,10 @@ class zt {
|
|
|
2106
2574
|
return 3 /* UNKNOWN_DOCUMENT */ === this.documentType;
|
|
2107
2575
|
}
|
|
2108
2576
|
isEqual(t) {
|
|
2109
|
-
return t instanceof
|
|
2577
|
+
return t instanceof Ht && this.key.isEqual(t.key) && this.version.isEqual(t.version) && this.documentType === t.documentType && this.documentState === t.documentState && this.data.isEqual(t.data);
|
|
2110
2578
|
}
|
|
2111
2579
|
mutableCopy() {
|
|
2112
|
-
return new
|
|
2580
|
+
return new Ht(this.key, this.documentType, this.version, this.readTime, this.data.clone(), this.documentState);
|
|
2113
2581
|
}
|
|
2114
2582
|
toString() {
|
|
2115
2583
|
return `Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`;
|
|
@@ -2133,7 +2601,7 @@ class zt {
|
|
|
2133
2601
|
* limitations under the License.
|
|
2134
2602
|
*/
|
|
2135
2603
|
// Visible for testing
|
|
2136
|
-
class
|
|
2604
|
+
class Jt {
|
|
2137
2605
|
constructor(t, e = null, n = [], r = [], s = null, i = null, o = null) {
|
|
2138
2606
|
this.path = t, this.collectionGroup = e, this.orderBy = n, this.filters = r, this.limit = s,
|
|
2139
2607
|
this.startAt = i, this.endAt = o, this.P = null;
|
|
@@ -2147,29 +2615,29 @@ class Qt {
|
|
|
2147
2615
|
* NOTE: you should always construct `Target` from `Query.toTarget` instead of
|
|
2148
2616
|
* using this factory method, because `Query` provides an implicit `orderBy`
|
|
2149
2617
|
* property.
|
|
2150
|
-
*/ function
|
|
2151
|
-
return new
|
|
2618
|
+
*/ function Xt(t, e = null, n = [], r = [], s = null, i = null, o = null) {
|
|
2619
|
+
return new Jt(t, e, n, r, s, i, o);
|
|
2152
2620
|
}
|
|
2153
2621
|
|
|
2154
|
-
class
|
|
2622
|
+
class Zt extends class {} {
|
|
2155
2623
|
constructor(t, e, n) {
|
|
2156
2624
|
super(), this.field = t, this.op = e, this.value = n;
|
|
2157
2625
|
}
|
|
2158
2626
|
/**
|
|
2159
2627
|
* Creates a filter based on the provided arguments.
|
|
2160
2628
|
*/ static create(t, e, n) {
|
|
2161
|
-
return t.isKeyField() ? "in" /* IN */ === e || "not-in" /* NOT_IN */ === e ? this.V(t, e, n) : new
|
|
2629
|
+
return t.isKeyField() ? "in" /* IN */ === e || "not-in" /* NOT_IN */ === e ? this.V(t, e, n) : new te(t, e, n) : "array-contains" /* ARRAY_CONTAINS */ === e ? new se(t, n) : "in" /* IN */ === e ? new ie(t, n) : "not-in" /* NOT_IN */ === e ? new oe(t, n) : "array-contains-any" /* ARRAY_CONTAINS_ANY */ === e ? new ue(t, n) : new Zt(t, e, n);
|
|
2162
2630
|
}
|
|
2163
2631
|
static V(t, e, n) {
|
|
2164
|
-
return "in" /* IN */ === e ? new
|
|
2632
|
+
return "in" /* IN */ === e ? new ee(t, n) : new ne(t, n);
|
|
2165
2633
|
}
|
|
2166
2634
|
matches(t) {
|
|
2167
2635
|
const e = t.data.field(this.field);
|
|
2168
2636
|
// Types do not have to match in NOT_EQUAL filters.
|
|
2169
|
-
return "!=" /* NOT_EQUAL */ === this.op ? null !== e && this.
|
|
2637
|
+
return "!=" /* NOT_EQUAL */ === this.op ? null !== e && this.N(Ut(e, this.value)) : null !== e && Ct(this.value) === Ct(e) && this.N(Ut(e, this.value));
|
|
2170
2638
|
// Only compare types with matching backend order (such as double and int).
|
|
2171
2639
|
}
|
|
2172
|
-
|
|
2640
|
+
N(t) {
|
|
2173
2641
|
switch (this.op) {
|
|
2174
2642
|
case "<" /* LESS_THAN */ :
|
|
2175
2643
|
return t < 0;
|
|
@@ -2193,85 +2661,85 @@ class Yt extends class {} {
|
|
|
2193
2661
|
return g();
|
|
2194
2662
|
}
|
|
2195
2663
|
}
|
|
2196
|
-
|
|
2664
|
+
D() {
|
|
2197
2665
|
return [ "<" /* LESS_THAN */ , "<=" /* LESS_THAN_OR_EQUAL */ , ">" /* GREATER_THAN */ , ">=" /* GREATER_THAN_OR_EQUAL */ , "!=" /* NOT_EQUAL */ , "not-in" /* NOT_IN */ ].indexOf(this.op) >= 0;
|
|
2198
2666
|
}
|
|
2199
2667
|
}
|
|
2200
2668
|
|
|
2201
2669
|
/** Filter that matches on key fields (i.e. '__name__'). */
|
|
2202
|
-
class
|
|
2670
|
+
class te extends Zt {
|
|
2203
2671
|
constructor(t, e, n) {
|
|
2204
2672
|
super(t, e, n), this.key = et.fromName(n.referenceValue);
|
|
2205
2673
|
}
|
|
2206
2674
|
matches(t) {
|
|
2207
2675
|
const e = et.comparator(t.key, this.key);
|
|
2208
|
-
return this.
|
|
2676
|
+
return this.N(e);
|
|
2209
2677
|
}
|
|
2210
2678
|
}
|
|
2211
2679
|
|
|
2212
|
-
/** Filter that matches on key fields within an array. */ class
|
|
2680
|
+
/** Filter that matches on key fields within an array. */ class ee extends Zt {
|
|
2213
2681
|
constructor(t, e) {
|
|
2214
|
-
super(t, "in" /* IN */ , e), this.keys =
|
|
2682
|
+
super(t, "in" /* IN */ , e), this.keys = re("in" /* IN */ , e);
|
|
2215
2683
|
}
|
|
2216
2684
|
matches(t) {
|
|
2217
2685
|
return this.keys.some((e => e.isEqual(t.key)));
|
|
2218
2686
|
}
|
|
2219
2687
|
}
|
|
2220
2688
|
|
|
2221
|
-
/** Filter that matches on key fields not present within an array. */ class
|
|
2689
|
+
/** Filter that matches on key fields not present within an array. */ class ne extends Zt {
|
|
2222
2690
|
constructor(t, e) {
|
|
2223
|
-
super(t, "not-in" /* NOT_IN */ , e), this.keys =
|
|
2691
|
+
super(t, "not-in" /* NOT_IN */ , e), this.keys = re("not-in" /* NOT_IN */ , e);
|
|
2224
2692
|
}
|
|
2225
2693
|
matches(t) {
|
|
2226
2694
|
return !this.keys.some((e => e.isEqual(t.key)));
|
|
2227
2695
|
}
|
|
2228
2696
|
}
|
|
2229
2697
|
|
|
2230
|
-
function
|
|
2698
|
+
function re(t, e) {
|
|
2231
2699
|
var n;
|
|
2232
2700
|
return ((null === (n = e.arrayValue) || void 0 === n ? void 0 : n.values) || []).map((t => et.fromName(t.referenceValue)));
|
|
2233
2701
|
}
|
|
2234
2702
|
|
|
2235
|
-
/** A Filter that implements the array-contains operator. */ class
|
|
2703
|
+
/** A Filter that implements the array-contains operator. */ class se extends Zt {
|
|
2236
2704
|
constructor(t, e) {
|
|
2237
2705
|
super(t, "array-contains" /* ARRAY_CONTAINS */ , e);
|
|
2238
2706
|
}
|
|
2239
2707
|
matches(t) {
|
|
2240
2708
|
const e = t.data.field(this.field);
|
|
2241
|
-
return
|
|
2709
|
+
return zt(e) && Mt(e.arrayValue, this.value);
|
|
2242
2710
|
}
|
|
2243
2711
|
}
|
|
2244
2712
|
|
|
2245
|
-
/** A Filter that implements the IN operator. */ class
|
|
2713
|
+
/** A Filter that implements the IN operator. */ class ie extends Zt {
|
|
2246
2714
|
constructor(t, e) {
|
|
2247
2715
|
super(t, "in" /* IN */ , e);
|
|
2248
2716
|
}
|
|
2249
2717
|
matches(t) {
|
|
2250
2718
|
const e = t.data.field(this.field);
|
|
2251
|
-
return null !== e &&
|
|
2719
|
+
return null !== e && Mt(this.value.arrayValue, e);
|
|
2252
2720
|
}
|
|
2253
2721
|
}
|
|
2254
2722
|
|
|
2255
|
-
/** A Filter that implements the not-in operator. */ class
|
|
2723
|
+
/** A Filter that implements the not-in operator. */ class oe extends Zt {
|
|
2256
2724
|
constructor(t, e) {
|
|
2257
2725
|
super(t, "not-in" /* NOT_IN */ , e);
|
|
2258
2726
|
}
|
|
2259
2727
|
matches(t) {
|
|
2260
|
-
if (
|
|
2728
|
+
if (Mt(this.value.arrayValue, {
|
|
2261
2729
|
nullValue: "NULL_VALUE"
|
|
2262
2730
|
})) return !1;
|
|
2263
2731
|
const e = t.data.field(this.field);
|
|
2264
|
-
return null !== e && !
|
|
2732
|
+
return null !== e && !Mt(this.value.arrayValue, e);
|
|
2265
2733
|
}
|
|
2266
2734
|
}
|
|
2267
2735
|
|
|
2268
|
-
/** A Filter that implements the array-contains-any operator. */ class
|
|
2736
|
+
/** A Filter that implements the array-contains-any operator. */ class ue extends Zt {
|
|
2269
2737
|
constructor(t, e) {
|
|
2270
2738
|
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ , e);
|
|
2271
2739
|
}
|
|
2272
2740
|
matches(t) {
|
|
2273
2741
|
const e = t.data.field(this.field);
|
|
2274
|
-
return !(!
|
|
2742
|
+
return !(!zt(e) || !e.arrayValue.values) && e.arrayValue.values.some((t => Mt(this.value.arrayValue, t)));
|
|
2275
2743
|
}
|
|
2276
2744
|
}
|
|
2277
2745
|
|
|
@@ -2288,7 +2756,7 @@ function Xt(t, e) {
|
|
|
2288
2756
|
* Bound provides a function to determine whether a document comes before or
|
|
2289
2757
|
* after a bound. This is influenced by whether the position is just before or
|
|
2290
2758
|
* just after the provided values.
|
|
2291
|
-
*/ class
|
|
2759
|
+
*/ class ce {
|
|
2292
2760
|
constructor(t, e) {
|
|
2293
2761
|
this.position = t, this.inclusive = e;
|
|
2294
2762
|
}
|
|
@@ -2296,22 +2764,22 @@ function Xt(t, e) {
|
|
|
2296
2764
|
|
|
2297
2765
|
/**
|
|
2298
2766
|
* An ordering on a field, in some Direction. Direction defaults to ASCENDING.
|
|
2299
|
-
*/ class
|
|
2767
|
+
*/ class ae {
|
|
2300
2768
|
constructor(t, e = "asc" /* ASCENDING */) {
|
|
2301
2769
|
this.field = t, this.dir = e;
|
|
2302
2770
|
}
|
|
2303
2771
|
}
|
|
2304
2772
|
|
|
2305
|
-
function
|
|
2773
|
+
function he(t, e) {
|
|
2306
2774
|
return t.dir === e.dir && t.field.isEqual(e.field);
|
|
2307
2775
|
}
|
|
2308
2776
|
|
|
2309
|
-
function
|
|
2777
|
+
function le(t, e) {
|
|
2310
2778
|
if (null === t) return null === e;
|
|
2311
2779
|
if (null === e) return !1;
|
|
2312
2780
|
if (t.inclusive !== e.inclusive || t.position.length !== e.position.length) return !1;
|
|
2313
2781
|
for (let n = 0; n < t.position.length; n++) {
|
|
2314
|
-
if (!
|
|
2782
|
+
if (!Lt(t.position[n], e.position[n])) return !1;
|
|
2315
2783
|
}
|
|
2316
2784
|
return !0;
|
|
2317
2785
|
}
|
|
@@ -2338,7 +2806,7 @@ function oe(t, e) {
|
|
|
2338
2806
|
* query the RemoteStore results.
|
|
2339
2807
|
*
|
|
2340
2808
|
* Visible for testing.
|
|
2341
|
-
*/ class
|
|
2809
|
+
*/ class fe {
|
|
2342
2810
|
/**
|
|
2343
2811
|
* Initializes a Query with a path and optional additional query constraints.
|
|
2344
2812
|
* Path must currently be empty if this is a collection group query.
|
|
@@ -2347,16 +2815,16 @@ function oe(t, e) {
|
|
|
2347
2815
|
this.path = t, this.collectionGroup = e, this.explicitOrderBy = n, this.filters = r,
|
|
2348
2816
|
this.limit = s, this.limitType = i, this.startAt = o, this.endAt = u, this.$ = null,
|
|
2349
2817
|
// The corresponding `Target` of this `Query` instance.
|
|
2350
|
-
this.
|
|
2818
|
+
this.F = null, this.startAt, this.endAt;
|
|
2351
2819
|
}
|
|
2352
2820
|
}
|
|
2353
2821
|
|
|
2354
|
-
/** Creates a new Query for a query that matches all documents at `path` */ function
|
|
2822
|
+
/** Creates a new Query for a query that matches all documents at `path` */ function de(t) {
|
|
2355
2823
|
return t.explicitOrderBy.length > 0 ? t.explicitOrderBy[0].field : null;
|
|
2356
2824
|
}
|
|
2357
2825
|
|
|
2358
|
-
function
|
|
2359
|
-
for (const e of t.filters) if (e.
|
|
2826
|
+
function we(t) {
|
|
2827
|
+
for (const e of t.filters) if (e.D()) return e.field;
|
|
2360
2828
|
return null;
|
|
2361
2829
|
}
|
|
2362
2830
|
|
|
@@ -2368,7 +2836,7 @@ function ae(t) {
|
|
|
2368
2836
|
* Returns whether the query matches a collection group rather than a specific
|
|
2369
2837
|
* collection.
|
|
2370
2838
|
*/
|
|
2371
|
-
function
|
|
2839
|
+
function me(t) {
|
|
2372
2840
|
return null !== t.collectionGroup;
|
|
2373
2841
|
}
|
|
2374
2842
|
|
|
@@ -2376,23 +2844,23 @@ function he(t) {
|
|
|
2376
2844
|
* Returns the implicit order by constraint that is used to execute the Query,
|
|
2377
2845
|
* which can be different from the order by constraints the user provided (e.g.
|
|
2378
2846
|
* the SDK and backend always orders by `__name__`).
|
|
2379
|
-
*/ function
|
|
2380
|
-
const e =
|
|
2847
|
+
*/ function pe(t) {
|
|
2848
|
+
const e = b(t);
|
|
2381
2849
|
if (null === e.$) {
|
|
2382
2850
|
e.$ = [];
|
|
2383
|
-
const t =
|
|
2851
|
+
const t = we(e), n = de(e);
|
|
2384
2852
|
if (null !== t && null === n)
|
|
2385
2853
|
// In order to implicitly add key ordering, we must also add the
|
|
2386
2854
|
// inequality filter field for it to be a valid query.
|
|
2387
2855
|
// Note that the default inequality field and key ordering is ascending.
|
|
2388
|
-
t.isKeyField() || e.$.push(new
|
|
2856
|
+
t.isKeyField() || e.$.push(new ae(t)), e.$.push(new ae(tt.keyField(), "asc" /* ASCENDING */)); else {
|
|
2389
2857
|
let t = !1;
|
|
2390
2858
|
for (const n of e.explicitOrderBy) e.$.push(n), n.field.isKeyField() && (t = !0);
|
|
2391
2859
|
if (!t) {
|
|
2392
2860
|
// The order of the implicit key ordering always matches the last
|
|
2393
2861
|
// explicit order by
|
|
2394
2862
|
const t = e.explicitOrderBy.length > 0 ? e.explicitOrderBy[e.explicitOrderBy.length - 1].dir : "asc" /* ASCENDING */;
|
|
2395
|
-
e.$.push(new
|
|
2863
|
+
e.$.push(new ae(tt.keyField(), t));
|
|
2396
2864
|
}
|
|
2397
2865
|
}
|
|
2398
2866
|
}
|
|
@@ -2401,34 +2869,34 @@ function he(t) {
|
|
|
2401
2869
|
|
|
2402
2870
|
/**
|
|
2403
2871
|
* Converts this `Query` instance to it's corresponding `Target` representation.
|
|
2404
|
-
*/ function
|
|
2405
|
-
const e =
|
|
2406
|
-
if (!e.
|
|
2872
|
+
*/ function ye(t) {
|
|
2873
|
+
const e = b(t);
|
|
2874
|
+
if (!e.F) if ("F" /* First */ === e.limitType) e.F = Xt(e.path, e.collectionGroup, pe(e), e.filters, e.limit, e.startAt, e.endAt); else {
|
|
2407
2875
|
// Flip the orderBy directions since we want the last results
|
|
2408
2876
|
const t = [];
|
|
2409
|
-
for (const n of
|
|
2877
|
+
for (const n of pe(e)) {
|
|
2410
2878
|
const e = "desc" /* DESCENDING */ === n.dir ? "asc" /* ASCENDING */ : "desc" /* DESCENDING */;
|
|
2411
|
-
t.push(new
|
|
2879
|
+
t.push(new ae(n.field, e));
|
|
2412
2880
|
}
|
|
2413
2881
|
// We need to swap the cursors to match the now-flipped query ordering.
|
|
2414
|
-
const n = e.endAt ? new
|
|
2882
|
+
const n = e.endAt ? new ce(e.endAt.position, e.endAt.inclusive) : null, r = e.startAt ? new ce(e.startAt.position, e.startAt.inclusive) : null;
|
|
2415
2883
|
// Now return as a LimitType.First query.
|
|
2416
|
-
e.
|
|
2884
|
+
e.F = Xt(e.path, e.collectionGroup, t, e.filters, e.limit, n, r);
|
|
2417
2885
|
}
|
|
2418
|
-
return e.
|
|
2886
|
+
return e.F;
|
|
2419
2887
|
}
|
|
2420
2888
|
|
|
2421
|
-
function
|
|
2889
|
+
function _e(t, e) {
|
|
2422
2890
|
return function(t, e) {
|
|
2423
2891
|
if (t.limit !== e.limit) return !1;
|
|
2424
2892
|
if (t.orderBy.length !== e.orderBy.length) return !1;
|
|
2425
|
-
for (let n = 0; n < t.orderBy.length; n++) if (!
|
|
2893
|
+
for (let n = 0; n < t.orderBy.length; n++) if (!he(t.orderBy[n], e.orderBy[n])) return !1;
|
|
2426
2894
|
if (t.filters.length !== e.filters.length) return !1;
|
|
2427
2895
|
for (let s = 0; s < t.filters.length; s++) if (n = t.filters[s], r = e.filters[s],
|
|
2428
|
-
n.op !== r.op || !n.field.isEqual(r.field) || !
|
|
2896
|
+
n.op !== r.op || !n.field.isEqual(r.field) || !Lt(n.value, r.value)) return !1;
|
|
2429
2897
|
var n, r;
|
|
2430
|
-
return t.collectionGroup === e.collectionGroup && !!t.path.isEqual(e.path) && !!
|
|
2431
|
-
}(
|
|
2898
|
+
return t.collectionGroup === e.collectionGroup && !!t.path.isEqual(e.path) && !!le(t.startAt, e.startAt) && le(t.endAt, e.endAt);
|
|
2899
|
+
}(ye(t), ye(e)) && t.limitType === e.limitType;
|
|
2432
2900
|
}
|
|
2433
2901
|
|
|
2434
2902
|
/**
|
|
@@ -2456,7 +2924,7 @@ function de(t, e) {
|
|
|
2456
2924
|
* The return value is an IntegerValue if it can safely represent the value,
|
|
2457
2925
|
* otherwise a DoubleValue is returned.
|
|
2458
2926
|
*/
|
|
2459
|
-
function
|
|
2927
|
+
function ge(t, e) {
|
|
2460
2928
|
return function(t) {
|
|
2461
2929
|
return "number" == typeof t && Number.isInteger(t) && !at(t) && t <= Number.MAX_SAFE_INTEGER && t >= Number.MIN_SAFE_INTEGER;
|
|
2462
2930
|
}(e) ?
|
|
@@ -2468,7 +2936,7 @@ function we(t, e) {
|
|
|
2468
2936
|
integerValue: "" + t
|
|
2469
2937
|
};
|
|
2470
2938
|
}(e) : function(t, e) {
|
|
2471
|
-
if (t.
|
|
2939
|
+
if (t.S) {
|
|
2472
2940
|
if (isNaN(e)) return {
|
|
2473
2941
|
doubleValue: "NaN"
|
|
2474
2942
|
};
|
|
@@ -2501,7 +2969,7 @@ function we(t, e) {
|
|
|
2501
2969
|
* See the License for the specific language governing permissions and
|
|
2502
2970
|
* limitations under the License.
|
|
2503
2971
|
*/
|
|
2504
|
-
/** Used to represent a field transform on a mutation. */ class
|
|
2972
|
+
/** Used to represent a field transform on a mutation. */ class ve {
|
|
2505
2973
|
constructor() {
|
|
2506
2974
|
// Make sure that the structural type of `TransformOperation` is unique.
|
|
2507
2975
|
// See https://github.com/microsoft/TypeScript/issues/5451
|
|
@@ -2509,15 +2977,15 @@ function we(t, e) {
|
|
|
2509
2977
|
}
|
|
2510
2978
|
}
|
|
2511
2979
|
|
|
2512
|
-
/** Transforms a value into a server-generated timestamp. */ class
|
|
2980
|
+
/** Transforms a value into a server-generated timestamp. */ class be extends ve {}
|
|
2513
2981
|
|
|
2514
|
-
/** Transforms an array value via a union operation. */ class
|
|
2982
|
+
/** Transforms an array value via a union operation. */ class Ee extends ve {
|
|
2515
2983
|
constructor(t) {
|
|
2516
2984
|
super(), this.elements = t;
|
|
2517
2985
|
}
|
|
2518
2986
|
}
|
|
2519
2987
|
|
|
2520
|
-
/** Transforms an array value via a remove operation. */ class
|
|
2988
|
+
/** Transforms an array value via a remove operation. */ class Te extends ve {
|
|
2521
2989
|
constructor(t) {
|
|
2522
2990
|
super(), this.elements = t;
|
|
2523
2991
|
}
|
|
@@ -2528,7 +2996,7 @@ function we(t, e) {
|
|
|
2528
2996
|
* transforms. Converts all field values to integers or doubles, but unlike the
|
|
2529
2997
|
* backend does not cap integer values at 2^63. Instead, JavaScript number
|
|
2530
2998
|
* arithmetic is used and precision loss can occur for values greater than 2^53.
|
|
2531
|
-
*/ class
|
|
2999
|
+
*/ class Ie extends ve {
|
|
2532
3000
|
constructor(t, e) {
|
|
2533
3001
|
super(), this.q = t, this.O = e;
|
|
2534
3002
|
}
|
|
@@ -2550,7 +3018,7 @@ function we(t, e) {
|
|
|
2550
3018
|
* See the License for the specific language governing permissions and
|
|
2551
3019
|
* limitations under the License.
|
|
2552
3020
|
*/
|
|
2553
|
-
/** A field path and the TransformOperation to perform upon it. */ class
|
|
3021
|
+
/** A field path and the TransformOperation to perform upon it. */ class Ae {
|
|
2554
3022
|
constructor(t, e) {
|
|
2555
3023
|
this.field = t, this.transform = e;
|
|
2556
3024
|
}
|
|
@@ -2560,18 +3028,18 @@ function we(t, e) {
|
|
|
2560
3028
|
* Encodes a precondition for a mutation. This follows the model that the
|
|
2561
3029
|
* backend accepts with the special case of an explicit "empty" precondition
|
|
2562
3030
|
* (meaning no precondition).
|
|
2563
|
-
*/ class
|
|
3031
|
+
*/ class Re {
|
|
2564
3032
|
constructor(t, e) {
|
|
2565
3033
|
this.updateTime = t, this.exists = e;
|
|
2566
3034
|
}
|
|
2567
3035
|
/** Creates a new empty Precondition. */ static none() {
|
|
2568
|
-
return new
|
|
3036
|
+
return new Re;
|
|
2569
3037
|
}
|
|
2570
3038
|
/** Creates a new Precondition with an exists flag. */ static exists(t) {
|
|
2571
|
-
return new
|
|
3039
|
+
return new Re(void 0, t);
|
|
2572
3040
|
}
|
|
2573
3041
|
/** Creates a new Precondition based on a version a document exists at. */ static updateTime(t) {
|
|
2574
|
-
return new
|
|
3042
|
+
return new Re(t);
|
|
2575
3043
|
}
|
|
2576
3044
|
/** Returns whether this Precondition is empty. */ get isNone() {
|
|
2577
3045
|
return void 0 === this.updateTime && void 0 === this.exists;
|
|
@@ -2624,16 +3092,19 @@ function we(t, e) {
|
|
|
2624
3092
|
* applyToLocalView() to implement the actual behavior of applying the mutation
|
|
2625
3093
|
* to some source document (see `setMutationApplyToRemoteDocument()` for an
|
|
2626
3094
|
* example).
|
|
2627
|
-
*/ class
|
|
3095
|
+
*/ class Pe {}
|
|
2628
3096
|
|
|
2629
3097
|
/**
|
|
2630
3098
|
* A mutation that creates or replaces the document at the given key with the
|
|
2631
3099
|
* object value contents.
|
|
2632
|
-
*/ class
|
|
3100
|
+
*/ class Ve extends Pe {
|
|
2633
3101
|
constructor(t, e, n, r = []) {
|
|
2634
3102
|
super(), this.key = t, this.value = e, this.precondition = n, this.fieldTransforms = r,
|
|
2635
3103
|
this.type = 0 /* Set */;
|
|
2636
3104
|
}
|
|
3105
|
+
getFieldMask() {
|
|
3106
|
+
return null;
|
|
3107
|
+
}
|
|
2637
3108
|
}
|
|
2638
3109
|
|
|
2639
3110
|
/**
|
|
@@ -2648,17 +3119,23 @@ function we(t, e) {
|
|
|
2648
3119
|
* is deleted.
|
|
2649
3120
|
* * When a field is not in the mask but is in the values, the values map is
|
|
2650
3121
|
* ignored.
|
|
2651
|
-
*/ class
|
|
3122
|
+
*/ class Ne extends Pe {
|
|
2652
3123
|
constructor(t, e, n, r, s = []) {
|
|
2653
3124
|
super(), this.key = t, this.data = e, this.fieldMask = n, this.precondition = r,
|
|
2654
3125
|
this.fieldTransforms = s, this.type = 1 /* Patch */;
|
|
2655
3126
|
}
|
|
3127
|
+
getFieldMask() {
|
|
3128
|
+
return this.fieldMask;
|
|
3129
|
+
}
|
|
2656
3130
|
}
|
|
2657
3131
|
|
|
2658
|
-
/** A mutation that deletes the document at the given key. */ class
|
|
3132
|
+
/** A mutation that deletes the document at the given key. */ class De extends Pe {
|
|
2659
3133
|
constructor(t, e) {
|
|
2660
3134
|
super(), this.key = t, this.precondition = e, this.type = 2 /* Delete */ , this.fieldTransforms = [];
|
|
2661
3135
|
}
|
|
3136
|
+
getFieldMask() {
|
|
3137
|
+
return null;
|
|
3138
|
+
}
|
|
2662
3139
|
}
|
|
2663
3140
|
|
|
2664
3141
|
/**
|
|
@@ -2667,10 +3144,13 @@ function we(t, e) {
|
|
|
2667
3144
|
*
|
|
2668
3145
|
* The `verify` operation is only used in Transactions, and this class serves
|
|
2669
3146
|
* primarily to facilitate serialization into protos.
|
|
2670
|
-
*/ class
|
|
3147
|
+
*/ class $e extends Pe {
|
|
2671
3148
|
constructor(t, e) {
|
|
2672
3149
|
super(), this.key = t, this.precondition = e, this.type = 3 /* Verify */ , this.fieldTransforms = [];
|
|
2673
3150
|
}
|
|
3151
|
+
getFieldMask() {
|
|
3152
|
+
return null;
|
|
3153
|
+
}
|
|
2674
3154
|
}
|
|
2675
3155
|
|
|
2676
3156
|
/**
|
|
@@ -2688,13 +3168,13 @@ function we(t, e) {
|
|
|
2688
3168
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2689
3169
|
* See the License for the specific language governing permissions and
|
|
2690
3170
|
* limitations under the License.
|
|
2691
|
-
*/ const
|
|
3171
|
+
*/ const xe = (() => {
|
|
2692
3172
|
const t = {
|
|
2693
3173
|
asc: "ASCENDING",
|
|
2694
3174
|
desc: "DESCENDING"
|
|
2695
3175
|
};
|
|
2696
3176
|
return t;
|
|
2697
|
-
})(),
|
|
3177
|
+
})(), Fe = (() => {
|
|
2698
3178
|
const t = {
|
|
2699
3179
|
"<": "LESS_THAN",
|
|
2700
3180
|
"<=": "LESS_THAN_OR_EQUAL",
|
|
@@ -2724,9 +3204,9 @@ function we(t, e) {
|
|
|
2724
3204
|
* TODO(klimt): We can remove the databaseId argument if we keep the full
|
|
2725
3205
|
* resource name in documents.
|
|
2726
3206
|
*/
|
|
2727
|
-
class
|
|
3207
|
+
class Se {
|
|
2728
3208
|
constructor(t, e) {
|
|
2729
|
-
this.databaseId = t, this.
|
|
3209
|
+
this.databaseId = t, this.S = e;
|
|
2730
3210
|
}
|
|
2731
3211
|
}
|
|
2732
3212
|
|
|
@@ -2741,8 +3221,8 @@ class De {
|
|
|
2741
3221
|
/**
|
|
2742
3222
|
* Returns a value for a Date that's appropriate to put into a proto.
|
|
2743
3223
|
*/
|
|
2744
|
-
function
|
|
2745
|
-
if (t.
|
|
3224
|
+
function qe(t, e) {
|
|
3225
|
+
if (t.S) {
|
|
2746
3226
|
return `${new Date(1e3 * e.seconds).toISOString().replace(/\.\d*/, "").replace("Z", "")}.${("000000000" + e.nanoseconds).slice(-9)}Z`;
|
|
2747
3227
|
}
|
|
2748
3228
|
return {
|
|
@@ -2756,129 +3236,129 @@ function Ne(t, e) {
|
|
|
2756
3236
|
*
|
|
2757
3237
|
* Visible for testing.
|
|
2758
3238
|
*/
|
|
2759
|
-
function
|
|
2760
|
-
return t.
|
|
3239
|
+
function Oe(t, e) {
|
|
3240
|
+
return t.S ? e.toBase64() : e.toUint8Array();
|
|
2761
3241
|
}
|
|
2762
3242
|
|
|
2763
|
-
function
|
|
2764
|
-
return
|
|
3243
|
+
function ke(t, e) {
|
|
3244
|
+
return qe(t, e.toTimestamp());
|
|
2765
3245
|
}
|
|
2766
3246
|
|
|
2767
|
-
function
|
|
2768
|
-
return
|
|
2769
|
-
const e =
|
|
3247
|
+
function Ce(t) {
|
|
3248
|
+
return v(!!t), vt.fromTimestamp(function(t) {
|
|
3249
|
+
const e = $t(t);
|
|
2770
3250
|
return new gt(e.seconds, e.nanos);
|
|
2771
3251
|
}(t));
|
|
2772
3252
|
}
|
|
2773
3253
|
|
|
2774
|
-
function
|
|
3254
|
+
function Le(t, e) {
|
|
2775
3255
|
return function(t) {
|
|
2776
3256
|
return new X([ "projects", t.projectId, "databases", t.database ]);
|
|
2777
3257
|
}(t).child("documents").child(e).canonicalString();
|
|
2778
3258
|
}
|
|
2779
3259
|
|
|
2780
|
-
function
|
|
2781
|
-
return
|
|
3260
|
+
function Me(t, e) {
|
|
3261
|
+
return Le(t.databaseId, e.path);
|
|
2782
3262
|
}
|
|
2783
3263
|
|
|
2784
|
-
function
|
|
3264
|
+
function Ue(t, e) {
|
|
2785
3265
|
const n = function(t) {
|
|
2786
3266
|
const e = X.fromString(t);
|
|
2787
|
-
return
|
|
3267
|
+
return v(Xe(e)), e;
|
|
2788
3268
|
}(e);
|
|
2789
|
-
if (n.get(1) !== t.databaseId.projectId) throw new
|
|
2790
|
-
if (n.get(3) !== t.databaseId.database) throw new
|
|
2791
|
-
return new et((
|
|
3269
|
+
if (n.get(1) !== t.databaseId.projectId) throw new L(A, "Tried to deserialize key from different project: " + n.get(1) + " vs " + t.databaseId.projectId);
|
|
3270
|
+
if (n.get(3) !== t.databaseId.database) throw new L(A, "Tried to deserialize key from different database: " + n.get(3) + " vs " + t.databaseId.database);
|
|
3271
|
+
return new et((v((r = n).length > 4 && "documents" === r.get(4)), r.popFirst(5)));
|
|
2792
3272
|
var r;
|
|
2793
3273
|
/** Creates a Document proto from key and fields (but no create/update time) */}
|
|
2794
3274
|
|
|
2795
|
-
function
|
|
2796
|
-
return
|
|
3275
|
+
function je(t, e) {
|
|
3276
|
+
return Le(t.databaseId, e);
|
|
2797
3277
|
}
|
|
2798
3278
|
|
|
2799
|
-
function
|
|
3279
|
+
function Be(t) {
|
|
2800
3280
|
return new X([ "projects", t.databaseId.projectId, "databases", t.databaseId.database ]).canonicalString();
|
|
2801
3281
|
}
|
|
2802
3282
|
|
|
2803
|
-
function
|
|
3283
|
+
function ze(t, e, n) {
|
|
2804
3284
|
return {
|
|
2805
|
-
name:
|
|
3285
|
+
name: Me(t, e),
|
|
2806
3286
|
fields: n.value.mapValue.fields
|
|
2807
3287
|
};
|
|
2808
3288
|
}
|
|
2809
3289
|
|
|
2810
|
-
function
|
|
3290
|
+
function Ge(t, e) {
|
|
2811
3291
|
return "found" in e ? function(t, e) {
|
|
2812
|
-
|
|
2813
|
-
const n =
|
|
3292
|
+
v(!!e.found), e.found.name, e.found.updateTime;
|
|
3293
|
+
const n = Ue(t, e.found.name), r = Ce(e.found.updateTime), s = new Yt({
|
|
2814
3294
|
mapValue: {
|
|
2815
3295
|
fields: e.found.fields
|
|
2816
3296
|
}
|
|
2817
3297
|
});
|
|
2818
|
-
return
|
|
3298
|
+
return Ht.newFoundDocument(n, r, s);
|
|
2819
3299
|
}(t, e) : "missing" in e ? function(t, e) {
|
|
2820
|
-
|
|
2821
|
-
const n =
|
|
2822
|
-
return
|
|
3300
|
+
v(!!e.missing), v(!!e.readTime);
|
|
3301
|
+
const n = Ue(t, e.missing), r = Ce(e.readTime);
|
|
3302
|
+
return Ht.newNoDocument(n, r);
|
|
2823
3303
|
}(t, e) : g();
|
|
2824
3304
|
}
|
|
2825
3305
|
|
|
2826
|
-
function
|
|
3306
|
+
function We(t, e) {
|
|
2827
3307
|
let n;
|
|
2828
|
-
if (e instanceof
|
|
2829
|
-
update:
|
|
2830
|
-
}; else if (e instanceof
|
|
2831
|
-
delete:
|
|
2832
|
-
}; else if (e instanceof
|
|
2833
|
-
update:
|
|
2834
|
-
updateMask:
|
|
3308
|
+
if (e instanceof Ve) n = {
|
|
3309
|
+
update: ze(t, e.key, e.value)
|
|
3310
|
+
}; else if (e instanceof De) n = {
|
|
3311
|
+
delete: Me(t, e.key)
|
|
3312
|
+
}; else if (e instanceof Ne) n = {
|
|
3313
|
+
update: ze(t, e.key, e.data),
|
|
3314
|
+
updateMask: Je(e.fieldMask)
|
|
2835
3315
|
}; else {
|
|
2836
|
-
if (!(e instanceof
|
|
3316
|
+
if (!(e instanceof $e)) return g();
|
|
2837
3317
|
n = {
|
|
2838
|
-
verify:
|
|
3318
|
+
verify: Me(t, e.key)
|
|
2839
3319
|
};
|
|
2840
3320
|
}
|
|
2841
3321
|
return e.fieldTransforms.length > 0 && (n.updateTransforms = e.fieldTransforms.map((t => function(t, e) {
|
|
2842
3322
|
const n = e.transform;
|
|
2843
|
-
if (n instanceof
|
|
3323
|
+
if (n instanceof be) return {
|
|
2844
3324
|
fieldPath: e.field.canonicalString(),
|
|
2845
3325
|
setToServerValue: "REQUEST_TIME"
|
|
2846
3326
|
};
|
|
2847
|
-
if (n instanceof
|
|
3327
|
+
if (n instanceof Ee) return {
|
|
2848
3328
|
fieldPath: e.field.canonicalString(),
|
|
2849
3329
|
appendMissingElements: {
|
|
2850
3330
|
values: n.elements
|
|
2851
3331
|
}
|
|
2852
3332
|
};
|
|
2853
|
-
if (n instanceof
|
|
3333
|
+
if (n instanceof Te) return {
|
|
2854
3334
|
fieldPath: e.field.canonicalString(),
|
|
2855
3335
|
removeAllFromArray: {
|
|
2856
3336
|
values: n.elements
|
|
2857
3337
|
}
|
|
2858
3338
|
};
|
|
2859
|
-
if (n instanceof
|
|
3339
|
+
if (n instanceof Ie) return {
|
|
2860
3340
|
fieldPath: e.field.canonicalString(),
|
|
2861
3341
|
increment: n.O
|
|
2862
3342
|
};
|
|
2863
3343
|
throw g();
|
|
2864
3344
|
}(0, t)))), e.precondition.isNone || (n.currentDocument = function(t, e) {
|
|
2865
3345
|
return void 0 !== e.updateTime ? {
|
|
2866
|
-
updateTime:
|
|
3346
|
+
updateTime: ke(t, e.updateTime)
|
|
2867
3347
|
} : void 0 !== e.exists ? {
|
|
2868
3348
|
exists: e.exists
|
|
2869
3349
|
} : g();
|
|
2870
3350
|
}(t, e.precondition)), n;
|
|
2871
3351
|
}
|
|
2872
3352
|
|
|
2873
|
-
function
|
|
3353
|
+
function Ke(t, e) {
|
|
2874
3354
|
// Dissect the path into parent, collectionId, and optional key filter.
|
|
2875
3355
|
const n = {
|
|
2876
3356
|
structuredQuery: {}
|
|
2877
3357
|
}, r = e.path;
|
|
2878
|
-
null !== e.collectionGroup ? (n.parent =
|
|
3358
|
+
null !== e.collectionGroup ? (n.parent = je(t, r), n.structuredQuery.from = [ {
|
|
2879
3359
|
collectionId: e.collectionGroup,
|
|
2880
3360
|
allDescendants: !0
|
|
2881
|
-
} ]) : (n.parent =
|
|
3361
|
+
} ]) : (n.parent = je(t, r.popLast()), n.structuredQuery.from = [ {
|
|
2882
3362
|
collectionId: r.lastSegment()
|
|
2883
3363
|
} ]);
|
|
2884
3364
|
const s = function(t) {
|
|
@@ -2887,36 +3367,36 @@ function Me(t, e) {
|
|
|
2887
3367
|
// visible for testing
|
|
2888
3368
|
function(t) {
|
|
2889
3369
|
if ("==" /* EQUAL */ === t.op) {
|
|
2890
|
-
if (
|
|
3370
|
+
if (Wt(t.value)) return {
|
|
2891
3371
|
unaryFilter: {
|
|
2892
|
-
field:
|
|
3372
|
+
field: He(t.field),
|
|
2893
3373
|
op: "IS_NAN"
|
|
2894
3374
|
}
|
|
2895
3375
|
};
|
|
2896
|
-
if (
|
|
3376
|
+
if (Gt(t.value)) return {
|
|
2897
3377
|
unaryFilter: {
|
|
2898
|
-
field:
|
|
3378
|
+
field: He(t.field),
|
|
2899
3379
|
op: "IS_NULL"
|
|
2900
3380
|
}
|
|
2901
3381
|
};
|
|
2902
3382
|
} else if ("!=" /* NOT_EQUAL */ === t.op) {
|
|
2903
|
-
if (
|
|
3383
|
+
if (Wt(t.value)) return {
|
|
2904
3384
|
unaryFilter: {
|
|
2905
|
-
field:
|
|
3385
|
+
field: He(t.field),
|
|
2906
3386
|
op: "IS_NOT_NAN"
|
|
2907
3387
|
}
|
|
2908
3388
|
};
|
|
2909
|
-
if (
|
|
3389
|
+
if (Gt(t.value)) return {
|
|
2910
3390
|
unaryFilter: {
|
|
2911
|
-
field:
|
|
3391
|
+
field: He(t.field),
|
|
2912
3392
|
op: "IS_NOT_NULL"
|
|
2913
3393
|
}
|
|
2914
3394
|
};
|
|
2915
3395
|
}
|
|
2916
3396
|
return {
|
|
2917
3397
|
fieldFilter: {
|
|
2918
|
-
field:
|
|
2919
|
-
op:
|
|
3398
|
+
field: He(t.field),
|
|
3399
|
+
op: Ye(t.op),
|
|
2920
3400
|
value: t.value
|
|
2921
3401
|
}
|
|
2922
3402
|
};
|
|
@@ -2936,14 +3416,14 @@ function Me(t, e) {
|
|
|
2936
3416
|
// visible for testing
|
|
2937
3417
|
function(t) {
|
|
2938
3418
|
return {
|
|
2939
|
-
field:
|
|
2940
|
-
direction:
|
|
3419
|
+
field: He(t.field),
|
|
3420
|
+
direction: Qe(t.dir)
|
|
2941
3421
|
};
|
|
2942
3422
|
}(t)));
|
|
2943
3423
|
}(e.orderBy);
|
|
2944
3424
|
i && (n.structuredQuery.orderBy = i);
|
|
2945
3425
|
const o = function(t, e) {
|
|
2946
|
-
return t.
|
|
3426
|
+
return t.S || ct(e) ? e : {
|
|
2947
3427
|
value: e
|
|
2948
3428
|
};
|
|
2949
3429
|
}(t, e.limit);
|
|
@@ -2961,29 +3441,29 @@ function Me(t, e) {
|
|
|
2961
3441
|
(e.endAt)), n;
|
|
2962
3442
|
}
|
|
2963
3443
|
|
|
2964
|
-
function
|
|
2965
|
-
return
|
|
3444
|
+
function Qe(t) {
|
|
3445
|
+
return xe[t];
|
|
2966
3446
|
}
|
|
2967
3447
|
|
|
2968
3448
|
// visible for testing
|
|
2969
|
-
function
|
|
2970
|
-
return
|
|
3449
|
+
function Ye(t) {
|
|
3450
|
+
return Fe[t];
|
|
2971
3451
|
}
|
|
2972
3452
|
|
|
2973
|
-
function
|
|
3453
|
+
function He(t) {
|
|
2974
3454
|
return {
|
|
2975
3455
|
fieldPath: t.canonicalString()
|
|
2976
3456
|
};
|
|
2977
3457
|
}
|
|
2978
3458
|
|
|
2979
|
-
function
|
|
3459
|
+
function Je(t) {
|
|
2980
3460
|
const e = [];
|
|
2981
3461
|
return t.fields.forEach((t => e.push(t.canonicalString()))), {
|
|
2982
3462
|
fieldPaths: e
|
|
2983
3463
|
};
|
|
2984
3464
|
}
|
|
2985
3465
|
|
|
2986
|
-
function
|
|
3466
|
+
function Xe(t) {
|
|
2987
3467
|
// Resource names have at least 4 components (project ID, database ID)
|
|
2988
3468
|
return t.length >= 4 && "projects" === t.get(0) && "databases" === t.get(2);
|
|
2989
3469
|
}
|
|
@@ -3003,8 +3483,8 @@ function We(t) {
|
|
|
3003
3483
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3004
3484
|
* See the License for the specific language governing permissions and
|
|
3005
3485
|
* limitations under the License.
|
|
3006
|
-
*/ function
|
|
3007
|
-
return new
|
|
3486
|
+
*/ function Ze(t) {
|
|
3487
|
+
return new Se(t, /* useProto3Json= */ !0);
|
|
3008
3488
|
}
|
|
3009
3489
|
|
|
3010
3490
|
/**
|
|
@@ -3032,7 +3512,7 @@ function We(t) {
|
|
|
3032
3512
|
* base delay. This prevents clients from accidentally synchronizing their
|
|
3033
3513
|
* delays causing spikes of load to the backend.
|
|
3034
3514
|
*/
|
|
3035
|
-
class
|
|
3515
|
+
class tn {
|
|
3036
3516
|
constructor(
|
|
3037
3517
|
/**
|
|
3038
3518
|
* The AsyncQueue to run backoff operations on.
|
|
@@ -3057,7 +3537,7 @@ class He {
|
|
|
3057
3537
|
* Note that jitter will still be applied, so the actual delay could be as
|
|
3058
3538
|
* much as 1.5*maxDelayMs.
|
|
3059
3539
|
*/ , s = 6e4) {
|
|
3060
|
-
this.
|
|
3540
|
+
this.k = t, this.timerId = e, this.C = n, this.L = r, this.M = s, this.U = 0, this.j = null,
|
|
3061
3541
|
/** The last backoff attempt, as epoch milliseconds. */
|
|
3062
3542
|
this.B = Date.now(), this.reset();
|
|
3063
3543
|
}
|
|
@@ -3068,13 +3548,13 @@ class He {
|
|
|
3068
3548
|
* (i.e. due to an error), initialDelayMs (plus jitter) will be used, and
|
|
3069
3549
|
* subsequent ones will increase according to the backoffFactor.
|
|
3070
3550
|
*/ reset() {
|
|
3071
|
-
this.
|
|
3551
|
+
this.U = 0;
|
|
3072
3552
|
}
|
|
3073
3553
|
/**
|
|
3074
3554
|
* Resets the backoff delay to the maximum delay (e.g. for use after a
|
|
3075
3555
|
* RESOURCE_EXHAUSTED error).
|
|
3076
3556
|
*/ G() {
|
|
3077
|
-
this.
|
|
3557
|
+
this.U = this.M;
|
|
3078
3558
|
}
|
|
3079
3559
|
/**
|
|
3080
3560
|
* Returns a promise that resolves after currentDelayMs, and increases the
|
|
@@ -3085,23 +3565,23 @@ class He {
|
|
|
3085
3565
|
this.cancel();
|
|
3086
3566
|
// First schedule using the current base (which may be 0 and should be
|
|
3087
3567
|
// honored as such).
|
|
3088
|
-
const e = Math.floor(this.
|
|
3568
|
+
const e = Math.floor(this.U + this.K()), n = Math.max(0, Date.now() - this.B), r = Math.max(0, e - n);
|
|
3089
3569
|
// Guard against lastAttemptTime being in the future due to a clock change.
|
|
3090
|
-
r > 0 && m("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.
|
|
3091
|
-
this.
|
|
3570
|
+
r > 0 && m("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.U} ms, delay with jitter: ${e} ms, last attempt: ${n} ms ago)`),
|
|
3571
|
+
this.j = this.k.enqueueAfterDelay(this.timerId, r, (() => (this.B = Date.now(),
|
|
3092
3572
|
t()))),
|
|
3093
3573
|
// Apply backoff factor to determine next delay and ensure it is within
|
|
3094
3574
|
// bounds.
|
|
3095
|
-
this.
|
|
3575
|
+
this.U *= this.L, this.U < this.C && (this.U = this.C), this.U > this.M && (this.U = this.M);
|
|
3096
3576
|
}
|
|
3097
|
-
|
|
3098
|
-
null !== this.
|
|
3577
|
+
Y() {
|
|
3578
|
+
null !== this.j && (this.j.skipDelay(), this.j = null);
|
|
3099
3579
|
}
|
|
3100
3580
|
cancel() {
|
|
3101
|
-
null !== this.
|
|
3581
|
+
null !== this.j && (this.j.cancel(), this.j = null);
|
|
3102
3582
|
}
|
|
3103
|
-
/** Returns a random value in the range [-currentBaseMs/2, currentBaseMs/2] */
|
|
3104
|
-
return (Math.random() - .5) * this.
|
|
3583
|
+
/** Returns a random value in the range [-currentBaseMs/2, currentBaseMs/2] */ K() {
|
|
3584
|
+
return (Math.random() - .5) * this.U;
|
|
3105
3585
|
}
|
|
3106
3586
|
}
|
|
3107
3587
|
|
|
@@ -3130,24 +3610,24 @@ class He {
|
|
|
3130
3610
|
* An implementation of Datastore that exposes additional state for internal
|
|
3131
3611
|
* consumption.
|
|
3132
3612
|
*/
|
|
3133
|
-
class
|
|
3613
|
+
class en extends class {} {
|
|
3134
3614
|
constructor(t, e, n, r) {
|
|
3135
|
-
super(), this.authCredentials = t, this.appCheckCredentials = e, this.
|
|
3615
|
+
super(), this.authCredentials = t, this.appCheckCredentials = e, this.H = n, this.q = r,
|
|
3136
3616
|
this.J = !1;
|
|
3137
3617
|
}
|
|
3138
3618
|
X() {
|
|
3139
|
-
if (this.J) throw new
|
|
3619
|
+
if (this.J) throw new L(x, "The client has already been terminated.");
|
|
3140
3620
|
}
|
|
3141
3621
|
/** Invokes the provided RPC with auth and AppCheck tokens. */ m(t, e, n) {
|
|
3142
|
-
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.
|
|
3143
|
-
throw "FirebaseError" === t.name ? (t.code ===
|
|
3144
|
-
this.appCheckCredentials.invalidateToken()), t) : new
|
|
3622
|
+
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.H.m(t, e, n, r, s))).catch((t => {
|
|
3623
|
+
throw "FirebaseError" === t.name ? (t.code === D && (this.authCredentials.invalidateToken(),
|
|
3624
|
+
this.appCheckCredentials.invalidateToken()), t) : new L(I, t.toString());
|
|
3145
3625
|
}));
|
|
3146
3626
|
}
|
|
3147
3627
|
/** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */ T(t, e, n) {
|
|
3148
|
-
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.
|
|
3149
|
-
throw "FirebaseError" === t.name ? (t.code ===
|
|
3150
|
-
this.appCheckCredentials.invalidateToken()), t) : new
|
|
3628
|
+
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.H.T(t, e, n, r, s))).catch((t => {
|
|
3629
|
+
throw "FirebaseError" === t.name ? (t.code === D && (this.authCredentials.invalidateToken(),
|
|
3630
|
+
this.appCheckCredentials.invalidateToken()), t) : new L(I, t.toString());
|
|
3151
3631
|
}));
|
|
3152
3632
|
}
|
|
3153
3633
|
terminate() {
|
|
@@ -3157,38 +3637,38 @@ class Ke extends class {} {
|
|
|
3157
3637
|
|
|
3158
3638
|
// TODO(firestorexp): Make sure there is only one Datastore instance per
|
|
3159
3639
|
// firestore-exp client.
|
|
3160
|
-
async function
|
|
3161
|
-
const n =
|
|
3162
|
-
writes: e.map((t =>
|
|
3640
|
+
async function nn(t, e) {
|
|
3641
|
+
const n = b(t), r = Be(n.q) + "/documents", s = {
|
|
3642
|
+
writes: e.map((t => We(n.q, t)))
|
|
3163
3643
|
};
|
|
3164
3644
|
await n.m("Commit", r, s);
|
|
3165
3645
|
}
|
|
3166
3646
|
|
|
3167
|
-
async function
|
|
3168
|
-
const n =
|
|
3169
|
-
documents: e.map((t =>
|
|
3647
|
+
async function rn(t, e) {
|
|
3648
|
+
const n = b(t), r = Be(n.q) + "/documents", s = {
|
|
3649
|
+
documents: e.map((t => Me(n.q, t)))
|
|
3170
3650
|
}, i = await n.T("BatchGetDocuments", r, s), o = new Map;
|
|
3171
3651
|
i.forEach((t => {
|
|
3172
|
-
const e =
|
|
3652
|
+
const e = Ge(n.q, t);
|
|
3173
3653
|
o.set(e.key.toString(), e);
|
|
3174
3654
|
}));
|
|
3175
3655
|
const u = [];
|
|
3176
3656
|
return e.forEach((t => {
|
|
3177
3657
|
const e = o.get(t.toString());
|
|
3178
|
-
|
|
3658
|
+
v(!!e), u.push(e);
|
|
3179
3659
|
})), u;
|
|
3180
3660
|
}
|
|
3181
3661
|
|
|
3182
|
-
async function
|
|
3183
|
-
const n =
|
|
3662
|
+
async function sn(t, e) {
|
|
3663
|
+
const n = b(t), r = Ke(n.q, ye(e));
|
|
3184
3664
|
return (await n.T("RunQuery", r.parent, {
|
|
3185
3665
|
structuredQuery: r.structuredQuery
|
|
3186
3666
|
})).filter((t => !!t.document)).map((t => function(t, e, n) {
|
|
3187
|
-
const r =
|
|
3667
|
+
const r = Ue(t, e.name), s = Ce(e.updateTime), i = new Yt({
|
|
3188
3668
|
mapValue: {
|
|
3189
3669
|
fields: e.fields
|
|
3190
3670
|
}
|
|
3191
|
-
}), o =
|
|
3671
|
+
}), o = Ht.newFoundDocument(r, s, i);
|
|
3192
3672
|
return n && o.setHasCommittedMutations(), n ? o.setHasCommittedMutations() : o;
|
|
3193
3673
|
}(n.q, t.document, void 0)));
|
|
3194
3674
|
}
|
|
@@ -3208,7 +3688,7 @@ async function Ze(t, e) {
|
|
|
3208
3688
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3209
3689
|
* See the License for the specific language governing permissions and
|
|
3210
3690
|
* limitations under the License.
|
|
3211
|
-
*/ const
|
|
3691
|
+
*/ const on = new Map;
|
|
3212
3692
|
|
|
3213
3693
|
/**
|
|
3214
3694
|
* An instance map that ensures only one Datastore exists per Firestore
|
|
@@ -3219,17 +3699,17 @@ async function Ze(t, e) {
|
|
|
3219
3699
|
* instance. Callers must invoke removeComponents() when the Firestore
|
|
3220
3700
|
* instance is terminated.
|
|
3221
3701
|
*/
|
|
3222
|
-
function
|
|
3223
|
-
if (t._terminated) throw new
|
|
3224
|
-
if (!
|
|
3702
|
+
function un(t) {
|
|
3703
|
+
if (t._terminated) throw new L(x, "The client has already been terminated.");
|
|
3704
|
+
if (!on.has(t)) {
|
|
3225
3705
|
m("ComponentProvider", "Initializing Datastore");
|
|
3226
3706
|
const i = function(t) {
|
|
3227
3707
|
return new wt(t, fetch.bind(null));
|
|
3228
3708
|
}((e = t._databaseId, n = t.app.options.appId || "", r = t._persistenceKey, s = t._freezeSettings(),
|
|
3229
|
-
new
|
|
3230
|
-
return new
|
|
3709
|
+
new Y(e, n, r, s.host, s.ssl, s.experimentalForceLongPolling, s.experimentalAutoDetectLongPolling, s.useFetchStreams))), o = Ze(t._databaseId), u = function(t, e, n, r) {
|
|
3710
|
+
return new en(t, e, n, r);
|
|
3231
3711
|
}(t._authCredentials, t._appCheckCredentials, i, o);
|
|
3232
|
-
|
|
3712
|
+
on.set(t, u);
|
|
3233
3713
|
}
|
|
3234
3714
|
var e, n, r, s;
|
|
3235
3715
|
/**
|
|
@@ -3247,7 +3727,7 @@ function en(t) {
|
|
|
3247
3727
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3248
3728
|
* See the License for the specific language governing permissions and
|
|
3249
3729
|
* limitations under the License.
|
|
3250
|
-
*/ return
|
|
3730
|
+
*/ return on.get(t);
|
|
3251
3731
|
}
|
|
3252
3732
|
|
|
3253
3733
|
/**
|
|
@@ -3259,21 +3739,21 @@ function en(t) {
|
|
|
3259
3739
|
* user-supplied `FirestoreSettings` object. This is a separate type so that
|
|
3260
3740
|
* defaults can be supplied and the value can be checked for equality.
|
|
3261
3741
|
*/
|
|
3262
|
-
class
|
|
3742
|
+
class cn {
|
|
3263
3743
|
constructor(t) {
|
|
3264
3744
|
var e;
|
|
3265
3745
|
if (void 0 === t.host) {
|
|
3266
|
-
if (void 0 !== t.ssl) throw new
|
|
3746
|
+
if (void 0 !== t.ssl) throw new L(A, "Can't provide ssl option if host option is not set");
|
|
3267
3747
|
this.host = "firestore.googleapis.com", this.ssl = true;
|
|
3268
3748
|
} else this.host = t.host, this.ssl = null === (e = t.ssl) || void 0 === e || e;
|
|
3269
3749
|
if (this.credentials = t.credentials, this.ignoreUndefinedProperties = !!t.ignoreUndefinedProperties,
|
|
3270
3750
|
void 0 === t.cacheSizeBytes) this.cacheSizeBytes = 41943040; else {
|
|
3271
|
-
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new
|
|
3751
|
+
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new L(A, "cacheSizeBytes must be at least 1048576");
|
|
3272
3752
|
this.cacheSizeBytes = t.cacheSizeBytes;
|
|
3273
3753
|
}
|
|
3274
3754
|
this.experimentalForceLongPolling = !!t.experimentalForceLongPolling, this.experimentalAutoDetectLongPolling = !!t.experimentalAutoDetectLongPolling,
|
|
3275
3755
|
this.useFetchStreams = !!t.useFetchStreams, function(t, e, n, r) {
|
|
3276
|
-
if (!0 === e && !0 === r) throw new
|
|
3756
|
+
if (!0 === e && !0 === r) throw new L(A, `${t} and ${n} cannot be used together.`);
|
|
3277
3757
|
}("experimentalForceLongPolling", t.experimentalForceLongPolling, "experimentalAutoDetectLongPolling", t.experimentalAutoDetectLongPolling);
|
|
3278
3758
|
}
|
|
3279
3759
|
isEqual(t) {
|
|
@@ -3301,18 +3781,18 @@ class nn {
|
|
|
3301
3781
|
* The Cloud Firestore service interface.
|
|
3302
3782
|
*
|
|
3303
3783
|
* Do not call this constructor directly. Instead, use {@link getFirestore}.
|
|
3304
|
-
*/ class
|
|
3784
|
+
*/ class an {
|
|
3305
3785
|
/** @hideconstructor */
|
|
3306
3786
|
constructor(t, e, n) {
|
|
3307
3787
|
this._authCredentials = e, this._appCheckCredentials = n,
|
|
3308
3788
|
/**
|
|
3309
3789
|
* Whether it's a Firestore or Firestore Lite instance.
|
|
3310
3790
|
*/
|
|
3311
|
-
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new
|
|
3312
|
-
this._settingsFrozen = !1, t instanceof
|
|
3791
|
+
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new cn({}),
|
|
3792
|
+
this._settingsFrozen = !1, t instanceof H ? this._databaseId = t : (this._app = t,
|
|
3313
3793
|
this._databaseId = function(t) {
|
|
3314
|
-
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new
|
|
3315
|
-
return new
|
|
3794
|
+
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new L(A, '"projectId" not provided in firebase.initializeApp.');
|
|
3795
|
+
return new H(t.options.projectId);
|
|
3316
3796
|
}
|
|
3317
3797
|
/**
|
|
3318
3798
|
* Initializes a new instance of Cloud Firestore with the provided settings.
|
|
@@ -3330,7 +3810,7 @@ class nn {
|
|
|
3330
3810
|
* The {@link @firebase/app#FirebaseApp} associated with this `Firestore` service
|
|
3331
3811
|
* instance.
|
|
3332
3812
|
*/ get app() {
|
|
3333
|
-
if (!this._app) throw new
|
|
3813
|
+
if (!this._app) throw new L(x, "Firestore was not initialized using the Firebase SDK. 'app' is not available");
|
|
3334
3814
|
return this._app;
|
|
3335
3815
|
}
|
|
3336
3816
|
get _initialized() {
|
|
@@ -3340,21 +3820,21 @@ class nn {
|
|
|
3340
3820
|
return void 0 !== this._terminateTask;
|
|
3341
3821
|
}
|
|
3342
3822
|
_setSettings(t) {
|
|
3343
|
-
if (this._settingsFrozen) throw new
|
|
3344
|
-
this._settings = new
|
|
3345
|
-
if (!t) return new
|
|
3823
|
+
if (this._settingsFrozen) throw new L(x, "Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");
|
|
3824
|
+
this._settings = new cn(t), void 0 !== t.credentials && (this._authCredentials = function(t) {
|
|
3825
|
+
if (!t) return new j;
|
|
3346
3826
|
switch (t.type) {
|
|
3347
3827
|
case "gapi":
|
|
3348
3828
|
const e = t.client;
|
|
3349
3829
|
// Make sure this really is a Gapi client.
|
|
3350
|
-
return
|
|
3351
|
-
new
|
|
3830
|
+
return v(!("object" != typeof e || null === e || !e.auth || !e.auth.getAuthHeaderValueForFirstParty)),
|
|
3831
|
+
new W(e, t.sessionIndex || "0", t.iamToken || null);
|
|
3352
3832
|
|
|
3353
3833
|
case "provider":
|
|
3354
3834
|
return t.client;
|
|
3355
3835
|
|
|
3356
3836
|
default:
|
|
3357
|
-
throw new
|
|
3837
|
+
throw new L(A, "makeAuthCredentialsProvider failed due to invalid credential type");
|
|
3358
3838
|
}
|
|
3359
3839
|
}(t.credentials));
|
|
3360
3840
|
}
|
|
@@ -3382,15 +3862,15 @@ class nn {
|
|
|
3382
3862
|
* Only ever called once.
|
|
3383
3863
|
*/ _terminate() {
|
|
3384
3864
|
return function(t) {
|
|
3385
|
-
const e =
|
|
3386
|
-
e && (m("ComponentProvider", "Removing Datastore"),
|
|
3865
|
+
const e = on.get(t);
|
|
3866
|
+
e && (m("ComponentProvider", "Removing Datastore"), on.delete(t), e.terminate());
|
|
3387
3867
|
}(this), Promise.resolve();
|
|
3388
3868
|
}
|
|
3389
3869
|
}
|
|
3390
3870
|
|
|
3391
|
-
function
|
|
3871
|
+
function hn(t, e) {
|
|
3392
3872
|
const n = _getProvider(t, "firestore/lite");
|
|
3393
|
-
if (n.isInitialized()) throw new
|
|
3873
|
+
if (n.isInitialized()) throw new L(x, "Firestore can only be initialized once per app.");
|
|
3394
3874
|
return n.initialize({
|
|
3395
3875
|
options: e
|
|
3396
3876
|
});
|
|
@@ -3404,7 +3884,7 @@ function sn(t, e) {
|
|
|
3404
3884
|
* @param app - The {@link @firebase/app#FirebaseApp} instance that the returned `Firestore`
|
|
3405
3885
|
* instance is associated with.
|
|
3406
3886
|
* @returns The `Firestore` instance of the provided app.
|
|
3407
|
-
*/ function
|
|
3887
|
+
*/ function ln(e = getApp()) {
|
|
3408
3888
|
return _getProvider(e, "firestore/lite").getImmediate();
|
|
3409
3889
|
}
|
|
3410
3890
|
|
|
@@ -3420,9 +3900,9 @@ function sn(t, e) {
|
|
|
3420
3900
|
* @param port - the emulator port (ex: 9000).
|
|
3421
3901
|
* @param options.mockUserToken - the mock auth token to use for unit testing
|
|
3422
3902
|
* Security Rules.
|
|
3423
|
-
*/ function
|
|
3903
|
+
*/ function fn(t, e, n, r = {}) {
|
|
3424
3904
|
var s;
|
|
3425
|
-
const i = (t = ot(t,
|
|
3905
|
+
const i = (t = ot(t, an))._getSettings();
|
|
3426
3906
|
if ("firestore.googleapis.com" !== i.host && i.host !== e && y("Host has been set in both settings() and useEmulator(), emulator host will be used"),
|
|
3427
3907
|
t._setSettings(Object.assign(Object.assign({}, i), {
|
|
3428
3908
|
host: `${e}:${n}`,
|
|
@@ -3434,10 +3914,10 @@ function sn(t, e) {
|
|
|
3434
3914
|
// invalid field "uid" and missing field "sub" / "user_id".)
|
|
3435
3915
|
e = createMockUserToken(r.mockUserToken, null === (s = t._app) || void 0 === s ? void 0 : s.options.projectId);
|
|
3436
3916
|
const i = r.mockUserToken.sub || r.mockUserToken.user_id;
|
|
3437
|
-
if (!i) throw new
|
|
3917
|
+
if (!i) throw new L(A, "mockUserToken must contain 'sub' or 'user_id' field!");
|
|
3438
3918
|
n = new l(i);
|
|
3439
3919
|
}
|
|
3440
|
-
t._authCredentials = new B(new
|
|
3920
|
+
t._authCredentials = new B(new U(e, n));
|
|
3441
3921
|
}
|
|
3442
3922
|
}
|
|
3443
3923
|
|
|
@@ -3460,8 +3940,8 @@ function sn(t, e) {
|
|
|
3460
3940
|
* @param firestore - The `Firestore` instance to terminate.
|
|
3461
3941
|
* @returns A `Promise` that is resolved when the instance has been successfully
|
|
3462
3942
|
* terminated.
|
|
3463
|
-
*/ function
|
|
3464
|
-
return t = ot(t,
|
|
3943
|
+
*/ function dn(t) {
|
|
3944
|
+
return t = ot(t, an), _removeServiceInstance(t.app, "firestore/lite"), t._delete();
|
|
3465
3945
|
}
|
|
3466
3946
|
|
|
3467
3947
|
/**
|
|
@@ -3501,7 +3981,7 @@ function sn(t, e) {
|
|
|
3501
3981
|
* and can be used to write, read, or listen to the location. The document at
|
|
3502
3982
|
* the referenced location may or may not exist.
|
|
3503
3983
|
*/
|
|
3504
|
-
class
|
|
3984
|
+
class wn {
|
|
3505
3985
|
/** @hideconstructor */
|
|
3506
3986
|
constructor(t,
|
|
3507
3987
|
/**
|
|
@@ -3529,17 +4009,17 @@ class an {
|
|
|
3529
4009
|
/**
|
|
3530
4010
|
* The collection this `DocumentReference` belongs to.
|
|
3531
4011
|
*/ get parent() {
|
|
3532
|
-
return new
|
|
4012
|
+
return new pn(this.firestore, this.converter, this._key.path.popLast());
|
|
3533
4013
|
}
|
|
3534
4014
|
withConverter(t) {
|
|
3535
|
-
return new
|
|
4015
|
+
return new wn(this.firestore, t, this._key);
|
|
3536
4016
|
}
|
|
3537
4017
|
}
|
|
3538
4018
|
|
|
3539
4019
|
/**
|
|
3540
4020
|
* A `Query` refers to a query which you can read or listen to. You can also
|
|
3541
4021
|
* construct refined `Query` objects by adding filters and ordering.
|
|
3542
|
-
*/ class
|
|
4022
|
+
*/ class mn {
|
|
3543
4023
|
// This is the lite version of the Query class in the main SDK.
|
|
3544
4024
|
/** @hideconstructor protected */
|
|
3545
4025
|
constructor(t,
|
|
@@ -3552,17 +4032,17 @@ class an {
|
|
|
3552
4032
|
this.type = "query", this.firestore = t;
|
|
3553
4033
|
}
|
|
3554
4034
|
withConverter(t) {
|
|
3555
|
-
return new
|
|
4035
|
+
return new mn(this.firestore, t, this._query);
|
|
3556
4036
|
}
|
|
3557
4037
|
}
|
|
3558
4038
|
|
|
3559
4039
|
/**
|
|
3560
4040
|
* A `CollectionReference` object can be used for adding documents, getting
|
|
3561
4041
|
* document references, and querying for documents (using {@link query}).
|
|
3562
|
-
*/ class
|
|
4042
|
+
*/ class pn extends mn {
|
|
3563
4043
|
/** @hideconstructor */
|
|
3564
4044
|
constructor(t, e, n) {
|
|
3565
|
-
super(t, e, new
|
|
4045
|
+
super(t, e, new fe(n)), this._path = n,
|
|
3566
4046
|
/** The type of this Firestore reference. */
|
|
3567
4047
|
this.type = "collection";
|
|
3568
4048
|
}
|
|
@@ -3580,23 +4060,23 @@ class an {
|
|
|
3580
4060
|
* subcollection. If this isn't a subcollection, the reference is null.
|
|
3581
4061
|
*/ get parent() {
|
|
3582
4062
|
const t = this._path.popLast();
|
|
3583
|
-
return t.isEmpty() ? null : new
|
|
4063
|
+
return t.isEmpty() ? null : new wn(this.firestore,
|
|
3584
4064
|
/* converter= */ null, new et(t));
|
|
3585
4065
|
}
|
|
3586
4066
|
withConverter(t) {
|
|
3587
|
-
return new
|
|
4067
|
+
return new pn(this.firestore, t, this._path);
|
|
3588
4068
|
}
|
|
3589
4069
|
}
|
|
3590
4070
|
|
|
3591
|
-
function
|
|
3592
|
-
if (t = getModularInstance(t), nt("collection", "path", e), t instanceof
|
|
4071
|
+
function yn(t, e, ...n) {
|
|
4072
|
+
if (t = getModularInstance(t), nt("collection", "path", e), t instanceof an) {
|
|
3593
4073
|
const r = X.fromString(e, ...n);
|
|
3594
|
-
return st(r), new
|
|
4074
|
+
return st(r), new pn(t, /* converter= */ null, r);
|
|
3595
4075
|
}
|
|
3596
4076
|
{
|
|
3597
|
-
if (!(t instanceof
|
|
4077
|
+
if (!(t instanceof wn || t instanceof pn)) throw new L(A, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3598
4078
|
const r = t._path.child(X.fromString(e, ...n));
|
|
3599
|
-
return st(r), new
|
|
4079
|
+
return st(r), new pn(t.firestore,
|
|
3600
4080
|
/* converter= */ null, r);
|
|
3601
4081
|
}
|
|
3602
4082
|
}
|
|
@@ -3613,32 +4093,32 @@ function fn(t, e, ...n) {
|
|
|
3613
4093
|
* collection or subcollection with this ID as the last segment of its path
|
|
3614
4094
|
* will be included. Cannot contain a slash.
|
|
3615
4095
|
* @returns The created `Query`.
|
|
3616
|
-
*/ function
|
|
3617
|
-
if (t = ot(t,
|
|
3618
|
-
return new
|
|
4096
|
+
*/ function _n(t, e) {
|
|
4097
|
+
if (t = ot(t, an), nt("collectionGroup", "collection id", e), e.indexOf("/") >= 0) throw new L(A, `Invalid collection ID '${e}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);
|
|
4098
|
+
return new mn(t,
|
|
3619
4099
|
/* converter= */ null,
|
|
3620
4100
|
/**
|
|
3621
4101
|
* Creates a new Query for a collection group query that matches all documents
|
|
3622
4102
|
* within the provided collection group.
|
|
3623
4103
|
*/
|
|
3624
4104
|
function(t) {
|
|
3625
|
-
return new
|
|
4105
|
+
return new fe(X.emptyPath(), t);
|
|
3626
4106
|
}(e));
|
|
3627
4107
|
}
|
|
3628
4108
|
|
|
3629
|
-
function
|
|
4109
|
+
function gn(t, e, ...n) {
|
|
3630
4110
|
if (t = getModularInstance(t),
|
|
3631
4111
|
// We allow omission of 'pathString' but explicitly prohibit passing in both
|
|
3632
4112
|
// 'undefined' and 'null'.
|
|
3633
|
-
1 === arguments.length && (e = pt.R()), nt("doc", "path", e), t instanceof
|
|
4113
|
+
1 === arguments.length && (e = pt.R()), nt("doc", "path", e), t instanceof an) {
|
|
3634
4114
|
const r = X.fromString(e, ...n);
|
|
3635
|
-
return rt(r), new
|
|
4115
|
+
return rt(r), new wn(t,
|
|
3636
4116
|
/* converter= */ null, new et(r));
|
|
3637
4117
|
}
|
|
3638
4118
|
{
|
|
3639
|
-
if (!(t instanceof
|
|
4119
|
+
if (!(t instanceof wn || t instanceof pn)) throw new L(A, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3640
4120
|
const r = t._path.child(X.fromString(e, ...n));
|
|
3641
|
-
return rt(r), new
|
|
4121
|
+
return rt(r), new wn(t.firestore, t instanceof pn ? t.converter : null, new et(r));
|
|
3642
4122
|
}
|
|
3643
4123
|
}
|
|
3644
4124
|
|
|
@@ -3649,8 +4129,8 @@ function wn(t, e, ...n) {
|
|
|
3649
4129
|
* @param right - A reference to compare.
|
|
3650
4130
|
* @returns true if the references point to the same location in the same
|
|
3651
4131
|
* Firestore database.
|
|
3652
|
-
*/ function
|
|
3653
|
-
return t = getModularInstance(t), e = getModularInstance(e), (t instanceof
|
|
4132
|
+
*/ function vn(t, e) {
|
|
4133
|
+
return t = getModularInstance(t), e = getModularInstance(e), (t instanceof wn || t instanceof pn) && (e instanceof wn || e instanceof pn) && (t.firestore === e.firestore && t.path === e.path && t.converter === e.converter);
|
|
3654
4134
|
}
|
|
3655
4135
|
|
|
3656
4136
|
/**
|
|
@@ -3661,8 +4141,8 @@ function wn(t, e, ...n) {
|
|
|
3661
4141
|
* @param right - A `Query` to compare.
|
|
3662
4142
|
* @returns true if the references point to the same location in the same
|
|
3663
4143
|
* Firestore database.
|
|
3664
|
-
*/ function
|
|
3665
|
-
return t = getModularInstance(t), e = getModularInstance(e), t instanceof
|
|
4144
|
+
*/ function bn(t, e) {
|
|
4145
|
+
return t = getModularInstance(t), e = getModularInstance(e), t instanceof mn && e instanceof mn && (t.firestore === e.firestore && _e(t._query, e._query) && t.converter === e.converter);
|
|
3666
4146
|
}
|
|
3667
4147
|
|
|
3668
4148
|
/**
|
|
@@ -3688,7 +4168,7 @@ function wn(t, e, ...n) {
|
|
|
3688
4168
|
*
|
|
3689
4169
|
* Create a `FieldPath` by providing field names. If more than one field
|
|
3690
4170
|
* name is provided, the path will point to a nested field in a document.
|
|
3691
|
-
*/ class
|
|
4171
|
+
*/ class En {
|
|
3692
4172
|
/**
|
|
3693
4173
|
* Creates a `FieldPath` from the provided field names. If more than one field
|
|
3694
4174
|
* name is provided, the path will point to a nested field in a document.
|
|
@@ -3696,7 +4176,7 @@ function wn(t, e, ...n) {
|
|
|
3696
4176
|
* @param fieldNames - A list of field names.
|
|
3697
4177
|
*/
|
|
3698
4178
|
constructor(...t) {
|
|
3699
|
-
for (let e = 0; e < t.length; ++e) if (0 === t[e].length) throw new
|
|
4179
|
+
for (let e = 0; e < t.length; ++e) if (0 === t[e].length) throw new L(A, "Invalid field name at argument $(i + 1). Field names must not be empty.");
|
|
3700
4180
|
this._internalPath = new tt(t);
|
|
3701
4181
|
}
|
|
3702
4182
|
/**
|
|
@@ -3712,8 +4192,8 @@ function wn(t, e, ...n) {
|
|
|
3712
4192
|
/**
|
|
3713
4193
|
* Returns a special sentinel `FieldPath` to refer to the ID of a document.
|
|
3714
4194
|
* It can be used in queries to sort or filter by the document ID.
|
|
3715
|
-
*/ function
|
|
3716
|
-
return new
|
|
4195
|
+
*/ function Tn() {
|
|
4196
|
+
return new En("__name__");
|
|
3717
4197
|
}
|
|
3718
4198
|
|
|
3719
4199
|
/**
|
|
@@ -3734,7 +4214,7 @@ function wn(t, e, ...n) {
|
|
|
3734
4214
|
*/
|
|
3735
4215
|
/**
|
|
3736
4216
|
* An immutable object representing an array of bytes.
|
|
3737
|
-
*/ class
|
|
4217
|
+
*/ class In {
|
|
3738
4218
|
/** @hideconstructor */
|
|
3739
4219
|
constructor(t) {
|
|
3740
4220
|
this._byteString = t;
|
|
@@ -3746,9 +4226,9 @@ function wn(t, e, ...n) {
|
|
|
3746
4226
|
* @param base64 - The Base64 string used to create the `Bytes` object.
|
|
3747
4227
|
*/ static fromBase64String(t) {
|
|
3748
4228
|
try {
|
|
3749
|
-
return new
|
|
4229
|
+
return new In(Nt.fromBase64String(t));
|
|
3750
4230
|
} catch (t) {
|
|
3751
|
-
throw new
|
|
4231
|
+
throw new L(A, "Failed to construct data from Base64 string: " + t);
|
|
3752
4232
|
}
|
|
3753
4233
|
}
|
|
3754
4234
|
/**
|
|
@@ -3756,7 +4236,7 @@ function wn(t, e, ...n) {
|
|
|
3756
4236
|
*
|
|
3757
4237
|
* @param array - The Uint8Array used to create the `Bytes` object.
|
|
3758
4238
|
*/ static fromUint8Array(t) {
|
|
3759
|
-
return new
|
|
4239
|
+
return new In(Nt.fromUint8Array(t));
|
|
3760
4240
|
}
|
|
3761
4241
|
/**
|
|
3762
4242
|
* Returns the underlying bytes as a Base64-encoded string.
|
|
@@ -3808,7 +4288,7 @@ function wn(t, e, ...n) {
|
|
|
3808
4288
|
/**
|
|
3809
4289
|
* Sentinel values that can be used when writing document fields with `set()`
|
|
3810
4290
|
* or `update()`.
|
|
3811
|
-
*/ class
|
|
4291
|
+
*/ class An {
|
|
3812
4292
|
/**
|
|
3813
4293
|
* @param _methodName - The public API endpoint that returns this class.
|
|
3814
4294
|
* @hideconstructor
|
|
@@ -3840,7 +4320,7 @@ function wn(t, e, ...n) {
|
|
|
3840
4320
|
*
|
|
3841
4321
|
* Latitude values are in the range of [-90, 90].
|
|
3842
4322
|
* Longitude values are in the range of [-180, 180].
|
|
3843
|
-
*/ class
|
|
4323
|
+
*/ class Rn {
|
|
3844
4324
|
/**
|
|
3845
4325
|
* Creates a new immutable `GeoPoint` object with the provided latitude and
|
|
3846
4326
|
* longitude values.
|
|
@@ -3848,8 +4328,8 @@ function wn(t, e, ...n) {
|
|
|
3848
4328
|
* @param longitude - The longitude as number between -180 and 180.
|
|
3849
4329
|
*/
|
|
3850
4330
|
constructor(t, e) {
|
|
3851
|
-
if (!isFinite(t) || t < -90 || t > 90) throw new
|
|
3852
|
-
if (!isFinite(e) || e < -180 || e > 180) throw new
|
|
4331
|
+
if (!isFinite(t) || t < -90 || t > 90) throw new L(A, "Latitude must be a number between -90 and 90, but was: " + t);
|
|
4332
|
+
if (!isFinite(e) || e < -180 || e > 180) throw new L(A, "Longitude must be a number between -180 and 180, but was: " + e);
|
|
3853
4333
|
this._lat = t, this._long = e;
|
|
3854
4334
|
}
|
|
3855
4335
|
/**
|
|
@@ -3899,29 +4379,29 @@ function wn(t, e, ...n) {
|
|
|
3899
4379
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3900
4380
|
* See the License for the specific language governing permissions and
|
|
3901
4381
|
* limitations under the License.
|
|
3902
|
-
*/ const
|
|
4382
|
+
*/ const Pn = /^__.*__$/;
|
|
3903
4383
|
|
|
3904
|
-
/** The result of parsing document data (e.g. for a setData call). */ class
|
|
4384
|
+
/** The result of parsing document data (e.g. for a setData call). */ class Vn {
|
|
3905
4385
|
constructor(t, e, n) {
|
|
3906
4386
|
this.data = t, this.fieldMask = e, this.fieldTransforms = n;
|
|
3907
4387
|
}
|
|
3908
4388
|
toMutation(t, e) {
|
|
3909
|
-
return null !== this.fieldMask ? new
|
|
4389
|
+
return null !== this.fieldMask ? new Ne(t, this.data, this.fieldMask, e, this.fieldTransforms) : new Ve(t, this.data, e, this.fieldTransforms);
|
|
3910
4390
|
}
|
|
3911
4391
|
}
|
|
3912
4392
|
|
|
3913
|
-
/** The result of parsing "update" data (i.e. for an updateData call). */ class
|
|
4393
|
+
/** The result of parsing "update" data (i.e. for an updateData call). */ class Nn {
|
|
3914
4394
|
constructor(t,
|
|
3915
4395
|
// The fieldMask does not include document transforms.
|
|
3916
4396
|
e, n) {
|
|
3917
4397
|
this.data = t, this.fieldMask = e, this.fieldTransforms = n;
|
|
3918
4398
|
}
|
|
3919
4399
|
toMutation(t, e) {
|
|
3920
|
-
return new
|
|
4400
|
+
return new Ne(t, this.data, this.fieldMask, e, this.fieldTransforms);
|
|
3921
4401
|
}
|
|
3922
4402
|
}
|
|
3923
4403
|
|
|
3924
|
-
function
|
|
4404
|
+
function Dn(t) {
|
|
3925
4405
|
switch (t) {
|
|
3926
4406
|
case 0 /* Set */ :
|
|
3927
4407
|
// fall through
|
|
@@ -3939,7 +4419,7 @@ function In(t) {
|
|
|
3939
4419
|
}
|
|
3940
4420
|
}
|
|
3941
4421
|
|
|
3942
|
-
/** A "context" object passed around while parsing user data. */ class
|
|
4422
|
+
/** A "context" object passed around while parsing user data. */ class $n {
|
|
3943
4423
|
/**
|
|
3944
4424
|
* Initializes a ParseContext with the given source and path.
|
|
3945
4425
|
*
|
|
@@ -3971,7 +4451,7 @@ function In(t) {
|
|
|
3971
4451
|
return this.settings.tt;
|
|
3972
4452
|
}
|
|
3973
4453
|
/** Returns a new context with the specified settings overwritten. */ et(t) {
|
|
3974
|
-
return new
|
|
4454
|
+
return new $n(Object.assign(Object.assign({}, this.settings), t), this.databaseId, this.q, this.ignoreUndefinedProperties, this.fieldTransforms, this.fieldMask);
|
|
3975
4455
|
}
|
|
3976
4456
|
nt(t) {
|
|
3977
4457
|
var e;
|
|
@@ -3998,7 +4478,7 @@ function In(t) {
|
|
|
3998
4478
|
});
|
|
3999
4479
|
}
|
|
4000
4480
|
ut(t) {
|
|
4001
|
-
return
|
|
4481
|
+
return Jn(t, this.settings.methodName, this.settings.ct || !1, this.path, this.settings.at);
|
|
4002
4482
|
}
|
|
4003
4483
|
/** Returns 'true' if 'fieldPath' was traversed when creating this context. */ contains(t) {
|
|
4004
4484
|
return void 0 !== this.fieldMask.find((e => t.isPrefixOf(e))) || void 0 !== this.fieldTransforms.find((e => t.isPrefixOf(e.field)));
|
|
@@ -4010,19 +4490,19 @@ function In(t) {
|
|
|
4010
4490
|
}
|
|
4011
4491
|
st(t) {
|
|
4012
4492
|
if (0 === t.length) throw this.ut("Document fields must not be empty");
|
|
4013
|
-
if (
|
|
4493
|
+
if (Dn(this.tt) && Pn.test(t)) throw this.ut('Document fields cannot begin and end with "__"');
|
|
4014
4494
|
}
|
|
4015
4495
|
}
|
|
4016
4496
|
|
|
4017
4497
|
/**
|
|
4018
4498
|
* Helper for parsing raw user input (provided via the API) into internal model
|
|
4019
4499
|
* classes.
|
|
4020
|
-
*/ class
|
|
4500
|
+
*/ class xn {
|
|
4021
4501
|
constructor(t, e, n) {
|
|
4022
|
-
this.databaseId = t, this.ignoreUndefinedProperties = e, this.q = n ||
|
|
4502
|
+
this.databaseId = t, this.ignoreUndefinedProperties = e, this.q = n || Ze(t);
|
|
4023
4503
|
}
|
|
4024
4504
|
/** Creates a new top-level parse context. */ ht(t, e, n, r = !1) {
|
|
4025
|
-
return new
|
|
4505
|
+
return new $n({
|
|
4026
4506
|
tt: t,
|
|
4027
4507
|
methodName: e,
|
|
4028
4508
|
at: n,
|
|
@@ -4033,29 +4513,29 @@ function In(t) {
|
|
|
4033
4513
|
}
|
|
4034
4514
|
}
|
|
4035
4515
|
|
|
4036
|
-
function
|
|
4037
|
-
const e = t._freezeSettings(), n =
|
|
4038
|
-
return new
|
|
4516
|
+
function Fn(t) {
|
|
4517
|
+
const e = t._freezeSettings(), n = Ze(t._databaseId);
|
|
4518
|
+
return new xn(t._databaseId, !!e.ignoreUndefinedProperties, n);
|
|
4039
4519
|
}
|
|
4040
4520
|
|
|
4041
|
-
/** Parse document data from a set() call. */ function
|
|
4521
|
+
/** Parse document data from a set() call. */ function Sn(t, e, n, r, s, i = {}) {
|
|
4042
4522
|
const o = t.ht(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ , e, n, s);
|
|
4043
|
-
|
|
4044
|
-
const u =
|
|
4523
|
+
Kn("Data must be an object, but it was:", o, r);
|
|
4524
|
+
const u = Gn(r, o);
|
|
4045
4525
|
let c, a;
|
|
4046
|
-
if (i.merge) c = new
|
|
4526
|
+
if (i.merge) c = new Vt(o.fieldMask), a = o.fieldTransforms; else if (i.mergeFields) {
|
|
4047
4527
|
const t = [];
|
|
4048
4528
|
for (const r of i.mergeFields) {
|
|
4049
|
-
const s =
|
|
4050
|
-
if (!o.contains(s)) throw new
|
|
4051
|
-
|
|
4529
|
+
const s = Qn(e, r, n);
|
|
4530
|
+
if (!o.contains(s)) throw new L(A, `Field '${s}' is specified in your field mask but missing from your input data.`);
|
|
4531
|
+
Xn(t, s) || t.push(s);
|
|
4052
4532
|
}
|
|
4053
|
-
c = new
|
|
4533
|
+
c = new Vt(t), a = o.fieldTransforms.filter((t => c.covers(t.field)));
|
|
4054
4534
|
} else c = null, a = o.fieldTransforms;
|
|
4055
|
-
return new
|
|
4535
|
+
return new Vn(new Yt(u), c, a);
|
|
4056
4536
|
}
|
|
4057
4537
|
|
|
4058
|
-
class
|
|
4538
|
+
class qn extends An {
|
|
4059
4539
|
_toFieldTransform(t) {
|
|
4060
4540
|
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}`);
|
|
4061
4541
|
// No transform to add for a delete, but we need to add it to our
|
|
@@ -4063,7 +4543,7 @@ class Nn extends bn {
|
|
|
4063
4543
|
return t.fieldMask.push(t.path), null;
|
|
4064
4544
|
}
|
|
4065
4545
|
isEqual(t) {
|
|
4066
|
-
return t instanceof
|
|
4546
|
+
return t instanceof qn;
|
|
4067
4547
|
}
|
|
4068
4548
|
}
|
|
4069
4549
|
|
|
@@ -4082,8 +4562,8 @@ class Nn extends bn {
|
|
|
4082
4562
|
* context.
|
|
4083
4563
|
* @param context - The parent context.
|
|
4084
4564
|
* @param arrayElement - Whether or not the FieldValue has an array.
|
|
4085
|
-
*/ function
|
|
4086
|
-
return new
|
|
4565
|
+
*/ function On(t, e, n) {
|
|
4566
|
+
return new $n({
|
|
4087
4567
|
tt: 3 /* Argument */ ,
|
|
4088
4568
|
at: e.settings.at,
|
|
4089
4569
|
methodName: t._methodName,
|
|
@@ -4091,23 +4571,23 @@ class Nn extends bn {
|
|
|
4091
4571
|
}, e.databaseId, e.q, e.ignoreUndefinedProperties);
|
|
4092
4572
|
}
|
|
4093
4573
|
|
|
4094
|
-
class
|
|
4574
|
+
class kn extends An {
|
|
4095
4575
|
_toFieldTransform(t) {
|
|
4096
|
-
return new
|
|
4576
|
+
return new Ae(t.path, new be);
|
|
4097
4577
|
}
|
|
4098
4578
|
isEqual(t) {
|
|
4099
|
-
return t instanceof
|
|
4579
|
+
return t instanceof kn;
|
|
4100
4580
|
}
|
|
4101
4581
|
}
|
|
4102
4582
|
|
|
4103
|
-
class
|
|
4583
|
+
class Cn extends An {
|
|
4104
4584
|
constructor(t, e) {
|
|
4105
4585
|
super(t), this.lt = e;
|
|
4106
4586
|
}
|
|
4107
4587
|
_toFieldTransform(t) {
|
|
4108
|
-
const e =
|
|
4109
|
-
/*array=*/ !0), n = this.lt.map((t =>
|
|
4110
|
-
return new
|
|
4588
|
+
const e = On(this, t,
|
|
4589
|
+
/*array=*/ !0), n = this.lt.map((t => zn(t, e))), r = new Ee(n);
|
|
4590
|
+
return new Ae(t.path, r);
|
|
4111
4591
|
}
|
|
4112
4592
|
isEqual(t) {
|
|
4113
4593
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4115,14 +4595,14 @@ class xn extends bn {
|
|
|
4115
4595
|
}
|
|
4116
4596
|
}
|
|
4117
4597
|
|
|
4118
|
-
class
|
|
4598
|
+
class Ln extends An {
|
|
4119
4599
|
constructor(t, e) {
|
|
4120
4600
|
super(t), this.lt = e;
|
|
4121
4601
|
}
|
|
4122
4602
|
_toFieldTransform(t) {
|
|
4123
|
-
const e =
|
|
4124
|
-
/*array=*/ !0), n = this.lt.map((t =>
|
|
4125
|
-
return new
|
|
4603
|
+
const e = On(this, t,
|
|
4604
|
+
/*array=*/ !0), n = this.lt.map((t => zn(t, e))), r = new Te(n);
|
|
4605
|
+
return new Ae(t.path, r);
|
|
4126
4606
|
}
|
|
4127
4607
|
isEqual(t) {
|
|
4128
4608
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4130,13 +4610,13 @@ class Fn extends bn {
|
|
|
4130
4610
|
}
|
|
4131
4611
|
}
|
|
4132
4612
|
|
|
4133
|
-
class
|
|
4613
|
+
class Mn extends An {
|
|
4134
4614
|
constructor(t, e) {
|
|
4135
4615
|
super(t), this.ft = e;
|
|
4136
4616
|
}
|
|
4137
4617
|
_toFieldTransform(t) {
|
|
4138
|
-
const e = new
|
|
4139
|
-
return new
|
|
4618
|
+
const e = new Ie(t.q, ge(t.q, this.ft));
|
|
4619
|
+
return new Ae(t.path, e);
|
|
4140
4620
|
}
|
|
4141
4621
|
isEqual(t) {
|
|
4142
4622
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4144,50 +4624,50 @@ class qn extends bn {
|
|
|
4144
4624
|
}
|
|
4145
4625
|
}
|
|
4146
4626
|
|
|
4147
|
-
/** Parse update data from an update() call. */ function
|
|
4627
|
+
/** Parse update data from an update() call. */ function Un(t, e, n, r) {
|
|
4148
4628
|
const s = t.ht(1 /* Update */ , e, n);
|
|
4149
|
-
|
|
4150
|
-
const i = [], o =
|
|
4629
|
+
Kn("Data must be an object, but it was:", s, r);
|
|
4630
|
+
const i = [], o = Yt.empty();
|
|
4151
4631
|
Et(r, ((t, r) => {
|
|
4152
|
-
const u =
|
|
4632
|
+
const u = Hn(e, t, n);
|
|
4153
4633
|
// For Compat types, we have to "extract" the underlying types before
|
|
4154
4634
|
// performing validation.
|
|
4155
4635
|
r = getModularInstance(r);
|
|
4156
4636
|
const c = s.it(u);
|
|
4157
|
-
if (r instanceof
|
|
4637
|
+
if (r instanceof qn)
|
|
4158
4638
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4159
4639
|
i.push(u); else {
|
|
4160
|
-
const t =
|
|
4640
|
+
const t = zn(r, c);
|
|
4161
4641
|
null != t && (i.push(u), o.set(u, t));
|
|
4162
4642
|
}
|
|
4163
4643
|
}));
|
|
4164
|
-
const u = new
|
|
4165
|
-
return new
|
|
4644
|
+
const u = new Vt(i);
|
|
4645
|
+
return new Nn(o, u, s.fieldTransforms);
|
|
4166
4646
|
}
|
|
4167
4647
|
|
|
4168
|
-
/** Parse update data from a list of field/value arguments. */ function
|
|
4169
|
-
const o = t.ht(1 /* Update */ , e, n), u = [
|
|
4170
|
-
if (i.length % 2 != 0) throw new
|
|
4171
|
-
for (let t = 0; t < i.length; t += 2) u.push(
|
|
4172
|
-
const a = [], l =
|
|
4648
|
+
/** Parse update data from a list of field/value arguments. */ function jn(t, e, n, r, s, i) {
|
|
4649
|
+
const o = t.ht(1 /* Update */ , e, n), u = [ Qn(e, r, n) ], c = [ s ];
|
|
4650
|
+
if (i.length % 2 != 0) throw new L(A, `Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);
|
|
4651
|
+
for (let t = 0; t < i.length; t += 2) u.push(Qn(e, i[t])), c.push(i[t + 1]);
|
|
4652
|
+
const a = [], l = Yt.empty();
|
|
4173
4653
|
// We iterate in reverse order to pick the last value for a field if the
|
|
4174
4654
|
// user specified the field multiple times.
|
|
4175
|
-
for (let t = u.length - 1; t >= 0; --t) if (!
|
|
4655
|
+
for (let t = u.length - 1; t >= 0; --t) if (!Xn(a, u[t])) {
|
|
4176
4656
|
const e = u[t];
|
|
4177
4657
|
let n = c[t];
|
|
4178
4658
|
// For Compat types, we have to "extract" the underlying types before
|
|
4179
4659
|
// performing validation.
|
|
4180
4660
|
n = getModularInstance(n);
|
|
4181
4661
|
const r = o.it(e);
|
|
4182
|
-
if (n instanceof
|
|
4662
|
+
if (n instanceof qn)
|
|
4183
4663
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4184
4664
|
a.push(e); else {
|
|
4185
|
-
const t =
|
|
4665
|
+
const t = zn(n, r);
|
|
4186
4666
|
null != t && (a.push(e), l.set(e, t));
|
|
4187
4667
|
}
|
|
4188
4668
|
}
|
|
4189
|
-
const f = new
|
|
4190
|
-
return new
|
|
4669
|
+
const f = new Vt(a);
|
|
4670
|
+
return new Nn(l, f, o.fieldTransforms);
|
|
4191
4671
|
}
|
|
4192
4672
|
|
|
4193
4673
|
/**
|
|
@@ -4196,8 +4676,8 @@ class qn extends bn {
|
|
|
4196
4676
|
*
|
|
4197
4677
|
* @param allowArrays - Whether the query value is an array that may directly
|
|
4198
4678
|
* contain additional arrays (e.g. the operand of an `in` query).
|
|
4199
|
-
*/ function
|
|
4200
|
-
return
|
|
4679
|
+
*/ function Bn(t, e, n, r = !1) {
|
|
4680
|
+
return zn(n, t.ht(r ? 4 /* ArrayArgument */ : 3 /* Argument */ , e));
|
|
4201
4681
|
}
|
|
4202
4682
|
|
|
4203
4683
|
/**
|
|
@@ -4208,12 +4688,12 @@ class qn extends bn {
|
|
|
4208
4688
|
* the source of the data being parsed, etc.
|
|
4209
4689
|
* @returns The parsed value, or null if the value was a FieldValue sentinel
|
|
4210
4690
|
* that should not be included in the resulting parsed data.
|
|
4211
|
-
*/ function
|
|
4212
|
-
if (
|
|
4691
|
+
*/ function zn(t, e) {
|
|
4692
|
+
if (Wn(
|
|
4213
4693
|
// Unwrap the API type from the Compat SDK. This will return the API type
|
|
4214
4694
|
// from firestore-exp.
|
|
4215
|
-
t = getModularInstance(t))) return
|
|
4216
|
-
if (t instanceof
|
|
4695
|
+
t = getModularInstance(t))) return Kn("Unsupported field value:", e, t), Gn(t, e);
|
|
4696
|
+
if (t instanceof An)
|
|
4217
4697
|
// FieldValues usually parse into transforms (except deleteField())
|
|
4218
4698
|
// in which case we do not want to include this field in our parsed data
|
|
4219
4699
|
// (as doing so will overwrite the field directly prior to the transform
|
|
@@ -4225,7 +4705,7 @@ class qn extends bn {
|
|
|
4225
4705
|
*/
|
|
4226
4706
|
return function(t, e) {
|
|
4227
4707
|
// Sentinels are only supported with writes, and not within arrays.
|
|
4228
|
-
if (!
|
|
4708
|
+
if (!Dn(e.tt)) throw e.ut(`${t._methodName}() can only be used with update() and set()`);
|
|
4229
4709
|
if (!e.path) throw e.ut(`${t._methodName}() is not currently supported inside arrays`);
|
|
4230
4710
|
const n = t._toFieldTransform(e);
|
|
4231
4711
|
n && e.fieldTransforms.push(n);
|
|
@@ -4255,7 +4735,7 @@ class qn extends bn {
|
|
|
4255
4735
|
const n = [];
|
|
4256
4736
|
let r = 0;
|
|
4257
4737
|
for (const s of t) {
|
|
4258
|
-
let t =
|
|
4738
|
+
let t = zn(s, e.ot(r));
|
|
4259
4739
|
null == t && (
|
|
4260
4740
|
// Just include nulls in the array for fields being replaced with a
|
|
4261
4741
|
// sentinel.
|
|
@@ -4274,7 +4754,7 @@ class qn extends bn {
|
|
|
4274
4754
|
if (null === (t = getModularInstance(t))) return {
|
|
4275
4755
|
nullValue: "NULL_VALUE"
|
|
4276
4756
|
};
|
|
4277
|
-
if ("number" == typeof t) return
|
|
4757
|
+
if ("number" == typeof t) return ge(e.q, t);
|
|
4278
4758
|
if ("boolean" == typeof t) return {
|
|
4279
4759
|
booleanValue: t
|
|
4280
4760
|
};
|
|
@@ -4284,7 +4764,7 @@ class qn extends bn {
|
|
|
4284
4764
|
if (t instanceof Date) {
|
|
4285
4765
|
const n = gt.fromDate(t);
|
|
4286
4766
|
return {
|
|
4287
|
-
timestampValue:
|
|
4767
|
+
timestampValue: qe(e.q, n)
|
|
4288
4768
|
};
|
|
4289
4769
|
}
|
|
4290
4770
|
if (t instanceof gt) {
|
|
@@ -4293,23 +4773,23 @@ class qn extends bn {
|
|
|
4293
4773
|
// truncation immediately without waiting for the backend to do that.
|
|
4294
4774
|
const n = new gt(t.seconds, 1e3 * Math.floor(t.nanoseconds / 1e3));
|
|
4295
4775
|
return {
|
|
4296
|
-
timestampValue:
|
|
4776
|
+
timestampValue: qe(e.q, n)
|
|
4297
4777
|
};
|
|
4298
4778
|
}
|
|
4299
|
-
if (t instanceof
|
|
4779
|
+
if (t instanceof Rn) return {
|
|
4300
4780
|
geoPointValue: {
|
|
4301
4781
|
latitude: t.latitude,
|
|
4302
4782
|
longitude: t.longitude
|
|
4303
4783
|
}
|
|
4304
4784
|
};
|
|
4305
|
-
if (t instanceof
|
|
4306
|
-
bytesValue:
|
|
4785
|
+
if (t instanceof In) return {
|
|
4786
|
+
bytesValue: Oe(e.q, t._byteString)
|
|
4307
4787
|
};
|
|
4308
|
-
if (t instanceof
|
|
4788
|
+
if (t instanceof wn) {
|
|
4309
4789
|
const n = e.databaseId, r = t.firestore._databaseId;
|
|
4310
4790
|
if (!r.isEqual(n)) throw e.ut(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);
|
|
4311
4791
|
return {
|
|
4312
|
-
referenceValue:
|
|
4792
|
+
referenceValue: Le(t.firestore._databaseId || e.databaseId, t._key.path)
|
|
4313
4793
|
};
|
|
4314
4794
|
}
|
|
4315
4795
|
throw e.ut(`Unsupported field value: ${it(t)}`);
|
|
@@ -4323,13 +4803,13 @@ class qn extends bn {
|
|
|
4323
4803
|
*/ (t, e);
|
|
4324
4804
|
}
|
|
4325
4805
|
|
|
4326
|
-
function
|
|
4806
|
+
function Gn(t, e) {
|
|
4327
4807
|
const n = {};
|
|
4328
4808
|
return !function(t) {
|
|
4329
4809
|
for (const e in t) if (Object.prototype.hasOwnProperty.call(t, e)) return !1;
|
|
4330
4810
|
return !0;
|
|
4331
4811
|
}(t) ? Et(t, ((t, r) => {
|
|
4332
|
-
const s =
|
|
4812
|
+
const s = zn(r, e.nt(t));
|
|
4333
4813
|
null != s && (n[t] = s);
|
|
4334
4814
|
})) :
|
|
4335
4815
|
// If we encounter an empty object, we explicitly add it to the update
|
|
@@ -4341,12 +4821,12 @@ function kn(t, e) {
|
|
|
4341
4821
|
};
|
|
4342
4822
|
}
|
|
4343
4823
|
|
|
4344
|
-
function
|
|
4345
|
-
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof gt || t instanceof
|
|
4824
|
+
function Wn(t) {
|
|
4825
|
+
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof gt || t instanceof Rn || t instanceof In || t instanceof wn || t instanceof An);
|
|
4346
4826
|
}
|
|
4347
4827
|
|
|
4348
|
-
function
|
|
4349
|
-
if (!
|
|
4828
|
+
function Kn(t, e, n) {
|
|
4829
|
+
if (!Wn(n) || !function(t) {
|
|
4350
4830
|
return "object" == typeof t && null !== t && (Object.getPrototypeOf(t) === Object.prototype || null === Object.getPrototypeOf(t));
|
|
4351
4831
|
}(n)) {
|
|
4352
4832
|
const r = it(n);
|
|
@@ -4356,20 +4836,20 @@ function Mn(t, e, n) {
|
|
|
4356
4836
|
|
|
4357
4837
|
/**
|
|
4358
4838
|
* Helper that calls fromDotSeparatedString() but wraps any error thrown.
|
|
4359
|
-
*/ function
|
|
4839
|
+
*/ function Qn(t, e, n) {
|
|
4360
4840
|
if ((
|
|
4361
4841
|
// If required, replace the FieldPath Compat class with with the firestore-exp
|
|
4362
4842
|
// FieldPath.
|
|
4363
|
-
e = getModularInstance(e)) instanceof
|
|
4364
|
-
if ("string" == typeof e) return
|
|
4365
|
-
throw
|
|
4843
|
+
e = getModularInstance(e)) instanceof En) return e._internalPath;
|
|
4844
|
+
if ("string" == typeof e) return Hn(t, e);
|
|
4845
|
+
throw Jn("Field path arguments must be of type string or ", t,
|
|
4366
4846
|
/* hasConverter= */ !1,
|
|
4367
4847
|
/* path= */ void 0, n);
|
|
4368
4848
|
}
|
|
4369
4849
|
|
|
4370
4850
|
/**
|
|
4371
4851
|
* Matches any characters in a field path string that are reserved.
|
|
4372
|
-
*/ const
|
|
4852
|
+
*/ const Yn = new RegExp("[~\\*/\\[\\]]");
|
|
4373
4853
|
|
|
4374
4854
|
/**
|
|
4375
4855
|
* Wraps fromDotSeparatedString with an error message about the method that
|
|
@@ -4379,29 +4859,29 @@ function Mn(t, e, n) {
|
|
|
4379
4859
|
* split on dots.
|
|
4380
4860
|
* @param targetDoc - The document against which the field path will be
|
|
4381
4861
|
* evaluated.
|
|
4382
|
-
*/ function
|
|
4383
|
-
if (e.search(
|
|
4862
|
+
*/ function Hn(t, e, n) {
|
|
4863
|
+
if (e.search(Yn) >= 0) throw Jn(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`, t,
|
|
4384
4864
|
/* hasConverter= */ !1,
|
|
4385
4865
|
/* path= */ void 0, n);
|
|
4386
4866
|
try {
|
|
4387
|
-
return new
|
|
4867
|
+
return new En(...e.split("."))._internalPath;
|
|
4388
4868
|
} catch (r) {
|
|
4389
|
-
throw
|
|
4869
|
+
throw Jn(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`, t,
|
|
4390
4870
|
/* hasConverter= */ !1,
|
|
4391
4871
|
/* path= */ void 0, n);
|
|
4392
4872
|
}
|
|
4393
4873
|
}
|
|
4394
4874
|
|
|
4395
|
-
function
|
|
4875
|
+
function Jn(t, e, n, r, s) {
|
|
4396
4876
|
const i = r && !r.isEmpty(), o = void 0 !== s;
|
|
4397
4877
|
let u = `Function ${e}() called with invalid data`;
|
|
4398
4878
|
n && (u += " (via `toFirestore()`)"), u += ". ";
|
|
4399
4879
|
let c = "";
|
|
4400
4880
|
return (i || o) && (c += " (found", i && (c += ` in field ${r}`), o && (c += ` in document ${s}`),
|
|
4401
|
-
c += ")"), new
|
|
4881
|
+
c += ")"), new L(A, u + t + c);
|
|
4402
4882
|
}
|
|
4403
4883
|
|
|
4404
|
-
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function
|
|
4884
|
+
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function Xn(t, e) {
|
|
4405
4885
|
return t.some((t => t.isEqual(e)));
|
|
4406
4886
|
}
|
|
4407
4887
|
|
|
@@ -4429,7 +4909,7 @@ function Qn(t, e, n, r, s) {
|
|
|
4429
4909
|
* For a `DocumentSnapshot` that points to a non-existing document, any data
|
|
4430
4910
|
* access will return 'undefined'. You can use the `exists()` method to
|
|
4431
4911
|
* explicitly verify a document's existence.
|
|
4432
|
-
*/ class
|
|
4912
|
+
*/ class Zn {
|
|
4433
4913
|
// Note: This class is stripped down version of the DocumentSnapshot in
|
|
4434
4914
|
// the legacy SDK. The changes are:
|
|
4435
4915
|
// - No support for SnapshotMetadata.
|
|
@@ -4445,7 +4925,7 @@ function Qn(t, e, n, r, s) {
|
|
|
4445
4925
|
/**
|
|
4446
4926
|
* The `DocumentReference` for the document included in the `DocumentSnapshot`.
|
|
4447
4927
|
*/ get ref() {
|
|
4448
|
-
return new
|
|
4928
|
+
return new wn(this._firestore, this._converter, this._key);
|
|
4449
4929
|
}
|
|
4450
4930
|
/**
|
|
4451
4931
|
* Signals whether or not the document at the snapshot's location exists.
|
|
@@ -4465,7 +4945,7 @@ function Qn(t, e, n, r, s) {
|
|
|
4465
4945
|
if (this._converter) {
|
|
4466
4946
|
// We only want to use the converter and create a new DocumentSnapshot
|
|
4467
4947
|
// if a converter has been provided.
|
|
4468
|
-
const t = new
|
|
4948
|
+
const t = new tr(this._firestore, this._userDataWriter, this._key, this._document,
|
|
4469
4949
|
/* converter= */ null);
|
|
4470
4950
|
return this._converter.fromFirestore(t);
|
|
4471
4951
|
}
|
|
@@ -4485,7 +4965,7 @@ function Qn(t, e, n, r, s) {
|
|
|
4485
4965
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4486
4966
|
get(t) {
|
|
4487
4967
|
if (this._document) {
|
|
4488
|
-
const e = this._document.data.field(
|
|
4968
|
+
const e = this._document.data.field(rr("DocumentSnapshot.get", t));
|
|
4489
4969
|
if (null !== e) return this._userDataWriter.convertValue(e);
|
|
4490
4970
|
}
|
|
4491
4971
|
}
|
|
@@ -4501,7 +4981,7 @@ function Qn(t, e, n, r, s) {
|
|
|
4501
4981
|
* `DocumentSnapshot`. Since query results contain only existing documents, the
|
|
4502
4982
|
* `exists` property will always be true and `data()` will never return
|
|
4503
4983
|
* 'undefined'.
|
|
4504
|
-
*/ class
|
|
4984
|
+
*/ class tr extends Zn {
|
|
4505
4985
|
/**
|
|
4506
4986
|
* Retrieves all fields in the document as an `Object`.
|
|
4507
4987
|
*
|
|
@@ -4519,7 +4999,7 @@ function Qn(t, e, n, r, s) {
|
|
|
4519
4999
|
* array via the `docs` property or enumerated using the `forEach` method. The
|
|
4520
5000
|
* number of documents can be determined via the `empty` and `size`
|
|
4521
5001
|
* properties.
|
|
4522
|
-
*/ class
|
|
5002
|
+
*/ class er {
|
|
4523
5003
|
/** @hideconstructor */
|
|
4524
5004
|
constructor(t, e) {
|
|
4525
5005
|
this._docs = e, this.query = t;
|
|
@@ -4550,14 +5030,14 @@ function Qn(t, e, n, r, s) {
|
|
|
4550
5030
|
* @param left - A snapshot to compare.
|
|
4551
5031
|
* @param right - A snapshot to compare.
|
|
4552
5032
|
* @returns true if the snapshots are equal.
|
|
4553
|
-
*/ function
|
|
4554
|
-
return t = getModularInstance(t), e = getModularInstance(e), t instanceof
|
|
5033
|
+
*/ function nr(t, e) {
|
|
5034
|
+
return t = getModularInstance(t), e = getModularInstance(e), t instanceof Zn && e instanceof Zn ? t._firestore === e._firestore && t._key.isEqual(e._key) && (null === t._document ? null === e._document : t._document.isEqual(e._document)) && t._converter === e._converter : t instanceof er && e instanceof er && (bn(t.query, e.query) && _t(t.docs, e.docs, nr));
|
|
4555
5035
|
}
|
|
4556
5036
|
|
|
4557
5037
|
/**
|
|
4558
5038
|
* Helper that calls `fromDotSeparatedString()` but wraps any error thrown.
|
|
4559
|
-
*/ function
|
|
4560
|
-
return "string" == typeof e ?
|
|
5039
|
+
*/ function rr(t, e) {
|
|
5040
|
+
return "string" == typeof e ? Hn(t, e) : e instanceof En ? e._internalPath : e._delegate._internalPath;
|
|
4561
5041
|
}
|
|
4562
5042
|
|
|
4563
5043
|
/**
|
|
@@ -4584,7 +5064,7 @@ function Qn(t, e, n, r, s) {
|
|
|
4584
5064
|
* can then be passed to {@link query} to create a new query instance that
|
|
4585
5065
|
* also contains this `QueryConstraint`.
|
|
4586
5066
|
*/
|
|
4587
|
-
class
|
|
5067
|
+
class sr {}
|
|
4588
5068
|
|
|
4589
5069
|
/**
|
|
4590
5070
|
* Creates a new immutable instance of {@link Query} that is extended to also include
|
|
@@ -4594,40 +5074,40 @@ class Zn {}
|
|
|
4594
5074
|
* @param queryConstraints - The list of {@link QueryConstraint}s to apply.
|
|
4595
5075
|
* @throws if any of the provided query constraints cannot be combined with the
|
|
4596
5076
|
* existing or new constraints.
|
|
4597
|
-
*/ function
|
|
5077
|
+
*/ function ir(t, ...e) {
|
|
4598
5078
|
for (const n of e) t = n._apply(t);
|
|
4599
5079
|
return t;
|
|
4600
5080
|
}
|
|
4601
5081
|
|
|
4602
|
-
class
|
|
5082
|
+
class or extends sr {
|
|
4603
5083
|
constructor(t, e, n) {
|
|
4604
5084
|
super(), this.dt = t, this.wt = e, this.yt = n, this.type = "where";
|
|
4605
5085
|
}
|
|
4606
5086
|
_apply(t) {
|
|
4607
|
-
const e =
|
|
5087
|
+
const e = Fn(t.firestore), n = function(t, e, n, r, s, i, o) {
|
|
4608
5088
|
let u;
|
|
4609
5089
|
if (s.isKeyField()) {
|
|
4610
|
-
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new
|
|
5090
|
+
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new L(A, `Invalid Query. You can't perform '${i}' queries on documentId().`);
|
|
4611
5091
|
if ("in" /* IN */ === i || "not-in" /* NOT_IN */ === i) {
|
|
4612
|
-
|
|
5092
|
+
br(o, i);
|
|
4613
5093
|
const e = [];
|
|
4614
|
-
for (const n of o) e.push(
|
|
5094
|
+
for (const n of o) e.push(vr(r, t, n));
|
|
4615
5095
|
u = {
|
|
4616
5096
|
arrayValue: {
|
|
4617
5097
|
values: e
|
|
4618
5098
|
}
|
|
4619
5099
|
};
|
|
4620
|
-
} else u =
|
|
4621
|
-
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i ||
|
|
4622
|
-
u =
|
|
5100
|
+
} else u = vr(r, t, o);
|
|
5101
|
+
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i || br(o, i),
|
|
5102
|
+
u = Bn(n, e, o,
|
|
4623
5103
|
/* allowArrays= */ "in" /* IN */ === i || "not-in" /* NOT_IN */ === i);
|
|
4624
|
-
const c =
|
|
5104
|
+
const c = Zt.create(s, i, u);
|
|
4625
5105
|
return function(t, e) {
|
|
4626
|
-
if (e.
|
|
4627
|
-
const n =
|
|
4628
|
-
if (null !== n && !n.isEqual(e.field)) throw new
|
|
4629
|
-
const r =
|
|
4630
|
-
null !== r &&
|
|
5106
|
+
if (e.D()) {
|
|
5107
|
+
const n = we(t);
|
|
5108
|
+
if (null !== n && !n.isEqual(e.field)) throw new L(A, `Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '${n.toString()}' and '${e.field.toString()}'`);
|
|
5109
|
+
const r = de(t);
|
|
5110
|
+
null !== r && Er(t, e.field, r);
|
|
4631
5111
|
}
|
|
4632
5112
|
const n = function(t, e) {
|
|
4633
5113
|
for (const n of t.filters) if (e.indexOf(n.op) >= 0) return n.op;
|
|
@@ -4668,12 +5148,12 @@ class er extends Zn {
|
|
|
4668
5148
|
}(e.op));
|
|
4669
5149
|
if (null !== n)
|
|
4670
5150
|
// Special case when it's a duplicate op to give a slightly clearer error message.
|
|
4671
|
-
throw n === e.op ? new
|
|
5151
|
+
throw n === e.op ? new L(A, `Invalid query. You cannot use more than one '${e.op.toString()}' filter.`) : new L(A, `Invalid query. You cannot use '${e.op.toString()}' filters with '${n.toString()}' filters.`);
|
|
4672
5152
|
}(t, c), c;
|
|
4673
5153
|
}(t._query, "where", e, t.firestore._databaseId, this.dt, this.wt, this.yt);
|
|
4674
|
-
return new
|
|
5154
|
+
return new mn(t.firestore, t.converter, function(t, e) {
|
|
4675
5155
|
const n = t.filters.concat([ e ]);
|
|
4676
|
-
return new
|
|
5156
|
+
return new fe(t.path, t.collectionGroup, t.explicitOrderBy.slice(), n, t.limit, t.limitType, t.startAt, t.endAt);
|
|
4677
5157
|
}(t._query, n));
|
|
4678
5158
|
}
|
|
4679
5159
|
}
|
|
@@ -4688,25 +5168,25 @@ class er extends Zn {
|
|
|
4688
5168
|
* "<=", "!=").
|
|
4689
5169
|
* @param value - The value for comparison
|
|
4690
5170
|
* @returns The created {@link Query}.
|
|
4691
|
-
*/ function
|
|
4692
|
-
const r = e, s =
|
|
4693
|
-
return new
|
|
5171
|
+
*/ function ur(t, e, n) {
|
|
5172
|
+
const r = e, s = rr("where", t);
|
|
5173
|
+
return new or(s, r, n);
|
|
4694
5174
|
}
|
|
4695
5175
|
|
|
4696
|
-
class
|
|
5176
|
+
class cr extends sr {
|
|
4697
5177
|
constructor(t, e) {
|
|
4698
5178
|
super(), this.dt = t, this._t = e, this.type = "orderBy";
|
|
4699
5179
|
}
|
|
4700
5180
|
_apply(t) {
|
|
4701
5181
|
const e = function(t, e, n) {
|
|
4702
|
-
if (null !== t.startAt) throw new
|
|
4703
|
-
if (null !== t.endAt) throw new
|
|
4704
|
-
const r = new
|
|
5182
|
+
if (null !== t.startAt) throw new L(A, "Invalid query. You must not call startAt() or startAfter() before calling orderBy().");
|
|
5183
|
+
if (null !== t.endAt) throw new L(A, "Invalid query. You must not call endAt() or endBefore() before calling orderBy().");
|
|
5184
|
+
const r = new ae(e, n);
|
|
4705
5185
|
return function(t, e) {
|
|
4706
|
-
if (null ===
|
|
5186
|
+
if (null === de(t)) {
|
|
4707
5187
|
// This is the first order by. It must match any inequality.
|
|
4708
|
-
const n =
|
|
4709
|
-
null !== n &&
|
|
5188
|
+
const n = we(t);
|
|
5189
|
+
null !== n && Er(t, n, e.field);
|
|
4710
5190
|
}
|
|
4711
5191
|
}(t, r), r;
|
|
4712
5192
|
}
|
|
@@ -4721,10 +5201,10 @@ class rr extends Zn {
|
|
|
4721
5201
|
* of the query or if any of the fields in the order by are an uncommitted
|
|
4722
5202
|
* server timestamp.
|
|
4723
5203
|
*/ (t._query, this.dt, this._t);
|
|
4724
|
-
return new
|
|
5204
|
+
return new mn(t.firestore, t.converter, function(t, e) {
|
|
4725
5205
|
// TODO(dimond): validate that orderBy does not list the same key twice.
|
|
4726
5206
|
const n = t.explicitOrderBy.concat([ e ]);
|
|
4727
|
-
return new
|
|
5207
|
+
return new fe(t.path, t.collectionGroup, n, t.filters.slice(), t.limit, t.limitType, t.startAt, t.endAt);
|
|
4728
5208
|
}(t._query, e));
|
|
4729
5209
|
}
|
|
4730
5210
|
}
|
|
@@ -4737,19 +5217,19 @@ class rr extends Zn {
|
|
|
4737
5217
|
* @param directionStr - Optional direction to sort by ('asc' or 'desc'). If
|
|
4738
5218
|
* not specified, order will be ascending.
|
|
4739
5219
|
* @returns The created {@link Query}.
|
|
4740
|
-
*/ function
|
|
4741
|
-
const n = e, r =
|
|
4742
|
-
return new
|
|
5220
|
+
*/ function ar(t, e = "asc") {
|
|
5221
|
+
const n = e, r = rr("orderBy", t);
|
|
5222
|
+
return new cr(r, n);
|
|
4743
5223
|
}
|
|
4744
5224
|
|
|
4745
|
-
class
|
|
5225
|
+
class hr extends sr {
|
|
4746
5226
|
constructor(t, e, n) {
|
|
4747
|
-
super(), this.type = t, this.gt = e, this.
|
|
5227
|
+
super(), this.type = t, this.gt = e, this.vt = n;
|
|
4748
5228
|
}
|
|
4749
5229
|
_apply(t) {
|
|
4750
|
-
return new
|
|
4751
|
-
return new
|
|
4752
|
-
}(t._query, this.gt, this.
|
|
5230
|
+
return new mn(t.firestore, t.converter, function(t, e, n) {
|
|
5231
|
+
return new fe(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), e, n, t.startAt, t.endAt);
|
|
5232
|
+
}(t._query, this.gt, this.vt));
|
|
4753
5233
|
}
|
|
4754
5234
|
}
|
|
4755
5235
|
|
|
@@ -4758,8 +5238,8 @@ class ir extends Zn {
|
|
|
4758
5238
|
*
|
|
4759
5239
|
* @param limit - The maximum number of items to return.
|
|
4760
5240
|
* @returns The created {@link Query}.
|
|
4761
|
-
*/ function
|
|
4762
|
-
return ut("limit", t), new
|
|
5241
|
+
*/ function lr(t) {
|
|
5242
|
+
return ut("limit", t), new hr("limit", t, "F" /* First */);
|
|
4763
5243
|
}
|
|
4764
5244
|
|
|
4765
5245
|
/**
|
|
@@ -4770,56 +5250,56 @@ class ir extends Zn {
|
|
|
4770
5250
|
*
|
|
4771
5251
|
* @param limit - The maximum number of items to return.
|
|
4772
5252
|
* @returns The created {@link Query}.
|
|
4773
|
-
*/ function
|
|
4774
|
-
return ut("limitToLast", t), new
|
|
5253
|
+
*/ function fr(t) {
|
|
5254
|
+
return ut("limitToLast", t), new hr("limitToLast", t, "L" /* Last */);
|
|
4775
5255
|
}
|
|
4776
5256
|
|
|
4777
|
-
class
|
|
5257
|
+
class dr extends sr {
|
|
4778
5258
|
constructor(t, e, n) {
|
|
4779
|
-
super(), this.type = t, this.
|
|
5259
|
+
super(), this.type = t, this.bt = e, this.Et = n;
|
|
4780
5260
|
}
|
|
4781
5261
|
_apply(t) {
|
|
4782
|
-
const e =
|
|
4783
|
-
return new
|
|
4784
|
-
return new
|
|
5262
|
+
const e = gr(t, this.type, this.bt, this.Et);
|
|
5263
|
+
return new mn(t.firestore, t.converter, function(t, e) {
|
|
5264
|
+
return new fe(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, e, t.endAt);
|
|
4785
5265
|
}(t._query, e));
|
|
4786
5266
|
}
|
|
4787
5267
|
}
|
|
4788
5268
|
|
|
4789
|
-
function
|
|
4790
|
-
return new
|
|
5269
|
+
function wr(...t) {
|
|
5270
|
+
return new dr("startAt", t,
|
|
4791
5271
|
/*inclusive=*/ !0);
|
|
4792
5272
|
}
|
|
4793
5273
|
|
|
4794
|
-
function
|
|
4795
|
-
return new
|
|
5274
|
+
function mr(...t) {
|
|
5275
|
+
return new dr("startAfter", t,
|
|
4796
5276
|
/*inclusive=*/ !1);
|
|
4797
5277
|
}
|
|
4798
5278
|
|
|
4799
|
-
class
|
|
5279
|
+
class pr extends sr {
|
|
4800
5280
|
constructor(t, e, n) {
|
|
4801
|
-
super(), this.type = t, this.
|
|
5281
|
+
super(), this.type = t, this.bt = e, this.Et = n;
|
|
4802
5282
|
}
|
|
4803
5283
|
_apply(t) {
|
|
4804
|
-
const e =
|
|
4805
|
-
return new
|
|
4806
|
-
return new
|
|
5284
|
+
const e = gr(t, this.type, this.bt, this.Et);
|
|
5285
|
+
return new mn(t.firestore, t.converter, function(t, e) {
|
|
5286
|
+
return new fe(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, t.startAt, e);
|
|
4807
5287
|
}(t._query, e));
|
|
4808
5288
|
}
|
|
4809
5289
|
}
|
|
4810
5290
|
|
|
4811
|
-
function
|
|
4812
|
-
return new
|
|
5291
|
+
function yr(...t) {
|
|
5292
|
+
return new pr("endBefore", t,
|
|
4813
5293
|
/*inclusive=*/ !1);
|
|
4814
5294
|
}
|
|
4815
5295
|
|
|
4816
|
-
function
|
|
4817
|
-
return new
|
|
5296
|
+
function _r(...t) {
|
|
5297
|
+
return new pr("endAt", t, /*inclusive=*/ !0);
|
|
4818
5298
|
}
|
|
4819
5299
|
|
|
4820
|
-
/** Helper function to create a bound from a document or fields */ function
|
|
4821
|
-
if (n[0] = getModularInstance(n[0]), n[0] instanceof
|
|
4822
|
-
if (!r) throw new
|
|
5300
|
+
/** Helper function to create a bound from a document or fields */ function gr(t, e, n, r) {
|
|
5301
|
+
if (n[0] = getModularInstance(n[0]), n[0] instanceof Zn) return function(t, e, n, r, s) {
|
|
5302
|
+
if (!r) throw new L(P, `Can't use a DocumentSnapshot that doesn't exist for ${n}().`);
|
|
4823
5303
|
const i = [];
|
|
4824
5304
|
// Because people expect to continue/end a query at the exact document
|
|
4825
5305
|
// provided, we need to use the implicit sort order rather than the explicit
|
|
@@ -4828,42 +5308,42 @@ function dr(...t) {
|
|
|
4828
5308
|
// the provided document. Without the key (by using the explicit sort
|
|
4829
5309
|
// orders), multiple documents could match the position, yielding duplicate
|
|
4830
5310
|
// results.
|
|
4831
|
-
for (const n of
|
|
5311
|
+
for (const n of pe(t)) if (n.field.isKeyField()) i.push(Bt(e, r.key)); else {
|
|
4832
5312
|
const t = r.data.field(n.field);
|
|
4833
|
-
if (
|
|
5313
|
+
if (St(t)) throw new L(A, 'Invalid query. You are trying to start or end a query using a document for which the field "' + n.field + '" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');
|
|
4834
5314
|
if (null === t) {
|
|
4835
5315
|
const t = n.field.canonicalString();
|
|
4836
|
-
throw new
|
|
5316
|
+
throw new L(A, `Invalid query. You are trying to start or end a query using a document for which the field '${t}' (used as the orderBy) does not exist.`);
|
|
4837
5317
|
}
|
|
4838
5318
|
i.push(t);
|
|
4839
5319
|
}
|
|
4840
|
-
return new
|
|
5320
|
+
return new ce(i, s);
|
|
4841
5321
|
}
|
|
4842
5322
|
/**
|
|
4843
5323
|
* Converts a list of field values to a `Bound` for the given query.
|
|
4844
5324
|
*/ (t._query, t.firestore._databaseId, e, n[0]._document, r);
|
|
4845
5325
|
{
|
|
4846
|
-
const s =
|
|
5326
|
+
const s = Fn(t.firestore);
|
|
4847
5327
|
return function(t, e, n, r, s, i) {
|
|
4848
5328
|
// Use explicit order by's because it has to match the query the user made
|
|
4849
5329
|
const o = t.explicitOrderBy;
|
|
4850
|
-
if (s.length > o.length) throw new
|
|
5330
|
+
if (s.length > o.length) throw new L(A, `Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);
|
|
4851
5331
|
const u = [];
|
|
4852
5332
|
for (let i = 0; i < s.length; i++) {
|
|
4853
5333
|
const c = s[i];
|
|
4854
5334
|
if (o[i].field.isKeyField()) {
|
|
4855
|
-
if ("string" != typeof c) throw new
|
|
4856
|
-
if (!
|
|
5335
|
+
if ("string" != typeof c) throw new L(A, `Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);
|
|
5336
|
+
if (!me(t) && -1 !== c.indexOf("/")) throw new L(A, `Invalid query. When querying a collection and ordering by documentId(), the value passed to ${r}() must be a plain document ID, but '${c}' contains a slash.`);
|
|
4857
5337
|
const n = t.path.child(X.fromString(c));
|
|
4858
|
-
if (!et.isDocumentKey(n)) throw new
|
|
5338
|
+
if (!et.isDocumentKey(n)) throw new L(A, `Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${r}() must result in a valid document path, but '${n}' is not because it contains an odd number of segments.`);
|
|
4859
5339
|
const s = new et(n);
|
|
4860
|
-
u.push(
|
|
5340
|
+
u.push(Bt(e, s));
|
|
4861
5341
|
} else {
|
|
4862
|
-
const t =
|
|
5342
|
+
const t = Bn(n, r, c);
|
|
4863
5343
|
u.push(t);
|
|
4864
5344
|
}
|
|
4865
5345
|
}
|
|
4866
|
-
return new
|
|
5346
|
+
return new ce(u, i);
|
|
4867
5347
|
}
|
|
4868
5348
|
/**
|
|
4869
5349
|
* Parses the given `documentIdValue` into a `ReferenceValue`, throwing
|
|
@@ -4873,28 +5353,28 @@ function dr(...t) {
|
|
|
4873
5353
|
}
|
|
4874
5354
|
}
|
|
4875
5355
|
|
|
4876
|
-
function
|
|
5356
|
+
function vr(t, e, n) {
|
|
4877
5357
|
if ("string" == typeof (n = getModularInstance(n))) {
|
|
4878
|
-
if ("" === n) throw new
|
|
4879
|
-
if (!
|
|
5358
|
+
if ("" === n) throw new L(A, "Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");
|
|
5359
|
+
if (!me(e) && -1 !== n.indexOf("/")) throw new L(A, `Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);
|
|
4880
5360
|
const r = e.path.child(X.fromString(n));
|
|
4881
|
-
if (!et.isDocumentKey(r)) throw new
|
|
4882
|
-
return
|
|
5361
|
+
if (!et.isDocumentKey(r)) throw new L(A, `Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);
|
|
5362
|
+
return Bt(t, new et(r));
|
|
4883
5363
|
}
|
|
4884
|
-
if (n instanceof
|
|
4885
|
-
throw new
|
|
5364
|
+
if (n instanceof wn) return Bt(t, n._key);
|
|
5365
|
+
throw new L(A, `Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${it(n)}.`);
|
|
4886
5366
|
}
|
|
4887
5367
|
|
|
4888
5368
|
/**
|
|
4889
5369
|
* Validates that the value passed into a disjunctive filter satisfies all
|
|
4890
5370
|
* array requirements.
|
|
4891
|
-
*/ function
|
|
4892
|
-
if (!Array.isArray(t) || 0 === t.length) throw new
|
|
4893
|
-
if (t.length > 10) throw new
|
|
5371
|
+
*/ function br(t, e) {
|
|
5372
|
+
if (!Array.isArray(t) || 0 === t.length) throw new L(A, `Invalid Query. A non-empty array is required for '${e.toString()}' filters.`);
|
|
5373
|
+
if (t.length > 10) throw new L(A, `Invalid Query. '${e.toString()}' filters support a maximum of 10 elements in the value array.`);
|
|
4894
5374
|
}
|
|
4895
5375
|
|
|
4896
|
-
function
|
|
4897
|
-
if (!n.isEqual(e)) throw new
|
|
5376
|
+
function Er(t, e, n) {
|
|
5377
|
+
if (!n.isEqual(e)) throw new L(A, `Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '${e.toString()}' and so you must also use '${e.toString()}' as your first argument to orderBy(), but your first orderBy() is on field '${n.toString()}' instead.`);
|
|
4898
5378
|
}
|
|
4899
5379
|
|
|
4900
5380
|
/**
|
|
@@ -4944,7 +5424,7 @@ function yr(t, e, n) {
|
|
|
4944
5424
|
* their `set()` or fails due to invalid data originating from a `toFirestore()`
|
|
4945
5425
|
* call.
|
|
4946
5426
|
*/
|
|
4947
|
-
function
|
|
5427
|
+
function Tr(t, e, n) {
|
|
4948
5428
|
let r;
|
|
4949
5429
|
// Cast to `any` in order to satisfy the union type constraint on
|
|
4950
5430
|
// toFirestore().
|
|
@@ -4953,9 +5433,9 @@ function _r(t, e, n) {
|
|
|
4953
5433
|
r;
|
|
4954
5434
|
}
|
|
4955
5435
|
|
|
4956
|
-
class
|
|
5436
|
+
class Ir extends class {
|
|
4957
5437
|
convertValue(t, e = "none") {
|
|
4958
|
-
switch (
|
|
5438
|
+
switch (Ct(t)) {
|
|
4959
5439
|
case 0 /* NullValue */ :
|
|
4960
5440
|
return null;
|
|
4961
5441
|
|
|
@@ -4963,7 +5443,7 @@ class gr extends class {
|
|
|
4963
5443
|
return t.booleanValue;
|
|
4964
5444
|
|
|
4965
5445
|
case 2 /* NumberValue */ :
|
|
4966
|
-
return
|
|
5446
|
+
return xt(t.integerValue || t.doubleValue);
|
|
4967
5447
|
|
|
4968
5448
|
case 3 /* TimestampValue */ :
|
|
4969
5449
|
return this.convertTimestamp(t.timestampValue);
|
|
@@ -4975,7 +5455,7 @@ class gr extends class {
|
|
|
4975
5455
|
return t.stringValue;
|
|
4976
5456
|
|
|
4977
5457
|
case 6 /* BlobValue */ :
|
|
4978
|
-
return this.convertBytes(
|
|
5458
|
+
return this.convertBytes(Ft(t.bytesValue));
|
|
4979
5459
|
|
|
4980
5460
|
case 7 /* RefValue */ :
|
|
4981
5461
|
return this.convertReference(t.referenceValue);
|
|
@@ -5000,7 +5480,7 @@ class gr extends class {
|
|
|
5000
5480
|
})), n;
|
|
5001
5481
|
}
|
|
5002
5482
|
convertGeoPoint(t) {
|
|
5003
|
-
return new
|
|
5483
|
+
return new Rn(xt(t.latitude), xt(t.longitude));
|
|
5004
5484
|
}
|
|
5005
5485
|
convertArray(t, e) {
|
|
5006
5486
|
return (t.values || []).map((t => this.convertValue(t, e)));
|
|
@@ -5008,24 +5488,24 @@ class gr extends class {
|
|
|
5008
5488
|
convertServerTimestamp(t, e) {
|
|
5009
5489
|
switch (e) {
|
|
5010
5490
|
case "previous":
|
|
5011
|
-
const n =
|
|
5491
|
+
const n = qt(t);
|
|
5012
5492
|
return null == n ? null : this.convertValue(n, e);
|
|
5013
5493
|
|
|
5014
5494
|
case "estimate":
|
|
5015
|
-
return this.convertTimestamp(
|
|
5495
|
+
return this.convertTimestamp(Ot(t));
|
|
5016
5496
|
|
|
5017
5497
|
default:
|
|
5018
5498
|
return null;
|
|
5019
5499
|
}
|
|
5020
5500
|
}
|
|
5021
5501
|
convertTimestamp(t) {
|
|
5022
|
-
const e =
|
|
5502
|
+
const e = $t(t);
|
|
5023
5503
|
return new gt(e.seconds, e.nanos);
|
|
5024
5504
|
}
|
|
5025
5505
|
convertDocumentKey(t, e) {
|
|
5026
5506
|
const n = X.fromString(t);
|
|
5027
|
-
|
|
5028
|
-
const r = new
|
|
5507
|
+
v(Xe(n));
|
|
5508
|
+
const r = new H(n.get(1), n.get(3)), s = new et(n.popFirst(5));
|
|
5029
5509
|
return r.isEqual(e) ||
|
|
5030
5510
|
// TODO(b/64130202): Somehow support foreign references.
|
|
5031
5511
|
p(`Document ${s} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${e.projectId}/${e.database}) instead.`),
|
|
@@ -5036,11 +5516,11 @@ class gr extends class {
|
|
|
5036
5516
|
super(), this.firestore = t;
|
|
5037
5517
|
}
|
|
5038
5518
|
convertBytes(t) {
|
|
5039
|
-
return new
|
|
5519
|
+
return new In(t);
|
|
5040
5520
|
}
|
|
5041
5521
|
convertReference(t) {
|
|
5042
5522
|
const e = this.convertDocumentKey(t, this.firestore._databaseId);
|
|
5043
|
-
return new
|
|
5523
|
+
return new wn(this.firestore, /* converter= */ null, e);
|
|
5044
5524
|
}
|
|
5045
5525
|
}
|
|
5046
5526
|
|
|
@@ -5056,12 +5536,12 @@ class gr extends class {
|
|
|
5056
5536
|
* @param reference - The reference of the document to fetch.
|
|
5057
5537
|
* @returns A Promise resolved with a `DocumentSnapshot` containing the current
|
|
5058
5538
|
* document contents.
|
|
5059
|
-
*/ function
|
|
5060
|
-
const e =
|
|
5061
|
-
return
|
|
5062
|
-
|
|
5539
|
+
*/ function Ar(t) {
|
|
5540
|
+
const e = un((t = ot(t, wn)).firestore), n = new Ir(t.firestore);
|
|
5541
|
+
return rn(e, [ t._key ]).then((e => {
|
|
5542
|
+
v(1 === e.length);
|
|
5063
5543
|
const r = e[0];
|
|
5064
|
-
return new
|
|
5544
|
+
return new Zn(t.firestore, n, t._key, r.isFoundDocument() ? r : null, t.converter);
|
|
5065
5545
|
}));
|
|
5066
5546
|
}
|
|
5067
5547
|
|
|
@@ -5076,33 +5556,33 @@ class gr extends class {
|
|
|
5076
5556
|
*
|
|
5077
5557
|
* @param query - The `Query` to execute.
|
|
5078
5558
|
* @returns A Promise that will be resolved with the results of the query.
|
|
5079
|
-
*/ function
|
|
5559
|
+
*/ function Rr(t) {
|
|
5080
5560
|
!function(t) {
|
|
5081
|
-
if ("L" /* Last */ === t.limitType && 0 === t.explicitOrderBy.length) throw new
|
|
5082
|
-
}((t = ot(t,
|
|
5083
|
-
const e =
|
|
5084
|
-
return
|
|
5085
|
-
const r = e.map((e => new
|
|
5561
|
+
if ("L" /* Last */ === t.limitType && 0 === t.explicitOrderBy.length) throw new L(q, "limitToLast() queries require specifying at least one orderBy() clause");
|
|
5562
|
+
}((t = ot(t, mn))._query);
|
|
5563
|
+
const e = un(t.firestore), n = new Ir(t.firestore);
|
|
5564
|
+
return sn(e, t._query).then((e => {
|
|
5565
|
+
const r = e.map((e => new tr(t.firestore, n, e.key, e, t.converter)));
|
|
5086
5566
|
return "L" /* Last */ === t._query.limitType &&
|
|
5087
5567
|
// Limit to last queries reverse the orderBy constraint that was
|
|
5088
5568
|
// specified by the user. As such, we need to reverse the order of the
|
|
5089
5569
|
// results to return the documents in the expected order.
|
|
5090
|
-
r.reverse(), new
|
|
5570
|
+
r.reverse(), new er(t, r);
|
|
5091
5571
|
}));
|
|
5092
5572
|
}
|
|
5093
5573
|
|
|
5094
|
-
function
|
|
5095
|
-
const r =
|
|
5096
|
-
return
|
|
5574
|
+
function Pr(t, e, n) {
|
|
5575
|
+
const r = Tr((t = ot(t, wn)).converter, e, n), s = Sn(Fn(t.firestore), "setDoc", t._key, r, null !== t.converter, n);
|
|
5576
|
+
return nn(un(t.firestore), [ s.toMutation(t._key, Re.none()) ]);
|
|
5097
5577
|
}
|
|
5098
5578
|
|
|
5099
|
-
function
|
|
5100
|
-
const s =
|
|
5579
|
+
function Vr(t, e, n, ...r) {
|
|
5580
|
+
const s = Fn((t = ot(t, wn)).firestore);
|
|
5101
5581
|
// For Compat types, we have to "extract" the underlying types before
|
|
5102
5582
|
// performing validation.
|
|
5103
5583
|
let i;
|
|
5104
|
-
i = "string" == typeof (e = getModularInstance(e)) || e instanceof
|
|
5105
|
-
return
|
|
5584
|
+
i = "string" == typeof (e = getModularInstance(e)) || e instanceof En ? jn(s, "updateDoc", t._key, e, n, r) : Un(s, "updateDoc", t._key, e);
|
|
5585
|
+
return nn(un(t.firestore), [ i.toMutation(t._key, Re.exists(!0)) ]);
|
|
5106
5586
|
}
|
|
5107
5587
|
|
|
5108
5588
|
/**
|
|
@@ -5116,8 +5596,8 @@ function Tr(t, e, n, ...r) {
|
|
|
5116
5596
|
* @param reference - A reference to the document to delete.
|
|
5117
5597
|
* @returns A `Promise` resolved once the document has been successfully
|
|
5118
5598
|
* deleted from the backend.
|
|
5119
|
-
*/ function
|
|
5120
|
-
return
|
|
5599
|
+
*/ function Nr(t) {
|
|
5600
|
+
return nn(un((t = ot(t, wn)).firestore), [ new De(t._key, Re.none()) ]);
|
|
5121
5601
|
}
|
|
5122
5602
|
|
|
5123
5603
|
/**
|
|
@@ -5134,9 +5614,9 @@ function Tr(t, e, n, ...r) {
|
|
|
5134
5614
|
* @throws Error - If the provided input is not a valid Firestore document.
|
|
5135
5615
|
* @returns A `Promise` resolved with a `DocumentReference` pointing to the
|
|
5136
5616
|
* newly created document after it has been written to the backend.
|
|
5137
|
-
*/ function
|
|
5138
|
-
const n =
|
|
5139
|
-
return
|
|
5617
|
+
*/ function Dr(t, e) {
|
|
5618
|
+
const n = gn(t = ot(t, pn)), r = Tr(t.converter, e), s = Sn(Fn(t.firestore), "addDoc", n._key, r, null !== n.converter, {});
|
|
5619
|
+
return nn(un(t.firestore), [ s.toMutation(n._key, Re.exists(!1)) ]).then((() => n));
|
|
5140
5620
|
}
|
|
5141
5621
|
|
|
5142
5622
|
/**
|
|
@@ -5158,15 +5638,15 @@ function Tr(t, e, n, ...r) {
|
|
|
5158
5638
|
/**
|
|
5159
5639
|
* Returns a sentinel for use with {@link @firebase/firestore/lite#(updateDoc:1)} or
|
|
5160
5640
|
* {@link @firebase/firestore/lite#(setDoc:1)} with `{merge: true}` to mark a field for deletion.
|
|
5161
|
-
*/ function
|
|
5162
|
-
return new
|
|
5641
|
+
*/ function $r() {
|
|
5642
|
+
return new qn("deleteField");
|
|
5163
5643
|
}
|
|
5164
5644
|
|
|
5165
5645
|
/**
|
|
5166
5646
|
* Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
|
|
5167
5647
|
* include a server-generated timestamp in the written data.
|
|
5168
|
-
*/ function
|
|
5169
|
-
return new
|
|
5648
|
+
*/ function xr() {
|
|
5649
|
+
return new kn("serverTimestamp");
|
|
5170
5650
|
}
|
|
5171
5651
|
|
|
5172
5652
|
/**
|
|
@@ -5180,10 +5660,10 @@ function Tr(t, e, n, ...r) {
|
|
|
5180
5660
|
* @param elements - The elements to union into the array.
|
|
5181
5661
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5182
5662
|
* `updateDoc()`.
|
|
5183
|
-
*/ function
|
|
5663
|
+
*/ function Fr(...t) {
|
|
5184
5664
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5185
5665
|
// update() since we'd need the Firestore instance to do this.
|
|
5186
|
-
return new
|
|
5666
|
+
return new Cn("arrayUnion", t);
|
|
5187
5667
|
}
|
|
5188
5668
|
|
|
5189
5669
|
/**
|
|
@@ -5196,10 +5676,10 @@ function Tr(t, e, n, ...r) {
|
|
|
5196
5676
|
* @param elements - The elements to remove from the array.
|
|
5197
5677
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5198
5678
|
* `updateDoc()`
|
|
5199
|
-
*/ function
|
|
5679
|
+
*/ function Sr(...t) {
|
|
5200
5680
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5201
5681
|
// update() since we'd need the Firestore instance to do this.
|
|
5202
|
-
return new
|
|
5682
|
+
return new Ln("arrayRemove", t);
|
|
5203
5683
|
}
|
|
5204
5684
|
|
|
5205
5685
|
/**
|
|
@@ -5220,8 +5700,8 @@ function Tr(t, e, n, ...r) {
|
|
|
5220
5700
|
* @param n - The value to increment by.
|
|
5221
5701
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5222
5702
|
* `updateDoc()`
|
|
5223
|
-
*/ function
|
|
5224
|
-
return new
|
|
5703
|
+
*/ function qr(t) {
|
|
5704
|
+
return new Mn("increment", t);
|
|
5225
5705
|
}
|
|
5226
5706
|
|
|
5227
5707
|
/**
|
|
@@ -5247,25 +5727,25 @@ function Tr(t, e, n, ...r) {
|
|
|
5247
5727
|
* provides methods for adding writes to the write batch. None of the writes
|
|
5248
5728
|
* will be committed (or visible locally) until {@link WriteBatch.commit} is
|
|
5249
5729
|
* called.
|
|
5250
|
-
*/ class
|
|
5730
|
+
*/ class Or {
|
|
5251
5731
|
/** @hideconstructor */
|
|
5252
5732
|
constructor(t, e) {
|
|
5253
5733
|
this._firestore = t, this._commitHandler = e, this._mutations = [], this._committed = !1,
|
|
5254
|
-
this._dataReader =
|
|
5734
|
+
this._dataReader = Fn(t);
|
|
5255
5735
|
}
|
|
5256
5736
|
set(t, e, n) {
|
|
5257
5737
|
this._verifyNotCommitted();
|
|
5258
|
-
const r =
|
|
5259
|
-
return this._mutations.push(i.toMutation(r._key,
|
|
5738
|
+
const r = kr(t, this._firestore), s = Tr(r.converter, e, n), i = Sn(this._dataReader, "WriteBatch.set", r._key, s, null !== r.converter, n);
|
|
5739
|
+
return this._mutations.push(i.toMutation(r._key, Re.none())), this;
|
|
5260
5740
|
}
|
|
5261
5741
|
update(t, e, n, ...r) {
|
|
5262
5742
|
this._verifyNotCommitted();
|
|
5263
|
-
const s =
|
|
5743
|
+
const s = kr(t, this._firestore);
|
|
5264
5744
|
// For Compat types, we have to "extract" the underlying types before
|
|
5265
5745
|
// performing validation.
|
|
5266
5746
|
let i;
|
|
5267
|
-
return i = "string" == typeof (e = getModularInstance(e)) || e instanceof
|
|
5268
|
-
this._mutations.push(i.toMutation(s._key,
|
|
5747
|
+
return i = "string" == typeof (e = getModularInstance(e)) || e instanceof En ? jn(this._dataReader, "WriteBatch.update", s._key, e, n, r) : Un(this._dataReader, "WriteBatch.update", s._key, e),
|
|
5748
|
+
this._mutations.push(i.toMutation(s._key, Re.exists(!0))), this;
|
|
5269
5749
|
}
|
|
5270
5750
|
/**
|
|
5271
5751
|
* Deletes the document referred to by the provided {@link DocumentReference}.
|
|
@@ -5274,8 +5754,8 @@ function Tr(t, e, n, ...r) {
|
|
|
5274
5754
|
* @returns This `WriteBatch` instance. Used for chaining method calls.
|
|
5275
5755
|
*/ delete(t) {
|
|
5276
5756
|
this._verifyNotCommitted();
|
|
5277
|
-
const e =
|
|
5278
|
-
return this._mutations = this._mutations.concat(new
|
|
5757
|
+
const e = kr(t, this._firestore);
|
|
5758
|
+
return this._mutations = this._mutations.concat(new De(e._key, Re.none())), this;
|
|
5279
5759
|
}
|
|
5280
5760
|
/**
|
|
5281
5761
|
* Commits all of the writes in this write batch as a single atomic unit.
|
|
@@ -5292,12 +5772,12 @@ function Tr(t, e, n, ...r) {
|
|
|
5292
5772
|
return this._verifyNotCommitted(), this._committed = !0, this._mutations.length > 0 ? this._commitHandler(this._mutations) : Promise.resolve();
|
|
5293
5773
|
}
|
|
5294
5774
|
_verifyNotCommitted() {
|
|
5295
|
-
if (this._committed) throw new
|
|
5775
|
+
if (this._committed) throw new L(x, "A write batch can no longer be used after commit() has been called.");
|
|
5296
5776
|
}
|
|
5297
5777
|
}
|
|
5298
5778
|
|
|
5299
|
-
function
|
|
5300
|
-
if ((t = getModularInstance(t)).firestore !== e) throw new
|
|
5779
|
+
function kr(t, e) {
|
|
5780
|
+
if ((t = getModularInstance(t)).firestore !== e) throw new L(A, "Provided document reference is from a different Firestore instance.");
|
|
5301
5781
|
return t;
|
|
5302
5782
|
}
|
|
5303
5783
|
|
|
@@ -5313,9 +5793,9 @@ function Sr(t, e) {
|
|
|
5313
5793
|
*
|
|
5314
5794
|
* @returns A `WriteBatch` that can be used to atomically execute multiple
|
|
5315
5795
|
* writes.
|
|
5316
|
-
*/ function
|
|
5317
|
-
const e =
|
|
5318
|
-
return new
|
|
5796
|
+
*/ function Cr(t) {
|
|
5797
|
+
const e = un(t = ot(t, an));
|
|
5798
|
+
return new Or(t, (t => nn(e, t)));
|
|
5319
5799
|
}
|
|
5320
5800
|
|
|
5321
5801
|
/**
|
|
@@ -5337,7 +5817,7 @@ function Sr(t, e) {
|
|
|
5337
5817
|
/**
|
|
5338
5818
|
* Internal transaction object responsible for accumulating the mutations to
|
|
5339
5819
|
* perform and the base versions for any documents read.
|
|
5340
|
-
*/ class
|
|
5820
|
+
*/ class Lr {
|
|
5341
5821
|
constructor(t) {
|
|
5342
5822
|
this.datastore = t,
|
|
5343
5823
|
// The version of each document that was read during this transaction.
|
|
@@ -5356,8 +5836,8 @@ function Sr(t, e) {
|
|
|
5356
5836
|
this.writtenDocs = new Set;
|
|
5357
5837
|
}
|
|
5358
5838
|
async lookup(t) {
|
|
5359
|
-
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new
|
|
5360
|
-
const e = await
|
|
5839
|
+
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new L(A, "Firestore transactions require all reads to be executed before all writes.");
|
|
5840
|
+
const e = await rn(this.datastore, t);
|
|
5361
5841
|
return e.forEach((t => this.recordVersion(t))), e;
|
|
5362
5842
|
}
|
|
5363
5843
|
set(t, e) {
|
|
@@ -5372,7 +5852,7 @@ function Sr(t, e) {
|
|
|
5372
5852
|
this.writtenDocs.add(t.toString());
|
|
5373
5853
|
}
|
|
5374
5854
|
delete(t) {
|
|
5375
|
-
this.write(new
|
|
5855
|
+
this.write(new De(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5376
5856
|
}
|
|
5377
5857
|
async commit() {
|
|
5378
5858
|
if (this.ensureCommitNotCalled(), this.lastWriteError) throw this.lastWriteError;
|
|
@@ -5385,21 +5865,21 @@ function Sr(t, e) {
|
|
|
5385
5865
|
// a `verify` operation.
|
|
5386
5866
|
t.forEach(((t, e) => {
|
|
5387
5867
|
const n = et.fromPath(e);
|
|
5388
|
-
this.mutations.push(new
|
|
5389
|
-
})), await
|
|
5868
|
+
this.mutations.push(new $e(n, this.precondition(n)));
|
|
5869
|
+
})), await nn(this.datastore, this.mutations), this.committed = !0;
|
|
5390
5870
|
}
|
|
5391
5871
|
recordVersion(t) {
|
|
5392
5872
|
let e;
|
|
5393
5873
|
if (t.isFoundDocument()) e = t.version; else {
|
|
5394
5874
|
if (!t.isNoDocument()) throw g();
|
|
5395
5875
|
// For deleted docs, we must use baseVersion 0 when we overwrite them.
|
|
5396
|
-
e =
|
|
5876
|
+
e = vt.min();
|
|
5397
5877
|
}
|
|
5398
5878
|
const n = this.readVersions.get(t.key.toString());
|
|
5399
5879
|
if (n) {
|
|
5400
5880
|
if (!e.isEqual(n))
|
|
5401
5881
|
// This transaction will fail no matter what.
|
|
5402
|
-
throw new
|
|
5882
|
+
throw new L(F, "Document version changed between two reads.");
|
|
5403
5883
|
} else this.readVersions.set(t.key.toString(), e);
|
|
5404
5884
|
}
|
|
5405
5885
|
/**
|
|
@@ -5407,7 +5887,7 @@ function Sr(t, e) {
|
|
|
5407
5887
|
* as a precondition, or no precondition if it was not read.
|
|
5408
5888
|
*/ precondition(t) {
|
|
5409
5889
|
const e = this.readVersions.get(t.toString());
|
|
5410
|
-
return !this.writtenDocs.has(t.toString()) && e ?
|
|
5890
|
+
return !this.writtenDocs.has(t.toString()) && e ? Re.updateTime(e) : Re.none();
|
|
5411
5891
|
}
|
|
5412
5892
|
/**
|
|
5413
5893
|
* Returns the precondition for a document if the operation is an update.
|
|
@@ -5416,7 +5896,7 @@ function Sr(t, e) {
|
|
|
5416
5896
|
// The first time a document is written, we want to take into account the
|
|
5417
5897
|
// read time and existence
|
|
5418
5898
|
if (!this.writtenDocs.has(t.toString()) && e) {
|
|
5419
|
-
if (e.isEqual(
|
|
5899
|
+
if (e.isEqual(vt.min()))
|
|
5420
5900
|
// The document doesn't exist, so fail the transaction.
|
|
5421
5901
|
// This has to be validated locally because you can't send a
|
|
5422
5902
|
// precondition that a document does not exist without changing the
|
|
@@ -5426,13 +5906,13 @@ function Sr(t, e) {
|
|
|
5426
5906
|
// express that to the backend, we have to validate locally.
|
|
5427
5907
|
// Note: this can change once we can send separate verify writes in the
|
|
5428
5908
|
// transaction.
|
|
5429
|
-
throw new
|
|
5909
|
+
throw new L(A, "Can't update a document that doesn't exist.");
|
|
5430
5910
|
// Document exists, base precondition on document update time.
|
|
5431
|
-
return
|
|
5911
|
+
return Re.updateTime(e);
|
|
5432
5912
|
}
|
|
5433
5913
|
// Document was not read, so we just use the preconditions for a blind
|
|
5434
5914
|
// update.
|
|
5435
|
-
return
|
|
5915
|
+
return Re.exists(!0);
|
|
5436
5916
|
}
|
|
5437
5917
|
write(t) {
|
|
5438
5918
|
this.ensureCommitNotCalled(), this.mutations.push(t);
|
|
@@ -5455,7 +5935,7 @@ function Sr(t, e) {
|
|
|
5455
5935
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5456
5936
|
* See the License for the specific language governing permissions and
|
|
5457
5937
|
* limitations under the License.
|
|
5458
|
-
*/ const
|
|
5938
|
+
*/ const Mr = {
|
|
5459
5939
|
maxAttempts: 5
|
|
5460
5940
|
};
|
|
5461
5941
|
|
|
@@ -5479,17 +5959,17 @@ function Sr(t, e) {
|
|
|
5479
5959
|
* TransactionRunner encapsulates the logic needed to run and retry transactions
|
|
5480
5960
|
* with backoff.
|
|
5481
5961
|
*/
|
|
5482
|
-
class
|
|
5962
|
+
class Ur {
|
|
5483
5963
|
constructor(t, e, n, r, s) {
|
|
5484
5964
|
this.asyncQueue = t, this.datastore = e, this.options = n, this.updateFunction = r,
|
|
5485
|
-
this.deferred = s, this.Tt = n.maxAttempts, this.
|
|
5965
|
+
this.deferred = s, this.Tt = n.maxAttempts, this.It = new tn(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
|
|
5486
5966
|
}
|
|
5487
5967
|
/** Runs the transaction and sets the result on deferred. */ run() {
|
|
5488
|
-
this.Tt -= 1, this.
|
|
5968
|
+
this.Tt -= 1, this.At();
|
|
5489
5969
|
}
|
|
5490
|
-
|
|
5491
|
-
this.
|
|
5492
|
-
const t = new
|
|
5970
|
+
At() {
|
|
5971
|
+
this.It.W((async () => {
|
|
5972
|
+
const t = new Lr(this.datastore), e = this.Rt(t);
|
|
5493
5973
|
e && e.then((e => {
|
|
5494
5974
|
this.asyncQueue.enqueueAndForget((() => t.commit().then((() => {
|
|
5495
5975
|
this.deferred.resolve(e);
|
|
@@ -5512,7 +5992,7 @@ class Or {
|
|
|
5512
5992
|
}
|
|
5513
5993
|
}
|
|
5514
5994
|
Pt(t) {
|
|
5515
|
-
this.Tt > 0 && this.Vt(t) ? (this.Tt -= 1, this.asyncQueue.enqueueAndForget((() => (this.
|
|
5995
|
+
this.Tt > 0 && this.Vt(t) ? (this.Tt -= 1, this.asyncQueue.enqueueAndForget((() => (this.At(),
|
|
5516
5996
|
Promise.resolve())))) : this.deferred.reject(t);
|
|
5517
5997
|
}
|
|
5518
5998
|
Vt(t) {
|
|
@@ -5533,28 +6013,28 @@ class Or {
|
|
|
5533
6013
|
return g();
|
|
5534
6014
|
|
|
5535
6015
|
case T:
|
|
5536
|
-
case
|
|
6016
|
+
case I:
|
|
5537
6017
|
case R:
|
|
5538
6018
|
case $:
|
|
5539
6019
|
case O:
|
|
5540
|
-
case
|
|
6020
|
+
case k:
|
|
5541
6021
|
// Unauthenticated means something went wrong with our token and we need
|
|
5542
6022
|
// to retry with new credentials which will happen automatically.
|
|
5543
|
-
case
|
|
6023
|
+
case D:
|
|
5544
6024
|
return !1;
|
|
5545
6025
|
|
|
5546
|
-
case
|
|
6026
|
+
case A:
|
|
5547
6027
|
case P:
|
|
5548
6028
|
case V:
|
|
5549
|
-
case
|
|
5550
|
-
case
|
|
6029
|
+
case N:
|
|
6030
|
+
case x:
|
|
5551
6031
|
// Aborted might be retried in some scenarios, but that is dependant on
|
|
5552
6032
|
// the context and should handled individually by the calling code.
|
|
5553
6033
|
// See https://cloud.google.com/apis/design/errors.
|
|
5554
|
-
case
|
|
5555
|
-
case
|
|
6034
|
+
case F:
|
|
6035
|
+
case S:
|
|
5556
6036
|
case q:
|
|
5557
|
-
case
|
|
6037
|
+
case C:
|
|
5558
6038
|
return !0;
|
|
5559
6039
|
}
|
|
5560
6040
|
}(e);
|
|
@@ -5579,7 +6059,7 @@ class Or {
|
|
|
5579
6059
|
* See the License for the specific language governing permissions and
|
|
5580
6060
|
* limitations under the License.
|
|
5581
6061
|
*/
|
|
5582
|
-
/** The Platform's 'document' implementation or null if not available. */ function
|
|
6062
|
+
/** The Platform's 'document' implementation or null if not available. */ function jr() {
|
|
5583
6063
|
// `document` is not always available, e.g. in ReactNative and WebWorkers.
|
|
5584
6064
|
// eslint-disable-next-line no-restricted-globals
|
|
5585
6065
|
return "undefined" != typeof document ? document : null;
|
|
@@ -5611,10 +6091,10 @@ class Or {
|
|
|
5611
6091
|
* Note: We implement `PromiseLike` instead of `Promise`, as the `Promise` type
|
|
5612
6092
|
* in newer versions of TypeScript defines `finally`, which is not available in
|
|
5613
6093
|
* IE.
|
|
5614
|
-
*/ class
|
|
6094
|
+
*/ class Br {
|
|
5615
6095
|
constructor(t, e, n, r, s) {
|
|
5616
6096
|
this.asyncQueue = t, this.timerId = e, this.targetTimeMs = n, this.op = r, this.removalCallback = s,
|
|
5617
|
-
this.deferred = new
|
|
6097
|
+
this.deferred = new M, this.then = this.deferred.promise.then.bind(this.deferred.promise),
|
|
5618
6098
|
// It's normal for the deferred promise to be canceled (due to cancellation)
|
|
5619
6099
|
// and so we attach a dummy catch callback to avoid
|
|
5620
6100
|
// 'UnhandledPromiseRejectionWarning' log spam.
|
|
@@ -5634,7 +6114,7 @@ class Or {
|
|
|
5634
6114
|
* PORTING NOTE: This exists to prevent making removeDelayedOperation() and
|
|
5635
6115
|
* the DelayedOperation class public.
|
|
5636
6116
|
*/ static createAndSchedule(t, e, n, r, s) {
|
|
5637
|
-
const i = Date.now() + n, o = new
|
|
6117
|
+
const i = Date.now() + n, o = new Br(t, e, i, r, s);
|
|
5638
6118
|
return o.start(n), o;
|
|
5639
6119
|
}
|
|
5640
6120
|
/**
|
|
@@ -5656,7 +6136,7 @@ class Or {
|
|
|
5656
6136
|
* As long as the operation has not yet been run, calling cancel() provides a
|
|
5657
6137
|
* guarantee that the operation will not be run.
|
|
5658
6138
|
*/ cancel(t) {
|
|
5659
|
-
null !== this.timerHandle && (this.clearTimeout(), this.deferred.reject(new
|
|
6139
|
+
null !== this.timerHandle && (this.clearTimeout(), this.deferred.reject(new L(T, "Operation cancelled" + (t ? ": " + t : ""))));
|
|
5660
6140
|
}
|
|
5661
6141
|
handleDelayElapsed() {
|
|
5662
6142
|
this.asyncQueue.enqueueAndForget((() => null !== this.timerHandle ? (this.clearTimeout(),
|
|
@@ -5683,39 +6163,39 @@ class Or {
|
|
|
5683
6163
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5684
6164
|
* See the License for the specific language governing permissions and
|
|
5685
6165
|
* limitations under the License.
|
|
5686
|
-
*/ class
|
|
6166
|
+
*/ class zr {
|
|
5687
6167
|
constructor() {
|
|
5688
6168
|
// The last promise in the queue.
|
|
5689
|
-
this.
|
|
6169
|
+
this.Nt = Promise.resolve(),
|
|
5690
6170
|
// A list of retryable operations. Retryable operations are run in order and
|
|
5691
6171
|
// retried with backoff.
|
|
5692
|
-
this.
|
|
6172
|
+
this.Dt = [],
|
|
5693
6173
|
// Is this AsyncQueue being shut down? Once it is set to true, it will not
|
|
5694
6174
|
// be changed again.
|
|
5695
6175
|
this.$t = !1,
|
|
5696
6176
|
// Operations scheduled to be queued in the future. Operations are
|
|
5697
6177
|
// automatically removed after they are run or canceled.
|
|
5698
|
-
this.
|
|
6178
|
+
this.xt = [],
|
|
5699
6179
|
// visible for testing
|
|
5700
|
-
this.
|
|
6180
|
+
this.Ft = null,
|
|
5701
6181
|
// Flag set while there's an outstanding AsyncQueue operation, used for
|
|
5702
6182
|
// assertion sanity-checks.
|
|
5703
|
-
this.
|
|
6183
|
+
this.St = !1,
|
|
5704
6184
|
// Enabled during shutdown on Safari to prevent future access to IndexedDB.
|
|
5705
6185
|
this.qt = !1,
|
|
5706
6186
|
// List of TimerIds to fast-forward delays for.
|
|
5707
6187
|
this.Ot = [],
|
|
5708
6188
|
// Backoff timer used to schedule retries for retryable operations
|
|
5709
|
-
this.
|
|
6189
|
+
this.It = new tn(this, "async_queue_retry" /* AsyncQueueRetry */),
|
|
5710
6190
|
// Visibility handler that triggers an immediate retry of all retryable
|
|
5711
6191
|
// operations. Meant to speed up recovery when we regain file system access
|
|
5712
6192
|
// after page comes into foreground.
|
|
5713
|
-
this.
|
|
5714
|
-
const t =
|
|
5715
|
-
t && m("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.
|
|
6193
|
+
this.kt = () => {
|
|
6194
|
+
const t = jr();
|
|
6195
|
+
t && m("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.It.Y();
|
|
5716
6196
|
};
|
|
5717
|
-
const t =
|
|
5718
|
-
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.
|
|
6197
|
+
const t = jr();
|
|
6198
|
+
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.kt);
|
|
5719
6199
|
}
|
|
5720
6200
|
get isShuttingDown() {
|
|
5721
6201
|
return this.$t;
|
|
@@ -5728,38 +6208,38 @@ class Or {
|
|
|
5728
6208
|
this.enqueue(t);
|
|
5729
6209
|
}
|
|
5730
6210
|
enqueueAndForgetEvenWhileRestricted(t) {
|
|
5731
|
-
this.
|
|
6211
|
+
this.Ct(),
|
|
5732
6212
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
5733
|
-
this.
|
|
6213
|
+
this.Lt(t);
|
|
5734
6214
|
}
|
|
5735
6215
|
enterRestrictedMode(t) {
|
|
5736
6216
|
if (!this.$t) {
|
|
5737
6217
|
this.$t = !0, this.qt = t || !1;
|
|
5738
|
-
const e =
|
|
5739
|
-
e && "function" == typeof e.removeEventListener && e.removeEventListener("visibilitychange", this.
|
|
6218
|
+
const e = jr();
|
|
6219
|
+
e && "function" == typeof e.removeEventListener && e.removeEventListener("visibilitychange", this.kt);
|
|
5740
6220
|
}
|
|
5741
6221
|
}
|
|
5742
6222
|
enqueue(t) {
|
|
5743
|
-
if (this.
|
|
6223
|
+
if (this.Ct(), this.$t)
|
|
5744
6224
|
// Return a Promise which never resolves.
|
|
5745
6225
|
return new Promise((() => {}));
|
|
5746
6226
|
// Create a deferred Promise that we can return to the callee. This
|
|
5747
6227
|
// allows us to return a "hanging Promise" only to the callee and still
|
|
5748
6228
|
// advance the queue even when the operation is not run.
|
|
5749
|
-
const e = new
|
|
5750
|
-
return this.
|
|
6229
|
+
const e = new M;
|
|
6230
|
+
return this.Lt((() => this.$t && this.qt ? Promise.resolve() : (t().then(e.resolve, e.reject),
|
|
5751
6231
|
e.promise))).then((() => e.promise));
|
|
5752
6232
|
}
|
|
5753
6233
|
enqueueRetryable(t) {
|
|
5754
|
-
this.enqueueAndForget((() => (this.
|
|
6234
|
+
this.enqueueAndForget((() => (this.Dt.push(t), this.Mt())));
|
|
5755
6235
|
}
|
|
5756
6236
|
/**
|
|
5757
6237
|
* Runs the next operation from the retryable queue. If the operation fails,
|
|
5758
6238
|
* reschedules with backoff.
|
|
5759
|
-
*/ async
|
|
5760
|
-
if (0 !== this.
|
|
6239
|
+
*/ async Mt() {
|
|
6240
|
+
if (0 !== this.Dt.length) {
|
|
5761
6241
|
try {
|
|
5762
|
-
await this.
|
|
6242
|
+
await this.Dt[0](), this.Dt.shift(), this.It.reset();
|
|
5763
6243
|
} catch (t) {
|
|
5764
6244
|
if (!
|
|
5765
6245
|
/**
|
|
@@ -5803,7 +6283,7 @@ class Or {
|
|
|
5803
6283
|
// Failure will be handled by AsyncQueue
|
|
5804
6284
|
m("AsyncQueue", "Operation failed with retryable error: " + t);
|
|
5805
6285
|
}
|
|
5806
|
-
this.
|
|
6286
|
+
this.Dt.length > 0 &&
|
|
5807
6287
|
// If there are additional operations, we re-schedule `retryNextOp()`.
|
|
5808
6288
|
// This is necessary to run retryable operations that failed during
|
|
5809
6289
|
// their initial attempt since we don't know whether they are already
|
|
@@ -5814,12 +6294,12 @@ class Or {
|
|
|
5814
6294
|
// Since `backoffAndRun()` cancels an existing backoff and schedules a
|
|
5815
6295
|
// new backoff on every call, there is only ever a single additional
|
|
5816
6296
|
// operation in the queue.
|
|
5817
|
-
this.
|
|
6297
|
+
this.It.W((() => this.Mt()));
|
|
5818
6298
|
}
|
|
5819
6299
|
}
|
|
5820
|
-
|
|
5821
|
-
const e = this.
|
|
5822
|
-
this.
|
|
6300
|
+
Lt(t) {
|
|
6301
|
+
const e = this.Nt.then((() => (this.St = !0, t().catch((t => {
|
|
6302
|
+
this.Ft = t, this.St = !1;
|
|
5823
6303
|
const e =
|
|
5824
6304
|
/**
|
|
5825
6305
|
* Chrome includes Error.message in Error.stack. Other browsers do not.
|
|
@@ -5860,38 +6340,38 @@ class Or {
|
|
|
5860
6340
|
// all further attempts to chain (via .then) will just short-circuit
|
|
5861
6341
|
// and return the rejected Promise.
|
|
5862
6342
|
throw p("INTERNAL UNHANDLED ERROR: ", e), t;
|
|
5863
|
-
})).then((t => (this.
|
|
5864
|
-
return this.
|
|
6343
|
+
})).then((t => (this.St = !1, t))))));
|
|
6344
|
+
return this.Nt = e, e;
|
|
5865
6345
|
}
|
|
5866
6346
|
enqueueAfterDelay(t, e, n) {
|
|
5867
|
-
this.
|
|
6347
|
+
this.Ct(),
|
|
5868
6348
|
// Fast-forward delays for timerIds that have been overriden.
|
|
5869
6349
|
this.Ot.indexOf(t) > -1 && (e = 0);
|
|
5870
|
-
const r =
|
|
5871
|
-
return this.
|
|
6350
|
+
const r = Br.createAndSchedule(this, t, e, n, (t => this.Ut(t)));
|
|
6351
|
+
return this.xt.push(r), r;
|
|
5872
6352
|
}
|
|
5873
|
-
|
|
5874
|
-
this.
|
|
6353
|
+
Ct() {
|
|
6354
|
+
this.Ft && g();
|
|
5875
6355
|
}
|
|
5876
6356
|
verifyOperationInProgress() {}
|
|
5877
6357
|
/**
|
|
5878
6358
|
* Waits until all currently queued tasks are finished executing. Delayed
|
|
5879
6359
|
* operations are not run.
|
|
5880
|
-
*/ async
|
|
6360
|
+
*/ async jt() {
|
|
5881
6361
|
// Operations in the queue prior to draining may have enqueued additional
|
|
5882
6362
|
// operations. Keep draining the queue until the tail is no longer advanced,
|
|
5883
6363
|
// which indicates that no more new operations were enqueued and that all
|
|
5884
6364
|
// operations were executed.
|
|
5885
6365
|
let t;
|
|
5886
6366
|
do {
|
|
5887
|
-
t = this.
|
|
5888
|
-
} while (t !== this.
|
|
6367
|
+
t = this.Nt, await t;
|
|
6368
|
+
} while (t !== this.Nt);
|
|
5889
6369
|
}
|
|
5890
6370
|
/**
|
|
5891
6371
|
* For Tests: Determine if a delayed operation with a particular TimerId
|
|
5892
6372
|
* exists.
|
|
5893
6373
|
*/ Bt(t) {
|
|
5894
|
-
for (const e of this.
|
|
6374
|
+
for (const e of this.xt) if (e.timerId === t) return !0;
|
|
5895
6375
|
return !1;
|
|
5896
6376
|
}
|
|
5897
6377
|
/**
|
|
@@ -5902,11 +6382,11 @@ class Or {
|
|
|
5902
6382
|
* @returns a Promise that resolves once all operations have been run.
|
|
5903
6383
|
*/ zt(t) {
|
|
5904
6384
|
// Note that draining may generate more delayed ops, so we do that first.
|
|
5905
|
-
return this.
|
|
6385
|
+
return this.jt().then((() => {
|
|
5906
6386
|
// Run ops in the same order they'd run if they ran naturally.
|
|
5907
|
-
this.
|
|
5908
|
-
for (const e of this.
|
|
5909
|
-
return this.
|
|
6387
|
+
this.xt.sort(((t, e) => t.targetTimeMs - e.targetTimeMs));
|
|
6388
|
+
for (const e of this.xt) if (e.skipDelay(), "all" /* All */ !== t && e.timerId === t) break;
|
|
6389
|
+
return this.jt();
|
|
5910
6390
|
}));
|
|
5911
6391
|
}
|
|
5912
6392
|
/**
|
|
@@ -5914,17 +6394,17 @@ class Or {
|
|
|
5914
6394
|
*/ Gt(t) {
|
|
5915
6395
|
this.Ot.push(t);
|
|
5916
6396
|
}
|
|
5917
|
-
/** Called once a DelayedOperation is run or canceled. */
|
|
6397
|
+
/** Called once a DelayedOperation is run or canceled. */ Ut(t) {
|
|
5918
6398
|
// NOTE: indexOf / slice are O(n), but delayedOperations is expected to be small.
|
|
5919
|
-
const e = this.
|
|
5920
|
-
this.
|
|
6399
|
+
const e = this.xt.indexOf(t);
|
|
6400
|
+
this.xt.splice(e, 1);
|
|
5921
6401
|
}
|
|
5922
6402
|
}
|
|
5923
6403
|
|
|
5924
|
-
class
|
|
6404
|
+
class Gr {
|
|
5925
6405
|
/** @hideconstructor */
|
|
5926
6406
|
constructor(t, e) {
|
|
5927
|
-
this._firestore = t, this._transaction = e, this._dataReader =
|
|
6407
|
+
this._firestore = t, this._transaction = e, this._dataReader = Fn(t);
|
|
5928
6408
|
}
|
|
5929
6409
|
/**
|
|
5930
6410
|
* Reads the document referenced by the provided {@link DocumentReference}.
|
|
@@ -5932,25 +6412,25 @@ class kr {
|
|
|
5932
6412
|
* @param documentRef - A reference to the document to be read.
|
|
5933
6413
|
* @returns A `DocumentSnapshot` with the read data.
|
|
5934
6414
|
*/ get(t) {
|
|
5935
|
-
const e =
|
|
6415
|
+
const e = kr(t, this._firestore), n = new Ir(this._firestore);
|
|
5936
6416
|
return this._transaction.lookup([ e._key ]).then((t => {
|
|
5937
6417
|
if (!t || 1 !== t.length) return g();
|
|
5938
6418
|
const r = t[0];
|
|
5939
|
-
if (r.isFoundDocument()) return new
|
|
5940
|
-
if (r.isNoDocument()) return new
|
|
6419
|
+
if (r.isFoundDocument()) return new Zn(this._firestore, n, r.key, r, e.converter);
|
|
6420
|
+
if (r.isNoDocument()) return new Zn(this._firestore, n, e._key, null, e.converter);
|
|
5941
6421
|
throw g();
|
|
5942
6422
|
}));
|
|
5943
6423
|
}
|
|
5944
6424
|
set(t, e, n) {
|
|
5945
|
-
const r =
|
|
6425
|
+
const r = kr(t, this._firestore), s = Tr(r.converter, e, n), i = Sn(this._dataReader, "Transaction.set", r._key, s, null !== r.converter, n);
|
|
5946
6426
|
return this._transaction.set(r._key, i), this;
|
|
5947
6427
|
}
|
|
5948
6428
|
update(t, e, n, ...r) {
|
|
5949
|
-
const s =
|
|
6429
|
+
const s = kr(t, this._firestore);
|
|
5950
6430
|
// For Compat types, we have to "extract" the underlying types before
|
|
5951
6431
|
// performing validation.
|
|
5952
6432
|
let i;
|
|
5953
|
-
return i = "string" == typeof (e = getModularInstance(e)) || e instanceof
|
|
6433
|
+
return i = "string" == typeof (e = getModularInstance(e)) || e instanceof En ? jn(this._dataReader, "Transaction.update", s._key, e, n, r) : Un(this._dataReader, "Transaction.update", s._key, e),
|
|
5954
6434
|
this._transaction.update(s._key, i), this;
|
|
5955
6435
|
}
|
|
5956
6436
|
/**
|
|
@@ -5959,7 +6439,7 @@ class kr {
|
|
|
5959
6439
|
* @param documentRef - A reference to the document to be deleted.
|
|
5960
6440
|
* @returns This `Transaction` instance. Used for chaining method calls.
|
|
5961
6441
|
*/ delete(t) {
|
|
5962
|
-
const e =
|
|
6442
|
+
const e = kr(t, this._firestore);
|
|
5963
6443
|
return this._transaction.delete(e._key), this;
|
|
5964
6444
|
}
|
|
5965
6445
|
}
|
|
@@ -5976,17 +6456,19 @@ class kr {
|
|
|
5976
6456
|
* transaction against.
|
|
5977
6457
|
* @param updateFunction - The function to execute within the transaction
|
|
5978
6458
|
* context.
|
|
6459
|
+
* @param options - An options object to configure maximum number of attempts to
|
|
6460
|
+
* commit.
|
|
5979
6461
|
* @returns If the transaction completed successfully or was explicitly aborted
|
|
5980
6462
|
* (the `updateFunction` returned a failed promise), the promise returned by the
|
|
5981
6463
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
5982
6464
|
* rejected promise with the corresponding failure error is returned.
|
|
5983
|
-
*/ function
|
|
5984
|
-
const r =
|
|
6465
|
+
*/ function Wr(t, e, n) {
|
|
6466
|
+
const r = un(t = ot(t, an)), s = Object.assign(Object.assign({}, Mr), n);
|
|
5985
6467
|
!function(t) {
|
|
5986
|
-
if (t.maxAttempts < 1) throw new
|
|
6468
|
+
if (t.maxAttempts < 1) throw new L(A, "Max attempts must be at least 1");
|
|
5987
6469
|
}(s);
|
|
5988
|
-
const i = new
|
|
5989
|
-
return new
|
|
6470
|
+
const i = new M;
|
|
6471
|
+
return new Ur(new zr, r, s, (n => e(new Gr(t, n))), i).run(), i.promise;
|
|
5990
6472
|
}
|
|
5991
6473
|
|
|
5992
6474
|
/**
|
|
@@ -5999,11 +6481,11 @@ class kr {
|
|
|
5999
6481
|
*/ !function(t) {
|
|
6000
6482
|
f = t;
|
|
6001
6483
|
}(`${SDK_VERSION}_lite`), _registerComponent(new Component("firestore/lite", ((t, {options: e}) => {
|
|
6002
|
-
const n = t.getProvider("app").getImmediate(), r = new
|
|
6484
|
+
const n = t.getProvider("app").getImmediate(), r = new an(n, new z(t.getProvider("auth-internal")), new Q(t.getProvider("app-check-internal")));
|
|
6003
6485
|
return e && r._setSettings(e), r;
|
|
6004
6486
|
}), "PUBLIC")),
|
|
6005
6487
|
// RUNTIME_ENV and BUILD_TARGET are replaced by real values during the compilation
|
|
6006
|
-
registerVersion("firestore-lite", "3.4.
|
|
6488
|
+
registerVersion("firestore-lite", "3.4.10-canary.ebc17e27f", ""), registerVersion("firestore-lite", "3.4.10-canary.ebc17e27f", "esm2017");
|
|
6007
6489
|
|
|
6008
|
-
export {
|
|
6490
|
+
export { In as Bytes, pn as CollectionReference, wn as DocumentReference, Zn as DocumentSnapshot, En as FieldPath, An as FieldValue, an as Firestore, L as FirestoreError, Rn as GeoPoint, mn as Query, sr as QueryConstraint, tr as QueryDocumentSnapshot, er as QuerySnapshot, gt as Timestamp, Gr as Transaction, Or as WriteBatch, Dr as addDoc, Sr as arrayRemove, Fr as arrayUnion, yn as collection, _n as collectionGroup, fn as connectFirestoreEmulator, Nr as deleteDoc, $r as deleteField, gn as doc, Tn as documentId, _r as endAt, yr as endBefore, Ar as getDoc, Rr as getDocs, ln as getFirestore, qr as increment, hn as initializeFirestore, lr as limit, fr as limitToLast, ar as orderBy, ir as query, bn as queryEqual, vn as refEqual, Wr as runTransaction, xr as serverTimestamp, Pr as setDoc, w as setLogLevel, nr as snapshotEqual, mr as startAfter, wr as startAt, dn as terminate, Vr as updateDoc, ur as where, Cr as writeBatch };
|
|
6009
6491
|
//# sourceMappingURL=index.browser.esm2017.js.map
|