@firebase/firestore 3.4.2 → 3.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/firestore/src/api/snapshot.d.ts +6 -6
- package/dist/firestore/src/lite-api/snapshot.d.ts +2 -2
- package/dist/firestore/test/integration/bootstrap.d.ts +0 -1
- package/dist/firestore/test/integration/util/events_accumulator.d.ts +2 -2
- package/dist/firestore/test/integration/util/firebase_export.d.ts +6 -14
- package/dist/firestore/test/integration/util/helpers.d.ts +18 -18
- package/dist/firestore/test/integration/util/internal_helpers.d.ts +3 -3
- package/dist/firestore/test/integration/util/settings.d.ts +2 -2
- package/dist/firestore/test/unit/api/{blob.test.d.ts → bytes.test.d.ts} +0 -0
- package/dist/firestore/test/util/api_helpers.d.ts +1 -1
- package/dist/firestore/test/util/helpers.d.ts +4 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.esm2017.js +869 -869
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +1257 -1257
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +2674 -24
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +2675 -25
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +1068 -1068
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +8 -8
- package/dist/lite/firestore/src/api/snapshot.d.ts +6 -6
- package/dist/lite/firestore/src/lite-api/snapshot.d.ts +2 -2
- package/dist/lite/firestore/test/integration/bootstrap.d.ts +0 -1
- package/dist/lite/firestore/test/integration/util/events_accumulator.d.ts +2 -2
- package/dist/lite/firestore/test/integration/util/firebase_export.d.ts +6 -14
- package/dist/lite/firestore/test/integration/util/helpers.d.ts +18 -18
- package/dist/lite/firestore/test/integration/util/internal_helpers.d.ts +3 -3
- package/dist/lite/firestore/test/integration/util/settings.d.ts +2 -2
- package/dist/lite/firestore/test/unit/api/{blob.test.d.ts → bytes.test.d.ts} +0 -0
- package/dist/lite/firestore/test/util/api_helpers.d.ts +1 -1
- package/dist/lite/firestore/test/util/helpers.d.ts +4 -6
- package/dist/lite/index.browser.esm2017.js +1136 -1136
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +105 -105
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.d.ts +2 -2
- package/dist/lite/index.node.cjs.js +11 -12
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +11 -12
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +148 -148
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +2 -2
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +107 -107
- package/dist/lite/packages/firestore/src/api/snapshot.d.ts +6 -6
- package/dist/lite/packages/firestore/src/lite-api/snapshot.d.ts +2 -2
- package/dist/lite/packages/firestore/test/integration/bootstrap.d.ts +0 -1
- package/dist/lite/packages/firestore/test/integration/util/events_accumulator.d.ts +2 -2
- package/dist/lite/packages/firestore/test/integration/util/firebase_export.d.ts +6 -14
- package/dist/lite/packages/firestore/test/integration/util/helpers.d.ts +18 -18
- package/dist/lite/packages/firestore/test/integration/util/internal_helpers.d.ts +3 -3
- package/dist/lite/packages/firestore/test/integration/util/settings.d.ts +2 -2
- package/dist/lite/packages/firestore/test/unit/api/{blob.test.d.ts → bytes.test.d.ts} +0 -0
- package/dist/lite/packages/firestore/test/util/api_helpers.d.ts +1 -1
- package/dist/lite/packages/firestore/test/util/helpers.d.ts +4 -6
- package/dist/lite/private.d.ts +2 -2
- package/dist/packages/firestore/dist/index.esm2017.d.ts +105 -105
- package/dist/packages/firestore/src/api/snapshot.d.ts +6 -6
- package/dist/packages/firestore/src/lite-api/snapshot.d.ts +2 -2
- package/dist/packages/firestore/test/integration/bootstrap.d.ts +0 -1
- package/dist/packages/firestore/test/integration/util/events_accumulator.d.ts +2 -2
- package/dist/packages/firestore/test/integration/util/firebase_export.d.ts +6 -14
- package/dist/packages/firestore/test/integration/util/helpers.d.ts +18 -18
- package/dist/packages/firestore/test/integration/util/internal_helpers.d.ts +3 -3
- package/dist/packages/firestore/test/integration/util/settings.d.ts +2 -2
- package/dist/packages/firestore/test/unit/api/{blob.test.d.ts → bytes.test.d.ts} +0 -0
- package/dist/packages/firestore/test/util/api_helpers.d.ts +1 -1
- package/dist/packages/firestore/test/util/helpers.d.ts +4 -6
- package/dist/private.d.ts +8 -8
- package/package.json +4 -7
- package/dist/firestore/compat/api/blob.d.ts +0 -29
- package/dist/firestore/compat/api/database.d.ts +0 -228
- package/dist/firestore/compat/api/field_path.d.ts +0 -36
- package/dist/firestore/compat/api/field_value.d.ts +0 -29
- package/dist/firestore/compat/api/geo_point.d.ts +0 -17
- package/dist/firestore/compat/api/observer.d.ts +0 -29
- package/dist/firestore/compat/api/timestamp.d.ts +0 -17
- package/dist/firestore/compat/config.d.ts +0 -28
- package/dist/firestore/compat/index.console.d.ts +0 -42
- package/dist/firestore/compat/index.d.ts +0 -49
- package/dist/firestore/compat/index.node.d.ts +0 -22
- package/dist/firestore/compat/index.rn.d.ts +0 -22
- package/dist/firestore/compat/register-module.d.ts +0 -42
- package/dist/firestore/compat/util/input_validation.d.ts +0 -18
- package/dist/lite/firestore/compat/api/blob.d.ts +0 -29
- package/dist/lite/firestore/compat/api/database.d.ts +0 -228
- package/dist/lite/firestore/compat/api/field_path.d.ts +0 -36
- package/dist/lite/firestore/compat/api/field_value.d.ts +0 -29
- package/dist/lite/firestore/compat/api/geo_point.d.ts +0 -17
- package/dist/lite/firestore/compat/api/observer.d.ts +0 -29
- package/dist/lite/firestore/compat/api/timestamp.d.ts +0 -17
- package/dist/lite/firestore/compat/config.d.ts +0 -28
- package/dist/lite/firestore/compat/index.console.d.ts +0 -42
- package/dist/lite/firestore/compat/index.d.ts +0 -49
- package/dist/lite/firestore/compat/index.node.d.ts +0 -22
- package/dist/lite/firestore/compat/index.rn.d.ts +0 -22
- package/dist/lite/firestore/compat/register-module.d.ts +0 -42
- package/dist/lite/firestore/compat/util/input_validation.d.ts +0 -18
- package/dist/lite/packages/firestore/compat/api/blob.d.ts +0 -29
- package/dist/lite/packages/firestore/compat/api/database.d.ts +0 -228
- package/dist/lite/packages/firestore/compat/api/field_path.d.ts +0 -36
- package/dist/lite/packages/firestore/compat/api/field_value.d.ts +0 -29
- package/dist/lite/packages/firestore/compat/api/geo_point.d.ts +0 -17
- package/dist/lite/packages/firestore/compat/api/observer.d.ts +0 -29
- package/dist/lite/packages/firestore/compat/api/timestamp.d.ts +0 -17
- package/dist/lite/packages/firestore/compat/config.d.ts +0 -28
- package/dist/lite/packages/firestore/compat/index.console.d.ts +0 -42
- package/dist/lite/packages/firestore/compat/index.d.ts +0 -49
- package/dist/lite/packages/firestore/compat/index.node.d.ts +0 -22
- package/dist/lite/packages/firestore/compat/index.rn.d.ts +0 -22
- package/dist/lite/packages/firestore/compat/register-module.d.ts +0 -42
- package/dist/lite/packages/firestore/compat/util/input_validation.d.ts +0 -18
- package/dist/lite/src/protos/README.md +0 -2
- package/dist/lite/src/protos/firestore/bundle.proto +0 -121
- package/dist/lite/src/protos/firestore_bundle_proto.ts +0 -93
- package/dist/lite/src/protos/firestore_proto_api.ts +0 -1259
- package/dist/lite/src/protos/google/api/annotations.proto +0 -31
- package/dist/lite/src/protos/google/api/http.proto +0 -370
- package/dist/lite/src/protos/google/firestore/v1/common.proto +0 -84
- package/dist/lite/src/protos/google/firestore/v1/document.proto +0 -151
- package/dist/lite/src/protos/google/firestore/v1/firestore.proto +0 -761
- package/dist/lite/src/protos/google/firestore/v1/query.proto +0 -302
- package/dist/lite/src/protos/google/firestore/v1/write.proto +0 -264
- package/dist/lite/src/protos/google/protobuf/any.proto +0 -155
- package/dist/lite/src/protos/google/protobuf/descriptor.proto +0 -882
- package/dist/lite/src/protos/google/protobuf/empty.proto +0 -52
- package/dist/lite/src/protos/google/protobuf/struct.proto +0 -96
- package/dist/lite/src/protos/google/protobuf/timestamp.proto +0 -137
- package/dist/lite/src/protos/google/protobuf/wrappers.proto +0 -123
- package/dist/lite/src/protos/google/rpc/status.proto +0 -92
- package/dist/lite/src/protos/google/type/latlng.proto +0 -71
- package/dist/lite/src/protos/update.sh +0 -61
- package/dist/packages/firestore/compat/api/blob.d.ts +0 -29
- package/dist/packages/firestore/compat/api/database.d.ts +0 -228
- package/dist/packages/firestore/compat/api/field_path.d.ts +0 -36
- package/dist/packages/firestore/compat/api/field_value.d.ts +0 -29
- package/dist/packages/firestore/compat/api/geo_point.d.ts +0 -17
- package/dist/packages/firestore/compat/api/observer.d.ts +0 -29
- package/dist/packages/firestore/compat/api/timestamp.d.ts +0 -17
- package/dist/packages/firestore/compat/config.d.ts +0 -28
- package/dist/packages/firestore/compat/index.console.d.ts +0 -42
- package/dist/packages/firestore/compat/index.d.ts +0 -49
- package/dist/packages/firestore/compat/index.node.d.ts +0 -22
- package/dist/packages/firestore/compat/index.rn.d.ts +0 -22
- package/dist/packages/firestore/compat/register-module.d.ts +0 -42
- package/dist/packages/firestore/compat/util/input_validation.d.ts +0 -18
- package/dist/src/protos/README.md +0 -2
- package/dist/src/protos/firestore/bundle.proto +0 -121
- package/dist/src/protos/firestore_bundle_proto.ts +0 -93
- package/dist/src/protos/firestore_proto_api.ts +0 -1259
- package/dist/src/protos/google/api/annotations.proto +0 -31
- package/dist/src/protos/google/api/http.proto +0 -370
- package/dist/src/protos/google/firestore/v1/common.proto +0 -84
- package/dist/src/protos/google/firestore/v1/document.proto +0 -151
- package/dist/src/protos/google/firestore/v1/firestore.proto +0 -761
- package/dist/src/protos/google/firestore/v1/query.proto +0 -302
- package/dist/src/protos/google/firestore/v1/write.proto +0 -264
- package/dist/src/protos/google/protobuf/any.proto +0 -155
- package/dist/src/protos/google/protobuf/descriptor.proto +0 -882
- package/dist/src/protos/google/protobuf/empty.proto +0 -52
- package/dist/src/protos/google/protobuf/struct.proto +0 -96
- package/dist/src/protos/google/protobuf/timestamp.proto +0 -137
- package/dist/src/protos/google/protobuf/wrappers.proto +0 -123
- package/dist/src/protos/google/rpc/status.proto +0 -92
- package/dist/src/protos/google/type/latlng.proto +0 -71
- package/dist/src/protos/update.sh +0 -61
|
@@ -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.6.
|
|
66
|
+
let f = "9.6.3";
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* @license
|
|
@@ -99,26 +99,26 @@ const d = new Logger("@firebase/firestore");
|
|
|
99
99
|
d.setLogLevel(t);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
function m(t, ...
|
|
102
|
+
function m(t, ...n) {
|
|
103
103
|
if (d.logLevel <= LogLevel.DEBUG) {
|
|
104
|
-
const
|
|
105
|
-
d.debug(`Firestore (${f}): ${t}`, ...
|
|
104
|
+
const e = n.map(_);
|
|
105
|
+
d.debug(`Firestore (${f}): ${t}`, ...e);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
function p(t, ...
|
|
109
|
+
function p(t, ...n) {
|
|
110
110
|
if (d.logLevel <= LogLevel.ERROR) {
|
|
111
|
-
const
|
|
112
|
-
d.error(`Firestore (${f}): ${t}`, ...
|
|
111
|
+
const e = n.map(_);
|
|
112
|
+
d.error(`Firestore (${f}): ${t}`, ...e);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
/**
|
|
117
117
|
* @internal
|
|
118
|
-
*/ function y(t, ...
|
|
118
|
+
*/ function y(t, ...n) {
|
|
119
119
|
if (d.logLevel <= LogLevel.WARN) {
|
|
120
|
-
const
|
|
121
|
-
d.warn(`Firestore (${f}): ${t}`, ...
|
|
120
|
+
const e = n.map(_);
|
|
121
|
+
d.warn(`Firestore (${f}): ${t}`, ...e);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
@@ -127,8 +127,8 @@ function p(t, ...e) {
|
|
|
127
127
|
*/ function _(t) {
|
|
128
128
|
if ("string" == typeof t) return t;
|
|
129
129
|
try {
|
|
130
|
-
return
|
|
131
|
-
} catch (
|
|
130
|
+
return n = t, JSON.stringify(n);
|
|
131
|
+
} catch (n) {
|
|
132
132
|
// Converting to JSON failed, just log the object directly
|
|
133
133
|
return t;
|
|
134
134
|
}
|
|
@@ -149,7 +149,7 @@ function p(t, ...e) {
|
|
|
149
149
|
* limitations under the License.
|
|
150
150
|
*/
|
|
151
151
|
/** Formats an object as a JSON string, suitable for logging. */
|
|
152
|
-
var
|
|
152
|
+
var n;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
/**
|
|
@@ -178,11 +178,11 @@ function p(t, ...e) {
|
|
|
178
178
|
*/ function g(t = "Unexpected state") {
|
|
179
179
|
// Log the failure in addition to throw an exception, just in case the
|
|
180
180
|
// exception is swallowed.
|
|
181
|
-
const
|
|
181
|
+
const n = `FIRESTORE (${f}) INTERNAL ASSERTION FAILED: ` + t;
|
|
182
182
|
// NOTE: We don't use FirestoreError here because these are internal failures
|
|
183
183
|
// that cannot be handled by the user. (Also it would create a circular
|
|
184
184
|
// dependency between the error and assert modules which doesn't work.)
|
|
185
|
-
throw p(
|
|
185
|
+
throw p(n), new Error(n);
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
/**
|
|
@@ -190,7 +190,7 @@ function p(t, ...e) {
|
|
|
190
190
|
* given message if it did.
|
|
191
191
|
*
|
|
192
192
|
* Messages are stripped in production builds.
|
|
193
|
-
*/ function v(t,
|
|
193
|
+
*/ function v(t, n) {
|
|
194
194
|
t || g();
|
|
195
195
|
}
|
|
196
196
|
|
|
@@ -199,7 +199,7 @@ function p(t, ...e) {
|
|
|
199
199
|
* instance of `T` before casting.
|
|
200
200
|
*/ function b(t,
|
|
201
201
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
202
|
-
|
|
202
|
+
n) {
|
|
203
203
|
return t;
|
|
204
204
|
}
|
|
205
205
|
|
|
@@ -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", I = "unknown", A = "invalid-argument",
|
|
221
|
+
*/ const E = "ok", T = "cancelled", I = "unknown", A = "invalid-argument", R = "deadline-exceeded", P = "not-found", V = "already-exists", D = "permission-denied", N = "unauthenticated", $ = "resource-exhausted", S = "failed-precondition", F = "aborted", x = "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 */
|
|
@@ -230,8 +230,8 @@ e) {
|
|
|
230
230
|
/**
|
|
231
231
|
* A custom error description.
|
|
232
232
|
*/
|
|
233
|
-
|
|
234
|
-
super(t,
|
|
233
|
+
n) {
|
|
234
|
+
super(t, n), this.code = t, this.message = n,
|
|
235
235
|
// HACK: We write a toString property directly because Error is not a real
|
|
236
236
|
// class and so inheritance does not work correctly. We could alternatively
|
|
237
237
|
// do the same "back-door inheritance" trick that FirebaseError does.
|
|
@@ -256,8 +256,8 @@ e) {
|
|
|
256
256
|
* limitations under the License.
|
|
257
257
|
*/ class k {
|
|
258
258
|
constructor() {
|
|
259
|
-
this.promise = new Promise(((t,
|
|
260
|
-
this.resolve = t, this.reject =
|
|
259
|
+
this.promise = new Promise(((t, n) => {
|
|
260
|
+
this.resolve = t, this.reject = n;
|
|
261
261
|
}));
|
|
262
262
|
}
|
|
263
263
|
}
|
|
@@ -278,8 +278,8 @@ e) {
|
|
|
278
278
|
* See the License for the specific language governing permissions and
|
|
279
279
|
* limitations under the License.
|
|
280
280
|
*/ class j {
|
|
281
|
-
constructor(t,
|
|
282
|
-
this.user =
|
|
281
|
+
constructor(t, n) {
|
|
282
|
+
this.user = n, this.type = "OAuth", this.headers = new Map, this.headers.set("Authorization", `Bearer ${t}`);
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
285
|
|
|
@@ -291,9 +291,9 @@ e) {
|
|
|
291
291
|
return Promise.resolve(null);
|
|
292
292
|
}
|
|
293
293
|
invalidateToken() {}
|
|
294
|
-
start(t,
|
|
294
|
+
start(t, n) {
|
|
295
295
|
// Fire with initial user.
|
|
296
|
-
t.enqueueRetryable((() =>
|
|
296
|
+
t.enqueueRetryable((() => n(l.UNAUTHENTICATED)));
|
|
297
297
|
}
|
|
298
298
|
shutdown() {}
|
|
299
299
|
}
|
|
@@ -315,10 +315,10 @@ e) {
|
|
|
315
315
|
return Promise.resolve(this.token);
|
|
316
316
|
}
|
|
317
317
|
invalidateToken() {}
|
|
318
|
-
start(t,
|
|
319
|
-
this.changeListener =
|
|
318
|
+
start(t, n) {
|
|
319
|
+
this.changeListener = n,
|
|
320
320
|
// Fire with initial user.
|
|
321
|
-
t.enqueueRetryable((() =>
|
|
321
|
+
t.enqueueRetryable((() => n(this.token.user)));
|
|
322
322
|
}
|
|
323
323
|
shutdown() {
|
|
324
324
|
this.changeListener = null;
|
|
@@ -336,7 +336,7 @@ e) {
|
|
|
336
336
|
new j(t.accessToken, new l(this.auth.getUid()))) : null)) : Promise.resolve(null);
|
|
337
337
|
}
|
|
338
338
|
invalidateToken() {}
|
|
339
|
-
start(t,
|
|
339
|
+
start(t, n) {}
|
|
340
340
|
shutdown() {}
|
|
341
341
|
}
|
|
342
342
|
|
|
@@ -347,10 +347,10 @@ e) {
|
|
|
347
347
|
* recover from unauthenticated errors (see b/33147818 for context), but it's
|
|
348
348
|
* safer to keep the implementation as-is.
|
|
349
349
|
*/ class G {
|
|
350
|
-
constructor(t,
|
|
351
|
-
this.type = "FirstParty", this.user = l.FIRST_PARTY, this.headers = new Map, this.headers.set("X-Goog-AuthUser",
|
|
350
|
+
constructor(t, n, e) {
|
|
351
|
+
this.type = "FirstParty", this.user = l.FIRST_PARTY, this.headers = new Map, this.headers.set("X-Goog-AuthUser", n);
|
|
352
352
|
const r = t.auth.getAuthHeaderValueForFirstParty([]);
|
|
353
|
-
r && this.headers.set("Authorization", r),
|
|
353
|
+
r && this.headers.set("Authorization", r), e && this.headers.set("X-Goog-Iam-Authorization-Token", e);
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
356
|
|
|
@@ -359,15 +359,15 @@ e) {
|
|
|
359
359
|
* to authenticate the user, using technique that is only available
|
|
360
360
|
* to applications hosted by Google.
|
|
361
361
|
*/ class Q {
|
|
362
|
-
constructor(t,
|
|
363
|
-
this.t = t, this.i =
|
|
362
|
+
constructor(t, n, e) {
|
|
363
|
+
this.t = t, this.i = n, this.o = e;
|
|
364
364
|
}
|
|
365
365
|
getToken() {
|
|
366
366
|
return Promise.resolve(new G(this.t, this.i, this.o));
|
|
367
367
|
}
|
|
368
|
-
start(t,
|
|
368
|
+
start(t, n) {
|
|
369
369
|
// Fire with initial uid.
|
|
370
|
-
t.enqueueRetryable((() =>
|
|
370
|
+
t.enqueueRetryable((() => n(l.FIRST_PARTY)));
|
|
371
371
|
}
|
|
372
372
|
shutdown() {}
|
|
373
373
|
invalidateToken() {}
|
|
@@ -390,7 +390,7 @@ class W {
|
|
|
390
390
|
new W(t.token)) : null)) : Promise.resolve(null);
|
|
391
391
|
}
|
|
392
392
|
invalidateToken() {}
|
|
393
|
-
start(t,
|
|
393
|
+
start(t, n) {}
|
|
394
394
|
shutdown() {}
|
|
395
395
|
}
|
|
396
396
|
|
|
@@ -432,8 +432,8 @@ class H {
|
|
|
432
432
|
* @param useFetchStreams Whether to use the Fetch API instead of
|
|
433
433
|
* XMLHTTPRequest
|
|
434
434
|
*/
|
|
435
|
-
constructor(t,
|
|
436
|
-
this.databaseId = t, this.appId =
|
|
435
|
+
constructor(t, n, e, r, s, i, o, u) {
|
|
436
|
+
this.databaseId = t, this.appId = n, this.persistenceKey = e, this.host = r, this.ssl = s,
|
|
437
437
|
this.forceLongPolling = i, this.autoDetectLongPolling = o, this.useFetchStreams = u;
|
|
438
438
|
}
|
|
439
439
|
}
|
|
@@ -444,8 +444,8 @@ class H {
|
|
|
444
444
|
* @internal
|
|
445
445
|
*/
|
|
446
446
|
class K {
|
|
447
|
-
constructor(t,
|
|
448
|
-
this.projectId = t, this.database =
|
|
447
|
+
constructor(t, n) {
|
|
448
|
+
this.projectId = t, this.database = n || "(default)";
|
|
449
449
|
}
|
|
450
450
|
get isDefaultDatabase() {
|
|
451
451
|
return "(default)" === this.database;
|
|
@@ -475,9 +475,9 @@ class K {
|
|
|
475
475
|
* Path represents an ordered sequence of string segments.
|
|
476
476
|
*/
|
|
477
477
|
class J {
|
|
478
|
-
constructor(t,
|
|
479
|
-
void 0 ===
|
|
480
|
-
this.segments = t, this.offset =
|
|
478
|
+
constructor(t, n, e) {
|
|
479
|
+
void 0 === n ? n = 0 : n > t.length && g(), void 0 === e ? e = t.length - n : e > t.length - n && g(),
|
|
480
|
+
this.segments = t, this.offset = n, this.len = e;
|
|
481
481
|
}
|
|
482
482
|
get length() {
|
|
483
483
|
return this.len;
|
|
@@ -486,10 +486,10 @@ class J {
|
|
|
486
486
|
return 0 === J.comparator(this, t);
|
|
487
487
|
}
|
|
488
488
|
child(t) {
|
|
489
|
-
const
|
|
489
|
+
const n = this.segments.slice(this.offset, this.limit());
|
|
490
490
|
return t instanceof J ? t.forEach((t => {
|
|
491
|
-
|
|
492
|
-
})) :
|
|
491
|
+
n.push(t);
|
|
492
|
+
})) : n.push(t), this.construct(n);
|
|
493
493
|
}
|
|
494
494
|
/** The index of one past the last segment of the path. */ limit() {
|
|
495
495
|
return this.offset + this.length;
|
|
@@ -514,28 +514,28 @@ class J {
|
|
|
514
514
|
}
|
|
515
515
|
isPrefixOf(t) {
|
|
516
516
|
if (t.length < this.length) return !1;
|
|
517
|
-
for (let
|
|
517
|
+
for (let n = 0; n < this.length; n++) if (this.get(n) !== t.get(n)) return !1;
|
|
518
518
|
return !0;
|
|
519
519
|
}
|
|
520
520
|
isImmediateParentOf(t) {
|
|
521
521
|
if (this.length + 1 !== t.length) return !1;
|
|
522
|
-
for (let
|
|
522
|
+
for (let n = 0; n < this.length; n++) if (this.get(n) !== t.get(n)) return !1;
|
|
523
523
|
return !0;
|
|
524
524
|
}
|
|
525
525
|
forEach(t) {
|
|
526
|
-
for (let
|
|
526
|
+
for (let n = this.offset, e = this.limit(); n < e; n++) t(this.segments[n]);
|
|
527
527
|
}
|
|
528
528
|
toArray() {
|
|
529
529
|
return this.segments.slice(this.offset, this.limit());
|
|
530
530
|
}
|
|
531
|
-
static comparator(t,
|
|
532
|
-
const
|
|
533
|
-
for (let r = 0; r <
|
|
534
|
-
const
|
|
535
|
-
if (
|
|
536
|
-
if (
|
|
531
|
+
static comparator(t, n) {
|
|
532
|
+
const e = Math.min(t.length, n.length);
|
|
533
|
+
for (let r = 0; r < e; r++) {
|
|
534
|
+
const e = t.get(r), s = n.get(r);
|
|
535
|
+
if (e < s) return -1;
|
|
536
|
+
if (e > s) return 1;
|
|
537
537
|
}
|
|
538
|
-
return t.length <
|
|
538
|
+
return t.length < n.length ? -1 : t.length > n.length ? 1 : 0;
|
|
539
539
|
}
|
|
540
540
|
}
|
|
541
541
|
|
|
@@ -545,8 +545,8 @@ class J {
|
|
|
545
545
|
*
|
|
546
546
|
* @internal
|
|
547
547
|
*/ class X extends J {
|
|
548
|
-
construct(t,
|
|
549
|
-
return new X(t,
|
|
548
|
+
construct(t, n, e) {
|
|
549
|
+
return new X(t, n, e);
|
|
550
550
|
}
|
|
551
551
|
canonicalString() {
|
|
552
552
|
// NOTE: The client is ignorant of any path segments containing escape
|
|
@@ -565,13 +565,13 @@ class J {
|
|
|
565
565
|
// NOTE: The client is ignorant of any path segments containing escape
|
|
566
566
|
// sequences (e.g. __id123__) and just passes them through raw (they exist
|
|
567
567
|
// for legacy reasons and should not be used frequently).
|
|
568
|
-
const
|
|
569
|
-
for (const
|
|
570
|
-
if (
|
|
568
|
+
const n = [];
|
|
569
|
+
for (const e of t) {
|
|
570
|
+
if (e.indexOf("//") >= 0) throw new U(A, `Invalid segment (${e}). Paths must not contain // in them.`);
|
|
571
571
|
// Strip leading and traling slashed.
|
|
572
|
-
|
|
572
|
+
n.push(...e.split("/").filter((t => t.length > 0)));
|
|
573
573
|
}
|
|
574
|
-
return new X(
|
|
574
|
+
return new X(n);
|
|
575
575
|
}
|
|
576
576
|
static emptyPath() {
|
|
577
577
|
return new X([]);
|
|
@@ -584,8 +584,8 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
584
584
|
* A dot-separated path for navigating sub-objects within a document.
|
|
585
585
|
* @internal
|
|
586
586
|
*/ class tt extends J {
|
|
587
|
-
construct(t,
|
|
588
|
-
return new tt(t,
|
|
587
|
+
construct(t, n, e) {
|
|
588
|
+
return new tt(t, n, e);
|
|
589
589
|
}
|
|
590
590
|
/**
|
|
591
591
|
* Returns true if the string could be used as a segment in a field path
|
|
@@ -620,24 +620,24 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
620
620
|
* TODO(b/37244157): we should make this more strict. Right now, it allows
|
|
621
621
|
* non-identifier path components, even if they aren't escaped.
|
|
622
622
|
*/ static fromServerFormat(t) {
|
|
623
|
-
const
|
|
624
|
-
let
|
|
623
|
+
const n = [];
|
|
624
|
+
let e = "", r = 0;
|
|
625
625
|
const s = () => {
|
|
626
|
-
if (0 ===
|
|
627
|
-
|
|
626
|
+
if (0 === e.length) throw new U(A, `Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);
|
|
627
|
+
n.push(e), e = "";
|
|
628
628
|
};
|
|
629
629
|
let i = !1;
|
|
630
630
|
for (;r < t.length; ) {
|
|
631
|
-
const
|
|
632
|
-
if ("\\" ===
|
|
631
|
+
const n = t[r];
|
|
632
|
+
if ("\\" === n) {
|
|
633
633
|
if (r + 1 === t.length) throw new U(A, "Path has trailing escape character: " + t);
|
|
634
|
-
const
|
|
635
|
-
if ("\\" !==
|
|
636
|
-
|
|
637
|
-
} else "`" ===
|
|
634
|
+
const n = t[r + 1];
|
|
635
|
+
if ("\\" !== n && "." !== n && "`" !== n) throw new U(A, "Path has invalid escape sequence: " + t);
|
|
636
|
+
e += n, r += 2;
|
|
637
|
+
} else "`" === n ? (i = !i, r++) : "." !== n || i ? (e += n, r++) : (s(), r++);
|
|
638
638
|
}
|
|
639
639
|
if (s(), i) throw new U(A, "Unterminated ` in path: " + t);
|
|
640
|
-
return new tt(
|
|
640
|
+
return new tt(n);
|
|
641
641
|
}
|
|
642
642
|
static emptyPath() {
|
|
643
643
|
return new tt([]);
|
|
@@ -662,15 +662,15 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
662
662
|
*/
|
|
663
663
|
/**
|
|
664
664
|
* @internal
|
|
665
|
-
*/ class
|
|
665
|
+
*/ class nt {
|
|
666
666
|
constructor(t) {
|
|
667
667
|
this.path = t;
|
|
668
668
|
}
|
|
669
669
|
static fromPath(t) {
|
|
670
|
-
return new
|
|
670
|
+
return new nt(X.fromString(t));
|
|
671
671
|
}
|
|
672
672
|
static fromName(t) {
|
|
673
|
-
return new
|
|
673
|
+
return new nt(X.fromString(t).popFirst(5));
|
|
674
674
|
}
|
|
675
675
|
/** Returns true if the document is in the specified collectionId. */ hasCollectionId(t) {
|
|
676
676
|
return this.path.length >= 2 && this.path.get(this.path.length - 2) === t;
|
|
@@ -681,8 +681,8 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
681
681
|
toString() {
|
|
682
682
|
return this.path.toString();
|
|
683
683
|
}
|
|
684
|
-
static comparator(t,
|
|
685
|
-
return X.comparator(t.path,
|
|
684
|
+
static comparator(t, n) {
|
|
685
|
+
return X.comparator(t.path, n.path);
|
|
686
686
|
}
|
|
687
687
|
static isDocumentKey(t) {
|
|
688
688
|
return t.length % 2 == 0;
|
|
@@ -693,7 +693,7 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
693
693
|
* @param segments - The segments of the path to the document
|
|
694
694
|
* @returns A new instance of DocumentKey
|
|
695
695
|
*/ static fromSegments(t) {
|
|
696
|
-
return new
|
|
696
|
+
return new nt(new X(t.slice()));
|
|
697
697
|
}
|
|
698
698
|
}
|
|
699
699
|
|
|
@@ -712,8 +712,8 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
712
712
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
713
713
|
* See the License for the specific language governing permissions and
|
|
714
714
|
* limitations under the License.
|
|
715
|
-
*/ function
|
|
716
|
-
if (!
|
|
715
|
+
*/ function et(t, n, e) {
|
|
716
|
+
if (!e) throw new U(A, `Function ${t}() cannot be called with an empty ${n}.`);
|
|
717
717
|
}
|
|
718
718
|
|
|
719
719
|
/**
|
|
@@ -725,14 +725,14 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
725
725
|
* an even numbers of segments).
|
|
726
726
|
*/
|
|
727
727
|
function rt(t) {
|
|
728
|
-
if (!
|
|
728
|
+
if (!nt.isDocumentKey(t)) throw new U(A, `Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`);
|
|
729
729
|
}
|
|
730
730
|
|
|
731
731
|
/**
|
|
732
732
|
* Validates that `path` refers to a collection (indicated by the fact it
|
|
733
733
|
* contains an odd numbers of segments).
|
|
734
734
|
*/ function st(t) {
|
|
735
|
-
if (
|
|
735
|
+
if (nt.isDocumentKey(t)) throw new U(A, `Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`);
|
|
736
736
|
}
|
|
737
737
|
|
|
738
738
|
/**
|
|
@@ -749,7 +749,7 @@ function it(t) {
|
|
|
749
749
|
if ("object" == typeof t) {
|
|
750
750
|
if (t instanceof Array) return "an array";
|
|
751
751
|
{
|
|
752
|
-
const
|
|
752
|
+
const n =
|
|
753
753
|
/** try to get the constructor name for an object. */
|
|
754
754
|
function(t) {
|
|
755
755
|
if (t.constructor) return t.constructor.name;
|
|
@@ -763,7 +763,7 @@ function it(t) {
|
|
|
763
763
|
* arguments passed to the public API.
|
|
764
764
|
* @internal
|
|
765
765
|
*/ (t);
|
|
766
|
-
return
|
|
766
|
+
return n ? `a custom ${n} object` : "an object";
|
|
767
767
|
}
|
|
768
768
|
}
|
|
769
769
|
return "function" == typeof t ? "a function" : g();
|
|
@@ -771,22 +771,22 @@ function it(t) {
|
|
|
771
771
|
|
|
772
772
|
function ot(t,
|
|
773
773
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
774
|
-
|
|
774
|
+
n) {
|
|
775
775
|
if ("_delegate" in t && (
|
|
776
776
|
// Unwrap Compat types
|
|
777
777
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
778
|
-
t = t._delegate), !(t instanceof
|
|
779
|
-
if (
|
|
778
|
+
t = t._delegate), !(t instanceof n)) {
|
|
779
|
+
if (n.name === t.constructor.name) throw new U(A, "Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");
|
|
780
780
|
{
|
|
781
|
-
const
|
|
782
|
-
throw new U(A, `Expected type '${
|
|
781
|
+
const e = it(t);
|
|
782
|
+
throw new U(A, `Expected type '${n.name}', but it was: ${e}`);
|
|
783
783
|
}
|
|
784
784
|
}
|
|
785
785
|
return t;
|
|
786
786
|
}
|
|
787
787
|
|
|
788
|
-
function ut(t,
|
|
789
|
-
if (
|
|
788
|
+
function ut(t, n) {
|
|
789
|
+
if (n <= 0) throw new U(A, `Function ${t}() requires a positive number, but it was: ${n}.`);
|
|
790
790
|
}
|
|
791
791
|
|
|
792
792
|
/**
|
|
@@ -898,7 +898,7 @@ function dt(t) {
|
|
|
898
898
|
|
|
899
899
|
case 400:
|
|
900
900
|
// Bad Request
|
|
901
|
-
return
|
|
901
|
+
return S;
|
|
902
902
|
|
|
903
903
|
// Other possibilities based on the forward mapping
|
|
904
904
|
// return Code.INVALID_ARGUMENT;
|
|
@@ -913,11 +913,11 @@ function dt(t) {
|
|
|
913
913
|
|
|
914
914
|
case 404:
|
|
915
915
|
// Not Found
|
|
916
|
-
return
|
|
916
|
+
return P;
|
|
917
917
|
|
|
918
918
|
case 409:
|
|
919
919
|
// Conflict
|
|
920
|
-
return
|
|
920
|
+
return F;
|
|
921
921
|
|
|
922
922
|
// Other possibilities:
|
|
923
923
|
// return Code.ALREADY_EXISTS;
|
|
@@ -950,10 +950,10 @@ function dt(t) {
|
|
|
950
950
|
|
|
951
951
|
case 504:
|
|
952
952
|
// Gateway Timeout
|
|
953
|
-
return
|
|
953
|
+
return R;
|
|
954
954
|
|
|
955
955
|
default:
|
|
956
|
-
return t >= 200 && t < 300 ? E : t >= 400 && t < 500 ?
|
|
956
|
+
return t >= 200 && t < 300 ? E : t >= 400 && t < 500 ? S : t >= 500 && t < 600 ? O : I;
|
|
957
957
|
}
|
|
958
958
|
}
|
|
959
959
|
|
|
@@ -993,58 +993,58 @@ class wt extends
|
|
|
993
993
|
class {
|
|
994
994
|
constructor(t) {
|
|
995
995
|
this.databaseInfo = t, this.databaseId = t.databaseId;
|
|
996
|
-
const
|
|
997
|
-
this.h =
|
|
996
|
+
const n = t.ssl ? "https" : "http";
|
|
997
|
+
this.h = n + "://" + t.host, this.l = "projects/" + this.databaseId.projectId + "/databases/" + this.databaseId.database + "/documents";
|
|
998
998
|
}
|
|
999
|
-
m(t,
|
|
1000
|
-
const i = this.p(t,
|
|
1001
|
-
m("RestConnection", "Sending: ", i,
|
|
999
|
+
m(t, n, e, r, s) {
|
|
1000
|
+
const i = this.p(t, n);
|
|
1001
|
+
m("RestConnection", "Sending: ", i, e);
|
|
1002
1002
|
const o = {};
|
|
1003
|
-
return this.g(o, r, s), this.v(t, i, o,
|
|
1004
|
-
t)), (
|
|
1005
|
-
throw y("RestConnection", `${t} failed with error: `,
|
|
1006
|
-
|
|
1003
|
+
return this.g(o, r, s), this.v(t, i, o, e).then((t => (m("RestConnection", "Received: ", t),
|
|
1004
|
+
t)), (n => {
|
|
1005
|
+
throw y("RestConnection", `${t} failed with error: `, n, "url: ", i, "request:", e),
|
|
1006
|
+
n;
|
|
1007
1007
|
}));
|
|
1008
1008
|
}
|
|
1009
|
-
T(t,
|
|
1009
|
+
T(t, n, e, r, s) {
|
|
1010
1010
|
// The REST API automatically aggregates all of the streamed results, so we
|
|
1011
1011
|
// can just use the normal invoke() method.
|
|
1012
|
-
return this.m(t,
|
|
1012
|
+
return this.m(t, n, e, r, s);
|
|
1013
1013
|
}
|
|
1014
1014
|
/**
|
|
1015
1015
|
* Modifies the headers for a request, adding any authorization token if
|
|
1016
1016
|
* present and any additional headers for the request.
|
|
1017
|
-
*/ g(t,
|
|
1017
|
+
*/ g(t, n, e) {
|
|
1018
1018
|
t["X-Goog-Api-Client"] = "gl-js/ fire/" + f,
|
|
1019
1019
|
// Content-Type: text/plain will avoid preflight requests which might
|
|
1020
1020
|
// mess with CORS and redirects by proxies. If we add custom headers
|
|
1021
1021
|
// we will need to change this code to potentially use the $httpOverwrite
|
|
1022
1022
|
// parameter supported by ESF to avoid triggering preflight requests.
|
|
1023
1023
|
t["Content-Type"] = "text/plain", this.databaseInfo.appId && (t["X-Firebase-GMPID"] = this.databaseInfo.appId),
|
|
1024
|
-
|
|
1024
|
+
n && n.headers.forEach(((n, e) => t[e] = n)), e && e.headers.forEach(((n, e) => t[e] = n));
|
|
1025
1025
|
}
|
|
1026
|
-
p(t,
|
|
1027
|
-
const
|
|
1028
|
-
return `${this.h}/v1/${
|
|
1026
|
+
p(t, n) {
|
|
1027
|
+
const e = ht[t];
|
|
1028
|
+
return `${this.h}/v1/${n}:${e}`;
|
|
1029
1029
|
}
|
|
1030
1030
|
} {
|
|
1031
1031
|
/**
|
|
1032
1032
|
* @param databaseInfo - The connection info.
|
|
1033
1033
|
* @param fetchImpl - `fetch` or a Polyfill that implements the fetch API.
|
|
1034
1034
|
*/
|
|
1035
|
-
constructor(t,
|
|
1036
|
-
super(t), this.I =
|
|
1035
|
+
constructor(t, n) {
|
|
1036
|
+
super(t), this.I = n;
|
|
1037
1037
|
}
|
|
1038
|
-
A(t,
|
|
1038
|
+
A(t, n) {
|
|
1039
1039
|
throw new Error("Not supported by FetchConnection");
|
|
1040
1040
|
}
|
|
1041
|
-
async v(t,
|
|
1041
|
+
async v(t, n, e, r) {
|
|
1042
1042
|
const s = JSON.stringify(r);
|
|
1043
1043
|
let i;
|
|
1044
1044
|
try {
|
|
1045
|
-
i = await this.I(
|
|
1045
|
+
i = await this.I(n, {
|
|
1046
1046
|
method: "POST",
|
|
1047
|
-
headers:
|
|
1047
|
+
headers: e,
|
|
1048
1048
|
body: s
|
|
1049
1049
|
});
|
|
1050
1050
|
} catch (t) {
|
|
@@ -1095,13 +1095,13 @@ class {
|
|
|
1095
1095
|
*/
|
|
1096
1096
|
function mt(t) {
|
|
1097
1097
|
// Polyfills for IE and WebWorker by using `self` and `msCrypto` when `crypto` is not available.
|
|
1098
|
-
const
|
|
1098
|
+
const n =
|
|
1099
1099
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1100
|
-
"undefined" != typeof self && (self.crypto || self.msCrypto),
|
|
1101
|
-
if (
|
|
1100
|
+
"undefined" != typeof self && (self.crypto || self.msCrypto), e = new Uint8Array(t);
|
|
1101
|
+
if (n && "function" == typeof n.getRandomValues) n.getRandomValues(e); else
|
|
1102
1102
|
// Falls back to Math.random
|
|
1103
|
-
for (let
|
|
1104
|
-
return
|
|
1103
|
+
for (let n = 0; n < t; n++) e[n] = Math.floor(256 * Math.random());
|
|
1104
|
+
return e;
|
|
1105
1105
|
}
|
|
1106
1106
|
|
|
1107
1107
|
/**
|
|
@@ -1120,28 +1120,28 @@ function mt(t) {
|
|
|
1120
1120
|
* See the License for the specific language governing permissions and
|
|
1121
1121
|
* limitations under the License.
|
|
1122
1122
|
*/ class pt {
|
|
1123
|
-
static
|
|
1123
|
+
static R() {
|
|
1124
1124
|
// Alphanumeric characters
|
|
1125
|
-
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
|
|
1125
|
+
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", n = Math.floor(256 / t.length) * t.length;
|
|
1126
1126
|
// The largest byte value that is a multiple of `char.length`.
|
|
1127
|
-
let
|
|
1128
|
-
for (;
|
|
1127
|
+
let e = "";
|
|
1128
|
+
for (;e.length < 20; ) {
|
|
1129
1129
|
const r = mt(40);
|
|
1130
1130
|
for (let s = 0; s < r.length; ++s)
|
|
1131
1131
|
// Only accept values that are [0, maxMultiple), this ensures they can
|
|
1132
1132
|
// be evenly mapped to indices of `chars` via a modulo operation.
|
|
1133
|
-
|
|
1133
|
+
e.length < 20 && r[s] < n && (e += t.charAt(r[s] % t.length));
|
|
1134
1134
|
}
|
|
1135
|
-
return
|
|
1135
|
+
return e;
|
|
1136
1136
|
}
|
|
1137
1137
|
}
|
|
1138
1138
|
|
|
1139
|
-
function yt(t,
|
|
1140
|
-
return t <
|
|
1139
|
+
function yt(t, n) {
|
|
1140
|
+
return t < n ? -1 : t > n ? 1 : 0;
|
|
1141
1141
|
}
|
|
1142
1142
|
|
|
1143
|
-
/** Helper to compare arrays using isEqual(). */ function _t(t,
|
|
1144
|
-
return t.length ===
|
|
1143
|
+
/** Helper to compare arrays using isEqual(). */ function _t(t, n, e) {
|
|
1144
|
+
return t.length === n.length && t.every(((t, r) => e(t, n[r])));
|
|
1145
1145
|
}
|
|
1146
1146
|
|
|
1147
1147
|
/**
|
|
@@ -1195,9 +1195,9 @@ class gt {
|
|
|
1195
1195
|
/**
|
|
1196
1196
|
* The fractions of a second at nanosecond resolution.*
|
|
1197
1197
|
*/
|
|
1198
|
-
|
|
1199
|
-
if (this.seconds = t, this.nanoseconds =
|
|
1200
|
-
if (
|
|
1198
|
+
n) {
|
|
1199
|
+
if (this.seconds = t, this.nanoseconds = n, n < 0) throw new U(A, "Timestamp nanoseconds out of range: " + n);
|
|
1200
|
+
if (n >= 1e9) throw new U(A, "Timestamp nanoseconds out of range: " + n);
|
|
1201
1201
|
if (t < -62135596800) throw new U(A, "Timestamp seconds out of range: " + t);
|
|
1202
1202
|
// This will break in the year 10,000.
|
|
1203
1203
|
if (t >= 253402300800) throw new U(A, "Timestamp seconds out of range: " + t);
|
|
@@ -1226,8 +1226,8 @@ class gt {
|
|
|
1226
1226
|
* @returns A new `Timestamp` representing the same point in time as the given
|
|
1227
1227
|
* number of milliseconds.
|
|
1228
1228
|
*/ static fromMillis(t) {
|
|
1229
|
-
const
|
|
1230
|
-
return new gt(
|
|
1229
|
+
const n = Math.floor(t / 1e3), e = Math.floor(1e6 * (t - 1e3 * n));
|
|
1230
|
+
return new gt(n, e);
|
|
1231
1231
|
}
|
|
1232
1232
|
/**
|
|
1233
1233
|
* Converts a `Timestamp` to a JavaScript `Date` object. This conversion
|
|
@@ -1349,13 +1349,13 @@ class gt {
|
|
|
1349
1349
|
* See the License for the specific language governing permissions and
|
|
1350
1350
|
* limitations under the License.
|
|
1351
1351
|
*/ function bt(t) {
|
|
1352
|
-
let
|
|
1353
|
-
for (const
|
|
1354
|
-
return
|
|
1352
|
+
let n = 0;
|
|
1353
|
+
for (const e in t) Object.prototype.hasOwnProperty.call(t, e) && n++;
|
|
1354
|
+
return n;
|
|
1355
1355
|
}
|
|
1356
1356
|
|
|
1357
|
-
function Et(t,
|
|
1358
|
-
for (const
|
|
1357
|
+
function Et(t, n) {
|
|
1358
|
+
for (const e in t) Object.prototype.hasOwnProperty.call(t, e) && n(e, t[e]);
|
|
1359
1359
|
}
|
|
1360
1360
|
|
|
1361
1361
|
/**
|
|
@@ -1397,11 +1397,11 @@ class Tt {
|
|
|
1397
1397
|
*
|
|
1398
1398
|
* This is an O(n) operation, where `n` is the size of the field mask.
|
|
1399
1399
|
*/ covers(t) {
|
|
1400
|
-
for (const
|
|
1400
|
+
for (const n of this.fields) if (n.isPrefixOf(t)) return !0;
|
|
1401
1401
|
return !1;
|
|
1402
1402
|
}
|
|
1403
1403
|
isEqual(t) {
|
|
1404
|
-
return _t(this.fields, t.fields, ((t,
|
|
1404
|
+
return _t(this.fields, t.fields, ((t, n) => t.isEqual(n)));
|
|
1405
1405
|
}
|
|
1406
1406
|
}
|
|
1407
1407
|
|
|
@@ -1452,23 +1452,23 @@ class It {
|
|
|
1452
1452
|
this.binaryString = t;
|
|
1453
1453
|
}
|
|
1454
1454
|
static fromBase64String(t) {
|
|
1455
|
-
const
|
|
1456
|
-
return new It(
|
|
1455
|
+
const n = atob(t);
|
|
1456
|
+
return new It(n);
|
|
1457
1457
|
}
|
|
1458
1458
|
static fromUint8Array(t) {
|
|
1459
|
-
const
|
|
1459
|
+
const n =
|
|
1460
1460
|
/**
|
|
1461
1461
|
* Helper function to convert an Uint8array to a binary string.
|
|
1462
1462
|
*/
|
|
1463
1463
|
function(t) {
|
|
1464
|
-
let
|
|
1465
|
-
for (let
|
|
1466
|
-
return
|
|
1464
|
+
let n = "";
|
|
1465
|
+
for (let e = 0; e < t.length; ++e) n += String.fromCharCode(t[e]);
|
|
1466
|
+
return n;
|
|
1467
1467
|
}
|
|
1468
1468
|
/**
|
|
1469
1469
|
* Helper function to convert a binary string to an Uint8Array.
|
|
1470
1470
|
*/ (t);
|
|
1471
|
-
return new It(
|
|
1471
|
+
return new It(n);
|
|
1472
1472
|
}
|
|
1473
1473
|
[Symbol.iterator]() {
|
|
1474
1474
|
let t = 0;
|
|
@@ -1489,9 +1489,9 @@ class It {
|
|
|
1489
1489
|
}
|
|
1490
1490
|
toUint8Array() {
|
|
1491
1491
|
return function(t) {
|
|
1492
|
-
const
|
|
1493
|
-
for (let
|
|
1494
|
-
return
|
|
1492
|
+
const n = new Uint8Array(t.length);
|
|
1493
|
+
for (let e = 0; e < t.length; e++) n[e] = t.charCodeAt(e);
|
|
1494
|
+
return n;
|
|
1495
1495
|
}
|
|
1496
1496
|
/**
|
|
1497
1497
|
* @license
|
|
@@ -1530,7 +1530,7 @@ const At = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1530
1530
|
/**
|
|
1531
1531
|
* Converts the possible Proto values for a timestamp value into a "seconds and
|
|
1532
1532
|
* nanos" representation.
|
|
1533
|
-
*/ function
|
|
1533
|
+
*/ function Rt(t) {
|
|
1534
1534
|
// The json interface (for the browser) will return an iso timestamp string,
|
|
1535
1535
|
// while the proto js library (for node) will return a
|
|
1536
1536
|
// google.protobuf.Timestamp instance.
|
|
@@ -1538,30 +1538,30 @@ const At = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1538
1538
|
// The date string can have higher precision (nanos) than the Date class
|
|
1539
1539
|
// (millis), so we do some custom parsing here.
|
|
1540
1540
|
// Parse the nanos right out of the string.
|
|
1541
|
-
let
|
|
1542
|
-
const
|
|
1543
|
-
if (v(!!
|
|
1541
|
+
let n = 0;
|
|
1542
|
+
const e = At.exec(t);
|
|
1543
|
+
if (v(!!e), e[1]) {
|
|
1544
1544
|
// Pad the fraction out to 9 digits (nanos).
|
|
1545
|
-
let t =
|
|
1546
|
-
t = (t + "000000000").substr(0, 9),
|
|
1545
|
+
let t = e[1];
|
|
1546
|
+
t = (t + "000000000").substr(0, 9), n = Number(t);
|
|
1547
1547
|
}
|
|
1548
1548
|
// Parse the date to get the seconds.
|
|
1549
1549
|
const r = new Date(t);
|
|
1550
1550
|
return {
|
|
1551
1551
|
seconds: Math.floor(r.getTime() / 1e3),
|
|
1552
|
-
nanos:
|
|
1552
|
+
nanos: n
|
|
1553
1553
|
};
|
|
1554
1554
|
}
|
|
1555
1555
|
return {
|
|
1556
|
-
seconds:
|
|
1557
|
-
nanos:
|
|
1556
|
+
seconds: Pt(t.seconds),
|
|
1557
|
+
nanos: Pt(t.nanos)
|
|
1558
1558
|
};
|
|
1559
1559
|
}
|
|
1560
1560
|
|
|
1561
1561
|
/**
|
|
1562
1562
|
* Converts the possible Proto types for numbers into a JavaScript number.
|
|
1563
1563
|
* Returns 0 if the value is not numeric.
|
|
1564
|
-
*/ function
|
|
1564
|
+
*/ function Pt(t) {
|
|
1565
1565
|
// TODO(bjornick): Handle int64 greater than 53 bits.
|
|
1566
1566
|
return "number" == typeof t ? t : "string" == typeof t ? Number(t) : 0;
|
|
1567
1567
|
}
|
|
@@ -1604,8 +1604,8 @@ const At = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1604
1604
|
* - With respect to other ServerTimestampValues, they sort by their
|
|
1605
1605
|
* localWriteTime.
|
|
1606
1606
|
*/ function Dt(t) {
|
|
1607
|
-
var
|
|
1608
|
-
return "server_timestamp" === (null === (
|
|
1607
|
+
var n, e;
|
|
1608
|
+
return "server_timestamp" === (null === (e = ((null === (n = null == t ? void 0 : t.mapValue) || void 0 === n ? void 0 : n.fields) || {}).__type__) || void 0 === e ? void 0 : e.stringValue);
|
|
1609
1609
|
}
|
|
1610
1610
|
|
|
1611
1611
|
/**
|
|
@@ -1614,15 +1614,15 @@ const At = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1614
1614
|
* Preserving the previous values allows the user to display the last resoled
|
|
1615
1615
|
* value until the backend responds with the timestamp.
|
|
1616
1616
|
*/ function Nt(t) {
|
|
1617
|
-
const
|
|
1618
|
-
return Dt(
|
|
1617
|
+
const n = t.mapValue.fields.__previous_value__;
|
|
1618
|
+
return Dt(n) ? Nt(n) : n;
|
|
1619
1619
|
}
|
|
1620
1620
|
|
|
1621
1621
|
/**
|
|
1622
1622
|
* Returns the local time at which this timestamp was first set.
|
|
1623
1623
|
*/ function $t(t) {
|
|
1624
|
-
const
|
|
1625
|
-
return new gt(
|
|
1624
|
+
const n = Rt(t.mapValue.fields.__local_write_time__.timestampValue);
|
|
1625
|
+
return new gt(n.seconds, n.nanos);
|
|
1626
1626
|
}
|
|
1627
1627
|
|
|
1628
1628
|
/**
|
|
@@ -1641,173 +1641,173 @@ const At = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1641
1641
|
* See the License for the specific language governing permissions and
|
|
1642
1642
|
* limitations under the License.
|
|
1643
1643
|
*/
|
|
1644
|
-
/** Extracts the backend's type order for the provided value. */ function
|
|
1644
|
+
/** Extracts the backend's type order for the provided value. */ function St(t) {
|
|
1645
1645
|
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 */ : 10 /* ObjectValue */ : g();
|
|
1646
1646
|
}
|
|
1647
1647
|
|
|
1648
|
-
/** Tests `left` and `right` for equality based on the backend semantics. */ function
|
|
1649
|
-
if (t ===
|
|
1650
|
-
const
|
|
1651
|
-
if (
|
|
1652
|
-
switch (
|
|
1648
|
+
/** Tests `left` and `right` for equality based on the backend semantics. */ function Ft(t, n) {
|
|
1649
|
+
if (t === n) return !0;
|
|
1650
|
+
const e = St(t);
|
|
1651
|
+
if (e !== St(n)) return !1;
|
|
1652
|
+
switch (e) {
|
|
1653
1653
|
case 0 /* NullValue */ :
|
|
1654
1654
|
return !0;
|
|
1655
1655
|
|
|
1656
1656
|
case 1 /* BooleanValue */ :
|
|
1657
|
-
return t.booleanValue ===
|
|
1657
|
+
return t.booleanValue === n.booleanValue;
|
|
1658
1658
|
|
|
1659
1659
|
case 4 /* ServerTimestampValue */ :
|
|
1660
|
-
return $t(t).isEqual($t(
|
|
1660
|
+
return $t(t).isEqual($t(n));
|
|
1661
1661
|
|
|
1662
1662
|
case 3 /* TimestampValue */ :
|
|
1663
|
-
return function(t,
|
|
1664
|
-
if ("string" == typeof t.timestampValue && "string" == typeof
|
|
1663
|
+
return function(t, n) {
|
|
1664
|
+
if ("string" == typeof t.timestampValue && "string" == typeof n.timestampValue && t.timestampValue.length === n.timestampValue.length)
|
|
1665
1665
|
// Use string equality for ISO 8601 timestamps
|
|
1666
|
-
return t.timestampValue ===
|
|
1667
|
-
const
|
|
1668
|
-
return
|
|
1669
|
-
}(t,
|
|
1666
|
+
return t.timestampValue === n.timestampValue;
|
|
1667
|
+
const e = Rt(t.timestampValue), r = Rt(n.timestampValue);
|
|
1668
|
+
return e.seconds === r.seconds && e.nanos === r.nanos;
|
|
1669
|
+
}(t, n);
|
|
1670
1670
|
|
|
1671
1671
|
case 5 /* StringValue */ :
|
|
1672
|
-
return t.stringValue ===
|
|
1672
|
+
return t.stringValue === n.stringValue;
|
|
1673
1673
|
|
|
1674
1674
|
case 6 /* BlobValue */ :
|
|
1675
|
-
return function(t,
|
|
1676
|
-
return Vt(t.bytesValue).isEqual(Vt(
|
|
1677
|
-
}(t,
|
|
1675
|
+
return function(t, n) {
|
|
1676
|
+
return Vt(t.bytesValue).isEqual(Vt(n.bytesValue));
|
|
1677
|
+
}(t, n);
|
|
1678
1678
|
|
|
1679
1679
|
case 7 /* RefValue */ :
|
|
1680
|
-
return t.referenceValue ===
|
|
1680
|
+
return t.referenceValue === n.referenceValue;
|
|
1681
1681
|
|
|
1682
1682
|
case 8 /* GeoPointValue */ :
|
|
1683
|
-
return function(t,
|
|
1684
|
-
return
|
|
1685
|
-
}(t,
|
|
1683
|
+
return function(t, n) {
|
|
1684
|
+
return Pt(t.geoPointValue.latitude) === Pt(n.geoPointValue.latitude) && Pt(t.geoPointValue.longitude) === Pt(n.geoPointValue.longitude);
|
|
1685
|
+
}(t, n);
|
|
1686
1686
|
|
|
1687
1687
|
case 2 /* NumberValue */ :
|
|
1688
|
-
return function(t,
|
|
1689
|
-
if ("integerValue" in t && "integerValue" in
|
|
1690
|
-
if ("doubleValue" in t && "doubleValue" in
|
|
1691
|
-
const
|
|
1692
|
-
return
|
|
1688
|
+
return function(t, n) {
|
|
1689
|
+
if ("integerValue" in t && "integerValue" in n) return Pt(t.integerValue) === Pt(n.integerValue);
|
|
1690
|
+
if ("doubleValue" in t && "doubleValue" in n) {
|
|
1691
|
+
const e = Pt(t.doubleValue), r = Pt(n.doubleValue);
|
|
1692
|
+
return e === r ? at(e) === at(r) : isNaN(e) && isNaN(r);
|
|
1693
1693
|
}
|
|
1694
1694
|
return !1;
|
|
1695
|
-
}(t,
|
|
1695
|
+
}(t, n);
|
|
1696
1696
|
|
|
1697
1697
|
case 9 /* ArrayValue */ :
|
|
1698
|
-
return _t(t.arrayValue.values || [],
|
|
1698
|
+
return _t(t.arrayValue.values || [], n.arrayValue.values || [], Ft);
|
|
1699
1699
|
|
|
1700
1700
|
case 10 /* ObjectValue */ :
|
|
1701
|
-
return function(t,
|
|
1702
|
-
const
|
|
1703
|
-
if (bt(
|
|
1704
|
-
for (const t in
|
|
1701
|
+
return function(t, n) {
|
|
1702
|
+
const e = t.mapValue.fields || {}, r = n.mapValue.fields || {};
|
|
1703
|
+
if (bt(e) !== bt(r)) return !1;
|
|
1704
|
+
for (const t in e) if (e.hasOwnProperty(t) && (void 0 === r[t] || !Ft(e[t], r[t]))) return !1;
|
|
1705
1705
|
return !0;
|
|
1706
1706
|
}
|
|
1707
|
-
/** Returns true if the ArrayValue contains the specified element. */ (t,
|
|
1707
|
+
/** Returns true if the ArrayValue contains the specified element. */ (t, n);
|
|
1708
1708
|
|
|
1709
1709
|
default:
|
|
1710
1710
|
return g();
|
|
1711
1711
|
}
|
|
1712
1712
|
}
|
|
1713
1713
|
|
|
1714
|
-
function xt(t,
|
|
1715
|
-
return void 0 !== (t.values || []).find((t =>
|
|
1714
|
+
function xt(t, n) {
|
|
1715
|
+
return void 0 !== (t.values || []).find((t => Ft(t, n)));
|
|
1716
1716
|
}
|
|
1717
1717
|
|
|
1718
|
-
function qt(t,
|
|
1719
|
-
if (t ===
|
|
1720
|
-
const
|
|
1721
|
-
if (
|
|
1722
|
-
switch (
|
|
1718
|
+
function qt(t, n) {
|
|
1719
|
+
if (t === n) return 0;
|
|
1720
|
+
const e = St(t), r = St(n);
|
|
1721
|
+
if (e !== r) return yt(e, r);
|
|
1722
|
+
switch (e) {
|
|
1723
1723
|
case 0 /* NullValue */ :
|
|
1724
1724
|
return 0;
|
|
1725
1725
|
|
|
1726
1726
|
case 1 /* BooleanValue */ :
|
|
1727
|
-
return yt(t.booleanValue,
|
|
1727
|
+
return yt(t.booleanValue, n.booleanValue);
|
|
1728
1728
|
|
|
1729
1729
|
case 2 /* NumberValue */ :
|
|
1730
|
-
return function(t,
|
|
1731
|
-
const
|
|
1732
|
-
return
|
|
1730
|
+
return function(t, n) {
|
|
1731
|
+
const e = Pt(t.integerValue || t.doubleValue), r = Pt(n.integerValue || n.doubleValue);
|
|
1732
|
+
return e < r ? -1 : e > r ? 1 : e === r ? 0 :
|
|
1733
1733
|
// one or both are NaN.
|
|
1734
|
-
isNaN(
|
|
1735
|
-
}(t,
|
|
1734
|
+
isNaN(e) ? isNaN(r) ? 0 : -1 : 1;
|
|
1735
|
+
}(t, n);
|
|
1736
1736
|
|
|
1737
1737
|
case 3 /* TimestampValue */ :
|
|
1738
|
-
return Ot(t.timestampValue,
|
|
1738
|
+
return Ot(t.timestampValue, n.timestampValue);
|
|
1739
1739
|
|
|
1740
1740
|
case 4 /* ServerTimestampValue */ :
|
|
1741
|
-
return Ot($t(t), $t(
|
|
1741
|
+
return Ot($t(t), $t(n));
|
|
1742
1742
|
|
|
1743
1743
|
case 5 /* StringValue */ :
|
|
1744
|
-
return yt(t.stringValue,
|
|
1744
|
+
return yt(t.stringValue, n.stringValue);
|
|
1745
1745
|
|
|
1746
1746
|
case 6 /* BlobValue */ :
|
|
1747
|
-
return function(t,
|
|
1748
|
-
const
|
|
1749
|
-
return
|
|
1750
|
-
}(t.bytesValue,
|
|
1747
|
+
return function(t, n) {
|
|
1748
|
+
const e = Vt(t), r = Vt(n);
|
|
1749
|
+
return e.compareTo(r);
|
|
1750
|
+
}(t.bytesValue, n.bytesValue);
|
|
1751
1751
|
|
|
1752
1752
|
case 7 /* RefValue */ :
|
|
1753
|
-
return function(t,
|
|
1754
|
-
const
|
|
1755
|
-
for (let t = 0; t <
|
|
1756
|
-
const
|
|
1757
|
-
if (0 !==
|
|
1753
|
+
return function(t, n) {
|
|
1754
|
+
const e = t.split("/"), r = n.split("/");
|
|
1755
|
+
for (let t = 0; t < e.length && t < r.length; t++) {
|
|
1756
|
+
const n = yt(e[t], r[t]);
|
|
1757
|
+
if (0 !== n) return n;
|
|
1758
1758
|
}
|
|
1759
|
-
return yt(
|
|
1760
|
-
}(t.referenceValue,
|
|
1759
|
+
return yt(e.length, r.length);
|
|
1760
|
+
}(t.referenceValue, n.referenceValue);
|
|
1761
1761
|
|
|
1762
1762
|
case 8 /* GeoPointValue */ :
|
|
1763
|
-
return function(t,
|
|
1764
|
-
const
|
|
1765
|
-
if (0 !==
|
|
1766
|
-
return yt(
|
|
1767
|
-
}(t.geoPointValue,
|
|
1763
|
+
return function(t, n) {
|
|
1764
|
+
const e = yt(Pt(t.latitude), Pt(n.latitude));
|
|
1765
|
+
if (0 !== e) return e;
|
|
1766
|
+
return yt(Pt(t.longitude), Pt(n.longitude));
|
|
1767
|
+
}(t.geoPointValue, n.geoPointValue);
|
|
1768
1768
|
|
|
1769
1769
|
case 9 /* ArrayValue */ :
|
|
1770
|
-
return function(t,
|
|
1771
|
-
const
|
|
1772
|
-
for (let t = 0; t <
|
|
1773
|
-
const
|
|
1774
|
-
if (
|
|
1770
|
+
return function(t, n) {
|
|
1771
|
+
const e = t.values || [], r = n.values || [];
|
|
1772
|
+
for (let t = 0; t < e.length && t < r.length; ++t) {
|
|
1773
|
+
const n = qt(e[t], r[t]);
|
|
1774
|
+
if (n) return n;
|
|
1775
1775
|
}
|
|
1776
|
-
return yt(
|
|
1777
|
-
}(t.arrayValue,
|
|
1776
|
+
return yt(e.length, r.length);
|
|
1777
|
+
}(t.arrayValue, n.arrayValue);
|
|
1778
1778
|
|
|
1779
1779
|
case 10 /* ObjectValue */ :
|
|
1780
|
-
return function(t,
|
|
1781
|
-
const
|
|
1780
|
+
return function(t, n) {
|
|
1781
|
+
const e = t.fields || {}, r = Object.keys(e), s = n.fields || {}, i = Object.keys(s);
|
|
1782
1782
|
// Even though MapValues are likely sorted correctly based on their insertion
|
|
1783
1783
|
// order (e.g. when received from the backend), local modifications can bring
|
|
1784
1784
|
// elements out of order. We need to re-sort the elements to ensure that
|
|
1785
1785
|
// canonical IDs are independent of insertion order.
|
|
1786
1786
|
r.sort(), i.sort();
|
|
1787
1787
|
for (let t = 0; t < r.length && t < i.length; ++t) {
|
|
1788
|
-
const
|
|
1789
|
-
if (0 !==
|
|
1790
|
-
const o = qt(
|
|
1788
|
+
const n = yt(r[t], i[t]);
|
|
1789
|
+
if (0 !== n) return n;
|
|
1790
|
+
const o = qt(e[r[t]], s[i[t]]);
|
|
1791
1791
|
if (0 !== o) return o;
|
|
1792
1792
|
}
|
|
1793
1793
|
return yt(r.length, i.length);
|
|
1794
1794
|
}
|
|
1795
|
-
/** Returns a reference value for the provided database and key. */ (t.mapValue,
|
|
1795
|
+
/** Returns a reference value for the provided database and key. */ (t.mapValue, n.mapValue);
|
|
1796
1796
|
|
|
1797
1797
|
default:
|
|
1798
1798
|
throw g();
|
|
1799
1799
|
}
|
|
1800
1800
|
}
|
|
1801
1801
|
|
|
1802
|
-
function Ot(t,
|
|
1803
|
-
if ("string" == typeof t && "string" == typeof
|
|
1804
|
-
const
|
|
1805
|
-
return 0 !== s ? s : yt(
|
|
1802
|
+
function Ot(t, n) {
|
|
1803
|
+
if ("string" == typeof t && "string" == typeof n && t.length === n.length) return yt(t, n);
|
|
1804
|
+
const e = Rt(t), r = Rt(n), s = yt(e.seconds, r.seconds);
|
|
1805
|
+
return 0 !== s ? s : yt(e.nanos, r.nanos);
|
|
1806
1806
|
}
|
|
1807
1807
|
|
|
1808
|
-
function Ct(t,
|
|
1808
|
+
function Ct(t, n) {
|
|
1809
1809
|
return {
|
|
1810
|
-
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${
|
|
1810
|
+
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${n.path.canonicalString()}`
|
|
1811
1811
|
};
|
|
1812
1812
|
}
|
|
1813
1813
|
|
|
@@ -1835,21 +1835,21 @@ function Ct(t, e) {
|
|
|
1835
1835
|
timestampValue: Object.assign({}, t.timestampValue)
|
|
1836
1836
|
};
|
|
1837
1837
|
if (t.mapValue) {
|
|
1838
|
-
const
|
|
1838
|
+
const n = {
|
|
1839
1839
|
mapValue: {
|
|
1840
1840
|
fields: {}
|
|
1841
1841
|
}
|
|
1842
1842
|
};
|
|
1843
|
-
return Et(t.mapValue.fields, ((t,
|
|
1843
|
+
return Et(t.mapValue.fields, ((t, e) => n.mapValue.fields[t] = Mt(e))), n;
|
|
1844
1844
|
}
|
|
1845
1845
|
if (t.arrayValue) {
|
|
1846
|
-
const
|
|
1846
|
+
const n = {
|
|
1847
1847
|
arrayValue: {
|
|
1848
1848
|
values: []
|
|
1849
1849
|
}
|
|
1850
1850
|
};
|
|
1851
|
-
for (let
|
|
1852
|
-
return
|
|
1851
|
+
for (let e = 0; e < (t.arrayValue.values || []).length; ++e) n.arrayValue.values[e] = Mt(t.arrayValue.values[e]);
|
|
1852
|
+
return n;
|
|
1853
1853
|
}
|
|
1854
1854
|
return Object.assign({}, t);
|
|
1855
1855
|
}
|
|
@@ -1890,10 +1890,10 @@ function Ct(t, e) {
|
|
|
1890
1890
|
*/ field(t) {
|
|
1891
1891
|
if (t.isEmpty()) return this.value;
|
|
1892
1892
|
{
|
|
1893
|
-
let
|
|
1894
|
-
for (let
|
|
1895
|
-
!jt(
|
|
1896
|
-
return
|
|
1893
|
+
let n = this.value;
|
|
1894
|
+
for (let e = 0; e < t.length - 1; ++e) if (n = (n.mapValue.fields || {})[t.get(e)],
|
|
1895
|
+
!jt(n)) return null;
|
|
1896
|
+
return n = (n.mapValue.fields || {})[t.lastSegment()], n || null;
|
|
1897
1897
|
}
|
|
1898
1898
|
}
|
|
1899
1899
|
/**
|
|
@@ -1901,25 +1901,25 @@ function Ct(t, e) {
|
|
|
1901
1901
|
*
|
|
1902
1902
|
* @param path - The field path to set.
|
|
1903
1903
|
* @param value - The value to set.
|
|
1904
|
-
*/ set(t,
|
|
1905
|
-
this.getFieldsMap(t.popLast())[t.lastSegment()] = Mt(
|
|
1904
|
+
*/ set(t, n) {
|
|
1905
|
+
this.getFieldsMap(t.popLast())[t.lastSegment()] = Mt(n);
|
|
1906
1906
|
}
|
|
1907
1907
|
/**
|
|
1908
1908
|
* Sets the provided fields to the provided values.
|
|
1909
1909
|
*
|
|
1910
1910
|
* @param data - A map of fields to values (or null for deletes).
|
|
1911
1911
|
*/ setAll(t) {
|
|
1912
|
-
let
|
|
1912
|
+
let n = tt.emptyPath(), e = {}, r = [];
|
|
1913
1913
|
t.forEach(((t, s) => {
|
|
1914
|
-
if (!
|
|
1914
|
+
if (!n.isImmediateParentOf(s)) {
|
|
1915
1915
|
// Insert the accumulated changes at this parent location
|
|
1916
|
-
const t = this.getFieldsMap(
|
|
1917
|
-
this.applyChanges(t,
|
|
1916
|
+
const t = this.getFieldsMap(n);
|
|
1917
|
+
this.applyChanges(t, e, r), e = {}, r = [], n = s.popLast();
|
|
1918
1918
|
}
|
|
1919
|
-
t ?
|
|
1919
|
+
t ? e[s.lastSegment()] = Mt(t) : r.push(s.lastSegment());
|
|
1920
1920
|
}));
|
|
1921
|
-
const s = this.getFieldsMap(
|
|
1922
|
-
this.applyChanges(s,
|
|
1921
|
+
const s = this.getFieldsMap(n);
|
|
1922
|
+
this.applyChanges(s, e, r);
|
|
1923
1923
|
}
|
|
1924
1924
|
/**
|
|
1925
1925
|
* Removes the field at the specified path. If there is no field at the
|
|
@@ -1927,36 +1927,36 @@ function Ct(t, e) {
|
|
|
1927
1927
|
*
|
|
1928
1928
|
* @param path - The field path to remove.
|
|
1929
1929
|
*/ delete(t) {
|
|
1930
|
-
const
|
|
1931
|
-
jt(
|
|
1930
|
+
const n = this.field(t.popLast());
|
|
1931
|
+
jt(n) && n.mapValue.fields && delete n.mapValue.fields[t.lastSegment()];
|
|
1932
1932
|
}
|
|
1933
1933
|
isEqual(t) {
|
|
1934
|
-
return
|
|
1934
|
+
return Ft(this.value, t.value);
|
|
1935
1935
|
}
|
|
1936
1936
|
/**
|
|
1937
1937
|
* Returns the map that contains the leaf element of `path`. If the parent
|
|
1938
1938
|
* entry does not yet exist, or if it is not a map, a new map will be created.
|
|
1939
1939
|
*/ getFieldsMap(t) {
|
|
1940
|
-
let
|
|
1941
|
-
|
|
1940
|
+
let n = this.value;
|
|
1941
|
+
n.mapValue.fields || (n.mapValue = {
|
|
1942
1942
|
fields: {}
|
|
1943
1943
|
});
|
|
1944
|
-
for (let
|
|
1945
|
-
let r =
|
|
1944
|
+
for (let e = 0; e < t.length; ++e) {
|
|
1945
|
+
let r = n.mapValue.fields[t.get(e)];
|
|
1946
1946
|
jt(r) && r.mapValue.fields || (r = {
|
|
1947
1947
|
mapValue: {
|
|
1948
1948
|
fields: {}
|
|
1949
1949
|
}
|
|
1950
|
-
},
|
|
1950
|
+
}, n.mapValue.fields[t.get(e)] = r), n = r;
|
|
1951
1951
|
}
|
|
1952
|
-
return
|
|
1952
|
+
return n.mapValue.fields;
|
|
1953
1953
|
}
|
|
1954
1954
|
/**
|
|
1955
1955
|
* Modifies `fieldsMap` by adding, replacing or deleting the specified
|
|
1956
1956
|
* entries.
|
|
1957
|
-
*/ applyChanges(t,
|
|
1958
|
-
Et(
|
|
1959
|
-
for (const
|
|
1957
|
+
*/ applyChanges(t, n, e) {
|
|
1958
|
+
Et(n, ((n, e) => t[n] = e));
|
|
1959
|
+
for (const n of e) delete t[n];
|
|
1960
1960
|
}
|
|
1961
1961
|
clone() {
|
|
1962
1962
|
return new Bt(Mt(this.value));
|
|
@@ -1989,8 +1989,8 @@ function Ct(t, e) {
|
|
|
1989
1989
|
* applied, `isValidDocument()` returns false and the document should be removed
|
|
1990
1990
|
* from all views.
|
|
1991
1991
|
*/ class zt {
|
|
1992
|
-
constructor(t,
|
|
1993
|
-
this.key = t, this.documentType =
|
|
1992
|
+
constructor(t, n, e, r, s) {
|
|
1993
|
+
this.key = t, this.documentType = n, this.version = e, this.data = r, this.documentState = s;
|
|
1994
1994
|
}
|
|
1995
1995
|
/**
|
|
1996
1996
|
* Creates a document with no known version or data, but which can serve as
|
|
@@ -2001,24 +2001,24 @@ function Ct(t, e) {
|
|
|
2001
2001
|
/**
|
|
2002
2002
|
* Creates a new document that is known to exist with the given data at the
|
|
2003
2003
|
* given version.
|
|
2004
|
-
*/ static newFoundDocument(t,
|
|
2005
|
-
return new zt(t, 1 /* FOUND_DOCUMENT */ ,
|
|
2004
|
+
*/ static newFoundDocument(t, n, e) {
|
|
2005
|
+
return new zt(t, 1 /* FOUND_DOCUMENT */ , n, e, 0 /* SYNCED */);
|
|
2006
2006
|
}
|
|
2007
|
-
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t,
|
|
2008
|
-
return new zt(t, 2 /* NO_DOCUMENT */ ,
|
|
2007
|
+
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t, n) {
|
|
2008
|
+
return new zt(t, 2 /* NO_DOCUMENT */ , n, Bt.empty(), 0 /* SYNCED */);
|
|
2009
2009
|
}
|
|
2010
2010
|
/**
|
|
2011
2011
|
* Creates a new document that is known to exist at the given version but
|
|
2012
2012
|
* whose data is not known (e.g. a document that was updated without a known
|
|
2013
2013
|
* base document).
|
|
2014
|
-
*/ static newUnknownDocument(t,
|
|
2015
|
-
return new zt(t, 3 /* UNKNOWN_DOCUMENT */ ,
|
|
2014
|
+
*/ static newUnknownDocument(t, n) {
|
|
2015
|
+
return new zt(t, 3 /* UNKNOWN_DOCUMENT */ , n, Bt.empty(), 2 /* HAS_COMMITTED_MUTATIONS */);
|
|
2016
2016
|
}
|
|
2017
2017
|
/**
|
|
2018
2018
|
* Changes the document type to indicate that it exists and that its version
|
|
2019
2019
|
* and data are known.
|
|
2020
|
-
*/ convertToFoundDocument(t,
|
|
2021
|
-
return this.version = t, this.documentType = 1 /* FOUND_DOCUMENT */ , this.data =
|
|
2020
|
+
*/ convertToFoundDocument(t, n) {
|
|
2021
|
+
return this.version = t, this.documentType = 1 /* FOUND_DOCUMENT */ , this.data = n,
|
|
2022
2022
|
this.documentState = 0 /* SYNCED */ , this;
|
|
2023
2023
|
}
|
|
2024
2024
|
/**
|
|
@@ -2092,9 +2092,9 @@ function Ct(t, e) {
|
|
|
2092
2092
|
*/
|
|
2093
2093
|
// Visible for testing
|
|
2094
2094
|
class Gt {
|
|
2095
|
-
constructor(t,
|
|
2096
|
-
this.path = t, this.collectionGroup =
|
|
2097
|
-
this.startAt = i, this.endAt = o, this.
|
|
2095
|
+
constructor(t, n = null, e = [], r = [], s = null, i = null, o = null) {
|
|
2096
|
+
this.path = t, this.collectionGroup = n, this.orderBy = e, this.filters = r, this.limit = s,
|
|
2097
|
+
this.startAt = i, this.endAt = o, this.P = null;
|
|
2098
2098
|
}
|
|
2099
2099
|
}
|
|
2100
2100
|
|
|
@@ -2105,26 +2105,26 @@ class Gt {
|
|
|
2105
2105
|
* NOTE: you should always construct `Target` from `Query.toTarget` instead of
|
|
2106
2106
|
* using this factory method, because `Query` provides an implicit `orderBy`
|
|
2107
2107
|
* property.
|
|
2108
|
-
*/ function Qt(t,
|
|
2109
|
-
return new Gt(t,
|
|
2108
|
+
*/ function Qt(t, n = null, e = [], r = [], s = null, i = null, o = null) {
|
|
2109
|
+
return new Gt(t, n, e, r, s, i, o);
|
|
2110
2110
|
}
|
|
2111
2111
|
|
|
2112
2112
|
class Wt extends class {} {
|
|
2113
|
-
constructor(t,
|
|
2114
|
-
super(), this.field = t, this.op =
|
|
2113
|
+
constructor(t, n, e) {
|
|
2114
|
+
super(), this.field = t, this.op = n, this.value = e;
|
|
2115
2115
|
}
|
|
2116
2116
|
/**
|
|
2117
2117
|
* Creates a filter based on the provided arguments.
|
|
2118
|
-
*/ static create(t,
|
|
2119
|
-
return t.isKeyField() ? "in" /* IN */ ===
|
|
2118
|
+
*/ static create(t, n, e) {
|
|
2119
|
+
return t.isKeyField() ? "in" /* IN */ === n || "not-in" /* NOT_IN */ === n ? this.V(t, n, e) : new Yt(t, n, e) : "array-contains" /* ARRAY_CONTAINS */ === n ? new Xt(t, e) : "in" /* IN */ === n ? new Zt(t, e) : "not-in" /* NOT_IN */ === n ? new tn(t, e) : "array-contains-any" /* ARRAY_CONTAINS_ANY */ === n ? new nn(t, e) : new Wt(t, n, e);
|
|
2120
2120
|
}
|
|
2121
|
-
static V(t,
|
|
2122
|
-
return "in" /* IN */ ===
|
|
2121
|
+
static V(t, n, e) {
|
|
2122
|
+
return "in" /* IN */ === n ? new Ht(t, e) : new Kt(t, e);
|
|
2123
2123
|
}
|
|
2124
2124
|
matches(t) {
|
|
2125
|
-
const
|
|
2125
|
+
const n = t.data.field(this.field);
|
|
2126
2126
|
// Types do not have to match in NOT_EQUAL filters.
|
|
2127
|
-
return "!=" /* NOT_EQUAL */ === this.op ? null !==
|
|
2127
|
+
return "!=" /* NOT_EQUAL */ === this.op ? null !== n && this.D(qt(n, this.value)) : null !== n && St(this.value) === St(n) && this.D(qt(n, this.value));
|
|
2128
2128
|
// Only compare types with matching backend order (such as double and int).
|
|
2129
2129
|
}
|
|
2130
2130
|
D(t) {
|
|
@@ -2158,78 +2158,78 @@ class Wt extends class {} {
|
|
|
2158
2158
|
|
|
2159
2159
|
/** Filter that matches on key fields (i.e. '__name__'). */
|
|
2160
2160
|
class Yt extends Wt {
|
|
2161
|
-
constructor(t,
|
|
2162
|
-
super(t,
|
|
2161
|
+
constructor(t, n, e) {
|
|
2162
|
+
super(t, n, e), this.key = nt.fromName(e.referenceValue);
|
|
2163
2163
|
}
|
|
2164
2164
|
matches(t) {
|
|
2165
|
-
const
|
|
2166
|
-
return this.D(
|
|
2165
|
+
const n = nt.comparator(t.key, this.key);
|
|
2166
|
+
return this.D(n);
|
|
2167
2167
|
}
|
|
2168
2168
|
}
|
|
2169
2169
|
|
|
2170
2170
|
/** Filter that matches on key fields within an array. */ class Ht extends Wt {
|
|
2171
|
-
constructor(t,
|
|
2172
|
-
super(t, "in" /* IN */ ,
|
|
2171
|
+
constructor(t, n) {
|
|
2172
|
+
super(t, "in" /* IN */ , n), this.keys = Jt("in" /* IN */ , n);
|
|
2173
2173
|
}
|
|
2174
2174
|
matches(t) {
|
|
2175
|
-
return this.keys.some((
|
|
2175
|
+
return this.keys.some((n => n.isEqual(t.key)));
|
|
2176
2176
|
}
|
|
2177
2177
|
}
|
|
2178
2178
|
|
|
2179
2179
|
/** Filter that matches on key fields not present within an array. */ class Kt extends Wt {
|
|
2180
|
-
constructor(t,
|
|
2181
|
-
super(t, "not-in" /* NOT_IN */ ,
|
|
2180
|
+
constructor(t, n) {
|
|
2181
|
+
super(t, "not-in" /* NOT_IN */ , n), this.keys = Jt("not-in" /* NOT_IN */ , n);
|
|
2182
2182
|
}
|
|
2183
2183
|
matches(t) {
|
|
2184
|
-
return !this.keys.some((
|
|
2184
|
+
return !this.keys.some((n => n.isEqual(t.key)));
|
|
2185
2185
|
}
|
|
2186
2186
|
}
|
|
2187
2187
|
|
|
2188
|
-
function Jt(t,
|
|
2189
|
-
var
|
|
2190
|
-
return ((null === (
|
|
2188
|
+
function Jt(t, n) {
|
|
2189
|
+
var e;
|
|
2190
|
+
return ((null === (e = n.arrayValue) || void 0 === e ? void 0 : e.values) || []).map((t => nt.fromName(t.referenceValue)));
|
|
2191
2191
|
}
|
|
2192
2192
|
|
|
2193
2193
|
/** A Filter that implements the array-contains operator. */ class Xt extends Wt {
|
|
2194
|
-
constructor(t,
|
|
2195
|
-
super(t, "array-contains" /* ARRAY_CONTAINS */ ,
|
|
2194
|
+
constructor(t, n) {
|
|
2195
|
+
super(t, "array-contains" /* ARRAY_CONTAINS */ , n);
|
|
2196
2196
|
}
|
|
2197
2197
|
matches(t) {
|
|
2198
|
-
const
|
|
2199
|
-
return Lt(
|
|
2198
|
+
const n = t.data.field(this.field);
|
|
2199
|
+
return Lt(n) && xt(n.arrayValue, this.value);
|
|
2200
2200
|
}
|
|
2201
2201
|
}
|
|
2202
2202
|
|
|
2203
2203
|
/** A Filter that implements the IN operator. */ class Zt extends Wt {
|
|
2204
|
-
constructor(t,
|
|
2205
|
-
super(t, "in" /* IN */ ,
|
|
2204
|
+
constructor(t, n) {
|
|
2205
|
+
super(t, "in" /* IN */ , n);
|
|
2206
2206
|
}
|
|
2207
2207
|
matches(t) {
|
|
2208
|
-
const
|
|
2209
|
-
return null !==
|
|
2208
|
+
const n = t.data.field(this.field);
|
|
2209
|
+
return null !== n && xt(this.value.arrayValue, n);
|
|
2210
2210
|
}
|
|
2211
2211
|
}
|
|
2212
2212
|
|
|
2213
|
-
/** A Filter that implements the not-in operator. */ class
|
|
2214
|
-
constructor(t,
|
|
2215
|
-
super(t, "not-in" /* NOT_IN */ ,
|
|
2213
|
+
/** A Filter that implements the not-in operator. */ class tn extends Wt {
|
|
2214
|
+
constructor(t, n) {
|
|
2215
|
+
super(t, "not-in" /* NOT_IN */ , n);
|
|
2216
2216
|
}
|
|
2217
2217
|
matches(t) {
|
|
2218
2218
|
if (xt(this.value.arrayValue, {
|
|
2219
2219
|
nullValue: "NULL_VALUE"
|
|
2220
2220
|
})) return !1;
|
|
2221
|
-
const
|
|
2222
|
-
return null !==
|
|
2221
|
+
const n = t.data.field(this.field);
|
|
2222
|
+
return null !== n && !xt(this.value.arrayValue, n);
|
|
2223
2223
|
}
|
|
2224
2224
|
}
|
|
2225
2225
|
|
|
2226
|
-
/** A Filter that implements the array-contains-any operator. */ class
|
|
2227
|
-
constructor(t,
|
|
2228
|
-
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ ,
|
|
2226
|
+
/** A Filter that implements the array-contains-any operator. */ class nn extends Wt {
|
|
2227
|
+
constructor(t, n) {
|
|
2228
|
+
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ , n);
|
|
2229
2229
|
}
|
|
2230
2230
|
matches(t) {
|
|
2231
|
-
const
|
|
2232
|
-
return !(!Lt(
|
|
2231
|
+
const n = t.data.field(this.field);
|
|
2232
|
+
return !(!Lt(n) || !n.arrayValue.values) && n.arrayValue.values.some((t => xt(this.value.arrayValue, t)));
|
|
2233
2233
|
}
|
|
2234
2234
|
}
|
|
2235
2235
|
|
|
@@ -2246,30 +2246,30 @@ function Jt(t, e) {
|
|
|
2246
2246
|
* Bound provides a function to determine whether a document comes before or
|
|
2247
2247
|
* after a bound. This is influenced by whether the position is just before or
|
|
2248
2248
|
* just after the provided values.
|
|
2249
|
-
*/ class
|
|
2250
|
-
constructor(t,
|
|
2251
|
-
this.position = t, this.before =
|
|
2249
|
+
*/ class en {
|
|
2250
|
+
constructor(t, n) {
|
|
2251
|
+
this.position = t, this.before = n;
|
|
2252
2252
|
}
|
|
2253
2253
|
}
|
|
2254
2254
|
|
|
2255
2255
|
/**
|
|
2256
2256
|
* An ordering on a field, in some Direction. Direction defaults to ASCENDING.
|
|
2257
|
-
*/ class
|
|
2258
|
-
constructor(t,
|
|
2259
|
-
this.field = t, this.dir =
|
|
2257
|
+
*/ class rn {
|
|
2258
|
+
constructor(t, n = "asc" /* ASCENDING */) {
|
|
2259
|
+
this.field = t, this.dir = n;
|
|
2260
2260
|
}
|
|
2261
2261
|
}
|
|
2262
2262
|
|
|
2263
|
-
function
|
|
2264
|
-
return t.dir ===
|
|
2263
|
+
function sn(t, n) {
|
|
2264
|
+
return t.dir === n.dir && t.field.isEqual(n.field);
|
|
2265
2265
|
}
|
|
2266
2266
|
|
|
2267
|
-
function
|
|
2268
|
-
if (null === t) return null ===
|
|
2269
|
-
if (null ===
|
|
2270
|
-
if (t.before !==
|
|
2271
|
-
for (let
|
|
2272
|
-
if (!
|
|
2267
|
+
function on(t, n) {
|
|
2268
|
+
if (null === t) return null === n;
|
|
2269
|
+
if (null === n) return !1;
|
|
2270
|
+
if (t.before !== n.before || t.position.length !== n.position.length) return !1;
|
|
2271
|
+
for (let e = 0; e < t.position.length; e++) {
|
|
2272
|
+
if (!Ft(t.position[e], n.position[e])) return !1;
|
|
2273
2273
|
}
|
|
2274
2274
|
return !0;
|
|
2275
2275
|
}
|
|
@@ -2296,29 +2296,29 @@ function ie(t, e) {
|
|
|
2296
2296
|
* query the RemoteStore results.
|
|
2297
2297
|
*
|
|
2298
2298
|
* Visible for testing.
|
|
2299
|
-
*/ class
|
|
2299
|
+
*/ class un {
|
|
2300
2300
|
/**
|
|
2301
2301
|
* Initializes a Query with a path and optional additional query constraints.
|
|
2302
2302
|
* Path must currently be empty if this is a collection group query.
|
|
2303
2303
|
*/
|
|
2304
|
-
constructor(t,
|
|
2305
|
-
this.path = t, this.collectionGroup =
|
|
2304
|
+
constructor(t, n = null, e = [], r = [], s = null, i = "F" /* First */ , o = null, u = null) {
|
|
2305
|
+
this.path = t, this.collectionGroup = n, this.explicitOrderBy = e, this.filters = r,
|
|
2306
2306
|
this.limit = s, this.limitType = i, this.startAt = o, this.endAt = u, this.$ = null,
|
|
2307
2307
|
// The corresponding `Target` of this `Query` instance.
|
|
2308
|
-
this.
|
|
2308
|
+
this.S = null, this.startAt, this.endAt;
|
|
2309
2309
|
}
|
|
2310
2310
|
}
|
|
2311
2311
|
|
|
2312
|
-
/** Creates a new Query for a query that matches all documents at `path` */ function
|
|
2312
|
+
/** Creates a new Query for a query that matches all documents at `path` */ function cn(t) {
|
|
2313
2313
|
return !ct(t.limit) && "L" /* Last */ === t.limitType;
|
|
2314
2314
|
}
|
|
2315
2315
|
|
|
2316
|
-
function
|
|
2316
|
+
function an(t) {
|
|
2317
2317
|
return t.explicitOrderBy.length > 0 ? t.explicitOrderBy[0].field : null;
|
|
2318
2318
|
}
|
|
2319
2319
|
|
|
2320
|
-
function
|
|
2321
|
-
for (const
|
|
2320
|
+
function hn(t) {
|
|
2321
|
+
for (const n of t.filters) if (n.N()) return n.field;
|
|
2322
2322
|
return null;
|
|
2323
2323
|
}
|
|
2324
2324
|
|
|
@@ -2330,7 +2330,7 @@ function ae(t) {
|
|
|
2330
2330
|
* Returns whether the query matches a collection group rather than a specific
|
|
2331
2331
|
* collection.
|
|
2332
2332
|
*/
|
|
2333
|
-
function
|
|
2333
|
+
function ln(t) {
|
|
2334
2334
|
return null !== t.collectionGroup;
|
|
2335
2335
|
}
|
|
2336
2336
|
|
|
@@ -2338,59 +2338,59 @@ function he(t) {
|
|
|
2338
2338
|
* Returns the implicit order by constraint that is used to execute the Query,
|
|
2339
2339
|
* which can be different from the order by constraints the user provided (e.g.
|
|
2340
2340
|
* the SDK and backend always orders by `__name__`).
|
|
2341
|
-
*/ function
|
|
2342
|
-
const
|
|
2343
|
-
if (null ===
|
|
2344
|
-
|
|
2345
|
-
const t =
|
|
2346
|
-
if (null !== t && null ===
|
|
2341
|
+
*/ function fn(t) {
|
|
2342
|
+
const n = b(t);
|
|
2343
|
+
if (null === n.$) {
|
|
2344
|
+
n.$ = [];
|
|
2345
|
+
const t = hn(n), e = an(n);
|
|
2346
|
+
if (null !== t && null === e)
|
|
2347
2347
|
// In order to implicitly add key ordering, we must also add the
|
|
2348
2348
|
// inequality filter field for it to be a valid query.
|
|
2349
2349
|
// Note that the default inequality field and key ordering is ascending.
|
|
2350
|
-
t.isKeyField() ||
|
|
2350
|
+
t.isKeyField() || n.$.push(new rn(t)), n.$.push(new rn(tt.keyField(), "asc" /* ASCENDING */)); else {
|
|
2351
2351
|
let t = !1;
|
|
2352
|
-
for (const
|
|
2352
|
+
for (const e of n.explicitOrderBy) n.$.push(e), e.field.isKeyField() && (t = !0);
|
|
2353
2353
|
if (!t) {
|
|
2354
2354
|
// The order of the implicit key ordering always matches the last
|
|
2355
2355
|
// explicit order by
|
|
2356
|
-
const t =
|
|
2357
|
-
|
|
2356
|
+
const t = n.explicitOrderBy.length > 0 ? n.explicitOrderBy[n.explicitOrderBy.length - 1].dir : "asc" /* ASCENDING */;
|
|
2357
|
+
n.$.push(new rn(tt.keyField(), t));
|
|
2358
2358
|
}
|
|
2359
2359
|
}
|
|
2360
2360
|
}
|
|
2361
|
-
return
|
|
2361
|
+
return n.$;
|
|
2362
2362
|
}
|
|
2363
2363
|
|
|
2364
2364
|
/**
|
|
2365
2365
|
* Converts this `Query` instance to it's corresponding `Target` representation.
|
|
2366
|
-
*/ function
|
|
2367
|
-
const
|
|
2368
|
-
if (!
|
|
2366
|
+
*/ function dn(t) {
|
|
2367
|
+
const n = b(t);
|
|
2368
|
+
if (!n.S) if ("F" /* First */ === n.limitType) n.S = Qt(n.path, n.collectionGroup, fn(n), n.filters, n.limit, n.startAt, n.endAt); else {
|
|
2369
2369
|
// Flip the orderBy directions since we want the last results
|
|
2370
2370
|
const t = [];
|
|
2371
|
-
for (const
|
|
2372
|
-
const
|
|
2373
|
-
t.push(new
|
|
2371
|
+
for (const e of fn(n)) {
|
|
2372
|
+
const n = "desc" /* DESCENDING */ === e.dir ? "asc" /* ASCENDING */ : "desc" /* DESCENDING */;
|
|
2373
|
+
t.push(new rn(e.field, n));
|
|
2374
2374
|
}
|
|
2375
2375
|
// We need to swap the cursors to match the now-flipped query ordering.
|
|
2376
|
-
const
|
|
2376
|
+
const e = n.endAt ? new en(n.endAt.position, !n.endAt.before) : null, r = n.startAt ? new en(n.startAt.position, !n.startAt.before) : null;
|
|
2377
2377
|
// Now return as a LimitType.First query.
|
|
2378
|
-
|
|
2378
|
+
n.S = Qt(n.path, n.collectionGroup, t, n.filters, n.limit, e, r);
|
|
2379
2379
|
}
|
|
2380
|
-
return
|
|
2380
|
+
return n.S;
|
|
2381
2381
|
}
|
|
2382
2382
|
|
|
2383
|
-
function
|
|
2384
|
-
return function(t,
|
|
2385
|
-
if (t.limit !==
|
|
2386
|
-
if (t.orderBy.length !==
|
|
2387
|
-
for (let
|
|
2388
|
-
if (t.filters.length !==
|
|
2389
|
-
for (let s = 0; s < t.filters.length; s++) if (
|
|
2390
|
-
|
|
2391
|
-
var
|
|
2392
|
-
return t.collectionGroup ===
|
|
2393
|
-
}(
|
|
2383
|
+
function wn(t, n) {
|
|
2384
|
+
return function(t, n) {
|
|
2385
|
+
if (t.limit !== n.limit) return !1;
|
|
2386
|
+
if (t.orderBy.length !== n.orderBy.length) return !1;
|
|
2387
|
+
for (let e = 0; e < t.orderBy.length; e++) if (!sn(t.orderBy[e], n.orderBy[e])) return !1;
|
|
2388
|
+
if (t.filters.length !== n.filters.length) return !1;
|
|
2389
|
+
for (let s = 0; s < t.filters.length; s++) if (e = t.filters[s], r = n.filters[s],
|
|
2390
|
+
e.op !== r.op || !e.field.isEqual(r.field) || !Ft(e.value, r.value)) return !1;
|
|
2391
|
+
var e, r;
|
|
2392
|
+
return t.collectionGroup === n.collectionGroup && !!t.path.isEqual(n.path) && !!on(t.startAt, n.startAt) && on(t.endAt, n.endAt);
|
|
2393
|
+
}(dn(t), dn(n)) && t.limitType === n.limitType;
|
|
2394
2394
|
}
|
|
2395
2395
|
|
|
2396
2396
|
/**
|
|
@@ -2418,10 +2418,10 @@ function de(t, e) {
|
|
|
2418
2418
|
* The return value is an IntegerValue if it can safely represent the value,
|
|
2419
2419
|
* otherwise a DoubleValue is returned.
|
|
2420
2420
|
*/
|
|
2421
|
-
function
|
|
2421
|
+
function mn(t, n) {
|
|
2422
2422
|
return function(t) {
|
|
2423
2423
|
return "number" == typeof t && Number.isInteger(t) && !at(t) && t <= Number.MAX_SAFE_INTEGER && t >= Number.MIN_SAFE_INTEGER;
|
|
2424
|
-
}(
|
|
2424
|
+
}(n) ?
|
|
2425
2425
|
/**
|
|
2426
2426
|
* Returns an IntegerValue for `value`.
|
|
2427
2427
|
*/
|
|
@@ -2429,22 +2429,22 @@ function we(t, e) {
|
|
|
2429
2429
|
return {
|
|
2430
2430
|
integerValue: "" + t
|
|
2431
2431
|
};
|
|
2432
|
-
}(
|
|
2433
|
-
if (t.
|
|
2434
|
-
if (isNaN(
|
|
2432
|
+
}(n) : function(t, n) {
|
|
2433
|
+
if (t.F) {
|
|
2434
|
+
if (isNaN(n)) return {
|
|
2435
2435
|
doubleValue: "NaN"
|
|
2436
2436
|
};
|
|
2437
|
-
if (
|
|
2437
|
+
if (n === 1 / 0) return {
|
|
2438
2438
|
doubleValue: "Infinity"
|
|
2439
2439
|
};
|
|
2440
|
-
if (
|
|
2440
|
+
if (n === -1 / 0) return {
|
|
2441
2441
|
doubleValue: "-Infinity"
|
|
2442
2442
|
};
|
|
2443
2443
|
}
|
|
2444
2444
|
return {
|
|
2445
|
-
doubleValue: at(
|
|
2445
|
+
doubleValue: at(n) ? "-0" : n
|
|
2446
2446
|
};
|
|
2447
|
-
}(t,
|
|
2447
|
+
}(t, n);
|
|
2448
2448
|
}
|
|
2449
2449
|
|
|
2450
2450
|
/**
|
|
@@ -2463,7 +2463,7 @@ function we(t, e) {
|
|
|
2463
2463
|
* See the License for the specific language governing permissions and
|
|
2464
2464
|
* limitations under the License.
|
|
2465
2465
|
*/
|
|
2466
|
-
/** Used to represent a field transform on a mutation. */ class
|
|
2466
|
+
/** Used to represent a field transform on a mutation. */ class pn {
|
|
2467
2467
|
constructor() {
|
|
2468
2468
|
// Make sure that the structural type of `TransformOperation` is unique.
|
|
2469
2469
|
// See https://github.com/microsoft/TypeScript/issues/5451
|
|
@@ -2471,15 +2471,15 @@ function we(t, e) {
|
|
|
2471
2471
|
}
|
|
2472
2472
|
}
|
|
2473
2473
|
|
|
2474
|
-
/** Transforms a value into a server-generated timestamp. */ class
|
|
2474
|
+
/** Transforms a value into a server-generated timestamp. */ class yn extends pn {}
|
|
2475
2475
|
|
|
2476
|
-
/** Transforms an array value via a union operation. */ class
|
|
2476
|
+
/** Transforms an array value via a union operation. */ class _n extends pn {
|
|
2477
2477
|
constructor(t) {
|
|
2478
2478
|
super(), this.elements = t;
|
|
2479
2479
|
}
|
|
2480
2480
|
}
|
|
2481
2481
|
|
|
2482
|
-
/** Transforms an array value via a remove operation. */ class
|
|
2482
|
+
/** Transforms an array value via a remove operation. */ class gn extends pn {
|
|
2483
2483
|
constructor(t) {
|
|
2484
2484
|
super(), this.elements = t;
|
|
2485
2485
|
}
|
|
@@ -2490,9 +2490,9 @@ function we(t, e) {
|
|
|
2490
2490
|
* transforms. Converts all field values to integers or doubles, but unlike the
|
|
2491
2491
|
* backend does not cap integer values at 2^63. Instead, JavaScript number
|
|
2492
2492
|
* arithmetic is used and precision loss can occur for values greater than 2^53.
|
|
2493
|
-
*/ class
|
|
2494
|
-
constructor(t,
|
|
2495
|
-
super(), this.q = t, this.O =
|
|
2493
|
+
*/ class vn extends pn {
|
|
2494
|
+
constructor(t, n) {
|
|
2495
|
+
super(), this.q = t, this.O = n;
|
|
2496
2496
|
}
|
|
2497
2497
|
}
|
|
2498
2498
|
|
|
@@ -2512,9 +2512,9 @@ function we(t, e) {
|
|
|
2512
2512
|
* See the License for the specific language governing permissions and
|
|
2513
2513
|
* limitations under the License.
|
|
2514
2514
|
*/
|
|
2515
|
-
/** A field path and the TransformOperation to perform upon it. */ class
|
|
2516
|
-
constructor(t,
|
|
2517
|
-
this.field = t, this.transform =
|
|
2515
|
+
/** A field path and the TransformOperation to perform upon it. */ class bn {
|
|
2516
|
+
constructor(t, n) {
|
|
2517
|
+
this.field = t, this.transform = n;
|
|
2518
2518
|
}
|
|
2519
2519
|
}
|
|
2520
2520
|
|
|
@@ -2522,18 +2522,18 @@ function we(t, e) {
|
|
|
2522
2522
|
* Encodes a precondition for a mutation. This follows the model that the
|
|
2523
2523
|
* backend accepts with the special case of an explicit "empty" precondition
|
|
2524
2524
|
* (meaning no precondition).
|
|
2525
|
-
*/ class
|
|
2526
|
-
constructor(t,
|
|
2527
|
-
this.updateTime = t, this.exists =
|
|
2525
|
+
*/ class En {
|
|
2526
|
+
constructor(t, n) {
|
|
2527
|
+
this.updateTime = t, this.exists = n;
|
|
2528
2528
|
}
|
|
2529
2529
|
/** Creates a new empty Precondition. */ static none() {
|
|
2530
|
-
return new
|
|
2530
|
+
return new En;
|
|
2531
2531
|
}
|
|
2532
2532
|
/** Creates a new Precondition with an exists flag. */ static exists(t) {
|
|
2533
|
-
return new
|
|
2533
|
+
return new En(void 0, t);
|
|
2534
2534
|
}
|
|
2535
2535
|
/** Creates a new Precondition based on a version a document exists at. */ static updateTime(t) {
|
|
2536
|
-
return new
|
|
2536
|
+
return new En(t);
|
|
2537
2537
|
}
|
|
2538
2538
|
/** Returns whether this Precondition is empty. */ get isNone() {
|
|
2539
2539
|
return void 0 === this.updateTime && void 0 === this.exists;
|
|
@@ -2586,14 +2586,14 @@ function we(t, e) {
|
|
|
2586
2586
|
* applyToLocalView() to implement the actual behavior of applying the mutation
|
|
2587
2587
|
* to some source document (see `setMutationApplyToRemoteDocument()` for an
|
|
2588
2588
|
* example).
|
|
2589
|
-
*/ class
|
|
2589
|
+
*/ class Tn {}
|
|
2590
2590
|
|
|
2591
2591
|
/**
|
|
2592
2592
|
* A mutation that creates or replaces the document at the given key with the
|
|
2593
2593
|
* object value contents.
|
|
2594
|
-
*/ class
|
|
2595
|
-
constructor(t,
|
|
2596
|
-
super(), this.key = t, this.value =
|
|
2594
|
+
*/ class In extends Tn {
|
|
2595
|
+
constructor(t, n, e, r = []) {
|
|
2596
|
+
super(), this.key = t, this.value = n, this.precondition = e, this.fieldTransforms = r,
|
|
2597
2597
|
this.type = 0 /* Set */;
|
|
2598
2598
|
}
|
|
2599
2599
|
}
|
|
@@ -2610,16 +2610,16 @@ function we(t, e) {
|
|
|
2610
2610
|
* is deleted.
|
|
2611
2611
|
* * When a field is not in the mask but is in the values, the values map is
|
|
2612
2612
|
* ignored.
|
|
2613
|
-
*/ class
|
|
2614
|
-
constructor(t,
|
|
2615
|
-
super(), this.key = t, this.data =
|
|
2613
|
+
*/ class An extends Tn {
|
|
2614
|
+
constructor(t, n, e, r, s = []) {
|
|
2615
|
+
super(), this.key = t, this.data = n, this.fieldMask = e, this.precondition = r,
|
|
2616
2616
|
this.fieldTransforms = s, this.type = 1 /* Patch */;
|
|
2617
2617
|
}
|
|
2618
2618
|
}
|
|
2619
2619
|
|
|
2620
|
-
/** A mutation that deletes the document at the given key. */ class
|
|
2621
|
-
constructor(t,
|
|
2622
|
-
super(), this.key = t, this.precondition =
|
|
2620
|
+
/** A mutation that deletes the document at the given key. */ class Rn extends Tn {
|
|
2621
|
+
constructor(t, n) {
|
|
2622
|
+
super(), this.key = t, this.precondition = n, this.type = 2 /* Delete */ , this.fieldTransforms = [];
|
|
2623
2623
|
}
|
|
2624
2624
|
}
|
|
2625
2625
|
|
|
@@ -2629,9 +2629,9 @@ function we(t, e) {
|
|
|
2629
2629
|
*
|
|
2630
2630
|
* The `verify` operation is only used in Transactions, and this class serves
|
|
2631
2631
|
* primarily to facilitate serialization into protos.
|
|
2632
|
-
*/ class
|
|
2633
|
-
constructor(t,
|
|
2634
|
-
super(), this.key = t, this.precondition =
|
|
2632
|
+
*/ class Pn extends Tn {
|
|
2633
|
+
constructor(t, n) {
|
|
2634
|
+
super(), this.key = t, this.precondition = n, this.type = 3 /* Verify */ , this.fieldTransforms = [];
|
|
2635
2635
|
}
|
|
2636
2636
|
}
|
|
2637
2637
|
|
|
@@ -2650,13 +2650,13 @@ function we(t, e) {
|
|
|
2650
2650
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2651
2651
|
* See the License for the specific language governing permissions and
|
|
2652
2652
|
* limitations under the License.
|
|
2653
|
-
*/ const
|
|
2653
|
+
*/ const Vn = (() => {
|
|
2654
2654
|
const t = {
|
|
2655
2655
|
asc: "ASCENDING",
|
|
2656
2656
|
desc: "DESCENDING"
|
|
2657
2657
|
};
|
|
2658
2658
|
return t;
|
|
2659
|
-
})(),
|
|
2659
|
+
})(), Dn = (() => {
|
|
2660
2660
|
const t = {
|
|
2661
2661
|
"<": "LESS_THAN",
|
|
2662
2662
|
"<=": "LESS_THAN_OR_EQUAL",
|
|
@@ -2686,9 +2686,9 @@ function we(t, e) {
|
|
|
2686
2686
|
* TODO(klimt): We can remove the databaseId argument if we keep the full
|
|
2687
2687
|
* resource name in documents.
|
|
2688
2688
|
*/
|
|
2689
|
-
class
|
|
2690
|
-
constructor(t,
|
|
2691
|
-
this.databaseId = t, this.
|
|
2689
|
+
class Nn {
|
|
2690
|
+
constructor(t, n) {
|
|
2691
|
+
this.databaseId = t, this.F = n;
|
|
2692
2692
|
}
|
|
2693
2693
|
}
|
|
2694
2694
|
|
|
@@ -2703,13 +2703,13 @@ class De {
|
|
|
2703
2703
|
/**
|
|
2704
2704
|
* Returns a value for a Date that's appropriate to put into a proto.
|
|
2705
2705
|
*/
|
|
2706
|
-
function
|
|
2707
|
-
if (t.
|
|
2708
|
-
return `${new Date(1e3 *
|
|
2706
|
+
function $n(t, n) {
|
|
2707
|
+
if (t.F) {
|
|
2708
|
+
return `${new Date(1e3 * n.seconds).toISOString().replace(/\.\d*/, "").replace("Z", "")}.${("000000000" + n.nanoseconds).slice(-9)}Z`;
|
|
2709
2709
|
}
|
|
2710
2710
|
return {
|
|
2711
|
-
seconds: "" +
|
|
2712
|
-
nanos:
|
|
2711
|
+
seconds: "" + n.seconds,
|
|
2712
|
+
nanos: n.nanoseconds
|
|
2713
2713
|
};
|
|
2714
2714
|
}
|
|
2715
2715
|
|
|
@@ -2718,202 +2718,202 @@ function Ne(t, e) {
|
|
|
2718
2718
|
*
|
|
2719
2719
|
* Visible for testing.
|
|
2720
2720
|
*/
|
|
2721
|
-
function
|
|
2722
|
-
return t.
|
|
2721
|
+
function Sn(t, n) {
|
|
2722
|
+
return t.F ? n.toBase64() : n.toUint8Array();
|
|
2723
2723
|
}
|
|
2724
2724
|
|
|
2725
|
-
function
|
|
2726
|
-
return
|
|
2725
|
+
function Fn(t, n) {
|
|
2726
|
+
return $n(t, n.toTimestamp());
|
|
2727
2727
|
}
|
|
2728
2728
|
|
|
2729
|
-
function
|
|
2729
|
+
function xn(t) {
|
|
2730
2730
|
return v(!!t), vt.fromTimestamp(function(t) {
|
|
2731
|
-
const
|
|
2732
|
-
return new gt(
|
|
2731
|
+
const n = Rt(t);
|
|
2732
|
+
return new gt(n.seconds, n.nanos);
|
|
2733
2733
|
}(t));
|
|
2734
2734
|
}
|
|
2735
2735
|
|
|
2736
|
-
function
|
|
2736
|
+
function qn(t, n) {
|
|
2737
2737
|
return function(t) {
|
|
2738
2738
|
return new X([ "projects", t.projectId, "databases", t.database ]);
|
|
2739
|
-
}(t).child("documents").child(
|
|
2739
|
+
}(t).child("documents").child(n).canonicalString();
|
|
2740
2740
|
}
|
|
2741
2741
|
|
|
2742
|
-
function
|
|
2743
|
-
return
|
|
2742
|
+
function On(t, n) {
|
|
2743
|
+
return qn(t.databaseId, n.path);
|
|
2744
2744
|
}
|
|
2745
2745
|
|
|
2746
|
-
function
|
|
2747
|
-
const
|
|
2748
|
-
const
|
|
2749
|
-
return v(
|
|
2750
|
-
}(
|
|
2751
|
-
if (
|
|
2752
|
-
if (
|
|
2753
|
-
return new
|
|
2746
|
+
function Cn(t, n) {
|
|
2747
|
+
const e = function(t) {
|
|
2748
|
+
const n = X.fromString(t);
|
|
2749
|
+
return v(Hn(n)), n;
|
|
2750
|
+
}(n);
|
|
2751
|
+
if (e.get(1) !== t.databaseId.projectId) throw new U(A, "Tried to deserialize key from different project: " + e.get(1) + " vs " + t.databaseId.projectId);
|
|
2752
|
+
if (e.get(3) !== t.databaseId.database) throw new U(A, "Tried to deserialize key from different database: " + e.get(3) + " vs " + t.databaseId.database);
|
|
2753
|
+
return new nt((v((r = e).length > 4 && "documents" === r.get(4)), r.popFirst(5)));
|
|
2754
2754
|
var r;
|
|
2755
2755
|
/** Creates a Document proto from key and fields (but no create/update time) */}
|
|
2756
2756
|
|
|
2757
|
-
function
|
|
2758
|
-
return
|
|
2757
|
+
function Ln(t, n) {
|
|
2758
|
+
return qn(t.databaseId, n);
|
|
2759
2759
|
}
|
|
2760
2760
|
|
|
2761
|
-
function
|
|
2761
|
+
function Un(t) {
|
|
2762
2762
|
return new X([ "projects", t.databaseId.projectId, "databases", t.databaseId.database ]).canonicalString();
|
|
2763
2763
|
}
|
|
2764
2764
|
|
|
2765
|
-
function
|
|
2765
|
+
function kn(t, n, e) {
|
|
2766
2766
|
return {
|
|
2767
|
-
name:
|
|
2768
|
-
fields:
|
|
2767
|
+
name: On(t, n),
|
|
2768
|
+
fields: e.value.mapValue.fields
|
|
2769
2769
|
};
|
|
2770
2770
|
}
|
|
2771
2771
|
|
|
2772
|
-
function
|
|
2773
|
-
return "found" in
|
|
2774
|
-
v(!!
|
|
2775
|
-
const
|
|
2772
|
+
function jn(t, n) {
|
|
2773
|
+
return "found" in n ? function(t, n) {
|
|
2774
|
+
v(!!n.found), n.found.name, n.found.updateTime;
|
|
2775
|
+
const e = Cn(t, n.found.name), r = xn(n.found.updateTime), s = new Bt({
|
|
2776
2776
|
mapValue: {
|
|
2777
|
-
fields:
|
|
2777
|
+
fields: n.found.fields
|
|
2778
2778
|
}
|
|
2779
2779
|
});
|
|
2780
|
-
return zt.newFoundDocument(
|
|
2781
|
-
}(t,
|
|
2782
|
-
v(!!
|
|
2783
|
-
const
|
|
2784
|
-
return zt.newNoDocument(
|
|
2785
|
-
}(t,
|
|
2786
|
-
}
|
|
2787
|
-
|
|
2788
|
-
function
|
|
2789
|
-
let
|
|
2790
|
-
if (
|
|
2791
|
-
update:
|
|
2792
|
-
}; else if (
|
|
2793
|
-
delete:
|
|
2794
|
-
}; else if (
|
|
2795
|
-
update:
|
|
2796
|
-
updateMask:
|
|
2780
|
+
return zt.newFoundDocument(e, r, s);
|
|
2781
|
+
}(t, n) : "missing" in n ? function(t, n) {
|
|
2782
|
+
v(!!n.missing), v(!!n.readTime);
|
|
2783
|
+
const e = Cn(t, n.missing), r = xn(n.readTime);
|
|
2784
|
+
return zt.newNoDocument(e, r);
|
|
2785
|
+
}(t, n) : g();
|
|
2786
|
+
}
|
|
2787
|
+
|
|
2788
|
+
function Mn(t, n) {
|
|
2789
|
+
let e;
|
|
2790
|
+
if (n instanceof In) e = {
|
|
2791
|
+
update: kn(t, n.key, n.value)
|
|
2792
|
+
}; else if (n instanceof Rn) e = {
|
|
2793
|
+
delete: On(t, n.key)
|
|
2794
|
+
}; else if (n instanceof An) e = {
|
|
2795
|
+
update: kn(t, n.key, n.data),
|
|
2796
|
+
updateMask: Yn(n.fieldMask)
|
|
2797
2797
|
}; else {
|
|
2798
|
-
if (!(
|
|
2799
|
-
|
|
2800
|
-
verify:
|
|
2798
|
+
if (!(n instanceof Pn)) return g();
|
|
2799
|
+
e = {
|
|
2800
|
+
verify: On(t, n.key)
|
|
2801
2801
|
};
|
|
2802
2802
|
}
|
|
2803
|
-
return
|
|
2804
|
-
const
|
|
2805
|
-
if (
|
|
2806
|
-
fieldPath:
|
|
2803
|
+
return n.fieldTransforms.length > 0 && (e.updateTransforms = n.fieldTransforms.map((t => function(t, n) {
|
|
2804
|
+
const e = n.transform;
|
|
2805
|
+
if (e instanceof yn) return {
|
|
2806
|
+
fieldPath: n.field.canonicalString(),
|
|
2807
2807
|
setToServerValue: "REQUEST_TIME"
|
|
2808
2808
|
};
|
|
2809
|
-
if (
|
|
2810
|
-
fieldPath:
|
|
2809
|
+
if (e instanceof _n) return {
|
|
2810
|
+
fieldPath: n.field.canonicalString(),
|
|
2811
2811
|
appendMissingElements: {
|
|
2812
|
-
values:
|
|
2812
|
+
values: e.elements
|
|
2813
2813
|
}
|
|
2814
2814
|
};
|
|
2815
|
-
if (
|
|
2816
|
-
fieldPath:
|
|
2815
|
+
if (e instanceof gn) return {
|
|
2816
|
+
fieldPath: n.field.canonicalString(),
|
|
2817
2817
|
removeAllFromArray: {
|
|
2818
|
-
values:
|
|
2818
|
+
values: e.elements
|
|
2819
2819
|
}
|
|
2820
2820
|
};
|
|
2821
|
-
if (
|
|
2822
|
-
fieldPath:
|
|
2823
|
-
increment:
|
|
2821
|
+
if (e instanceof vn) return {
|
|
2822
|
+
fieldPath: n.field.canonicalString(),
|
|
2823
|
+
increment: e.O
|
|
2824
2824
|
};
|
|
2825
2825
|
throw g();
|
|
2826
|
-
}(0, t)))),
|
|
2827
|
-
return void 0 !==
|
|
2828
|
-
updateTime:
|
|
2829
|
-
} : void 0 !==
|
|
2830
|
-
exists:
|
|
2826
|
+
}(0, t)))), n.precondition.isNone || (e.currentDocument = function(t, n) {
|
|
2827
|
+
return void 0 !== n.updateTime ? {
|
|
2828
|
+
updateTime: Fn(t, n.updateTime)
|
|
2829
|
+
} : void 0 !== n.exists ? {
|
|
2830
|
+
exists: n.exists
|
|
2831
2831
|
} : g();
|
|
2832
|
-
}(t,
|
|
2832
|
+
}(t, n.precondition)), e;
|
|
2833
2833
|
}
|
|
2834
2834
|
|
|
2835
|
-
function
|
|
2835
|
+
function Bn(t, n) {
|
|
2836
2836
|
// Dissect the path into parent, collectionId, and optional key filter.
|
|
2837
|
-
const
|
|
2837
|
+
const e = {
|
|
2838
2838
|
structuredQuery: {}
|
|
2839
|
-
}, r =
|
|
2840
|
-
null !==
|
|
2841
|
-
collectionId:
|
|
2839
|
+
}, r = n.path;
|
|
2840
|
+
null !== n.collectionGroup ? (e.parent = Ln(t, r), e.structuredQuery.from = [ {
|
|
2841
|
+
collectionId: n.collectionGroup,
|
|
2842
2842
|
allDescendants: !0
|
|
2843
|
-
} ]) : (
|
|
2843
|
+
} ]) : (e.parent = Ln(t, r.popLast()), e.structuredQuery.from = [ {
|
|
2844
2844
|
collectionId: r.lastSegment()
|
|
2845
2845
|
} ]);
|
|
2846
2846
|
const s = function(t) {
|
|
2847
2847
|
if (0 === t.length) return;
|
|
2848
|
-
const
|
|
2848
|
+
const n = t.map((t =>
|
|
2849
2849
|
// visible for testing
|
|
2850
2850
|
function(t) {
|
|
2851
2851
|
if ("==" /* EQUAL */ === t.op) {
|
|
2852
2852
|
if (kt(t.value)) return {
|
|
2853
2853
|
unaryFilter: {
|
|
2854
|
-
field:
|
|
2854
|
+
field: Wn(t.field),
|
|
2855
2855
|
op: "IS_NAN"
|
|
2856
2856
|
}
|
|
2857
2857
|
};
|
|
2858
2858
|
if (Ut(t.value)) return {
|
|
2859
2859
|
unaryFilter: {
|
|
2860
|
-
field:
|
|
2860
|
+
field: Wn(t.field),
|
|
2861
2861
|
op: "IS_NULL"
|
|
2862
2862
|
}
|
|
2863
2863
|
};
|
|
2864
2864
|
} else if ("!=" /* NOT_EQUAL */ === t.op) {
|
|
2865
2865
|
if (kt(t.value)) return {
|
|
2866
2866
|
unaryFilter: {
|
|
2867
|
-
field:
|
|
2867
|
+
field: Wn(t.field),
|
|
2868
2868
|
op: "IS_NOT_NAN"
|
|
2869
2869
|
}
|
|
2870
2870
|
};
|
|
2871
2871
|
if (Ut(t.value)) return {
|
|
2872
2872
|
unaryFilter: {
|
|
2873
|
-
field:
|
|
2873
|
+
field: Wn(t.field),
|
|
2874
2874
|
op: "IS_NOT_NULL"
|
|
2875
2875
|
}
|
|
2876
2876
|
};
|
|
2877
2877
|
}
|
|
2878
2878
|
return {
|
|
2879
2879
|
fieldFilter: {
|
|
2880
|
-
field:
|
|
2881
|
-
op:
|
|
2880
|
+
field: Wn(t.field),
|
|
2881
|
+
op: Qn(t.op),
|
|
2882
2882
|
value: t.value
|
|
2883
2883
|
}
|
|
2884
2884
|
};
|
|
2885
2885
|
}(t)));
|
|
2886
|
-
if (1 ===
|
|
2886
|
+
if (1 === n.length) return n[0];
|
|
2887
2887
|
return {
|
|
2888
2888
|
compositeFilter: {
|
|
2889
2889
|
op: "AND",
|
|
2890
|
-
filters:
|
|
2890
|
+
filters: n
|
|
2891
2891
|
}
|
|
2892
2892
|
};
|
|
2893
|
-
}(
|
|
2894
|
-
s && (
|
|
2893
|
+
}(n.filters);
|
|
2894
|
+
s && (e.structuredQuery.where = s);
|
|
2895
2895
|
const i = function(t) {
|
|
2896
2896
|
if (0 === t.length) return;
|
|
2897
2897
|
return t.map((t =>
|
|
2898
2898
|
// visible for testing
|
|
2899
2899
|
function(t) {
|
|
2900
2900
|
return {
|
|
2901
|
-
field:
|
|
2902
|
-
direction:
|
|
2901
|
+
field: Wn(t.field),
|
|
2902
|
+
direction: Gn(t.dir)
|
|
2903
2903
|
};
|
|
2904
2904
|
}(t)));
|
|
2905
|
-
}(
|
|
2906
|
-
i && (
|
|
2907
|
-
const o = function(t,
|
|
2908
|
-
return t.
|
|
2909
|
-
value:
|
|
2905
|
+
}(n.orderBy);
|
|
2906
|
+
i && (e.structuredQuery.orderBy = i);
|
|
2907
|
+
const o = function(t, n) {
|
|
2908
|
+
return t.F || ct(n) ? n : {
|
|
2909
|
+
value: n
|
|
2910
2910
|
};
|
|
2911
|
-
}(t,
|
|
2912
|
-
return null !== o && (
|
|
2913
|
-
|
|
2911
|
+
}(t, n.limit);
|
|
2912
|
+
return null !== o && (e.structuredQuery.limit = o), n.startAt && (e.structuredQuery.startAt = zn(n.startAt)),
|
|
2913
|
+
n.endAt && (e.structuredQuery.endAt = zn(n.endAt)), e;
|
|
2914
2914
|
}
|
|
2915
2915
|
|
|
2916
|
-
function
|
|
2916
|
+
function zn(t) {
|
|
2917
2917
|
return {
|
|
2918
2918
|
before: t.before,
|
|
2919
2919
|
values: t.position
|
|
@@ -2921,29 +2921,29 @@ function Be(t) {
|
|
|
2921
2921
|
}
|
|
2922
2922
|
|
|
2923
2923
|
// visible for testing
|
|
2924
|
-
function
|
|
2925
|
-
return
|
|
2924
|
+
function Gn(t) {
|
|
2925
|
+
return Vn[t];
|
|
2926
2926
|
}
|
|
2927
2927
|
|
|
2928
2928
|
// visible for testing
|
|
2929
|
-
function
|
|
2930
|
-
return
|
|
2929
|
+
function Qn(t) {
|
|
2930
|
+
return Dn[t];
|
|
2931
2931
|
}
|
|
2932
2932
|
|
|
2933
|
-
function
|
|
2933
|
+
function Wn(t) {
|
|
2934
2934
|
return {
|
|
2935
2935
|
fieldPath: t.canonicalString()
|
|
2936
2936
|
};
|
|
2937
2937
|
}
|
|
2938
2938
|
|
|
2939
|
-
function
|
|
2940
|
-
const
|
|
2941
|
-
return t.fields.forEach((t =>
|
|
2942
|
-
fieldPaths:
|
|
2939
|
+
function Yn(t) {
|
|
2940
|
+
const n = [];
|
|
2941
|
+
return t.fields.forEach((t => n.push(t.canonicalString()))), {
|
|
2942
|
+
fieldPaths: n
|
|
2943
2943
|
};
|
|
2944
2944
|
}
|
|
2945
2945
|
|
|
2946
|
-
function
|
|
2946
|
+
function Hn(t) {
|
|
2947
2947
|
// Resource names have at least 4 components (project ID, database ID)
|
|
2948
2948
|
return t.length >= 4 && "projects" === t.get(0) && "databases" === t.get(2);
|
|
2949
2949
|
}
|
|
@@ -2963,8 +2963,8 @@ function Ye(t) {
|
|
|
2963
2963
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2964
2964
|
* See the License for the specific language governing permissions and
|
|
2965
2965
|
* limitations under the License.
|
|
2966
|
-
*/ function
|
|
2967
|
-
return new
|
|
2966
|
+
*/ function Kn(t) {
|
|
2967
|
+
return new Nn(t, /* useProto3Json= */ !0);
|
|
2968
2968
|
}
|
|
2969
2969
|
|
|
2970
2970
|
/**
|
|
@@ -2992,7 +2992,7 @@ function Ye(t) {
|
|
|
2992
2992
|
* base delay. This prevents clients from accidentally synchronizing their
|
|
2993
2993
|
* delays causing spikes of load to the backend.
|
|
2994
2994
|
*/
|
|
2995
|
-
class
|
|
2995
|
+
class Jn {
|
|
2996
2996
|
constructor(
|
|
2997
2997
|
/**
|
|
2998
2998
|
* The AsyncQueue to run backoff operations on.
|
|
@@ -3001,13 +3001,13 @@ class Ke {
|
|
|
3001
3001
|
/**
|
|
3002
3002
|
* The ID to use when scheduling backoff operations on the AsyncQueue.
|
|
3003
3003
|
*/
|
|
3004
|
-
|
|
3004
|
+
n,
|
|
3005
3005
|
/**
|
|
3006
3006
|
* The initial delay (used as the base delay on the first retry attempt).
|
|
3007
3007
|
* Note that jitter will still be applied, so the actual delay could be as
|
|
3008
3008
|
* little as 0.5*initialDelayMs.
|
|
3009
3009
|
*/
|
|
3010
|
-
|
|
3010
|
+
e = 1e3
|
|
3011
3011
|
/**
|
|
3012
3012
|
* The multiplier to use to determine the extended base delay after each
|
|
3013
3013
|
* attempt.
|
|
@@ -3017,7 +3017,7 @@ class Ke {
|
|
|
3017
3017
|
* Note that jitter will still be applied, so the actual delay could be as
|
|
3018
3018
|
* much as 1.5*maxDelayMs.
|
|
3019
3019
|
*/ , s = 6e4) {
|
|
3020
|
-
this.C = t, this.timerId =
|
|
3020
|
+
this.C = t, this.timerId = n, this.L = e, this.U = r, this.k = s, this.j = 0, this.M = null,
|
|
3021
3021
|
/** The last backoff attempt, as epoch milliseconds. */
|
|
3022
3022
|
this.B = Date.now(), this.reset();
|
|
3023
3023
|
}
|
|
@@ -3045,9 +3045,9 @@ class Ke {
|
|
|
3045
3045
|
this.cancel();
|
|
3046
3046
|
// First schedule using the current base (which may be 0 and should be
|
|
3047
3047
|
// honored as such).
|
|
3048
|
-
const
|
|
3048
|
+
const n = Math.floor(this.j + this.Y()), e = Math.max(0, Date.now() - this.B), r = Math.max(0, n - e);
|
|
3049
3049
|
// Guard against lastAttemptTime being in the future due to a clock change.
|
|
3050
|
-
r > 0 && m("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.j} ms, delay with jitter: ${
|
|
3050
|
+
r > 0 && m("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.j} ms, delay with jitter: ${n} ms, last attempt: ${e} ms ago)`),
|
|
3051
3051
|
this.M = this.C.enqueueAfterDelay(this.timerId, r, (() => (this.B = Date.now(),
|
|
3052
3052
|
t()))),
|
|
3053
3053
|
// Apply backoff factor to determine next delay and ensure it is within
|
|
@@ -3090,22 +3090,22 @@ class Ke {
|
|
|
3090
3090
|
* An implementation of Datastore that exposes additional state for internal
|
|
3091
3091
|
* consumption.
|
|
3092
3092
|
*/
|
|
3093
|
-
class
|
|
3094
|
-
constructor(t,
|
|
3095
|
-
super(), this.authCredentials = t, this.appCheckCredentials =
|
|
3093
|
+
class Xn extends class {} {
|
|
3094
|
+
constructor(t, n, e, r) {
|
|
3095
|
+
super(), this.authCredentials = t, this.appCheckCredentials = n, this.K = e, this.q = r,
|
|
3096
3096
|
this.J = !1;
|
|
3097
3097
|
}
|
|
3098
3098
|
X() {
|
|
3099
|
-
if (this.J) throw new U(
|
|
3099
|
+
if (this.J) throw new U(S, "The client has already been terminated.");
|
|
3100
3100
|
}
|
|
3101
|
-
/** Invokes the provided RPC with auth and AppCheck tokens. */ m(t,
|
|
3102
|
-
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.m(t,
|
|
3101
|
+
/** Invokes the provided RPC with auth and AppCheck tokens. */ m(t, n, e) {
|
|
3102
|
+
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.m(t, n, e, r, s))).catch((t => {
|
|
3103
3103
|
throw "FirebaseError" === t.name ? (t.code === N && (this.authCredentials.invalidateToken(),
|
|
3104
3104
|
this.appCheckCredentials.invalidateToken()), t) : new U(I, t.toString());
|
|
3105
3105
|
}));
|
|
3106
3106
|
}
|
|
3107
|
-
/** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */ T(t,
|
|
3108
|
-
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.T(t,
|
|
3107
|
+
/** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */ T(t, n, e) {
|
|
3108
|
+
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.T(t, n, e, r, s))).catch((t => {
|
|
3109
3109
|
throw "FirebaseError" === t.name ? (t.code === N && (this.authCredentials.invalidateToken(),
|
|
3110
3110
|
this.appCheckCredentials.invalidateToken()), t) : new U(I, t.toString());
|
|
3111
3111
|
}));
|
|
@@ -3117,40 +3117,40 @@ class Je extends class {} {
|
|
|
3117
3117
|
|
|
3118
3118
|
// TODO(firestorexp): Make sure there is only one Datastore instance per
|
|
3119
3119
|
// firestore-exp client.
|
|
3120
|
-
async function
|
|
3121
|
-
const
|
|
3122
|
-
writes:
|
|
3120
|
+
async function Zn(t, n) {
|
|
3121
|
+
const e = b(t), r = Un(e.q) + "/documents", s = {
|
|
3122
|
+
writes: n.map((t => Mn(e.q, t)))
|
|
3123
3123
|
};
|
|
3124
|
-
await
|
|
3124
|
+
await e.m("Commit", r, s);
|
|
3125
3125
|
}
|
|
3126
3126
|
|
|
3127
|
-
async function
|
|
3128
|
-
const
|
|
3129
|
-
documents:
|
|
3130
|
-
}, i = await
|
|
3127
|
+
async function te(t, n) {
|
|
3128
|
+
const e = b(t), r = Un(e.q) + "/documents", s = {
|
|
3129
|
+
documents: n.map((t => On(e.q, t)))
|
|
3130
|
+
}, i = await e.T("BatchGetDocuments", r, s), o = new Map;
|
|
3131
3131
|
i.forEach((t => {
|
|
3132
|
-
const
|
|
3133
|
-
o.set(
|
|
3132
|
+
const n = jn(e.q, t);
|
|
3133
|
+
o.set(n.key.toString(), n);
|
|
3134
3134
|
}));
|
|
3135
3135
|
const u = [];
|
|
3136
|
-
return
|
|
3137
|
-
const
|
|
3138
|
-
v(!!
|
|
3136
|
+
return n.forEach((t => {
|
|
3137
|
+
const n = o.get(t.toString());
|
|
3138
|
+
v(!!n), u.push(n);
|
|
3139
3139
|
})), u;
|
|
3140
3140
|
}
|
|
3141
3141
|
|
|
3142
|
-
async function
|
|
3143
|
-
const
|
|
3144
|
-
return (await
|
|
3142
|
+
async function ne(t, n) {
|
|
3143
|
+
const e = b(t), r = Bn(e.q, dn(n));
|
|
3144
|
+
return (await e.T("RunQuery", r.parent, {
|
|
3145
3145
|
structuredQuery: r.structuredQuery
|
|
3146
|
-
})).filter((t => !!t.document)).map((t => function(t,
|
|
3147
|
-
const r =
|
|
3146
|
+
})).filter((t => !!t.document)).map((t => function(t, n, e) {
|
|
3147
|
+
const r = Cn(t, n.name), s = xn(n.updateTime), i = new Bt({
|
|
3148
3148
|
mapValue: {
|
|
3149
|
-
fields:
|
|
3149
|
+
fields: n.fields
|
|
3150
3150
|
}
|
|
3151
3151
|
}), o = zt.newFoundDocument(r, s, i);
|
|
3152
|
-
return
|
|
3153
|
-
}(
|
|
3152
|
+
return e && o.setHasCommittedMutations(), e ? o.setHasCommittedMutations() : o;
|
|
3153
|
+
}(e.q, t.document, void 0)));
|
|
3154
3154
|
}
|
|
3155
3155
|
|
|
3156
3156
|
/**
|
|
@@ -3168,7 +3168,7 @@ async function tn(t, e) {
|
|
|
3168
3168
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3169
3169
|
* See the License for the specific language governing permissions and
|
|
3170
3170
|
* limitations under the License.
|
|
3171
|
-
*/ const
|
|
3171
|
+
*/ const ee = new Map;
|
|
3172
3172
|
|
|
3173
3173
|
/**
|
|
3174
3174
|
* An instance map that ensures only one Datastore exists per Firestore
|
|
@@ -3179,19 +3179,19 @@ async function tn(t, e) {
|
|
|
3179
3179
|
* instance. Callers must invoke removeComponents() when the Firestore
|
|
3180
3180
|
* instance is terminated.
|
|
3181
3181
|
*/
|
|
3182
|
-
function
|
|
3183
|
-
if (t._terminated) throw new U(
|
|
3184
|
-
if (!
|
|
3182
|
+
function re(t) {
|
|
3183
|
+
if (t._terminated) throw new U(S, "The client has already been terminated.");
|
|
3184
|
+
if (!ee.has(t)) {
|
|
3185
3185
|
m("ComponentProvider", "Initializing Datastore");
|
|
3186
3186
|
const i = function(t) {
|
|
3187
3187
|
return new wt(t, fetch.bind(null));
|
|
3188
|
-
}((
|
|
3189
|
-
new H(
|
|
3190
|
-
return new
|
|
3188
|
+
}((n = t._databaseId, e = t.app.options.appId || "", r = t._persistenceKey, s = t._freezeSettings(),
|
|
3189
|
+
new H(n, e, r, s.host, s.ssl, s.experimentalForceLongPolling, s.experimentalAutoDetectLongPolling, s.useFetchStreams))), o = Kn(t._databaseId), u = function(t, n, e, r) {
|
|
3190
|
+
return new Xn(t, n, e, r);
|
|
3191
3191
|
}(t._authCredentials, t._appCheckCredentials, i, o);
|
|
3192
|
-
|
|
3192
|
+
ee.set(t, u);
|
|
3193
3193
|
}
|
|
3194
|
-
var
|
|
3194
|
+
var n, e, r, s;
|
|
3195
3195
|
/**
|
|
3196
3196
|
* @license
|
|
3197
3197
|
* Copyright 2018 Google LLC
|
|
@@ -3207,7 +3207,7 @@ function nn(t) {
|
|
|
3207
3207
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3208
3208
|
* See the License for the specific language governing permissions and
|
|
3209
3209
|
* limitations under the License.
|
|
3210
|
-
*/ return
|
|
3210
|
+
*/ return ee.get(t);
|
|
3211
3211
|
}
|
|
3212
3212
|
|
|
3213
3213
|
/**
|
|
@@ -3219,21 +3219,21 @@ function nn(t) {
|
|
|
3219
3219
|
* user-supplied `FirestoreSettings` object. This is a separate type so that
|
|
3220
3220
|
* defaults can be supplied and the value can be checked for equality.
|
|
3221
3221
|
*/
|
|
3222
|
-
class
|
|
3222
|
+
class se {
|
|
3223
3223
|
constructor(t) {
|
|
3224
|
-
var
|
|
3224
|
+
var n;
|
|
3225
3225
|
if (void 0 === t.host) {
|
|
3226
3226
|
if (void 0 !== t.ssl) throw new U(A, "Can't provide ssl option if host option is not set");
|
|
3227
3227
|
this.host = "firestore.googleapis.com", this.ssl = true;
|
|
3228
|
-
} else this.host = t.host, this.ssl = null === (
|
|
3228
|
+
} else this.host = t.host, this.ssl = null === (n = t.ssl) || void 0 === n || n;
|
|
3229
3229
|
if (this.credentials = t.credentials, this.ignoreUndefinedProperties = !!t.ignoreUndefinedProperties,
|
|
3230
3230
|
void 0 === t.cacheSizeBytes) this.cacheSizeBytes = 41943040; else {
|
|
3231
3231
|
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new U(A, "cacheSizeBytes must be at least 1048576");
|
|
3232
3232
|
this.cacheSizeBytes = t.cacheSizeBytes;
|
|
3233
3233
|
}
|
|
3234
3234
|
this.experimentalForceLongPolling = !!t.experimentalForceLongPolling, this.experimentalAutoDetectLongPolling = !!t.experimentalAutoDetectLongPolling,
|
|
3235
|
-
this.useFetchStreams = !!t.useFetchStreams, function(t,
|
|
3236
|
-
if (!0 ===
|
|
3235
|
+
this.useFetchStreams = !!t.useFetchStreams, function(t, n, e, r) {
|
|
3236
|
+
if (!0 === n && !0 === r) throw new U(A, `${t} and ${e} cannot be used together.`);
|
|
3237
3237
|
}("experimentalForceLongPolling", t.experimentalForceLongPolling, "experimentalAutoDetectLongPolling", t.experimentalAutoDetectLongPolling);
|
|
3238
3238
|
}
|
|
3239
3239
|
isEqual(t) {
|
|
@@ -3261,14 +3261,14 @@ class rn {
|
|
|
3261
3261
|
* The Cloud Firestore service interface.
|
|
3262
3262
|
*
|
|
3263
3263
|
* Do not call this constructor directly. Instead, use {@link getFirestore}.
|
|
3264
|
-
*/ class
|
|
3264
|
+
*/ class ie {
|
|
3265
3265
|
/** @hideconstructor */
|
|
3266
|
-
constructor(t,
|
|
3267
|
-
this._authCredentials =
|
|
3266
|
+
constructor(t, n, e) {
|
|
3267
|
+
this._authCredentials = n, this._appCheckCredentials = e,
|
|
3268
3268
|
/**
|
|
3269
3269
|
* Whether it's a Firestore or Firestore Lite instance.
|
|
3270
3270
|
*/
|
|
3271
|
-
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new
|
|
3271
|
+
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new se({}),
|
|
3272
3272
|
this._settingsFrozen = !1, t instanceof K ? this._databaseId = t : (this._app = t,
|
|
3273
3273
|
this._databaseId = function(t) {
|
|
3274
3274
|
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new U(A, '"projectId" not provided in firebase.initializeApp.');
|
|
@@ -3290,7 +3290,7 @@ class rn {
|
|
|
3290
3290
|
* The {@link @firebase/app#FirebaseApp} associated with this `Firestore` service
|
|
3291
3291
|
* instance.
|
|
3292
3292
|
*/ get app() {
|
|
3293
|
-
if (!this._app) throw new U(
|
|
3293
|
+
if (!this._app) throw new U(S, "Firestore was not initialized using the Firebase SDK. 'app' is not available");
|
|
3294
3294
|
return this._app;
|
|
3295
3295
|
}
|
|
3296
3296
|
get _initialized() {
|
|
@@ -3300,15 +3300,15 @@ class rn {
|
|
|
3300
3300
|
return void 0 !== this._terminateTask;
|
|
3301
3301
|
}
|
|
3302
3302
|
_setSettings(t) {
|
|
3303
|
-
if (this._settingsFrozen) throw new U(
|
|
3304
|
-
this._settings = new
|
|
3303
|
+
if (this._settingsFrozen) throw new U(S, "Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");
|
|
3304
|
+
this._settings = new se(t), void 0 !== t.credentials && (this._authCredentials = function(t) {
|
|
3305
3305
|
if (!t) return new M;
|
|
3306
3306
|
switch (t.type) {
|
|
3307
3307
|
case "gapi":
|
|
3308
|
-
const
|
|
3308
|
+
const n = t.client;
|
|
3309
3309
|
// Make sure this really is a Gapi client.
|
|
3310
|
-
return v(!("object" != typeof
|
|
3311
|
-
new Q(
|
|
3310
|
+
return v(!("object" != typeof n || null === n || !n.auth || !n.auth.getAuthHeaderValueForFirstParty)),
|
|
3311
|
+
new Q(n, t.sessionIndex || "0", t.iamToken || null);
|
|
3312
3312
|
|
|
3313
3313
|
case "provider":
|
|
3314
3314
|
return t.client;
|
|
@@ -3342,17 +3342,17 @@ class rn {
|
|
|
3342
3342
|
* Only ever called once.
|
|
3343
3343
|
*/ _terminate() {
|
|
3344
3344
|
return function(t) {
|
|
3345
|
-
const
|
|
3346
|
-
|
|
3345
|
+
const n = ee.get(t);
|
|
3346
|
+
n && (m("ComponentProvider", "Removing Datastore"), ee.delete(t), n.terminate());
|
|
3347
3347
|
}(this), Promise.resolve();
|
|
3348
3348
|
}
|
|
3349
3349
|
}
|
|
3350
3350
|
|
|
3351
|
-
function
|
|
3352
|
-
const
|
|
3353
|
-
if (
|
|
3354
|
-
return
|
|
3355
|
-
options:
|
|
3351
|
+
function oe(t, n) {
|
|
3352
|
+
const e = _getProvider(t, "firestore/lite");
|
|
3353
|
+
if (e.isInitialized()) throw new U(S, "Firestore can only be initialized once per app.");
|
|
3354
|
+
return e.initialize({
|
|
3355
|
+
options: n
|
|
3356
3356
|
});
|
|
3357
3357
|
}
|
|
3358
3358
|
|
|
@@ -3364,8 +3364,8 @@ function on(t, e) {
|
|
|
3364
3364
|
* @param app - The {@link @firebase/app#FirebaseApp} instance that the returned `Firestore`
|
|
3365
3365
|
* instance is associated with.
|
|
3366
3366
|
* @returns The `Firestore` instance of the provided app.
|
|
3367
|
-
*/ function
|
|
3368
|
-
return _getProvider(
|
|
3367
|
+
*/ function ue(n = getApp()) {
|
|
3368
|
+
return _getProvider(n, "firestore/lite").getImmediate();
|
|
3369
3369
|
}
|
|
3370
3370
|
|
|
3371
3371
|
/**
|
|
@@ -3380,24 +3380,24 @@ function on(t, e) {
|
|
|
3380
3380
|
* @param port - the emulator port (ex: 9000).
|
|
3381
3381
|
* @param options.mockUserToken - the mock auth token to use for unit testing
|
|
3382
3382
|
* Security Rules.
|
|
3383
|
-
*/ function
|
|
3383
|
+
*/ function ce(t, n, e, r = {}) {
|
|
3384
3384
|
var s;
|
|
3385
|
-
const i = (t = ot(t,
|
|
3386
|
-
if ("firestore.googleapis.com" !== i.host && i.host !==
|
|
3385
|
+
const i = (t = ot(t, ie))._getSettings();
|
|
3386
|
+
if ("firestore.googleapis.com" !== i.host && i.host !== n && y("Host has been set in both settings() and useEmulator(), emulator host will be used"),
|
|
3387
3387
|
t._setSettings(Object.assign(Object.assign({}, i), {
|
|
3388
|
-
host: `${
|
|
3388
|
+
host: `${n}:${e}`,
|
|
3389
3389
|
ssl: !1
|
|
3390
3390
|
})), r.mockUserToken) {
|
|
3391
|
-
let
|
|
3392
|
-
if ("string" == typeof r.mockUserToken)
|
|
3391
|
+
let n, e;
|
|
3392
|
+
if ("string" == typeof r.mockUserToken) n = r.mockUserToken, e = l.MOCK_USER; else {
|
|
3393
3393
|
// Let createMockUserToken validate first (catches common mistakes like
|
|
3394
3394
|
// invalid field "uid" and missing field "sub" / "user_id".)
|
|
3395
|
-
|
|
3395
|
+
n = createMockUserToken(r.mockUserToken, null === (s = t._app) || void 0 === s ? void 0 : s.options.projectId);
|
|
3396
3396
|
const i = r.mockUserToken.sub || r.mockUserToken.user_id;
|
|
3397
3397
|
if (!i) throw new U(A, "mockUserToken must contain 'sub' or 'user_id' field!");
|
|
3398
|
-
|
|
3398
|
+
e = new l(i);
|
|
3399
3399
|
}
|
|
3400
|
-
t._authCredentials = new B(new j(
|
|
3400
|
+
t._authCredentials = new B(new j(n, e));
|
|
3401
3401
|
}
|
|
3402
3402
|
}
|
|
3403
3403
|
|
|
@@ -3420,8 +3420,8 @@ function on(t, e) {
|
|
|
3420
3420
|
* @param firestore - The `Firestore` instance to terminate.
|
|
3421
3421
|
* @returns A `Promise` that is resolved when the instance has been successfully
|
|
3422
3422
|
* terminated.
|
|
3423
|
-
*/ function
|
|
3424
|
-
return t = ot(t,
|
|
3423
|
+
*/ function ae(t) {
|
|
3424
|
+
return t = ot(t, ie), _removeServiceInstance(t.app, "firestore/lite"), t._delete();
|
|
3425
3425
|
}
|
|
3426
3426
|
|
|
3427
3427
|
/**
|
|
@@ -3461,14 +3461,14 @@ function on(t, e) {
|
|
|
3461
3461
|
* and can be used to write, read, or listen to the location. The document at
|
|
3462
3462
|
* the referenced location may or may not exist.
|
|
3463
3463
|
*/
|
|
3464
|
-
class
|
|
3464
|
+
class he {
|
|
3465
3465
|
/** @hideconstructor */
|
|
3466
3466
|
constructor(t,
|
|
3467
3467
|
/**
|
|
3468
3468
|
* If provided, the `FirestoreDataConverter` associated with this instance.
|
|
3469
3469
|
*/
|
|
3470
|
-
|
|
3471
|
-
this.converter =
|
|
3470
|
+
n, e) {
|
|
3471
|
+
this.converter = n, this._key = e,
|
|
3472
3472
|
/** The type of this Firestore reference. */
|
|
3473
3473
|
this.type = "document", this.firestore = t;
|
|
3474
3474
|
}
|
|
@@ -3489,40 +3489,40 @@ class hn {
|
|
|
3489
3489
|
/**
|
|
3490
3490
|
* The collection this `DocumentReference` belongs to.
|
|
3491
3491
|
*/ get parent() {
|
|
3492
|
-
return new
|
|
3492
|
+
return new fe(this.firestore, this.converter, this._key.path.popLast());
|
|
3493
3493
|
}
|
|
3494
3494
|
withConverter(t) {
|
|
3495
|
-
return new
|
|
3495
|
+
return new he(this.firestore, t, this._key);
|
|
3496
3496
|
}
|
|
3497
3497
|
}
|
|
3498
3498
|
|
|
3499
3499
|
/**
|
|
3500
3500
|
* A `Query` refers to a query which you can read or listen to. You can also
|
|
3501
3501
|
* construct refined `Query` objects by adding filters and ordering.
|
|
3502
|
-
*/ class
|
|
3502
|
+
*/ class le {
|
|
3503
3503
|
// This is the lite version of the Query class in the main SDK.
|
|
3504
3504
|
/** @hideconstructor protected */
|
|
3505
3505
|
constructor(t,
|
|
3506
3506
|
/**
|
|
3507
3507
|
* If provided, the `FirestoreDataConverter` associated with this instance.
|
|
3508
3508
|
*/
|
|
3509
|
-
|
|
3510
|
-
this.converter =
|
|
3509
|
+
n, e) {
|
|
3510
|
+
this.converter = n, this._query = e,
|
|
3511
3511
|
/** The type of this Firestore reference. */
|
|
3512
3512
|
this.type = "query", this.firestore = t;
|
|
3513
3513
|
}
|
|
3514
3514
|
withConverter(t) {
|
|
3515
|
-
return new
|
|
3515
|
+
return new le(this.firestore, t, this._query);
|
|
3516
3516
|
}
|
|
3517
3517
|
}
|
|
3518
3518
|
|
|
3519
3519
|
/**
|
|
3520
3520
|
* A `CollectionReference` object can be used for adding documents, getting
|
|
3521
3521
|
* document references, and querying for documents (using {@link query}).
|
|
3522
|
-
*/ class
|
|
3522
|
+
*/ class fe extends le {
|
|
3523
3523
|
/** @hideconstructor */
|
|
3524
|
-
constructor(t,
|
|
3525
|
-
super(t,
|
|
3524
|
+
constructor(t, n, e) {
|
|
3525
|
+
super(t, n, new un(e)), this._path = e,
|
|
3526
3526
|
/** The type of this Firestore reference. */
|
|
3527
3527
|
this.type = "collection";
|
|
3528
3528
|
}
|
|
@@ -3540,23 +3540,23 @@ class hn {
|
|
|
3540
3540
|
* subcollection. If this isn't a subcollection, the reference is null.
|
|
3541
3541
|
*/ get parent() {
|
|
3542
3542
|
const t = this._path.popLast();
|
|
3543
|
-
return t.isEmpty() ? null : new
|
|
3544
|
-
/* converter= */ null, new
|
|
3543
|
+
return t.isEmpty() ? null : new he(this.firestore,
|
|
3544
|
+
/* converter= */ null, new nt(t));
|
|
3545
3545
|
}
|
|
3546
3546
|
withConverter(t) {
|
|
3547
|
-
return new
|
|
3547
|
+
return new fe(this.firestore, t, this._path);
|
|
3548
3548
|
}
|
|
3549
3549
|
}
|
|
3550
3550
|
|
|
3551
|
-
function
|
|
3552
|
-
if (t = getModularInstance(t),
|
|
3553
|
-
const r = X.fromString(
|
|
3554
|
-
return st(r), new
|
|
3551
|
+
function de(t, n, ...e) {
|
|
3552
|
+
if (t = getModularInstance(t), et("collection", "path", n), t instanceof ie) {
|
|
3553
|
+
const r = X.fromString(n, ...e);
|
|
3554
|
+
return st(r), new fe(t, /* converter= */ null, r);
|
|
3555
3555
|
}
|
|
3556
3556
|
{
|
|
3557
|
-
if (!(t instanceof
|
|
3558
|
-
const r = t._path.child(X.fromString(
|
|
3559
|
-
return st(r), new
|
|
3557
|
+
if (!(t instanceof he || t instanceof fe)) throw new U(A, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3558
|
+
const r = t._path.child(X.fromString(n, ...e));
|
|
3559
|
+
return st(r), new fe(t.firestore,
|
|
3560
3560
|
/* converter= */ null, r);
|
|
3561
3561
|
}
|
|
3562
3562
|
}
|
|
@@ -3573,32 +3573,32 @@ function dn(t, e, ...n) {
|
|
|
3573
3573
|
* collection or subcollection with this ID as the last segment of its path
|
|
3574
3574
|
* will be included. Cannot contain a slash.
|
|
3575
3575
|
* @returns The created `Query`.
|
|
3576
|
-
*/ function
|
|
3577
|
-
if (t = ot(t,
|
|
3578
|
-
return new
|
|
3576
|
+
*/ function we(t, n) {
|
|
3577
|
+
if (t = ot(t, ie), et("collectionGroup", "collection id", n), n.indexOf("/") >= 0) throw new U(A, `Invalid collection ID '${n}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);
|
|
3578
|
+
return new le(t,
|
|
3579
3579
|
/* converter= */ null,
|
|
3580
3580
|
/**
|
|
3581
3581
|
* Creates a new Query for a collection group query that matches all documents
|
|
3582
3582
|
* within the provided collection group.
|
|
3583
3583
|
*/
|
|
3584
3584
|
function(t) {
|
|
3585
|
-
return new
|
|
3586
|
-
}(
|
|
3585
|
+
return new un(X.emptyPath(), t);
|
|
3586
|
+
}(n));
|
|
3587
3587
|
}
|
|
3588
3588
|
|
|
3589
|
-
function
|
|
3589
|
+
function me(t, n, ...e) {
|
|
3590
3590
|
if (t = getModularInstance(t),
|
|
3591
3591
|
// We allow omission of 'pathString' but explicitly prohibit passing in both
|
|
3592
3592
|
// 'undefined' and 'null'.
|
|
3593
|
-
1 === arguments.length && (
|
|
3594
|
-
const r = X.fromString(
|
|
3595
|
-
return rt(r), new
|
|
3596
|
-
/* converter= */ null, new
|
|
3593
|
+
1 === arguments.length && (n = pt.R()), et("doc", "path", n), t instanceof ie) {
|
|
3594
|
+
const r = X.fromString(n, ...e);
|
|
3595
|
+
return rt(r), new he(t,
|
|
3596
|
+
/* converter= */ null, new nt(r));
|
|
3597
3597
|
}
|
|
3598
3598
|
{
|
|
3599
|
-
if (!(t instanceof
|
|
3600
|
-
const r = t._path.child(X.fromString(
|
|
3601
|
-
return rt(r), new
|
|
3599
|
+
if (!(t instanceof he || t instanceof fe)) throw new U(A, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3600
|
+
const r = t._path.child(X.fromString(n, ...e));
|
|
3601
|
+
return rt(r), new he(t.firestore, t instanceof fe ? t.converter : null, new nt(r));
|
|
3602
3602
|
}
|
|
3603
3603
|
}
|
|
3604
3604
|
|
|
@@ -3609,8 +3609,8 @@ function mn(t, e, ...n) {
|
|
|
3609
3609
|
* @param right - A reference to compare.
|
|
3610
3610
|
* @returns true if the references point to the same location in the same
|
|
3611
3611
|
* Firestore database.
|
|
3612
|
-
*/ function
|
|
3613
|
-
return t = getModularInstance(t),
|
|
3612
|
+
*/ function pe(t, n) {
|
|
3613
|
+
return t = getModularInstance(t), n = getModularInstance(n), (t instanceof he || t instanceof fe) && (n instanceof he || n instanceof fe) && (t.firestore === n.firestore && t.path === n.path && t.converter === n.converter);
|
|
3614
3614
|
}
|
|
3615
3615
|
|
|
3616
3616
|
/**
|
|
@@ -3621,8 +3621,8 @@ function mn(t, e, ...n) {
|
|
|
3621
3621
|
* @param right - A `Query` to compare.
|
|
3622
3622
|
* @returns true if the references point to the same location in the same
|
|
3623
3623
|
* Firestore database.
|
|
3624
|
-
*/ function
|
|
3625
|
-
return t = getModularInstance(t),
|
|
3624
|
+
*/ function ye(t, n) {
|
|
3625
|
+
return t = getModularInstance(t), n = getModularInstance(n), t instanceof le && n instanceof le && (t.firestore === n.firestore && wn(t._query, n._query) && t.converter === n.converter);
|
|
3626
3626
|
}
|
|
3627
3627
|
|
|
3628
3628
|
/**
|
|
@@ -3648,7 +3648,7 @@ function mn(t, e, ...n) {
|
|
|
3648
3648
|
*
|
|
3649
3649
|
* Create a `FieldPath` by providing field names. If more than one field
|
|
3650
3650
|
* name is provided, the path will point to a nested field in a document.
|
|
3651
|
-
*/ class
|
|
3651
|
+
*/ class _e {
|
|
3652
3652
|
/**
|
|
3653
3653
|
* Creates a `FieldPath` from the provided field names. If more than one field
|
|
3654
3654
|
* name is provided, the path will point to a nested field in a document.
|
|
@@ -3656,7 +3656,7 @@ function mn(t, e, ...n) {
|
|
|
3656
3656
|
* @param fieldNames - A list of field names.
|
|
3657
3657
|
*/
|
|
3658
3658
|
constructor(...t) {
|
|
3659
|
-
for (let
|
|
3659
|
+
for (let n = 0; n < t.length; ++n) if (0 === t[n].length) throw new U(A, "Invalid field name at argument $(i + 1). Field names must not be empty.");
|
|
3660
3660
|
this._internalPath = new tt(t);
|
|
3661
3661
|
}
|
|
3662
3662
|
/**
|
|
@@ -3672,8 +3672,8 @@ function mn(t, e, ...n) {
|
|
|
3672
3672
|
/**
|
|
3673
3673
|
* Returns a special sentinel `FieldPath` to refer to the ID of a document.
|
|
3674
3674
|
* It can be used in queries to sort or filter by the document ID.
|
|
3675
|
-
*/ function
|
|
3676
|
-
return new
|
|
3675
|
+
*/ function ge() {
|
|
3676
|
+
return new _e("__name__");
|
|
3677
3677
|
}
|
|
3678
3678
|
|
|
3679
3679
|
/**
|
|
@@ -3694,7 +3694,7 @@ function mn(t, e, ...n) {
|
|
|
3694
3694
|
*/
|
|
3695
3695
|
/**
|
|
3696
3696
|
* An immutable object representing an array of bytes.
|
|
3697
|
-
*/ class
|
|
3697
|
+
*/ class ve {
|
|
3698
3698
|
/** @hideconstructor */
|
|
3699
3699
|
constructor(t) {
|
|
3700
3700
|
this._byteString = t;
|
|
@@ -3706,7 +3706,7 @@ function mn(t, e, ...n) {
|
|
|
3706
3706
|
* @param base64 - The Base64 string used to create the `Bytes` object.
|
|
3707
3707
|
*/ static fromBase64String(t) {
|
|
3708
3708
|
try {
|
|
3709
|
-
return new
|
|
3709
|
+
return new ve(It.fromBase64String(t));
|
|
3710
3710
|
} catch (t) {
|
|
3711
3711
|
throw new U(A, "Failed to construct data from Base64 string: " + t);
|
|
3712
3712
|
}
|
|
@@ -3716,7 +3716,7 @@ function mn(t, e, ...n) {
|
|
|
3716
3716
|
*
|
|
3717
3717
|
* @param array - The Uint8Array used to create the `Bytes` object.
|
|
3718
3718
|
*/ static fromUint8Array(t) {
|
|
3719
|
-
return new
|
|
3719
|
+
return new ve(It.fromUint8Array(t));
|
|
3720
3720
|
}
|
|
3721
3721
|
/**
|
|
3722
3722
|
* Returns the underlying bytes as a Base64-encoded string.
|
|
@@ -3768,7 +3768,7 @@ function mn(t, e, ...n) {
|
|
|
3768
3768
|
/**
|
|
3769
3769
|
* Sentinel values that can be used when writing document fields with `set()`
|
|
3770
3770
|
* or `update()`.
|
|
3771
|
-
*/ class
|
|
3771
|
+
*/ class be {
|
|
3772
3772
|
/**
|
|
3773
3773
|
* @param _methodName - The public API endpoint that returns this class.
|
|
3774
3774
|
* @hideconstructor
|
|
@@ -3800,17 +3800,17 @@ function mn(t, e, ...n) {
|
|
|
3800
3800
|
*
|
|
3801
3801
|
* Latitude values are in the range of [-90, 90].
|
|
3802
3802
|
* Longitude values are in the range of [-180, 180].
|
|
3803
|
-
*/ class
|
|
3803
|
+
*/ class Ee {
|
|
3804
3804
|
/**
|
|
3805
3805
|
* Creates a new immutable `GeoPoint` object with the provided latitude and
|
|
3806
3806
|
* longitude values.
|
|
3807
3807
|
* @param latitude - The latitude as number between -90 and 90.
|
|
3808
3808
|
* @param longitude - The longitude as number between -180 and 180.
|
|
3809
3809
|
*/
|
|
3810
|
-
constructor(t,
|
|
3810
|
+
constructor(t, n) {
|
|
3811
3811
|
if (!isFinite(t) || t < -90 || t > 90) throw new U(A, "Latitude must be a number between -90 and 90, but was: " + t);
|
|
3812
|
-
if (!isFinite(
|
|
3813
|
-
this._lat = t, this._long =
|
|
3812
|
+
if (!isFinite(n) || n < -180 || n > 180) throw new U(A, "Longitude must be a number between -180 and 180, but was: " + n);
|
|
3813
|
+
this._lat = t, this._long = n;
|
|
3814
3814
|
}
|
|
3815
3815
|
/**
|
|
3816
3816
|
* The latitude of this `GeoPoint` instance.
|
|
@@ -3859,29 +3859,29 @@ function mn(t, e, ...n) {
|
|
|
3859
3859
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3860
3860
|
* See the License for the specific language governing permissions and
|
|
3861
3861
|
* limitations under the License.
|
|
3862
|
-
*/ const
|
|
3862
|
+
*/ const Te = /^__.*__$/;
|
|
3863
3863
|
|
|
3864
|
-
/** The result of parsing document data (e.g. for a setData call). */ class
|
|
3865
|
-
constructor(t,
|
|
3866
|
-
this.data = t, this.fieldMask =
|
|
3864
|
+
/** The result of parsing document data (e.g. for a setData call). */ class Ie {
|
|
3865
|
+
constructor(t, n, e) {
|
|
3866
|
+
this.data = t, this.fieldMask = n, this.fieldTransforms = e;
|
|
3867
3867
|
}
|
|
3868
|
-
toMutation(t,
|
|
3869
|
-
return null !== this.fieldMask ? new
|
|
3868
|
+
toMutation(t, n) {
|
|
3869
|
+
return null !== this.fieldMask ? new An(t, this.data, this.fieldMask, n, this.fieldTransforms) : new In(t, this.data, n, this.fieldTransforms);
|
|
3870
3870
|
}
|
|
3871
3871
|
}
|
|
3872
3872
|
|
|
3873
|
-
/** The result of parsing "update" data (i.e. for an updateData call). */ class
|
|
3873
|
+
/** The result of parsing "update" data (i.e. for an updateData call). */ class Ae {
|
|
3874
3874
|
constructor(t,
|
|
3875
3875
|
// The fieldMask does not include document transforms.
|
|
3876
|
-
|
|
3877
|
-
this.data = t, this.fieldMask =
|
|
3876
|
+
n, e) {
|
|
3877
|
+
this.data = t, this.fieldMask = n, this.fieldTransforms = e;
|
|
3878
3878
|
}
|
|
3879
|
-
toMutation(t,
|
|
3880
|
-
return new
|
|
3879
|
+
toMutation(t, n) {
|
|
3880
|
+
return new An(t, this.data, this.fieldMask, n, this.fieldTransforms);
|
|
3881
3881
|
}
|
|
3882
3882
|
}
|
|
3883
3883
|
|
|
3884
|
-
function
|
|
3884
|
+
function Re(t) {
|
|
3885
3885
|
switch (t) {
|
|
3886
3886
|
case 0 /* Set */ :
|
|
3887
3887
|
// fall through
|
|
@@ -3899,7 +3899,7 @@ function Pn(t) {
|
|
|
3899
3899
|
}
|
|
3900
3900
|
}
|
|
3901
3901
|
|
|
3902
|
-
/** A "context" object passed around while parsing user data. */ class
|
|
3902
|
+
/** A "context" object passed around while parsing user data. */ class Pe {
|
|
3903
3903
|
/**
|
|
3904
3904
|
* Initializes a ParseContext with the given source and path.
|
|
3905
3905
|
*
|
|
@@ -3918,8 +3918,8 @@ function Pn(t) {
|
|
|
3918
3918
|
* which case certain features will not work and errors will be somewhat
|
|
3919
3919
|
* compromised).
|
|
3920
3920
|
*/
|
|
3921
|
-
constructor(t,
|
|
3922
|
-
this.settings = t, this.databaseId =
|
|
3921
|
+
constructor(t, n, e, r, s, i) {
|
|
3922
|
+
this.settings = t, this.databaseId = n, this.q = e, this.ignoreUndefinedProperties = r,
|
|
3923
3923
|
// Minor hack: If fieldTransforms is undefined, we assume this is an
|
|
3924
3924
|
// external call and we need to validate the entire path.
|
|
3925
3925
|
void 0 === s && this.Z(), this.fieldTransforms = s || [], this.fieldMask = i || [];
|
|
@@ -3930,21 +3930,21 @@ function Pn(t) {
|
|
|
3930
3930
|
get tt() {
|
|
3931
3931
|
return this.settings.tt;
|
|
3932
3932
|
}
|
|
3933
|
-
/** Returns a new context with the specified settings overwritten. */
|
|
3934
|
-
return new
|
|
3933
|
+
/** Returns a new context with the specified settings overwritten. */ nt(t) {
|
|
3934
|
+
return new Pe(Object.assign(Object.assign({}, this.settings), t), this.databaseId, this.q, this.ignoreUndefinedProperties, this.fieldTransforms, this.fieldMask);
|
|
3935
3935
|
}
|
|
3936
|
-
|
|
3937
|
-
var
|
|
3938
|
-
const
|
|
3939
|
-
path:
|
|
3936
|
+
et(t) {
|
|
3937
|
+
var n;
|
|
3938
|
+
const e = null === (n = this.path) || void 0 === n ? void 0 : n.child(t), r = this.nt({
|
|
3939
|
+
path: e,
|
|
3940
3940
|
rt: !1
|
|
3941
3941
|
});
|
|
3942
3942
|
return r.st(t), r;
|
|
3943
3943
|
}
|
|
3944
3944
|
it(t) {
|
|
3945
|
-
var
|
|
3946
|
-
const
|
|
3947
|
-
path:
|
|
3945
|
+
var n;
|
|
3946
|
+
const e = null === (n = this.path) || void 0 === n ? void 0 : n.child(t), r = this.nt({
|
|
3947
|
+
path: e,
|
|
3948
3948
|
rt: !1
|
|
3949
3949
|
});
|
|
3950
3950
|
return r.Z(), r;
|
|
@@ -3952,16 +3952,16 @@ function Pn(t) {
|
|
|
3952
3952
|
ot(t) {
|
|
3953
3953
|
// TODO(b/34871131): We don't support array paths right now; so make path
|
|
3954
3954
|
// undefined.
|
|
3955
|
-
return this.
|
|
3955
|
+
return this.nt({
|
|
3956
3956
|
path: void 0,
|
|
3957
3957
|
rt: !0
|
|
3958
3958
|
});
|
|
3959
3959
|
}
|
|
3960
3960
|
ut(t) {
|
|
3961
|
-
return
|
|
3961
|
+
return We(t, this.settings.methodName, this.settings.ct || !1, this.path, this.settings.at);
|
|
3962
3962
|
}
|
|
3963
3963
|
/** Returns 'true' if 'fieldPath' was traversed when creating this context. */ contains(t) {
|
|
3964
|
-
return void 0 !== this.fieldMask.find((
|
|
3964
|
+
return void 0 !== this.fieldMask.find((n => t.isPrefixOf(n))) || void 0 !== this.fieldTransforms.find((n => t.isPrefixOf(n.field)));
|
|
3965
3965
|
}
|
|
3966
3966
|
Z() {
|
|
3967
3967
|
// TODO(b/34871131): Remove null check once we have proper paths for fields
|
|
@@ -3970,22 +3970,22 @@ function Pn(t) {
|
|
|
3970
3970
|
}
|
|
3971
3971
|
st(t) {
|
|
3972
3972
|
if (0 === t.length) throw this.ut("Document fields must not be empty");
|
|
3973
|
-
if (
|
|
3973
|
+
if (Re(this.tt) && Te.test(t)) throw this.ut('Document fields cannot begin and end with "__"');
|
|
3974
3974
|
}
|
|
3975
3975
|
}
|
|
3976
3976
|
|
|
3977
3977
|
/**
|
|
3978
3978
|
* Helper for parsing raw user input (provided via the API) into internal model
|
|
3979
3979
|
* classes.
|
|
3980
|
-
*/ class
|
|
3981
|
-
constructor(t,
|
|
3982
|
-
this.databaseId = t, this.ignoreUndefinedProperties =
|
|
3980
|
+
*/ class Ve {
|
|
3981
|
+
constructor(t, n, e) {
|
|
3982
|
+
this.databaseId = t, this.ignoreUndefinedProperties = n, this.q = e || Kn(t);
|
|
3983
3983
|
}
|
|
3984
|
-
/** Creates a new top-level parse context. */ ht(t,
|
|
3985
|
-
return new
|
|
3984
|
+
/** Creates a new top-level parse context. */ ht(t, n, e, r = !1) {
|
|
3985
|
+
return new Pe({
|
|
3986
3986
|
tt: t,
|
|
3987
|
-
methodName:
|
|
3988
|
-
at:
|
|
3987
|
+
methodName: n,
|
|
3988
|
+
at: e,
|
|
3989
3989
|
path: tt.emptyPath(),
|
|
3990
3990
|
rt: !1,
|
|
3991
3991
|
ct: r
|
|
@@ -3993,29 +3993,29 @@ function Pn(t) {
|
|
|
3993
3993
|
}
|
|
3994
3994
|
}
|
|
3995
3995
|
|
|
3996
|
-
function
|
|
3997
|
-
const
|
|
3998
|
-
return new
|
|
3996
|
+
function De(t) {
|
|
3997
|
+
const n = t._freezeSettings(), e = Kn(t._databaseId);
|
|
3998
|
+
return new Ve(t._databaseId, !!n.ignoreUndefinedProperties, e);
|
|
3999
3999
|
}
|
|
4000
4000
|
|
|
4001
|
-
/** Parse document data from a set() call. */ function
|
|
4002
|
-
const o = t.ht(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ ,
|
|
4003
|
-
|
|
4004
|
-
const u =
|
|
4001
|
+
/** Parse document data from a set() call. */ function Ne(t, n, e, r, s, i = {}) {
|
|
4002
|
+
const o = t.ht(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ , n, e, s);
|
|
4003
|
+
Be("Data must be an object, but it was:", o, r);
|
|
4004
|
+
const u = je(r, o);
|
|
4005
4005
|
let c, a;
|
|
4006
4006
|
if (i.merge) c = new Tt(o.fieldMask), a = o.fieldTransforms; else if (i.mergeFields) {
|
|
4007
4007
|
const t = [];
|
|
4008
4008
|
for (const r of i.mergeFields) {
|
|
4009
|
-
const s =
|
|
4009
|
+
const s = ze(n, r, e);
|
|
4010
4010
|
if (!o.contains(s)) throw new U(A, `Field '${s}' is specified in your field mask but missing from your input data.`);
|
|
4011
|
-
|
|
4011
|
+
Ye(t, s) || t.push(s);
|
|
4012
4012
|
}
|
|
4013
4013
|
c = new Tt(t), a = o.fieldTransforms.filter((t => c.covers(t.field)));
|
|
4014
4014
|
} else c = null, a = o.fieldTransforms;
|
|
4015
|
-
return new
|
|
4015
|
+
return new Ie(new Bt(u), c, a);
|
|
4016
4016
|
}
|
|
4017
4017
|
|
|
4018
|
-
class $
|
|
4018
|
+
class $e extends be {
|
|
4019
4019
|
_toFieldTransform(t) {
|
|
4020
4020
|
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}`);
|
|
4021
4021
|
// No transform to add for a delete, but we need to add it to our
|
|
@@ -4023,7 +4023,7 @@ class $n extends bn {
|
|
|
4023
4023
|
return t.fieldMask.push(t.path), null;
|
|
4024
4024
|
}
|
|
4025
4025
|
isEqual(t) {
|
|
4026
|
-
return t instanceof $
|
|
4026
|
+
return t instanceof $e;
|
|
4027
4027
|
}
|
|
4028
4028
|
}
|
|
4029
4029
|
|
|
@@ -4042,32 +4042,32 @@ class $n extends bn {
|
|
|
4042
4042
|
* context.
|
|
4043
4043
|
* @param context - The parent context.
|
|
4044
4044
|
* @param arrayElement - Whether or not the FieldValue has an array.
|
|
4045
|
-
*/ function
|
|
4046
|
-
return new
|
|
4045
|
+
*/ function Se(t, n, e) {
|
|
4046
|
+
return new Pe({
|
|
4047
4047
|
tt: 3 /* Argument */ ,
|
|
4048
|
-
at:
|
|
4048
|
+
at: n.settings.at,
|
|
4049
4049
|
methodName: t._methodName,
|
|
4050
|
-
rt:
|
|
4051
|
-
},
|
|
4050
|
+
rt: e
|
|
4051
|
+
}, n.databaseId, n.q, n.ignoreUndefinedProperties);
|
|
4052
4052
|
}
|
|
4053
4053
|
|
|
4054
|
-
class
|
|
4054
|
+
class Fe extends be {
|
|
4055
4055
|
_toFieldTransform(t) {
|
|
4056
|
-
return new
|
|
4056
|
+
return new bn(t.path, new yn);
|
|
4057
4057
|
}
|
|
4058
4058
|
isEqual(t) {
|
|
4059
|
-
return t instanceof
|
|
4059
|
+
return t instanceof Fe;
|
|
4060
4060
|
}
|
|
4061
4061
|
}
|
|
4062
4062
|
|
|
4063
|
-
class
|
|
4064
|
-
constructor(t,
|
|
4065
|
-
super(t), this.lt =
|
|
4063
|
+
class xe extends be {
|
|
4064
|
+
constructor(t, n) {
|
|
4065
|
+
super(t), this.lt = n;
|
|
4066
4066
|
}
|
|
4067
4067
|
_toFieldTransform(t) {
|
|
4068
|
-
const
|
|
4069
|
-
/*array=*/ !0),
|
|
4070
|
-
return new
|
|
4068
|
+
const n = Se(this, t,
|
|
4069
|
+
/*array=*/ !0), e = this.lt.map((t => ke(t, n))), r = new _n(e);
|
|
4070
|
+
return new bn(t.path, r);
|
|
4071
4071
|
}
|
|
4072
4072
|
isEqual(t) {
|
|
4073
4073
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4075,14 +4075,14 @@ class xn extends bn {
|
|
|
4075
4075
|
}
|
|
4076
4076
|
}
|
|
4077
4077
|
|
|
4078
|
-
class
|
|
4079
|
-
constructor(t,
|
|
4080
|
-
super(t), this.lt =
|
|
4078
|
+
class qe extends be {
|
|
4079
|
+
constructor(t, n) {
|
|
4080
|
+
super(t), this.lt = n;
|
|
4081
4081
|
}
|
|
4082
4082
|
_toFieldTransform(t) {
|
|
4083
|
-
const
|
|
4084
|
-
/*array=*/ !0),
|
|
4085
|
-
return new
|
|
4083
|
+
const n = Se(this, t,
|
|
4084
|
+
/*array=*/ !0), e = this.lt.map((t => ke(t, n))), r = new gn(e);
|
|
4085
|
+
return new bn(t.path, r);
|
|
4086
4086
|
}
|
|
4087
4087
|
isEqual(t) {
|
|
4088
4088
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4090,13 +4090,13 @@ class qn extends bn {
|
|
|
4090
4090
|
}
|
|
4091
4091
|
}
|
|
4092
4092
|
|
|
4093
|
-
class
|
|
4094
|
-
constructor(t,
|
|
4095
|
-
super(t), this.ft =
|
|
4093
|
+
class Oe extends be {
|
|
4094
|
+
constructor(t, n) {
|
|
4095
|
+
super(t), this.ft = n;
|
|
4096
4096
|
}
|
|
4097
4097
|
_toFieldTransform(t) {
|
|
4098
|
-
const
|
|
4099
|
-
return new
|
|
4098
|
+
const n = new vn(t.q, mn(t.q, this.ft));
|
|
4099
|
+
return new bn(t.path, n);
|
|
4100
4100
|
}
|
|
4101
4101
|
isEqual(t) {
|
|
4102
4102
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4104,50 +4104,50 @@ class On extends bn {
|
|
|
4104
4104
|
}
|
|
4105
4105
|
}
|
|
4106
4106
|
|
|
4107
|
-
/** Parse update data from an update() call. */ function
|
|
4108
|
-
const s = t.ht(1 /* Update */ ,
|
|
4109
|
-
|
|
4107
|
+
/** Parse update data from an update() call. */ function Ce(t, n, e, r) {
|
|
4108
|
+
const s = t.ht(1 /* Update */ , n, e);
|
|
4109
|
+
Be("Data must be an object, but it was:", s, r);
|
|
4110
4110
|
const i = [], o = Bt.empty();
|
|
4111
4111
|
Et(r, ((t, r) => {
|
|
4112
|
-
const u =
|
|
4112
|
+
const u = Qe(n, t, e);
|
|
4113
4113
|
// For Compat types, we have to "extract" the underlying types before
|
|
4114
4114
|
// performing validation.
|
|
4115
4115
|
r = getModularInstance(r);
|
|
4116
4116
|
const c = s.it(u);
|
|
4117
|
-
if (r instanceof $
|
|
4117
|
+
if (r instanceof $e)
|
|
4118
4118
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4119
4119
|
i.push(u); else {
|
|
4120
|
-
const t =
|
|
4120
|
+
const t = ke(r, c);
|
|
4121
4121
|
null != t && (i.push(u), o.set(u, t));
|
|
4122
4122
|
}
|
|
4123
4123
|
}));
|
|
4124
4124
|
const u = new Tt(i);
|
|
4125
|
-
return new
|
|
4125
|
+
return new Ae(o, u, s.fieldTransforms);
|
|
4126
4126
|
}
|
|
4127
4127
|
|
|
4128
|
-
/** Parse update data from a list of field/value arguments. */ function
|
|
4129
|
-
const o = t.ht(1 /* Update */ ,
|
|
4130
|
-
if (i.length % 2 != 0) throw new U(A, `Function ${
|
|
4131
|
-
for (let t = 0; t < i.length; t += 2) u.push(
|
|
4128
|
+
/** Parse update data from a list of field/value arguments. */ function Le(t, n, e, r, s, i) {
|
|
4129
|
+
const o = t.ht(1 /* Update */ , n, e), u = [ ze(n, r, e) ], c = [ s ];
|
|
4130
|
+
if (i.length % 2 != 0) throw new U(A, `Function ${n}() needs to be called with an even number of arguments that alternate between field names and values.`);
|
|
4131
|
+
for (let t = 0; t < i.length; t += 2) u.push(ze(n, i[t])), c.push(i[t + 1]);
|
|
4132
4132
|
const a = [], l = Bt.empty();
|
|
4133
4133
|
// We iterate in reverse order to pick the last value for a field if the
|
|
4134
4134
|
// user specified the field multiple times.
|
|
4135
|
-
for (let t = u.length - 1; t >= 0; --t) if (!
|
|
4136
|
-
const
|
|
4137
|
-
let
|
|
4135
|
+
for (let t = u.length - 1; t >= 0; --t) if (!Ye(a, u[t])) {
|
|
4136
|
+
const n = u[t];
|
|
4137
|
+
let e = c[t];
|
|
4138
4138
|
// For Compat types, we have to "extract" the underlying types before
|
|
4139
4139
|
// performing validation.
|
|
4140
|
-
|
|
4141
|
-
const r = o.it(
|
|
4142
|
-
if (
|
|
4140
|
+
e = getModularInstance(e);
|
|
4141
|
+
const r = o.it(n);
|
|
4142
|
+
if (e instanceof $e)
|
|
4143
4143
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4144
|
-
a.push(
|
|
4145
|
-
const t =
|
|
4146
|
-
null != t && (a.push(
|
|
4144
|
+
a.push(n); else {
|
|
4145
|
+
const t = ke(e, r);
|
|
4146
|
+
null != t && (a.push(n), l.set(n, t));
|
|
4147
4147
|
}
|
|
4148
4148
|
}
|
|
4149
4149
|
const f = new Tt(a);
|
|
4150
|
-
return new
|
|
4150
|
+
return new Ae(l, f, o.fieldTransforms);
|
|
4151
4151
|
}
|
|
4152
4152
|
|
|
4153
4153
|
/**
|
|
@@ -4156,8 +4156,8 @@ class On extends bn {
|
|
|
4156
4156
|
*
|
|
4157
4157
|
* @param allowArrays - Whether the query value is an array that may directly
|
|
4158
4158
|
* contain additional arrays (e.g. the operand of an `in` query).
|
|
4159
|
-
*/ function
|
|
4160
|
-
return
|
|
4159
|
+
*/ function Ue(t, n, e, r = !1) {
|
|
4160
|
+
return ke(e, t.ht(r ? 4 /* ArrayArgument */ : 3 /* Argument */ , n));
|
|
4161
4161
|
}
|
|
4162
4162
|
|
|
4163
4163
|
/**
|
|
@@ -4168,13 +4168,13 @@ class On extends bn {
|
|
|
4168
4168
|
* the source of the data being parsed, etc.
|
|
4169
4169
|
* @returns The parsed value, or null if the value was a FieldValue sentinel
|
|
4170
4170
|
* that should not be included in the resulting parsed data.
|
|
4171
|
-
*/ function
|
|
4172
|
-
if (
|
|
4171
|
+
*/ function ke(t, n) {
|
|
4172
|
+
if (Me(
|
|
4173
4173
|
// Unwrap the API type from the Compat SDK. This will return the API type
|
|
4174
4174
|
// from firestore-exp.
|
|
4175
|
-
t = getModularInstance(t))) return
|
|
4176
|
-
if (t instanceof
|
|
4177
|
-
// FieldValues usually parse into transforms (except
|
|
4175
|
+
t = getModularInstance(t))) return Be("Unsupported field value:", n, t), je(t, n);
|
|
4176
|
+
if (t instanceof be)
|
|
4177
|
+
// FieldValues usually parse into transforms (except deleteField())
|
|
4178
4178
|
// in which case we do not want to include this field in our parsed data
|
|
4179
4179
|
// (as doing so will overwrite the field directly prior to the transform
|
|
4180
4180
|
// trying to transform it). So we don't add this location to
|
|
@@ -4183,19 +4183,19 @@ class On extends bn {
|
|
|
4183
4183
|
* "Parses" the provided FieldValueImpl, adding any necessary transforms to
|
|
4184
4184
|
* context.fieldTransforms.
|
|
4185
4185
|
*/
|
|
4186
|
-
return function(t,
|
|
4186
|
+
return function(t, n) {
|
|
4187
4187
|
// Sentinels are only supported with writes, and not within arrays.
|
|
4188
|
-
if (!
|
|
4189
|
-
if (!
|
|
4190
|
-
const
|
|
4191
|
-
|
|
4188
|
+
if (!Re(n.tt)) throw n.ut(`${t._methodName}() can only be used with update() and set()`);
|
|
4189
|
+
if (!n.path) throw n.ut(`${t._methodName}() is not currently supported inside arrays`);
|
|
4190
|
+
const e = t._toFieldTransform(n);
|
|
4191
|
+
e && n.fieldTransforms.push(e);
|
|
4192
4192
|
}
|
|
4193
4193
|
/**
|
|
4194
4194
|
* Helper to parse a scalar value (i.e. not an Object, Array, or FieldValue)
|
|
4195
4195
|
*
|
|
4196
4196
|
* @returns The parsed value
|
|
4197
|
-
*/ (t,
|
|
4198
|
-
if (void 0 === t &&
|
|
4197
|
+
*/ (t, n), null;
|
|
4198
|
+
if (void 0 === t && n.ignoreUndefinedProperties)
|
|
4199
4199
|
// If the input is undefined it can never participate in the fieldMask, so
|
|
4200
4200
|
// don't handle this below. If `ignoreUndefinedProperties` is false,
|
|
4201
4201
|
// `parseScalarValue` will reject an undefined value.
|
|
@@ -4203,38 +4203,38 @@ class On extends bn {
|
|
|
4203
4203
|
if (
|
|
4204
4204
|
// If context.path is null we are inside an array and we don't support
|
|
4205
4205
|
// field mask paths more granular than the top-level array.
|
|
4206
|
-
|
|
4206
|
+
n.path && n.fieldMask.push(n.path), t instanceof Array) {
|
|
4207
4207
|
// TODO(b/34871131): Include the path containing the array in the error
|
|
4208
4208
|
// message.
|
|
4209
4209
|
// In the case of IN queries, the parsed data is an array (representing
|
|
4210
4210
|
// the set of values to be included for the IN query) that may directly
|
|
4211
4211
|
// contain additional arrays (each representing an individual field
|
|
4212
4212
|
// value), so we disable this validation.
|
|
4213
|
-
if (
|
|
4214
|
-
return function(t,
|
|
4215
|
-
const
|
|
4213
|
+
if (n.settings.rt && 4 /* ArrayArgument */ !== n.tt) throw n.ut("Nested arrays are not supported");
|
|
4214
|
+
return function(t, n) {
|
|
4215
|
+
const e = [];
|
|
4216
4216
|
let r = 0;
|
|
4217
4217
|
for (const s of t) {
|
|
4218
|
-
let t =
|
|
4218
|
+
let t = ke(s, n.ot(r));
|
|
4219
4219
|
null == t && (
|
|
4220
4220
|
// Just include nulls in the array for fields being replaced with a
|
|
4221
4221
|
// sentinel.
|
|
4222
4222
|
t = {
|
|
4223
4223
|
nullValue: "NULL_VALUE"
|
|
4224
|
-
}),
|
|
4224
|
+
}), e.push(t), r++;
|
|
4225
4225
|
}
|
|
4226
4226
|
return {
|
|
4227
4227
|
arrayValue: {
|
|
4228
|
-
values:
|
|
4228
|
+
values: e
|
|
4229
4229
|
}
|
|
4230
4230
|
};
|
|
4231
|
-
}(t,
|
|
4231
|
+
}(t, n);
|
|
4232
4232
|
}
|
|
4233
|
-
return function(t,
|
|
4233
|
+
return function(t, n) {
|
|
4234
4234
|
if (null === (t = getModularInstance(t))) return {
|
|
4235
4235
|
nullValue: "NULL_VALUE"
|
|
4236
4236
|
};
|
|
4237
|
-
if ("number" == typeof t) return
|
|
4237
|
+
if ("number" == typeof t) return mn(n.q, t);
|
|
4238
4238
|
if ("boolean" == typeof t) return {
|
|
4239
4239
|
booleanValue: t
|
|
4240
4240
|
};
|
|
@@ -4242,37 +4242,37 @@ class On extends bn {
|
|
|
4242
4242
|
stringValue: t
|
|
4243
4243
|
};
|
|
4244
4244
|
if (t instanceof Date) {
|
|
4245
|
-
const
|
|
4245
|
+
const e = gt.fromDate(t);
|
|
4246
4246
|
return {
|
|
4247
|
-
timestampValue:
|
|
4247
|
+
timestampValue: $n(n.q, e)
|
|
4248
4248
|
};
|
|
4249
4249
|
}
|
|
4250
4250
|
if (t instanceof gt) {
|
|
4251
4251
|
// Firestore backend truncates precision down to microseconds. To ensure
|
|
4252
4252
|
// offline mode works the same with regards to truncation, perform the
|
|
4253
4253
|
// truncation immediately without waiting for the backend to do that.
|
|
4254
|
-
const
|
|
4254
|
+
const e = new gt(t.seconds, 1e3 * Math.floor(t.nanoseconds / 1e3));
|
|
4255
4255
|
return {
|
|
4256
|
-
timestampValue:
|
|
4256
|
+
timestampValue: $n(n.q, e)
|
|
4257
4257
|
};
|
|
4258
4258
|
}
|
|
4259
|
-
if (t instanceof
|
|
4259
|
+
if (t instanceof Ee) return {
|
|
4260
4260
|
geoPointValue: {
|
|
4261
4261
|
latitude: t.latitude,
|
|
4262
4262
|
longitude: t.longitude
|
|
4263
4263
|
}
|
|
4264
4264
|
};
|
|
4265
|
-
if (t instanceof
|
|
4266
|
-
bytesValue:
|
|
4265
|
+
if (t instanceof ve) return {
|
|
4266
|
+
bytesValue: Sn(n.q, t._byteString)
|
|
4267
4267
|
};
|
|
4268
|
-
if (t instanceof
|
|
4269
|
-
const
|
|
4270
|
-
if (!r.isEqual(
|
|
4268
|
+
if (t instanceof he) {
|
|
4269
|
+
const e = n.databaseId, r = t.firestore._databaseId;
|
|
4270
|
+
if (!r.isEqual(e)) throw n.ut(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${e.projectId}/${e.database}`);
|
|
4271
4271
|
return {
|
|
4272
|
-
referenceValue:
|
|
4272
|
+
referenceValue: qn(t.firestore._databaseId || n.databaseId, t._key.path)
|
|
4273
4273
|
};
|
|
4274
4274
|
}
|
|
4275
|
-
throw
|
|
4275
|
+
throw n.ut(`Unsupported field value: ${it(t)}`);
|
|
4276
4276
|
}
|
|
4277
4277
|
/**
|
|
4278
4278
|
* Checks whether an object looks like a JSON object that should be converted
|
|
@@ -4280,56 +4280,56 @@ class On extends bn {
|
|
|
4280
4280
|
* JSON objects since they should be converted to a struct value. Arrays, Dates,
|
|
4281
4281
|
* GeoPoints, etc. are not considered to look like JSON objects since they map
|
|
4282
4282
|
* to specific FieldValue types other than ObjectValue.
|
|
4283
|
-
*/ (t,
|
|
4283
|
+
*/ (t, n);
|
|
4284
4284
|
}
|
|
4285
4285
|
|
|
4286
|
-
function
|
|
4287
|
-
const
|
|
4286
|
+
function je(t, n) {
|
|
4287
|
+
const e = {};
|
|
4288
4288
|
return !function(t) {
|
|
4289
|
-
for (const
|
|
4289
|
+
for (const n in t) if (Object.prototype.hasOwnProperty.call(t, n)) return !1;
|
|
4290
4290
|
return !0;
|
|
4291
4291
|
}(t) ? Et(t, ((t, r) => {
|
|
4292
|
-
const s =
|
|
4293
|
-
null != s && (
|
|
4292
|
+
const s = ke(r, n.et(t));
|
|
4293
|
+
null != s && (e[t] = s);
|
|
4294
4294
|
})) :
|
|
4295
4295
|
// If we encounter an empty object, we explicitly add it to the update
|
|
4296
4296
|
// mask to ensure that the server creates a map entry.
|
|
4297
|
-
|
|
4297
|
+
n.path && n.path.length > 0 && n.fieldMask.push(n.path), {
|
|
4298
4298
|
mapValue: {
|
|
4299
|
-
fields:
|
|
4299
|
+
fields: e
|
|
4300
4300
|
}
|
|
4301
4301
|
};
|
|
4302
4302
|
}
|
|
4303
4303
|
|
|
4304
|
-
function
|
|
4305
|
-
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof gt || t instanceof
|
|
4304
|
+
function Me(t) {
|
|
4305
|
+
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof gt || t instanceof Ee || t instanceof ve || t instanceof he || t instanceof be);
|
|
4306
4306
|
}
|
|
4307
4307
|
|
|
4308
|
-
function
|
|
4309
|
-
if (!
|
|
4308
|
+
function Be(t, n, e) {
|
|
4309
|
+
if (!Me(e) || !function(t) {
|
|
4310
4310
|
return "object" == typeof t && null !== t && (Object.getPrototypeOf(t) === Object.prototype || null === Object.getPrototypeOf(t));
|
|
4311
|
-
}(
|
|
4312
|
-
const r = it(
|
|
4313
|
-
throw "an object" === r ?
|
|
4311
|
+
}(e)) {
|
|
4312
|
+
const r = it(e);
|
|
4313
|
+
throw "an object" === r ? n.ut(t + " a custom object") : n.ut(t + " " + r);
|
|
4314
4314
|
}
|
|
4315
4315
|
}
|
|
4316
4316
|
|
|
4317
4317
|
/**
|
|
4318
4318
|
* Helper that calls fromDotSeparatedString() but wraps any error thrown.
|
|
4319
|
-
*/ function
|
|
4319
|
+
*/ function ze(t, n, e) {
|
|
4320
4320
|
if ((
|
|
4321
4321
|
// If required, replace the FieldPath Compat class with with the firestore-exp
|
|
4322
4322
|
// FieldPath.
|
|
4323
|
-
|
|
4324
|
-
if ("string" == typeof
|
|
4325
|
-
throw
|
|
4323
|
+
n = getModularInstance(n)) instanceof _e) return n._internalPath;
|
|
4324
|
+
if ("string" == typeof n) return Qe(t, n);
|
|
4325
|
+
throw We("Field path arguments must be of type string or ", t,
|
|
4326
4326
|
/* hasConverter= */ !1,
|
|
4327
|
-
/* path= */ void 0,
|
|
4327
|
+
/* path= */ void 0, e);
|
|
4328
4328
|
}
|
|
4329
4329
|
|
|
4330
4330
|
/**
|
|
4331
4331
|
* Matches any characters in a field path string that are reserved.
|
|
4332
|
-
*/ const
|
|
4332
|
+
*/ const Ge = new RegExp("[~\\*/\\[\\]]");
|
|
4333
4333
|
|
|
4334
4334
|
/**
|
|
4335
4335
|
* Wraps fromDotSeparatedString with an error message about the method that
|
|
@@ -4339,30 +4339,30 @@ function Bn(t, e, n) {
|
|
|
4339
4339
|
* split on dots.
|
|
4340
4340
|
* @param targetDoc - The document against which the field path will be
|
|
4341
4341
|
* evaluated.
|
|
4342
|
-
*/ function
|
|
4343
|
-
if (
|
|
4342
|
+
*/ function Qe(t, n, e) {
|
|
4343
|
+
if (n.search(Ge) >= 0) throw We(`Invalid field path (${n}). Paths must not contain '~', '*', '/', '[', or ']'`, t,
|
|
4344
4344
|
/* hasConverter= */ !1,
|
|
4345
|
-
/* path= */ void 0,
|
|
4345
|
+
/* path= */ void 0, e);
|
|
4346
4346
|
try {
|
|
4347
|
-
return new
|
|
4347
|
+
return new _e(...n.split("."))._internalPath;
|
|
4348
4348
|
} catch (r) {
|
|
4349
|
-
throw
|
|
4349
|
+
throw We(`Invalid field path (${n}). Paths must not be empty, begin with '.', end with '.', or contain '..'`, t,
|
|
4350
4350
|
/* hasConverter= */ !1,
|
|
4351
|
-
/* path= */ void 0,
|
|
4351
|
+
/* path= */ void 0, e);
|
|
4352
4352
|
}
|
|
4353
4353
|
}
|
|
4354
4354
|
|
|
4355
|
-
function
|
|
4355
|
+
function We(t, n, e, r, s) {
|
|
4356
4356
|
const i = r && !r.isEmpty(), o = void 0 !== s;
|
|
4357
|
-
let u = `Function ${
|
|
4358
|
-
|
|
4357
|
+
let u = `Function ${n}() called with invalid data`;
|
|
4358
|
+
e && (u += " (via `toFirestore()`)"), u += ". ";
|
|
4359
4359
|
let c = "";
|
|
4360
4360
|
return (i || o) && (c += " (found", i && (c += ` in field ${r}`), o && (c += ` in document ${s}`),
|
|
4361
4361
|
c += ")"), new U(A, u + t + c);
|
|
4362
4362
|
}
|
|
4363
4363
|
|
|
4364
|
-
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function
|
|
4365
|
-
return t.some((t => t.isEqual(
|
|
4364
|
+
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function Ye(t, n) {
|
|
4365
|
+
return t.some((t => t.isEqual(n)));
|
|
4366
4366
|
}
|
|
4367
4367
|
|
|
4368
4368
|
/**
|
|
@@ -4389,14 +4389,14 @@ function Wn(t, e, n, r, s) {
|
|
|
4389
4389
|
* For a `DocumentSnapshot` that points to a non-existing document, any data
|
|
4390
4390
|
* access will return 'undefined'. You can use the `exists()` method to
|
|
4391
4391
|
* explicitly verify a document's existence.
|
|
4392
|
-
*/ class
|
|
4392
|
+
*/ class He {
|
|
4393
4393
|
// Note: This class is stripped down version of the DocumentSnapshot in
|
|
4394
4394
|
// the legacy SDK. The changes are:
|
|
4395
4395
|
// - No support for SnapshotMetadata.
|
|
4396
4396
|
// - No support for SnapshotOptions.
|
|
4397
4397
|
/** @hideconstructor protected */
|
|
4398
|
-
constructor(t,
|
|
4399
|
-
this._firestore = t, this._userDataWriter =
|
|
4398
|
+
constructor(t, n, e, r, s) {
|
|
4399
|
+
this._firestore = t, this._userDataWriter = n, this._key = e, this._document = r,
|
|
4400
4400
|
this._converter = s;
|
|
4401
4401
|
}
|
|
4402
4402
|
/** Property of the `DocumentSnapshot` that provides the document's ID. */ get id() {
|
|
@@ -4405,7 +4405,7 @@ function Wn(t, e, n, r, s) {
|
|
|
4405
4405
|
/**
|
|
4406
4406
|
* The `DocumentReference` for the document included in the `DocumentSnapshot`.
|
|
4407
4407
|
*/ get ref() {
|
|
4408
|
-
return new
|
|
4408
|
+
return new he(this._firestore, this._converter, this._key);
|
|
4409
4409
|
}
|
|
4410
4410
|
/**
|
|
4411
4411
|
* Signals whether or not the document at the snapshot's location exists.
|
|
@@ -4425,7 +4425,7 @@ function Wn(t, e, n, r, s) {
|
|
|
4425
4425
|
if (this._converter) {
|
|
4426
4426
|
// We only want to use the converter and create a new DocumentSnapshot
|
|
4427
4427
|
// if a converter has been provided.
|
|
4428
|
-
const t = new
|
|
4428
|
+
const t = new Ke(this._firestore, this._userDataWriter, this._key, this._document,
|
|
4429
4429
|
/* converter= */ null);
|
|
4430
4430
|
return this._converter.fromFirestore(t);
|
|
4431
4431
|
}
|
|
@@ -4445,8 +4445,8 @@ function Wn(t, e, n, r, s) {
|
|
|
4445
4445
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4446
4446
|
get(t) {
|
|
4447
4447
|
if (this._document) {
|
|
4448
|
-
const
|
|
4449
|
-
if (null !==
|
|
4448
|
+
const n = this._document.data.field(Ze("DocumentSnapshot.get", t));
|
|
4449
|
+
if (null !== n) return this._userDataWriter.convertValue(n);
|
|
4450
4450
|
}
|
|
4451
4451
|
}
|
|
4452
4452
|
}
|
|
@@ -4461,7 +4461,7 @@ function Wn(t, e, n, r, s) {
|
|
|
4461
4461
|
* `DocumentSnapshot`. Since query results contain only existing documents, the
|
|
4462
4462
|
* `exists` property will always be true and `data()` will never return
|
|
4463
4463
|
* 'undefined'.
|
|
4464
|
-
*/ class
|
|
4464
|
+
*/ class Ke extends He {
|
|
4465
4465
|
/**
|
|
4466
4466
|
* Retrieves all fields in the document as an `Object`.
|
|
4467
4467
|
*
|
|
@@ -4479,10 +4479,10 @@ function Wn(t, e, n, r, s) {
|
|
|
4479
4479
|
* array via the `docs` property or enumerated using the `forEach` method. The
|
|
4480
4480
|
* number of documents can be determined via the `empty` and `size`
|
|
4481
4481
|
* properties.
|
|
4482
|
-
*/ class
|
|
4482
|
+
*/ class Je {
|
|
4483
4483
|
/** @hideconstructor */
|
|
4484
|
-
constructor(t,
|
|
4485
|
-
this._docs =
|
|
4484
|
+
constructor(t, n) {
|
|
4485
|
+
this._docs = n, this.query = t;
|
|
4486
4486
|
}
|
|
4487
4487
|
/** An array of all the documents in the `QuerySnapshot`. */ get docs() {
|
|
4488
4488
|
return [ ...this._docs ];
|
|
@@ -4499,8 +4499,8 @@ function Wn(t, e, n, r, s) {
|
|
|
4499
4499
|
* @param callback - A callback to be called with a `QueryDocumentSnapshot` for
|
|
4500
4500
|
* each document in the snapshot.
|
|
4501
4501
|
* @param thisArg - The `this` binding for the callback.
|
|
4502
|
-
*/ forEach(t,
|
|
4503
|
-
this._docs.forEach(t,
|
|
4502
|
+
*/ forEach(t, n) {
|
|
4503
|
+
this._docs.forEach(t, n);
|
|
4504
4504
|
}
|
|
4505
4505
|
}
|
|
4506
4506
|
|
|
@@ -4510,14 +4510,14 @@ function Wn(t, e, n, r, s) {
|
|
|
4510
4510
|
* @param left - A snapshot to compare.
|
|
4511
4511
|
* @param right - A snapshot to compare.
|
|
4512
4512
|
* @returns true if the snapshots are equal.
|
|
4513
|
-
*/ function
|
|
4514
|
-
return t = getModularInstance(t),
|
|
4513
|
+
*/ function Xe(t, n) {
|
|
4514
|
+
return t = getModularInstance(t), n = getModularInstance(n), t instanceof He && n instanceof He ? t._firestore === n._firestore && t._key.isEqual(n._key) && (null === t._document ? null === n._document : t._document.isEqual(n._document)) && t._converter === n._converter : t instanceof Je && n instanceof Je && (ye(t.query, n.query) && _t(t.docs, n.docs, Xe));
|
|
4515
4515
|
}
|
|
4516
4516
|
|
|
4517
4517
|
/**
|
|
4518
4518
|
* Helper that calls `fromDotSeparatedString()` but wraps any error thrown.
|
|
4519
|
-
*/ function
|
|
4520
|
-
return "string" == typeof
|
|
4519
|
+
*/ function Ze(t, n) {
|
|
4520
|
+
return "string" == typeof n ? Qe(t, n) : n instanceof _e ? n._internalPath : n._delegate._internalPath;
|
|
4521
4521
|
}
|
|
4522
4522
|
|
|
4523
4523
|
/**
|
|
@@ -4554,43 +4554,43 @@ class tr {}
|
|
|
4554
4554
|
* @param queryConstraints - The list of {@link QueryConstraint}s to apply.
|
|
4555
4555
|
* @throws if any of the provided query constraints cannot be combined with the
|
|
4556
4556
|
* existing or new constraints.
|
|
4557
|
-
*/ function
|
|
4558
|
-
for (const
|
|
4557
|
+
*/ function nr(t, ...n) {
|
|
4558
|
+
for (const e of n) t = e._apply(t);
|
|
4559
4559
|
return t;
|
|
4560
4560
|
}
|
|
4561
4561
|
|
|
4562
|
-
class
|
|
4563
|
-
constructor(t,
|
|
4564
|
-
super(), this.dt = t, this.wt =
|
|
4562
|
+
class er extends tr {
|
|
4563
|
+
constructor(t, n, e) {
|
|
4564
|
+
super(), this.dt = t, this.wt = n, this.yt = e, this.type = "where";
|
|
4565
4565
|
}
|
|
4566
4566
|
_apply(t) {
|
|
4567
|
-
const
|
|
4567
|
+
const n = De(t.firestore), e = function(t, n, e, r, s, i, o) {
|
|
4568
4568
|
let u;
|
|
4569
4569
|
if (s.isKeyField()) {
|
|
4570
|
-
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new U(A, `Invalid Query. You can't perform '${i}' queries on
|
|
4570
|
+
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new U(A, `Invalid Query. You can't perform '${i}' queries on documentId().`);
|
|
4571
4571
|
if ("in" /* IN */ === i || "not-in" /* NOT_IN */ === i) {
|
|
4572
4572
|
yr(o, i);
|
|
4573
|
-
const
|
|
4574
|
-
for (const
|
|
4573
|
+
const n = [];
|
|
4574
|
+
for (const e of o) n.push(pr(r, t, e));
|
|
4575
4575
|
u = {
|
|
4576
4576
|
arrayValue: {
|
|
4577
|
-
values:
|
|
4577
|
+
values: n
|
|
4578
4578
|
}
|
|
4579
4579
|
};
|
|
4580
4580
|
} else u = pr(r, t, o);
|
|
4581
4581
|
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i || yr(o, i),
|
|
4582
|
-
u =
|
|
4582
|
+
u = Ue(e, n, o,
|
|
4583
4583
|
/* allowArrays= */ "in" /* IN */ === i || "not-in" /* NOT_IN */ === i);
|
|
4584
4584
|
const c = Wt.create(s, i, u);
|
|
4585
|
-
return function(t,
|
|
4586
|
-
if (
|
|
4587
|
-
const
|
|
4588
|
-
if (null !==
|
|
4589
|
-
const r =
|
|
4590
|
-
null !== r && _r(t,
|
|
4585
|
+
return function(t, n) {
|
|
4586
|
+
if (n.N()) {
|
|
4587
|
+
const e = hn(t);
|
|
4588
|
+
if (null !== e && !e.isEqual(n.field)) throw new U(A, `Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '${e.toString()}' and '${n.field.toString()}'`);
|
|
4589
|
+
const r = an(t);
|
|
4590
|
+
null !== r && _r(t, n.field, r);
|
|
4591
4591
|
}
|
|
4592
|
-
const
|
|
4593
|
-
for (const
|
|
4592
|
+
const e = function(t, n) {
|
|
4593
|
+
for (const e of t.filters) if (n.indexOf(e.op) >= 0) return e.op;
|
|
4594
4594
|
return null;
|
|
4595
4595
|
}(t,
|
|
4596
4596
|
/**
|
|
@@ -4625,16 +4625,16 @@ class nr extends tr {
|
|
|
4625
4625
|
default:
|
|
4626
4626
|
return [];
|
|
4627
4627
|
}
|
|
4628
|
-
}(
|
|
4629
|
-
if (null !==
|
|
4628
|
+
}(n.op));
|
|
4629
|
+
if (null !== e)
|
|
4630
4630
|
// Special case when it's a duplicate op to give a slightly clearer error message.
|
|
4631
|
-
throw
|
|
4631
|
+
throw e === n.op ? new U(A, `Invalid query. You cannot use more than one '${n.op.toString()}' filter.`) : new U(A, `Invalid query. You cannot use '${n.op.toString()}' filters with '${e.toString()}' filters.`);
|
|
4632
4632
|
}(t, c), c;
|
|
4633
|
-
}(t._query, "where",
|
|
4634
|
-
return new
|
|
4635
|
-
const
|
|
4636
|
-
return new
|
|
4637
|
-
}(t._query,
|
|
4633
|
+
}(t._query, "where", n, t.firestore._databaseId, this.dt, this.wt, this.yt);
|
|
4634
|
+
return new le(t.firestore, t.converter, function(t, n) {
|
|
4635
|
+
const e = t.filters.concat([ n ]);
|
|
4636
|
+
return new un(t.path, t.collectionGroup, t.explicitOrderBy.slice(), e, t.limit, t.limitType, t.startAt, t.endAt);
|
|
4637
|
+
}(t._query, e));
|
|
4638
4638
|
}
|
|
4639
4639
|
}
|
|
4640
4640
|
|
|
@@ -4648,25 +4648,25 @@ class nr extends tr {
|
|
|
4648
4648
|
* "<=", "!=").
|
|
4649
4649
|
* @param value - The value for comparison
|
|
4650
4650
|
* @returns The created {@link Query}.
|
|
4651
|
-
*/ function rr(t,
|
|
4652
|
-
const r =
|
|
4653
|
-
return new
|
|
4651
|
+
*/ function rr(t, n, e) {
|
|
4652
|
+
const r = n, s = Ze("where", t);
|
|
4653
|
+
return new er(s, r, e);
|
|
4654
4654
|
}
|
|
4655
4655
|
|
|
4656
4656
|
class sr extends tr {
|
|
4657
|
-
constructor(t,
|
|
4658
|
-
super(), this.dt = t, this._t =
|
|
4657
|
+
constructor(t, n) {
|
|
4658
|
+
super(), this.dt = t, this._t = n, this.type = "orderBy";
|
|
4659
4659
|
}
|
|
4660
4660
|
_apply(t) {
|
|
4661
|
-
const
|
|
4661
|
+
const n = function(t, n, e) {
|
|
4662
4662
|
if (null !== t.startAt) throw new U(A, "Invalid query. You must not call startAt() or startAfter() before calling orderBy().");
|
|
4663
4663
|
if (null !== t.endAt) throw new U(A, "Invalid query. You must not call endAt() or endBefore() before calling orderBy().");
|
|
4664
|
-
const r = new
|
|
4665
|
-
return function(t,
|
|
4666
|
-
if (null ===
|
|
4664
|
+
const r = new rn(n, e);
|
|
4665
|
+
return function(t, n) {
|
|
4666
|
+
if (null === an(t)) {
|
|
4667
4667
|
// This is the first order by. It must match any inequality.
|
|
4668
|
-
const
|
|
4669
|
-
null !==
|
|
4668
|
+
const e = hn(t);
|
|
4669
|
+
null !== e && _r(t, e, n.field);
|
|
4670
4670
|
}
|
|
4671
4671
|
}(t, r), r;
|
|
4672
4672
|
}
|
|
@@ -4681,11 +4681,11 @@ class sr extends tr {
|
|
|
4681
4681
|
* of the query or if any of the fields in the order by are an uncommitted
|
|
4682
4682
|
* server timestamp.
|
|
4683
4683
|
*/ (t._query, this.dt, this._t);
|
|
4684
|
-
return new
|
|
4684
|
+
return new le(t.firestore, t.converter, function(t, n) {
|
|
4685
4685
|
// TODO(dimond): validate that orderBy does not list the same key twice.
|
|
4686
|
-
const
|
|
4687
|
-
return new
|
|
4688
|
-
}(t._query,
|
|
4686
|
+
const e = t.explicitOrderBy.concat([ n ]);
|
|
4687
|
+
return new un(t.path, t.collectionGroup, e, t.filters.slice(), t.limit, t.limitType, t.startAt, t.endAt);
|
|
4688
|
+
}(t._query, n));
|
|
4689
4689
|
}
|
|
4690
4690
|
}
|
|
4691
4691
|
|
|
@@ -4697,18 +4697,18 @@ class sr extends tr {
|
|
|
4697
4697
|
* @param directionStr - Optional direction to sort by ('asc' or 'desc'). If
|
|
4698
4698
|
* not specified, order will be ascending.
|
|
4699
4699
|
* @returns The created {@link Query}.
|
|
4700
|
-
*/ function ir(t,
|
|
4701
|
-
const
|
|
4702
|
-
return new sr(r,
|
|
4700
|
+
*/ function ir(t, n = "asc") {
|
|
4701
|
+
const e = n, r = Ze("orderBy", t);
|
|
4702
|
+
return new sr(r, e);
|
|
4703
4703
|
}
|
|
4704
4704
|
|
|
4705
4705
|
class or extends tr {
|
|
4706
|
-
constructor(t,
|
|
4707
|
-
super(), this.type = t, this.gt =
|
|
4706
|
+
constructor(t, n, e) {
|
|
4707
|
+
super(), this.type = t, this.gt = n, this.vt = e;
|
|
4708
4708
|
}
|
|
4709
4709
|
_apply(t) {
|
|
4710
|
-
return new
|
|
4711
|
-
return new
|
|
4710
|
+
return new le(t.firestore, t.converter, function(t, n, e) {
|
|
4711
|
+
return new un(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), n, e, t.startAt, t.endAt);
|
|
4712
4712
|
}(t._query, this.gt, this.vt));
|
|
4713
4713
|
}
|
|
4714
4714
|
}
|
|
@@ -4735,14 +4735,14 @@ class or extends tr {
|
|
|
4735
4735
|
}
|
|
4736
4736
|
|
|
4737
4737
|
class ar extends tr {
|
|
4738
|
-
constructor(t,
|
|
4739
|
-
super(), this.type = t, this.bt =
|
|
4738
|
+
constructor(t, n, e) {
|
|
4739
|
+
super(), this.type = t, this.bt = n, this.Et = e;
|
|
4740
4740
|
}
|
|
4741
4741
|
_apply(t) {
|
|
4742
|
-
const
|
|
4743
|
-
return new
|
|
4744
|
-
return new
|
|
4745
|
-
}(t._query,
|
|
4742
|
+
const n = mr(t, this.type, this.bt, this.Et);
|
|
4743
|
+
return new le(t.firestore, t.converter, function(t, n) {
|
|
4744
|
+
return new un(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, n, t.endAt);
|
|
4745
|
+
}(t._query, n));
|
|
4746
4746
|
}
|
|
4747
4747
|
}
|
|
4748
4748
|
|
|
@@ -4756,14 +4756,14 @@ function lr(...t) {
|
|
|
4756
4756
|
}
|
|
4757
4757
|
|
|
4758
4758
|
class fr extends tr {
|
|
4759
|
-
constructor(t,
|
|
4760
|
-
super(), this.type = t, this.bt =
|
|
4759
|
+
constructor(t, n, e) {
|
|
4760
|
+
super(), this.type = t, this.bt = n, this.Et = e;
|
|
4761
4761
|
}
|
|
4762
4762
|
_apply(t) {
|
|
4763
|
-
const
|
|
4764
|
-
return new
|
|
4765
|
-
return new
|
|
4766
|
-
}(t._query,
|
|
4763
|
+
const n = mr(t, this.type, this.bt, this.Et);
|
|
4764
|
+
return new le(t.firestore, t.converter, function(t, n) {
|
|
4765
|
+
return new un(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, t.startAt, n);
|
|
4766
|
+
}(t._query, n));
|
|
4767
4767
|
}
|
|
4768
4768
|
}
|
|
4769
4769
|
|
|
@@ -4775,9 +4775,9 @@ function wr(...t) {
|
|
|
4775
4775
|
return new fr("endAt", t, /*before=*/ !1);
|
|
4776
4776
|
}
|
|
4777
4777
|
|
|
4778
|
-
/** Helper function to create a bound from a document or fields */ function mr(t,
|
|
4779
|
-
if (
|
|
4780
|
-
if (!r) throw new U(
|
|
4778
|
+
/** Helper function to create a bound from a document or fields */ function mr(t, n, e, r) {
|
|
4779
|
+
if (e[0] = getModularInstance(e[0]), e[0] instanceof He) return function(t, n, e, r, s) {
|
|
4780
|
+
if (!r) throw new U(P, `Can't use a DocumentSnapshot that doesn't exist for ${e}().`);
|
|
4781
4781
|
const i = [];
|
|
4782
4782
|
// Because people expect to continue/end a query at the exact document
|
|
4783
4783
|
// provided, we need to use the implicit sort order rather than the explicit
|
|
@@ -4786,23 +4786,23 @@ function wr(...t) {
|
|
|
4786
4786
|
// the provided document. Without the key (by using the explicit sort
|
|
4787
4787
|
// orders), multiple documents could match the position, yielding duplicate
|
|
4788
4788
|
// results.
|
|
4789
|
-
for (const
|
|
4790
|
-
const t = r.data.field(
|
|
4791
|
-
if (Dt(t)) throw new U(A, 'Invalid query. You are trying to start or end a query using a document for which the field "' +
|
|
4789
|
+
for (const e of fn(t)) if (e.field.isKeyField()) i.push(Ct(n, r.key)); else {
|
|
4790
|
+
const t = r.data.field(e.field);
|
|
4791
|
+
if (Dt(t)) throw new U(A, 'Invalid query. You are trying to start or end a query using a document for which the field "' + e.field + '" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');
|
|
4792
4792
|
if (null === t) {
|
|
4793
|
-
const t =
|
|
4793
|
+
const t = e.field.canonicalString();
|
|
4794
4794
|
throw new U(A, `Invalid query. You are trying to start or end a query using a document for which the field '${t}' (used as the orderBy) does not exist.`);
|
|
4795
4795
|
}
|
|
4796
4796
|
i.push(t);
|
|
4797
4797
|
}
|
|
4798
|
-
return new
|
|
4798
|
+
return new en(i, s);
|
|
4799
4799
|
}
|
|
4800
4800
|
/**
|
|
4801
4801
|
* Converts a list of field values to a `Bound` for the given query.
|
|
4802
|
-
*/ (t._query, t.firestore._databaseId,
|
|
4802
|
+
*/ (t._query, t.firestore._databaseId, n, e[0]._document, r);
|
|
4803
4803
|
{
|
|
4804
|
-
const s =
|
|
4805
|
-
return function(t,
|
|
4804
|
+
const s = De(t.firestore);
|
|
4805
|
+
return function(t, n, e, r, s, i) {
|
|
4806
4806
|
// Use explicit order by's because it has to match the query the user made
|
|
4807
4807
|
const o = t.explicitOrderBy;
|
|
4808
4808
|
if (s.length > o.length) throw new U(A, `Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);
|
|
@@ -4811,48 +4811,48 @@ function wr(...t) {
|
|
|
4811
4811
|
const c = s[i];
|
|
4812
4812
|
if (o[i].field.isKeyField()) {
|
|
4813
4813
|
if ("string" != typeof c) throw new U(A, `Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);
|
|
4814
|
-
if (!
|
|
4815
|
-
const
|
|
4816
|
-
if (!
|
|
4817
|
-
const s = new
|
|
4818
|
-
u.push(Ct(
|
|
4814
|
+
if (!ln(t) && -1 !== c.indexOf("/")) throw new U(A, `Invalid query. When querying a collection and ordering by documentId(), the value passed to ${r}() must be a plain document ID, but '${c}' contains a slash.`);
|
|
4815
|
+
const e = t.path.child(X.fromString(c));
|
|
4816
|
+
if (!nt.isDocumentKey(e)) throw new U(A, `Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${r}() must result in a valid document path, but '${e}' is not because it contains an odd number of segments.`);
|
|
4817
|
+
const s = new nt(e);
|
|
4818
|
+
u.push(Ct(n, s));
|
|
4819
4819
|
} else {
|
|
4820
|
-
const t =
|
|
4820
|
+
const t = Ue(e, r, c);
|
|
4821
4821
|
u.push(t);
|
|
4822
4822
|
}
|
|
4823
4823
|
}
|
|
4824
|
-
return new
|
|
4824
|
+
return new en(u, i);
|
|
4825
4825
|
}
|
|
4826
4826
|
/**
|
|
4827
4827
|
* Parses the given `documentIdValue` into a `ReferenceValue`, throwing
|
|
4828
4828
|
* appropriate errors if the value is anything other than a `DocumentReference`
|
|
4829
4829
|
* or `string`, or if the string is malformed.
|
|
4830
|
-
*/ (t._query, t.firestore._databaseId, s,
|
|
4830
|
+
*/ (t._query, t.firestore._databaseId, s, n, e, r);
|
|
4831
4831
|
}
|
|
4832
4832
|
}
|
|
4833
4833
|
|
|
4834
|
-
function pr(t,
|
|
4835
|
-
if ("string" == typeof (
|
|
4836
|
-
if ("" ===
|
|
4837
|
-
if (!
|
|
4838
|
-
const r =
|
|
4839
|
-
if (!
|
|
4840
|
-
return Ct(t, new
|
|
4834
|
+
function pr(t, n, e) {
|
|
4835
|
+
if ("string" == typeof (e = getModularInstance(e))) {
|
|
4836
|
+
if ("" === e) throw new U(A, "Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");
|
|
4837
|
+
if (!ln(n) && -1 !== e.indexOf("/")) throw new U(A, `Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${e}' contains a '/' character.`);
|
|
4838
|
+
const r = n.path.child(X.fromString(e));
|
|
4839
|
+
if (!nt.isDocumentKey(r)) throw new U(A, `Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);
|
|
4840
|
+
return Ct(t, new nt(r));
|
|
4841
4841
|
}
|
|
4842
|
-
if (
|
|
4843
|
-
throw new U(A, `Invalid query. When querying with
|
|
4842
|
+
if (e instanceof he) return Ct(t, e._key);
|
|
4843
|
+
throw new U(A, `Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${it(e)}.`);
|
|
4844
4844
|
}
|
|
4845
4845
|
|
|
4846
4846
|
/**
|
|
4847
4847
|
* Validates that the value passed into a disjunctive filter satisfies all
|
|
4848
4848
|
* array requirements.
|
|
4849
|
-
*/ function yr(t,
|
|
4850
|
-
if (!Array.isArray(t) || 0 === t.length) throw new U(A, `Invalid Query. A non-empty array is required for '${
|
|
4851
|
-
if (t.length > 10) throw new U(A, `Invalid Query. '${
|
|
4849
|
+
*/ function yr(t, n) {
|
|
4850
|
+
if (!Array.isArray(t) || 0 === t.length) throw new U(A, `Invalid Query. A non-empty array is required for '${n.toString()}' filters.`);
|
|
4851
|
+
if (t.length > 10) throw new U(A, `Invalid Query. '${n.toString()}' filters support a maximum of 10 elements in the value array.`);
|
|
4852
4852
|
}
|
|
4853
4853
|
|
|
4854
|
-
function _r(t,
|
|
4855
|
-
if (!
|
|
4854
|
+
function _r(t, n, e) {
|
|
4855
|
+
if (!e.isEqual(n)) throw new U(A, `Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '${n.toString()}' and so you must also use '${n.toString()}' as your first argument to orderBy(), but your first orderBy() is on field '${e.toString()}' instead.`);
|
|
4856
4856
|
}
|
|
4857
4857
|
|
|
4858
4858
|
/**
|
|
@@ -4902,18 +4902,18 @@ function _r(t, e, n) {
|
|
|
4902
4902
|
* their `set()` or fails due to invalid data originating from a `toFirestore()`
|
|
4903
4903
|
* call.
|
|
4904
4904
|
*/
|
|
4905
|
-
function gr(t,
|
|
4905
|
+
function gr(t, n, e) {
|
|
4906
4906
|
let r;
|
|
4907
4907
|
// Cast to `any` in order to satisfy the union type constraint on
|
|
4908
4908
|
// toFirestore().
|
|
4909
4909
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4910
|
-
return r = t ?
|
|
4910
|
+
return r = t ? e && (e.merge || e.mergeFields) ? t.toFirestore(n, e) : t.toFirestore(n) : n,
|
|
4911
4911
|
r;
|
|
4912
4912
|
}
|
|
4913
4913
|
|
|
4914
4914
|
class vr extends class {
|
|
4915
|
-
convertValue(t,
|
|
4916
|
-
switch (
|
|
4915
|
+
convertValue(t, n = "none") {
|
|
4916
|
+
switch (St(t)) {
|
|
4917
4917
|
case 0 /* NullValue */ :
|
|
4918
4918
|
return null;
|
|
4919
4919
|
|
|
@@ -4921,13 +4921,13 @@ class vr extends class {
|
|
|
4921
4921
|
return t.booleanValue;
|
|
4922
4922
|
|
|
4923
4923
|
case 2 /* NumberValue */ :
|
|
4924
|
-
return
|
|
4924
|
+
return Pt(t.integerValue || t.doubleValue);
|
|
4925
4925
|
|
|
4926
4926
|
case 3 /* TimestampValue */ :
|
|
4927
4927
|
return this.convertTimestamp(t.timestampValue);
|
|
4928
4928
|
|
|
4929
4929
|
case 4 /* ServerTimestampValue */ :
|
|
4930
|
-
return this.convertServerTimestamp(t,
|
|
4930
|
+
return this.convertServerTimestamp(t, n);
|
|
4931
4931
|
|
|
4932
4932
|
case 5 /* StringValue */ :
|
|
4933
4933
|
return t.stringValue;
|
|
@@ -4942,32 +4942,32 @@ class vr extends class {
|
|
|
4942
4942
|
return this.convertGeoPoint(t.geoPointValue);
|
|
4943
4943
|
|
|
4944
4944
|
case 9 /* ArrayValue */ :
|
|
4945
|
-
return this.convertArray(t.arrayValue,
|
|
4945
|
+
return this.convertArray(t.arrayValue, n);
|
|
4946
4946
|
|
|
4947
4947
|
case 10 /* ObjectValue */ :
|
|
4948
|
-
return this.convertObject(t.mapValue,
|
|
4948
|
+
return this.convertObject(t.mapValue, n);
|
|
4949
4949
|
|
|
4950
4950
|
default:
|
|
4951
4951
|
throw g();
|
|
4952
4952
|
}
|
|
4953
4953
|
}
|
|
4954
|
-
convertObject(t,
|
|
4955
|
-
const
|
|
4954
|
+
convertObject(t, n) {
|
|
4955
|
+
const e = {};
|
|
4956
4956
|
return Et(t.fields, ((t, r) => {
|
|
4957
|
-
|
|
4958
|
-
})),
|
|
4957
|
+
e[t] = this.convertValue(r, n);
|
|
4958
|
+
})), e;
|
|
4959
4959
|
}
|
|
4960
4960
|
convertGeoPoint(t) {
|
|
4961
|
-
return new
|
|
4961
|
+
return new Ee(Pt(t.latitude), Pt(t.longitude));
|
|
4962
4962
|
}
|
|
4963
|
-
convertArray(t,
|
|
4964
|
-
return (t.values || []).map((t => this.convertValue(t,
|
|
4963
|
+
convertArray(t, n) {
|
|
4964
|
+
return (t.values || []).map((t => this.convertValue(t, n)));
|
|
4965
4965
|
}
|
|
4966
|
-
convertServerTimestamp(t,
|
|
4967
|
-
switch (
|
|
4966
|
+
convertServerTimestamp(t, n) {
|
|
4967
|
+
switch (n) {
|
|
4968
4968
|
case "previous":
|
|
4969
|
-
const
|
|
4970
|
-
return null ==
|
|
4969
|
+
const e = Nt(t);
|
|
4970
|
+
return null == e ? null : this.convertValue(e, n);
|
|
4971
4971
|
|
|
4972
4972
|
case "estimate":
|
|
4973
4973
|
return this.convertTimestamp($t(t));
|
|
@@ -4977,16 +4977,16 @@ class vr extends class {
|
|
|
4977
4977
|
}
|
|
4978
4978
|
}
|
|
4979
4979
|
convertTimestamp(t) {
|
|
4980
|
-
const
|
|
4981
|
-
return new gt(
|
|
4980
|
+
const n = Rt(t);
|
|
4981
|
+
return new gt(n.seconds, n.nanos);
|
|
4982
4982
|
}
|
|
4983
|
-
convertDocumentKey(t,
|
|
4984
|
-
const
|
|
4985
|
-
v(
|
|
4986
|
-
const r = new K(
|
|
4987
|
-
return r.isEqual(
|
|
4983
|
+
convertDocumentKey(t, n) {
|
|
4984
|
+
const e = X.fromString(t);
|
|
4985
|
+
v(Hn(e));
|
|
4986
|
+
const r = new K(e.get(1), e.get(3)), s = new nt(e.popFirst(5));
|
|
4987
|
+
return r.isEqual(n) ||
|
|
4988
4988
|
// TODO(b/64130202): Somehow support foreign references.
|
|
4989
|
-
p(`Document ${s} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${
|
|
4989
|
+
p(`Document ${s} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${n.projectId}/${n.database}) instead.`),
|
|
4990
4990
|
s;
|
|
4991
4991
|
}
|
|
4992
4992
|
} {
|
|
@@ -4994,11 +4994,11 @@ class vr extends class {
|
|
|
4994
4994
|
super(), this.firestore = t;
|
|
4995
4995
|
}
|
|
4996
4996
|
convertBytes(t) {
|
|
4997
|
-
return new
|
|
4997
|
+
return new ve(t);
|
|
4998
4998
|
}
|
|
4999
4999
|
convertReference(t) {
|
|
5000
|
-
const
|
|
5001
|
-
return new
|
|
5000
|
+
const n = this.convertDocumentKey(t, this.firestore._databaseId);
|
|
5001
|
+
return new he(this.firestore, /* converter= */ null, n);
|
|
5002
5002
|
}
|
|
5003
5003
|
}
|
|
5004
5004
|
|
|
@@ -5015,11 +5015,11 @@ class vr extends class {
|
|
|
5015
5015
|
* @returns A Promise resolved with a `DocumentSnapshot` containing the current
|
|
5016
5016
|
* document contents.
|
|
5017
5017
|
*/ function br(t) {
|
|
5018
|
-
const
|
|
5019
|
-
return
|
|
5020
|
-
v(1 ===
|
|
5021
|
-
const r =
|
|
5022
|
-
return new
|
|
5018
|
+
const n = re((t = ot(t, he)).firestore), e = new vr(t.firestore);
|
|
5019
|
+
return te(n, [ t._key ]).then((n => {
|
|
5020
|
+
v(1 === n.length);
|
|
5021
|
+
const r = n[0];
|
|
5022
|
+
return new He(t.firestore, e, t._key, r.isFoundDocument() ? r : null, t.converter);
|
|
5023
5023
|
}));
|
|
5024
5024
|
}
|
|
5025
5025
|
|
|
@@ -5036,31 +5036,31 @@ class vr extends class {
|
|
|
5036
5036
|
* @returns A Promise that will be resolved with the results of the query.
|
|
5037
5037
|
*/ function Er(t) {
|
|
5038
5038
|
!function(t) {
|
|
5039
|
-
if (
|
|
5040
|
-
}((t = ot(t,
|
|
5041
|
-
const
|
|
5042
|
-
return
|
|
5043
|
-
const r =
|
|
5044
|
-
return
|
|
5039
|
+
if (cn(t) && 0 === t.explicitOrderBy.length) throw new U(q, "limitToLast() queries require specifying at least one orderBy() clause");
|
|
5040
|
+
}((t = ot(t, le))._query);
|
|
5041
|
+
const n = re(t.firestore), e = new vr(t.firestore);
|
|
5042
|
+
return ne(n, t._query).then((n => {
|
|
5043
|
+
const r = n.map((n => new Ke(t.firestore, e, n.key, n, t.converter)));
|
|
5044
|
+
return cn(t._query) &&
|
|
5045
5045
|
// Limit to last queries reverse the orderBy constraint that was
|
|
5046
5046
|
// specified by the user. As such, we need to reverse the order of the
|
|
5047
5047
|
// results to return the documents in the expected order.
|
|
5048
|
-
r.reverse(), new
|
|
5048
|
+
r.reverse(), new Je(t, r);
|
|
5049
5049
|
}));
|
|
5050
5050
|
}
|
|
5051
5051
|
|
|
5052
|
-
function Tr(t,
|
|
5053
|
-
const r = gr((t = ot(t,
|
|
5054
|
-
return
|
|
5052
|
+
function Tr(t, n, e) {
|
|
5053
|
+
const r = gr((t = ot(t, he)).converter, n, e), s = Ne(De(t.firestore), "setDoc", t._key, r, null !== t.converter, e);
|
|
5054
|
+
return Zn(re(t.firestore), [ s.toMutation(t._key, En.none()) ]);
|
|
5055
5055
|
}
|
|
5056
5056
|
|
|
5057
|
-
function Ir(t,
|
|
5058
|
-
const s =
|
|
5057
|
+
function Ir(t, n, e, ...r) {
|
|
5058
|
+
const s = De((t = ot(t, he)).firestore);
|
|
5059
5059
|
// For Compat types, we have to "extract" the underlying types before
|
|
5060
5060
|
// performing validation.
|
|
5061
5061
|
let i;
|
|
5062
|
-
i = "string" == typeof (
|
|
5063
|
-
return
|
|
5062
|
+
i = "string" == typeof (n = getModularInstance(n)) || n instanceof _e ? Le(s, "updateDoc", t._key, n, e, r) : Ce(s, "updateDoc", t._key, n);
|
|
5063
|
+
return Zn(re(t.firestore), [ i.toMutation(t._key, En.exists(!0)) ]);
|
|
5064
5064
|
}
|
|
5065
5065
|
|
|
5066
5066
|
/**
|
|
@@ -5075,7 +5075,7 @@ function Ir(t, e, n, ...r) {
|
|
|
5075
5075
|
* @returns A `Promise` resolved once the document has been successfully
|
|
5076
5076
|
* deleted from the backend.
|
|
5077
5077
|
*/ function Ar(t) {
|
|
5078
|
-
return
|
|
5078
|
+
return Zn(re((t = ot(t, he)).firestore), [ new Rn(t._key, En.none()) ]);
|
|
5079
5079
|
}
|
|
5080
5080
|
|
|
5081
5081
|
/**
|
|
@@ -5092,9 +5092,9 @@ function Ir(t, e, n, ...r) {
|
|
|
5092
5092
|
* @throws Error - If the provided input is not a valid Firestore document.
|
|
5093
5093
|
* @returns A `Promise` resolved with a `DocumentReference` pointing to the
|
|
5094
5094
|
* newly created document after it has been written to the backend.
|
|
5095
|
-
*/ function
|
|
5096
|
-
const
|
|
5097
|
-
return
|
|
5095
|
+
*/ function Rr(t, n) {
|
|
5096
|
+
const e = me(t = ot(t, fe)), r = gr(t.converter, n), s = Ne(De(t.firestore), "addDoc", e._key, r, null !== e.converter, {});
|
|
5097
|
+
return Zn(re(t.firestore), [ s.toMutation(e._key, En.exists(!1)) ]).then((() => e));
|
|
5098
5098
|
}
|
|
5099
5099
|
|
|
5100
5100
|
/**
|
|
@@ -5116,15 +5116,15 @@ function Ir(t, e, n, ...r) {
|
|
|
5116
5116
|
/**
|
|
5117
5117
|
* Returns a sentinel for use with {@link @firebase/firestore/lite#(updateDoc:1)} or
|
|
5118
5118
|
* {@link @firebase/firestore/lite#(setDoc:1)} with `{merge: true}` to mark a field for deletion.
|
|
5119
|
-
*/ function
|
|
5120
|
-
return new $
|
|
5119
|
+
*/ function Pr() {
|
|
5120
|
+
return new $e("deleteField");
|
|
5121
5121
|
}
|
|
5122
5122
|
|
|
5123
5123
|
/**
|
|
5124
5124
|
* Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
|
|
5125
5125
|
* include a server-generated timestamp in the written data.
|
|
5126
5126
|
*/ function Vr() {
|
|
5127
|
-
return new
|
|
5127
|
+
return new Fe("serverTimestamp");
|
|
5128
5128
|
}
|
|
5129
5129
|
|
|
5130
5130
|
/**
|
|
@@ -5141,7 +5141,7 @@ function Ir(t, e, n, ...r) {
|
|
|
5141
5141
|
*/ function Dr(...t) {
|
|
5142
5142
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5143
5143
|
// update() since we'd need the Firestore instance to do this.
|
|
5144
|
-
return new
|
|
5144
|
+
return new xe("arrayUnion", t);
|
|
5145
5145
|
}
|
|
5146
5146
|
|
|
5147
5147
|
/**
|
|
@@ -5157,7 +5157,7 @@ function Ir(t, e, n, ...r) {
|
|
|
5157
5157
|
*/ function Nr(...t) {
|
|
5158
5158
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5159
5159
|
// update() since we'd need the Firestore instance to do this.
|
|
5160
|
-
return new
|
|
5160
|
+
return new qe("arrayRemove", t);
|
|
5161
5161
|
}
|
|
5162
5162
|
|
|
5163
5163
|
/**
|
|
@@ -5179,7 +5179,7 @@ function Ir(t, e, n, ...r) {
|
|
|
5179
5179
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5180
5180
|
* `updateDoc()`
|
|
5181
5181
|
*/ function $r(t) {
|
|
5182
|
-
return new
|
|
5182
|
+
return new Oe("increment", t);
|
|
5183
5183
|
}
|
|
5184
5184
|
|
|
5185
5185
|
/**
|
|
@@ -5205,25 +5205,25 @@ function Ir(t, e, n, ...r) {
|
|
|
5205
5205
|
* provides methods for adding writes to the write batch. None of the writes
|
|
5206
5206
|
* will be committed (or visible locally) until {@link WriteBatch.commit} is
|
|
5207
5207
|
* called.
|
|
5208
|
-
*/ class
|
|
5208
|
+
*/ class Sr {
|
|
5209
5209
|
/** @hideconstructor */
|
|
5210
|
-
constructor(t,
|
|
5211
|
-
this._firestore = t, this._commitHandler =
|
|
5212
|
-
this._dataReader =
|
|
5210
|
+
constructor(t, n) {
|
|
5211
|
+
this._firestore = t, this._commitHandler = n, this._mutations = [], this._committed = !1,
|
|
5212
|
+
this._dataReader = De(t);
|
|
5213
5213
|
}
|
|
5214
|
-
set(t,
|
|
5214
|
+
set(t, n, e) {
|
|
5215
5215
|
this._verifyNotCommitted();
|
|
5216
|
-
const r =
|
|
5217
|
-
return this._mutations.push(i.toMutation(r._key,
|
|
5216
|
+
const r = Fr(t, this._firestore), s = gr(r.converter, n, e), i = Ne(this._dataReader, "WriteBatch.set", r._key, s, null !== r.converter, e);
|
|
5217
|
+
return this._mutations.push(i.toMutation(r._key, En.none())), this;
|
|
5218
5218
|
}
|
|
5219
|
-
update(t,
|
|
5219
|
+
update(t, n, e, ...r) {
|
|
5220
5220
|
this._verifyNotCommitted();
|
|
5221
|
-
const s =
|
|
5221
|
+
const s = Fr(t, this._firestore);
|
|
5222
5222
|
// For Compat types, we have to "extract" the underlying types before
|
|
5223
5223
|
// performing validation.
|
|
5224
5224
|
let i;
|
|
5225
|
-
return i = "string" == typeof (
|
|
5226
|
-
this._mutations.push(i.toMutation(s._key,
|
|
5225
|
+
return i = "string" == typeof (n = getModularInstance(n)) || n instanceof _e ? Le(this._dataReader, "WriteBatch.update", s._key, n, e, r) : Ce(this._dataReader, "WriteBatch.update", s._key, n),
|
|
5226
|
+
this._mutations.push(i.toMutation(s._key, En.exists(!0))), this;
|
|
5227
5227
|
}
|
|
5228
5228
|
/**
|
|
5229
5229
|
* Deletes the document referred to by the provided {@link DocumentReference}.
|
|
@@ -5232,8 +5232,8 @@ function Ir(t, e, n, ...r) {
|
|
|
5232
5232
|
* @returns This `WriteBatch` instance. Used for chaining method calls.
|
|
5233
5233
|
*/ delete(t) {
|
|
5234
5234
|
this._verifyNotCommitted();
|
|
5235
|
-
const
|
|
5236
|
-
return this._mutations = this._mutations.concat(new
|
|
5235
|
+
const n = Fr(t, this._firestore);
|
|
5236
|
+
return this._mutations = this._mutations.concat(new Rn(n._key, En.none())), this;
|
|
5237
5237
|
}
|
|
5238
5238
|
/**
|
|
5239
5239
|
* Commits all of the writes in this write batch as a single atomic unit.
|
|
@@ -5250,12 +5250,12 @@ function Ir(t, e, n, ...r) {
|
|
|
5250
5250
|
return this._verifyNotCommitted(), this._committed = !0, this._mutations.length > 0 ? this._commitHandler(this._mutations) : Promise.resolve();
|
|
5251
5251
|
}
|
|
5252
5252
|
_verifyNotCommitted() {
|
|
5253
|
-
if (this._committed) throw new U(
|
|
5253
|
+
if (this._committed) throw new U(S, "A write batch can no longer be used after commit() has been called.");
|
|
5254
5254
|
}
|
|
5255
5255
|
}
|
|
5256
5256
|
|
|
5257
|
-
function
|
|
5258
|
-
if ((t = getModularInstance(t)).firestore !==
|
|
5257
|
+
function Fr(t, n) {
|
|
5258
|
+
if ((t = getModularInstance(t)).firestore !== n) throw new U(A, "Provided document reference is from a different Firestore instance.");
|
|
5259
5259
|
return t;
|
|
5260
5260
|
}
|
|
5261
5261
|
|
|
@@ -5272,8 +5272,8 @@ function Sr(t, e) {
|
|
|
5272
5272
|
* @returns A `WriteBatch` that can be used to atomically execute multiple
|
|
5273
5273
|
* writes.
|
|
5274
5274
|
*/ function xr(t) {
|
|
5275
|
-
const
|
|
5276
|
-
return new
|
|
5275
|
+
const n = re(t = ot(t, ie));
|
|
5276
|
+
return new Sr(t, (t => Zn(n, t)));
|
|
5277
5277
|
}
|
|
5278
5278
|
|
|
5279
5279
|
/**
|
|
@@ -5315,66 +5315,66 @@ function Sr(t, e) {
|
|
|
5315
5315
|
}
|
|
5316
5316
|
async lookup(t) {
|
|
5317
5317
|
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new U(A, "Firestore transactions require all reads to be executed before all writes.");
|
|
5318
|
-
const
|
|
5319
|
-
return
|
|
5318
|
+
const n = await te(this.datastore, t);
|
|
5319
|
+
return n.forEach((t => this.recordVersion(t))), n;
|
|
5320
5320
|
}
|
|
5321
|
-
set(t,
|
|
5322
|
-
this.write(
|
|
5321
|
+
set(t, n) {
|
|
5322
|
+
this.write(n.toMutation(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5323
5323
|
}
|
|
5324
|
-
update(t,
|
|
5324
|
+
update(t, n) {
|
|
5325
5325
|
try {
|
|
5326
|
-
this.write(
|
|
5326
|
+
this.write(n.toMutation(t, this.preconditionForUpdate(t)));
|
|
5327
5327
|
} catch (t) {
|
|
5328
5328
|
this.lastWriteError = t;
|
|
5329
5329
|
}
|
|
5330
5330
|
this.writtenDocs.add(t.toString());
|
|
5331
5331
|
}
|
|
5332
5332
|
delete(t) {
|
|
5333
|
-
this.write(new
|
|
5333
|
+
this.write(new Rn(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5334
5334
|
}
|
|
5335
5335
|
async commit() {
|
|
5336
5336
|
if (this.ensureCommitNotCalled(), this.lastWriteError) throw this.lastWriteError;
|
|
5337
5337
|
const t = this.readVersions;
|
|
5338
5338
|
// For each mutation, note that the doc was written.
|
|
5339
|
-
this.mutations.forEach((
|
|
5340
|
-
t.delete(
|
|
5339
|
+
this.mutations.forEach((n => {
|
|
5340
|
+
t.delete(n.key.toString());
|
|
5341
5341
|
})),
|
|
5342
5342
|
// For each document that was read but not written to, we want to perform
|
|
5343
5343
|
// a `verify` operation.
|
|
5344
|
-
t.forEach(((t,
|
|
5345
|
-
const
|
|
5346
|
-
this.mutations.push(new
|
|
5347
|
-
})), await
|
|
5344
|
+
t.forEach(((t, n) => {
|
|
5345
|
+
const e = nt.fromPath(n);
|
|
5346
|
+
this.mutations.push(new Pn(e, this.precondition(e)));
|
|
5347
|
+
})), await Zn(this.datastore, this.mutations), this.committed = !0;
|
|
5348
5348
|
}
|
|
5349
5349
|
recordVersion(t) {
|
|
5350
|
-
let
|
|
5351
|
-
if (t.isFoundDocument())
|
|
5350
|
+
let n;
|
|
5351
|
+
if (t.isFoundDocument()) n = t.version; else {
|
|
5352
5352
|
if (!t.isNoDocument()) throw g();
|
|
5353
5353
|
// For deleted docs, we must use baseVersion 0 when we overwrite them.
|
|
5354
|
-
|
|
5354
|
+
n = vt.min();
|
|
5355
5355
|
}
|
|
5356
|
-
const
|
|
5357
|
-
if (
|
|
5358
|
-
if (!
|
|
5356
|
+
const e = this.readVersions.get(t.key.toString());
|
|
5357
|
+
if (e) {
|
|
5358
|
+
if (!n.isEqual(e))
|
|
5359
5359
|
// This transaction will fail no matter what.
|
|
5360
|
-
throw new U(
|
|
5361
|
-
} else this.readVersions.set(t.key.toString(),
|
|
5360
|
+
throw new U(F, "Document version changed between two reads.");
|
|
5361
|
+
} else this.readVersions.set(t.key.toString(), n);
|
|
5362
5362
|
}
|
|
5363
5363
|
/**
|
|
5364
5364
|
* Returns the version of this document when it was read in this transaction,
|
|
5365
5365
|
* as a precondition, or no precondition if it was not read.
|
|
5366
5366
|
*/ precondition(t) {
|
|
5367
|
-
const
|
|
5368
|
-
return !this.writtenDocs.has(t.toString()) &&
|
|
5367
|
+
const n = this.readVersions.get(t.toString());
|
|
5368
|
+
return !this.writtenDocs.has(t.toString()) && n ? En.updateTime(n) : En.none();
|
|
5369
5369
|
}
|
|
5370
5370
|
/**
|
|
5371
5371
|
* Returns the precondition for a document if the operation is an update.
|
|
5372
5372
|
*/ preconditionForUpdate(t) {
|
|
5373
|
-
const
|
|
5373
|
+
const n = this.readVersions.get(t.toString());
|
|
5374
5374
|
// The first time a document is written, we want to take into account the
|
|
5375
5375
|
// read time and existence
|
|
5376
|
-
if (!this.writtenDocs.has(t.toString()) &&
|
|
5377
|
-
if (
|
|
5376
|
+
if (!this.writtenDocs.has(t.toString()) && n) {
|
|
5377
|
+
if (n.isEqual(vt.min()))
|
|
5378
5378
|
// The document doesn't exist, so fail the transaction.
|
|
5379
5379
|
// This has to be validated locally because you can't send a
|
|
5380
5380
|
// precondition that a document does not exist without changing the
|
|
@@ -5386,11 +5386,11 @@ function Sr(t, e) {
|
|
|
5386
5386
|
// transaction.
|
|
5387
5387
|
throw new U(A, "Can't update a document that doesn't exist.");
|
|
5388
5388
|
// Document exists, base precondition on document update time.
|
|
5389
|
-
return
|
|
5389
|
+
return En.updateTime(n);
|
|
5390
5390
|
}
|
|
5391
5391
|
// Document was not read, so we just use the preconditions for a blind
|
|
5392
5392
|
// update.
|
|
5393
|
-
return
|
|
5393
|
+
return En.exists(!0);
|
|
5394
5394
|
}
|
|
5395
5395
|
write(t) {
|
|
5396
5396
|
this.ensureCommitNotCalled(), this.mutations.push(t);
|
|
@@ -5419,38 +5419,38 @@ function Sr(t, e) {
|
|
|
5419
5419
|
* with backoff.
|
|
5420
5420
|
*/
|
|
5421
5421
|
class Or {
|
|
5422
|
-
constructor(t,
|
|
5423
|
-
this.asyncQueue = t, this.datastore =
|
|
5424
|
-
this.Tt = 5, this.It = new
|
|
5422
|
+
constructor(t, n, e, r) {
|
|
5423
|
+
this.asyncQueue = t, this.datastore = n, this.updateFunction = e, this.deferred = r,
|
|
5424
|
+
this.Tt = 5, this.It = new Jn(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
|
|
5425
5425
|
}
|
|
5426
5426
|
/** Runs the transaction and sets the result on deferred. */ run() {
|
|
5427
5427
|
this.Tt -= 1, this.At();
|
|
5428
5428
|
}
|
|
5429
5429
|
At() {
|
|
5430
5430
|
this.It.W((async () => {
|
|
5431
|
-
const t = new qr(this.datastore),
|
|
5432
|
-
|
|
5431
|
+
const t = new qr(this.datastore), n = this.Rt(t);
|
|
5432
|
+
n && n.then((n => {
|
|
5433
5433
|
this.asyncQueue.enqueueAndForget((() => t.commit().then((() => {
|
|
5434
|
-
this.deferred.resolve(
|
|
5434
|
+
this.deferred.resolve(n);
|
|
5435
5435
|
})).catch((t => {
|
|
5436
|
-
this.
|
|
5436
|
+
this.Pt(t);
|
|
5437
5437
|
}))));
|
|
5438
5438
|
})).catch((t => {
|
|
5439
|
-
this.
|
|
5439
|
+
this.Pt(t);
|
|
5440
5440
|
}));
|
|
5441
5441
|
}));
|
|
5442
5442
|
}
|
|
5443
|
-
|
|
5443
|
+
Rt(t) {
|
|
5444
5444
|
try {
|
|
5445
|
-
const
|
|
5446
|
-
return !ct(
|
|
5445
|
+
const n = this.updateFunction(t);
|
|
5446
|
+
return !ct(n) && n.catch && n.then ? n : (this.deferred.reject(Error("Transaction callback must return a Promise")),
|
|
5447
5447
|
null);
|
|
5448
5448
|
} catch (t) {
|
|
5449
5449
|
// Do not retry errors thrown by user provided updateFunction.
|
|
5450
5450
|
return this.deferred.reject(t), null;
|
|
5451
5451
|
}
|
|
5452
5452
|
}
|
|
5453
|
-
|
|
5453
|
+
Pt(t) {
|
|
5454
5454
|
this.Tt > 0 && this.Vt(t) ? (this.Tt -= 1, this.asyncQueue.enqueueAndForget((() => (this.At(),
|
|
5455
5455
|
Promise.resolve())))) : this.deferred.reject(t);
|
|
5456
5456
|
}
|
|
@@ -5458,8 +5458,8 @@ class Or {
|
|
|
5458
5458
|
if ("FirebaseError" === t.name) {
|
|
5459
5459
|
// In transactions, the backend will fail outdated reads with FAILED_PRECONDITION and
|
|
5460
5460
|
// non-matching document versions with ABORTED. These errors should be retried.
|
|
5461
|
-
const
|
|
5462
|
-
return "aborted" ===
|
|
5461
|
+
const n = t.code;
|
|
5462
|
+
return "aborted" === n || "failed-precondition" === n || !
|
|
5463
5463
|
/**
|
|
5464
5464
|
* Determines whether an error code represents a permanent error when received
|
|
5465
5465
|
* in response to a non-write operation.
|
|
@@ -5473,7 +5473,7 @@ class Or {
|
|
|
5473
5473
|
|
|
5474
5474
|
case T:
|
|
5475
5475
|
case I:
|
|
5476
|
-
case
|
|
5476
|
+
case R:
|
|
5477
5477
|
case $:
|
|
5478
5478
|
case O:
|
|
5479
5479
|
case C:
|
|
@@ -5483,20 +5483,20 @@ class Or {
|
|
|
5483
5483
|
return !1;
|
|
5484
5484
|
|
|
5485
5485
|
case A:
|
|
5486
|
-
case
|
|
5486
|
+
case P:
|
|
5487
5487
|
case V:
|
|
5488
5488
|
case D:
|
|
5489
|
-
case
|
|
5489
|
+
case S:
|
|
5490
5490
|
// Aborted might be retried in some scenarios, but that is dependant on
|
|
5491
5491
|
// the context and should handled individually by the calling code.
|
|
5492
5492
|
// See https://cloud.google.com/apis/design/errors.
|
|
5493
|
-
case
|
|
5493
|
+
case F:
|
|
5494
5494
|
case x:
|
|
5495
5495
|
case q:
|
|
5496
5496
|
case L:
|
|
5497
5497
|
return !0;
|
|
5498
5498
|
}
|
|
5499
|
-
}(
|
|
5499
|
+
}(n);
|
|
5500
5500
|
}
|
|
5501
5501
|
return !1;
|
|
5502
5502
|
}
|
|
@@ -5551,8 +5551,8 @@ class Or {
|
|
|
5551
5551
|
* in newer versions of TypeScript defines `finally`, which is not available in
|
|
5552
5552
|
* IE.
|
|
5553
5553
|
*/ class Lr {
|
|
5554
|
-
constructor(t,
|
|
5555
|
-
this.asyncQueue = t, this.timerId =
|
|
5554
|
+
constructor(t, n, e, r, s) {
|
|
5555
|
+
this.asyncQueue = t, this.timerId = n, this.targetTimeMs = e, this.op = r, this.removalCallback = s,
|
|
5556
5556
|
this.deferred = new k, this.then = this.deferred.promise.then.bind(this.deferred.promise),
|
|
5557
5557
|
// It's normal for the deferred promise to be canceled (due to cancellation)
|
|
5558
5558
|
// and so we attach a dummy catch callback to avoid
|
|
@@ -5572,9 +5572,9 @@ class Or {
|
|
|
5572
5572
|
* from its delayedOperations list.
|
|
5573
5573
|
* PORTING NOTE: This exists to prevent making removeDelayedOperation() and
|
|
5574
5574
|
* the DelayedOperation class public.
|
|
5575
|
-
*/ static createAndSchedule(t,
|
|
5576
|
-
const i = Date.now() +
|
|
5577
|
-
return o.start(
|
|
5575
|
+
*/ static createAndSchedule(t, n, e, r, s) {
|
|
5576
|
+
const i = Date.now() + e, o = new Lr(t, n, i, r, s);
|
|
5577
|
+
return o.start(e), o;
|
|
5578
5578
|
}
|
|
5579
5579
|
/**
|
|
5580
5580
|
* Starts the timer. This is called immediately after construction by
|
|
@@ -5634,9 +5634,9 @@ class Or {
|
|
|
5634
5634
|
this.$t = !1,
|
|
5635
5635
|
// Operations scheduled to be queued in the future. Operations are
|
|
5636
5636
|
// automatically removed after they are run or canceled.
|
|
5637
|
-
this.
|
|
5637
|
+
this.St = [],
|
|
5638
5638
|
// visible for testing
|
|
5639
|
-
this.
|
|
5639
|
+
this.Ft = null,
|
|
5640
5640
|
// Flag set while there's an outstanding AsyncQueue operation, used for
|
|
5641
5641
|
// assertion sanity-checks.
|
|
5642
5642
|
this.xt = !1,
|
|
@@ -5645,7 +5645,7 @@ class Or {
|
|
|
5645
5645
|
// List of TimerIds to fast-forward delays for.
|
|
5646
5646
|
this.Ot = [],
|
|
5647
5647
|
// Backoff timer used to schedule retries for retryable operations
|
|
5648
|
-
this.It = new
|
|
5648
|
+
this.It = new Jn(this, "async_queue_retry" /* AsyncQueueRetry */),
|
|
5649
5649
|
// Visibility handler that triggers an immediate retry of all retryable
|
|
5650
5650
|
// operations. Meant to speed up recovery when we regain file system access
|
|
5651
5651
|
// after page comes into foreground.
|
|
@@ -5674,8 +5674,8 @@ class Or {
|
|
|
5674
5674
|
enterRestrictedMode(t) {
|
|
5675
5675
|
if (!this.$t) {
|
|
5676
5676
|
this.$t = !0, this.qt = t || !1;
|
|
5677
|
-
const
|
|
5678
|
-
|
|
5677
|
+
const n = Cr();
|
|
5678
|
+
n && "function" == typeof n.removeEventListener && n.removeEventListener("visibilitychange", this.Ct);
|
|
5679
5679
|
}
|
|
5680
5680
|
}
|
|
5681
5681
|
enqueue(t) {
|
|
@@ -5685,9 +5685,9 @@ class Or {
|
|
|
5685
5685
|
// Create a deferred Promise that we can return to the callee. This
|
|
5686
5686
|
// allows us to return a "hanging Promise" only to the callee and still
|
|
5687
5687
|
// advance the queue even when the operation is not run.
|
|
5688
|
-
const
|
|
5689
|
-
return this.Ut((() => this.$t && this.qt ? Promise.resolve() : (t().then(
|
|
5690
|
-
|
|
5688
|
+
const n = new k;
|
|
5689
|
+
return this.Ut((() => this.$t && this.qt ? Promise.resolve() : (t().then(n.resolve, n.reject),
|
|
5690
|
+
n.promise))).then((() => n.promise));
|
|
5691
5691
|
}
|
|
5692
5692
|
enqueueRetryable(t) {
|
|
5693
5693
|
this.enqueueAndForget((() => (this.Nt.push(t), this.kt())));
|
|
@@ -5757,18 +5757,18 @@ class Or {
|
|
|
5757
5757
|
}
|
|
5758
5758
|
}
|
|
5759
5759
|
Ut(t) {
|
|
5760
|
-
const
|
|
5761
|
-
this.
|
|
5762
|
-
const
|
|
5760
|
+
const n = this.Dt.then((() => (this.xt = !0, t().catch((t => {
|
|
5761
|
+
this.Ft = t, this.xt = !1;
|
|
5762
|
+
const n =
|
|
5763
5763
|
/**
|
|
5764
5764
|
* Chrome includes Error.message in Error.stack. Other browsers do not.
|
|
5765
5765
|
* This returns expected output of message + stack when available.
|
|
5766
5766
|
* @param error - Error or FirestoreError
|
|
5767
5767
|
*/
|
|
5768
5768
|
function(t) {
|
|
5769
|
-
let
|
|
5770
|
-
t.stack && (
|
|
5771
|
-
return
|
|
5769
|
+
let n = t.message || "";
|
|
5770
|
+
t.stack && (n = t.stack.includes(t.message) ? t.stack : t.message + "\n" + t.stack);
|
|
5771
|
+
return n;
|
|
5772
5772
|
}
|
|
5773
5773
|
/**
|
|
5774
5774
|
* @license
|
|
@@ -5798,19 +5798,19 @@ class Or {
|
|
|
5798
5798
|
// Re-throw the error so that this.tail becomes a rejected Promise and
|
|
5799
5799
|
// all further attempts to chain (via .then) will just short-circuit
|
|
5800
5800
|
// and return the rejected Promise.
|
|
5801
|
-
throw p("INTERNAL UNHANDLED ERROR: ",
|
|
5801
|
+
throw p("INTERNAL UNHANDLED ERROR: ", n), t;
|
|
5802
5802
|
})).then((t => (this.xt = !1, t))))));
|
|
5803
|
-
return this.Dt =
|
|
5803
|
+
return this.Dt = n, n;
|
|
5804
5804
|
}
|
|
5805
|
-
enqueueAfterDelay(t,
|
|
5805
|
+
enqueueAfterDelay(t, n, e) {
|
|
5806
5806
|
this.Lt(),
|
|
5807
5807
|
// Fast-forward delays for timerIds that have been overriden.
|
|
5808
|
-
this.Ot.indexOf(t) > -1 && (
|
|
5809
|
-
const r = Lr.createAndSchedule(this, t,
|
|
5810
|
-
return this.
|
|
5808
|
+
this.Ot.indexOf(t) > -1 && (n = 0);
|
|
5809
|
+
const r = Lr.createAndSchedule(this, t, n, e, (t => this.jt(t)));
|
|
5810
|
+
return this.St.push(r), r;
|
|
5811
5811
|
}
|
|
5812
5812
|
Lt() {
|
|
5813
|
-
this.
|
|
5813
|
+
this.Ft && g();
|
|
5814
5814
|
}
|
|
5815
5815
|
verifyOperationInProgress() {}
|
|
5816
5816
|
/**
|
|
@@ -5830,7 +5830,7 @@ class Or {
|
|
|
5830
5830
|
* For Tests: Determine if a delayed operation with a particular TimerId
|
|
5831
5831
|
* exists.
|
|
5832
5832
|
*/ Bt(t) {
|
|
5833
|
-
for (const
|
|
5833
|
+
for (const n of this.St) if (n.timerId === t) return !0;
|
|
5834
5834
|
return !1;
|
|
5835
5835
|
}
|
|
5836
5836
|
/**
|
|
@@ -5843,8 +5843,8 @@ class Or {
|
|
|
5843
5843
|
// Note that draining may generate more delayed ops, so we do that first.
|
|
5844
5844
|
return this.Mt().then((() => {
|
|
5845
5845
|
// Run ops in the same order they'd run if they ran naturally.
|
|
5846
|
-
this.
|
|
5847
|
-
for (const
|
|
5846
|
+
this.St.sort(((t, n) => t.targetTimeMs - n.targetTimeMs));
|
|
5847
|
+
for (const n of this.St) if (n.skipDelay(), "all" /* All */ !== t && n.timerId === t) break;
|
|
5848
5848
|
return this.Mt();
|
|
5849
5849
|
}));
|
|
5850
5850
|
}
|
|
@@ -5855,15 +5855,15 @@ class Or {
|
|
|
5855
5855
|
}
|
|
5856
5856
|
/** Called once a DelayedOperation is run or canceled. */ jt(t) {
|
|
5857
5857
|
// NOTE: indexOf / slice are O(n), but delayedOperations is expected to be small.
|
|
5858
|
-
const
|
|
5859
|
-
this.
|
|
5858
|
+
const n = this.St.indexOf(t);
|
|
5859
|
+
this.St.splice(n, 1);
|
|
5860
5860
|
}
|
|
5861
5861
|
}
|
|
5862
5862
|
|
|
5863
5863
|
class kr {
|
|
5864
5864
|
/** @hideconstructor */
|
|
5865
|
-
constructor(t,
|
|
5866
|
-
this._firestore = t, this._transaction =
|
|
5865
|
+
constructor(t, n) {
|
|
5866
|
+
this._firestore = t, this._transaction = n, this._dataReader = De(t);
|
|
5867
5867
|
}
|
|
5868
5868
|
/**
|
|
5869
5869
|
* Reads the document referenced by the provided {@link DocumentReference}.
|
|
@@ -5871,25 +5871,25 @@ class kr {
|
|
|
5871
5871
|
* @param documentRef - A reference to the document to be read.
|
|
5872
5872
|
* @returns A `DocumentSnapshot` with the read data.
|
|
5873
5873
|
*/ get(t) {
|
|
5874
|
-
const
|
|
5875
|
-
return this._transaction.lookup([
|
|
5874
|
+
const n = Fr(t, this._firestore), e = new vr(this._firestore);
|
|
5875
|
+
return this._transaction.lookup([ n._key ]).then((t => {
|
|
5876
5876
|
if (!t || 1 !== t.length) return g();
|
|
5877
5877
|
const r = t[0];
|
|
5878
|
-
if (r.isFoundDocument()) return new
|
|
5879
|
-
if (r.isNoDocument()) return new
|
|
5878
|
+
if (r.isFoundDocument()) return new He(this._firestore, e, r.key, r, n.converter);
|
|
5879
|
+
if (r.isNoDocument()) return new He(this._firestore, e, n._key, null, n.converter);
|
|
5880
5880
|
throw g();
|
|
5881
5881
|
}));
|
|
5882
5882
|
}
|
|
5883
|
-
set(t,
|
|
5884
|
-
const r =
|
|
5883
|
+
set(t, n, e) {
|
|
5884
|
+
const r = Fr(t, this._firestore), s = gr(r.converter, n, e), i = Ne(this._dataReader, "Transaction.set", r._key, s, null !== r.converter, e);
|
|
5885
5885
|
return this._transaction.set(r._key, i), this;
|
|
5886
5886
|
}
|
|
5887
|
-
update(t,
|
|
5888
|
-
const s =
|
|
5887
|
+
update(t, n, e, ...r) {
|
|
5888
|
+
const s = Fr(t, this._firestore);
|
|
5889
5889
|
// For Compat types, we have to "extract" the underlying types before
|
|
5890
5890
|
// performing validation.
|
|
5891
5891
|
let i;
|
|
5892
|
-
return i = "string" == typeof (
|
|
5892
|
+
return i = "string" == typeof (n = getModularInstance(n)) || n instanceof _e ? Le(this._dataReader, "Transaction.update", s._key, n, e, r) : Ce(this._dataReader, "Transaction.update", s._key, n),
|
|
5893
5893
|
this._transaction.update(s._key, i), this;
|
|
5894
5894
|
}
|
|
5895
5895
|
/**
|
|
@@ -5898,8 +5898,8 @@ class kr {
|
|
|
5898
5898
|
* @param documentRef - A reference to the document to be deleted.
|
|
5899
5899
|
* @returns This `Transaction` instance. Used for chaining method calls.
|
|
5900
5900
|
*/ delete(t) {
|
|
5901
|
-
const
|
|
5902
|
-
return this._transaction.delete(
|
|
5901
|
+
const n = Fr(t, this._firestore);
|
|
5902
|
+
return this._transaction.delete(n._key), this;
|
|
5903
5903
|
}
|
|
5904
5904
|
}
|
|
5905
5905
|
|
|
@@ -5919,9 +5919,9 @@ class kr {
|
|
|
5919
5919
|
* (the `updateFunction` returned a failed promise), the promise returned by the
|
|
5920
5920
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
5921
5921
|
* rejected promise with the corresponding failure error is returned.
|
|
5922
|
-
*/ function jr(t,
|
|
5923
|
-
const
|
|
5924
|
-
return new Or(new Ur,
|
|
5922
|
+
*/ function jr(t, n) {
|
|
5923
|
+
const e = re(t = ot(t, ie)), r = new k;
|
|
5924
|
+
return new Or(new Ur, e, (e => n(new kr(t, e))), r).run(), r.promise;
|
|
5925
5925
|
}
|
|
5926
5926
|
|
|
5927
5927
|
/**
|
|
@@ -5933,12 +5933,12 @@ class kr {
|
|
|
5933
5933
|
* @packageDocumentation
|
|
5934
5934
|
*/ !function(t) {
|
|
5935
5935
|
f = t;
|
|
5936
|
-
}(`${SDK_VERSION}_lite`), _registerComponent(new Component("firestore/lite", ((t, {options:
|
|
5937
|
-
const
|
|
5938
|
-
return
|
|
5936
|
+
}(`${SDK_VERSION}_lite`), _registerComponent(new Component("firestore/lite", ((t, {options: n}) => {
|
|
5937
|
+
const e = t.getProvider("app").getImmediate(), r = new ie(e, new z(t.getProvider("auth-internal")), new Y(t.getProvider("app-check-internal")));
|
|
5938
|
+
return n && r._setSettings(n), r;
|
|
5939
5939
|
}), "PUBLIC")),
|
|
5940
5940
|
// RUNTIME_ENV and BUILD_TARGET are replaced by real values during the compilation
|
|
5941
|
-
registerVersion("firestore-lite", "3.4.
|
|
5941
|
+
registerVersion("firestore-lite", "3.4.3", ""), registerVersion("firestore-lite", "3.4.3", "esm2017");
|
|
5942
5942
|
|
|
5943
|
-
export {
|
|
5943
|
+
export { ve as Bytes, fe as CollectionReference, he as DocumentReference, He as DocumentSnapshot, _e as FieldPath, be as FieldValue, ie as Firestore, U as FirestoreError, Ee as GeoPoint, le as Query, tr as QueryConstraint, Ke as QueryDocumentSnapshot, Je as QuerySnapshot, gt as Timestamp, kr as Transaction, Sr as WriteBatch, Rr as addDoc, Nr as arrayRemove, Dr as arrayUnion, de as collection, we as collectionGroup, ce as connectFirestoreEmulator, Ar as deleteDoc, Pr as deleteField, me as doc, ge as documentId, wr as endAt, dr as endBefore, br as getDoc, Er as getDocs, ue as getFirestore, $r as increment, oe as initializeFirestore, ur as limit, cr as limitToLast, ir as orderBy, nr as query, ye as queryEqual, pe as refEqual, jr as runTransaction, Vr as serverTimestamp, Tr as setDoc, w as setLogLevel, Xe as snapshotEqual, lr as startAfter, hr as startAt, ae as terminate, Ir as updateDoc, rr as where, xr as writeBatch };
|
|
5944
5944
|
//# sourceMappingURL=index.browser.esm2017.js.map
|