@firebase/firestore 4.7.5 → 4.7.6-canary.144bc3709
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/dist/firestore/src/global_index.d.ts +8 -0
- package/dist/firestore/src/model/path.d.ts +8 -0
- package/dist/index.cjs.js +219 -197
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +219 -197
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.node.cjs.js +48 -13
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +48 -13
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +317 -295
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +8 -0
- package/dist/lite/firestore/src/model/path.d.ts +8 -0
- package/dist/lite/index.browser.esm2017.js +193 -176
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.cjs.js +193 -176
- package/dist/lite/index.cjs.js.map +1 -1
- package/dist/lite/index.node.cjs.js +41 -12
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +41 -12
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +181 -163
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +8 -0
- package/dist/lite/private.d.ts +8 -0
- package/dist/packages/firestore/src/model/path.d.ts +8 -0
- package/dist/private.d.ts +8 -0
- package/package.json +9 -9
package/dist/lite/index.cjs.js
CHANGED
|
@@ -2,6 +2,7 @@ import { _registerComponent, registerVersion, _getProvider, getApp, _removeServi
|
|
|
2
2
|
import { Component } from '@firebase/component';
|
|
3
3
|
import { Logger, LogLevel } from '@firebase/logger';
|
|
4
4
|
import { FirebaseError, getDefaultEmulatorHostnameAndPort, createMockUserToken, getModularInstance, deepEqual } from '@firebase/util';
|
|
5
|
+
import { Integer } from '@firebase/webchannel-wrapper/bloom-blob';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @license
|
|
@@ -63,7 +64,7 @@ User.MOCK_USER = new User("mock-user");
|
|
|
63
64
|
* See the License for the specific language governing permissions and
|
|
64
65
|
* limitations under the License.
|
|
65
66
|
*/
|
|
66
|
-
let
|
|
67
|
+
let f = "11.2.0-canary.144bc3709";
|
|
67
68
|
|
|
68
69
|
/**
|
|
69
70
|
* @license
|
|
@@ -81,7 +82,7 @@ let d = "11.0.2";
|
|
|
81
82
|
* See the License for the specific language governing permissions and
|
|
82
83
|
* limitations under the License.
|
|
83
84
|
*/
|
|
84
|
-
const
|
|
85
|
+
const E = new Logger("@firebase/firestore");
|
|
85
86
|
|
|
86
87
|
/**
|
|
87
88
|
* Sets the verbosity of Cloud Firestore logs (debug, error, or silent).
|
|
@@ -96,29 +97,29 @@ const f = new Logger("@firebase/firestore");
|
|
|
96
97
|
* <li><code>`silent` to turn off logging.</li>
|
|
97
98
|
* </ul>
|
|
98
99
|
*/ function setLogLevel(t) {
|
|
99
|
-
|
|
100
|
+
E.setLogLevel(t);
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
function __PRIVATE_logDebug(t, ...e) {
|
|
103
|
-
if (
|
|
104
|
+
if (E.logLevel <= LogLevel.DEBUG) {
|
|
104
105
|
const r = e.map(__PRIVATE_argToString);
|
|
105
|
-
|
|
106
|
+
E.debug(`Firestore (${f}): ${t}`, ...r);
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
109
|
|
|
109
110
|
function __PRIVATE_logError(t, ...e) {
|
|
110
|
-
if (
|
|
111
|
+
if (E.logLevel <= LogLevel.ERROR) {
|
|
111
112
|
const r = e.map(__PRIVATE_argToString);
|
|
112
|
-
|
|
113
|
+
E.error(`Firestore (${f}): ${t}`, ...r);
|
|
113
114
|
}
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
/**
|
|
117
118
|
* @internal
|
|
118
119
|
*/ function __PRIVATE_logWarn(t, ...e) {
|
|
119
|
-
if (
|
|
120
|
+
if (E.logLevel <= LogLevel.WARN) {
|
|
120
121
|
const r = e.map(__PRIVATE_argToString);
|
|
121
|
-
|
|
122
|
+
E.warn(`Firestore (${f}): ${t}`, ...r);
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
125
|
|
|
@@ -179,7 +180,7 @@ function __PRIVATE_logError(t, ...e) {
|
|
|
179
180
|
*/ function fail(t = "Unexpected state") {
|
|
180
181
|
// Log the failure in addition to throw an exception, just in case the
|
|
181
182
|
// exception is swallowed.
|
|
182
|
-
const e = `FIRESTORE (${
|
|
183
|
+
const e = `FIRESTORE (${f}) INTERNAL ASSERTION FAILED: ` + t;
|
|
183
184
|
// NOTE: We don't use FirestoreError here because these are internal failures
|
|
184
185
|
// that cannot be handled by the user. (Also it would create a circular
|
|
185
186
|
// dependency between the error and assert modules which doesn't work.)
|
|
@@ -219,7 +220,7 @@ e) {
|
|
|
219
220
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
220
221
|
* See the License for the specific language governing permissions and
|
|
221
222
|
* limitations under the License.
|
|
222
|
-
*/ const
|
|
223
|
+
*/ const m = "ok", A = "cancelled", T = "unknown", P = "invalid-argument", R = "deadline-exceeded", I = "not-found", V = "already-exists", p = "permission-denied", y = "unauthenticated", w = "resource-exhausted", g = "failed-precondition", F = "aborted", v = "out-of-range", D = "unimplemented", b = "internal", C = "unavailable", S = "data-loss";
|
|
223
224
|
|
|
224
225
|
/** An error returned by a Firestore operation. */ class FirestoreError extends FirebaseError {
|
|
225
226
|
/** @hideconstructor */
|
|
@@ -530,14 +531,30 @@ class BasePath {
|
|
|
530
531
|
toArray() {
|
|
531
532
|
return this.segments.slice(this.offset, this.limit());
|
|
532
533
|
}
|
|
533
|
-
|
|
534
|
+
/**
|
|
535
|
+
* Compare 2 paths segment by segment, prioritizing numeric IDs
|
|
536
|
+
* (e.g., "__id123__") in numeric ascending order, followed by string
|
|
537
|
+
* segments in lexicographical order.
|
|
538
|
+
*/ static comparator(t, e) {
|
|
534
539
|
const r = Math.min(t.length, e.length);
|
|
535
540
|
for (let n = 0; n < r; n++) {
|
|
536
|
-
const r = t.get(n),
|
|
537
|
-
if (
|
|
538
|
-
if (r > i) return 1;
|
|
541
|
+
const r = BasePath.compareSegments(t.get(n), e.get(n));
|
|
542
|
+
if (0 !== r) return r;
|
|
539
543
|
}
|
|
540
|
-
return t.length
|
|
544
|
+
return Math.sign(t.length - e.length);
|
|
545
|
+
}
|
|
546
|
+
static compareSegments(t, e) {
|
|
547
|
+
const r = BasePath.isNumericId(t), n = BasePath.isNumericId(e);
|
|
548
|
+
return r && !n ? -1 : !r && n ? 1 : r && n ? BasePath.extractNumericId(t).compare(BasePath.extractNumericId(e)) :
|
|
549
|
+
// both non-numeric
|
|
550
|
+
t < e ? -1 : t > e ? 1 : 0;
|
|
551
|
+
}
|
|
552
|
+
// Checks if a segment is a numeric ID (starts with "__id" and ends with "__").
|
|
553
|
+
static isNumericId(t) {
|
|
554
|
+
return t.startsWith("__id") && t.endsWith("__");
|
|
555
|
+
}
|
|
556
|
+
static extractNumericId(t) {
|
|
557
|
+
return Integer.fromString(t.substring(4, t.length - 2));
|
|
541
558
|
}
|
|
542
559
|
}
|
|
543
560
|
|
|
@@ -576,7 +593,7 @@ class BasePath {
|
|
|
576
593
|
// for legacy reasons and should not be used frequently).
|
|
577
594
|
const e = [];
|
|
578
595
|
for (const r of t) {
|
|
579
|
-
if (r.indexOf("//") >= 0) throw new FirestoreError(
|
|
596
|
+
if (r.indexOf("//") >= 0) throw new FirestoreError(P, `Invalid segment (${r}). Paths must not contain // in them.`);
|
|
580
597
|
// Strip leading and trailing slashed.
|
|
581
598
|
e.push(...r.split("/").filter((t => t.length > 0)));
|
|
582
599
|
}
|
|
@@ -587,7 +604,7 @@ class BasePath {
|
|
|
587
604
|
}
|
|
588
605
|
}
|
|
589
606
|
|
|
590
|
-
const
|
|
607
|
+
const N = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
591
608
|
|
|
592
609
|
/**
|
|
593
610
|
* A dot-separated path for navigating sub-objects within a document.
|
|
@@ -600,7 +617,7 @@ const S = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
600
617
|
* Returns true if the string could be used as a segment in a field path
|
|
601
618
|
* without escaping.
|
|
602
619
|
*/ static isValidIdentifier(t) {
|
|
603
|
-
return
|
|
620
|
+
return N.test(t);
|
|
604
621
|
}
|
|
605
622
|
canonicalString() {
|
|
606
623
|
return this.toArray().map((t => (t = t.replace(/\\/g, "\\\\").replace(/`/g, "\\`"),
|
|
@@ -632,21 +649,21 @@ const S = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
632
649
|
const e = [];
|
|
633
650
|
let r = "", n = 0;
|
|
634
651
|
const __PRIVATE_addCurrentSegment = () => {
|
|
635
|
-
if (0 === r.length) throw new FirestoreError(
|
|
652
|
+
if (0 === r.length) throw new FirestoreError(P, `Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);
|
|
636
653
|
e.push(r), r = "";
|
|
637
654
|
};
|
|
638
655
|
let i = !1;
|
|
639
656
|
for (;n < t.length; ) {
|
|
640
657
|
const e = t[n];
|
|
641
658
|
if ("\\" === e) {
|
|
642
|
-
if (n + 1 === t.length) throw new FirestoreError(
|
|
659
|
+
if (n + 1 === t.length) throw new FirestoreError(P, "Path has trailing escape character: " + t);
|
|
643
660
|
const e = t[n + 1];
|
|
644
|
-
if ("\\" !== e && "." !== e && "`" !== e) throw new FirestoreError(
|
|
661
|
+
if ("\\" !== e && "." !== e && "`" !== e) throw new FirestoreError(P, "Path has invalid escape sequence: " + t);
|
|
645
662
|
r += e, n += 2;
|
|
646
663
|
} else "`" === e ? (i = !i, n++) : "." !== e || i ? (r += e, n++) : (__PRIVATE_addCurrentSegment(),
|
|
647
664
|
n++);
|
|
648
665
|
}
|
|
649
|
-
if (__PRIVATE_addCurrentSegment(), i) throw new FirestoreError(
|
|
666
|
+
if (__PRIVATE_addCurrentSegment(), i) throw new FirestoreError(P, "Unterminated ` in path: " + t);
|
|
650
667
|
return new FieldPath$1(e);
|
|
651
668
|
}
|
|
652
669
|
static emptyPath() {
|
|
@@ -735,7 +752,7 @@ const S = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
735
752
|
* See the License for the specific language governing permissions and
|
|
736
753
|
* limitations under the License.
|
|
737
754
|
*/ function __PRIVATE_validateNonEmptyArgument(t, e, r) {
|
|
738
|
-
if (!r) throw new FirestoreError(
|
|
755
|
+
if (!r) throw new FirestoreError(P, `Function ${t}() cannot be called with an empty ${e}.`);
|
|
739
756
|
}
|
|
740
757
|
|
|
741
758
|
/**
|
|
@@ -747,14 +764,14 @@ const S = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
747
764
|
* an even numbers of segments).
|
|
748
765
|
*/
|
|
749
766
|
function __PRIVATE_validateDocumentPath(t) {
|
|
750
|
-
if (!DocumentKey.isDocumentKey(t)) throw new FirestoreError(
|
|
767
|
+
if (!DocumentKey.isDocumentKey(t)) throw new FirestoreError(P, `Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`);
|
|
751
768
|
}
|
|
752
769
|
|
|
753
770
|
/**
|
|
754
771
|
* Validates that `path` refers to a collection (indicated by the fact it
|
|
755
772
|
* contains an odd numbers of segments).
|
|
756
773
|
*/ function __PRIVATE_validateCollectionPath(t) {
|
|
757
|
-
if (DocumentKey.isDocumentKey(t)) throw new FirestoreError(
|
|
774
|
+
if (DocumentKey.isDocumentKey(t)) throw new FirestoreError(P, `Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`);
|
|
758
775
|
}
|
|
759
776
|
|
|
760
777
|
/**
|
|
@@ -798,17 +815,17 @@ e) {
|
|
|
798
815
|
// Unwrap Compat types
|
|
799
816
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
800
817
|
t = t._delegate), !(t instanceof e)) {
|
|
801
|
-
if (e.name === t.constructor.name) throw new FirestoreError(
|
|
818
|
+
if (e.name === t.constructor.name) throw new FirestoreError(P, "Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");
|
|
802
819
|
{
|
|
803
820
|
const r = __PRIVATE_valueDescription(t);
|
|
804
|
-
throw new FirestoreError(
|
|
821
|
+
throw new FirestoreError(P, `Expected type '${e.name}', but it was: ${r}`);
|
|
805
822
|
}
|
|
806
823
|
}
|
|
807
824
|
return t;
|
|
808
825
|
}
|
|
809
826
|
|
|
810
827
|
function __PRIVATE_validatePositiveNumber(t, e) {
|
|
811
|
-
if (e <= 0) throw new FirestoreError(
|
|
828
|
+
if (e <= 0) throw new FirestoreError(P, `Function ${t}() requires a positive number, but it was: ${e}.`);
|
|
812
829
|
}
|
|
813
830
|
|
|
814
831
|
/**
|
|
@@ -858,7 +875,7 @@ function __PRIVATE_cloneLongPollingOptions(t) {
|
|
|
858
875
|
/**
|
|
859
876
|
* The value returned from the most recent invocation of
|
|
860
877
|
* `generateUniqueDebugId()`, or null if it has never been invoked.
|
|
861
|
-
*/ let
|
|
878
|
+
*/ let O = null;
|
|
862
879
|
|
|
863
880
|
/**
|
|
864
881
|
* Generates and returns an initial value for `lastUniqueDebugId`.
|
|
@@ -883,9 +900,9 @@ function __PRIVATE_cloneLongPollingOptions(t) {
|
|
|
883
900
|
* @return the 10-character generated ID (e.g. "0xa1b2c3d4").
|
|
884
901
|
*/
|
|
885
902
|
function __PRIVATE_generateUniqueDebugId() {
|
|
886
|
-
return null ===
|
|
903
|
+
return null === O ? O = function __PRIVATE_generateInitialUniqueDebugId() {
|
|
887
904
|
return 268435456 + Math.round(2147483648 * Math.random());
|
|
888
|
-
}() :
|
|
905
|
+
}() : O++, "0x" + O.toString(16);
|
|
889
906
|
}
|
|
890
907
|
|
|
891
908
|
/**
|
|
@@ -936,7 +953,7 @@ function __PRIVATE_generateUniqueDebugId() {
|
|
|
936
953
|
* See the License for the specific language governing permissions and
|
|
937
954
|
* limitations under the License.
|
|
938
955
|
*/
|
|
939
|
-
const
|
|
956
|
+
const q = {
|
|
940
957
|
BatchGetDocuments: "batchGet",
|
|
941
958
|
Commit: "commit",
|
|
942
959
|
RunQuery: "runQuery",
|
|
@@ -974,7 +991,7 @@ const O = {
|
|
|
974
991
|
* are used for reverse lookups from the webchannel stream. Do NOT change the
|
|
975
992
|
* names of these identifiers or change this into a const enum.
|
|
976
993
|
*/
|
|
977
|
-
var
|
|
994
|
+
var B, $;
|
|
978
995
|
|
|
979
996
|
/**
|
|
980
997
|
* Converts an HTTP Status Code to the equivalent error code.
|
|
@@ -985,7 +1002,7 @@ var q, B;
|
|
|
985
1002
|
*/
|
|
986
1003
|
function __PRIVATE_mapCodeFromHttpStatus(t) {
|
|
987
1004
|
if (void 0 === t) return __PRIVATE_logError("RPC_ERROR", "HTTP error has no status"),
|
|
988
|
-
|
|
1005
|
+
T;
|
|
989
1006
|
// The canonical error codes for Google APIs [1] specify mapping onto HTTP
|
|
990
1007
|
// status codes but the mapping is not bijective. In each case of ambiguity
|
|
991
1008
|
// this function chooses a primary error.
|
|
@@ -995,66 +1012,66 @@ function __PRIVATE_mapCodeFromHttpStatus(t) {
|
|
|
995
1012
|
switch (t) {
|
|
996
1013
|
case 200:
|
|
997
1014
|
// OK
|
|
998
|
-
return
|
|
1015
|
+
return m;
|
|
999
1016
|
|
|
1000
1017
|
case 400:
|
|
1001
1018
|
// Bad Request
|
|
1002
|
-
return
|
|
1019
|
+
return g;
|
|
1003
1020
|
|
|
1004
1021
|
// Other possibilities based on the forward mapping
|
|
1005
1022
|
// return Code.INVALID_ARGUMENT;
|
|
1006
1023
|
// return Code.OUT_OF_RANGE;
|
|
1007
1024
|
case 401:
|
|
1008
1025
|
// Unauthorized
|
|
1009
|
-
return
|
|
1026
|
+
return y;
|
|
1010
1027
|
|
|
1011
1028
|
case 403:
|
|
1012
1029
|
// Forbidden
|
|
1013
|
-
return
|
|
1030
|
+
return p;
|
|
1014
1031
|
|
|
1015
1032
|
case 404:
|
|
1016
1033
|
// Not Found
|
|
1017
|
-
return
|
|
1034
|
+
return I;
|
|
1018
1035
|
|
|
1019
1036
|
case 409:
|
|
1020
1037
|
// Conflict
|
|
1021
|
-
return
|
|
1038
|
+
return F;
|
|
1022
1039
|
|
|
1023
1040
|
// Other possibilities:
|
|
1024
1041
|
// return Code.ALREADY_EXISTS;
|
|
1025
1042
|
case 416:
|
|
1026
1043
|
// Range Not Satisfiable
|
|
1027
|
-
return
|
|
1044
|
+
return v;
|
|
1028
1045
|
|
|
1029
1046
|
case 429:
|
|
1030
1047
|
// Too Many Requests
|
|
1031
|
-
return
|
|
1048
|
+
return w;
|
|
1032
1049
|
|
|
1033
1050
|
case 499:
|
|
1034
1051
|
// Client Closed Request
|
|
1035
|
-
return
|
|
1052
|
+
return A;
|
|
1036
1053
|
|
|
1037
1054
|
case 500:
|
|
1038
1055
|
// Internal Server Error
|
|
1039
|
-
return
|
|
1056
|
+
return T;
|
|
1040
1057
|
|
|
1041
1058
|
// Other possibilities:
|
|
1042
1059
|
// return Code.INTERNAL;
|
|
1043
1060
|
// return Code.DATA_LOSS;
|
|
1044
1061
|
case 501:
|
|
1045
1062
|
// Unimplemented
|
|
1046
|
-
return
|
|
1063
|
+
return D;
|
|
1047
1064
|
|
|
1048
1065
|
case 503:
|
|
1049
1066
|
// Service Unavailable
|
|
1050
|
-
return
|
|
1067
|
+
return C;
|
|
1051
1068
|
|
|
1052
1069
|
case 504:
|
|
1053
1070
|
// Gateway Timeout
|
|
1054
1071
|
return R;
|
|
1055
1072
|
|
|
1056
1073
|
default:
|
|
1057
|
-
return t >= 200 && t < 300 ?
|
|
1074
|
+
return t >= 200 && t < 300 ? m : t >= 400 && t < 500 ? g : t >= 500 && t < 600 ? b : T;
|
|
1058
1075
|
}
|
|
1059
1076
|
}
|
|
1060
1077
|
|
|
@@ -1077,13 +1094,13 @@ function __PRIVATE_mapCodeFromHttpStatus(t) {
|
|
|
1077
1094
|
/**
|
|
1078
1095
|
* A Rest-based connection that relies on the native HTTP stack
|
|
1079
1096
|
* (e.g. `fetch` or a polyfill).
|
|
1080
|
-
*/ (
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1097
|
+
*/ ($ = B || (B = {}))[$.OK = 0] = "OK", $[$.CANCELLED = 1] = "CANCELLED", $[$.UNKNOWN = 2] = "UNKNOWN",
|
|
1098
|
+
$[$.INVALID_ARGUMENT = 3] = "INVALID_ARGUMENT", $[$.DEADLINE_EXCEEDED = 4] = "DEADLINE_EXCEEDED",
|
|
1099
|
+
$[$.NOT_FOUND = 5] = "NOT_FOUND", $[$.ALREADY_EXISTS = 6] = "ALREADY_EXISTS", $[$.PERMISSION_DENIED = 7] = "PERMISSION_DENIED",
|
|
1100
|
+
$[$.UNAUTHENTICATED = 16] = "UNAUTHENTICATED", $[$.RESOURCE_EXHAUSTED = 8] = "RESOURCE_EXHAUSTED",
|
|
1101
|
+
$[$.FAILED_PRECONDITION = 9] = "FAILED_PRECONDITION", $[$.ABORTED = 10] = "ABORTED",
|
|
1102
|
+
$[$.OUT_OF_RANGE = 11] = "OUT_OF_RANGE", $[$.UNIMPLEMENTED = 12] = "UNIMPLEMENTED",
|
|
1103
|
+
$[$.INTERNAL = 13] = "INTERNAL", $[$.UNAVAILABLE = 14] = "UNAVAILABLE", $[$.DATA_LOSS = 15] = "DATA_LOSS";
|
|
1087
1104
|
|
|
1088
1105
|
class __PRIVATE_FetchConnection extends
|
|
1089
1106
|
/**
|
|
@@ -1099,16 +1116,16 @@ class __PRIVATE_RestConnection {
|
|
|
1099
1116
|
constructor(t) {
|
|
1100
1117
|
this.databaseInfo = t, this.databaseId = t.databaseId;
|
|
1101
1118
|
const e = t.ssl ? "https" : "http", r = encodeURIComponent(this.databaseId.projectId), n = encodeURIComponent(this.databaseId.database);
|
|
1102
|
-
this.A = e + "://" + t.host, this.T = `projects/${r}/databases/${n}`, this.
|
|
1119
|
+
this.A = e + "://" + t.host, this.T = `projects/${r}/databases/${n}`, this.P = "(default)" === this.databaseId.database ? `project_id=${r}` : `project_id=${r}&database_id=${n}`;
|
|
1103
1120
|
}
|
|
1104
|
-
|
|
1105
|
-
const s = __PRIVATE_generateUniqueDebugId(), o = this.
|
|
1121
|
+
R(t, e, r, n, i) {
|
|
1122
|
+
const s = __PRIVATE_generateUniqueDebugId(), o = this.I(t, e.toUriEncodedString());
|
|
1106
1123
|
__PRIVATE_logDebug("RestConnection", `Sending RPC '${t}' ${s}:`, o, r);
|
|
1107
1124
|
const a = {
|
|
1108
1125
|
"google-cloud-resource-prefix": this.T,
|
|
1109
|
-
"x-goog-request-params": this.
|
|
1126
|
+
"x-goog-request-params": this.P
|
|
1110
1127
|
};
|
|
1111
|
-
return this.
|
|
1128
|
+
return this.V(a, n, i), this.p(t, o, a, r).then((e => (__PRIVATE_logDebug("RestConnection", `Received RPC '${t}' ${s}: `, e),
|
|
1112
1129
|
e)), (e => {
|
|
1113
1130
|
throw __PRIVATE_logWarn("RestConnection", `RPC '${t}' ${s} failed with error: `, e, "url: ", o, "request:", r),
|
|
1114
1131
|
e;
|
|
@@ -1117,17 +1134,17 @@ class __PRIVATE_RestConnection {
|
|
|
1117
1134
|
g(t, e, r, n, i, s) {
|
|
1118
1135
|
// The REST API automatically aggregates all of the streamed results, so we
|
|
1119
1136
|
// can just use the normal invoke() method.
|
|
1120
|
-
return this.
|
|
1137
|
+
return this.R(t, e, r, n, i);
|
|
1121
1138
|
}
|
|
1122
1139
|
/**
|
|
1123
1140
|
* Modifies the headers for a request, adding any authorization token if
|
|
1124
1141
|
* present and any additional headers for the request.
|
|
1125
|
-
*/
|
|
1142
|
+
*/ V(t, e, r) {
|
|
1126
1143
|
t["X-Goog-Api-Client"] =
|
|
1127
1144
|
// SDK_VERSION is updated to different value at runtime depending on the entry point,
|
|
1128
1145
|
// so we need to get its value when we need it in a function.
|
|
1129
1146
|
function __PRIVATE_getGoogApiClientValue() {
|
|
1130
|
-
return "gl-js/ fire/" +
|
|
1147
|
+
return "gl-js/ fire/" + f;
|
|
1131
1148
|
}(),
|
|
1132
1149
|
// Content-Type: text/plain will avoid preflight requests which might
|
|
1133
1150
|
// mess with CORS and redirects by proxies. If we add custom headers
|
|
@@ -1136,8 +1153,8 @@ class __PRIVATE_RestConnection {
|
|
|
1136
1153
|
t["Content-Type"] = "text/plain", this.databaseInfo.appId && (t["X-Firebase-GMPID"] = this.databaseInfo.appId),
|
|
1137
1154
|
e && e.headers.forEach(((e, r) => t[r] = e)), r && r.headers.forEach(((e, r) => t[r] = e));
|
|
1138
1155
|
}
|
|
1139
|
-
|
|
1140
|
-
const r =
|
|
1156
|
+
I(t, e) {
|
|
1157
|
+
const r = q[t];
|
|
1141
1158
|
return `${this.A}/v1/${e}:${r}`;
|
|
1142
1159
|
}
|
|
1143
1160
|
/**
|
|
@@ -1476,7 +1493,7 @@ class ByteString {
|
|
|
1476
1493
|
|
|
1477
1494
|
ByteString.EMPTY_BYTE_STRING = new ByteString("");
|
|
1478
1495
|
|
|
1479
|
-
const
|
|
1496
|
+
const Q = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
1480
1497
|
|
|
1481
1498
|
/**
|
|
1482
1499
|
* Converts the possible Proto values for a timestamp value into a "seconds and
|
|
@@ -1490,7 +1507,7 @@ const $ = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1490
1507
|
// (millis), so we do some custom parsing here.
|
|
1491
1508
|
// Parse the nanos right out of the string.
|
|
1492
1509
|
let e = 0;
|
|
1493
|
-
const r =
|
|
1510
|
+
const r = Q.exec(t);
|
|
1494
1511
|
if (__PRIVATE_hardAssert(!!r), r[1]) {
|
|
1495
1512
|
// Pad the fraction out to 9 digits (nanos).
|
|
1496
1513
|
let t = r[1];
|
|
@@ -1600,11 +1617,11 @@ class Timestamp {
|
|
|
1600
1617
|
* The fractions of a second at nanosecond resolution.*
|
|
1601
1618
|
*/
|
|
1602
1619
|
e) {
|
|
1603
|
-
if (this.seconds = t, this.nanoseconds = e, e < 0) throw new FirestoreError(
|
|
1604
|
-
if (e >= 1e9) throw new FirestoreError(
|
|
1605
|
-
if (t < -62135596800) throw new FirestoreError(
|
|
1620
|
+
if (this.seconds = t, this.nanoseconds = e, e < 0) throw new FirestoreError(P, "Timestamp nanoseconds out of range: " + e);
|
|
1621
|
+
if (e >= 1e9) throw new FirestoreError(P, "Timestamp nanoseconds out of range: " + e);
|
|
1622
|
+
if (t < -62135596800) throw new FirestoreError(P, "Timestamp seconds out of range: " + t);
|
|
1606
1623
|
// This will break in the year 10,000.
|
|
1607
|
-
if (t >= 253402300800) throw new FirestoreError(
|
|
1624
|
+
if (t >= 253402300800) throw new FirestoreError(P, "Timestamp seconds out of range: " + t);
|
|
1608
1625
|
}
|
|
1609
1626
|
/**
|
|
1610
1627
|
* Converts a `Timestamp` to a JavaScript `Date` object. This conversion
|
|
@@ -1733,7 +1750,7 @@ class Timestamp {
|
|
|
1733
1750
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1734
1751
|
* See the License for the specific language governing permissions and
|
|
1735
1752
|
* limitations under the License.
|
|
1736
|
-
*/ const
|
|
1753
|
+
*/ const L = {
|
|
1737
1754
|
fields: {
|
|
1738
1755
|
__type__: {
|
|
1739
1756
|
stringValue: "__max__"
|
|
@@ -1923,9 +1940,9 @@ function __PRIVATE_valueCompare(t, e) {
|
|
|
1923
1940
|
|
|
1924
1941
|
case 11 /* TypeOrder.ObjectValue */ :
|
|
1925
1942
|
return function __PRIVATE_compareMaps(t, e) {
|
|
1926
|
-
if (t ===
|
|
1927
|
-
if (t ===
|
|
1928
|
-
if (e ===
|
|
1943
|
+
if (t === L && e === L) return 0;
|
|
1944
|
+
if (t === L) return 1;
|
|
1945
|
+
if (e === L) return -1;
|
|
1929
1946
|
const r = t.fields || {}, n = Object.keys(r), i = e.fields || {}, s = Object.keys(i);
|
|
1930
1947
|
// Even though MapValues are likely sorted correctly based on their insertion
|
|
1931
1948
|
// order (e.g. when received from the backend), local modifications can bring
|
|
@@ -3490,13 +3507,13 @@ function toNumber(t, e) {
|
|
|
3490
3507
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3491
3508
|
* See the License for the specific language governing permissions and
|
|
3492
3509
|
* limitations under the License.
|
|
3493
|
-
*/ const
|
|
3510
|
+
*/ const M = (() => {
|
|
3494
3511
|
const t = {
|
|
3495
3512
|
asc: "ASCENDING",
|
|
3496
3513
|
desc: "DESCENDING"
|
|
3497
3514
|
};
|
|
3498
3515
|
return t;
|
|
3499
|
-
})(),
|
|
3516
|
+
})(), x = (() => {
|
|
3500
3517
|
const t = {
|
|
3501
3518
|
"<": "LESS_THAN",
|
|
3502
3519
|
"<=": "LESS_THAN_OR_EQUAL",
|
|
@@ -3510,7 +3527,7 @@ function toNumber(t, e) {
|
|
|
3510
3527
|
"array-contains-any": "ARRAY_CONTAINS_ANY"
|
|
3511
3528
|
};
|
|
3512
3529
|
return t;
|
|
3513
|
-
})(),
|
|
3530
|
+
})(), k = (() => {
|
|
3514
3531
|
const t = {
|
|
3515
3532
|
and: "AND",
|
|
3516
3533
|
or: "OR"
|
|
@@ -3599,8 +3616,8 @@ function fromName(t, e) {
|
|
|
3599
3616
|
const e = ResourcePath.fromString(t);
|
|
3600
3617
|
return __PRIVATE_hardAssert(__PRIVATE_isValidResourceName(e)), e;
|
|
3601
3618
|
}(e);
|
|
3602
|
-
if (r.get(1) !== t.databaseId.projectId) throw new FirestoreError(
|
|
3603
|
-
if (r.get(3) !== t.databaseId.database) throw new FirestoreError(
|
|
3619
|
+
if (r.get(1) !== t.databaseId.projectId) throw new FirestoreError(P, "Tried to deserialize key from different project: " + r.get(1) + " vs " + t.databaseId.projectId);
|
|
3620
|
+
if (r.get(3) !== t.databaseId.database) throw new FirestoreError(P, "Tried to deserialize key from different database: " + r.get(3) + " vs " + t.databaseId.database);
|
|
3604
3621
|
return new DocumentKey(function __PRIVATE_extractLocalPathFromResourceName(t) {
|
|
3605
3622
|
return __PRIVATE_hardAssert(t.length > 4 && "documents" === t.get(4)), t.popFirst(5);
|
|
3606
3623
|
}
|
|
@@ -3734,16 +3751,16 @@ function __PRIVATE_toQueryTarget(t, e) {
|
|
|
3734
3751
|
}
|
|
3735
3752
|
|
|
3736
3753
|
function __PRIVATE_toDirection(t) {
|
|
3737
|
-
return
|
|
3754
|
+
return M[t];
|
|
3738
3755
|
}
|
|
3739
3756
|
|
|
3740
3757
|
// visible for testing
|
|
3741
3758
|
function __PRIVATE_toOperatorName(t) {
|
|
3742
|
-
return
|
|
3759
|
+
return x[t];
|
|
3743
3760
|
}
|
|
3744
3761
|
|
|
3745
3762
|
function __PRIVATE_toCompositeOperatorName(t) {
|
|
3746
|
-
return
|
|
3763
|
+
return k[t];
|
|
3747
3764
|
}
|
|
3748
3765
|
|
|
3749
3766
|
function __PRIVATE_toFieldPathReference(t) {
|
|
@@ -3960,18 +3977,18 @@ class __PRIVATE_DatastoreImpl extends class Datastore {} {
|
|
|
3960
3977
|
this.serializer = n, this.J = !1;
|
|
3961
3978
|
}
|
|
3962
3979
|
Y() {
|
|
3963
|
-
if (this.J) throw new FirestoreError(
|
|
3980
|
+
if (this.J) throw new FirestoreError(g, "The client has already been terminated.");
|
|
3964
3981
|
}
|
|
3965
|
-
/** Invokes the provided RPC with auth and AppCheck tokens. */
|
|
3966
|
-
return this.Y(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([i, s]) => this.connection.
|
|
3967
|
-
throw "FirebaseError" === t.name ? (t.code ===
|
|
3968
|
-
this.appCheckCredentials.invalidateToken()), t) : new FirestoreError(
|
|
3982
|
+
/** Invokes the provided RPC with auth and AppCheck tokens. */ R(t, e, r, n) {
|
|
3983
|
+
return this.Y(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([i, s]) => this.connection.R(t, __PRIVATE_toResourcePath(e, r), n, i, s))).catch((t => {
|
|
3984
|
+
throw "FirebaseError" === t.name ? (t.code === y && (this.authCredentials.invalidateToken(),
|
|
3985
|
+
this.appCheckCredentials.invalidateToken()), t) : new FirestoreError(T, t.toString());
|
|
3969
3986
|
}));
|
|
3970
3987
|
}
|
|
3971
3988
|
/** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */ g(t, e, r, n, i) {
|
|
3972
3989
|
return this.Y(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([s, o]) => this.connection.g(t, __PRIVATE_toResourcePath(e, r), n, s, o, i))).catch((t => {
|
|
3973
|
-
throw "FirebaseError" === t.name ? (t.code ===
|
|
3974
|
-
this.appCheckCredentials.invalidateToken()), t) : new FirestoreError(
|
|
3990
|
+
throw "FirebaseError" === t.name ? (t.code === y && (this.authCredentials.invalidateToken(),
|
|
3991
|
+
this.appCheckCredentials.invalidateToken()), t) : new FirestoreError(T, t.toString());
|
|
3975
3992
|
}));
|
|
3976
3993
|
}
|
|
3977
3994
|
terminate() {
|
|
@@ -3985,7 +4002,7 @@ async function __PRIVATE_invokeCommitRpc(t, e) {
|
|
|
3985
4002
|
const r = __PRIVATE_debugCast(t), n = {
|
|
3986
4003
|
writes: e.map((t => toMutation(r.serializer, t)))
|
|
3987
4004
|
};
|
|
3988
|
-
await r.
|
|
4005
|
+
await r.R("Commit", r.serializer.databaseId, ResourcePath.emptyPath(), n);
|
|
3989
4006
|
}
|
|
3990
4007
|
|
|
3991
4008
|
async function __PRIVATE_invokeBatchGetDocumentsRpc(t, e) {
|
|
@@ -4085,7 +4102,7 @@ async function __PRIVATE_invokeRunAggregationQueryRpc(t, e, r) {
|
|
|
4085
4102
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4086
4103
|
* See the License for the specific language governing permissions and
|
|
4087
4104
|
* limitations under the License.
|
|
4088
|
-
*/ const
|
|
4105
|
+
*/ const U = new Map;
|
|
4089
4106
|
|
|
4090
4107
|
/**
|
|
4091
4108
|
* An instance map that ensures only one Datastore exists per Firestore
|
|
@@ -4097,8 +4114,8 @@ async function __PRIVATE_invokeRunAggregationQueryRpc(t, e, r) {
|
|
|
4097
4114
|
* instance is terminated.
|
|
4098
4115
|
*/
|
|
4099
4116
|
function __PRIVATE_getDatastore(t) {
|
|
4100
|
-
if (t._terminated) throw new FirestoreError(
|
|
4101
|
-
if (!
|
|
4117
|
+
if (t._terminated) throw new FirestoreError(g, "The client has already been terminated.");
|
|
4118
|
+
if (!U.has(t)) {
|
|
4102
4119
|
__PRIVATE_logDebug("ComponentProvider", "Initializing Datastore");
|
|
4103
4120
|
const e = function __PRIVATE_newConnection(t) {
|
|
4104
4121
|
return new __PRIVATE_FetchConnection(t);
|
|
@@ -4123,9 +4140,9 @@ function __PRIVATE_getDatastore(t) {
|
|
|
4123
4140
|
*/ (t._databaseId, t.app.options.appId || "", t._persistenceKey, t._freezeSettings())), r = __PRIVATE_newSerializer(t._databaseId), n = function __PRIVATE_newDatastore(t, e, r, n) {
|
|
4124
4141
|
return new __PRIVATE_DatastoreImpl(t, e, r, n);
|
|
4125
4142
|
}(t._authCredentials, t._appCheckCredentials, e, r);
|
|
4126
|
-
|
|
4143
|
+
U.set(t, n);
|
|
4127
4144
|
}
|
|
4128
|
-
return
|
|
4145
|
+
return U.get(t);
|
|
4129
4146
|
}
|
|
4130
4147
|
|
|
4131
4148
|
/**
|
|
@@ -4141,16 +4158,16 @@ class FirestoreSettingsImpl {
|
|
|
4141
4158
|
constructor(t) {
|
|
4142
4159
|
var e, r;
|
|
4143
4160
|
if (void 0 === t.host) {
|
|
4144
|
-
if (void 0 !== t.ssl) throw new FirestoreError(
|
|
4161
|
+
if (void 0 !== t.ssl) throw new FirestoreError(P, "Can't provide ssl option if host option is not set");
|
|
4145
4162
|
this.host = "firestore.googleapis.com", this.ssl = true;
|
|
4146
4163
|
} else this.host = t.host, this.ssl = null === (e = t.ssl) || void 0 === e || e;
|
|
4147
4164
|
if (this.credentials = t.credentials, this.ignoreUndefinedProperties = !!t.ignoreUndefinedProperties,
|
|
4148
4165
|
this.localCache = t.localCache, void 0 === t.cacheSizeBytes) this.cacheSizeBytes = 41943040; else {
|
|
4149
|
-
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new FirestoreError(
|
|
4166
|
+
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new FirestoreError(P, "cacheSizeBytes must be at least 1048576");
|
|
4150
4167
|
this.cacheSizeBytes = t.cacheSizeBytes;
|
|
4151
4168
|
}
|
|
4152
4169
|
!function __PRIVATE_validateIsNotUsedTogether(t, e, r, n) {
|
|
4153
|
-
if (!0 === e && !0 === n) throw new FirestoreError(
|
|
4170
|
+
if (!0 === e && !0 === n) throw new FirestoreError(P, `${t} and ${r} cannot be used together.`);
|
|
4154
4171
|
}("experimentalForceLongPolling", t.experimentalForceLongPolling, "experimentalAutoDetectLongPolling", t.experimentalAutoDetectLongPolling),
|
|
4155
4172
|
this.experimentalForceLongPolling = !!t.experimentalForceLongPolling, this.experimentalForceLongPolling ? this.experimentalAutoDetectLongPolling = !1 : void 0 === t.experimentalAutoDetectLongPolling ? this.experimentalAutoDetectLongPolling = true :
|
|
4156
4173
|
// For backwards compatibility, coerce the value to boolean even though
|
|
@@ -4160,9 +4177,9 @@ class FirestoreSettingsImpl {
|
|
|
4160
4177
|
this.experimentalLongPollingOptions = __PRIVATE_cloneLongPollingOptions(null !== (r = t.experimentalLongPollingOptions) && void 0 !== r ? r : {}),
|
|
4161
4178
|
function __PRIVATE_validateLongPollingOptions(t) {
|
|
4162
4179
|
if (void 0 !== t.timeoutSeconds) {
|
|
4163
|
-
if (isNaN(t.timeoutSeconds)) throw new FirestoreError(
|
|
4164
|
-
if (t.timeoutSeconds < 5) throw new FirestoreError(
|
|
4165
|
-
if (t.timeoutSeconds > 30) throw new FirestoreError(
|
|
4180
|
+
if (isNaN(t.timeoutSeconds)) throw new FirestoreError(P, `invalid long polling timeout: ${t.timeoutSeconds} (must not be NaN)`);
|
|
4181
|
+
if (t.timeoutSeconds < 5) throw new FirestoreError(P, `invalid long polling timeout: ${t.timeoutSeconds} (minimum allowed value is 5)`);
|
|
4182
|
+
if (t.timeoutSeconds > 30) throw new FirestoreError(P, `invalid long polling timeout: ${t.timeoutSeconds} (maximum allowed value is 30)`);
|
|
4166
4183
|
}
|
|
4167
4184
|
}
|
|
4168
4185
|
/**
|
|
@@ -4214,7 +4231,7 @@ class Firestore {
|
|
|
4214
4231
|
* The {@link @firebase/app#FirebaseApp} associated with this `Firestore` service
|
|
4215
4232
|
* instance.
|
|
4216
4233
|
*/ get app() {
|
|
4217
|
-
if (!this._app) throw new FirestoreError(
|
|
4234
|
+
if (!this._app) throw new FirestoreError(g, "Firestore was not initialized using the Firebase SDK. 'app' is not available");
|
|
4218
4235
|
return this._app;
|
|
4219
4236
|
}
|
|
4220
4237
|
get _initialized() {
|
|
@@ -4224,7 +4241,7 @@ class Firestore {
|
|
|
4224
4241
|
return "notTerminated" !== this._terminateTask;
|
|
4225
4242
|
}
|
|
4226
4243
|
_setSettings(t) {
|
|
4227
|
-
if (this._settingsFrozen) throw new FirestoreError(
|
|
4244
|
+
if (this._settingsFrozen) throw new FirestoreError(g, "Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");
|
|
4228
4245
|
this._settings = new FirestoreSettingsImpl(t), void 0 !== t.credentials && (this._authCredentials = function __PRIVATE_makeAuthCredentialsProvider(t) {
|
|
4229
4246
|
if (!t) return new __PRIVATE_EmptyAuthCredentialsProvider;
|
|
4230
4247
|
switch (t.type) {
|
|
@@ -4235,7 +4252,7 @@ class Firestore {
|
|
|
4235
4252
|
return t.client;
|
|
4236
4253
|
|
|
4237
4254
|
default:
|
|
4238
|
-
throw new FirestoreError(
|
|
4255
|
+
throw new FirestoreError(P, "makeAuthCredentialsProvider failed due to invalid credential type");
|
|
4239
4256
|
}
|
|
4240
4257
|
}(t.credentials));
|
|
4241
4258
|
}
|
|
@@ -4272,8 +4289,8 @@ class Firestore {
|
|
|
4272
4289
|
* Only ever called once.
|
|
4273
4290
|
*/ _terminate() {
|
|
4274
4291
|
return function __PRIVATE_removeComponents(t) {
|
|
4275
|
-
const e =
|
|
4276
|
-
e && (__PRIVATE_logDebug("ComponentProvider", "Removing Datastore"),
|
|
4292
|
+
const e = U.get(t);
|
|
4293
|
+
e && (__PRIVATE_logDebug("ComponentProvider", "Removing Datastore"), U.delete(t),
|
|
4277
4294
|
e.terminate());
|
|
4278
4295
|
}(this), Promise.resolve();
|
|
4279
4296
|
}
|
|
@@ -4282,7 +4299,7 @@ class Firestore {
|
|
|
4282
4299
|
function initializeFirestore(t, e, r) {
|
|
4283
4300
|
r || (r = "(default)");
|
|
4284
4301
|
const n = _getProvider(t, "firestore/lite");
|
|
4285
|
-
if (n.isInitialized(r)) throw new FirestoreError(
|
|
4302
|
+
if (n.isInitialized(r)) throw new FirestoreError(g, "Firestore can only be initialized once per app.");
|
|
4286
4303
|
return n.initialize({
|
|
4287
4304
|
options: e,
|
|
4288
4305
|
instanceIdentifier: r
|
|
@@ -4326,7 +4343,7 @@ function getFirestore(e, r) {
|
|
|
4326
4343
|
// invalid field "uid" and missing field "sub" / "user_id".)
|
|
4327
4344
|
e = createMockUserToken(n.mockUserToken, null === (i = t._app) || void 0 === i ? void 0 : i.options.projectId);
|
|
4328
4345
|
const s = n.mockUserToken.sub || n.mockUserToken.user_id;
|
|
4329
|
-
if (!s) throw new FirestoreError(
|
|
4346
|
+
if (!s) throw new FirestoreError(P, "mockUserToken must contain 'sub' or 'user_id' field!");
|
|
4330
4347
|
r = new User(s);
|
|
4331
4348
|
}
|
|
4332
4349
|
t._authCredentials = new __PRIVATE_EmulatorAuthCredentialsProvider(new __PRIVATE_OAuthToken(e, r));
|
|
@@ -4545,7 +4562,7 @@ function collection(t, e, ...r) {
|
|
|
4545
4562
|
return __PRIVATE_validateCollectionPath(n), new CollectionReference(t, /* converter= */ null, n);
|
|
4546
4563
|
}
|
|
4547
4564
|
{
|
|
4548
|
-
if (!(t instanceof DocumentReference || t instanceof CollectionReference)) throw new FirestoreError(
|
|
4565
|
+
if (!(t instanceof DocumentReference || t instanceof CollectionReference)) throw new FirestoreError(P, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
4549
4566
|
const n = t._path.child(ResourcePath.fromString(e, ...r));
|
|
4550
4567
|
return __PRIVATE_validateCollectionPath(n), new CollectionReference(t.firestore,
|
|
4551
4568
|
/* converter= */ null, n);
|
|
@@ -4566,7 +4583,7 @@ function collection(t, e, ...r) {
|
|
|
4566
4583
|
* @returns The created `Query`.
|
|
4567
4584
|
*/ function collectionGroup(t, e) {
|
|
4568
4585
|
if (t = __PRIVATE_cast(t, Firestore), __PRIVATE_validateNonEmptyArgument("collectionGroup", "collection id", e),
|
|
4569
|
-
e.indexOf("/") >= 0) throw new FirestoreError(
|
|
4586
|
+
e.indexOf("/") >= 0) throw new FirestoreError(P, `Invalid collection ID '${e}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);
|
|
4570
4587
|
return new Query(t,
|
|
4571
4588
|
/* converter= */ null, function __PRIVATE_newQueryForCollectionGroup(t) {
|
|
4572
4589
|
return new __PRIVATE_QueryImpl(ResourcePath.emptyPath(), t);
|
|
@@ -4584,7 +4601,7 @@ function doc(t, e, ...r) {
|
|
|
4584
4601
|
/* converter= */ null, new DocumentKey(n));
|
|
4585
4602
|
}
|
|
4586
4603
|
{
|
|
4587
|
-
if (!(t instanceof DocumentReference || t instanceof CollectionReference)) throw new FirestoreError(
|
|
4604
|
+
if (!(t instanceof DocumentReference || t instanceof CollectionReference)) throw new FirestoreError(P, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
4588
4605
|
const n = t._path.child(ResourcePath.fromString(e, ...r));
|
|
4589
4606
|
return __PRIVATE_validateDocumentPath(n), new DocumentReference(t.firestore, t instanceof CollectionReference ? t.converter : null, new DocumentKey(n));
|
|
4590
4607
|
}
|
|
@@ -4645,7 +4662,7 @@ function doc(t, e, ...r) {
|
|
|
4645
4662
|
try {
|
|
4646
4663
|
return new Bytes(ByteString.fromBase64String(t));
|
|
4647
4664
|
} catch (t) {
|
|
4648
|
-
throw new FirestoreError(
|
|
4665
|
+
throw new FirestoreError(P, "Failed to construct data from Base64 string: " + t);
|
|
4649
4666
|
}
|
|
4650
4667
|
}
|
|
4651
4668
|
/**
|
|
@@ -4717,7 +4734,7 @@ function doc(t, e, ...r) {
|
|
|
4717
4734
|
* @param fieldNames - A list of field names.
|
|
4718
4735
|
*/
|
|
4719
4736
|
constructor(...t) {
|
|
4720
|
-
for (let e = 0; e < t.length; ++e) if (0 === t[e].length) throw new FirestoreError(
|
|
4737
|
+
for (let e = 0; e < t.length; ++e) if (0 === t[e].length) throw new FirestoreError(P, "Invalid field name at argument $(i + 1). Field names must not be empty.");
|
|
4721
4738
|
this._internalPath = new FieldPath$1(t);
|
|
4722
4739
|
}
|
|
4723
4740
|
/**
|
|
@@ -4796,8 +4813,8 @@ function doc(t, e, ...r) {
|
|
|
4796
4813
|
* @param longitude - The longitude as number between -180 and 180.
|
|
4797
4814
|
*/
|
|
4798
4815
|
constructor(t, e) {
|
|
4799
|
-
if (!isFinite(t) || t < -90 || t > 90) throw new FirestoreError(
|
|
4800
|
-
if (!isFinite(e) || e < -180 || e > 180) throw new FirestoreError(
|
|
4816
|
+
if (!isFinite(t) || t < -90 || t > 90) throw new FirestoreError(P, "Latitude must be a number between -90 and 90, but was: " + t);
|
|
4817
|
+
if (!isFinite(e) || e < -180 || e > 180) throw new FirestoreError(P, "Longitude must be a number between -180 and 180, but was: " + e);
|
|
4801
4818
|
this._lat = t, this._long = e;
|
|
4802
4819
|
}
|
|
4803
4820
|
/**
|
|
@@ -4919,7 +4936,7 @@ class VectorValue {
|
|
|
4919
4936
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4920
4937
|
* See the License for the specific language governing permissions and
|
|
4921
4938
|
* limitations under the License.
|
|
4922
|
-
*/ const
|
|
4939
|
+
*/ const j = /^__.*__$/;
|
|
4923
4940
|
|
|
4924
4941
|
/** The result of parsing document data (e.g. for a setData call). */ class ParsedSetData {
|
|
4925
4942
|
constructor(t, e, r) {
|
|
@@ -5030,7 +5047,7 @@ function __PRIVATE_isWrite(t) {
|
|
|
5030
5047
|
}
|
|
5031
5048
|
it(t) {
|
|
5032
5049
|
if (0 === t.length) throw this.ut("Document fields must not be empty");
|
|
5033
|
-
if (__PRIVATE_isWrite(this.tt) &&
|
|
5050
|
+
if (__PRIVATE_isWrite(this.tt) && j.test(t)) throw this.ut('Document fields cannot begin and end with "__"');
|
|
5034
5051
|
}
|
|
5035
5052
|
}
|
|
5036
5053
|
|
|
@@ -5067,7 +5084,7 @@ function __PRIVATE_newUserDataReader(t) {
|
|
|
5067
5084
|
const t = [];
|
|
5068
5085
|
for (const n of s.mergeFields) {
|
|
5069
5086
|
const i = __PRIVATE_fieldPathFromArgument$1(e, n, r);
|
|
5070
|
-
if (!o.contains(i)) throw new FirestoreError(
|
|
5087
|
+
if (!o.contains(i)) throw new FirestoreError(P, `Field '${i}' is specified in your field mask but missing from your input data.`);
|
|
5071
5088
|
__PRIVATE_fieldMaskContains(t, i) || t.push(i);
|
|
5072
5089
|
}
|
|
5073
5090
|
u = new FieldMask(t), _ = o.fieldTransforms.filter((t => u.covers(t.field)));
|
|
@@ -5184,7 +5201,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
|
|
|
5184
5201
|
|
|
5185
5202
|
/** Parse update data from a list of field/value arguments. */ function __PRIVATE_parseUpdateVarargs(t, e, r, n, i, s) {
|
|
5186
5203
|
const o = t.lt(1 /* UserDataSource.Update */ , e, r), a = [ __PRIVATE_fieldPathFromArgument$1(e, n, r) ], u = [ i ];
|
|
5187
|
-
if (s.length % 2 != 0) throw new FirestoreError(
|
|
5204
|
+
if (s.length % 2 != 0) throw new FirestoreError(P, `Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);
|
|
5188
5205
|
for (let t = 0; t < s.length; t += 2) a.push(__PRIVATE_fieldPathFromArgument$1(e, s[t])),
|
|
5189
5206
|
u.push(s[t + 1]);
|
|
5190
5207
|
const _ = [], c = ObjectValue.empty();
|
|
@@ -5411,7 +5428,7 @@ function __PRIVATE_validatePlainObject(t, e, r) {
|
|
|
5411
5428
|
|
|
5412
5429
|
/**
|
|
5413
5430
|
* Matches any characters in a field path string that are reserved.
|
|
5414
|
-
*/ const
|
|
5431
|
+
*/ const z = new RegExp("[~\\*/\\[\\]]");
|
|
5415
5432
|
|
|
5416
5433
|
/**
|
|
5417
5434
|
* Wraps fromDotSeparatedString with an error message about the method that
|
|
@@ -5422,7 +5439,7 @@ function __PRIVATE_validatePlainObject(t, e, r) {
|
|
|
5422
5439
|
* @param targetDoc - The document against which the field path will be
|
|
5423
5440
|
* evaluated.
|
|
5424
5441
|
*/ function __PRIVATE_fieldPathFromDotSeparatedString(t, e, r) {
|
|
5425
|
-
if (e.search(
|
|
5442
|
+
if (e.search(z) >= 0) throw __PRIVATE_createError(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`, t,
|
|
5426
5443
|
/* hasConverter= */ !1,
|
|
5427
5444
|
/* path= */ void 0, r);
|
|
5428
5445
|
try {
|
|
@@ -5440,7 +5457,7 @@ function __PRIVATE_createError(t, e, r, n, i) {
|
|
|
5440
5457
|
r && (a += " (via `toFirestore()`)"), a += ". ";
|
|
5441
5458
|
let u = "";
|
|
5442
5459
|
return (s || o) && (u += " (found", s && (u += ` in field ${n}`), o && (u += ` in document ${i}`),
|
|
5443
|
-
u += ")"), new FirestoreError(
|
|
5460
|
+
u += ")"), new FirestoreError(P, a + t + u);
|
|
5444
5461
|
}
|
|
5445
5462
|
|
|
5446
5463
|
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function __PRIVATE_fieldMaskContains(t, e) {
|
|
@@ -5637,7 +5654,7 @@ function query(t, e, ...r) {
|
|
|
5637
5654
|
let n = [];
|
|
5638
5655
|
e instanceof AppliableConstraint && n.push(e), n = n.concat(r), function __PRIVATE_validateQueryConstraintArray(t) {
|
|
5639
5656
|
const e = t.filter((t => t instanceof QueryCompositeFilterConstraint)).length, r = t.filter((t => t instanceof QueryFieldFilterConstraint)).length;
|
|
5640
|
-
if (e > 1 || e > 0 && r > 0) throw new FirestoreError(
|
|
5657
|
+
if (e > 1 || e > 0 && r > 0) throw new FirestoreError(P, "InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.");
|
|
5641
5658
|
}
|
|
5642
5659
|
/**
|
|
5643
5660
|
* @license
|
|
@@ -5691,7 +5708,7 @@ function query(t, e, ...r) {
|
|
|
5691
5708
|
const e = __PRIVATE_newUserDataReader(t.firestore), r = function __PRIVATE_newQueryFilter(t, e, r, n, i, s, o) {
|
|
5692
5709
|
let a;
|
|
5693
5710
|
if (i.isKeyField()) {
|
|
5694
|
-
if ("array-contains" /* Operator.ARRAY_CONTAINS */ === s || "array-contains-any" /* Operator.ARRAY_CONTAINS_ANY */ === s) throw new FirestoreError(
|
|
5711
|
+
if ("array-contains" /* Operator.ARRAY_CONTAINS */ === s || "array-contains-any" /* Operator.ARRAY_CONTAINS_ANY */ === s) throw new FirestoreError(P, `Invalid Query. You can't perform '${s}' queries on documentId().`);
|
|
5695
5712
|
if ("in" /* Operator.IN */ === s || "not-in" /* Operator.NOT_IN */ === s) {
|
|
5696
5713
|
__PRIVATE_validateDisjunctiveFilterElements(o, s);
|
|
5697
5714
|
const e = [];
|
|
@@ -5818,8 +5835,8 @@ function query(t, e, ...r) {
|
|
|
5818
5835
|
}
|
|
5819
5836
|
_apply(t) {
|
|
5820
5837
|
const e = function __PRIVATE_newQueryOrderBy(t, e, r) {
|
|
5821
|
-
if (null !== t.startAt) throw new FirestoreError(
|
|
5822
|
-
if (null !== t.endAt) throw new FirestoreError(
|
|
5838
|
+
if (null !== t.startAt) throw new FirestoreError(P, "Invalid query. You must not call startAt() or startAfter() before calling orderBy().");
|
|
5839
|
+
if (null !== t.endAt) throw new FirestoreError(P, "Invalid query. You must not call endAt() or endBefore() before calling orderBy().");
|
|
5823
5840
|
return new OrderBy(e, r);
|
|
5824
5841
|
}
|
|
5825
5842
|
/**
|
|
@@ -5979,7 +5996,7 @@ function endAt(...t) {
|
|
|
5979
5996
|
|
|
5980
5997
|
/** Helper function to create a bound from a document or fields */ function __PRIVATE_newQueryBoundFromDocOrFields(t, e, r, n) {
|
|
5981
5998
|
if (r[0] = getModularInstance(r[0]), r[0] instanceof DocumentSnapshot) return function __PRIVATE_newQueryBoundFromDocument(t, e, r, n, i) {
|
|
5982
|
-
if (!n) throw new FirestoreError(
|
|
5999
|
+
if (!n) throw new FirestoreError(I, `Can't use a DocumentSnapshot that doesn't exist for ${r}().`);
|
|
5983
6000
|
const s = [];
|
|
5984
6001
|
// Because people expect to continue/end a query at the exact document
|
|
5985
6002
|
// provided, we need to use the implicit sort order rather than the explicit
|
|
@@ -5990,10 +6007,10 @@ function endAt(...t) {
|
|
|
5990
6007
|
// results.
|
|
5991
6008
|
for (const r of __PRIVATE_queryNormalizedOrderBy(t)) if (r.field.isKeyField()) s.push(__PRIVATE_refValue(e, n.key)); else {
|
|
5992
6009
|
const t = n.data.field(r.field);
|
|
5993
|
-
if (__PRIVATE_isServerTimestamp(t)) throw new FirestoreError(
|
|
6010
|
+
if (__PRIVATE_isServerTimestamp(t)) throw new FirestoreError(P, 'Invalid query. You are trying to start or end a query using a document for which the field "' + r.field + '" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');
|
|
5994
6011
|
if (null === t) {
|
|
5995
6012
|
const t = r.field.canonicalString();
|
|
5996
|
-
throw new FirestoreError(
|
|
6013
|
+
throw new FirestoreError(P, `Invalid query. You are trying to start or end a query using a document for which the field '${t}' (used as the orderBy) does not exist.`);
|
|
5997
6014
|
}
|
|
5998
6015
|
s.push(t);
|
|
5999
6016
|
}
|
|
@@ -6007,15 +6024,15 @@ function endAt(...t) {
|
|
|
6007
6024
|
return function __PRIVATE_newQueryBoundFromFields(t, e, r, n, i, s) {
|
|
6008
6025
|
// Use explicit order by's because it has to match the query the user made
|
|
6009
6026
|
const o = t.explicitOrderBy;
|
|
6010
|
-
if (i.length > o.length) throw new FirestoreError(
|
|
6027
|
+
if (i.length > o.length) throw new FirestoreError(P, `Too many arguments provided to ${n}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);
|
|
6011
6028
|
const a = [];
|
|
6012
6029
|
for (let s = 0; s < i.length; s++) {
|
|
6013
6030
|
const u = i[s];
|
|
6014
6031
|
if (o[s].field.isKeyField()) {
|
|
6015
|
-
if ("string" != typeof u) throw new FirestoreError(
|
|
6016
|
-
if (!__PRIVATE_isCollectionGroupQuery(t) && -1 !== u.indexOf("/")) throw new FirestoreError(
|
|
6032
|
+
if ("string" != typeof u) throw new FirestoreError(P, `Invalid query. Expected a string for document ID in ${n}(), but got a ${typeof u}`);
|
|
6033
|
+
if (!__PRIVATE_isCollectionGroupQuery(t) && -1 !== u.indexOf("/")) throw new FirestoreError(P, `Invalid query. When querying a collection and ordering by documentId(), the value passed to ${n}() must be a plain document ID, but '${u}' contains a slash.`);
|
|
6017
6034
|
const r = t.path.child(ResourcePath.fromString(u));
|
|
6018
|
-
if (!DocumentKey.isDocumentKey(r)) throw new FirestoreError(
|
|
6035
|
+
if (!DocumentKey.isDocumentKey(r)) throw new FirestoreError(P, `Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${n}() must result in a valid document path, but '${r}' is not because it contains an odd number of segments.`);
|
|
6019
6036
|
const i = new DocumentKey(r);
|
|
6020
6037
|
a.push(__PRIVATE_refValue(e, i));
|
|
6021
6038
|
} else {
|
|
@@ -6035,21 +6052,21 @@ function endAt(...t) {
|
|
|
6035
6052
|
|
|
6036
6053
|
function __PRIVATE_parseDocumentIdValue(t, e, r) {
|
|
6037
6054
|
if ("string" == typeof (r = getModularInstance(r))) {
|
|
6038
|
-
if ("" === r) throw new FirestoreError(
|
|
6039
|
-
if (!__PRIVATE_isCollectionGroupQuery(e) && -1 !== r.indexOf("/")) throw new FirestoreError(
|
|
6055
|
+
if ("" === r) throw new FirestoreError(P, "Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");
|
|
6056
|
+
if (!__PRIVATE_isCollectionGroupQuery(e) && -1 !== r.indexOf("/")) throw new FirestoreError(P, `Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${r}' contains a '/' character.`);
|
|
6040
6057
|
const n = e.path.child(ResourcePath.fromString(r));
|
|
6041
|
-
if (!DocumentKey.isDocumentKey(n)) throw new FirestoreError(
|
|
6058
|
+
if (!DocumentKey.isDocumentKey(n)) throw new FirestoreError(P, `Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${n}' is not because it has an odd number of segments (${n.length}).`);
|
|
6042
6059
|
return __PRIVATE_refValue(t, new DocumentKey(n));
|
|
6043
6060
|
}
|
|
6044
6061
|
if (r instanceof DocumentReference) return __PRIVATE_refValue(t, r._key);
|
|
6045
|
-
throw new FirestoreError(
|
|
6062
|
+
throw new FirestoreError(P, `Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${__PRIVATE_valueDescription(r)}.`);
|
|
6046
6063
|
}
|
|
6047
6064
|
|
|
6048
6065
|
/**
|
|
6049
6066
|
* Validates that the value passed into a disjunctive filter satisfies all
|
|
6050
6067
|
* array requirements.
|
|
6051
6068
|
*/ function __PRIVATE_validateDisjunctiveFilterElements(t, e) {
|
|
6052
|
-
if (!Array.isArray(t) || 0 === t.length) throw new FirestoreError(
|
|
6069
|
+
if (!Array.isArray(t) || 0 === t.length) throw new FirestoreError(P, `Invalid Query. A non-empty array is required for '${e.toString()}' filters.`);
|
|
6053
6070
|
}
|
|
6054
6071
|
|
|
6055
6072
|
/**
|
|
@@ -6083,11 +6100,11 @@ function __PRIVATE_parseDocumentIdValue(t, e, r) {
|
|
|
6083
6100
|
}(e.op));
|
|
6084
6101
|
if (null !== r)
|
|
6085
6102
|
// Special case when it's a duplicate op to give a slightly clearer error message.
|
|
6086
|
-
throw r === e.op ? new FirestoreError(
|
|
6103
|
+
throw r === e.op ? new FirestoreError(P, `Invalid query. You cannot use more than one '${e.op.toString()}' filter.`) : new FirestoreError(P, `Invalid query. You cannot use '${e.op.toString()}' filters with '${r.toString()}' filters.`);
|
|
6087
6104
|
}
|
|
6088
6105
|
|
|
6089
6106
|
function __PRIVATE_validateQueryFilterConstraint(t, e) {
|
|
6090
|
-
if (!(e instanceof QueryFieldFilterConstraint || e instanceof QueryCompositeFilterConstraint)) throw new FirestoreError(
|
|
6107
|
+
if (!(e instanceof QueryFieldFilterConstraint || e instanceof QueryCompositeFilterConstraint)) throw new FirestoreError(P, `Function ${t}() requires AppliableConstraints created with a call to 'where(...)', 'or(...)', or 'and(...)'.`);
|
|
6091
6108
|
}
|
|
6092
6109
|
|
|
6093
6110
|
/**
|
|
@@ -6264,7 +6281,7 @@ class __PRIVATE_LiteUserDataWriter extends class AbstractUserDataWriter {
|
|
|
6264
6281
|
* @returns A Promise that will be resolved with the results of the query.
|
|
6265
6282
|
*/ function getDocs(t) {
|
|
6266
6283
|
(function __PRIVATE_validateHasExplicitOrderByForLimitToLast(t) {
|
|
6267
|
-
if ("L" /* LimitType.Last */ === t.limitType && 0 === t.explicitOrderBy.length) throw new FirestoreError(
|
|
6284
|
+
if ("L" /* LimitType.Last */ === t.limitType && 0 === t.explicitOrderBy.length) throw new FirestoreError(D, "limitToLast() queries require specifying at least one orderBy() clause");
|
|
6268
6285
|
})((t = __PRIVATE_cast(t, Query))._query);
|
|
6269
6286
|
const e = __PRIVATE_getDatastore(t.firestore), r = new __PRIVATE_LiteUserDataWriter(t.firestore);
|
|
6270
6287
|
return __PRIVATE_invokeRunQueryRpc(e, t._query).then((e => {
|
|
@@ -6611,12 +6628,12 @@ function sum(t) {
|
|
|
6611
6628
|
return this._verifyNotCommitted(), this._committed = !0, this._mutations.length > 0 ? this._commitHandler(this._mutations) : Promise.resolve();
|
|
6612
6629
|
}
|
|
6613
6630
|
_verifyNotCommitted() {
|
|
6614
|
-
if (this._committed) throw new FirestoreError(
|
|
6631
|
+
if (this._committed) throw new FirestoreError(g, "A write batch can no longer be used after commit() has been called.");
|
|
6615
6632
|
}
|
|
6616
6633
|
}
|
|
6617
6634
|
|
|
6618
6635
|
function __PRIVATE_validateReference(t, e) {
|
|
6619
|
-
if ((t = getModularInstance(t)).firestore !== e) throw new FirestoreError(
|
|
6636
|
+
if ((t = getModularInstance(t)).firestore !== e) throw new FirestoreError(P, "Provided document reference is from a different Firestore instance.");
|
|
6620
6637
|
return t;
|
|
6621
6638
|
}
|
|
6622
6639
|
|
|
@@ -6675,7 +6692,7 @@ function __PRIVATE_validateReference(t, e) {
|
|
|
6675
6692
|
this.writtenDocs = new Set;
|
|
6676
6693
|
}
|
|
6677
6694
|
async lookup(t) {
|
|
6678
|
-
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw this.lastTransactionError = new FirestoreError(
|
|
6695
|
+
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw this.lastTransactionError = new FirestoreError(P, "Firestore transactions require all reads to be executed before all writes."),
|
|
6679
6696
|
this.lastTransactionError;
|
|
6680
6697
|
const e = await __PRIVATE_invokeBatchGetDocumentsRpc(this.datastore, t);
|
|
6681
6698
|
return e.forEach((t => this.recordVersion(t))), e;
|
|
@@ -6719,7 +6736,7 @@ function __PRIVATE_validateReference(t, e) {
|
|
|
6719
6736
|
if (r) {
|
|
6720
6737
|
if (!e.isEqual(r))
|
|
6721
6738
|
// This transaction will fail no matter what.
|
|
6722
|
-
throw new FirestoreError(
|
|
6739
|
+
throw new FirestoreError(F, "Document version changed between two reads.");
|
|
6723
6740
|
} else this.readVersions.set(t.key.toString(), e);
|
|
6724
6741
|
}
|
|
6725
6742
|
/**
|
|
@@ -6746,7 +6763,7 @@ function __PRIVATE_validateReference(t, e) {
|
|
|
6746
6763
|
// express that to the backend, we have to validate locally.
|
|
6747
6764
|
// Note: this can change once we can send separate verify writes in the
|
|
6748
6765
|
// transaction.
|
|
6749
|
-
throw new FirestoreError(
|
|
6766
|
+
throw new FirestoreError(P, "Can't update a document that doesn't exist.");
|
|
6750
6767
|
// Document exists, base precondition on document update time.
|
|
6751
6768
|
return Precondition.updateTime(e);
|
|
6752
6769
|
}
|
|
@@ -6775,7 +6792,7 @@ function __PRIVATE_validateReference(t, e) {
|
|
|
6775
6792
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6776
6793
|
* See the License for the specific language governing permissions and
|
|
6777
6794
|
* limitations under the License.
|
|
6778
|
-
*/ const
|
|
6795
|
+
*/ const W = {
|
|
6779
6796
|
maxAttempts: 5
|
|
6780
6797
|
};
|
|
6781
6798
|
|
|
@@ -6809,19 +6826,19 @@ class __PRIVATE_TransactionRunner {
|
|
|
6809
6826
|
}
|
|
6810
6827
|
Tt() {
|
|
6811
6828
|
this.Et.K((async () => {
|
|
6812
|
-
const t = new Transaction$1(this.datastore), e = this.
|
|
6829
|
+
const t = new Transaction$1(this.datastore), e = this.Pt(t);
|
|
6813
6830
|
e && e.then((e => {
|
|
6814
6831
|
this.asyncQueue.enqueueAndForget((() => t.commit().then((() => {
|
|
6815
6832
|
this.deferred.resolve(e);
|
|
6816
6833
|
})).catch((t => {
|
|
6817
|
-
this.
|
|
6834
|
+
this.Rt(t);
|
|
6818
6835
|
}))));
|
|
6819
6836
|
})).catch((t => {
|
|
6820
|
-
this.
|
|
6837
|
+
this.Rt(t);
|
|
6821
6838
|
}));
|
|
6822
6839
|
}));
|
|
6823
6840
|
}
|
|
6824
|
-
|
|
6841
|
+
Pt(t) {
|
|
6825
6842
|
try {
|
|
6826
6843
|
const e = this.updateFunction(t);
|
|
6827
6844
|
return !__PRIVATE_isNullOrUndefined(e) && e.catch && e.then ? e : (this.deferred.reject(Error("Transaction callback must return a Promise")),
|
|
@@ -6831,11 +6848,11 @@ class __PRIVATE_TransactionRunner {
|
|
|
6831
6848
|
return this.deferred.reject(t), null;
|
|
6832
6849
|
}
|
|
6833
6850
|
}
|
|
6834
|
-
|
|
6835
|
-
this.ft > 0 && this.
|
|
6851
|
+
Rt(t) {
|
|
6852
|
+
this.ft > 0 && this.It(t) ? (this.ft -= 1, this.asyncQueue.enqueueAndForget((() => (this.Tt(),
|
|
6836
6853
|
Promise.resolve())))) : this.deferred.reject(t);
|
|
6837
6854
|
}
|
|
6838
|
-
|
|
6855
|
+
It(t) {
|
|
6839
6856
|
if ("FirebaseError" === t.name) {
|
|
6840
6857
|
// In transactions, the backend will fail outdated reads with FAILED_PRECONDITION and
|
|
6841
6858
|
// non-matching document versions with ABORTED. These errors should be retried.
|
|
@@ -6852,29 +6869,29 @@ class __PRIVATE_TransactionRunner {
|
|
|
6852
6869
|
default:
|
|
6853
6870
|
return fail();
|
|
6854
6871
|
|
|
6855
|
-
case m:
|
|
6856
6872
|
case A:
|
|
6873
|
+
case T:
|
|
6857
6874
|
case R:
|
|
6858
|
-
case
|
|
6859
|
-
case D:
|
|
6875
|
+
case w:
|
|
6860
6876
|
case b:
|
|
6877
|
+
case C:
|
|
6861
6878
|
// Unauthenticated means something went wrong with our token and we need
|
|
6862
6879
|
// to retry with new credentials which will happen automatically.
|
|
6863
|
-
case
|
|
6880
|
+
case y:
|
|
6864
6881
|
return !1;
|
|
6865
6882
|
|
|
6866
|
-
case T:
|
|
6867
6883
|
case P:
|
|
6868
|
-
case V:
|
|
6869
6884
|
case I:
|
|
6870
|
-
case
|
|
6885
|
+
case V:
|
|
6886
|
+
case p:
|
|
6887
|
+
case g:
|
|
6871
6888
|
// Aborted might be retried in some scenarios, but that is dependent on
|
|
6872
6889
|
// the context and should handled individually by the calling code.
|
|
6873
6890
|
// See https://cloud.google.com/apis/design/errors.
|
|
6874
|
-
case
|
|
6875
|
-
case F:
|
|
6891
|
+
case F:
|
|
6876
6892
|
case v:
|
|
6877
|
-
case
|
|
6893
|
+
case D:
|
|
6894
|
+
case S:
|
|
6878
6895
|
return !0;
|
|
6879
6896
|
}
|
|
6880
6897
|
}(e);
|
|
@@ -6979,7 +6996,7 @@ class __PRIVATE_TransactionRunner {
|
|
|
6979
6996
|
* As long as the operation has not yet been run, calling cancel() provides a
|
|
6980
6997
|
* guarantee that the operation will not be run.
|
|
6981
6998
|
*/ cancel(t) {
|
|
6982
|
-
null !== this.timerHandle && (this.clearTimeout(), this.deferred.reject(new FirestoreError(
|
|
6999
|
+
null !== this.timerHandle && (this.clearTimeout(), this.deferred.reject(new FirestoreError(A, "Operation cancelled" + (t ? ": " + t : ""))));
|
|
6983
7000
|
}
|
|
6984
7001
|
handleDelayElapsed() {
|
|
6985
7002
|
this.asyncQueue.enqueueAndForget((() => null !== this.timerHandle ? (this.clearTimeout(),
|
|
@@ -7010,7 +7027,7 @@ class __PRIVATE_TransactionRunner {
|
|
|
7010
7027
|
constructor(t = Promise.resolve()) {
|
|
7011
7028
|
// A list of retryable operations. Retryable operations are run in order and
|
|
7012
7029
|
// retried with backoff.
|
|
7013
|
-
this.
|
|
7030
|
+
this.Vt = [],
|
|
7014
7031
|
// Is this AsyncQueue being shut down? Once it is set to true, it will not
|
|
7015
7032
|
// be changed again.
|
|
7016
7033
|
this.yt = !1,
|
|
@@ -7073,15 +7090,15 @@ class __PRIVATE_TransactionRunner {
|
|
|
7073
7090
|
e.promise))).then((() => e.promise));
|
|
7074
7091
|
}
|
|
7075
7092
|
enqueueRetryable(t) {
|
|
7076
|
-
this.enqueueAndForget((() => (this.
|
|
7093
|
+
this.enqueueAndForget((() => (this.Vt.push(t), this.Ot())));
|
|
7077
7094
|
}
|
|
7078
7095
|
/**
|
|
7079
7096
|
* Runs the next operation from the retryable queue. If the operation fails,
|
|
7080
7097
|
* reschedules with backoff.
|
|
7081
7098
|
*/ async Ot() {
|
|
7082
|
-
if (0 !== this.
|
|
7099
|
+
if (0 !== this.Vt.length) {
|
|
7083
7100
|
try {
|
|
7084
|
-
await this.
|
|
7101
|
+
await this.Vt[0](), this.Vt.shift(), this.Et.reset();
|
|
7085
7102
|
} catch (t) {
|
|
7086
7103
|
if (!
|
|
7087
7104
|
/**
|
|
@@ -7125,7 +7142,7 @@ class __PRIVATE_TransactionRunner {
|
|
|
7125
7142
|
// Failure will be handled by AsyncQueue
|
|
7126
7143
|
__PRIVATE_logDebug("AsyncQueue", "Operation failed with retryable error: " + t);
|
|
7127
7144
|
}
|
|
7128
|
-
this.
|
|
7145
|
+
this.Vt.length > 0 &&
|
|
7129
7146
|
// If there are additional operations, we re-schedule `retryNextOp()`.
|
|
7130
7147
|
// This is necessary to run retryable operations that failed during
|
|
7131
7148
|
// their initial attempt since we don't know whether they are already
|
|
@@ -7306,9 +7323,9 @@ class Transaction {
|
|
|
7306
7323
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
7307
7324
|
* rejected promise with the corresponding failure error is returned.
|
|
7308
7325
|
*/ function runTransaction(t, e, r) {
|
|
7309
|
-
const n = __PRIVATE_getDatastore(t = __PRIVATE_cast(t, Firestore)), i = Object.assign(Object.assign({},
|
|
7326
|
+
const n = __PRIVATE_getDatastore(t = __PRIVATE_cast(t, Firestore)), i = Object.assign(Object.assign({}, W), r);
|
|
7310
7327
|
!function __PRIVATE_validateTransactionOptions(t) {
|
|
7311
|
-
if (t.maxAttempts < 1) throw new FirestoreError(
|
|
7328
|
+
if (t.maxAttempts < 1) throw new FirestoreError(P, "Max attempts must be at least 1");
|
|
7312
7329
|
}(i);
|
|
7313
7330
|
const s = new __PRIVATE_Deferred;
|
|
7314
7331
|
return new __PRIVATE_TransactionRunner(function __PRIVATE_newAsyncQueue() {
|
|
@@ -7325,10 +7342,10 @@ class Transaction {
|
|
|
7325
7342
|
* @packageDocumentation
|
|
7326
7343
|
*/ !function __PRIVATE_registerFirestore() {
|
|
7327
7344
|
!function __PRIVATE_setSDKVersion(t) {
|
|
7328
|
-
|
|
7345
|
+
f = t;
|
|
7329
7346
|
}(`${SDK_VERSION}_lite`), _registerComponent(new Component("firestore/lite", ((t, {instanceIdentifier: e, options: r}) => {
|
|
7330
7347
|
const n = t.getProvider("app").getImmediate(), i = new Firestore(new __PRIVATE_LiteAuthCredentialsProvider(t.getProvider("auth-internal")), new __PRIVATE_LiteAppCheckTokenProvider(t.getProvider("app-check-internal")), function __PRIVATE_databaseIdFromApp(t, e) {
|
|
7331
|
-
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new FirestoreError(
|
|
7348
|
+
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new FirestoreError(P, '"projectId" not provided in firebase.initializeApp.');
|
|
7332
7349
|
return new DatabaseId(t.options.projectId, e);
|
|
7333
7350
|
}
|
|
7334
7351
|
/**
|
|
@@ -7350,7 +7367,7 @@ class Transaction {
|
|
|
7350
7367
|
return r && i._setSettings(r), i;
|
|
7351
7368
|
}), "PUBLIC").setMultipleInstances(!0)),
|
|
7352
7369
|
// RUNTIME_ENV and BUILD_TARGET are replaced by real values during the compilation
|
|
7353
|
-
registerVersion("firestore-lite", "4.7.
|
|
7370
|
+
registerVersion("firestore-lite", "4.7.6-canary.144bc3709", ""), registerVersion("firestore-lite", "4.7.6-canary.144bc3709", "cjs2017");
|
|
7354
7371
|
}();
|
|
7355
7372
|
|
|
7356
7373
|
export { AggregateField, AggregateQuerySnapshot, Bytes, CollectionReference, DocumentReference, DocumentSnapshot, FieldPath, FieldValue, Firestore, FirestoreError, GeoPoint, Query, QueryCompositeFilterConstraint, QueryConstraint, QueryDocumentSnapshot, QueryEndAtConstraint, QueryFieldFilterConstraint, QueryLimitConstraint, QueryOrderByConstraint, QuerySnapshot, QueryStartAtConstraint, Timestamp, Transaction, VectorValue, WriteBatch, addDoc, aggregateFieldEqual, aggregateQuerySnapshotEqual, and, arrayRemove, arrayUnion, average, collection, collectionGroup, connectFirestoreEmulator, count, deleteDoc, deleteField, doc, documentId, endAt, endBefore, getAggregate, getCount, getDoc, getDocs, getFirestore, increment, initializeFirestore, limit, limitToLast, or, orderBy, query, queryEqual, refEqual, runTransaction, serverTimestamp, setDoc, setLogLevel, snapshotEqual, startAfter, startAt, sum, terminate, updateDoc, vector, where, writeBatch };
|