@firebase/firestore 3.4.8 → 3.4.9
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 +10 -0
- package/dist/firestore/lite/index.d.ts +1 -0
- package/dist/firestore/src/api/transaction.d.ts +2 -1
- package/dist/firestore/src/api/transaction_options.d.ts +17 -0
- package/dist/firestore/src/api.d.ts +1 -0
- package/dist/firestore/src/core/firestore_client.d.ts +2 -1
- package/dist/firestore/src/core/query.d.ts +2 -4
- package/dist/firestore/src/core/target.d.ts +6 -4
- package/dist/firestore/src/core/transaction_options.d.ts +25 -0
- package/dist/firestore/src/core/transaction_runner.d.ts +3 -2
- package/dist/firestore/src/lite-api/transaction.d.ts +2 -1
- package/dist/firestore/src/lite-api/transaction_options.d.ts +23 -0
- package/dist/firestore/src/local/index_manager.d.ts +24 -3
- package/dist/firestore/src/local/indexeddb_index_manager.d.ts +4 -7
- package/dist/firestore/src/local/indexeddb_schema.d.ts +1 -0
- package/dist/firestore/src/local/local_documents_view.d.ts +1 -1
- package/dist/firestore/src/local/memory_index_manager.d.ts +3 -2
- package/dist/firestore/src/local/query_engine.d.ts +44 -5
- package/dist/firestore/src/model/collections.d.ts +1 -1
- package/dist/firestore/src/model/values.d.ts +14 -2
- package/dist/firestore/src/util/misc.d.ts +3 -0
- package/dist/firestore/test/unit/local/counting_query_engine.d.ts +2 -1
- package/dist/firestore/test/unit/local/test_index_manager.d.ts +2 -2
- package/dist/index.d.ts +24 -1
- package/dist/index.esm2017.js +4108 -3992
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +4198 -4087
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +1711 -1565
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +1711 -1565
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +4100 -3984
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +50 -4
- package/dist/lite/firestore/lite/index.d.ts +1 -0
- package/dist/lite/firestore/src/api/transaction.d.ts +2 -1
- package/dist/lite/firestore/src/api/transaction_options.d.ts +17 -0
- package/dist/lite/firestore/src/api.d.ts +1 -0
- package/dist/lite/firestore/src/core/firestore_client.d.ts +2 -1
- package/dist/lite/firestore/src/core/query.d.ts +2 -4
- package/dist/lite/firestore/src/core/target.d.ts +6 -4
- package/dist/lite/firestore/src/core/transaction_options.d.ts +25 -0
- package/dist/lite/firestore/src/core/transaction_runner.d.ts +3 -2
- package/dist/lite/firestore/src/lite-api/transaction.d.ts +2 -1
- package/dist/lite/firestore/src/lite-api/transaction_options.d.ts +23 -0
- package/dist/lite/firestore/src/local/index_manager.d.ts +24 -3
- package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +4 -7
- package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +1 -0
- package/dist/lite/firestore/src/local/local_documents_view.d.ts +1 -1
- package/dist/lite/firestore/src/local/memory_index_manager.d.ts +3 -2
- package/dist/lite/firestore/src/local/query_engine.d.ts +44 -5
- package/dist/lite/firestore/src/model/collections.d.ts +1 -1
- package/dist/lite/firestore/src/model/values.d.ts +14 -2
- package/dist/lite/firestore/src/util/misc.d.ts +3 -0
- package/dist/lite/firestore/test/unit/local/counting_query_engine.d.ts +2 -1
- package/dist/lite/firestore/test/unit/local/test_index_manager.d.ts +2 -2
- package/dist/lite/index.browser.esm2017.js +341 -312
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +299 -291
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.d.ts +24 -1
- package/dist/lite/index.node.cjs.js +56 -15
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +56 -15
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +1227 -1198
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +25 -1
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +28 -28
- package/dist/lite/packages/firestore/lite/index.d.ts +1 -0
- package/dist/lite/packages/firestore/src/api/transaction.d.ts +2 -1
- package/dist/lite/packages/firestore/src/api/transaction_options.d.ts +17 -0
- package/dist/lite/packages/firestore/src/api.d.ts +1 -0
- package/dist/lite/packages/firestore/src/core/firestore_client.d.ts +2 -1
- package/dist/lite/packages/firestore/src/core/query.d.ts +2 -4
- package/dist/lite/packages/firestore/src/core/target.d.ts +6 -4
- package/dist/lite/packages/firestore/src/core/transaction_options.d.ts +25 -0
- package/dist/lite/packages/firestore/src/core/transaction_runner.d.ts +3 -2
- package/dist/lite/packages/firestore/src/lite-api/transaction.d.ts +2 -1
- package/dist/lite/packages/firestore/src/lite-api/transaction_options.d.ts +23 -0
- package/dist/lite/packages/firestore/src/local/index_manager.d.ts +24 -3
- package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +4 -7
- package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +1 -0
- package/dist/lite/packages/firestore/src/local/local_documents_view.d.ts +1 -1
- package/dist/lite/packages/firestore/src/local/memory_index_manager.d.ts +3 -2
- package/dist/lite/packages/firestore/src/local/query_engine.d.ts +44 -5
- package/dist/lite/packages/firestore/src/model/collections.d.ts +1 -1
- package/dist/lite/packages/firestore/src/model/values.d.ts +14 -2
- package/dist/lite/packages/firestore/src/util/misc.d.ts +3 -0
- package/dist/lite/packages/firestore/test/unit/local/counting_query_engine.d.ts +2 -1
- package/dist/lite/packages/firestore/test/unit/local/test_index_manager.d.ts +2 -2
- package/dist/lite/private.d.ts +25 -1
- package/dist/packages/firestore/dist/index.esm2017.d.ts +155 -154
- package/dist/packages/firestore/lite/index.d.ts +1 -0
- package/dist/packages/firestore/src/api/transaction.d.ts +2 -1
- package/dist/packages/firestore/src/api/transaction_options.d.ts +17 -0
- package/dist/packages/firestore/src/api.d.ts +1 -0
- package/dist/packages/firestore/src/core/firestore_client.d.ts +2 -1
- package/dist/packages/firestore/src/core/query.d.ts +2 -4
- package/dist/packages/firestore/src/core/target.d.ts +6 -4
- package/dist/packages/firestore/src/core/transaction_options.d.ts +25 -0
- package/dist/packages/firestore/src/core/transaction_runner.d.ts +3 -2
- package/dist/packages/firestore/src/lite-api/transaction.d.ts +2 -1
- package/dist/packages/firestore/src/lite-api/transaction_options.d.ts +23 -0
- package/dist/packages/firestore/src/local/index_manager.d.ts +24 -3
- package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +4 -7
- package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +1 -0
- package/dist/packages/firestore/src/local/local_documents_view.d.ts +1 -1
- package/dist/packages/firestore/src/local/memory_index_manager.d.ts +3 -2
- package/dist/packages/firestore/src/local/query_engine.d.ts +44 -5
- package/dist/packages/firestore/src/model/collections.d.ts +1 -1
- package/dist/packages/firestore/src/model/values.d.ts +14 -2
- package/dist/packages/firestore/src/util/misc.d.ts +3 -0
- package/dist/packages/firestore/test/unit/local/counting_query_engine.d.ts +2 -1
- package/dist/packages/firestore/test/unit/local/test_index_manager.d.ts +2 -2
- package/dist/private.d.ts +50 -4
- package/package.json +7 -7
|
@@ -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.
|
|
66
|
+
let f = "9.8.0";
|
|
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 b(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 v(t,
|
|
201
201
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
202
202
|
e) {
|
|
203
203
|
return t;
|
|
@@ -218,7 +218,7 @@ 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", A = "unknown", I = "invalid-argument", R = "deadline-exceeded", P = "not-found", V = "already-exists", D = "permission-denied", N = "unauthenticated", $ = "resource-exhausted", S = "failed-precondition", x = "aborted", F = "out-of-range", q = "unimplemented", O = "internal", C = "unavailable", L = "data-loss";
|
|
222
222
|
|
|
223
223
|
/** An error returned by a Firestore operation. */ class U extends FirebaseError {
|
|
224
224
|
/** @hideconstructor */
|
|
@@ -332,7 +332,7 @@ e) {
|
|
|
332
332
|
}));
|
|
333
333
|
}
|
|
334
334
|
getToken() {
|
|
335
|
-
return this.auth ? this.auth.getToken().then((t => t ? (
|
|
335
|
+
return this.auth ? this.auth.getToken().then((t => t ? (b("string" == typeof t.accessToken),
|
|
336
336
|
new j(t.accessToken, new l(this.auth.getUid()))) : null)) : Promise.resolve(null);
|
|
337
337
|
}
|
|
338
338
|
invalidateToken() {}
|
|
@@ -386,7 +386,7 @@ class W {
|
|
|
386
386
|
}));
|
|
387
387
|
}
|
|
388
388
|
getToken() {
|
|
389
|
-
return this.appCheck ? this.appCheck.getToken().then((t => t ? (
|
|
389
|
+
return this.appCheck ? this.appCheck.getToken().then((t => t ? (b("string" == typeof t.token),
|
|
390
390
|
new W(t.token)) : null)) : Promise.resolve(null);
|
|
391
391
|
}
|
|
392
392
|
invalidateToken() {}
|
|
@@ -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 U(
|
|
573
|
+
if (n.indexOf("//") >= 0) throw new U(I, `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 U(
|
|
629
|
+
if (0 === n.length) throw new U(I, `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 U(
|
|
636
|
+
if (r + 1 === t.length) throw new U(I, "Path has trailing escape character: " + t);
|
|
637
637
|
const e = t[r + 1];
|
|
638
|
-
if ("\\" !== e && "." !== e && "`" !== e) throw new U(
|
|
638
|
+
if ("\\" !== e && "." !== e && "`" !== e) throw new U(I, "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 U(
|
|
642
|
+
if (s(), i) throw new U(I, "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 U(
|
|
731
|
+
if (!n) throw new U(I, `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 U(
|
|
743
|
+
if (!et.isDocumentKey(t)) throw new U(I, `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 U(
|
|
750
|
+
if (et.isDocumentKey(t)) throw new U(I, `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 U(
|
|
794
|
+
if (e.name === t.constructor.name) throw new U(I, "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 U(
|
|
797
|
+
throw new U(I, `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 U(
|
|
804
|
+
if (e <= 0) throw new U(I, `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"), A;
|
|
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.
|
|
@@ -932,13 +932,13 @@ function dt(t) {
|
|
|
932
932
|
|
|
933
933
|
case 409:
|
|
934
934
|
// Conflict
|
|
935
|
-
return
|
|
935
|
+
return x;
|
|
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 F;
|
|
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 A;
|
|
954
954
|
|
|
955
955
|
// Other possibilities:
|
|
956
956
|
// return Code.INTERNAL;
|
|
@@ -968,7 +968,7 @@ function dt(t) {
|
|
|
968
968
|
return R;
|
|
969
969
|
|
|
970
970
|
default:
|
|
971
|
-
return t >= 200 && t < 300 ? E : t >= 400 && t < 500 ? S : t >= 500 && t < 600 ? O :
|
|
971
|
+
return t >= 200 && t < 300 ? E : t >= 400 && t < 500 ? S : t >= 500 && t < 600 ? O : A;
|
|
972
972
|
}
|
|
973
973
|
}
|
|
974
974
|
|
|
@@ -1048,16 +1048,16 @@ 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.A = e;
|
|
1052
1052
|
}
|
|
1053
|
-
|
|
1053
|
+
I(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.A(e, {
|
|
1061
1061
|
method: "POST",
|
|
1062
1062
|
headers: n,
|
|
1063
1063
|
body: s
|
|
@@ -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 U(
|
|
1215
|
-
if (e >= 1e9) throw new U(
|
|
1216
|
-
if (t < -62135596800) throw new U(
|
|
1214
|
+
if (this.seconds = t, this.nanoseconds = e, e < 0) throw new U(I, "Timestamp nanoseconds out of range: " + e);
|
|
1215
|
+
if (e >= 1e9) throw new U(I, "Timestamp nanoseconds out of range: " + e);
|
|
1216
|
+
if (t < -62135596800) throw new U(I, "Timestamp seconds out of range: " + t);
|
|
1217
1217
|
// This will break in the year 10,000.
|
|
1218
|
-
if (t >= 253402300800) throw new U(
|
|
1218
|
+
if (t >= 253402300800) throw new U(I, "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 bt {
|
|
1324
1324
|
constructor(t) {
|
|
1325
1325
|
this.timestamp = t;
|
|
1326
1326
|
}
|
|
1327
1327
|
static fromTimestamp(t) {
|
|
1328
|
-
return new
|
|
1328
|
+
return new bt(t);
|
|
1329
1329
|
}
|
|
1330
1330
|
static min() {
|
|
1331
|
-
return new
|
|
1331
|
+
return new bt(new gt(0, 0));
|
|
1332
1332
|
}
|
|
1333
1333
|
static max() {
|
|
1334
|
-
return new
|
|
1334
|
+
return new bt(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 vt(t) {
|
|
1370
1370
|
let e = 0;
|
|
1371
1371
|
for (const n in t) Object.prototype.hasOwnProperty.call(t, n) && e++;
|
|
1372
1372
|
return e;
|
|
@@ -1465,13 +1465,13 @@ class Tt {
|
|
|
1465
1465
|
* before being sent as a proto.
|
|
1466
1466
|
* @internal
|
|
1467
1467
|
*/
|
|
1468
|
-
class
|
|
1468
|
+
class At {
|
|
1469
1469
|
constructor(t) {
|
|
1470
1470
|
this.binaryString = t;
|
|
1471
1471
|
}
|
|
1472
1472
|
static fromBase64String(t) {
|
|
1473
1473
|
const e = atob(t);
|
|
1474
|
-
return new
|
|
1474
|
+
return new At(e);
|
|
1475
1475
|
}
|
|
1476
1476
|
static fromUint8Array(t) {
|
|
1477
1477
|
// TODO(indexing); Remove the copy of the byte string here as this method
|
|
@@ -1488,7 +1488,7 @@ class It {
|
|
|
1488
1488
|
/**
|
|
1489
1489
|
* Helper function to convert a binary string to an Uint8Array.
|
|
1490
1490
|
*/ (t);
|
|
1491
|
-
return new
|
|
1491
|
+
return new At(e);
|
|
1492
1492
|
}
|
|
1493
1493
|
[Symbol.iterator]() {
|
|
1494
1494
|
let t = 0;
|
|
@@ -1543,9 +1543,9 @@ class It {
|
|
|
1543
1543
|
}
|
|
1544
1544
|
}
|
|
1545
1545
|
|
|
1546
|
-
|
|
1546
|
+
At.EMPTY_BYTE_STRING = new At("");
|
|
1547
1547
|
|
|
1548
|
-
const
|
|
1548
|
+
const It = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
1549
1549
|
|
|
1550
1550
|
/**
|
|
1551
1551
|
* Converts the possible Proto values for a timestamp value into a "seconds and
|
|
@@ -1554,13 +1554,13 @@ const At = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1554
1554
|
// The json interface (for the browser) will return an iso timestamp string,
|
|
1555
1555
|
// while the proto js library (for node) will return a
|
|
1556
1556
|
// google.protobuf.Timestamp instance.
|
|
1557
|
-
if (
|
|
1557
|
+
if (b(!!t), "string" == typeof t) {
|
|
1558
1558
|
// The date string can have higher precision (nanos) than the Date class
|
|
1559
1559
|
// (millis), so we do some custom parsing here.
|
|
1560
1560
|
// Parse the nanos right out of the string.
|
|
1561
1561
|
let e = 0;
|
|
1562
|
-
const n =
|
|
1563
|
-
if (
|
|
1562
|
+
const n = It.exec(t);
|
|
1563
|
+
if (b(!!n), n[1]) {
|
|
1564
1564
|
// Pad the fraction out to 9 digits (nanos).
|
|
1565
1565
|
let t = n[1];
|
|
1566
1566
|
t = (t + "000000000").substr(0, 9), e = Number(t);
|
|
@@ -1587,7 +1587,7 @@ const At = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1587
1587
|
}
|
|
1588
1588
|
|
|
1589
1589
|
/** Converts the possible Proto types for Blobs into a ByteString. */ function Vt(t) {
|
|
1590
|
-
return "string" == typeof t ?
|
|
1590
|
+
return "string" == typeof t ? At.fromBase64String(t) : At.fromUint8Array(t);
|
|
1591
1591
|
}
|
|
1592
1592
|
|
|
1593
1593
|
/**
|
|
@@ -1660,9 +1660,16 @@ const At = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1660
1660
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1661
1661
|
* See the License for the specific language governing permissions and
|
|
1662
1662
|
* limitations under the License.
|
|
1663
|
-
*/
|
|
1663
|
+
*/ const St = {
|
|
1664
|
+
fields: {
|
|
1665
|
+
__type__: {
|
|
1666
|
+
stringValue: "__max__"
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
};
|
|
1670
|
+
|
|
1664
1671
|
/** Extracts the backend's type order for the provided value. */
|
|
1665
|
-
function
|
|
1672
|
+
function xt(t) {
|
|
1666
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 ? Dt(t) ? 4 /* ServerTimestampValue */ :
|
|
1667
1674
|
/** Returns true if the Value represents the canonical {@link #MAX_VALUE} . */
|
|
1668
1675
|
function(t) {
|
|
@@ -1687,13 +1694,13 @@ function St(t) {
|
|
|
1687
1694
|
/**
|
|
1688
1695
|
* An ObjectValue represents a MapValue in the Firestore Proto and offers the
|
|
1689
1696
|
* ability to add and remove fields (via the ObjectValueBuilder).
|
|
1690
|
-
*/ (t) ?
|
|
1697
|
+
*/ (t) ? 9007199254740991 /* MaxValue */ : 10 /* ObjectValue */ : g();
|
|
1691
1698
|
}
|
|
1692
1699
|
|
|
1693
1700
|
/** Tests `left` and `right` for equality based on the backend semantics. */ function Ft(t, e) {
|
|
1694
1701
|
if (t === e) return !0;
|
|
1695
|
-
const n =
|
|
1696
|
-
if (n !==
|
|
1702
|
+
const n = xt(t);
|
|
1703
|
+
if (n !== xt(e)) return !1;
|
|
1697
1704
|
switch (n) {
|
|
1698
1705
|
case 0 /* NullValue */ :
|
|
1699
1706
|
case 9007199254740991 /* MaxValue */ :
|
|
@@ -1746,7 +1753,7 @@ function St(t) {
|
|
|
1746
1753
|
case 10 /* ObjectValue */ :
|
|
1747
1754
|
return function(t, e) {
|
|
1748
1755
|
const n = t.mapValue.fields || {}, r = e.mapValue.fields || {};
|
|
1749
|
-
if (
|
|
1756
|
+
if (vt(n) !== vt(r)) return !1;
|
|
1750
1757
|
for (const t in n) if (n.hasOwnProperty(t) && (void 0 === r[t] || !Ft(n[t], r[t]))) return !1;
|
|
1751
1758
|
return !0;
|
|
1752
1759
|
}
|
|
@@ -1757,13 +1764,13 @@ function St(t) {
|
|
|
1757
1764
|
}
|
|
1758
1765
|
}
|
|
1759
1766
|
|
|
1760
|
-
function
|
|
1767
|
+
function qt(t, e) {
|
|
1761
1768
|
return void 0 !== (t.values || []).find((t => Ft(t, e)));
|
|
1762
1769
|
}
|
|
1763
1770
|
|
|
1764
|
-
function
|
|
1771
|
+
function Ot(t, e) {
|
|
1765
1772
|
if (t === e) return 0;
|
|
1766
|
-
const n =
|
|
1773
|
+
const n = xt(t), r = xt(e);
|
|
1767
1774
|
if (n !== r) return yt(n, r);
|
|
1768
1775
|
switch (n) {
|
|
1769
1776
|
case 0 /* NullValue */ :
|
|
@@ -1782,10 +1789,10 @@ function qt(t, e) {
|
|
|
1782
1789
|
}(t, e);
|
|
1783
1790
|
|
|
1784
1791
|
case 3 /* TimestampValue */ :
|
|
1785
|
-
return
|
|
1792
|
+
return Ct(t.timestampValue, e.timestampValue);
|
|
1786
1793
|
|
|
1787
1794
|
case 4 /* ServerTimestampValue */ :
|
|
1788
|
-
return
|
|
1795
|
+
return Ct($t(t), $t(e));
|
|
1789
1796
|
|
|
1790
1797
|
case 5 /* StringValue */ :
|
|
1791
1798
|
return yt(t.stringValue, e.stringValue);
|
|
@@ -1817,7 +1824,7 @@ function qt(t, e) {
|
|
|
1817
1824
|
return function(t, e) {
|
|
1818
1825
|
const n = t.values || [], r = e.values || [];
|
|
1819
1826
|
for (let t = 0; t < n.length && t < r.length; ++t) {
|
|
1820
|
-
const e =
|
|
1827
|
+
const e = Ot(n[t], r[t]);
|
|
1821
1828
|
if (e) return e;
|
|
1822
1829
|
}
|
|
1823
1830
|
return yt(n.length, r.length);
|
|
@@ -1825,6 +1832,9 @@ function qt(t, e) {
|
|
|
1825
1832
|
|
|
1826
1833
|
case 10 /* ObjectValue */ :
|
|
1827
1834
|
return function(t, e) {
|
|
1835
|
+
if (t === St && e === St) return 0;
|
|
1836
|
+
if (t === St) return 1;
|
|
1837
|
+
if (e === St) return -1;
|
|
1828
1838
|
const n = t.fields || {}, r = Object.keys(n), s = e.fields || {}, i = Object.keys(s);
|
|
1829
1839
|
// Even though MapValues are likely sorted correctly based on their insertion
|
|
1830
1840
|
// order (e.g. when received from the backend), local modifications can bring
|
|
@@ -1834,7 +1844,7 @@ function qt(t, e) {
|
|
|
1834
1844
|
for (let t = 0; t < r.length && t < i.length; ++t) {
|
|
1835
1845
|
const e = yt(r[t], i[t]);
|
|
1836
1846
|
if (0 !== e) return e;
|
|
1837
|
-
const o =
|
|
1847
|
+
const o = Ot(n[r[t]], s[i[t]]);
|
|
1838
1848
|
if (0 !== o) return o;
|
|
1839
1849
|
}
|
|
1840
1850
|
return yt(r.length, i.length);
|
|
@@ -1846,35 +1856,35 @@ function qt(t, e) {
|
|
|
1846
1856
|
}
|
|
1847
1857
|
}
|
|
1848
1858
|
|
|
1849
|
-
function
|
|
1859
|
+
function Ct(t, e) {
|
|
1850
1860
|
if ("string" == typeof t && "string" == typeof e && t.length === e.length) return yt(t, e);
|
|
1851
1861
|
const n = Rt(t), r = Rt(e), s = yt(n.seconds, r.seconds);
|
|
1852
1862
|
return 0 !== s ? s : yt(n.nanos, r.nanos);
|
|
1853
1863
|
}
|
|
1854
1864
|
|
|
1855
|
-
function
|
|
1865
|
+
function Lt(t, e) {
|
|
1856
1866
|
return {
|
|
1857
1867
|
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${e.path.canonicalString()}`
|
|
1858
1868
|
};
|
|
1859
1869
|
}
|
|
1860
1870
|
|
|
1861
|
-
/** Returns true if `value` is an ArrayValue. */ function
|
|
1871
|
+
/** Returns true if `value` is an ArrayValue. */ function Ut(t) {
|
|
1862
1872
|
return !!t && "arrayValue" in t;
|
|
1863
1873
|
}
|
|
1864
1874
|
|
|
1865
|
-
/** Returns true if `value` is a NullValue. */ function
|
|
1875
|
+
/** Returns true if `value` is a NullValue. */ function kt(t) {
|
|
1866
1876
|
return !!t && "nullValue" in t;
|
|
1867
1877
|
}
|
|
1868
1878
|
|
|
1869
|
-
/** Returns true if `value` is NaN. */ function
|
|
1879
|
+
/** Returns true if `value` is NaN. */ function jt(t) {
|
|
1870
1880
|
return !!t && "doubleValue" in t && isNaN(Number(t.doubleValue));
|
|
1871
1881
|
}
|
|
1872
1882
|
|
|
1873
|
-
/** Returns true if `value` is a MapValue. */ function
|
|
1883
|
+
/** Returns true if `value` is a MapValue. */ function Mt(t) {
|
|
1874
1884
|
return !!t && "mapValue" in t;
|
|
1875
1885
|
}
|
|
1876
1886
|
|
|
1877
|
-
/** Creates a deep copy of `source`. */ function
|
|
1887
|
+
/** Creates a deep copy of `source`. */ function Bt(t) {
|
|
1878
1888
|
if (t.geoPointValue) return {
|
|
1879
1889
|
geoPointValue: Object.assign({}, t.geoPointValue)
|
|
1880
1890
|
};
|
|
@@ -1887,7 +1897,7 @@ function Ct(t, e) {
|
|
|
1887
1897
|
fields: {}
|
|
1888
1898
|
}
|
|
1889
1899
|
};
|
|
1890
|
-
return Et(t.mapValue.fields, ((t, n) => e.mapValue.fields[t] =
|
|
1900
|
+
return Et(t.mapValue.fields, ((t, n) => e.mapValue.fields[t] = Bt(n))), e;
|
|
1891
1901
|
}
|
|
1892
1902
|
if (t.arrayValue) {
|
|
1893
1903
|
const e = {
|
|
@@ -1895,18 +1905,18 @@ function Ct(t, e) {
|
|
|
1895
1905
|
values: []
|
|
1896
1906
|
}
|
|
1897
1907
|
};
|
|
1898
|
-
for (let n = 0; n < (t.arrayValue.values || []).length; ++n) e.arrayValue.values[n] =
|
|
1908
|
+
for (let n = 0; n < (t.arrayValue.values || []).length; ++n) e.arrayValue.values[n] = Bt(t.arrayValue.values[n]);
|
|
1899
1909
|
return e;
|
|
1900
1910
|
}
|
|
1901
1911
|
return Object.assign({}, t);
|
|
1902
1912
|
}
|
|
1903
1913
|
|
|
1904
|
-
class
|
|
1914
|
+
class zt {
|
|
1905
1915
|
constructor(t) {
|
|
1906
1916
|
this.value = t;
|
|
1907
1917
|
}
|
|
1908
1918
|
static empty() {
|
|
1909
|
-
return new
|
|
1919
|
+
return new zt({
|
|
1910
1920
|
mapValue: {}
|
|
1911
1921
|
});
|
|
1912
1922
|
}
|
|
@@ -1920,7 +1930,7 @@ class Bt {
|
|
|
1920
1930
|
{
|
|
1921
1931
|
let e = this.value;
|
|
1922
1932
|
for (let n = 0; n < t.length - 1; ++n) if (e = (e.mapValue.fields || {})[t.get(n)],
|
|
1923
|
-
!
|
|
1933
|
+
!Mt(e)) return null;
|
|
1924
1934
|
return e = (e.mapValue.fields || {})[t.lastSegment()], e || null;
|
|
1925
1935
|
}
|
|
1926
1936
|
}
|
|
@@ -1930,7 +1940,7 @@ class Bt {
|
|
|
1930
1940
|
* @param path - The field path to set.
|
|
1931
1941
|
* @param value - The value to set.
|
|
1932
1942
|
*/ set(t, e) {
|
|
1933
|
-
this.getFieldsMap(t.popLast())[t.lastSegment()] =
|
|
1943
|
+
this.getFieldsMap(t.popLast())[t.lastSegment()] = Bt(e);
|
|
1934
1944
|
}
|
|
1935
1945
|
/**
|
|
1936
1946
|
* Sets the provided fields to the provided values.
|
|
@@ -1944,7 +1954,7 @@ class Bt {
|
|
|
1944
1954
|
const t = this.getFieldsMap(e);
|
|
1945
1955
|
this.applyChanges(t, n, r), n = {}, r = [], e = s.popLast();
|
|
1946
1956
|
}
|
|
1947
|
-
t ? n[s.lastSegment()] =
|
|
1957
|
+
t ? n[s.lastSegment()] = Bt(t) : r.push(s.lastSegment());
|
|
1948
1958
|
}));
|
|
1949
1959
|
const s = this.getFieldsMap(e);
|
|
1950
1960
|
this.applyChanges(s, n, r);
|
|
@@ -1956,7 +1966,7 @@ class Bt {
|
|
|
1956
1966
|
* @param path - The field path to remove.
|
|
1957
1967
|
*/ delete(t) {
|
|
1958
1968
|
const e = this.field(t.popLast());
|
|
1959
|
-
|
|
1969
|
+
Mt(e) && e.mapValue.fields && delete e.mapValue.fields[t.lastSegment()];
|
|
1960
1970
|
}
|
|
1961
1971
|
isEqual(t) {
|
|
1962
1972
|
return Ft(this.value, t.value);
|
|
@@ -1971,7 +1981,7 @@ class Bt {
|
|
|
1971
1981
|
});
|
|
1972
1982
|
for (let n = 0; n < t.length; ++n) {
|
|
1973
1983
|
let r = e.mapValue.fields[t.get(n)];
|
|
1974
|
-
|
|
1984
|
+
Mt(r) && r.mapValue.fields || (r = {
|
|
1975
1985
|
mapValue: {
|
|
1976
1986
|
fields: {}
|
|
1977
1987
|
}
|
|
@@ -1987,7 +1997,7 @@ class Bt {
|
|
|
1987
1997
|
for (const e of n) delete t[e];
|
|
1988
1998
|
}
|
|
1989
1999
|
clone() {
|
|
1990
|
-
return new Bt(
|
|
2000
|
+
return new zt(Bt(this.value));
|
|
1991
2001
|
}
|
|
1992
2002
|
}
|
|
1993
2003
|
|
|
@@ -2016,7 +2026,7 @@ class Bt {
|
|
|
2016
2026
|
* not transition to one of these states even after all mutations have been
|
|
2017
2027
|
* applied, `isValidDocument()` returns false and the document should be removed
|
|
2018
2028
|
* from all views.
|
|
2019
|
-
*/ class
|
|
2029
|
+
*/ class Gt {
|
|
2020
2030
|
constructor(t, e, n, r, s, i) {
|
|
2021
2031
|
this.key = t, this.documentType = e, this.version = n, this.readTime = r, this.data = s,
|
|
2022
2032
|
this.documentState = i;
|
|
@@ -2025,23 +2035,23 @@ class Bt {
|
|
|
2025
2035
|
* Creates a document with no known version or data, but which can serve as
|
|
2026
2036
|
* base document for mutations.
|
|
2027
2037
|
*/ static newInvalidDocument(t) {
|
|
2028
|
-
return new
|
|
2038
|
+
return new Gt(t, 0 /* INVALID */ , bt.min(), bt.min(), zt.empty(), 0 /* SYNCED */);
|
|
2029
2039
|
}
|
|
2030
2040
|
/**
|
|
2031
2041
|
* Creates a new document that is known to exist with the given data at the
|
|
2032
2042
|
* given version.
|
|
2033
2043
|
*/ static newFoundDocument(t, e, n) {
|
|
2034
|
-
return new
|
|
2044
|
+
return new Gt(t, 1 /* FOUND_DOCUMENT */ , e, bt.min(), n, 0 /* SYNCED */);
|
|
2035
2045
|
}
|
|
2036
2046
|
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t, e) {
|
|
2037
|
-
return new
|
|
2047
|
+
return new Gt(t, 2 /* NO_DOCUMENT */ , e, bt.min(), zt.empty(), 0 /* SYNCED */);
|
|
2038
2048
|
}
|
|
2039
2049
|
/**
|
|
2040
2050
|
* Creates a new document that is known to exist at the given version but
|
|
2041
2051
|
* whose data is not known (e.g. a document that was updated without a known
|
|
2042
2052
|
* base document).
|
|
2043
2053
|
*/ static newUnknownDocument(t, e) {
|
|
2044
|
-
return new
|
|
2054
|
+
return new Gt(t, 3 /* UNKNOWN_DOCUMENT */ , e, bt.min(), zt.empty(), 2 /* HAS_COMMITTED_MUTATIONS */);
|
|
2045
2055
|
}
|
|
2046
2056
|
/**
|
|
2047
2057
|
* Changes the document type to indicate that it exists and that its version
|
|
@@ -2054,7 +2064,7 @@ class Bt {
|
|
|
2054
2064
|
* Changes the document type to indicate that it doesn't exist at the given
|
|
2055
2065
|
* version.
|
|
2056
2066
|
*/ convertToNoDocument(t) {
|
|
2057
|
-
return this.version = t, this.documentType = 2 /* NO_DOCUMENT */ , this.data =
|
|
2067
|
+
return this.version = t, this.documentType = 2 /* NO_DOCUMENT */ , this.data = zt.empty(),
|
|
2058
2068
|
this.documentState = 0 /* SYNCED */ , this;
|
|
2059
2069
|
}
|
|
2060
2070
|
/**
|
|
@@ -2062,7 +2072,7 @@ class Bt {
|
|
|
2062
2072
|
* that its data is not known (e.g. a document that was updated without a known
|
|
2063
2073
|
* base document).
|
|
2064
2074
|
*/ convertToUnknownDocument(t) {
|
|
2065
|
-
return this.version = t, this.documentType = 3 /* UNKNOWN_DOCUMENT */ , this.data =
|
|
2075
|
+
return this.version = t, this.documentType = 3 /* UNKNOWN_DOCUMENT */ , this.data = zt.empty(),
|
|
2066
2076
|
this.documentState = 2 /* HAS_COMMITTED_MUTATIONS */ , this;
|
|
2067
2077
|
}
|
|
2068
2078
|
setHasCommittedMutations() {
|
|
@@ -2096,10 +2106,10 @@ class Bt {
|
|
|
2096
2106
|
return 3 /* UNKNOWN_DOCUMENT */ === this.documentType;
|
|
2097
2107
|
}
|
|
2098
2108
|
isEqual(t) {
|
|
2099
|
-
return t instanceof
|
|
2109
|
+
return t instanceof Gt && this.key.isEqual(t.key) && this.version.isEqual(t.version) && this.documentType === t.documentType && this.documentState === t.documentState && this.data.isEqual(t.data);
|
|
2100
2110
|
}
|
|
2101
2111
|
mutableCopy() {
|
|
2102
|
-
return new
|
|
2112
|
+
return new Gt(this.key, this.documentType, this.version, this.readTime, this.data.clone(), this.documentState);
|
|
2103
2113
|
}
|
|
2104
2114
|
toString() {
|
|
2105
2115
|
return `Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`;
|
|
@@ -2123,7 +2133,7 @@ class Bt {
|
|
|
2123
2133
|
* limitations under the License.
|
|
2124
2134
|
*/
|
|
2125
2135
|
// Visible for testing
|
|
2126
|
-
class
|
|
2136
|
+
class Qt {
|
|
2127
2137
|
constructor(t, e = null, n = [], r = [], s = null, i = null, o = null) {
|
|
2128
2138
|
this.path = t, this.collectionGroup = e, this.orderBy = n, this.filters = r, this.limit = s,
|
|
2129
2139
|
this.startAt = i, this.endAt = o, this.P = null;
|
|
@@ -2137,26 +2147,26 @@ class Gt {
|
|
|
2137
2147
|
* NOTE: you should always construct `Target` from `Query.toTarget` instead of
|
|
2138
2148
|
* using this factory method, because `Query` provides an implicit `orderBy`
|
|
2139
2149
|
* property.
|
|
2140
|
-
*/ function
|
|
2141
|
-
return new
|
|
2150
|
+
*/ function Wt(t, e = null, n = [], r = [], s = null, i = null, o = null) {
|
|
2151
|
+
return new Qt(t, e, n, r, s, i, o);
|
|
2142
2152
|
}
|
|
2143
2153
|
|
|
2144
|
-
class
|
|
2154
|
+
class Yt extends class {} {
|
|
2145
2155
|
constructor(t, e, n) {
|
|
2146
2156
|
super(), this.field = t, this.op = e, this.value = n;
|
|
2147
2157
|
}
|
|
2148
2158
|
/**
|
|
2149
2159
|
* Creates a filter based on the provided arguments.
|
|
2150
2160
|
*/ static create(t, e, n) {
|
|
2151
|
-
return t.isKeyField() ? "in" /* IN */ === e || "not-in" /* NOT_IN */ === e ? this.V(t, e, n) : new
|
|
2161
|
+
return t.isKeyField() ? "in" /* IN */ === e || "not-in" /* NOT_IN */ === e ? this.V(t, e, n) : new Ht(t, e, n) : "array-contains" /* ARRAY_CONTAINS */ === e ? new Zt(t, n) : "in" /* IN */ === e ? new te(t, n) : "not-in" /* NOT_IN */ === e ? new ee(t, n) : "array-contains-any" /* ARRAY_CONTAINS_ANY */ === e ? new ne(t, n) : new Yt(t, e, n);
|
|
2152
2162
|
}
|
|
2153
2163
|
static V(t, e, n) {
|
|
2154
|
-
return "in" /* IN */ === e ? new
|
|
2164
|
+
return "in" /* IN */ === e ? new Kt(t, n) : new Jt(t, n);
|
|
2155
2165
|
}
|
|
2156
2166
|
matches(t) {
|
|
2157
2167
|
const e = t.data.field(this.field);
|
|
2158
2168
|
// Types do not have to match in NOT_EQUAL filters.
|
|
2159
|
-
return "!=" /* NOT_EQUAL */ === this.op ? null !== e && this.D(
|
|
2169
|
+
return "!=" /* NOT_EQUAL */ === this.op ? null !== e && this.D(Ot(e, this.value)) : null !== e && xt(this.value) === xt(e) && this.D(Ot(e, this.value));
|
|
2160
2170
|
// Only compare types with matching backend order (such as double and int).
|
|
2161
2171
|
}
|
|
2162
2172
|
D(t) {
|
|
@@ -2189,7 +2199,7 @@ class Wt extends class {} {
|
|
|
2189
2199
|
}
|
|
2190
2200
|
|
|
2191
2201
|
/** Filter that matches on key fields (i.e. '__name__'). */
|
|
2192
|
-
class
|
|
2202
|
+
class Ht extends Yt {
|
|
2193
2203
|
constructor(t, e, n) {
|
|
2194
2204
|
super(t, e, n), this.key = et.fromName(n.referenceValue);
|
|
2195
2205
|
}
|
|
@@ -2199,69 +2209,69 @@ class Yt extends Wt {
|
|
|
2199
2209
|
}
|
|
2200
2210
|
}
|
|
2201
2211
|
|
|
2202
|
-
/** Filter that matches on key fields within an array. */ class
|
|
2212
|
+
/** Filter that matches on key fields within an array. */ class Kt extends Yt {
|
|
2203
2213
|
constructor(t, e) {
|
|
2204
|
-
super(t, "in" /* IN */ , e), this.keys =
|
|
2214
|
+
super(t, "in" /* IN */ , e), this.keys = Xt("in" /* IN */ , e);
|
|
2205
2215
|
}
|
|
2206
2216
|
matches(t) {
|
|
2207
2217
|
return this.keys.some((e => e.isEqual(t.key)));
|
|
2208
2218
|
}
|
|
2209
2219
|
}
|
|
2210
2220
|
|
|
2211
|
-
/** Filter that matches on key fields not present within an array. */ class
|
|
2221
|
+
/** Filter that matches on key fields not present within an array. */ class Jt extends Yt {
|
|
2212
2222
|
constructor(t, e) {
|
|
2213
|
-
super(t, "not-in" /* NOT_IN */ , e), this.keys =
|
|
2223
|
+
super(t, "not-in" /* NOT_IN */ , e), this.keys = Xt("not-in" /* NOT_IN */ , e);
|
|
2214
2224
|
}
|
|
2215
2225
|
matches(t) {
|
|
2216
2226
|
return !this.keys.some((e => e.isEqual(t.key)));
|
|
2217
2227
|
}
|
|
2218
2228
|
}
|
|
2219
2229
|
|
|
2220
|
-
function
|
|
2230
|
+
function Xt(t, e) {
|
|
2221
2231
|
var n;
|
|
2222
2232
|
return ((null === (n = e.arrayValue) || void 0 === n ? void 0 : n.values) || []).map((t => et.fromName(t.referenceValue)));
|
|
2223
2233
|
}
|
|
2224
2234
|
|
|
2225
|
-
/** A Filter that implements the array-contains operator. */ class
|
|
2235
|
+
/** A Filter that implements the array-contains operator. */ class Zt extends Yt {
|
|
2226
2236
|
constructor(t, e) {
|
|
2227
2237
|
super(t, "array-contains" /* ARRAY_CONTAINS */ , e);
|
|
2228
2238
|
}
|
|
2229
2239
|
matches(t) {
|
|
2230
2240
|
const e = t.data.field(this.field);
|
|
2231
|
-
return
|
|
2241
|
+
return Ut(e) && qt(e.arrayValue, this.value);
|
|
2232
2242
|
}
|
|
2233
2243
|
}
|
|
2234
2244
|
|
|
2235
|
-
/** A Filter that implements the IN operator. */ class
|
|
2245
|
+
/** A Filter that implements the IN operator. */ class te extends Yt {
|
|
2236
2246
|
constructor(t, e) {
|
|
2237
2247
|
super(t, "in" /* IN */ , e);
|
|
2238
2248
|
}
|
|
2239
2249
|
matches(t) {
|
|
2240
2250
|
const e = t.data.field(this.field);
|
|
2241
|
-
return null !== e &&
|
|
2251
|
+
return null !== e && qt(this.value.arrayValue, e);
|
|
2242
2252
|
}
|
|
2243
2253
|
}
|
|
2244
2254
|
|
|
2245
|
-
/** A Filter that implements the not-in operator. */ class
|
|
2255
|
+
/** A Filter that implements the not-in operator. */ class ee extends Yt {
|
|
2246
2256
|
constructor(t, e) {
|
|
2247
2257
|
super(t, "not-in" /* NOT_IN */ , e);
|
|
2248
2258
|
}
|
|
2249
2259
|
matches(t) {
|
|
2250
|
-
if (
|
|
2260
|
+
if (qt(this.value.arrayValue, {
|
|
2251
2261
|
nullValue: "NULL_VALUE"
|
|
2252
2262
|
})) return !1;
|
|
2253
2263
|
const e = t.data.field(this.field);
|
|
2254
|
-
return null !== e && !
|
|
2264
|
+
return null !== e && !qt(this.value.arrayValue, e);
|
|
2255
2265
|
}
|
|
2256
2266
|
}
|
|
2257
2267
|
|
|
2258
|
-
/** A Filter that implements the array-contains-any operator. */ class
|
|
2268
|
+
/** A Filter that implements the array-contains-any operator. */ class ne extends Yt {
|
|
2259
2269
|
constructor(t, e) {
|
|
2260
2270
|
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ , e);
|
|
2261
2271
|
}
|
|
2262
2272
|
matches(t) {
|
|
2263
2273
|
const e = t.data.field(this.field);
|
|
2264
|
-
return !(!
|
|
2274
|
+
return !(!Ut(e) || !e.arrayValue.values) && e.arrayValue.values.some((t => qt(this.value.arrayValue, t)));
|
|
2265
2275
|
}
|
|
2266
2276
|
}
|
|
2267
2277
|
|
|
@@ -2278,7 +2288,7 @@ function Jt(t, e) {
|
|
|
2278
2288
|
* Bound provides a function to determine whether a document comes before or
|
|
2279
2289
|
* after a bound. This is influenced by whether the position is just before or
|
|
2280
2290
|
* just after the provided values.
|
|
2281
|
-
*/ class
|
|
2291
|
+
*/ class re {
|
|
2282
2292
|
constructor(t, e) {
|
|
2283
2293
|
this.position = t, this.inclusive = e;
|
|
2284
2294
|
}
|
|
@@ -2286,17 +2296,17 @@ function Jt(t, e) {
|
|
|
2286
2296
|
|
|
2287
2297
|
/**
|
|
2288
2298
|
* An ordering on a field, in some Direction. Direction defaults to ASCENDING.
|
|
2289
|
-
*/ class
|
|
2299
|
+
*/ class se {
|
|
2290
2300
|
constructor(t, e = "asc" /* ASCENDING */) {
|
|
2291
2301
|
this.field = t, this.dir = e;
|
|
2292
2302
|
}
|
|
2293
2303
|
}
|
|
2294
2304
|
|
|
2295
|
-
function
|
|
2305
|
+
function ie(t, e) {
|
|
2296
2306
|
return t.dir === e.dir && t.field.isEqual(e.field);
|
|
2297
2307
|
}
|
|
2298
2308
|
|
|
2299
|
-
function
|
|
2309
|
+
function oe(t, e) {
|
|
2300
2310
|
if (null === t) return null === e;
|
|
2301
2311
|
if (null === e) return !1;
|
|
2302
2312
|
if (t.inclusive !== e.inclusive || t.position.length !== e.position.length) return !1;
|
|
@@ -2328,7 +2338,7 @@ function ie(t, e) {
|
|
|
2328
2338
|
* query the RemoteStore results.
|
|
2329
2339
|
*
|
|
2330
2340
|
* Visible for testing.
|
|
2331
|
-
*/ class
|
|
2341
|
+
*/ class ue {
|
|
2332
2342
|
/**
|
|
2333
2343
|
* Initializes a Query with a path and optional additional query constraints.
|
|
2334
2344
|
* Path must currently be empty if this is a collection group query.
|
|
@@ -2341,11 +2351,7 @@ function ie(t, e) {
|
|
|
2341
2351
|
}
|
|
2342
2352
|
}
|
|
2343
2353
|
|
|
2344
|
-
/** Creates a new Query for a query that matches all documents at `path` */ function
|
|
2345
|
-
return !ct(t.limit) && "L" /* Last */ === t.limitType;
|
|
2346
|
-
}
|
|
2347
|
-
|
|
2348
|
-
function ce(t) {
|
|
2354
|
+
/** Creates a new Query for a query that matches all documents at `path` */ function ce(t) {
|
|
2349
2355
|
return t.explicitOrderBy.length > 0 ? t.explicitOrderBy[0].field : null;
|
|
2350
2356
|
}
|
|
2351
2357
|
|
|
@@ -2371,7 +2377,7 @@ function he(t) {
|
|
|
2371
2377
|
* which can be different from the order by constraints the user provided (e.g.
|
|
2372
2378
|
* the SDK and backend always orders by `__name__`).
|
|
2373
2379
|
*/ function le(t) {
|
|
2374
|
-
const e =
|
|
2380
|
+
const e = v(t);
|
|
2375
2381
|
if (null === e.$) {
|
|
2376
2382
|
e.$ = [];
|
|
2377
2383
|
const t = ae(e), n = ce(e);
|
|
@@ -2379,14 +2385,14 @@ function he(t) {
|
|
|
2379
2385
|
// In order to implicitly add key ordering, we must also add the
|
|
2380
2386
|
// inequality filter field for it to be a valid query.
|
|
2381
2387
|
// Note that the default inequality field and key ordering is ascending.
|
|
2382
|
-
t.isKeyField() || e.$.push(new
|
|
2388
|
+
t.isKeyField() || e.$.push(new se(t)), e.$.push(new se(tt.keyField(), "asc" /* ASCENDING */)); else {
|
|
2383
2389
|
let t = !1;
|
|
2384
2390
|
for (const n of e.explicitOrderBy) e.$.push(n), n.field.isKeyField() && (t = !0);
|
|
2385
2391
|
if (!t) {
|
|
2386
2392
|
// The order of the implicit key ordering always matches the last
|
|
2387
2393
|
// explicit order by
|
|
2388
2394
|
const t = e.explicitOrderBy.length > 0 ? e.explicitOrderBy[e.explicitOrderBy.length - 1].dir : "asc" /* ASCENDING */;
|
|
2389
|
-
e.$.push(new
|
|
2395
|
+
e.$.push(new se(tt.keyField(), t));
|
|
2390
2396
|
}
|
|
2391
2397
|
}
|
|
2392
2398
|
}
|
|
@@ -2396,18 +2402,18 @@ function he(t) {
|
|
|
2396
2402
|
/**
|
|
2397
2403
|
* Converts this `Query` instance to it's corresponding `Target` representation.
|
|
2398
2404
|
*/ function fe(t) {
|
|
2399
|
-
const e =
|
|
2400
|
-
if (!e.S) if ("F" /* First */ === e.limitType) e.S =
|
|
2405
|
+
const e = v(t);
|
|
2406
|
+
if (!e.S) if ("F" /* First */ === e.limitType) e.S = Wt(e.path, e.collectionGroup, le(e), e.filters, e.limit, e.startAt, e.endAt); else {
|
|
2401
2407
|
// Flip the orderBy directions since we want the last results
|
|
2402
2408
|
const t = [];
|
|
2403
2409
|
for (const n of le(e)) {
|
|
2404
2410
|
const e = "desc" /* DESCENDING */ === n.dir ? "asc" /* ASCENDING */ : "desc" /* DESCENDING */;
|
|
2405
|
-
t.push(new
|
|
2411
|
+
t.push(new se(n.field, e));
|
|
2406
2412
|
}
|
|
2407
2413
|
// We need to swap the cursors to match the now-flipped query ordering.
|
|
2408
|
-
const n = e.endAt ? new
|
|
2414
|
+
const n = e.endAt ? new re(e.endAt.position, e.endAt.inclusive) : null, r = e.startAt ? new re(e.startAt.position, e.startAt.inclusive) : null;
|
|
2409
2415
|
// Now return as a LimitType.First query.
|
|
2410
|
-
e.S =
|
|
2416
|
+
e.S = Wt(e.path, e.collectionGroup, t, e.filters, e.limit, n, r);
|
|
2411
2417
|
}
|
|
2412
2418
|
return e.S;
|
|
2413
2419
|
}
|
|
@@ -2416,12 +2422,12 @@ function de(t, e) {
|
|
|
2416
2422
|
return function(t, e) {
|
|
2417
2423
|
if (t.limit !== e.limit) return !1;
|
|
2418
2424
|
if (t.orderBy.length !== e.orderBy.length) return !1;
|
|
2419
|
-
for (let n = 0; n < t.orderBy.length; n++) if (!
|
|
2425
|
+
for (let n = 0; n < t.orderBy.length; n++) if (!ie(t.orderBy[n], e.orderBy[n])) return !1;
|
|
2420
2426
|
if (t.filters.length !== e.filters.length) return !1;
|
|
2421
2427
|
for (let s = 0; s < t.filters.length; s++) if (n = t.filters[s], r = e.filters[s],
|
|
2422
2428
|
n.op !== r.op || !n.field.isEqual(r.field) || !Ft(n.value, r.value)) return !1;
|
|
2423
2429
|
var n, r;
|
|
2424
|
-
return t.collectionGroup === e.collectionGroup && !!t.path.isEqual(e.path) && !!
|
|
2430
|
+
return t.collectionGroup === e.collectionGroup && !!t.path.isEqual(e.path) && !!oe(t.startAt, e.startAt) && oe(t.endAt, e.endAt);
|
|
2425
2431
|
}(fe(t), fe(e)) && t.limitType === e.limitType;
|
|
2426
2432
|
}
|
|
2427
2433
|
|
|
@@ -2544,7 +2550,7 @@ function we(t, e) {
|
|
|
2544
2550
|
* See the License for the specific language governing permissions and
|
|
2545
2551
|
* limitations under the License.
|
|
2546
2552
|
*/
|
|
2547
|
-
/** A field path and the TransformOperation to perform upon it. */ class
|
|
2553
|
+
/** A field path and the TransformOperation to perform upon it. */ class be {
|
|
2548
2554
|
constructor(t, e) {
|
|
2549
2555
|
this.field = t, this.transform = e;
|
|
2550
2556
|
}
|
|
@@ -2554,18 +2560,18 @@ function we(t, e) {
|
|
|
2554
2560
|
* Encodes a precondition for a mutation. This follows the model that the
|
|
2555
2561
|
* backend accepts with the special case of an explicit "empty" precondition
|
|
2556
2562
|
* (meaning no precondition).
|
|
2557
|
-
*/ class
|
|
2563
|
+
*/ class ve {
|
|
2558
2564
|
constructor(t, e) {
|
|
2559
2565
|
this.updateTime = t, this.exists = e;
|
|
2560
2566
|
}
|
|
2561
2567
|
/** Creates a new empty Precondition. */ static none() {
|
|
2562
|
-
return new
|
|
2568
|
+
return new ve;
|
|
2563
2569
|
}
|
|
2564
2570
|
/** Creates a new Precondition with an exists flag. */ static exists(t) {
|
|
2565
|
-
return new
|
|
2571
|
+
return new ve(void 0, t);
|
|
2566
2572
|
}
|
|
2567
2573
|
/** Creates a new Precondition based on a version a document exists at. */ static updateTime(t) {
|
|
2568
|
-
return new
|
|
2574
|
+
return new ve(t);
|
|
2569
2575
|
}
|
|
2570
2576
|
/** Returns whether this Precondition is empty. */ get isNone() {
|
|
2571
2577
|
return void 0 === this.updateTime && void 0 === this.exists;
|
|
@@ -2642,14 +2648,14 @@ function we(t, e) {
|
|
|
2642
2648
|
* is deleted.
|
|
2643
2649
|
* * When a field is not in the mask but is in the values, the values map is
|
|
2644
2650
|
* ignored.
|
|
2645
|
-
*/ class
|
|
2651
|
+
*/ class Ae extends Ee {
|
|
2646
2652
|
constructor(t, e, n, r, s = []) {
|
|
2647
2653
|
super(), this.key = t, this.data = e, this.fieldMask = n, this.precondition = r,
|
|
2648
2654
|
this.fieldTransforms = s, this.type = 1 /* Patch */;
|
|
2649
2655
|
}
|
|
2650
2656
|
}
|
|
2651
2657
|
|
|
2652
|
-
/** A mutation that deletes the document at the given key. */ class
|
|
2658
|
+
/** A mutation that deletes the document at the given key. */ class Ie extends Ee {
|
|
2653
2659
|
constructor(t, e) {
|
|
2654
2660
|
super(), this.key = t, this.precondition = e, this.type = 2 /* Delete */ , this.fieldTransforms = [];
|
|
2655
2661
|
}
|
|
@@ -2758,36 +2764,36 @@ function Se(t, e) {
|
|
|
2758
2764
|
return Ne(t, e.toTimestamp());
|
|
2759
2765
|
}
|
|
2760
2766
|
|
|
2761
|
-
function
|
|
2762
|
-
return
|
|
2767
|
+
function xe(t) {
|
|
2768
|
+
return b(!!t), bt.fromTimestamp(function(t) {
|
|
2763
2769
|
const e = Rt(t);
|
|
2764
2770
|
return new gt(e.seconds, e.nanos);
|
|
2765
2771
|
}(t));
|
|
2766
2772
|
}
|
|
2767
2773
|
|
|
2768
|
-
function
|
|
2774
|
+
function Fe(t, e) {
|
|
2769
2775
|
return function(t) {
|
|
2770
2776
|
return new X([ "projects", t.projectId, "databases", t.database ]);
|
|
2771
2777
|
}(t).child("documents").child(e).canonicalString();
|
|
2772
2778
|
}
|
|
2773
2779
|
|
|
2774
2780
|
function qe(t, e) {
|
|
2775
|
-
return
|
|
2781
|
+
return Fe(t.databaseId, e.path);
|
|
2776
2782
|
}
|
|
2777
2783
|
|
|
2778
2784
|
function Oe(t, e) {
|
|
2779
2785
|
const n = function(t) {
|
|
2780
2786
|
const e = X.fromString(t);
|
|
2781
|
-
return
|
|
2787
|
+
return b(We(e)), e;
|
|
2782
2788
|
}(e);
|
|
2783
|
-
if (n.get(1) !== t.databaseId.projectId) throw new U(
|
|
2784
|
-
if (n.get(3) !== t.databaseId.database) throw new U(
|
|
2785
|
-
return new et((
|
|
2789
|
+
if (n.get(1) !== t.databaseId.projectId) throw new U(I, "Tried to deserialize key from different project: " + n.get(1) + " vs " + t.databaseId.projectId);
|
|
2790
|
+
if (n.get(3) !== t.databaseId.database) throw new U(I, "Tried to deserialize key from different database: " + n.get(3) + " vs " + t.databaseId.database);
|
|
2791
|
+
return new et((b((r = n).length > 4 && "documents" === r.get(4)), r.popFirst(5)));
|
|
2786
2792
|
var r;
|
|
2787
2793
|
/** Creates a Document proto from key and fields (but no create/update time) */}
|
|
2788
2794
|
|
|
2789
2795
|
function Ce(t, e) {
|
|
2790
|
-
return
|
|
2796
|
+
return Fe(t.databaseId, e);
|
|
2791
2797
|
}
|
|
2792
2798
|
|
|
2793
2799
|
function Le(t) {
|
|
@@ -2803,17 +2809,17 @@ function Ue(t, e, n) {
|
|
|
2803
2809
|
|
|
2804
2810
|
function ke(t, e) {
|
|
2805
2811
|
return "found" in e ? function(t, e) {
|
|
2806
|
-
|
|
2807
|
-
const n = Oe(t, e.found.name), r =
|
|
2812
|
+
b(!!e.found), e.found.name, e.found.updateTime;
|
|
2813
|
+
const n = Oe(t, e.found.name), r = xe(e.found.updateTime), s = new zt({
|
|
2808
2814
|
mapValue: {
|
|
2809
2815
|
fields: e.found.fields
|
|
2810
2816
|
}
|
|
2811
2817
|
});
|
|
2812
|
-
return
|
|
2818
|
+
return Gt.newFoundDocument(n, r, s);
|
|
2813
2819
|
}(t, e) : "missing" in e ? function(t, e) {
|
|
2814
|
-
|
|
2815
|
-
const n = Oe(t, e.missing), r =
|
|
2816
|
-
return
|
|
2820
|
+
b(!!e.missing), b(!!e.readTime);
|
|
2821
|
+
const n = Oe(t, e.missing), r = xe(e.readTime);
|
|
2822
|
+
return Gt.newNoDocument(n, r);
|
|
2817
2823
|
}(t, e) : g();
|
|
2818
2824
|
}
|
|
2819
2825
|
|
|
@@ -2821,9 +2827,9 @@ function je(t, e) {
|
|
|
2821
2827
|
let n;
|
|
2822
2828
|
if (e instanceof Te) n = {
|
|
2823
2829
|
update: Ue(t, e.key, e.value)
|
|
2824
|
-
}; else if (e instanceof Ae) n = {
|
|
2825
|
-
delete: qe(t, e.key)
|
|
2826
2830
|
}; else if (e instanceof Ie) n = {
|
|
2831
|
+
delete: qe(t, e.key)
|
|
2832
|
+
}; else if (e instanceof Ae) n = {
|
|
2827
2833
|
update: Ue(t, e.key, e.data),
|
|
2828
2834
|
updateMask: Qe(e.fieldMask)
|
|
2829
2835
|
}; else {
|
|
@@ -2881,26 +2887,26 @@ function Me(t, e) {
|
|
|
2881
2887
|
// visible for testing
|
|
2882
2888
|
function(t) {
|
|
2883
2889
|
if ("==" /* EQUAL */ === t.op) {
|
|
2884
|
-
if (
|
|
2890
|
+
if (jt(t.value)) return {
|
|
2885
2891
|
unaryFilter: {
|
|
2886
2892
|
field: Ge(t.field),
|
|
2887
2893
|
op: "IS_NAN"
|
|
2888
2894
|
}
|
|
2889
2895
|
};
|
|
2890
|
-
if (
|
|
2896
|
+
if (kt(t.value)) return {
|
|
2891
2897
|
unaryFilter: {
|
|
2892
2898
|
field: Ge(t.field),
|
|
2893
2899
|
op: "IS_NULL"
|
|
2894
2900
|
}
|
|
2895
2901
|
};
|
|
2896
2902
|
} else if ("!=" /* NOT_EQUAL */ === t.op) {
|
|
2897
|
-
if (
|
|
2903
|
+
if (jt(t.value)) return {
|
|
2898
2904
|
unaryFilter: {
|
|
2899
2905
|
field: Ge(t.field),
|
|
2900
2906
|
op: "IS_NOT_NAN"
|
|
2901
2907
|
}
|
|
2902
2908
|
};
|
|
2903
|
-
if (
|
|
2909
|
+
if (kt(t.value)) return {
|
|
2904
2910
|
unaryFilter: {
|
|
2905
2911
|
field: Ge(t.field),
|
|
2906
2912
|
op: "IS_NOT_NULL"
|
|
@@ -3135,13 +3141,13 @@ class Ke extends class {} {
|
|
|
3135
3141
|
/** Invokes the provided RPC with auth and AppCheck tokens. */ m(t, e, n) {
|
|
3136
3142
|
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.m(t, e, n, r, s))).catch((t => {
|
|
3137
3143
|
throw "FirebaseError" === t.name ? (t.code === N && (this.authCredentials.invalidateToken(),
|
|
3138
|
-
this.appCheckCredentials.invalidateToken()), t) : new U(
|
|
3144
|
+
this.appCheckCredentials.invalidateToken()), t) : new U(A, t.toString());
|
|
3139
3145
|
}));
|
|
3140
3146
|
}
|
|
3141
3147
|
/** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */ T(t, e, n) {
|
|
3142
3148
|
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.T(t, e, n, r, s))).catch((t => {
|
|
3143
3149
|
throw "FirebaseError" === t.name ? (t.code === N && (this.authCredentials.invalidateToken(),
|
|
3144
|
-
this.appCheckCredentials.invalidateToken()), t) : new U(
|
|
3150
|
+
this.appCheckCredentials.invalidateToken()), t) : new U(A, t.toString());
|
|
3145
3151
|
}));
|
|
3146
3152
|
}
|
|
3147
3153
|
terminate() {
|
|
@@ -3152,14 +3158,14 @@ class Ke extends class {} {
|
|
|
3152
3158
|
// TODO(firestorexp): Make sure there is only one Datastore instance per
|
|
3153
3159
|
// firestore-exp client.
|
|
3154
3160
|
async function Je(t, e) {
|
|
3155
|
-
const n =
|
|
3161
|
+
const n = v(t), r = Le(n.q) + "/documents", s = {
|
|
3156
3162
|
writes: e.map((t => je(n.q, t)))
|
|
3157
3163
|
};
|
|
3158
3164
|
await n.m("Commit", r, s);
|
|
3159
3165
|
}
|
|
3160
3166
|
|
|
3161
3167
|
async function Xe(t, e) {
|
|
3162
|
-
const n =
|
|
3168
|
+
const n = v(t), r = Le(n.q) + "/documents", s = {
|
|
3163
3169
|
documents: e.map((t => qe(n.q, t)))
|
|
3164
3170
|
}, i = await n.T("BatchGetDocuments", r, s), o = new Map;
|
|
3165
3171
|
i.forEach((t => {
|
|
@@ -3169,20 +3175,20 @@ async function Xe(t, e) {
|
|
|
3169
3175
|
const u = [];
|
|
3170
3176
|
return e.forEach((t => {
|
|
3171
3177
|
const e = o.get(t.toString());
|
|
3172
|
-
|
|
3178
|
+
b(!!e), u.push(e);
|
|
3173
3179
|
})), u;
|
|
3174
3180
|
}
|
|
3175
3181
|
|
|
3176
3182
|
async function Ze(t, e) {
|
|
3177
|
-
const n =
|
|
3183
|
+
const n = v(t), r = Me(n.q, fe(e));
|
|
3178
3184
|
return (await n.T("RunQuery", r.parent, {
|
|
3179
3185
|
structuredQuery: r.structuredQuery
|
|
3180
3186
|
})).filter((t => !!t.document)).map((t => function(t, e, n) {
|
|
3181
|
-
const r = Oe(t, e.name), s =
|
|
3187
|
+
const r = Oe(t, e.name), s = xe(e.updateTime), i = new zt({
|
|
3182
3188
|
mapValue: {
|
|
3183
3189
|
fields: e.fields
|
|
3184
3190
|
}
|
|
3185
|
-
}), o =
|
|
3191
|
+
}), o = Gt.newFoundDocument(r, s, i);
|
|
3186
3192
|
return n && o.setHasCommittedMutations(), n ? o.setHasCommittedMutations() : o;
|
|
3187
3193
|
}(n.q, t.document, void 0)));
|
|
3188
3194
|
}
|
|
@@ -3257,17 +3263,17 @@ class nn {
|
|
|
3257
3263
|
constructor(t) {
|
|
3258
3264
|
var e;
|
|
3259
3265
|
if (void 0 === t.host) {
|
|
3260
|
-
if (void 0 !== t.ssl) throw new U(
|
|
3266
|
+
if (void 0 !== t.ssl) throw new U(I, "Can't provide ssl option if host option is not set");
|
|
3261
3267
|
this.host = "firestore.googleapis.com", this.ssl = true;
|
|
3262
3268
|
} else this.host = t.host, this.ssl = null === (e = t.ssl) || void 0 === e || e;
|
|
3263
3269
|
if (this.credentials = t.credentials, this.ignoreUndefinedProperties = !!t.ignoreUndefinedProperties,
|
|
3264
3270
|
void 0 === t.cacheSizeBytes) this.cacheSizeBytes = 41943040; else {
|
|
3265
|
-
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new U(
|
|
3271
|
+
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new U(I, "cacheSizeBytes must be at least 1048576");
|
|
3266
3272
|
this.cacheSizeBytes = t.cacheSizeBytes;
|
|
3267
3273
|
}
|
|
3268
3274
|
this.experimentalForceLongPolling = !!t.experimentalForceLongPolling, this.experimentalAutoDetectLongPolling = !!t.experimentalAutoDetectLongPolling,
|
|
3269
3275
|
this.useFetchStreams = !!t.useFetchStreams, function(t, e, n, r) {
|
|
3270
|
-
if (!0 === e && !0 === r) throw new U(
|
|
3276
|
+
if (!0 === e && !0 === r) throw new U(I, `${t} and ${n} cannot be used together.`);
|
|
3271
3277
|
}("experimentalForceLongPolling", t.experimentalForceLongPolling, "experimentalAutoDetectLongPolling", t.experimentalAutoDetectLongPolling);
|
|
3272
3278
|
}
|
|
3273
3279
|
isEqual(t) {
|
|
@@ -3305,7 +3311,7 @@ class nn {
|
|
|
3305
3311
|
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new nn({}),
|
|
3306
3312
|
this._settingsFrozen = !1, t instanceof K ? this._databaseId = t : (this._app = t,
|
|
3307
3313
|
this._databaseId = function(t) {
|
|
3308
|
-
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new U(
|
|
3314
|
+
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new U(I, '"projectId" not provided in firebase.initializeApp.');
|
|
3309
3315
|
return new K(t.options.projectId);
|
|
3310
3316
|
}
|
|
3311
3317
|
/**
|
|
@@ -3341,14 +3347,14 @@ class nn {
|
|
|
3341
3347
|
case "gapi":
|
|
3342
3348
|
const e = t.client;
|
|
3343
3349
|
// Make sure this really is a Gapi client.
|
|
3344
|
-
return
|
|
3350
|
+
return b(!("object" != typeof e || null === e || !e.auth || !e.auth.getAuthHeaderValueForFirstParty)),
|
|
3345
3351
|
new Q(e, t.sessionIndex || "0", t.iamToken || null);
|
|
3346
3352
|
|
|
3347
3353
|
case "provider":
|
|
3348
3354
|
return t.client;
|
|
3349
3355
|
|
|
3350
3356
|
default:
|
|
3351
|
-
throw new U(
|
|
3357
|
+
throw new U(I, "makeAuthCredentialsProvider failed due to invalid credential type");
|
|
3352
3358
|
}
|
|
3353
3359
|
}(t.credentials));
|
|
3354
3360
|
}
|
|
@@ -3428,7 +3434,7 @@ function sn(t, e) {
|
|
|
3428
3434
|
// invalid field "uid" and missing field "sub" / "user_id".)
|
|
3429
3435
|
e = createMockUserToken(r.mockUserToken, null === (s = t._app) || void 0 === s ? void 0 : s.options.projectId);
|
|
3430
3436
|
const i = r.mockUserToken.sub || r.mockUserToken.user_id;
|
|
3431
|
-
if (!i) throw new U(
|
|
3437
|
+
if (!i) throw new U(I, "mockUserToken must contain 'sub' or 'user_id' field!");
|
|
3432
3438
|
n = new l(i);
|
|
3433
3439
|
}
|
|
3434
3440
|
t._authCredentials = new B(new j(e, n));
|
|
@@ -3556,7 +3562,7 @@ class an {
|
|
|
3556
3562
|
*/ class ln extends hn {
|
|
3557
3563
|
/** @hideconstructor */
|
|
3558
3564
|
constructor(t, e, n) {
|
|
3559
|
-
super(t, e, new
|
|
3565
|
+
super(t, e, new ue(n)), this._path = n,
|
|
3560
3566
|
/** The type of this Firestore reference. */
|
|
3561
3567
|
this.type = "collection";
|
|
3562
3568
|
}
|
|
@@ -3588,7 +3594,7 @@ function fn(t, e, ...n) {
|
|
|
3588
3594
|
return st(r), new ln(t, /* converter= */ null, r);
|
|
3589
3595
|
}
|
|
3590
3596
|
{
|
|
3591
|
-
if (!(t instanceof an || t instanceof ln)) throw new U(
|
|
3597
|
+
if (!(t instanceof an || t instanceof ln)) throw new U(I, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3592
3598
|
const r = t._path.child(X.fromString(e, ...n));
|
|
3593
3599
|
return st(r), new ln(t.firestore,
|
|
3594
3600
|
/* converter= */ null, r);
|
|
@@ -3608,7 +3614,7 @@ function fn(t, e, ...n) {
|
|
|
3608
3614
|
* will be included. Cannot contain a slash.
|
|
3609
3615
|
* @returns The created `Query`.
|
|
3610
3616
|
*/ function dn(t, e) {
|
|
3611
|
-
if (t = ot(t, rn), nt("collectionGroup", "collection id", e), e.indexOf("/") >= 0) throw new U(
|
|
3617
|
+
if (t = ot(t, rn), nt("collectionGroup", "collection id", e), e.indexOf("/") >= 0) throw new U(I, `Invalid collection ID '${e}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);
|
|
3612
3618
|
return new hn(t,
|
|
3613
3619
|
/* converter= */ null,
|
|
3614
3620
|
/**
|
|
@@ -3616,7 +3622,7 @@ function fn(t, e, ...n) {
|
|
|
3616
3622
|
* within the provided collection group.
|
|
3617
3623
|
*/
|
|
3618
3624
|
function(t) {
|
|
3619
|
-
return new
|
|
3625
|
+
return new ue(X.emptyPath(), t);
|
|
3620
3626
|
}(e));
|
|
3621
3627
|
}
|
|
3622
3628
|
|
|
@@ -3630,7 +3636,7 @@ function wn(t, e, ...n) {
|
|
|
3630
3636
|
/* converter= */ null, new et(r));
|
|
3631
3637
|
}
|
|
3632
3638
|
{
|
|
3633
|
-
if (!(t instanceof an || t instanceof ln)) throw new U(
|
|
3639
|
+
if (!(t instanceof an || t instanceof ln)) throw new U(I, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3634
3640
|
const r = t._path.child(X.fromString(e, ...n));
|
|
3635
3641
|
return rt(r), new an(t.firestore, t instanceof ln ? t.converter : null, new et(r));
|
|
3636
3642
|
}
|
|
@@ -3690,7 +3696,7 @@ function wn(t, e, ...n) {
|
|
|
3690
3696
|
* @param fieldNames - A list of field names.
|
|
3691
3697
|
*/
|
|
3692
3698
|
constructor(...t) {
|
|
3693
|
-
for (let e = 0; e < t.length; ++e) if (0 === t[e].length) throw new U(
|
|
3699
|
+
for (let e = 0; e < t.length; ++e) if (0 === t[e].length) throw new U(I, "Invalid field name at argument $(i + 1). Field names must not be empty.");
|
|
3694
3700
|
this._internalPath = new tt(t);
|
|
3695
3701
|
}
|
|
3696
3702
|
/**
|
|
@@ -3740,9 +3746,9 @@ function wn(t, e, ...n) {
|
|
|
3740
3746
|
* @param base64 - The Base64 string used to create the `Bytes` object.
|
|
3741
3747
|
*/ static fromBase64String(t) {
|
|
3742
3748
|
try {
|
|
3743
|
-
return new gn(
|
|
3749
|
+
return new gn(At.fromBase64String(t));
|
|
3744
3750
|
} catch (t) {
|
|
3745
|
-
throw new U(
|
|
3751
|
+
throw new U(I, "Failed to construct data from Base64 string: " + t);
|
|
3746
3752
|
}
|
|
3747
3753
|
}
|
|
3748
3754
|
/**
|
|
@@ -3750,7 +3756,7 @@ function wn(t, e, ...n) {
|
|
|
3750
3756
|
*
|
|
3751
3757
|
* @param array - The Uint8Array used to create the `Bytes` object.
|
|
3752
3758
|
*/ static fromUint8Array(t) {
|
|
3753
|
-
return new gn(
|
|
3759
|
+
return new gn(At.fromUint8Array(t));
|
|
3754
3760
|
}
|
|
3755
3761
|
/**
|
|
3756
3762
|
* Returns the underlying bytes as a Base64-encoded string.
|
|
@@ -3802,7 +3808,7 @@ function wn(t, e, ...n) {
|
|
|
3802
3808
|
/**
|
|
3803
3809
|
* Sentinel values that can be used when writing document fields with `set()`
|
|
3804
3810
|
* or `update()`.
|
|
3805
|
-
*/ class
|
|
3811
|
+
*/ class bn {
|
|
3806
3812
|
/**
|
|
3807
3813
|
* @param _methodName - The public API endpoint that returns this class.
|
|
3808
3814
|
* @hideconstructor
|
|
@@ -3834,7 +3840,7 @@ function wn(t, e, ...n) {
|
|
|
3834
3840
|
*
|
|
3835
3841
|
* Latitude values are in the range of [-90, 90].
|
|
3836
3842
|
* Longitude values are in the range of [-180, 180].
|
|
3837
|
-
*/ class
|
|
3843
|
+
*/ class vn {
|
|
3838
3844
|
/**
|
|
3839
3845
|
* Creates a new immutable `GeoPoint` object with the provided latitude and
|
|
3840
3846
|
* longitude values.
|
|
@@ -3842,8 +3848,8 @@ function wn(t, e, ...n) {
|
|
|
3842
3848
|
* @param longitude - The longitude as number between -180 and 180.
|
|
3843
3849
|
*/
|
|
3844
3850
|
constructor(t, e) {
|
|
3845
|
-
if (!isFinite(t) || t < -90 || t > 90) throw new U(
|
|
3846
|
-
if (!isFinite(e) || e < -180 || e > 180) throw new U(
|
|
3851
|
+
if (!isFinite(t) || t < -90 || t > 90) throw new U(I, "Latitude must be a number between -90 and 90, but was: " + t);
|
|
3852
|
+
if (!isFinite(e) || e < -180 || e > 180) throw new U(I, "Longitude must be a number between -180 and 180, but was: " + e);
|
|
3847
3853
|
this._lat = t, this._long = e;
|
|
3848
3854
|
}
|
|
3849
3855
|
/**
|
|
@@ -3900,22 +3906,22 @@ function wn(t, e, ...n) {
|
|
|
3900
3906
|
this.data = t, this.fieldMask = e, this.fieldTransforms = n;
|
|
3901
3907
|
}
|
|
3902
3908
|
toMutation(t, e) {
|
|
3903
|
-
return null !== this.fieldMask ? new
|
|
3909
|
+
return null !== this.fieldMask ? new Ae(t, this.data, this.fieldMask, e, this.fieldTransforms) : new Te(t, this.data, e, this.fieldTransforms);
|
|
3904
3910
|
}
|
|
3905
3911
|
}
|
|
3906
3912
|
|
|
3907
|
-
/** The result of parsing "update" data (i.e. for an updateData call). */ class
|
|
3913
|
+
/** The result of parsing "update" data (i.e. for an updateData call). */ class An {
|
|
3908
3914
|
constructor(t,
|
|
3909
3915
|
// The fieldMask does not include document transforms.
|
|
3910
3916
|
e, n) {
|
|
3911
3917
|
this.data = t, this.fieldMask = e, this.fieldTransforms = n;
|
|
3912
3918
|
}
|
|
3913
3919
|
toMutation(t, e) {
|
|
3914
|
-
return new
|
|
3920
|
+
return new Ae(t, this.data, this.fieldMask, e, this.fieldTransforms);
|
|
3915
3921
|
}
|
|
3916
3922
|
}
|
|
3917
3923
|
|
|
3918
|
-
function
|
|
3924
|
+
function In(t) {
|
|
3919
3925
|
switch (t) {
|
|
3920
3926
|
case 0 /* Set */ :
|
|
3921
3927
|
// fall through
|
|
@@ -4004,7 +4010,7 @@ function An(t) {
|
|
|
4004
4010
|
}
|
|
4005
4011
|
st(t) {
|
|
4006
4012
|
if (0 === t.length) throw this.ut("Document fields must not be empty");
|
|
4007
|
-
if (
|
|
4013
|
+
if (In(this.tt) && En.test(t)) throw this.ut('Document fields cannot begin and end with "__"');
|
|
4008
4014
|
}
|
|
4009
4015
|
}
|
|
4010
4016
|
|
|
@@ -4041,15 +4047,15 @@ function Vn(t) {
|
|
|
4041
4047
|
const t = [];
|
|
4042
4048
|
for (const r of i.mergeFields) {
|
|
4043
4049
|
const s = Bn(e, r, n);
|
|
4044
|
-
if (!o.contains(s)) throw new U(
|
|
4050
|
+
if (!o.contains(s)) throw new U(I, `Field '${s}' is specified in your field mask but missing from your input data.`);
|
|
4045
4051
|
Wn(t, s) || t.push(s);
|
|
4046
4052
|
}
|
|
4047
4053
|
c = new Tt(t), a = o.fieldTransforms.filter((t => c.covers(t.field)));
|
|
4048
4054
|
} else c = null, a = o.fieldTransforms;
|
|
4049
|
-
return new Tn(new
|
|
4055
|
+
return new Tn(new zt(u), c, a);
|
|
4050
4056
|
}
|
|
4051
4057
|
|
|
4052
|
-
class Nn extends
|
|
4058
|
+
class Nn extends bn {
|
|
4053
4059
|
_toFieldTransform(t) {
|
|
4054
4060
|
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}`);
|
|
4055
4061
|
// No transform to add for a delete, but we need to add it to our
|
|
@@ -4085,23 +4091,23 @@ class Nn extends vn {
|
|
|
4085
4091
|
}, e.databaseId, e.q, e.ignoreUndefinedProperties);
|
|
4086
4092
|
}
|
|
4087
4093
|
|
|
4088
|
-
class Sn extends
|
|
4094
|
+
class Sn extends bn {
|
|
4089
4095
|
_toFieldTransform(t) {
|
|
4090
|
-
return new
|
|
4096
|
+
return new be(t.path, new pe);
|
|
4091
4097
|
}
|
|
4092
4098
|
isEqual(t) {
|
|
4093
4099
|
return t instanceof Sn;
|
|
4094
4100
|
}
|
|
4095
4101
|
}
|
|
4096
4102
|
|
|
4097
|
-
class
|
|
4103
|
+
class xn extends bn {
|
|
4098
4104
|
constructor(t, e) {
|
|
4099
4105
|
super(t), this.lt = e;
|
|
4100
4106
|
}
|
|
4101
4107
|
_toFieldTransform(t) {
|
|
4102
4108
|
const e = $n(this, t,
|
|
4103
4109
|
/*array=*/ !0), n = this.lt.map((t => Un(t, e))), r = new ye(n);
|
|
4104
|
-
return new
|
|
4110
|
+
return new be(t.path, r);
|
|
4105
4111
|
}
|
|
4106
4112
|
isEqual(t) {
|
|
4107
4113
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4109,14 +4115,14 @@ class Fn extends vn {
|
|
|
4109
4115
|
}
|
|
4110
4116
|
}
|
|
4111
4117
|
|
|
4112
|
-
class
|
|
4118
|
+
class Fn extends bn {
|
|
4113
4119
|
constructor(t, e) {
|
|
4114
4120
|
super(t), this.lt = e;
|
|
4115
4121
|
}
|
|
4116
4122
|
_toFieldTransform(t) {
|
|
4117
4123
|
const e = $n(this, t,
|
|
4118
4124
|
/*array=*/ !0), n = this.lt.map((t => Un(t, e))), r = new _e(n);
|
|
4119
|
-
return new
|
|
4125
|
+
return new be(t.path, r);
|
|
4120
4126
|
}
|
|
4121
4127
|
isEqual(t) {
|
|
4122
4128
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4124,13 +4130,13 @@ class xn extends vn {
|
|
|
4124
4130
|
}
|
|
4125
4131
|
}
|
|
4126
4132
|
|
|
4127
|
-
class qn extends
|
|
4133
|
+
class qn extends bn {
|
|
4128
4134
|
constructor(t, e) {
|
|
4129
4135
|
super(t), this.ft = e;
|
|
4130
4136
|
}
|
|
4131
4137
|
_toFieldTransform(t) {
|
|
4132
4138
|
const e = new ge(t.q, we(t.q, this.ft));
|
|
4133
|
-
return new
|
|
4139
|
+
return new be(t.path, e);
|
|
4134
4140
|
}
|
|
4135
4141
|
isEqual(t) {
|
|
4136
4142
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4141,7 +4147,7 @@ class qn extends vn {
|
|
|
4141
4147
|
/** Parse update data from an update() call. */ function On(t, e, n, r) {
|
|
4142
4148
|
const s = t.ht(1 /* Update */ , e, n);
|
|
4143
4149
|
Mn("Data must be an object, but it was:", s, r);
|
|
4144
|
-
const i = [], o =
|
|
4150
|
+
const i = [], o = zt.empty();
|
|
4145
4151
|
Et(r, ((t, r) => {
|
|
4146
4152
|
const u = Gn(e, t, n);
|
|
4147
4153
|
// For Compat types, we have to "extract" the underlying types before
|
|
@@ -4156,14 +4162,14 @@ class qn extends vn {
|
|
|
4156
4162
|
}
|
|
4157
4163
|
}));
|
|
4158
4164
|
const u = new Tt(i);
|
|
4159
|
-
return new
|
|
4165
|
+
return new An(o, u, s.fieldTransforms);
|
|
4160
4166
|
}
|
|
4161
4167
|
|
|
4162
4168
|
/** Parse update data from a list of field/value arguments. */ function Cn(t, e, n, r, s, i) {
|
|
4163
4169
|
const o = t.ht(1 /* Update */ , e, n), u = [ Bn(e, r, n) ], c = [ s ];
|
|
4164
|
-
if (i.length % 2 != 0) throw new U(
|
|
4170
|
+
if (i.length % 2 != 0) throw new U(I, `Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);
|
|
4165
4171
|
for (let t = 0; t < i.length; t += 2) u.push(Bn(e, i[t])), c.push(i[t + 1]);
|
|
4166
|
-
const a = [], l =
|
|
4172
|
+
const a = [], l = zt.empty();
|
|
4167
4173
|
// We iterate in reverse order to pick the last value for a field if the
|
|
4168
4174
|
// user specified the field multiple times.
|
|
4169
4175
|
for (let t = u.length - 1; t >= 0; --t) if (!Wn(a, u[t])) {
|
|
@@ -4181,7 +4187,7 @@ class qn extends vn {
|
|
|
4181
4187
|
}
|
|
4182
4188
|
}
|
|
4183
4189
|
const f = new Tt(a);
|
|
4184
|
-
return new
|
|
4190
|
+
return new An(l, f, o.fieldTransforms);
|
|
4185
4191
|
}
|
|
4186
4192
|
|
|
4187
4193
|
/**
|
|
@@ -4207,7 +4213,7 @@ class qn extends vn {
|
|
|
4207
4213
|
// Unwrap the API type from the Compat SDK. This will return the API type
|
|
4208
4214
|
// from firestore-exp.
|
|
4209
4215
|
t = getModularInstance(t))) return Mn("Unsupported field value:", e, t), kn(t, e);
|
|
4210
|
-
if (t instanceof
|
|
4216
|
+
if (t instanceof bn)
|
|
4211
4217
|
// FieldValues usually parse into transforms (except deleteField())
|
|
4212
4218
|
// in which case we do not want to include this field in our parsed data
|
|
4213
4219
|
// (as doing so will overwrite the field directly prior to the transform
|
|
@@ -4219,7 +4225,7 @@ class qn extends vn {
|
|
|
4219
4225
|
*/
|
|
4220
4226
|
return function(t, e) {
|
|
4221
4227
|
// Sentinels are only supported with writes, and not within arrays.
|
|
4222
|
-
if (!
|
|
4228
|
+
if (!In(e.tt)) throw e.ut(`${t._methodName}() can only be used with update() and set()`);
|
|
4223
4229
|
if (!e.path) throw e.ut(`${t._methodName}() is not currently supported inside arrays`);
|
|
4224
4230
|
const n = t._toFieldTransform(e);
|
|
4225
4231
|
n && e.fieldTransforms.push(n);
|
|
@@ -4290,7 +4296,7 @@ class qn extends vn {
|
|
|
4290
4296
|
timestampValue: Ne(e.q, n)
|
|
4291
4297
|
};
|
|
4292
4298
|
}
|
|
4293
|
-
if (t instanceof
|
|
4299
|
+
if (t instanceof vn) return {
|
|
4294
4300
|
geoPointValue: {
|
|
4295
4301
|
latitude: t.latitude,
|
|
4296
4302
|
longitude: t.longitude
|
|
@@ -4303,7 +4309,7 @@ class qn extends vn {
|
|
|
4303
4309
|
const n = e.databaseId, r = t.firestore._databaseId;
|
|
4304
4310
|
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}`);
|
|
4305
4311
|
return {
|
|
4306
|
-
referenceValue:
|
|
4312
|
+
referenceValue: Fe(t.firestore._databaseId || e.databaseId, t._key.path)
|
|
4307
4313
|
};
|
|
4308
4314
|
}
|
|
4309
4315
|
throw e.ut(`Unsupported field value: ${it(t)}`);
|
|
@@ -4336,7 +4342,7 @@ function kn(t, e) {
|
|
|
4336
4342
|
}
|
|
4337
4343
|
|
|
4338
4344
|
function jn(t) {
|
|
4339
|
-
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof gt || t instanceof
|
|
4345
|
+
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof gt || t instanceof vn || t instanceof gn || t instanceof an || t instanceof bn);
|
|
4340
4346
|
}
|
|
4341
4347
|
|
|
4342
4348
|
function Mn(t, e, n) {
|
|
@@ -4392,7 +4398,7 @@ function Qn(t, e, n, r, s) {
|
|
|
4392
4398
|
n && (u += " (via `toFirestore()`)"), u += ". ";
|
|
4393
4399
|
let c = "";
|
|
4394
4400
|
return (i || o) && (c += " (found", i && (c += ` in field ${r}`), o && (c += ` in document ${s}`),
|
|
4395
|
-
c += ")"), new U(
|
|
4401
|
+
c += ")"), new U(I, u + t + c);
|
|
4396
4402
|
}
|
|
4397
4403
|
|
|
4398
4404
|
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function Wn(t, e) {
|
|
@@ -4601,7 +4607,7 @@ class er extends Zn {
|
|
|
4601
4607
|
const e = Vn(t.firestore), n = function(t, e, n, r, s, i, o) {
|
|
4602
4608
|
let u;
|
|
4603
4609
|
if (s.isKeyField()) {
|
|
4604
|
-
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new U(
|
|
4610
|
+
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new U(I, `Invalid Query. You can't perform '${i}' queries on documentId().`);
|
|
4605
4611
|
if ("in" /* IN */ === i || "not-in" /* NOT_IN */ === i) {
|
|
4606
4612
|
pr(o, i);
|
|
4607
4613
|
const e = [];
|
|
@@ -4615,11 +4621,11 @@ class er extends Zn {
|
|
|
4615
4621
|
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i || pr(o, i),
|
|
4616
4622
|
u = Ln(n, e, o,
|
|
4617
4623
|
/* allowArrays= */ "in" /* IN */ === i || "not-in" /* NOT_IN */ === i);
|
|
4618
|
-
const c =
|
|
4624
|
+
const c = Yt.create(s, i, u);
|
|
4619
4625
|
return function(t, e) {
|
|
4620
4626
|
if (e.N()) {
|
|
4621
4627
|
const n = ae(t);
|
|
4622
|
-
if (null !== n && !n.isEqual(e.field)) throw new U(
|
|
4628
|
+
if (null !== n && !n.isEqual(e.field)) throw new U(I, `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()}'`);
|
|
4623
4629
|
const r = ce(t);
|
|
4624
4630
|
null !== r && yr(t, e.field, r);
|
|
4625
4631
|
}
|
|
@@ -4662,12 +4668,12 @@ class er extends Zn {
|
|
|
4662
4668
|
}(e.op));
|
|
4663
4669
|
if (null !== n)
|
|
4664
4670
|
// Special case when it's a duplicate op to give a slightly clearer error message.
|
|
4665
|
-
throw n === e.op ? new U(
|
|
4671
|
+
throw n === e.op ? new U(I, `Invalid query. You cannot use more than one '${e.op.toString()}' filter.`) : new U(I, `Invalid query. You cannot use '${e.op.toString()}' filters with '${n.toString()}' filters.`);
|
|
4666
4672
|
}(t, c), c;
|
|
4667
4673
|
}(t._query, "where", e, t.firestore._databaseId, this.dt, this.wt, this.yt);
|
|
4668
4674
|
return new hn(t.firestore, t.converter, function(t, e) {
|
|
4669
4675
|
const n = t.filters.concat([ e ]);
|
|
4670
|
-
return new
|
|
4676
|
+
return new ue(t.path, t.collectionGroup, t.explicitOrderBy.slice(), n, t.limit, t.limitType, t.startAt, t.endAt);
|
|
4671
4677
|
}(t._query, n));
|
|
4672
4678
|
}
|
|
4673
4679
|
}
|
|
@@ -4693,9 +4699,9 @@ class rr extends Zn {
|
|
|
4693
4699
|
}
|
|
4694
4700
|
_apply(t) {
|
|
4695
4701
|
const e = function(t, e, n) {
|
|
4696
|
-
if (null !== t.startAt) throw new U(
|
|
4697
|
-
if (null !== t.endAt) throw new U(
|
|
4698
|
-
const r = new
|
|
4702
|
+
if (null !== t.startAt) throw new U(I, "Invalid query. You must not call startAt() or startAfter() before calling orderBy().");
|
|
4703
|
+
if (null !== t.endAt) throw new U(I, "Invalid query. You must not call endAt() or endBefore() before calling orderBy().");
|
|
4704
|
+
const r = new se(e, n);
|
|
4699
4705
|
return function(t, e) {
|
|
4700
4706
|
if (null === ce(t)) {
|
|
4701
4707
|
// This is the first order by. It must match any inequality.
|
|
@@ -4718,7 +4724,7 @@ class rr extends Zn {
|
|
|
4718
4724
|
return new hn(t.firestore, t.converter, function(t, e) {
|
|
4719
4725
|
// TODO(dimond): validate that orderBy does not list the same key twice.
|
|
4720
4726
|
const n = t.explicitOrderBy.concat([ e ]);
|
|
4721
|
-
return new
|
|
4727
|
+
return new ue(t.path, t.collectionGroup, n, t.filters.slice(), t.limit, t.limitType, t.startAt, t.endAt);
|
|
4722
4728
|
}(t._query, e));
|
|
4723
4729
|
}
|
|
4724
4730
|
}
|
|
@@ -4738,12 +4744,12 @@ class rr extends Zn {
|
|
|
4738
4744
|
|
|
4739
4745
|
class ir extends Zn {
|
|
4740
4746
|
constructor(t, e, n) {
|
|
4741
|
-
super(), this.type = t, this.gt = e, this.
|
|
4747
|
+
super(), this.type = t, this.gt = e, this.bt = n;
|
|
4742
4748
|
}
|
|
4743
4749
|
_apply(t) {
|
|
4744
4750
|
return new hn(t.firestore, t.converter, function(t, e, n) {
|
|
4745
|
-
return new
|
|
4746
|
-
}(t._query, this.gt, this.
|
|
4751
|
+
return new ue(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), e, n, t.startAt, t.endAt);
|
|
4752
|
+
}(t._query, this.gt, this.bt));
|
|
4747
4753
|
}
|
|
4748
4754
|
}
|
|
4749
4755
|
|
|
@@ -4770,12 +4776,12 @@ class ir extends Zn {
|
|
|
4770
4776
|
|
|
4771
4777
|
class cr extends Zn {
|
|
4772
4778
|
constructor(t, e, n) {
|
|
4773
|
-
super(), this.type = t, this.
|
|
4779
|
+
super(), this.type = t, this.vt = e, this.Et = n;
|
|
4774
4780
|
}
|
|
4775
4781
|
_apply(t) {
|
|
4776
|
-
const e = wr(t, this.type, this.
|
|
4782
|
+
const e = wr(t, this.type, this.vt, this.Et);
|
|
4777
4783
|
return new hn(t.firestore, t.converter, function(t, e) {
|
|
4778
|
-
return new
|
|
4784
|
+
return new ue(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, e, t.endAt);
|
|
4779
4785
|
}(t._query, e));
|
|
4780
4786
|
}
|
|
4781
4787
|
}
|
|
@@ -4792,12 +4798,12 @@ function hr(...t) {
|
|
|
4792
4798
|
|
|
4793
4799
|
class lr extends Zn {
|
|
4794
4800
|
constructor(t, e, n) {
|
|
4795
|
-
super(), this.type = t, this.
|
|
4801
|
+
super(), this.type = t, this.vt = e, this.Et = n;
|
|
4796
4802
|
}
|
|
4797
4803
|
_apply(t) {
|
|
4798
|
-
const e = wr(t, this.type, this.
|
|
4804
|
+
const e = wr(t, this.type, this.vt, this.Et);
|
|
4799
4805
|
return new hn(t.firestore, t.converter, function(t, e) {
|
|
4800
|
-
return new
|
|
4806
|
+
return new ue(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, t.startAt, e);
|
|
4801
4807
|
}(t._query, e));
|
|
4802
4808
|
}
|
|
4803
4809
|
}
|
|
@@ -4822,16 +4828,16 @@ function dr(...t) {
|
|
|
4822
4828
|
// the provided document. Without the key (by using the explicit sort
|
|
4823
4829
|
// orders), multiple documents could match the position, yielding duplicate
|
|
4824
4830
|
// results.
|
|
4825
|
-
for (const n of le(t)) if (n.field.isKeyField()) i.push(
|
|
4831
|
+
for (const n of le(t)) if (n.field.isKeyField()) i.push(Lt(e, r.key)); else {
|
|
4826
4832
|
const t = r.data.field(n.field);
|
|
4827
|
-
if (Dt(t)) throw new U(
|
|
4833
|
+
if (Dt(t)) throw new U(I, '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.)');
|
|
4828
4834
|
if (null === t) {
|
|
4829
4835
|
const t = n.field.canonicalString();
|
|
4830
|
-
throw new U(
|
|
4836
|
+
throw new U(I, `Invalid query. You are trying to start or end a query using a document for which the field '${t}' (used as the orderBy) does not exist.`);
|
|
4831
4837
|
}
|
|
4832
4838
|
i.push(t);
|
|
4833
4839
|
}
|
|
4834
|
-
return new
|
|
4840
|
+
return new re(i, s);
|
|
4835
4841
|
}
|
|
4836
4842
|
/**
|
|
4837
4843
|
* Converts a list of field values to a `Bound` for the given query.
|
|
@@ -4841,23 +4847,23 @@ function dr(...t) {
|
|
|
4841
4847
|
return function(t, e, n, r, s, i) {
|
|
4842
4848
|
// Use explicit order by's because it has to match the query the user made
|
|
4843
4849
|
const o = t.explicitOrderBy;
|
|
4844
|
-
if (s.length > o.length) throw new U(
|
|
4850
|
+
if (s.length > o.length) throw new U(I, `Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);
|
|
4845
4851
|
const u = [];
|
|
4846
4852
|
for (let i = 0; i < s.length; i++) {
|
|
4847
4853
|
const c = s[i];
|
|
4848
4854
|
if (o[i].field.isKeyField()) {
|
|
4849
|
-
if ("string" != typeof c) throw new U(
|
|
4850
|
-
if (!he(t) && -1 !== c.indexOf("/")) throw new U(
|
|
4855
|
+
if ("string" != typeof c) throw new U(I, `Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);
|
|
4856
|
+
if (!he(t) && -1 !== c.indexOf("/")) throw new U(I, `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.`);
|
|
4851
4857
|
const n = t.path.child(X.fromString(c));
|
|
4852
|
-
if (!et.isDocumentKey(n)) throw new U(
|
|
4858
|
+
if (!et.isDocumentKey(n)) throw new U(I, `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.`);
|
|
4853
4859
|
const s = new et(n);
|
|
4854
|
-
u.push(
|
|
4860
|
+
u.push(Lt(e, s));
|
|
4855
4861
|
} else {
|
|
4856
4862
|
const t = Ln(n, r, c);
|
|
4857
4863
|
u.push(t);
|
|
4858
4864
|
}
|
|
4859
4865
|
}
|
|
4860
|
-
return new
|
|
4866
|
+
return new re(u, i);
|
|
4861
4867
|
}
|
|
4862
4868
|
/**
|
|
4863
4869
|
* Parses the given `documentIdValue` into a `ReferenceValue`, throwing
|
|
@@ -4869,26 +4875,26 @@ function dr(...t) {
|
|
|
4869
4875
|
|
|
4870
4876
|
function mr(t, e, n) {
|
|
4871
4877
|
if ("string" == typeof (n = getModularInstance(n))) {
|
|
4872
|
-
if ("" === n) throw new U(
|
|
4873
|
-
if (!he(e) && -1 !== n.indexOf("/")) throw new U(
|
|
4878
|
+
if ("" === n) throw new U(I, "Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");
|
|
4879
|
+
if (!he(e) && -1 !== n.indexOf("/")) throw new U(I, `Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);
|
|
4874
4880
|
const r = e.path.child(X.fromString(n));
|
|
4875
|
-
if (!et.isDocumentKey(r)) throw new U(
|
|
4876
|
-
return
|
|
4881
|
+
if (!et.isDocumentKey(r)) throw new U(I, `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}).`);
|
|
4882
|
+
return Lt(t, new et(r));
|
|
4877
4883
|
}
|
|
4878
|
-
if (n instanceof an) return
|
|
4879
|
-
throw new U(
|
|
4884
|
+
if (n instanceof an) return Lt(t, n._key);
|
|
4885
|
+
throw new U(I, `Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${it(n)}.`);
|
|
4880
4886
|
}
|
|
4881
4887
|
|
|
4882
4888
|
/**
|
|
4883
4889
|
* Validates that the value passed into a disjunctive filter satisfies all
|
|
4884
4890
|
* array requirements.
|
|
4885
4891
|
*/ function pr(t, e) {
|
|
4886
|
-
if (!Array.isArray(t) || 0 === t.length) throw new U(
|
|
4887
|
-
if (t.length > 10) throw new U(
|
|
4892
|
+
if (!Array.isArray(t) || 0 === t.length) throw new U(I, `Invalid Query. A non-empty array is required for '${e.toString()}' filters.`);
|
|
4893
|
+
if (t.length > 10) throw new U(I, `Invalid Query. '${e.toString()}' filters support a maximum of 10 elements in the value array.`);
|
|
4888
4894
|
}
|
|
4889
4895
|
|
|
4890
4896
|
function yr(t, e, n) {
|
|
4891
|
-
if (!n.isEqual(e)) throw new U(
|
|
4897
|
+
if (!n.isEqual(e)) throw new U(I, `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.`);
|
|
4892
4898
|
}
|
|
4893
4899
|
|
|
4894
4900
|
/**
|
|
@@ -4949,7 +4955,7 @@ function _r(t, e, n) {
|
|
|
4949
4955
|
|
|
4950
4956
|
class gr extends class {
|
|
4951
4957
|
convertValue(t, e = "none") {
|
|
4952
|
-
switch (
|
|
4958
|
+
switch (xt(t)) {
|
|
4953
4959
|
case 0 /* NullValue */ :
|
|
4954
4960
|
return null;
|
|
4955
4961
|
|
|
@@ -4994,7 +5000,7 @@ class gr extends class {
|
|
|
4994
5000
|
})), n;
|
|
4995
5001
|
}
|
|
4996
5002
|
convertGeoPoint(t) {
|
|
4997
|
-
return new
|
|
5003
|
+
return new vn(Pt(t.latitude), Pt(t.longitude));
|
|
4998
5004
|
}
|
|
4999
5005
|
convertArray(t, e) {
|
|
5000
5006
|
return (t.values || []).map((t => this.convertValue(t, e)));
|
|
@@ -5018,7 +5024,7 @@ class gr extends class {
|
|
|
5018
5024
|
}
|
|
5019
5025
|
convertDocumentKey(t, e) {
|
|
5020
5026
|
const n = X.fromString(t);
|
|
5021
|
-
|
|
5027
|
+
b(We(n));
|
|
5022
5028
|
const r = new K(n.get(1), n.get(3)), s = new et(n.popFirst(5));
|
|
5023
5029
|
return r.isEqual(e) ||
|
|
5024
5030
|
// TODO(b/64130202): Somehow support foreign references.
|
|
@@ -5050,10 +5056,10 @@ class gr extends class {
|
|
|
5050
5056
|
* @param reference - The reference of the document to fetch.
|
|
5051
5057
|
* @returns A Promise resolved with a `DocumentSnapshot` containing the current
|
|
5052
5058
|
* document contents.
|
|
5053
|
-
*/ function
|
|
5059
|
+
*/ function br(t) {
|
|
5054
5060
|
const e = en((t = ot(t, an)).firestore), n = new gr(t.firestore);
|
|
5055
5061
|
return Xe(e, [ t._key ]).then((e => {
|
|
5056
|
-
|
|
5062
|
+
b(1 === e.length);
|
|
5057
5063
|
const r = e[0];
|
|
5058
5064
|
return new Yn(t.firestore, n, t._key, r.isFoundDocument() ? r : null, t.converter);
|
|
5059
5065
|
}));
|
|
@@ -5070,14 +5076,14 @@ class gr extends class {
|
|
|
5070
5076
|
*
|
|
5071
5077
|
* @param query - The `Query` to execute.
|
|
5072
5078
|
* @returns A Promise that will be resolved with the results of the query.
|
|
5073
|
-
*/ function
|
|
5079
|
+
*/ function vr(t) {
|
|
5074
5080
|
!function(t) {
|
|
5075
|
-
if (
|
|
5081
|
+
if ("L" /* Last */ === t.limitType && 0 === t.explicitOrderBy.length) throw new U(q, "limitToLast() queries require specifying at least one orderBy() clause");
|
|
5076
5082
|
}((t = ot(t, hn))._query);
|
|
5077
5083
|
const e = en(t.firestore), n = new gr(t.firestore);
|
|
5078
5084
|
return Ze(e, t._query).then((e => {
|
|
5079
5085
|
const r = e.map((e => new Hn(t.firestore, n, e.key, e, t.converter)));
|
|
5080
|
-
return
|
|
5086
|
+
return "L" /* Last */ === t._query.limitType &&
|
|
5081
5087
|
// Limit to last queries reverse the orderBy constraint that was
|
|
5082
5088
|
// specified by the user. As such, we need to reverse the order of the
|
|
5083
5089
|
// results to return the documents in the expected order.
|
|
@@ -5087,7 +5093,7 @@ class gr extends class {
|
|
|
5087
5093
|
|
|
5088
5094
|
function Er(t, e, n) {
|
|
5089
5095
|
const r = _r((t = ot(t, an)).converter, e, n), s = Dn(Vn(t.firestore), "setDoc", t._key, r, null !== t.converter, n);
|
|
5090
|
-
return Je(en(t.firestore), [ s.toMutation(t._key,
|
|
5096
|
+
return Je(en(t.firestore), [ s.toMutation(t._key, ve.none()) ]);
|
|
5091
5097
|
}
|
|
5092
5098
|
|
|
5093
5099
|
function Tr(t, e, n, ...r) {
|
|
@@ -5096,7 +5102,7 @@ function Tr(t, e, n, ...r) {
|
|
|
5096
5102
|
// performing validation.
|
|
5097
5103
|
let i;
|
|
5098
5104
|
i = "string" == typeof (e = getModularInstance(e)) || e instanceof yn ? Cn(s, "updateDoc", t._key, e, n, r) : On(s, "updateDoc", t._key, e);
|
|
5099
|
-
return Je(en(t.firestore), [ i.toMutation(t._key,
|
|
5105
|
+
return Je(en(t.firestore), [ i.toMutation(t._key, ve.exists(!0)) ]);
|
|
5100
5106
|
}
|
|
5101
5107
|
|
|
5102
5108
|
/**
|
|
@@ -5110,8 +5116,8 @@ function Tr(t, e, n, ...r) {
|
|
|
5110
5116
|
* @param reference - A reference to the document to delete.
|
|
5111
5117
|
* @returns A `Promise` resolved once the document has been successfully
|
|
5112
5118
|
* deleted from the backend.
|
|
5113
|
-
*/ function
|
|
5114
|
-
return Je(en((t = ot(t, an)).firestore), [ new
|
|
5119
|
+
*/ function Ar(t) {
|
|
5120
|
+
return Je(en((t = ot(t, an)).firestore), [ new Ie(t._key, ve.none()) ]);
|
|
5115
5121
|
}
|
|
5116
5122
|
|
|
5117
5123
|
/**
|
|
@@ -5128,9 +5134,9 @@ function Tr(t, e, n, ...r) {
|
|
|
5128
5134
|
* @throws Error - If the provided input is not a valid Firestore document.
|
|
5129
5135
|
* @returns A `Promise` resolved with a `DocumentReference` pointing to the
|
|
5130
5136
|
* newly created document after it has been written to the backend.
|
|
5131
|
-
*/ function
|
|
5137
|
+
*/ function Ir(t, e) {
|
|
5132
5138
|
const n = wn(t = ot(t, ln)), r = _r(t.converter, e), s = Dn(Vn(t.firestore), "addDoc", n._key, r, null !== n.converter, {});
|
|
5133
|
-
return Je(en(t.firestore), [ s.toMutation(n._key,
|
|
5139
|
+
return Je(en(t.firestore), [ s.toMutation(n._key, ve.exists(!1)) ]).then((() => n));
|
|
5134
5140
|
}
|
|
5135
5141
|
|
|
5136
5142
|
/**
|
|
@@ -5177,7 +5183,7 @@ function Tr(t, e, n, ...r) {
|
|
|
5177
5183
|
*/ function Vr(...t) {
|
|
5178
5184
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5179
5185
|
// update() since we'd need the Firestore instance to do this.
|
|
5180
|
-
return new
|
|
5186
|
+
return new xn("arrayUnion", t);
|
|
5181
5187
|
}
|
|
5182
5188
|
|
|
5183
5189
|
/**
|
|
@@ -5193,7 +5199,7 @@ function Tr(t, e, n, ...r) {
|
|
|
5193
5199
|
*/ function Dr(...t) {
|
|
5194
5200
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5195
5201
|
// update() since we'd need the Firestore instance to do this.
|
|
5196
|
-
return new
|
|
5202
|
+
return new Fn("arrayRemove", t);
|
|
5197
5203
|
}
|
|
5198
5204
|
|
|
5199
5205
|
/**
|
|
@@ -5250,7 +5256,7 @@ function Tr(t, e, n, ...r) {
|
|
|
5250
5256
|
set(t, e, n) {
|
|
5251
5257
|
this._verifyNotCommitted();
|
|
5252
5258
|
const r = Sr(t, this._firestore), s = _r(r.converter, e, n), i = Dn(this._dataReader, "WriteBatch.set", r._key, s, null !== r.converter, n);
|
|
5253
|
-
return this._mutations.push(i.toMutation(r._key,
|
|
5259
|
+
return this._mutations.push(i.toMutation(r._key, ve.none())), this;
|
|
5254
5260
|
}
|
|
5255
5261
|
update(t, e, n, ...r) {
|
|
5256
5262
|
this._verifyNotCommitted();
|
|
@@ -5259,7 +5265,7 @@ function Tr(t, e, n, ...r) {
|
|
|
5259
5265
|
// performing validation.
|
|
5260
5266
|
let i;
|
|
5261
5267
|
return i = "string" == typeof (e = getModularInstance(e)) || e instanceof yn ? Cn(this._dataReader, "WriteBatch.update", s._key, e, n, r) : On(this._dataReader, "WriteBatch.update", s._key, e),
|
|
5262
|
-
this._mutations.push(i.toMutation(s._key,
|
|
5268
|
+
this._mutations.push(i.toMutation(s._key, ve.exists(!0))), this;
|
|
5263
5269
|
}
|
|
5264
5270
|
/**
|
|
5265
5271
|
* Deletes the document referred to by the provided {@link DocumentReference}.
|
|
@@ -5269,7 +5275,7 @@ function Tr(t, e, n, ...r) {
|
|
|
5269
5275
|
*/ delete(t) {
|
|
5270
5276
|
this._verifyNotCommitted();
|
|
5271
5277
|
const e = Sr(t, this._firestore);
|
|
5272
|
-
return this._mutations = this._mutations.concat(new
|
|
5278
|
+
return this._mutations = this._mutations.concat(new Ie(e._key, ve.none())), this;
|
|
5273
5279
|
}
|
|
5274
5280
|
/**
|
|
5275
5281
|
* Commits all of the writes in this write batch as a single atomic unit.
|
|
@@ -5291,7 +5297,7 @@ function Tr(t, e, n, ...r) {
|
|
|
5291
5297
|
}
|
|
5292
5298
|
|
|
5293
5299
|
function Sr(t, e) {
|
|
5294
|
-
if ((t = getModularInstance(t)).firestore !== e) throw new U(
|
|
5300
|
+
if ((t = getModularInstance(t)).firestore !== e) throw new U(I, "Provided document reference is from a different Firestore instance.");
|
|
5295
5301
|
return t;
|
|
5296
5302
|
}
|
|
5297
5303
|
|
|
@@ -5307,7 +5313,7 @@ function Sr(t, e) {
|
|
|
5307
5313
|
*
|
|
5308
5314
|
* @returns A `WriteBatch` that can be used to atomically execute multiple
|
|
5309
5315
|
* writes.
|
|
5310
|
-
*/ function
|
|
5316
|
+
*/ function xr(t) {
|
|
5311
5317
|
const e = en(t = ot(t, rn));
|
|
5312
5318
|
return new $r(t, (t => Je(e, t)));
|
|
5313
5319
|
}
|
|
@@ -5331,7 +5337,7 @@ function Sr(t, e) {
|
|
|
5331
5337
|
/**
|
|
5332
5338
|
* Internal transaction object responsible for accumulating the mutations to
|
|
5333
5339
|
* perform and the base versions for any documents read.
|
|
5334
|
-
*/ class
|
|
5340
|
+
*/ class Fr {
|
|
5335
5341
|
constructor(t) {
|
|
5336
5342
|
this.datastore = t,
|
|
5337
5343
|
// The version of each document that was read during this transaction.
|
|
@@ -5350,7 +5356,7 @@ function Sr(t, e) {
|
|
|
5350
5356
|
this.writtenDocs = new Set;
|
|
5351
5357
|
}
|
|
5352
5358
|
async lookup(t) {
|
|
5353
|
-
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new U(
|
|
5359
|
+
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new U(I, "Firestore transactions require all reads to be executed before all writes.");
|
|
5354
5360
|
const e = await Xe(this.datastore, t);
|
|
5355
5361
|
return e.forEach((t => this.recordVersion(t))), e;
|
|
5356
5362
|
}
|
|
@@ -5366,7 +5372,7 @@ function Sr(t, e) {
|
|
|
5366
5372
|
this.writtenDocs.add(t.toString());
|
|
5367
5373
|
}
|
|
5368
5374
|
delete(t) {
|
|
5369
|
-
this.write(new
|
|
5375
|
+
this.write(new Ie(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5370
5376
|
}
|
|
5371
5377
|
async commit() {
|
|
5372
5378
|
if (this.ensureCommitNotCalled(), this.lastWriteError) throw this.lastWriteError;
|
|
@@ -5387,13 +5393,13 @@ function Sr(t, e) {
|
|
|
5387
5393
|
if (t.isFoundDocument()) e = t.version; else {
|
|
5388
5394
|
if (!t.isNoDocument()) throw g();
|
|
5389
5395
|
// For deleted docs, we must use baseVersion 0 when we overwrite them.
|
|
5390
|
-
e =
|
|
5396
|
+
e = bt.min();
|
|
5391
5397
|
}
|
|
5392
5398
|
const n = this.readVersions.get(t.key.toString());
|
|
5393
5399
|
if (n) {
|
|
5394
5400
|
if (!e.isEqual(n))
|
|
5395
5401
|
// This transaction will fail no matter what.
|
|
5396
|
-
throw new U(
|
|
5402
|
+
throw new U(x, "Document version changed between two reads.");
|
|
5397
5403
|
} else this.readVersions.set(t.key.toString(), e);
|
|
5398
5404
|
}
|
|
5399
5405
|
/**
|
|
@@ -5401,7 +5407,7 @@ function Sr(t, e) {
|
|
|
5401
5407
|
* as a precondition, or no precondition if it was not read.
|
|
5402
5408
|
*/ precondition(t) {
|
|
5403
5409
|
const e = this.readVersions.get(t.toString());
|
|
5404
|
-
return !this.writtenDocs.has(t.toString()) && e ?
|
|
5410
|
+
return !this.writtenDocs.has(t.toString()) && e ? ve.updateTime(e) : ve.none();
|
|
5405
5411
|
}
|
|
5406
5412
|
/**
|
|
5407
5413
|
* Returns the precondition for a document if the operation is an update.
|
|
@@ -5410,7 +5416,7 @@ function Sr(t, e) {
|
|
|
5410
5416
|
// The first time a document is written, we want to take into account the
|
|
5411
5417
|
// read time and existence
|
|
5412
5418
|
if (!this.writtenDocs.has(t.toString()) && e) {
|
|
5413
|
-
if (e.isEqual(
|
|
5419
|
+
if (e.isEqual(bt.min()))
|
|
5414
5420
|
// The document doesn't exist, so fail the transaction.
|
|
5415
5421
|
// This has to be validated locally because you can't send a
|
|
5416
5422
|
// precondition that a document does not exist without changing the
|
|
@@ -5420,13 +5426,13 @@ function Sr(t, e) {
|
|
|
5420
5426
|
// express that to the backend, we have to validate locally.
|
|
5421
5427
|
// Note: this can change once we can send separate verify writes in the
|
|
5422
5428
|
// transaction.
|
|
5423
|
-
throw new U(
|
|
5429
|
+
throw new U(I, "Can't update a document that doesn't exist.");
|
|
5424
5430
|
// Document exists, base precondition on document update time.
|
|
5425
|
-
return
|
|
5431
|
+
return ve.updateTime(e);
|
|
5426
5432
|
}
|
|
5427
5433
|
// Document was not read, so we just use the preconditions for a blind
|
|
5428
5434
|
// update.
|
|
5429
|
-
return
|
|
5435
|
+
return ve.exists(!0);
|
|
5430
5436
|
}
|
|
5431
5437
|
write(t) {
|
|
5432
5438
|
this.ensureCommitNotCalled(), this.mutations.push(t);
|
|
@@ -5434,6 +5440,25 @@ function Sr(t, e) {
|
|
|
5434
5440
|
ensureCommitNotCalled() {}
|
|
5435
5441
|
}
|
|
5436
5442
|
|
|
5443
|
+
/**
|
|
5444
|
+
* @license
|
|
5445
|
+
* Copyright 2022 Google LLC
|
|
5446
|
+
*
|
|
5447
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5448
|
+
* you may not use this file except in compliance with the License.
|
|
5449
|
+
* You may obtain a copy of the License at
|
|
5450
|
+
*
|
|
5451
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
5452
|
+
*
|
|
5453
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
5454
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
5455
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5456
|
+
* See the License for the specific language governing permissions and
|
|
5457
|
+
* limitations under the License.
|
|
5458
|
+
*/ const qr = {
|
|
5459
|
+
maxAttempts: 5
|
|
5460
|
+
};
|
|
5461
|
+
|
|
5437
5462
|
/**
|
|
5438
5463
|
* @license
|
|
5439
5464
|
* Copyright 2019 Google LLC
|
|
@@ -5454,17 +5479,17 @@ function Sr(t, e) {
|
|
|
5454
5479
|
* TransactionRunner encapsulates the logic needed to run and retry transactions
|
|
5455
5480
|
* with backoff.
|
|
5456
5481
|
*/
|
|
5457
|
-
class
|
|
5458
|
-
constructor(t, e, n, r) {
|
|
5459
|
-
this.asyncQueue = t, this.datastore = e, this.
|
|
5460
|
-
this.Tt =
|
|
5482
|
+
class Or {
|
|
5483
|
+
constructor(t, e, n, r, s) {
|
|
5484
|
+
this.asyncQueue = t, this.datastore = e, this.options = n, this.updateFunction = r,
|
|
5485
|
+
this.deferred = s, this.Tt = n.maxAttempts, this.At = new He(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
|
|
5461
5486
|
}
|
|
5462
5487
|
/** Runs the transaction and sets the result on deferred. */ run() {
|
|
5463
|
-
this.Tt -= 1, this.
|
|
5488
|
+
this.Tt -= 1, this.It();
|
|
5464
5489
|
}
|
|
5465
|
-
|
|
5466
|
-
this.
|
|
5467
|
-
const t = new
|
|
5490
|
+
It() {
|
|
5491
|
+
this.At.W((async () => {
|
|
5492
|
+
const t = new Fr(this.datastore), e = this.Rt(t);
|
|
5468
5493
|
e && e.then((e => {
|
|
5469
5494
|
this.asyncQueue.enqueueAndForget((() => t.commit().then((() => {
|
|
5470
5495
|
this.deferred.resolve(e);
|
|
@@ -5487,7 +5512,7 @@ class qr {
|
|
|
5487
5512
|
}
|
|
5488
5513
|
}
|
|
5489
5514
|
Pt(t) {
|
|
5490
|
-
this.Tt > 0 && this.Vt(t) ? (this.Tt -= 1, this.asyncQueue.enqueueAndForget((() => (this.
|
|
5515
|
+
this.Tt > 0 && this.Vt(t) ? (this.Tt -= 1, this.asyncQueue.enqueueAndForget((() => (this.It(),
|
|
5491
5516
|
Promise.resolve())))) : this.deferred.reject(t);
|
|
5492
5517
|
}
|
|
5493
5518
|
Vt(t) {
|
|
@@ -5508,7 +5533,7 @@ class qr {
|
|
|
5508
5533
|
return g();
|
|
5509
5534
|
|
|
5510
5535
|
case T:
|
|
5511
|
-
case
|
|
5536
|
+
case A:
|
|
5512
5537
|
case R:
|
|
5513
5538
|
case $:
|
|
5514
5539
|
case O:
|
|
@@ -5518,7 +5543,7 @@ class qr {
|
|
|
5518
5543
|
case N:
|
|
5519
5544
|
return !1;
|
|
5520
5545
|
|
|
5521
|
-
case
|
|
5546
|
+
case I:
|
|
5522
5547
|
case P:
|
|
5523
5548
|
case V:
|
|
5524
5549
|
case D:
|
|
@@ -5526,8 +5551,8 @@ class qr {
|
|
|
5526
5551
|
// Aborted might be retried in some scenarios, but that is dependant on
|
|
5527
5552
|
// the context and should handled individually by the calling code.
|
|
5528
5553
|
// See https://cloud.google.com/apis/design/errors.
|
|
5529
|
-
case
|
|
5530
|
-
case
|
|
5554
|
+
case x:
|
|
5555
|
+
case F:
|
|
5531
5556
|
case q:
|
|
5532
5557
|
case L:
|
|
5533
5558
|
return !0;
|
|
@@ -5554,7 +5579,7 @@ class qr {
|
|
|
5554
5579
|
* See the License for the specific language governing permissions and
|
|
5555
5580
|
* limitations under the License.
|
|
5556
5581
|
*/
|
|
5557
|
-
/** The Platform's 'document' implementation or null if not available. */ function
|
|
5582
|
+
/** The Platform's 'document' implementation or null if not available. */ function Cr() {
|
|
5558
5583
|
// `document` is not always available, e.g. in ReactNative and WebWorkers.
|
|
5559
5584
|
// eslint-disable-next-line no-restricted-globals
|
|
5560
5585
|
return "undefined" != typeof document ? document : null;
|
|
@@ -5586,7 +5611,7 @@ class qr {
|
|
|
5586
5611
|
* Note: We implement `PromiseLike` instead of `Promise`, as the `Promise` type
|
|
5587
5612
|
* in newer versions of TypeScript defines `finally`, which is not available in
|
|
5588
5613
|
* IE.
|
|
5589
|
-
*/ class
|
|
5614
|
+
*/ class Lr {
|
|
5590
5615
|
constructor(t, e, n, r, s) {
|
|
5591
5616
|
this.asyncQueue = t, this.timerId = e, this.targetTimeMs = n, this.op = r, this.removalCallback = s,
|
|
5592
5617
|
this.deferred = new k, this.then = this.deferred.promise.then.bind(this.deferred.promise),
|
|
@@ -5609,7 +5634,7 @@ class qr {
|
|
|
5609
5634
|
* PORTING NOTE: This exists to prevent making removeDelayedOperation() and
|
|
5610
5635
|
* the DelayedOperation class public.
|
|
5611
5636
|
*/ static createAndSchedule(t, e, n, r, s) {
|
|
5612
|
-
const i = Date.now() + n, o = new
|
|
5637
|
+
const i = Date.now() + n, o = new Lr(t, e, i, r, s);
|
|
5613
5638
|
return o.start(n), o;
|
|
5614
5639
|
}
|
|
5615
5640
|
/**
|
|
@@ -5658,7 +5683,7 @@ class qr {
|
|
|
5658
5683
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5659
5684
|
* See the License for the specific language governing permissions and
|
|
5660
5685
|
* limitations under the License.
|
|
5661
|
-
*/ class
|
|
5686
|
+
*/ class Ur {
|
|
5662
5687
|
constructor() {
|
|
5663
5688
|
// The last promise in the queue.
|
|
5664
5689
|
this.Dt = Promise.resolve(),
|
|
@@ -5672,24 +5697,24 @@ class qr {
|
|
|
5672
5697
|
// automatically removed after they are run or canceled.
|
|
5673
5698
|
this.St = [],
|
|
5674
5699
|
// visible for testing
|
|
5675
|
-
this.
|
|
5700
|
+
this.xt = null,
|
|
5676
5701
|
// Flag set while there's an outstanding AsyncQueue operation, used for
|
|
5677
5702
|
// assertion sanity-checks.
|
|
5678
|
-
this.
|
|
5703
|
+
this.Ft = !1,
|
|
5679
5704
|
// Enabled during shutdown on Safari to prevent future access to IndexedDB.
|
|
5680
5705
|
this.qt = !1,
|
|
5681
5706
|
// List of TimerIds to fast-forward delays for.
|
|
5682
5707
|
this.Ot = [],
|
|
5683
5708
|
// Backoff timer used to schedule retries for retryable operations
|
|
5684
|
-
this.
|
|
5709
|
+
this.At = new He(this, "async_queue_retry" /* AsyncQueueRetry */),
|
|
5685
5710
|
// Visibility handler that triggers an immediate retry of all retryable
|
|
5686
5711
|
// operations. Meant to speed up recovery when we regain file system access
|
|
5687
5712
|
// after page comes into foreground.
|
|
5688
5713
|
this.Ct = () => {
|
|
5689
|
-
const t =
|
|
5690
|
-
t && m("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.
|
|
5714
|
+
const t = Cr();
|
|
5715
|
+
t && m("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.At.H();
|
|
5691
5716
|
};
|
|
5692
|
-
const t =
|
|
5717
|
+
const t = Cr();
|
|
5693
5718
|
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.Ct);
|
|
5694
5719
|
}
|
|
5695
5720
|
get isShuttingDown() {
|
|
@@ -5710,7 +5735,7 @@ class qr {
|
|
|
5710
5735
|
enterRestrictedMode(t) {
|
|
5711
5736
|
if (!this.$t) {
|
|
5712
5737
|
this.$t = !0, this.qt = t || !1;
|
|
5713
|
-
const e =
|
|
5738
|
+
const e = Cr();
|
|
5714
5739
|
e && "function" == typeof e.removeEventListener && e.removeEventListener("visibilitychange", this.Ct);
|
|
5715
5740
|
}
|
|
5716
5741
|
}
|
|
@@ -5734,7 +5759,7 @@ class qr {
|
|
|
5734
5759
|
*/ async kt() {
|
|
5735
5760
|
if (0 !== this.Nt.length) {
|
|
5736
5761
|
try {
|
|
5737
|
-
await this.Nt[0](), this.Nt.shift(), this.
|
|
5762
|
+
await this.Nt[0](), this.Nt.shift(), this.At.reset();
|
|
5738
5763
|
} catch (t) {
|
|
5739
5764
|
if (!
|
|
5740
5765
|
/**
|
|
@@ -5789,12 +5814,12 @@ class qr {
|
|
|
5789
5814
|
// Since `backoffAndRun()` cancels an existing backoff and schedules a
|
|
5790
5815
|
// new backoff on every call, there is only ever a single additional
|
|
5791
5816
|
// operation in the queue.
|
|
5792
|
-
this.
|
|
5817
|
+
this.At.W((() => this.kt()));
|
|
5793
5818
|
}
|
|
5794
5819
|
}
|
|
5795
5820
|
Ut(t) {
|
|
5796
|
-
const e = this.Dt.then((() => (this.
|
|
5797
|
-
this.
|
|
5821
|
+
const e = this.Dt.then((() => (this.Ft = !0, t().catch((t => {
|
|
5822
|
+
this.xt = t, this.Ft = !1;
|
|
5798
5823
|
const e =
|
|
5799
5824
|
/**
|
|
5800
5825
|
* Chrome includes Error.message in Error.stack. Other browsers do not.
|
|
@@ -5835,18 +5860,18 @@ class qr {
|
|
|
5835
5860
|
// all further attempts to chain (via .then) will just short-circuit
|
|
5836
5861
|
// and return the rejected Promise.
|
|
5837
5862
|
throw p("INTERNAL UNHANDLED ERROR: ", e), t;
|
|
5838
|
-
})).then((t => (this.
|
|
5863
|
+
})).then((t => (this.Ft = !1, t))))));
|
|
5839
5864
|
return this.Dt = e, e;
|
|
5840
5865
|
}
|
|
5841
5866
|
enqueueAfterDelay(t, e, n) {
|
|
5842
5867
|
this.Lt(),
|
|
5843
5868
|
// Fast-forward delays for timerIds that have been overriden.
|
|
5844
5869
|
this.Ot.indexOf(t) > -1 && (e = 0);
|
|
5845
|
-
const r =
|
|
5870
|
+
const r = Lr.createAndSchedule(this, t, e, n, (t => this.jt(t)));
|
|
5846
5871
|
return this.St.push(r), r;
|
|
5847
5872
|
}
|
|
5848
5873
|
Lt() {
|
|
5849
|
-
this.
|
|
5874
|
+
this.xt && g();
|
|
5850
5875
|
}
|
|
5851
5876
|
verifyOperationInProgress() {}
|
|
5852
5877
|
/**
|
|
@@ -5896,7 +5921,7 @@ class qr {
|
|
|
5896
5921
|
}
|
|
5897
5922
|
}
|
|
5898
5923
|
|
|
5899
|
-
class
|
|
5924
|
+
class kr {
|
|
5900
5925
|
/** @hideconstructor */
|
|
5901
5926
|
constructor(t, e) {
|
|
5902
5927
|
this._firestore = t, this._transaction = e, this._dataReader = Vn(t);
|
|
@@ -5955,9 +5980,13 @@ class Ur {
|
|
|
5955
5980
|
* (the `updateFunction` returned a failed promise), the promise returned by the
|
|
5956
5981
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
5957
5982
|
* rejected promise with the corresponding failure error is returned.
|
|
5958
|
-
*/ function
|
|
5959
|
-
const
|
|
5960
|
-
|
|
5983
|
+
*/ function jr(t, e, n) {
|
|
5984
|
+
const r = en(t = ot(t, rn)), s = Object.assign(Object.assign({}, qr), n);
|
|
5985
|
+
!function(t) {
|
|
5986
|
+
if (t.maxAttempts < 1) throw new U(I, "Max attempts must be at least 1");
|
|
5987
|
+
}(s);
|
|
5988
|
+
const i = new k;
|
|
5989
|
+
return new Or(new Ur, r, s, (n => e(new kr(t, n))), i).run(), i.promise;
|
|
5961
5990
|
}
|
|
5962
5991
|
|
|
5963
5992
|
/**
|
|
@@ -5974,7 +6003,7 @@ class Ur {
|
|
|
5974
6003
|
return e && r._setSettings(e), r;
|
|
5975
6004
|
}), "PUBLIC")),
|
|
5976
6005
|
// RUNTIME_ENV and BUILD_TARGET are replaced by real values during the compilation
|
|
5977
|
-
registerVersion("firestore-lite", "3.4.
|
|
6006
|
+
registerVersion("firestore-lite", "3.4.9", ""), registerVersion("firestore-lite", "3.4.9", "esm2017");
|
|
5978
6007
|
|
|
5979
|
-
export { gn as Bytes, ln as CollectionReference, an as DocumentReference, Yn as DocumentSnapshot, yn as FieldPath,
|
|
6008
|
+
export { gn as Bytes, ln as CollectionReference, an as DocumentReference, Yn as DocumentSnapshot, yn as FieldPath, bn as FieldValue, rn as Firestore, U as FirestoreError, vn as GeoPoint, hn as Query, Zn as QueryConstraint, Hn as QueryDocumentSnapshot, Kn as QuerySnapshot, gt as Timestamp, kr as Transaction, $r as WriteBatch, Ir as addDoc, Dr as arrayRemove, Vr as arrayUnion, fn as collection, dn as collectionGroup, un as connectFirestoreEmulator, Ar as deleteDoc, Rr as deleteField, wn as doc, _n as documentId, dr as endAt, fr as endBefore, br as getDoc, vr as getDocs, on as getFirestore, Nr as increment, sn as initializeFirestore, or as limit, ur as limitToLast, sr as orderBy, tr as query, pn as queryEqual, mn as refEqual, jr as runTransaction, Pr as serverTimestamp, Er as setDoc, w as setLogLevel, Jn as snapshotEqual, hr as startAfter, ar as startAt, cn as terminate, Tr as updateDoc, nr as where, xr as writeBatch };
|
|
5980
6009
|
//# sourceMappingURL=index.browser.esm2017.js.map
|