@firebase/firestore 3.4.8 → 3.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/firestore/lite/index.d.ts +1 -0
- package/dist/firestore/src/api/transaction.d.ts +2 -1
- package/dist/firestore/src/api/transaction_options.d.ts +17 -0
- package/dist/firestore/src/api.d.ts +1 -0
- package/dist/firestore/src/core/firestore_client.d.ts +2 -1
- package/dist/firestore/src/core/query.d.ts +2 -4
- package/dist/firestore/src/core/target.d.ts +6 -4
- package/dist/firestore/src/core/transaction_options.d.ts +25 -0
- package/dist/firestore/src/core/transaction_runner.d.ts +3 -2
- package/dist/firestore/src/lite-api/transaction.d.ts +2 -1
- package/dist/firestore/src/lite-api/transaction_options.d.ts +23 -0
- package/dist/firestore/src/local/index_manager.d.ts +24 -3
- package/dist/firestore/src/local/indexeddb_index_manager.d.ts +4 -7
- package/dist/firestore/src/local/indexeddb_schema.d.ts +1 -0
- package/dist/firestore/src/local/local_documents_view.d.ts +1 -1
- package/dist/firestore/src/local/memory_index_manager.d.ts +3 -2
- package/dist/firestore/src/local/query_engine.d.ts +44 -5
- package/dist/firestore/src/model/collections.d.ts +1 -1
- package/dist/firestore/src/model/values.d.ts +14 -2
- package/dist/firestore/src/util/misc.d.ts +3 -0
- package/dist/firestore/test/unit/local/counting_query_engine.d.ts +2 -1
- package/dist/firestore/test/unit/local/test_index_manager.d.ts +2 -2
- package/dist/index.d.ts +24 -1
- package/dist/index.esm2017.js +4108 -3992
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +4198 -4087
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +1711 -1565
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +1711 -1565
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +4100 -3984
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +50 -4
- package/dist/lite/firestore/lite/index.d.ts +1 -0
- package/dist/lite/firestore/src/api/transaction.d.ts +2 -1
- package/dist/lite/firestore/src/api/transaction_options.d.ts +17 -0
- package/dist/lite/firestore/src/api.d.ts +1 -0
- package/dist/lite/firestore/src/core/firestore_client.d.ts +2 -1
- package/dist/lite/firestore/src/core/query.d.ts +2 -4
- package/dist/lite/firestore/src/core/target.d.ts +6 -4
- package/dist/lite/firestore/src/core/transaction_options.d.ts +25 -0
- package/dist/lite/firestore/src/core/transaction_runner.d.ts +3 -2
- package/dist/lite/firestore/src/lite-api/transaction.d.ts +2 -1
- package/dist/lite/firestore/src/lite-api/transaction_options.d.ts +23 -0
- package/dist/lite/firestore/src/local/index_manager.d.ts +24 -3
- package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +4 -7
- package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +1 -0
- package/dist/lite/firestore/src/local/local_documents_view.d.ts +1 -1
- package/dist/lite/firestore/src/local/memory_index_manager.d.ts +3 -2
- package/dist/lite/firestore/src/local/query_engine.d.ts +44 -5
- package/dist/lite/firestore/src/model/collections.d.ts +1 -1
- package/dist/lite/firestore/src/model/values.d.ts +14 -2
- package/dist/lite/firestore/src/util/misc.d.ts +3 -0
- package/dist/lite/firestore/test/unit/local/counting_query_engine.d.ts +2 -1
- package/dist/lite/firestore/test/unit/local/test_index_manager.d.ts +2 -2
- package/dist/lite/index.browser.esm2017.js +341 -312
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +299 -291
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.d.ts +24 -1
- package/dist/lite/index.node.cjs.js +56 -15
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +56 -15
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +1227 -1198
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +25 -1
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +28 -28
- package/dist/lite/packages/firestore/lite/index.d.ts +1 -0
- package/dist/lite/packages/firestore/src/api/transaction.d.ts +2 -1
- package/dist/lite/packages/firestore/src/api/transaction_options.d.ts +17 -0
- package/dist/lite/packages/firestore/src/api.d.ts +1 -0
- package/dist/lite/packages/firestore/src/core/firestore_client.d.ts +2 -1
- package/dist/lite/packages/firestore/src/core/query.d.ts +2 -4
- package/dist/lite/packages/firestore/src/core/target.d.ts +6 -4
- package/dist/lite/packages/firestore/src/core/transaction_options.d.ts +25 -0
- package/dist/lite/packages/firestore/src/core/transaction_runner.d.ts +3 -2
- package/dist/lite/packages/firestore/src/lite-api/transaction.d.ts +2 -1
- package/dist/lite/packages/firestore/src/lite-api/transaction_options.d.ts +23 -0
- package/dist/lite/packages/firestore/src/local/index_manager.d.ts +24 -3
- package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +4 -7
- package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +1 -0
- package/dist/lite/packages/firestore/src/local/local_documents_view.d.ts +1 -1
- package/dist/lite/packages/firestore/src/local/memory_index_manager.d.ts +3 -2
- package/dist/lite/packages/firestore/src/local/query_engine.d.ts +44 -5
- package/dist/lite/packages/firestore/src/model/collections.d.ts +1 -1
- package/dist/lite/packages/firestore/src/model/values.d.ts +14 -2
- package/dist/lite/packages/firestore/src/util/misc.d.ts +3 -0
- package/dist/lite/packages/firestore/test/unit/local/counting_query_engine.d.ts +2 -1
- package/dist/lite/packages/firestore/test/unit/local/test_index_manager.d.ts +2 -2
- package/dist/lite/private.d.ts +25 -1
- package/dist/packages/firestore/dist/index.esm2017.d.ts +155 -154
- package/dist/packages/firestore/lite/index.d.ts +1 -0
- package/dist/packages/firestore/src/api/transaction.d.ts +2 -1
- package/dist/packages/firestore/src/api/transaction_options.d.ts +17 -0
- package/dist/packages/firestore/src/api.d.ts +1 -0
- package/dist/packages/firestore/src/core/firestore_client.d.ts +2 -1
- package/dist/packages/firestore/src/core/query.d.ts +2 -4
- package/dist/packages/firestore/src/core/target.d.ts +6 -4
- package/dist/packages/firestore/src/core/transaction_options.d.ts +25 -0
- package/dist/packages/firestore/src/core/transaction_runner.d.ts +3 -2
- package/dist/packages/firestore/src/lite-api/transaction.d.ts +2 -1
- package/dist/packages/firestore/src/lite-api/transaction_options.d.ts +23 -0
- package/dist/packages/firestore/src/local/index_manager.d.ts +24 -3
- package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +4 -7
- package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +1 -0
- package/dist/packages/firestore/src/local/local_documents_view.d.ts +1 -1
- package/dist/packages/firestore/src/local/memory_index_manager.d.ts +3 -2
- package/dist/packages/firestore/src/local/query_engine.d.ts +44 -5
- package/dist/packages/firestore/src/model/collections.d.ts +1 -1
- package/dist/packages/firestore/src/model/values.d.ts +14 -2
- package/dist/packages/firestore/src/util/misc.d.ts +3 -0
- package/dist/packages/firestore/test/unit/local/counting_query_engine.d.ts +2 -1
- package/dist/packages/firestore/test/unit/local/test_index_manager.d.ts +2 -2
- package/dist/private.d.ts +50 -4
- package/package.json +7 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _getProvider, getApp as t, _removeServiceInstance as
|
|
1
|
+
import { _getProvider, getApp as t, _removeServiceInstance as e, _registerComponent as n, registerVersion as r, SDK_VERSION as s } from "@firebase/app";
|
|
2
2
|
|
|
3
3
|
import { Component as i } from "@firebase/component";
|
|
4
4
|
|
|
@@ -66,7 +66,7 @@ f.MOCK_USER = new f("mock-user");
|
|
|
66
66
|
* See the License for the specific language governing permissions and
|
|
67
67
|
* limitations under the License.
|
|
68
68
|
*/
|
|
69
|
-
let d = "9.
|
|
69
|
+
let d = "9.8.0";
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* @license
|
|
@@ -102,26 +102,26 @@ const w = new o("@firebase/firestore");
|
|
|
102
102
|
w.setLogLevel(t);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
function p(t, ...
|
|
105
|
+
function p(t, ...e) {
|
|
106
106
|
if (w.logLevel <= u.DEBUG) {
|
|
107
|
-
const
|
|
108
|
-
w.debug(`Firestore (${d}): ${t}`, ...
|
|
107
|
+
const n = e.map(g);
|
|
108
|
+
w.debug(`Firestore (${d}): ${t}`, ...n);
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
function y(t, ...
|
|
112
|
+
function y(t, ...e) {
|
|
113
113
|
if (w.logLevel <= u.ERROR) {
|
|
114
|
-
const
|
|
115
|
-
w.error(`Firestore (${d}): ${t}`, ...
|
|
114
|
+
const n = e.map(g);
|
|
115
|
+
w.error(`Firestore (${d}): ${t}`, ...n);
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
120
|
* @internal
|
|
121
|
-
*/ function _(t, ...
|
|
121
|
+
*/ function _(t, ...e) {
|
|
122
122
|
if (w.logLevel <= u.WARN) {
|
|
123
|
-
const
|
|
124
|
-
w.warn(`Firestore (${d}): ${t}`, ...
|
|
123
|
+
const n = e.map(g);
|
|
124
|
+
w.warn(`Firestore (${d}): ${t}`, ...n);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|
|
@@ -130,8 +130,8 @@ function y(t, ...n) {
|
|
|
130
130
|
*/ function g(t) {
|
|
131
131
|
if ("string" == typeof t) return t;
|
|
132
132
|
try {
|
|
133
|
-
return
|
|
134
|
-
} catch (
|
|
133
|
+
return e = t, JSON.stringify(e);
|
|
134
|
+
} catch (e) {
|
|
135
135
|
// Converting to JSON failed, just log the object directly
|
|
136
136
|
return t;
|
|
137
137
|
}
|
|
@@ -152,7 +152,7 @@ function y(t, ...n) {
|
|
|
152
152
|
* limitations under the License.
|
|
153
153
|
*/
|
|
154
154
|
/** Formats an object as a JSON string, suitable for logging. */
|
|
155
|
-
var
|
|
155
|
+
var e;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
/**
|
|
@@ -181,11 +181,11 @@ function y(t, ...n) {
|
|
|
181
181
|
*/ function v(t = "Unexpected state") {
|
|
182
182
|
// Log the failure in addition to throw an exception, just in case the
|
|
183
183
|
// exception is swallowed.
|
|
184
|
-
const
|
|
184
|
+
const e = `FIRESTORE (${d}) INTERNAL ASSERTION FAILED: ` + t;
|
|
185
185
|
// NOTE: We don't use FirestoreError here because these are internal failures
|
|
186
186
|
// that cannot be handled by the user. (Also it would create a circular
|
|
187
187
|
// dependency between the error and assert modules which doesn't work.)
|
|
188
|
-
throw y(
|
|
188
|
+
throw y(e), new Error(e);
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
/**
|
|
@@ -193,7 +193,7 @@ function y(t, ...n) {
|
|
|
193
193
|
* given message if it did.
|
|
194
194
|
*
|
|
195
195
|
* Messages are stripped in production builds.
|
|
196
|
-
*/ function b(t,
|
|
196
|
+
*/ function b(t, e) {
|
|
197
197
|
t || v();
|
|
198
198
|
}
|
|
199
199
|
|
|
@@ -202,7 +202,7 @@ function y(t, ...n) {
|
|
|
202
202
|
* instance of `T` before casting.
|
|
203
203
|
*/ function E(t,
|
|
204
204
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
205
|
-
|
|
205
|
+
e) {
|
|
206
206
|
return t;
|
|
207
207
|
}
|
|
208
208
|
|
|
@@ -221,7 +221,7 @@ n) {
|
|
|
221
221
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
222
222
|
* See the License for the specific language governing permissions and
|
|
223
223
|
* limitations under the License.
|
|
224
|
-
*/ const T = "ok",
|
|
224
|
+
*/ const T = "ok", A = "cancelled", I = "unknown", R = "invalid-argument", P = "deadline-exceeded", V = "not-found", N = "already-exists", D = "permission-denied", $ = "unauthenticated", S = "resource-exhausted", x = "failed-precondition", F = "aborted", q = "out-of-range", O = "unimplemented", C = "internal", L = "unavailable", k = "data-loss";
|
|
225
225
|
|
|
226
226
|
/** An error returned by a Firestore operation. */ class U extends c {
|
|
227
227
|
/** @hideconstructor */
|
|
@@ -233,8 +233,8 @@ n) {
|
|
|
233
233
|
/**
|
|
234
234
|
* A custom error description.
|
|
235
235
|
*/
|
|
236
|
-
|
|
237
|
-
super(t,
|
|
236
|
+
e) {
|
|
237
|
+
super(t, e), this.code = t, this.message = e,
|
|
238
238
|
// HACK: We write a toString property directly because Error is not a real
|
|
239
239
|
// class and so inheritance does not work correctly. We could alternatively
|
|
240
240
|
// do the same "back-door inheritance" trick that FirebaseError does.
|
|
@@ -259,8 +259,8 @@ n) {
|
|
|
259
259
|
* limitations under the License.
|
|
260
260
|
*/ class j {
|
|
261
261
|
constructor() {
|
|
262
|
-
this.promise = new Promise(((t,
|
|
263
|
-
this.resolve = t, this.reject =
|
|
262
|
+
this.promise = new Promise(((t, e) => {
|
|
263
|
+
this.resolve = t, this.reject = e;
|
|
264
264
|
}));
|
|
265
265
|
}
|
|
266
266
|
}
|
|
@@ -281,8 +281,8 @@ n) {
|
|
|
281
281
|
* See the License for the specific language governing permissions and
|
|
282
282
|
* limitations under the License.
|
|
283
283
|
*/ class M {
|
|
284
|
-
constructor(t,
|
|
285
|
-
this.user =
|
|
284
|
+
constructor(t, e) {
|
|
285
|
+
this.user = e, this.type = "OAuth", this.headers = new Map, this.headers.set("Authorization", `Bearer ${t}`);
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
|
|
@@ -294,9 +294,9 @@ n) {
|
|
|
294
294
|
return Promise.resolve(null);
|
|
295
295
|
}
|
|
296
296
|
invalidateToken() {}
|
|
297
|
-
start(t,
|
|
297
|
+
start(t, e) {
|
|
298
298
|
// Fire with initial user.
|
|
299
|
-
t.enqueueRetryable((() =>
|
|
299
|
+
t.enqueueRetryable((() => e(f.UNAUTHENTICATED)));
|
|
300
300
|
}
|
|
301
301
|
shutdown() {}
|
|
302
302
|
}
|
|
@@ -318,10 +318,10 @@ n) {
|
|
|
318
318
|
return Promise.resolve(this.token);
|
|
319
319
|
}
|
|
320
320
|
invalidateToken() {}
|
|
321
|
-
start(t,
|
|
322
|
-
this.changeListener =
|
|
321
|
+
start(t, e) {
|
|
322
|
+
this.changeListener = e,
|
|
323
323
|
// Fire with initial user.
|
|
324
|
-
t.enqueueRetryable((() =>
|
|
324
|
+
t.enqueueRetryable((() => e(this.token.user)));
|
|
325
325
|
}
|
|
326
326
|
shutdown() {
|
|
327
327
|
this.changeListener = null;
|
|
@@ -339,7 +339,7 @@ n) {
|
|
|
339
339
|
new M(t.accessToken, new f(this.auth.getUid()))) : null)) : Promise.resolve(null);
|
|
340
340
|
}
|
|
341
341
|
invalidateToken() {}
|
|
342
|
-
start(t,
|
|
342
|
+
start(t, e) {}
|
|
343
343
|
shutdown() {}
|
|
344
344
|
}
|
|
345
345
|
|
|
@@ -350,10 +350,10 @@ n) {
|
|
|
350
350
|
* recover from unauthenticated errors (see b/33147818 for context), but it's
|
|
351
351
|
* safer to keep the implementation as-is.
|
|
352
352
|
*/ class Q {
|
|
353
|
-
constructor(t,
|
|
354
|
-
this.type = "FirstParty", this.user = f.FIRST_PARTY, this.headers = new Map, this.headers.set("X-Goog-AuthUser",
|
|
353
|
+
constructor(t, e, n) {
|
|
354
|
+
this.type = "FirstParty", this.user = f.FIRST_PARTY, this.headers = new Map, this.headers.set("X-Goog-AuthUser", e);
|
|
355
355
|
const r = t.auth.getAuthHeaderValueForFirstParty([]);
|
|
356
|
-
r && this.headers.set("Authorization", r),
|
|
356
|
+
r && this.headers.set("Authorization", r), n && this.headers.set("X-Goog-Iam-Authorization-Token", n);
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
359
|
|
|
@@ -362,15 +362,15 @@ n) {
|
|
|
362
362
|
* to authenticate the user, using technique that is only available
|
|
363
363
|
* to applications hosted by Google.
|
|
364
364
|
*/ class W {
|
|
365
|
-
constructor(t,
|
|
366
|
-
this.t = t, this.i =
|
|
365
|
+
constructor(t, e, n) {
|
|
366
|
+
this.t = t, this.i = e, this.o = n;
|
|
367
367
|
}
|
|
368
368
|
getToken() {
|
|
369
369
|
return Promise.resolve(new Q(this.t, this.i, this.o));
|
|
370
370
|
}
|
|
371
|
-
start(t,
|
|
371
|
+
start(t, e) {
|
|
372
372
|
// Fire with initial uid.
|
|
373
|
-
t.enqueueRetryable((() =>
|
|
373
|
+
t.enqueueRetryable((() => e(f.FIRST_PARTY)));
|
|
374
374
|
}
|
|
375
375
|
shutdown() {}
|
|
376
376
|
invalidateToken() {}
|
|
@@ -393,7 +393,7 @@ class Y {
|
|
|
393
393
|
new Y(t.token)) : null)) : Promise.resolve(null);
|
|
394
394
|
}
|
|
395
395
|
invalidateToken() {}
|
|
396
|
-
start(t,
|
|
396
|
+
start(t, e) {}
|
|
397
397
|
shutdown() {}
|
|
398
398
|
}
|
|
399
399
|
|
|
@@ -435,8 +435,8 @@ class K {
|
|
|
435
435
|
* @param useFetchStreams Whether to use the Fetch API instead of
|
|
436
436
|
* XMLHTTPRequest
|
|
437
437
|
*/
|
|
438
|
-
constructor(t,
|
|
439
|
-
this.databaseId = t, this.appId =
|
|
438
|
+
constructor(t, e, n, r, s, i, o, u) {
|
|
439
|
+
this.databaseId = t, this.appId = e, this.persistenceKey = n, this.host = r, this.ssl = s,
|
|
440
440
|
this.forceLongPolling = i, this.autoDetectLongPolling = o, this.useFetchStreams = u;
|
|
441
441
|
}
|
|
442
442
|
}
|
|
@@ -447,8 +447,8 @@ class K {
|
|
|
447
447
|
* @internal
|
|
448
448
|
*/
|
|
449
449
|
class J {
|
|
450
|
-
constructor(t,
|
|
451
|
-
this.projectId = t, this.database =
|
|
450
|
+
constructor(t, e) {
|
|
451
|
+
this.projectId = t, this.database = e || "(default)";
|
|
452
452
|
}
|
|
453
453
|
static empty() {
|
|
454
454
|
return new J("", "");
|
|
@@ -481,9 +481,9 @@ class J {
|
|
|
481
481
|
* Path represents an ordered sequence of string segments.
|
|
482
482
|
*/
|
|
483
483
|
class X {
|
|
484
|
-
constructor(t,
|
|
485
|
-
void 0 ===
|
|
486
|
-
this.segments = t, this.offset =
|
|
484
|
+
constructor(t, e, n) {
|
|
485
|
+
void 0 === e ? e = 0 : e > t.length && v(), void 0 === n ? n = t.length - e : n > t.length - e && v(),
|
|
486
|
+
this.segments = t, this.offset = e, this.len = n;
|
|
487
487
|
}
|
|
488
488
|
get length() {
|
|
489
489
|
return this.len;
|
|
@@ -492,10 +492,10 @@ class X {
|
|
|
492
492
|
return 0 === X.comparator(this, t);
|
|
493
493
|
}
|
|
494
494
|
child(t) {
|
|
495
|
-
const
|
|
495
|
+
const e = this.segments.slice(this.offset, this.limit());
|
|
496
496
|
return t instanceof X ? t.forEach((t => {
|
|
497
|
-
|
|
498
|
-
})) :
|
|
497
|
+
e.push(t);
|
|
498
|
+
})) : e.push(t), this.construct(e);
|
|
499
499
|
}
|
|
500
500
|
/** The index of one past the last segment of the path. */ limit() {
|
|
501
501
|
return this.offset + this.length;
|
|
@@ -520,28 +520,28 @@ class X {
|
|
|
520
520
|
}
|
|
521
521
|
isPrefixOf(t) {
|
|
522
522
|
if (t.length < this.length) return !1;
|
|
523
|
-
for (let
|
|
523
|
+
for (let e = 0; e < this.length; e++) if (this.get(e) !== t.get(e)) return !1;
|
|
524
524
|
return !0;
|
|
525
525
|
}
|
|
526
526
|
isImmediateParentOf(t) {
|
|
527
527
|
if (this.length + 1 !== t.length) return !1;
|
|
528
|
-
for (let
|
|
528
|
+
for (let e = 0; e < this.length; e++) if (this.get(e) !== t.get(e)) return !1;
|
|
529
529
|
return !0;
|
|
530
530
|
}
|
|
531
531
|
forEach(t) {
|
|
532
|
-
for (let
|
|
532
|
+
for (let e = this.offset, n = this.limit(); e < n; e++) t(this.segments[e]);
|
|
533
533
|
}
|
|
534
534
|
toArray() {
|
|
535
535
|
return this.segments.slice(this.offset, this.limit());
|
|
536
536
|
}
|
|
537
|
-
static comparator(t,
|
|
538
|
-
const
|
|
539
|
-
for (let r = 0; r <
|
|
540
|
-
const
|
|
541
|
-
if (
|
|
542
|
-
if (
|
|
537
|
+
static comparator(t, e) {
|
|
538
|
+
const n = Math.min(t.length, e.length);
|
|
539
|
+
for (let r = 0; r < n; r++) {
|
|
540
|
+
const n = t.get(r), s = e.get(r);
|
|
541
|
+
if (n < s) return -1;
|
|
542
|
+
if (n > s) return 1;
|
|
543
543
|
}
|
|
544
|
-
return t.length <
|
|
544
|
+
return t.length < e.length ? -1 : t.length > e.length ? 1 : 0;
|
|
545
545
|
}
|
|
546
546
|
}
|
|
547
547
|
|
|
@@ -551,8 +551,8 @@ class X {
|
|
|
551
551
|
*
|
|
552
552
|
* @internal
|
|
553
553
|
*/ class Z extends X {
|
|
554
|
-
construct(t,
|
|
555
|
-
return new Z(t,
|
|
554
|
+
construct(t, e, n) {
|
|
555
|
+
return new Z(t, e, n);
|
|
556
556
|
}
|
|
557
557
|
canonicalString() {
|
|
558
558
|
// NOTE: The client is ignorant of any path segments containing escape
|
|
@@ -571,13 +571,13 @@ class X {
|
|
|
571
571
|
// NOTE: The client is ignorant of any path segments containing escape
|
|
572
572
|
// sequences (e.g. __id123__) and just passes them through raw (they exist
|
|
573
573
|
// for legacy reasons and should not be used frequently).
|
|
574
|
-
const
|
|
575
|
-
for (const
|
|
576
|
-
if (
|
|
574
|
+
const e = [];
|
|
575
|
+
for (const n of t) {
|
|
576
|
+
if (n.indexOf("//") >= 0) throw new U(R, `Invalid segment (${n}). Paths must not contain // in them.`);
|
|
577
577
|
// Strip leading and traling slashed.
|
|
578
|
-
|
|
578
|
+
e.push(...n.split("/").filter((t => t.length > 0)));
|
|
579
579
|
}
|
|
580
|
-
return new Z(
|
|
580
|
+
return new Z(e);
|
|
581
581
|
}
|
|
582
582
|
static emptyPath() {
|
|
583
583
|
return new Z([]);
|
|
@@ -589,9 +589,9 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
589
589
|
/**
|
|
590
590
|
* A dot-separated path for navigating sub-objects within a document.
|
|
591
591
|
* @internal
|
|
592
|
-
*/ class
|
|
593
|
-
construct(t,
|
|
594
|
-
return new
|
|
592
|
+
*/ class et extends X {
|
|
593
|
+
construct(t, e, n) {
|
|
594
|
+
return new et(t, e, n);
|
|
595
595
|
}
|
|
596
596
|
/**
|
|
597
597
|
* Returns true if the string could be used as a segment in a field path
|
|
@@ -601,7 +601,7 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
601
601
|
}
|
|
602
602
|
canonicalString() {
|
|
603
603
|
return this.toArray().map((t => (t = t.replace(/\\/g, "\\\\").replace(/`/g, "\\`"),
|
|
604
|
-
|
|
604
|
+
et.isValidIdentifier(t) || (t = "`" + t + "`"), t))).join(".");
|
|
605
605
|
}
|
|
606
606
|
toString() {
|
|
607
607
|
return this.canonicalString();
|
|
@@ -614,7 +614,7 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
614
614
|
/**
|
|
615
615
|
* The field designating the key of a document.
|
|
616
616
|
*/ static keyField() {
|
|
617
|
-
return new
|
|
617
|
+
return new et([ "__name__" ]);
|
|
618
618
|
}
|
|
619
619
|
/**
|
|
620
620
|
* Parses a field string from the given server-formatted string.
|
|
@@ -626,27 +626,27 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
626
626
|
* TODO(b/37244157): we should make this more strict. Right now, it allows
|
|
627
627
|
* non-identifier path components, even if they aren't escaped.
|
|
628
628
|
*/ static fromServerFormat(t) {
|
|
629
|
-
const
|
|
630
|
-
let
|
|
629
|
+
const e = [];
|
|
630
|
+
let n = "", r = 0;
|
|
631
631
|
const s = () => {
|
|
632
|
-
if (0 ===
|
|
633
|
-
|
|
632
|
+
if (0 === n.length) throw new U(R, `Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);
|
|
633
|
+
e.push(n), n = "";
|
|
634
634
|
};
|
|
635
635
|
let i = !1;
|
|
636
636
|
for (;r < t.length; ) {
|
|
637
|
-
const
|
|
638
|
-
if ("\\" ===
|
|
637
|
+
const e = t[r];
|
|
638
|
+
if ("\\" === e) {
|
|
639
639
|
if (r + 1 === t.length) throw new U(R, "Path has trailing escape character: " + t);
|
|
640
|
-
const
|
|
641
|
-
if ("\\" !==
|
|
642
|
-
|
|
643
|
-
} else "`" ===
|
|
640
|
+
const e = t[r + 1];
|
|
641
|
+
if ("\\" !== e && "." !== e && "`" !== e) throw new U(R, "Path has invalid escape sequence: " + t);
|
|
642
|
+
n += e, r += 2;
|
|
643
|
+
} else "`" === e ? (i = !i, r++) : "." !== e || i ? (n += e, r++) : (s(), r++);
|
|
644
644
|
}
|
|
645
645
|
if (s(), i) throw new U(R, "Unterminated ` in path: " + t);
|
|
646
|
-
return new
|
|
646
|
+
return new et(e);
|
|
647
647
|
}
|
|
648
648
|
static emptyPath() {
|
|
649
|
-
return new
|
|
649
|
+
return new et([]);
|
|
650
650
|
}
|
|
651
651
|
}
|
|
652
652
|
|
|
@@ -668,18 +668,18 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
668
668
|
*/
|
|
669
669
|
/**
|
|
670
670
|
* @internal
|
|
671
|
-
*/ class
|
|
671
|
+
*/ class nt {
|
|
672
672
|
constructor(t) {
|
|
673
673
|
this.path = t;
|
|
674
674
|
}
|
|
675
675
|
static fromPath(t) {
|
|
676
|
-
return new
|
|
676
|
+
return new nt(Z.fromString(t));
|
|
677
677
|
}
|
|
678
678
|
static fromName(t) {
|
|
679
|
-
return new
|
|
679
|
+
return new nt(Z.fromString(t).popFirst(5));
|
|
680
680
|
}
|
|
681
681
|
static empty() {
|
|
682
|
-
return new
|
|
682
|
+
return new nt(Z.emptyPath());
|
|
683
683
|
}
|
|
684
684
|
get collectionGroup() {
|
|
685
685
|
return this.path.popLast().lastSegment();
|
|
@@ -699,8 +699,8 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
699
699
|
toString() {
|
|
700
700
|
return this.path.toString();
|
|
701
701
|
}
|
|
702
|
-
static comparator(t,
|
|
703
|
-
return Z.comparator(t.path,
|
|
702
|
+
static comparator(t, e) {
|
|
703
|
+
return Z.comparator(t.path, e.path);
|
|
704
704
|
}
|
|
705
705
|
static isDocumentKey(t) {
|
|
706
706
|
return t.length % 2 == 0;
|
|
@@ -711,7 +711,7 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
711
711
|
* @param segments - The segments of the path to the document
|
|
712
712
|
* @returns A new instance of DocumentKey
|
|
713
713
|
*/ static fromSegments(t) {
|
|
714
|
-
return new
|
|
714
|
+
return new nt(new Z(t.slice()));
|
|
715
715
|
}
|
|
716
716
|
}
|
|
717
717
|
|
|
@@ -730,8 +730,8 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
730
730
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
731
731
|
* See the License for the specific language governing permissions and
|
|
732
732
|
* limitations under the License.
|
|
733
|
-
*/ function rt(t,
|
|
734
|
-
if (!
|
|
733
|
+
*/ function rt(t, e, n) {
|
|
734
|
+
if (!n) throw new U(R, `Function ${t}() cannot be called with an empty ${e}.`);
|
|
735
735
|
}
|
|
736
736
|
|
|
737
737
|
/**
|
|
@@ -743,14 +743,14 @@ const tt = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
743
743
|
* an even numbers of segments).
|
|
744
744
|
*/
|
|
745
745
|
function st(t) {
|
|
746
|
-
if (!
|
|
746
|
+
if (!nt.isDocumentKey(t)) throw new U(R, `Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`);
|
|
747
747
|
}
|
|
748
748
|
|
|
749
749
|
/**
|
|
750
750
|
* Validates that `path` refers to a collection (indicated by the fact it
|
|
751
751
|
* contains an odd numbers of segments).
|
|
752
752
|
*/ function it(t) {
|
|
753
|
-
if (
|
|
753
|
+
if (nt.isDocumentKey(t)) throw new U(R, `Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`);
|
|
754
754
|
}
|
|
755
755
|
|
|
756
756
|
/**
|
|
@@ -767,7 +767,7 @@ function ot(t) {
|
|
|
767
767
|
if ("object" == typeof t) {
|
|
768
768
|
if (t instanceof Array) return "an array";
|
|
769
769
|
{
|
|
770
|
-
const
|
|
770
|
+
const e =
|
|
771
771
|
/** try to get the constructor name for an object. */
|
|
772
772
|
function(t) {
|
|
773
773
|
if (t.constructor) return t.constructor.name;
|
|
@@ -781,7 +781,7 @@ function ot(t) {
|
|
|
781
781
|
* arguments passed to the public API.
|
|
782
782
|
* @internal
|
|
783
783
|
*/ (t);
|
|
784
|
-
return
|
|
784
|
+
return e ? `a custom ${e} object` : "an object";
|
|
785
785
|
}
|
|
786
786
|
}
|
|
787
787
|
return "function" == typeof t ? "a function" : v();
|
|
@@ -789,22 +789,22 @@ function ot(t) {
|
|
|
789
789
|
|
|
790
790
|
function ut(t,
|
|
791
791
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
792
|
-
|
|
792
|
+
e) {
|
|
793
793
|
if ("_delegate" in t && (
|
|
794
794
|
// Unwrap Compat types
|
|
795
795
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
796
|
-
t = t._delegate), !(t instanceof
|
|
797
|
-
if (
|
|
796
|
+
t = t._delegate), !(t instanceof e)) {
|
|
797
|
+
if (e.name === t.constructor.name) throw new U(R, "Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");
|
|
798
798
|
{
|
|
799
|
-
const
|
|
800
|
-
throw new U(R, `Expected type '${
|
|
799
|
+
const n = ot(t);
|
|
800
|
+
throw new U(R, `Expected type '${e.name}', but it was: ${n}`);
|
|
801
801
|
}
|
|
802
802
|
}
|
|
803
803
|
return t;
|
|
804
804
|
}
|
|
805
805
|
|
|
806
|
-
function ct(t,
|
|
807
|
-
if (
|
|
806
|
+
function ct(t, e) {
|
|
807
|
+
if (e <= 0) throw new U(R, `Function ${t}() requires a positive number, but it was: ${e}.`);
|
|
808
808
|
}
|
|
809
809
|
|
|
810
810
|
/**
|
|
@@ -902,7 +902,7 @@ var ft, dt;
|
|
|
902
902
|
* Code.UNKNOWN.
|
|
903
903
|
*/
|
|
904
904
|
function wt(t) {
|
|
905
|
-
if (void 0 === t) return y("RPC_ERROR", "HTTP error has no status"),
|
|
905
|
+
if (void 0 === t) return y("RPC_ERROR", "HTTP error has no status"), I;
|
|
906
906
|
// The canonical error codes for Google APIs [1] specify mapping onto HTTP
|
|
907
907
|
// status codes but the mapping is not bijective. In each case of ambiguity
|
|
908
908
|
// this function chooses a primary error.
|
|
@@ -916,7 +916,7 @@ function wt(t) {
|
|
|
916
916
|
|
|
917
917
|
case 400:
|
|
918
918
|
// Bad Request
|
|
919
|
-
return
|
|
919
|
+
return x;
|
|
920
920
|
|
|
921
921
|
// Other possibilities based on the forward mapping
|
|
922
922
|
// return Code.INVALID_ARGUMENT;
|
|
@@ -935,7 +935,7 @@ function wt(t) {
|
|
|
935
935
|
|
|
936
936
|
case 409:
|
|
937
937
|
// Conflict
|
|
938
|
-
return
|
|
938
|
+
return F;
|
|
939
939
|
|
|
940
940
|
// Other possibilities:
|
|
941
941
|
// return Code.ALREADY_EXISTS;
|
|
@@ -949,11 +949,11 @@ function wt(t) {
|
|
|
949
949
|
|
|
950
950
|
case 499:
|
|
951
951
|
// Client Closed Request
|
|
952
|
-
return
|
|
952
|
+
return A;
|
|
953
953
|
|
|
954
954
|
case 500:
|
|
955
955
|
// Internal Server Error
|
|
956
|
-
return
|
|
956
|
+
return I;
|
|
957
957
|
|
|
958
958
|
// Other possibilities:
|
|
959
959
|
// return Code.INTERNAL;
|
|
@@ -971,7 +971,7 @@ function wt(t) {
|
|
|
971
971
|
return P;
|
|
972
972
|
|
|
973
973
|
default:
|
|
974
|
-
return t >= 200 && t < 300 ? T : t >= 400 && t < 500 ?
|
|
974
|
+
return t >= 200 && t < 300 ? T : t >= 400 && t < 500 ? x : t >= 500 && t < 600 ? C : I;
|
|
975
975
|
}
|
|
976
976
|
}
|
|
977
977
|
|
|
@@ -1011,58 +1011,58 @@ class mt extends
|
|
|
1011
1011
|
class {
|
|
1012
1012
|
constructor(t) {
|
|
1013
1013
|
this.databaseInfo = t, this.databaseId = t.databaseId;
|
|
1014
|
-
const
|
|
1015
|
-
this.h =
|
|
1014
|
+
const e = t.ssl ? "https" : "http";
|
|
1015
|
+
this.h = e + "://" + t.host, this.l = "projects/" + this.databaseId.projectId + "/databases/" + this.databaseId.database + "/documents";
|
|
1016
1016
|
}
|
|
1017
|
-
m(t,
|
|
1018
|
-
const i = this.p(t,
|
|
1019
|
-
p("RestConnection", "Sending: ", i,
|
|
1017
|
+
m(t, e, n, r, s) {
|
|
1018
|
+
const i = this.p(t, e);
|
|
1019
|
+
p("RestConnection", "Sending: ", i, n);
|
|
1020
1020
|
const o = {};
|
|
1021
|
-
return this.g(o, r, s), this.v(t, i, o,
|
|
1022
|
-
t)), (
|
|
1023
|
-
throw _("RestConnection", `${t} failed with error: `,
|
|
1024
|
-
|
|
1021
|
+
return this.g(o, r, s), this.v(t, i, o, n).then((t => (p("RestConnection", "Received: ", t),
|
|
1022
|
+
t)), (e => {
|
|
1023
|
+
throw _("RestConnection", `${t} failed with error: `, e, "url: ", i, "request:", n),
|
|
1024
|
+
e;
|
|
1025
1025
|
}));
|
|
1026
1026
|
}
|
|
1027
|
-
T(t,
|
|
1027
|
+
T(t, e, n, r, s) {
|
|
1028
1028
|
// The REST API automatically aggregates all of the streamed results, so we
|
|
1029
1029
|
// can just use the normal invoke() method.
|
|
1030
|
-
return this.m(t,
|
|
1030
|
+
return this.m(t, e, n, r, s);
|
|
1031
1031
|
}
|
|
1032
1032
|
/**
|
|
1033
1033
|
* Modifies the headers for a request, adding any authorization token if
|
|
1034
1034
|
* present and any additional headers for the request.
|
|
1035
|
-
*/ g(t,
|
|
1035
|
+
*/ g(t, e, n) {
|
|
1036
1036
|
t["X-Goog-Api-Client"] = "gl-js/ fire/" + d,
|
|
1037
1037
|
// Content-Type: text/plain will avoid preflight requests which might
|
|
1038
1038
|
// mess with CORS and redirects by proxies. If we add custom headers
|
|
1039
1039
|
// we will need to change this code to potentially use the $httpOverwrite
|
|
1040
1040
|
// parameter supported by ESF to avoid triggering preflight requests.
|
|
1041
1041
|
t["Content-Type"] = "text/plain", this.databaseInfo.appId && (t["X-Firebase-GMPID"] = this.databaseInfo.appId),
|
|
1042
|
-
|
|
1042
|
+
e && e.headers.forEach(((e, n) => t[n] = e)), n && n.headers.forEach(((e, n) => t[n] = e));
|
|
1043
1043
|
}
|
|
1044
|
-
p(t,
|
|
1045
|
-
const
|
|
1046
|
-
return `${this.h}/v1/${
|
|
1044
|
+
p(t, e) {
|
|
1045
|
+
const n = lt[t];
|
|
1046
|
+
return `${this.h}/v1/${e}:${n}`;
|
|
1047
1047
|
}
|
|
1048
1048
|
} {
|
|
1049
1049
|
/**
|
|
1050
1050
|
* @param databaseInfo - The connection info.
|
|
1051
1051
|
* @param fetchImpl - `fetch` or a Polyfill that implements the fetch API.
|
|
1052
1052
|
*/
|
|
1053
|
-
constructor(t,
|
|
1054
|
-
super(t), this.
|
|
1053
|
+
constructor(t, e) {
|
|
1054
|
+
super(t), this.A = e;
|
|
1055
1055
|
}
|
|
1056
|
-
|
|
1056
|
+
I(t, e) {
|
|
1057
1057
|
throw new Error("Not supported by FetchConnection");
|
|
1058
1058
|
}
|
|
1059
|
-
async v(t,
|
|
1059
|
+
async v(t, e, n, r) {
|
|
1060
1060
|
const s = JSON.stringify(r);
|
|
1061
1061
|
let i;
|
|
1062
1062
|
try {
|
|
1063
|
-
i = await this.
|
|
1063
|
+
i = await this.A(e, {
|
|
1064
1064
|
method: "POST",
|
|
1065
|
-
headers:
|
|
1065
|
+
headers: n,
|
|
1066
1066
|
body: s
|
|
1067
1067
|
});
|
|
1068
1068
|
} catch (t) {
|
|
@@ -1113,13 +1113,13 @@ class {
|
|
|
1113
1113
|
*/
|
|
1114
1114
|
function pt(t) {
|
|
1115
1115
|
// Polyfills for IE and WebWorker by using `self` and `msCrypto` when `crypto` is not available.
|
|
1116
|
-
const
|
|
1116
|
+
const e =
|
|
1117
1117
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1118
|
-
"undefined" != typeof self && (self.crypto || self.msCrypto),
|
|
1119
|
-
if (
|
|
1118
|
+
"undefined" != typeof self && (self.crypto || self.msCrypto), n = new Uint8Array(t);
|
|
1119
|
+
if (e && "function" == typeof e.getRandomValues) e.getRandomValues(n); else
|
|
1120
1120
|
// Falls back to Math.random
|
|
1121
|
-
for (let
|
|
1122
|
-
return
|
|
1121
|
+
for (let e = 0; e < t; e++) n[e] = Math.floor(256 * Math.random());
|
|
1122
|
+
return n;
|
|
1123
1123
|
}
|
|
1124
1124
|
|
|
1125
1125
|
/**
|
|
@@ -1140,26 +1140,26 @@ function pt(t) {
|
|
|
1140
1140
|
*/ class yt {
|
|
1141
1141
|
static R() {
|
|
1142
1142
|
// Alphanumeric characters
|
|
1143
|
-
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
|
|
1143
|
+
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", e = Math.floor(256 / t.length) * t.length;
|
|
1144
1144
|
// The largest byte value that is a multiple of `char.length`.
|
|
1145
|
-
let
|
|
1146
|
-
for (;
|
|
1145
|
+
let n = "";
|
|
1146
|
+
for (;n.length < 20; ) {
|
|
1147
1147
|
const r = pt(40);
|
|
1148
1148
|
for (let s = 0; s < r.length; ++s)
|
|
1149
1149
|
// Only accept values that are [0, maxMultiple), this ensures they can
|
|
1150
1150
|
// be evenly mapped to indices of `chars` via a modulo operation.
|
|
1151
|
-
|
|
1151
|
+
n.length < 20 && r[s] < e && (n += t.charAt(r[s] % t.length));
|
|
1152
1152
|
}
|
|
1153
|
-
return
|
|
1153
|
+
return n;
|
|
1154
1154
|
}
|
|
1155
1155
|
}
|
|
1156
1156
|
|
|
1157
|
-
function _t(t,
|
|
1158
|
-
return t <
|
|
1157
|
+
function _t(t, e) {
|
|
1158
|
+
return t < e ? -1 : t > e ? 1 : 0;
|
|
1159
1159
|
}
|
|
1160
1160
|
|
|
1161
|
-
/** Helper to compare arrays using isEqual(). */ function gt(t,
|
|
1162
|
-
return t.length ===
|
|
1161
|
+
/** Helper to compare arrays using isEqual(). */ function gt(t, e, n) {
|
|
1162
|
+
return t.length === e.length && t.every(((t, r) => n(t, e[r])));
|
|
1163
1163
|
}
|
|
1164
1164
|
|
|
1165
1165
|
/**
|
|
@@ -1213,9 +1213,9 @@ class vt {
|
|
|
1213
1213
|
/**
|
|
1214
1214
|
* The fractions of a second at nanosecond resolution.*
|
|
1215
1215
|
*/
|
|
1216
|
-
|
|
1217
|
-
if (this.seconds = t, this.nanoseconds =
|
|
1218
|
-
if (
|
|
1216
|
+
e) {
|
|
1217
|
+
if (this.seconds = t, this.nanoseconds = e, e < 0) throw new U(R, "Timestamp nanoseconds out of range: " + e);
|
|
1218
|
+
if (e >= 1e9) throw new U(R, "Timestamp nanoseconds out of range: " + e);
|
|
1219
1219
|
if (t < -62135596800) throw new U(R, "Timestamp seconds out of range: " + t);
|
|
1220
1220
|
// This will break in the year 10,000.
|
|
1221
1221
|
if (t >= 253402300800) throw new U(R, "Timestamp seconds out of range: " + t);
|
|
@@ -1244,8 +1244,8 @@ class vt {
|
|
|
1244
1244
|
* @returns A new `Timestamp` representing the same point in time as the given
|
|
1245
1245
|
* number of milliseconds.
|
|
1246
1246
|
*/ static fromMillis(t) {
|
|
1247
|
-
const
|
|
1248
|
-
return new vt(
|
|
1247
|
+
const e = Math.floor(t / 1e3), n = Math.floor(1e6 * (t - 1e3 * e));
|
|
1248
|
+
return new vt(e, n);
|
|
1249
1249
|
}
|
|
1250
1250
|
/**
|
|
1251
1251
|
* Converts a `Timestamp` to a JavaScript `Date` object. This conversion
|
|
@@ -1370,13 +1370,13 @@ class vt {
|
|
|
1370
1370
|
* See the License for the specific language governing permissions and
|
|
1371
1371
|
* limitations under the License.
|
|
1372
1372
|
*/ function Et(t) {
|
|
1373
|
-
let
|
|
1374
|
-
for (const
|
|
1375
|
-
return
|
|
1373
|
+
let e = 0;
|
|
1374
|
+
for (const n in t) Object.prototype.hasOwnProperty.call(t, n) && e++;
|
|
1375
|
+
return e;
|
|
1376
1376
|
}
|
|
1377
1377
|
|
|
1378
|
-
function Tt(t,
|
|
1379
|
-
for (const
|
|
1378
|
+
function Tt(t, e) {
|
|
1379
|
+
for (const n in t) Object.prototype.hasOwnProperty.call(t, n) && e(n, t[n]);
|
|
1380
1380
|
}
|
|
1381
1381
|
|
|
1382
1382
|
/**
|
|
@@ -1405,12 +1405,12 @@ function Tt(t, n) {
|
|
|
1405
1405
|
* If foo is not an object, foo is replaced with an object
|
|
1406
1406
|
* containing foo
|
|
1407
1407
|
*/
|
|
1408
|
-
class
|
|
1408
|
+
class At {
|
|
1409
1409
|
constructor(t) {
|
|
1410
1410
|
this.fields = t,
|
|
1411
1411
|
// TODO(dimond): validation of FieldMask
|
|
1412
1412
|
// Sort the field mask to support `FieldMask.isEqual()` and assert below.
|
|
1413
|
-
t.sort(
|
|
1413
|
+
t.sort(et.comparator);
|
|
1414
1414
|
}
|
|
1415
1415
|
/**
|
|
1416
1416
|
* Verifies that `fieldPath` is included by at least one field in this field
|
|
@@ -1418,11 +1418,11 @@ class It {
|
|
|
1418
1418
|
*
|
|
1419
1419
|
* This is an O(n) operation, where `n` is the size of the field mask.
|
|
1420
1420
|
*/ covers(t) {
|
|
1421
|
-
for (const
|
|
1421
|
+
for (const e of this.fields) if (e.isPrefixOf(t)) return !0;
|
|
1422
1422
|
return !1;
|
|
1423
1423
|
}
|
|
1424
1424
|
isEqual(t) {
|
|
1425
|
-
return gt(this.fields, t.fields, ((t,
|
|
1425
|
+
return gt(this.fields, t.fields, ((t, e) => t.isEqual(e)));
|
|
1426
1426
|
}
|
|
1427
1427
|
}
|
|
1428
1428
|
|
|
@@ -1445,7 +1445,7 @@ class It {
|
|
|
1445
1445
|
// WebSafe uses a different URL-encoding safe alphabet that doesn't match
|
|
1446
1446
|
// the encoding used on the backend.
|
|
1447
1447
|
/** Converts a Base64 encoded string to a binary string. */
|
|
1448
|
-
function
|
|
1448
|
+
function It(t) {
|
|
1449
1449
|
return String.fromCharCode.apply(null,
|
|
1450
1450
|
// We use `decodeStringToByteArray()` instead of `decodeString()` since
|
|
1451
1451
|
// `decodeString()` returns Unicode strings, which doesn't match the values
|
|
@@ -1484,25 +1484,25 @@ class Rt {
|
|
|
1484
1484
|
this.binaryString = t;
|
|
1485
1485
|
}
|
|
1486
1486
|
static fromBase64String(t) {
|
|
1487
|
-
const
|
|
1488
|
-
return new Rt(
|
|
1487
|
+
const e = It(t);
|
|
1488
|
+
return new Rt(e);
|
|
1489
1489
|
}
|
|
1490
1490
|
static fromUint8Array(t) {
|
|
1491
1491
|
// TODO(indexing); Remove the copy of the byte string here as this method
|
|
1492
1492
|
// is frequently called during indexing.
|
|
1493
|
-
const
|
|
1493
|
+
const e =
|
|
1494
1494
|
/**
|
|
1495
1495
|
* Helper function to convert an Uint8array to a binary string.
|
|
1496
1496
|
*/
|
|
1497
1497
|
function(t) {
|
|
1498
|
-
let
|
|
1499
|
-
for (let
|
|
1500
|
-
return
|
|
1498
|
+
let e = "";
|
|
1499
|
+
for (let n = 0; n < t.length; ++n) e += String.fromCharCode(t[n]);
|
|
1500
|
+
return e;
|
|
1501
1501
|
}
|
|
1502
1502
|
/**
|
|
1503
1503
|
* Helper function to convert a binary string to an Uint8Array.
|
|
1504
1504
|
*/ (t);
|
|
1505
|
-
return new Rt(
|
|
1505
|
+
return new Rt(e);
|
|
1506
1506
|
}
|
|
1507
1507
|
[Symbol.iterator]() {
|
|
1508
1508
|
let t = 0;
|
|
@@ -1518,16 +1518,16 @@ class Rt {
|
|
|
1518
1518
|
}
|
|
1519
1519
|
toBase64() {
|
|
1520
1520
|
return function(t) {
|
|
1521
|
-
const
|
|
1522
|
-
for (let
|
|
1523
|
-
return a.encodeByteArray(
|
|
1521
|
+
const e = [];
|
|
1522
|
+
for (let n = 0; n < t.length; n++) e[n] = t.charCodeAt(n);
|
|
1523
|
+
return a.encodeByteArray(e, !1);
|
|
1524
1524
|
}(this.binaryString);
|
|
1525
1525
|
}
|
|
1526
1526
|
toUint8Array() {
|
|
1527
1527
|
return function(t) {
|
|
1528
|
-
const
|
|
1529
|
-
for (let
|
|
1530
|
-
return
|
|
1528
|
+
const e = new Uint8Array(t.length);
|
|
1529
|
+
for (let n = 0; n < t.length; n++) e[n] = t.charCodeAt(n);
|
|
1530
|
+
return e;
|
|
1531
1531
|
}
|
|
1532
1532
|
/**
|
|
1533
1533
|
* @license
|
|
@@ -1574,18 +1574,18 @@ const Pt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1574
1574
|
// The date string can have higher precision (nanos) than the Date class
|
|
1575
1575
|
// (millis), so we do some custom parsing here.
|
|
1576
1576
|
// Parse the nanos right out of the string.
|
|
1577
|
-
let
|
|
1578
|
-
const
|
|
1579
|
-
if (b(!!
|
|
1577
|
+
let e = 0;
|
|
1578
|
+
const n = Pt.exec(t);
|
|
1579
|
+
if (b(!!n), n[1]) {
|
|
1580
1580
|
// Pad the fraction out to 9 digits (nanos).
|
|
1581
|
-
let t =
|
|
1582
|
-
t = (t + "000000000").substr(0, 9),
|
|
1581
|
+
let t = n[1];
|
|
1582
|
+
t = (t + "000000000").substr(0, 9), e = Number(t);
|
|
1583
1583
|
}
|
|
1584
1584
|
// Parse the date to get the seconds.
|
|
1585
1585
|
const r = new Date(t);
|
|
1586
1586
|
return {
|
|
1587
1587
|
seconds: Math.floor(r.getTime() / 1e3),
|
|
1588
|
-
nanos:
|
|
1588
|
+
nanos: e
|
|
1589
1589
|
};
|
|
1590
1590
|
}
|
|
1591
1591
|
return {
|
|
@@ -1640,8 +1640,8 @@ const Pt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1640
1640
|
* - With respect to other ServerTimestampValues, they sort by their
|
|
1641
1641
|
* localWriteTime.
|
|
1642
1642
|
*/ function $t(t) {
|
|
1643
|
-
var
|
|
1644
|
-
return "server_timestamp" === (null === (
|
|
1643
|
+
var e, n;
|
|
1644
|
+
return "server_timestamp" === (null === (n = ((null === (e = null == t ? void 0 : t.mapValue) || void 0 === e ? void 0 : e.fields) || {}).__type__) || void 0 === n ? void 0 : n.stringValue);
|
|
1645
1645
|
}
|
|
1646
1646
|
|
|
1647
1647
|
/**
|
|
@@ -1650,15 +1650,15 @@ const Pt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1650
1650
|
* Preserving the previous values allows the user to display the last resoled
|
|
1651
1651
|
* value until the backend responds with the timestamp.
|
|
1652
1652
|
*/ function St(t) {
|
|
1653
|
-
const
|
|
1654
|
-
return $t(
|
|
1653
|
+
const e = t.mapValue.fields.__previous_value__;
|
|
1654
|
+
return $t(e) ? St(e) : e;
|
|
1655
1655
|
}
|
|
1656
1656
|
|
|
1657
1657
|
/**
|
|
1658
1658
|
* Returns the local time at which this timestamp was first set.
|
|
1659
|
-
*/ function
|
|
1660
|
-
const
|
|
1661
|
-
return new vt(
|
|
1659
|
+
*/ function xt(t) {
|
|
1660
|
+
const e = Vt(t.mapValue.fields.__local_write_time__.timestampValue);
|
|
1661
|
+
return new vt(e.seconds, e.nanos);
|
|
1662
1662
|
}
|
|
1663
1663
|
|
|
1664
1664
|
/**
|
|
@@ -1676,9 +1676,16 @@ const Pt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1676
1676
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1677
1677
|
* See the License for the specific language governing permissions and
|
|
1678
1678
|
* limitations under the License.
|
|
1679
|
-
*/
|
|
1679
|
+
*/ const Ft = {
|
|
1680
|
+
fields: {
|
|
1681
|
+
__type__: {
|
|
1682
|
+
stringValue: "__max__"
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
};
|
|
1686
|
+
|
|
1680
1687
|
/** Extracts the backend's type order for the provided value. */
|
|
1681
|
-
function
|
|
1688
|
+
function qt(t) {
|
|
1682
1689
|
return "nullValue" in t ? 0 /* NullValue */ : "booleanValue" in t ? 1 /* BooleanValue */ : "integerValue" in t || "doubleValue" in t ? 2 /* NumberValue */ : "timestampValue" in t ? 3 /* TimestampValue */ : "stringValue" in t ? 5 /* StringValue */ : "bytesValue" in t ? 6 /* BlobValue */ : "referenceValue" in t ? 7 /* RefValue */ : "geoPointValue" in t ? 8 /* GeoPointValue */ : "arrayValue" in t ? 9 /* ArrayValue */ : "mapValue" in t ? $t(t) ? 4 /* ServerTimestampValue */ :
|
|
1683
1690
|
/** Returns true if the Value represents the canonical {@link #MAX_VALUE} . */
|
|
1684
1691
|
function(t) {
|
|
@@ -1703,194 +1710,197 @@ function xt(t) {
|
|
|
1703
1710
|
/**
|
|
1704
1711
|
* An ObjectValue represents a MapValue in the Firestore Proto and offers the
|
|
1705
1712
|
* ability to add and remove fields (via the ObjectValueBuilder).
|
|
1706
|
-
*/ (t) ?
|
|
1713
|
+
*/ (t) ? 9007199254740991 /* MaxValue */ : 10 /* ObjectValue */ : v();
|
|
1707
1714
|
}
|
|
1708
1715
|
|
|
1709
|
-
/** Tests `left` and `right` for equality based on the backend semantics. */ function
|
|
1710
|
-
if (t ===
|
|
1711
|
-
const
|
|
1712
|
-
if (
|
|
1713
|
-
switch (
|
|
1716
|
+
/** Tests `left` and `right` for equality based on the backend semantics. */ function Ot(t, e) {
|
|
1717
|
+
if (t === e) return !0;
|
|
1718
|
+
const n = qt(t);
|
|
1719
|
+
if (n !== qt(e)) return !1;
|
|
1720
|
+
switch (n) {
|
|
1714
1721
|
case 0 /* NullValue */ :
|
|
1715
1722
|
case 9007199254740991 /* MaxValue */ :
|
|
1716
1723
|
return !0;
|
|
1717
1724
|
|
|
1718
1725
|
case 1 /* BooleanValue */ :
|
|
1719
|
-
return t.booleanValue ===
|
|
1726
|
+
return t.booleanValue === e.booleanValue;
|
|
1720
1727
|
|
|
1721
1728
|
case 4 /* ServerTimestampValue */ :
|
|
1722
|
-
return
|
|
1729
|
+
return xt(t).isEqual(xt(e));
|
|
1723
1730
|
|
|
1724
1731
|
case 3 /* TimestampValue */ :
|
|
1725
|
-
return function(t,
|
|
1726
|
-
if ("string" == typeof t.timestampValue && "string" == typeof
|
|
1732
|
+
return function(t, e) {
|
|
1733
|
+
if ("string" == typeof t.timestampValue && "string" == typeof e.timestampValue && t.timestampValue.length === e.timestampValue.length)
|
|
1727
1734
|
// Use string equality for ISO 8601 timestamps
|
|
1728
|
-
return t.timestampValue ===
|
|
1729
|
-
const
|
|
1730
|
-
return
|
|
1731
|
-
}(t,
|
|
1735
|
+
return t.timestampValue === e.timestampValue;
|
|
1736
|
+
const n = Vt(t.timestampValue), r = Vt(e.timestampValue);
|
|
1737
|
+
return n.seconds === r.seconds && n.nanos === r.nanos;
|
|
1738
|
+
}(t, e);
|
|
1732
1739
|
|
|
1733
1740
|
case 5 /* StringValue */ :
|
|
1734
|
-
return t.stringValue ===
|
|
1741
|
+
return t.stringValue === e.stringValue;
|
|
1735
1742
|
|
|
1736
1743
|
case 6 /* BlobValue */ :
|
|
1737
|
-
return function(t,
|
|
1738
|
-
return Dt(t.bytesValue).isEqual(Dt(
|
|
1739
|
-
}(t,
|
|
1744
|
+
return function(t, e) {
|
|
1745
|
+
return Dt(t.bytesValue).isEqual(Dt(e.bytesValue));
|
|
1746
|
+
}(t, e);
|
|
1740
1747
|
|
|
1741
1748
|
case 7 /* RefValue */ :
|
|
1742
|
-
return t.referenceValue ===
|
|
1749
|
+
return t.referenceValue === e.referenceValue;
|
|
1743
1750
|
|
|
1744
1751
|
case 8 /* GeoPointValue */ :
|
|
1745
|
-
return function(t,
|
|
1746
|
-
return Nt(t.geoPointValue.latitude) === Nt(
|
|
1747
|
-
}(t,
|
|
1752
|
+
return function(t, e) {
|
|
1753
|
+
return Nt(t.geoPointValue.latitude) === Nt(e.geoPointValue.latitude) && Nt(t.geoPointValue.longitude) === Nt(e.geoPointValue.longitude);
|
|
1754
|
+
}(t, e);
|
|
1748
1755
|
|
|
1749
1756
|
case 2 /* NumberValue */ :
|
|
1750
|
-
return function(t,
|
|
1751
|
-
if ("integerValue" in t && "integerValue" in
|
|
1752
|
-
if ("doubleValue" in t && "doubleValue" in
|
|
1753
|
-
const
|
|
1754
|
-
return
|
|
1757
|
+
return function(t, e) {
|
|
1758
|
+
if ("integerValue" in t && "integerValue" in e) return Nt(t.integerValue) === Nt(e.integerValue);
|
|
1759
|
+
if ("doubleValue" in t && "doubleValue" in e) {
|
|
1760
|
+
const n = Nt(t.doubleValue), r = Nt(e.doubleValue);
|
|
1761
|
+
return n === r ? ht(n) === ht(r) : isNaN(n) && isNaN(r);
|
|
1755
1762
|
}
|
|
1756
1763
|
return !1;
|
|
1757
|
-
}(t,
|
|
1764
|
+
}(t, e);
|
|
1758
1765
|
|
|
1759
1766
|
case 9 /* ArrayValue */ :
|
|
1760
|
-
return gt(t.arrayValue.values || [],
|
|
1767
|
+
return gt(t.arrayValue.values || [], e.arrayValue.values || [], Ot);
|
|
1761
1768
|
|
|
1762
1769
|
case 10 /* ObjectValue */ :
|
|
1763
|
-
return function(t,
|
|
1764
|
-
const
|
|
1765
|
-
if (Et(
|
|
1766
|
-
for (const t in
|
|
1770
|
+
return function(t, e) {
|
|
1771
|
+
const n = t.mapValue.fields || {}, r = e.mapValue.fields || {};
|
|
1772
|
+
if (Et(n) !== Et(r)) return !1;
|
|
1773
|
+
for (const t in n) if (n.hasOwnProperty(t) && (void 0 === r[t] || !Ot(n[t], r[t]))) return !1;
|
|
1767
1774
|
return !0;
|
|
1768
1775
|
}
|
|
1769
|
-
/** Returns true if the ArrayValue contains the specified element. */ (t,
|
|
1776
|
+
/** Returns true if the ArrayValue contains the specified element. */ (t, e);
|
|
1770
1777
|
|
|
1771
1778
|
default:
|
|
1772
1779
|
return v();
|
|
1773
1780
|
}
|
|
1774
1781
|
}
|
|
1775
1782
|
|
|
1776
|
-
function
|
|
1777
|
-
return void 0 !== (t.values || []).find((t =>
|
|
1783
|
+
function Ct(t, e) {
|
|
1784
|
+
return void 0 !== (t.values || []).find((t => Ot(t, e)));
|
|
1778
1785
|
}
|
|
1779
1786
|
|
|
1780
|
-
function
|
|
1781
|
-
if (t ===
|
|
1782
|
-
const
|
|
1783
|
-
if (
|
|
1784
|
-
switch (
|
|
1787
|
+
function Lt(t, e) {
|
|
1788
|
+
if (t === e) return 0;
|
|
1789
|
+
const n = qt(t), r = qt(e);
|
|
1790
|
+
if (n !== r) return _t(n, r);
|
|
1791
|
+
switch (n) {
|
|
1785
1792
|
case 0 /* NullValue */ :
|
|
1786
1793
|
case 9007199254740991 /* MaxValue */ :
|
|
1787
1794
|
return 0;
|
|
1788
1795
|
|
|
1789
1796
|
case 1 /* BooleanValue */ :
|
|
1790
|
-
return _t(t.booleanValue,
|
|
1797
|
+
return _t(t.booleanValue, e.booleanValue);
|
|
1791
1798
|
|
|
1792
1799
|
case 2 /* NumberValue */ :
|
|
1793
|
-
return function(t,
|
|
1794
|
-
const
|
|
1795
|
-
return
|
|
1800
|
+
return function(t, e) {
|
|
1801
|
+
const n = Nt(t.integerValue || t.doubleValue), r = Nt(e.integerValue || e.doubleValue);
|
|
1802
|
+
return n < r ? -1 : n > r ? 1 : n === r ? 0 :
|
|
1796
1803
|
// one or both are NaN.
|
|
1797
|
-
isNaN(
|
|
1798
|
-
}(t,
|
|
1804
|
+
isNaN(n) ? isNaN(r) ? 0 : -1 : 1;
|
|
1805
|
+
}(t, e);
|
|
1799
1806
|
|
|
1800
1807
|
case 3 /* TimestampValue */ :
|
|
1801
|
-
return
|
|
1808
|
+
return kt(t.timestampValue, e.timestampValue);
|
|
1802
1809
|
|
|
1803
1810
|
case 4 /* ServerTimestampValue */ :
|
|
1804
|
-
return
|
|
1811
|
+
return kt(xt(t), xt(e));
|
|
1805
1812
|
|
|
1806
1813
|
case 5 /* StringValue */ :
|
|
1807
|
-
return _t(t.stringValue,
|
|
1814
|
+
return _t(t.stringValue, e.stringValue);
|
|
1808
1815
|
|
|
1809
1816
|
case 6 /* BlobValue */ :
|
|
1810
|
-
return function(t,
|
|
1811
|
-
const
|
|
1812
|
-
return
|
|
1813
|
-
}(t.bytesValue,
|
|
1817
|
+
return function(t, e) {
|
|
1818
|
+
const n = Dt(t), r = Dt(e);
|
|
1819
|
+
return n.compareTo(r);
|
|
1820
|
+
}(t.bytesValue, e.bytesValue);
|
|
1814
1821
|
|
|
1815
1822
|
case 7 /* RefValue */ :
|
|
1816
|
-
return function(t,
|
|
1817
|
-
const
|
|
1818
|
-
for (let t = 0; t <
|
|
1819
|
-
const
|
|
1820
|
-
if (0 !==
|
|
1823
|
+
return function(t, e) {
|
|
1824
|
+
const n = t.split("/"), r = e.split("/");
|
|
1825
|
+
for (let t = 0; t < n.length && t < r.length; t++) {
|
|
1826
|
+
const e = _t(n[t], r[t]);
|
|
1827
|
+
if (0 !== e) return e;
|
|
1821
1828
|
}
|
|
1822
|
-
return _t(
|
|
1823
|
-
}(t.referenceValue,
|
|
1829
|
+
return _t(n.length, r.length);
|
|
1830
|
+
}(t.referenceValue, e.referenceValue);
|
|
1824
1831
|
|
|
1825
1832
|
case 8 /* GeoPointValue */ :
|
|
1826
|
-
return function(t,
|
|
1827
|
-
const
|
|
1828
|
-
if (0 !==
|
|
1829
|
-
return _t(Nt(t.longitude), Nt(
|
|
1830
|
-
}(t.geoPointValue,
|
|
1833
|
+
return function(t, e) {
|
|
1834
|
+
const n = _t(Nt(t.latitude), Nt(e.latitude));
|
|
1835
|
+
if (0 !== n) return n;
|
|
1836
|
+
return _t(Nt(t.longitude), Nt(e.longitude));
|
|
1837
|
+
}(t.geoPointValue, e.geoPointValue);
|
|
1831
1838
|
|
|
1832
1839
|
case 9 /* ArrayValue */ :
|
|
1833
|
-
return function(t,
|
|
1834
|
-
const
|
|
1835
|
-
for (let t = 0; t <
|
|
1836
|
-
const
|
|
1837
|
-
if (
|
|
1840
|
+
return function(t, e) {
|
|
1841
|
+
const n = t.values || [], r = e.values || [];
|
|
1842
|
+
for (let t = 0; t < n.length && t < r.length; ++t) {
|
|
1843
|
+
const e = Lt(n[t], r[t]);
|
|
1844
|
+
if (e) return e;
|
|
1838
1845
|
}
|
|
1839
|
-
return _t(
|
|
1840
|
-
}(t.arrayValue,
|
|
1846
|
+
return _t(n.length, r.length);
|
|
1847
|
+
}(t.arrayValue, e.arrayValue);
|
|
1841
1848
|
|
|
1842
1849
|
case 10 /* ObjectValue */ :
|
|
1843
|
-
return function(t,
|
|
1844
|
-
|
|
1850
|
+
return function(t, e) {
|
|
1851
|
+
if (t === Ft && e === Ft) return 0;
|
|
1852
|
+
if (t === Ft) return 1;
|
|
1853
|
+
if (e === Ft) return -1;
|
|
1854
|
+
const n = t.fields || {}, r = Object.keys(n), s = e.fields || {}, i = Object.keys(s);
|
|
1845
1855
|
// Even though MapValues are likely sorted correctly based on their insertion
|
|
1846
1856
|
// order (e.g. when received from the backend), local modifications can bring
|
|
1847
1857
|
// elements out of order. We need to re-sort the elements to ensure that
|
|
1848
1858
|
// canonical IDs are independent of insertion order.
|
|
1849
1859
|
r.sort(), i.sort();
|
|
1850
1860
|
for (let t = 0; t < r.length && t < i.length; ++t) {
|
|
1851
|
-
const
|
|
1852
|
-
if (0 !==
|
|
1853
|
-
const o =
|
|
1861
|
+
const e = _t(r[t], i[t]);
|
|
1862
|
+
if (0 !== e) return e;
|
|
1863
|
+
const o = Lt(n[r[t]], s[i[t]]);
|
|
1854
1864
|
if (0 !== o) return o;
|
|
1855
1865
|
}
|
|
1856
1866
|
return _t(r.length, i.length);
|
|
1857
1867
|
}
|
|
1858
|
-
/** Returns a reference value for the provided database and key. */ (t.mapValue,
|
|
1868
|
+
/** Returns a reference value for the provided database and key. */ (t.mapValue, e.mapValue);
|
|
1859
1869
|
|
|
1860
1870
|
default:
|
|
1861
1871
|
throw v();
|
|
1862
1872
|
}
|
|
1863
1873
|
}
|
|
1864
1874
|
|
|
1865
|
-
function
|
|
1866
|
-
if ("string" == typeof t && "string" == typeof
|
|
1867
|
-
const
|
|
1868
|
-
return 0 !== s ? s : _t(
|
|
1875
|
+
function kt(t, e) {
|
|
1876
|
+
if ("string" == typeof t && "string" == typeof e && t.length === e.length) return _t(t, e);
|
|
1877
|
+
const n = Vt(t), r = Vt(e), s = _t(n.seconds, r.seconds);
|
|
1878
|
+
return 0 !== s ? s : _t(n.nanos, r.nanos);
|
|
1869
1879
|
}
|
|
1870
1880
|
|
|
1871
|
-
function
|
|
1881
|
+
function Ut(t, e) {
|
|
1872
1882
|
return {
|
|
1873
|
-
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${
|
|
1883
|
+
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${e.path.canonicalString()}`
|
|
1874
1884
|
};
|
|
1875
1885
|
}
|
|
1876
1886
|
|
|
1877
|
-
/** Returns true if `value` is an ArrayValue. */ function
|
|
1887
|
+
/** Returns true if `value` is an ArrayValue. */ function jt(t) {
|
|
1878
1888
|
return !!t && "arrayValue" in t;
|
|
1879
1889
|
}
|
|
1880
1890
|
|
|
1881
|
-
/** Returns true if `value` is a NullValue. */ function
|
|
1891
|
+
/** Returns true if `value` is a NullValue. */ function Mt(t) {
|
|
1882
1892
|
return !!t && "nullValue" in t;
|
|
1883
1893
|
}
|
|
1884
1894
|
|
|
1885
|
-
/** Returns true if `value` is NaN. */ function
|
|
1895
|
+
/** Returns true if `value` is NaN. */ function Bt(t) {
|
|
1886
1896
|
return !!t && "doubleValue" in t && isNaN(Number(t.doubleValue));
|
|
1887
1897
|
}
|
|
1888
1898
|
|
|
1889
|
-
/** Returns true if `value` is a MapValue. */ function
|
|
1899
|
+
/** Returns true if `value` is a MapValue. */ function zt(t) {
|
|
1890
1900
|
return !!t && "mapValue" in t;
|
|
1891
1901
|
}
|
|
1892
1902
|
|
|
1893
|
-
/** Creates a deep copy of `source`. */ function
|
|
1903
|
+
/** Creates a deep copy of `source`. */ function Gt(t) {
|
|
1894
1904
|
if (t.geoPointValue) return {
|
|
1895
1905
|
geoPointValue: Object.assign({}, t.geoPointValue)
|
|
1896
1906
|
};
|
|
@@ -1898,31 +1908,31 @@ function kt(t, n) {
|
|
|
1898
1908
|
timestampValue: Object.assign({}, t.timestampValue)
|
|
1899
1909
|
};
|
|
1900
1910
|
if (t.mapValue) {
|
|
1901
|
-
const
|
|
1911
|
+
const e = {
|
|
1902
1912
|
mapValue: {
|
|
1903
1913
|
fields: {}
|
|
1904
1914
|
}
|
|
1905
1915
|
};
|
|
1906
|
-
return Tt(t.mapValue.fields, ((t,
|
|
1916
|
+
return Tt(t.mapValue.fields, ((t, n) => e.mapValue.fields[t] = Gt(n))), e;
|
|
1907
1917
|
}
|
|
1908
1918
|
if (t.arrayValue) {
|
|
1909
|
-
const
|
|
1919
|
+
const e = {
|
|
1910
1920
|
arrayValue: {
|
|
1911
1921
|
values: []
|
|
1912
1922
|
}
|
|
1913
1923
|
};
|
|
1914
|
-
for (let
|
|
1915
|
-
return
|
|
1924
|
+
for (let n = 0; n < (t.arrayValue.values || []).length; ++n) e.arrayValue.values[n] = Gt(t.arrayValue.values[n]);
|
|
1925
|
+
return e;
|
|
1916
1926
|
}
|
|
1917
1927
|
return Object.assign({}, t);
|
|
1918
1928
|
}
|
|
1919
1929
|
|
|
1920
|
-
class
|
|
1930
|
+
class Qt {
|
|
1921
1931
|
constructor(t) {
|
|
1922
1932
|
this.value = t;
|
|
1923
1933
|
}
|
|
1924
1934
|
static empty() {
|
|
1925
|
-
return new
|
|
1935
|
+
return new Qt({
|
|
1926
1936
|
mapValue: {}
|
|
1927
1937
|
});
|
|
1928
1938
|
}
|
|
@@ -1934,10 +1944,10 @@ class Gt {
|
|
|
1934
1944
|
*/ field(t) {
|
|
1935
1945
|
if (t.isEmpty()) return this.value;
|
|
1936
1946
|
{
|
|
1937
|
-
let
|
|
1938
|
-
for (let
|
|
1939
|
-
!
|
|
1940
|
-
return
|
|
1947
|
+
let e = this.value;
|
|
1948
|
+
for (let n = 0; n < t.length - 1; ++n) if (e = (e.mapValue.fields || {})[t.get(n)],
|
|
1949
|
+
!zt(e)) return null;
|
|
1950
|
+
return e = (e.mapValue.fields || {})[t.lastSegment()], e || null;
|
|
1941
1951
|
}
|
|
1942
1952
|
}
|
|
1943
1953
|
/**
|
|
@@ -1945,25 +1955,25 @@ class Gt {
|
|
|
1945
1955
|
*
|
|
1946
1956
|
* @param path - The field path to set.
|
|
1947
1957
|
* @param value - The value to set.
|
|
1948
|
-
*/ set(t,
|
|
1949
|
-
this.getFieldsMap(t.popLast())[t.lastSegment()] =
|
|
1958
|
+
*/ set(t, e) {
|
|
1959
|
+
this.getFieldsMap(t.popLast())[t.lastSegment()] = Gt(e);
|
|
1950
1960
|
}
|
|
1951
1961
|
/**
|
|
1952
1962
|
* Sets the provided fields to the provided values.
|
|
1953
1963
|
*
|
|
1954
1964
|
* @param data - A map of fields to values (or null for deletes).
|
|
1955
1965
|
*/ setAll(t) {
|
|
1956
|
-
let
|
|
1966
|
+
let e = et.emptyPath(), n = {}, r = [];
|
|
1957
1967
|
t.forEach(((t, s) => {
|
|
1958
|
-
if (!
|
|
1968
|
+
if (!e.isImmediateParentOf(s)) {
|
|
1959
1969
|
// Insert the accumulated changes at this parent location
|
|
1960
|
-
const t = this.getFieldsMap(
|
|
1961
|
-
this.applyChanges(t,
|
|
1970
|
+
const t = this.getFieldsMap(e);
|
|
1971
|
+
this.applyChanges(t, n, r), n = {}, r = [], e = s.popLast();
|
|
1962
1972
|
}
|
|
1963
|
-
t ?
|
|
1973
|
+
t ? n[s.lastSegment()] = Gt(t) : r.push(s.lastSegment());
|
|
1964
1974
|
}));
|
|
1965
|
-
const s = this.getFieldsMap(
|
|
1966
|
-
this.applyChanges(s,
|
|
1975
|
+
const s = this.getFieldsMap(e);
|
|
1976
|
+
this.applyChanges(s, n, r);
|
|
1967
1977
|
}
|
|
1968
1978
|
/**
|
|
1969
1979
|
* Removes the field at the specified path. If there is no field at the
|
|
@@ -1971,39 +1981,39 @@ class Gt {
|
|
|
1971
1981
|
*
|
|
1972
1982
|
* @param path - The field path to remove.
|
|
1973
1983
|
*/ delete(t) {
|
|
1974
|
-
const
|
|
1975
|
-
|
|
1984
|
+
const e = this.field(t.popLast());
|
|
1985
|
+
zt(e) && e.mapValue.fields && delete e.mapValue.fields[t.lastSegment()];
|
|
1976
1986
|
}
|
|
1977
1987
|
isEqual(t) {
|
|
1978
|
-
return
|
|
1988
|
+
return Ot(this.value, t.value);
|
|
1979
1989
|
}
|
|
1980
1990
|
/**
|
|
1981
1991
|
* Returns the map that contains the leaf element of `path`. If the parent
|
|
1982
1992
|
* entry does not yet exist, or if it is not a map, a new map will be created.
|
|
1983
1993
|
*/ getFieldsMap(t) {
|
|
1984
|
-
let
|
|
1985
|
-
|
|
1994
|
+
let e = this.value;
|
|
1995
|
+
e.mapValue.fields || (e.mapValue = {
|
|
1986
1996
|
fields: {}
|
|
1987
1997
|
});
|
|
1988
|
-
for (let
|
|
1989
|
-
let r =
|
|
1990
|
-
|
|
1998
|
+
for (let n = 0; n < t.length; ++n) {
|
|
1999
|
+
let r = e.mapValue.fields[t.get(n)];
|
|
2000
|
+
zt(r) && r.mapValue.fields || (r = {
|
|
1991
2001
|
mapValue: {
|
|
1992
2002
|
fields: {}
|
|
1993
2003
|
}
|
|
1994
|
-
},
|
|
2004
|
+
}, e.mapValue.fields[t.get(n)] = r), e = r;
|
|
1995
2005
|
}
|
|
1996
|
-
return
|
|
2006
|
+
return e.mapValue.fields;
|
|
1997
2007
|
}
|
|
1998
2008
|
/**
|
|
1999
2009
|
* Modifies `fieldsMap` by adding, replacing or deleting the specified
|
|
2000
2010
|
* entries.
|
|
2001
|
-
*/ applyChanges(t,
|
|
2002
|
-
Tt(
|
|
2003
|
-
for (const
|
|
2011
|
+
*/ applyChanges(t, e, n) {
|
|
2012
|
+
Tt(e, ((e, n) => t[e] = n));
|
|
2013
|
+
for (const e of n) delete t[e];
|
|
2004
2014
|
}
|
|
2005
2015
|
clone() {
|
|
2006
|
-
return new Gt(
|
|
2016
|
+
return new Qt(Gt(this.value));
|
|
2007
2017
|
}
|
|
2008
2018
|
}
|
|
2009
2019
|
|
|
@@ -2032,45 +2042,45 @@ class Gt {
|
|
|
2032
2042
|
* not transition to one of these states even after all mutations have been
|
|
2033
2043
|
* applied, `isValidDocument()` returns false and the document should be removed
|
|
2034
2044
|
* from all views.
|
|
2035
|
-
*/ class
|
|
2036
|
-
constructor(t,
|
|
2037
|
-
this.key = t, this.documentType =
|
|
2045
|
+
*/ class Wt {
|
|
2046
|
+
constructor(t, e, n, r, s, i) {
|
|
2047
|
+
this.key = t, this.documentType = e, this.version = n, this.readTime = r, this.data = s,
|
|
2038
2048
|
this.documentState = i;
|
|
2039
2049
|
}
|
|
2040
2050
|
/**
|
|
2041
2051
|
* Creates a document with no known version or data, but which can serve as
|
|
2042
2052
|
* base document for mutations.
|
|
2043
2053
|
*/ static newInvalidDocument(t) {
|
|
2044
|
-
return new
|
|
2054
|
+
return new Wt(t, 0 /* INVALID */ , bt.min(), bt.min(), Qt.empty(), 0 /* SYNCED */);
|
|
2045
2055
|
}
|
|
2046
2056
|
/**
|
|
2047
2057
|
* Creates a new document that is known to exist with the given data at the
|
|
2048
2058
|
* given version.
|
|
2049
|
-
*/ static newFoundDocument(t,
|
|
2050
|
-
return new
|
|
2059
|
+
*/ static newFoundDocument(t, e, n) {
|
|
2060
|
+
return new Wt(t, 1 /* FOUND_DOCUMENT */ , e, bt.min(), n, 0 /* SYNCED */);
|
|
2051
2061
|
}
|
|
2052
|
-
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t,
|
|
2053
|
-
return new
|
|
2062
|
+
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t, e) {
|
|
2063
|
+
return new Wt(t, 2 /* NO_DOCUMENT */ , e, bt.min(), Qt.empty(), 0 /* SYNCED */);
|
|
2054
2064
|
}
|
|
2055
2065
|
/**
|
|
2056
2066
|
* Creates a new document that is known to exist at the given version but
|
|
2057
2067
|
* whose data is not known (e.g. a document that was updated without a known
|
|
2058
2068
|
* base document).
|
|
2059
|
-
*/ static newUnknownDocument(t,
|
|
2060
|
-
return new
|
|
2069
|
+
*/ static newUnknownDocument(t, e) {
|
|
2070
|
+
return new Wt(t, 3 /* UNKNOWN_DOCUMENT */ , e, bt.min(), Qt.empty(), 2 /* HAS_COMMITTED_MUTATIONS */);
|
|
2061
2071
|
}
|
|
2062
2072
|
/**
|
|
2063
2073
|
* Changes the document type to indicate that it exists and that its version
|
|
2064
2074
|
* and data are known.
|
|
2065
|
-
*/ convertToFoundDocument(t,
|
|
2066
|
-
return this.version = t, this.documentType = 1 /* FOUND_DOCUMENT */ , this.data =
|
|
2075
|
+
*/ convertToFoundDocument(t, e) {
|
|
2076
|
+
return this.version = t, this.documentType = 1 /* FOUND_DOCUMENT */ , this.data = e,
|
|
2067
2077
|
this.documentState = 0 /* SYNCED */ , this;
|
|
2068
2078
|
}
|
|
2069
2079
|
/**
|
|
2070
2080
|
* Changes the document type to indicate that it doesn't exist at the given
|
|
2071
2081
|
* version.
|
|
2072
2082
|
*/ convertToNoDocument(t) {
|
|
2073
|
-
return this.version = t, this.documentType = 2 /* NO_DOCUMENT */ , this.data =
|
|
2083
|
+
return this.version = t, this.documentType = 2 /* NO_DOCUMENT */ , this.data = Qt.empty(),
|
|
2074
2084
|
this.documentState = 0 /* SYNCED */ , this;
|
|
2075
2085
|
}
|
|
2076
2086
|
/**
|
|
@@ -2078,7 +2088,7 @@ class Gt {
|
|
|
2078
2088
|
* that its data is not known (e.g. a document that was updated without a known
|
|
2079
2089
|
* base document).
|
|
2080
2090
|
*/ convertToUnknownDocument(t) {
|
|
2081
|
-
return this.version = t, this.documentType = 3 /* UNKNOWN_DOCUMENT */ , this.data =
|
|
2091
|
+
return this.version = t, this.documentType = 3 /* UNKNOWN_DOCUMENT */ , this.data = Qt.empty(),
|
|
2082
2092
|
this.documentState = 2 /* HAS_COMMITTED_MUTATIONS */ , this;
|
|
2083
2093
|
}
|
|
2084
2094
|
setHasCommittedMutations() {
|
|
@@ -2112,10 +2122,10 @@ class Gt {
|
|
|
2112
2122
|
return 3 /* UNKNOWN_DOCUMENT */ === this.documentType;
|
|
2113
2123
|
}
|
|
2114
2124
|
isEqual(t) {
|
|
2115
|
-
return t instanceof
|
|
2125
|
+
return t instanceof Wt && this.key.isEqual(t.key) && this.version.isEqual(t.version) && this.documentType === t.documentType && this.documentState === t.documentState && this.data.isEqual(t.data);
|
|
2116
2126
|
}
|
|
2117
2127
|
mutableCopy() {
|
|
2118
|
-
return new
|
|
2128
|
+
return new Wt(this.key, this.documentType, this.version, this.readTime, this.data.clone(), this.documentState);
|
|
2119
2129
|
}
|
|
2120
2130
|
toString() {
|
|
2121
2131
|
return `Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`;
|
|
@@ -2139,9 +2149,9 @@ class Gt {
|
|
|
2139
2149
|
* limitations under the License.
|
|
2140
2150
|
*/
|
|
2141
2151
|
// Visible for testing
|
|
2142
|
-
class
|
|
2143
|
-
constructor(t,
|
|
2144
|
-
this.path = t, this.collectionGroup =
|
|
2152
|
+
class Yt {
|
|
2153
|
+
constructor(t, e = null, n = [], r = [], s = null, i = null, o = null) {
|
|
2154
|
+
this.path = t, this.collectionGroup = e, this.orderBy = n, this.filters = r, this.limit = s,
|
|
2145
2155
|
this.startAt = i, this.endAt = o, this.P = null;
|
|
2146
2156
|
}
|
|
2147
2157
|
}
|
|
@@ -2153,26 +2163,26 @@ class Wt {
|
|
|
2153
2163
|
* NOTE: you should always construct `Target` from `Query.toTarget` instead of
|
|
2154
2164
|
* using this factory method, because `Query` provides an implicit `orderBy`
|
|
2155
2165
|
* property.
|
|
2156
|
-
*/ function
|
|
2157
|
-
return new
|
|
2166
|
+
*/ function Ht(t, e = null, n = [], r = [], s = null, i = null, o = null) {
|
|
2167
|
+
return new Yt(t, e, n, r, s, i, o);
|
|
2158
2168
|
}
|
|
2159
2169
|
|
|
2160
|
-
class
|
|
2161
|
-
constructor(t,
|
|
2162
|
-
super(), this.field = t, this.op =
|
|
2170
|
+
class Kt extends class {} {
|
|
2171
|
+
constructor(t, e, n) {
|
|
2172
|
+
super(), this.field = t, this.op = e, this.value = n;
|
|
2163
2173
|
}
|
|
2164
2174
|
/**
|
|
2165
2175
|
* Creates a filter based on the provided arguments.
|
|
2166
|
-
*/ static create(t,
|
|
2167
|
-
return t.isKeyField() ? "in" /* IN */ ===
|
|
2176
|
+
*/ static create(t, e, n) {
|
|
2177
|
+
return t.isKeyField() ? "in" /* IN */ === e || "not-in" /* NOT_IN */ === e ? this.V(t, e, n) : new Jt(t, e, n) : "array-contains" /* ARRAY_CONTAINS */ === e ? new ee(t, n) : "in" /* IN */ === e ? new ne(t, n) : "not-in" /* NOT_IN */ === e ? new re(t, n) : "array-contains-any" /* ARRAY_CONTAINS_ANY */ === e ? new se(t, n) : new Kt(t, e, n);
|
|
2168
2178
|
}
|
|
2169
|
-
static V(t,
|
|
2170
|
-
return "in" /* IN */ ===
|
|
2179
|
+
static V(t, e, n) {
|
|
2180
|
+
return "in" /* IN */ === e ? new Xt(t, n) : new Zt(t, n);
|
|
2171
2181
|
}
|
|
2172
2182
|
matches(t) {
|
|
2173
|
-
const
|
|
2183
|
+
const e = t.data.field(this.field);
|
|
2174
2184
|
// Types do not have to match in NOT_EQUAL filters.
|
|
2175
|
-
return "!=" /* NOT_EQUAL */ === this.op ? null !==
|
|
2185
|
+
return "!=" /* NOT_EQUAL */ === this.op ? null !== e && this.N(Lt(e, this.value)) : null !== e && qt(this.value) === qt(e) && this.N(Lt(e, this.value));
|
|
2176
2186
|
// Only compare types with matching backend order (such as double and int).
|
|
2177
2187
|
}
|
|
2178
2188
|
N(t) {
|
|
@@ -2205,79 +2215,79 @@ class Ht extends class {} {
|
|
|
2205
2215
|
}
|
|
2206
2216
|
|
|
2207
2217
|
/** Filter that matches on key fields (i.e. '__name__'). */
|
|
2208
|
-
class
|
|
2209
|
-
constructor(t,
|
|
2210
|
-
super(t,
|
|
2218
|
+
class Jt extends Kt {
|
|
2219
|
+
constructor(t, e, n) {
|
|
2220
|
+
super(t, e, n), this.key = nt.fromName(n.referenceValue);
|
|
2211
2221
|
}
|
|
2212
2222
|
matches(t) {
|
|
2213
|
-
const
|
|
2214
|
-
return this.N(
|
|
2223
|
+
const e = nt.comparator(t.key, this.key);
|
|
2224
|
+
return this.N(e);
|
|
2215
2225
|
}
|
|
2216
2226
|
}
|
|
2217
2227
|
|
|
2218
|
-
/** Filter that matches on key fields within an array. */ class
|
|
2219
|
-
constructor(t,
|
|
2220
|
-
super(t, "in" /* IN */ ,
|
|
2228
|
+
/** Filter that matches on key fields within an array. */ class Xt extends Kt {
|
|
2229
|
+
constructor(t, e) {
|
|
2230
|
+
super(t, "in" /* IN */ , e), this.keys = te("in" /* IN */ , e);
|
|
2221
2231
|
}
|
|
2222
2232
|
matches(t) {
|
|
2223
|
-
return this.keys.some((
|
|
2233
|
+
return this.keys.some((e => e.isEqual(t.key)));
|
|
2224
2234
|
}
|
|
2225
2235
|
}
|
|
2226
2236
|
|
|
2227
|
-
/** Filter that matches on key fields not present within an array. */ class
|
|
2228
|
-
constructor(t,
|
|
2229
|
-
super(t, "not-in" /* NOT_IN */ ,
|
|
2237
|
+
/** Filter that matches on key fields not present within an array. */ class Zt extends Kt {
|
|
2238
|
+
constructor(t, e) {
|
|
2239
|
+
super(t, "not-in" /* NOT_IN */ , e), this.keys = te("not-in" /* NOT_IN */ , e);
|
|
2230
2240
|
}
|
|
2231
2241
|
matches(t) {
|
|
2232
|
-
return !this.keys.some((
|
|
2242
|
+
return !this.keys.some((e => e.isEqual(t.key)));
|
|
2233
2243
|
}
|
|
2234
2244
|
}
|
|
2235
2245
|
|
|
2236
|
-
function
|
|
2237
|
-
var
|
|
2238
|
-
return ((null === (
|
|
2246
|
+
function te(t, e) {
|
|
2247
|
+
var n;
|
|
2248
|
+
return ((null === (n = e.arrayValue) || void 0 === n ? void 0 : n.values) || []).map((t => nt.fromName(t.referenceValue)));
|
|
2239
2249
|
}
|
|
2240
2250
|
|
|
2241
|
-
/** A Filter that implements the array-contains operator. */ class
|
|
2242
|
-
constructor(t,
|
|
2243
|
-
super(t, "array-contains" /* ARRAY_CONTAINS */ ,
|
|
2251
|
+
/** A Filter that implements the array-contains operator. */ class ee extends Kt {
|
|
2252
|
+
constructor(t, e) {
|
|
2253
|
+
super(t, "array-contains" /* ARRAY_CONTAINS */ , e);
|
|
2244
2254
|
}
|
|
2245
2255
|
matches(t) {
|
|
2246
|
-
const
|
|
2247
|
-
return
|
|
2256
|
+
const e = t.data.field(this.field);
|
|
2257
|
+
return jt(e) && Ct(e.arrayValue, this.value);
|
|
2248
2258
|
}
|
|
2249
2259
|
}
|
|
2250
2260
|
|
|
2251
|
-
/** A Filter that implements the IN operator. */ class
|
|
2252
|
-
constructor(t,
|
|
2253
|
-
super(t, "in" /* IN */ ,
|
|
2261
|
+
/** A Filter that implements the IN operator. */ class ne extends Kt {
|
|
2262
|
+
constructor(t, e) {
|
|
2263
|
+
super(t, "in" /* IN */ , e);
|
|
2254
2264
|
}
|
|
2255
2265
|
matches(t) {
|
|
2256
|
-
const
|
|
2257
|
-
return null !==
|
|
2266
|
+
const e = t.data.field(this.field);
|
|
2267
|
+
return null !== e && Ct(this.value.arrayValue, e);
|
|
2258
2268
|
}
|
|
2259
2269
|
}
|
|
2260
2270
|
|
|
2261
|
-
/** A Filter that implements the not-in operator. */ class
|
|
2262
|
-
constructor(t,
|
|
2263
|
-
super(t, "not-in" /* NOT_IN */ ,
|
|
2271
|
+
/** A Filter that implements the not-in operator. */ class re extends Kt {
|
|
2272
|
+
constructor(t, e) {
|
|
2273
|
+
super(t, "not-in" /* NOT_IN */ , e);
|
|
2264
2274
|
}
|
|
2265
2275
|
matches(t) {
|
|
2266
|
-
if (
|
|
2276
|
+
if (Ct(this.value.arrayValue, {
|
|
2267
2277
|
nullValue: "NULL_VALUE"
|
|
2268
2278
|
})) return !1;
|
|
2269
|
-
const
|
|
2270
|
-
return null !==
|
|
2279
|
+
const e = t.data.field(this.field);
|
|
2280
|
+
return null !== e && !Ct(this.value.arrayValue, e);
|
|
2271
2281
|
}
|
|
2272
2282
|
}
|
|
2273
2283
|
|
|
2274
|
-
/** A Filter that implements the array-contains-any operator. */ class
|
|
2275
|
-
constructor(t,
|
|
2276
|
-
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ ,
|
|
2284
|
+
/** A Filter that implements the array-contains-any operator. */ class se extends Kt {
|
|
2285
|
+
constructor(t, e) {
|
|
2286
|
+
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ , e);
|
|
2277
2287
|
}
|
|
2278
2288
|
matches(t) {
|
|
2279
|
-
const
|
|
2280
|
-
return !(!
|
|
2289
|
+
const e = t.data.field(this.field);
|
|
2290
|
+
return !(!jt(e) || !e.arrayValue.values) && e.arrayValue.values.some((t => Ct(this.value.arrayValue, t)));
|
|
2281
2291
|
}
|
|
2282
2292
|
}
|
|
2283
2293
|
|
|
@@ -2294,30 +2304,30 @@ function Zt(t, n) {
|
|
|
2294
2304
|
* Bound provides a function to determine whether a document comes before or
|
|
2295
2305
|
* after a bound. This is influenced by whether the position is just before or
|
|
2296
2306
|
* just after the provided values.
|
|
2297
|
-
*/ class
|
|
2298
|
-
constructor(t,
|
|
2299
|
-
this.position = t, this.inclusive =
|
|
2307
|
+
*/ class ie {
|
|
2308
|
+
constructor(t, e) {
|
|
2309
|
+
this.position = t, this.inclusive = e;
|
|
2300
2310
|
}
|
|
2301
2311
|
}
|
|
2302
2312
|
|
|
2303
2313
|
/**
|
|
2304
2314
|
* An ordering on a field, in some Direction. Direction defaults to ASCENDING.
|
|
2305
|
-
*/ class
|
|
2306
|
-
constructor(t,
|
|
2307
|
-
this.field = t, this.dir =
|
|
2315
|
+
*/ class oe {
|
|
2316
|
+
constructor(t, e = "asc" /* ASCENDING */) {
|
|
2317
|
+
this.field = t, this.dir = e;
|
|
2308
2318
|
}
|
|
2309
2319
|
}
|
|
2310
2320
|
|
|
2311
|
-
function
|
|
2312
|
-
return t.dir ===
|
|
2321
|
+
function ue(t, e) {
|
|
2322
|
+
return t.dir === e.dir && t.field.isEqual(e.field);
|
|
2313
2323
|
}
|
|
2314
2324
|
|
|
2315
|
-
function
|
|
2316
|
-
if (null === t) return null ===
|
|
2317
|
-
if (null ===
|
|
2318
|
-
if (t.inclusive !==
|
|
2319
|
-
for (let
|
|
2320
|
-
if (!
|
|
2325
|
+
function ce(t, e) {
|
|
2326
|
+
if (null === t) return null === e;
|
|
2327
|
+
if (null === e) return !1;
|
|
2328
|
+
if (t.inclusive !== e.inclusive || t.position.length !== e.position.length) return !1;
|
|
2329
|
+
for (let n = 0; n < t.position.length; n++) {
|
|
2330
|
+
if (!Ot(t.position[n], e.position[n])) return !1;
|
|
2321
2331
|
}
|
|
2322
2332
|
return !0;
|
|
2323
2333
|
}
|
|
@@ -2344,29 +2354,25 @@ function cn(t, n) {
|
|
|
2344
2354
|
* query the RemoteStore results.
|
|
2345
2355
|
*
|
|
2346
2356
|
* Visible for testing.
|
|
2347
|
-
*/ class
|
|
2357
|
+
*/ class ae {
|
|
2348
2358
|
/**
|
|
2349
2359
|
* Initializes a Query with a path and optional additional query constraints.
|
|
2350
2360
|
* Path must currently be empty if this is a collection group query.
|
|
2351
2361
|
*/
|
|
2352
|
-
constructor(t,
|
|
2353
|
-
this.path = t, this.collectionGroup =
|
|
2362
|
+
constructor(t, e = null, n = [], r = [], s = null, i = "F" /* First */ , o = null, u = null) {
|
|
2363
|
+
this.path = t, this.collectionGroup = e, this.explicitOrderBy = n, this.filters = r,
|
|
2354
2364
|
this.limit = s, this.limitType = i, this.startAt = o, this.endAt = u, this.$ = null,
|
|
2355
2365
|
// The corresponding `Target` of this `Query` instance.
|
|
2356
2366
|
this.S = null, this.startAt, this.endAt;
|
|
2357
2367
|
}
|
|
2358
2368
|
}
|
|
2359
2369
|
|
|
2360
|
-
/** Creates a new Query for a query that matches all documents at `path` */ function
|
|
2361
|
-
return !at(t.limit) && "L" /* Last */ === t.limitType;
|
|
2362
|
-
}
|
|
2363
|
-
|
|
2364
|
-
function ln(t) {
|
|
2370
|
+
/** Creates a new Query for a query that matches all documents at `path` */ function he(t) {
|
|
2365
2371
|
return t.explicitOrderBy.length > 0 ? t.explicitOrderBy[0].field : null;
|
|
2366
2372
|
}
|
|
2367
2373
|
|
|
2368
|
-
function
|
|
2369
|
-
for (const
|
|
2374
|
+
function le(t) {
|
|
2375
|
+
for (const e of t.filters) if (e.D()) return e.field;
|
|
2370
2376
|
return null;
|
|
2371
2377
|
}
|
|
2372
2378
|
|
|
@@ -2378,7 +2384,7 @@ function fn(t) {
|
|
|
2378
2384
|
* Returns whether the query matches a collection group rather than a specific
|
|
2379
2385
|
* collection.
|
|
2380
2386
|
*/
|
|
2381
|
-
function
|
|
2387
|
+
function fe(t) {
|
|
2382
2388
|
return null !== t.collectionGroup;
|
|
2383
2389
|
}
|
|
2384
2390
|
|
|
@@ -2386,59 +2392,59 @@ function dn(t) {
|
|
|
2386
2392
|
* Returns the implicit order by constraint that is used to execute the Query,
|
|
2387
2393
|
* which can be different from the order by constraints the user provided (e.g.
|
|
2388
2394
|
* the SDK and backend always orders by `__name__`).
|
|
2389
|
-
*/ function
|
|
2390
|
-
const
|
|
2391
|
-
if (null ===
|
|
2392
|
-
|
|
2393
|
-
const t =
|
|
2394
|
-
if (null !== t && null ===
|
|
2395
|
+
*/ function de(t) {
|
|
2396
|
+
const e = E(t);
|
|
2397
|
+
if (null === e.$) {
|
|
2398
|
+
e.$ = [];
|
|
2399
|
+
const t = le(e), n = he(e);
|
|
2400
|
+
if (null !== t && null === n)
|
|
2395
2401
|
// In order to implicitly add key ordering, we must also add the
|
|
2396
2402
|
// inequality filter field for it to be a valid query.
|
|
2397
2403
|
// Note that the default inequality field and key ordering is ascending.
|
|
2398
|
-
t.isKeyField() ||
|
|
2404
|
+
t.isKeyField() || e.$.push(new oe(t)), e.$.push(new oe(et.keyField(), "asc" /* ASCENDING */)); else {
|
|
2399
2405
|
let t = !1;
|
|
2400
|
-
for (const
|
|
2406
|
+
for (const n of e.explicitOrderBy) e.$.push(n), n.field.isKeyField() && (t = !0);
|
|
2401
2407
|
if (!t) {
|
|
2402
2408
|
// The order of the implicit key ordering always matches the last
|
|
2403
2409
|
// explicit order by
|
|
2404
|
-
const t =
|
|
2405
|
-
|
|
2410
|
+
const t = e.explicitOrderBy.length > 0 ? e.explicitOrderBy[e.explicitOrderBy.length - 1].dir : "asc" /* ASCENDING */;
|
|
2411
|
+
e.$.push(new oe(et.keyField(), t));
|
|
2406
2412
|
}
|
|
2407
2413
|
}
|
|
2408
2414
|
}
|
|
2409
|
-
return
|
|
2415
|
+
return e.$;
|
|
2410
2416
|
}
|
|
2411
2417
|
|
|
2412
2418
|
/**
|
|
2413
2419
|
* Converts this `Query` instance to it's corresponding `Target` representation.
|
|
2414
|
-
*/ function
|
|
2415
|
-
const
|
|
2416
|
-
if (!
|
|
2420
|
+
*/ function we(t) {
|
|
2421
|
+
const e = E(t);
|
|
2422
|
+
if (!e.S) if ("F" /* First */ === e.limitType) e.S = Ht(e.path, e.collectionGroup, de(e), e.filters, e.limit, e.startAt, e.endAt); else {
|
|
2417
2423
|
// Flip the orderBy directions since we want the last results
|
|
2418
2424
|
const t = [];
|
|
2419
|
-
for (const
|
|
2420
|
-
const
|
|
2421
|
-
t.push(new
|
|
2425
|
+
for (const n of de(e)) {
|
|
2426
|
+
const e = "desc" /* DESCENDING */ === n.dir ? "asc" /* ASCENDING */ : "desc" /* DESCENDING */;
|
|
2427
|
+
t.push(new oe(n.field, e));
|
|
2422
2428
|
}
|
|
2423
2429
|
// We need to swap the cursors to match the now-flipped query ordering.
|
|
2424
|
-
const
|
|
2430
|
+
const n = e.endAt ? new ie(e.endAt.position, e.endAt.inclusive) : null, r = e.startAt ? new ie(e.startAt.position, e.startAt.inclusive) : null;
|
|
2425
2431
|
// Now return as a LimitType.First query.
|
|
2426
|
-
|
|
2432
|
+
e.S = Ht(e.path, e.collectionGroup, t, e.filters, e.limit, n, r);
|
|
2427
2433
|
}
|
|
2428
|
-
return
|
|
2434
|
+
return e.S;
|
|
2429
2435
|
}
|
|
2430
2436
|
|
|
2431
|
-
function
|
|
2432
|
-
return function(t,
|
|
2433
|
-
if (t.limit !==
|
|
2434
|
-
if (t.orderBy.length !==
|
|
2435
|
-
for (let
|
|
2436
|
-
if (t.filters.length !==
|
|
2437
|
-
for (let s = 0; s < t.filters.length; s++) if (
|
|
2438
|
-
|
|
2439
|
-
var
|
|
2440
|
-
return t.collectionGroup ===
|
|
2441
|
-
}(
|
|
2437
|
+
function me(t, e) {
|
|
2438
|
+
return function(t, e) {
|
|
2439
|
+
if (t.limit !== e.limit) return !1;
|
|
2440
|
+
if (t.orderBy.length !== e.orderBy.length) return !1;
|
|
2441
|
+
for (let n = 0; n < t.orderBy.length; n++) if (!ue(t.orderBy[n], e.orderBy[n])) return !1;
|
|
2442
|
+
if (t.filters.length !== e.filters.length) return !1;
|
|
2443
|
+
for (let s = 0; s < t.filters.length; s++) if (n = t.filters[s], r = e.filters[s],
|
|
2444
|
+
n.op !== r.op || !n.field.isEqual(r.field) || !Ot(n.value, r.value)) return !1;
|
|
2445
|
+
var n, r;
|
|
2446
|
+
return t.collectionGroup === e.collectionGroup && !!t.path.isEqual(e.path) && !!ce(t.startAt, e.startAt) && ce(t.endAt, e.endAt);
|
|
2447
|
+
}(we(t), we(e)) && t.limitType === e.limitType;
|
|
2442
2448
|
}
|
|
2443
2449
|
|
|
2444
2450
|
/**
|
|
@@ -2466,10 +2472,10 @@ function pn(t, n) {
|
|
|
2466
2472
|
* The return value is an IntegerValue if it can safely represent the value,
|
|
2467
2473
|
* otherwise a DoubleValue is returned.
|
|
2468
2474
|
*/
|
|
2469
|
-
function
|
|
2475
|
+
function pe(t, e) {
|
|
2470
2476
|
return function(t) {
|
|
2471
2477
|
return "number" == typeof t && Number.isInteger(t) && !ht(t) && t <= Number.MAX_SAFE_INTEGER && t >= Number.MIN_SAFE_INTEGER;
|
|
2472
|
-
}(
|
|
2478
|
+
}(e) ?
|
|
2473
2479
|
/**
|
|
2474
2480
|
* Returns an IntegerValue for `value`.
|
|
2475
2481
|
*/
|
|
@@ -2477,22 +2483,22 @@ function yn(t, n) {
|
|
|
2477
2483
|
return {
|
|
2478
2484
|
integerValue: "" + t
|
|
2479
2485
|
};
|
|
2480
|
-
}(
|
|
2486
|
+
}(e) : function(t, e) {
|
|
2481
2487
|
if (t.F) {
|
|
2482
|
-
if (isNaN(
|
|
2488
|
+
if (isNaN(e)) return {
|
|
2483
2489
|
doubleValue: "NaN"
|
|
2484
2490
|
};
|
|
2485
|
-
if (
|
|
2491
|
+
if (e === 1 / 0) return {
|
|
2486
2492
|
doubleValue: "Infinity"
|
|
2487
2493
|
};
|
|
2488
|
-
if (
|
|
2494
|
+
if (e === -1 / 0) return {
|
|
2489
2495
|
doubleValue: "-Infinity"
|
|
2490
2496
|
};
|
|
2491
2497
|
}
|
|
2492
2498
|
return {
|
|
2493
|
-
doubleValue: ht(
|
|
2499
|
+
doubleValue: ht(e) ? "-0" : e
|
|
2494
2500
|
};
|
|
2495
|
-
}(t,
|
|
2501
|
+
}(t, e);
|
|
2496
2502
|
}
|
|
2497
2503
|
|
|
2498
2504
|
/**
|
|
@@ -2511,7 +2517,7 @@ function yn(t, n) {
|
|
|
2511
2517
|
* See the License for the specific language governing permissions and
|
|
2512
2518
|
* limitations under the License.
|
|
2513
2519
|
*/
|
|
2514
|
-
/** Used to represent a field transform on a mutation. */ class
|
|
2520
|
+
/** Used to represent a field transform on a mutation. */ class ye {
|
|
2515
2521
|
constructor() {
|
|
2516
2522
|
// Make sure that the structural type of `TransformOperation` is unique.
|
|
2517
2523
|
// See https://github.com/microsoft/TypeScript/issues/5451
|
|
@@ -2519,15 +2525,15 @@ function yn(t, n) {
|
|
|
2519
2525
|
}
|
|
2520
2526
|
}
|
|
2521
2527
|
|
|
2522
|
-
/** Transforms a value into a server-generated timestamp. */ class
|
|
2528
|
+
/** Transforms a value into a server-generated timestamp. */ class _e extends ye {}
|
|
2523
2529
|
|
|
2524
|
-
/** Transforms an array value via a union operation. */ class
|
|
2530
|
+
/** Transforms an array value via a union operation. */ class ge extends ye {
|
|
2525
2531
|
constructor(t) {
|
|
2526
2532
|
super(), this.elements = t;
|
|
2527
2533
|
}
|
|
2528
2534
|
}
|
|
2529
2535
|
|
|
2530
|
-
/** Transforms an array value via a remove operation. */ class
|
|
2536
|
+
/** Transforms an array value via a remove operation. */ class ve extends ye {
|
|
2531
2537
|
constructor(t) {
|
|
2532
2538
|
super(), this.elements = t;
|
|
2533
2539
|
}
|
|
@@ -2538,9 +2544,9 @@ function yn(t, n) {
|
|
|
2538
2544
|
* transforms. Converts all field values to integers or doubles, but unlike the
|
|
2539
2545
|
* backend does not cap integer values at 2^63. Instead, JavaScript number
|
|
2540
2546
|
* arithmetic is used and precision loss can occur for values greater than 2^53.
|
|
2541
|
-
*/ class
|
|
2542
|
-
constructor(t,
|
|
2543
|
-
super(), this.q = t, this.O =
|
|
2547
|
+
*/ class be extends ye {
|
|
2548
|
+
constructor(t, e) {
|
|
2549
|
+
super(), this.q = t, this.O = e;
|
|
2544
2550
|
}
|
|
2545
2551
|
}
|
|
2546
2552
|
|
|
@@ -2560,9 +2566,9 @@ function yn(t, n) {
|
|
|
2560
2566
|
* See the License for the specific language governing permissions and
|
|
2561
2567
|
* limitations under the License.
|
|
2562
2568
|
*/
|
|
2563
|
-
/** A field path and the TransformOperation to perform upon it. */ class
|
|
2564
|
-
constructor(t,
|
|
2565
|
-
this.field = t, this.transform =
|
|
2569
|
+
/** A field path and the TransformOperation to perform upon it. */ class Ee {
|
|
2570
|
+
constructor(t, e) {
|
|
2571
|
+
this.field = t, this.transform = e;
|
|
2566
2572
|
}
|
|
2567
2573
|
}
|
|
2568
2574
|
|
|
@@ -2570,18 +2576,18 @@ function yn(t, n) {
|
|
|
2570
2576
|
* Encodes a precondition for a mutation. This follows the model that the
|
|
2571
2577
|
* backend accepts with the special case of an explicit "empty" precondition
|
|
2572
2578
|
* (meaning no precondition).
|
|
2573
|
-
*/ class
|
|
2574
|
-
constructor(t,
|
|
2575
|
-
this.updateTime = t, this.exists =
|
|
2579
|
+
*/ class Te {
|
|
2580
|
+
constructor(t, e) {
|
|
2581
|
+
this.updateTime = t, this.exists = e;
|
|
2576
2582
|
}
|
|
2577
2583
|
/** Creates a new empty Precondition. */ static none() {
|
|
2578
|
-
return new
|
|
2584
|
+
return new Te;
|
|
2579
2585
|
}
|
|
2580
2586
|
/** Creates a new Precondition with an exists flag. */ static exists(t) {
|
|
2581
|
-
return new
|
|
2587
|
+
return new Te(void 0, t);
|
|
2582
2588
|
}
|
|
2583
2589
|
/** Creates a new Precondition based on a version a document exists at. */ static updateTime(t) {
|
|
2584
|
-
return new
|
|
2590
|
+
return new Te(t);
|
|
2585
2591
|
}
|
|
2586
2592
|
/** Returns whether this Precondition is empty. */ get isNone() {
|
|
2587
2593
|
return void 0 === this.updateTime && void 0 === this.exists;
|
|
@@ -2634,14 +2640,14 @@ function yn(t, n) {
|
|
|
2634
2640
|
* applyToLocalView() to implement the actual behavior of applying the mutation
|
|
2635
2641
|
* to some source document (see `setMutationApplyToRemoteDocument()` for an
|
|
2636
2642
|
* example).
|
|
2637
|
-
*/ class
|
|
2643
|
+
*/ class Ae {}
|
|
2638
2644
|
|
|
2639
2645
|
/**
|
|
2640
2646
|
* A mutation that creates or replaces the document at the given key with the
|
|
2641
2647
|
* object value contents.
|
|
2642
|
-
*/ class
|
|
2643
|
-
constructor(t,
|
|
2644
|
-
super(), this.key = t, this.value =
|
|
2648
|
+
*/ class Ie extends Ae {
|
|
2649
|
+
constructor(t, e, n, r = []) {
|
|
2650
|
+
super(), this.key = t, this.value = e, this.precondition = n, this.fieldTransforms = r,
|
|
2645
2651
|
this.type = 0 /* Set */;
|
|
2646
2652
|
}
|
|
2647
2653
|
}
|
|
@@ -2658,16 +2664,16 @@ function yn(t, n) {
|
|
|
2658
2664
|
* is deleted.
|
|
2659
2665
|
* * When a field is not in the mask but is in the values, the values map is
|
|
2660
2666
|
* ignored.
|
|
2661
|
-
*/ class
|
|
2662
|
-
constructor(t,
|
|
2663
|
-
super(), this.key = t, this.data =
|
|
2667
|
+
*/ class Re extends Ae {
|
|
2668
|
+
constructor(t, e, n, r, s = []) {
|
|
2669
|
+
super(), this.key = t, this.data = e, this.fieldMask = n, this.precondition = r,
|
|
2664
2670
|
this.fieldTransforms = s, this.type = 1 /* Patch */;
|
|
2665
2671
|
}
|
|
2666
2672
|
}
|
|
2667
2673
|
|
|
2668
|
-
/** A mutation that deletes the document at the given key. */ class
|
|
2669
|
-
constructor(t,
|
|
2670
|
-
super(), this.key = t, this.precondition =
|
|
2674
|
+
/** A mutation that deletes the document at the given key. */ class Pe extends Ae {
|
|
2675
|
+
constructor(t, e) {
|
|
2676
|
+
super(), this.key = t, this.precondition = e, this.type = 2 /* Delete */ , this.fieldTransforms = [];
|
|
2671
2677
|
}
|
|
2672
2678
|
}
|
|
2673
2679
|
|
|
@@ -2677,9 +2683,9 @@ function yn(t, n) {
|
|
|
2677
2683
|
*
|
|
2678
2684
|
* The `verify` operation is only used in Transactions, and this class serves
|
|
2679
2685
|
* primarily to facilitate serialization into protos.
|
|
2680
|
-
*/ class
|
|
2681
|
-
constructor(t,
|
|
2682
|
-
super(), this.key = t, this.precondition =
|
|
2686
|
+
*/ class Ve extends Ae {
|
|
2687
|
+
constructor(t, e) {
|
|
2688
|
+
super(), this.key = t, this.precondition = e, this.type = 3 /* Verify */ , this.fieldTransforms = [];
|
|
2683
2689
|
}
|
|
2684
2690
|
}
|
|
2685
2691
|
|
|
@@ -2698,13 +2704,13 @@ function yn(t, n) {
|
|
|
2698
2704
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2699
2705
|
* See the License for the specific language governing permissions and
|
|
2700
2706
|
* limitations under the License.
|
|
2701
|
-
*/ const
|
|
2707
|
+
*/ const Ne = (() => {
|
|
2702
2708
|
const t = {
|
|
2703
2709
|
asc: "ASCENDING",
|
|
2704
2710
|
desc: "DESCENDING"
|
|
2705
2711
|
};
|
|
2706
2712
|
return t;
|
|
2707
|
-
})(),
|
|
2713
|
+
})(), De = (() => {
|
|
2708
2714
|
const t = {
|
|
2709
2715
|
"<": "LESS_THAN",
|
|
2710
2716
|
"<=": "LESS_THAN_OR_EQUAL",
|
|
@@ -2734,9 +2740,9 @@ function yn(t, n) {
|
|
|
2734
2740
|
* TODO(klimt): We can remove the databaseId argument if we keep the full
|
|
2735
2741
|
* resource name in documents.
|
|
2736
2742
|
*/
|
|
2737
|
-
class
|
|
2738
|
-
constructor(t,
|
|
2739
|
-
this.databaseId = t, this.F =
|
|
2743
|
+
class $e {
|
|
2744
|
+
constructor(t, e) {
|
|
2745
|
+
this.databaseId = t, this.F = e;
|
|
2740
2746
|
}
|
|
2741
2747
|
}
|
|
2742
2748
|
|
|
@@ -2751,13 +2757,13 @@ class Sn {
|
|
|
2751
2757
|
/**
|
|
2752
2758
|
* Returns a value for a Date that's appropriate to put into a proto.
|
|
2753
2759
|
*/
|
|
2754
|
-
function
|
|
2760
|
+
function Se(t, e) {
|
|
2755
2761
|
if (t.F) {
|
|
2756
|
-
return `${new Date(1e3 *
|
|
2762
|
+
return `${new Date(1e3 * e.seconds).toISOString().replace(/\.\d*/, "").replace("Z", "")}.${("000000000" + e.nanoseconds).slice(-9)}Z`;
|
|
2757
2763
|
}
|
|
2758
2764
|
return {
|
|
2759
|
-
seconds: "" +
|
|
2760
|
-
nanos:
|
|
2765
|
+
seconds: "" + e.seconds,
|
|
2766
|
+
nanos: e.nanoseconds
|
|
2761
2767
|
};
|
|
2762
2768
|
}
|
|
2763
2769
|
|
|
@@ -2766,234 +2772,234 @@ function Fn(t, n) {
|
|
|
2766
2772
|
*
|
|
2767
2773
|
* Visible for testing.
|
|
2768
2774
|
*/
|
|
2769
|
-
function
|
|
2770
|
-
return t.F ?
|
|
2775
|
+
function xe(t, e) {
|
|
2776
|
+
return t.F ? e.toBase64() : e.toUint8Array();
|
|
2771
2777
|
}
|
|
2772
2778
|
|
|
2773
|
-
function
|
|
2774
|
-
return
|
|
2779
|
+
function Fe(t, e) {
|
|
2780
|
+
return Se(t, e.toTimestamp());
|
|
2775
2781
|
}
|
|
2776
2782
|
|
|
2777
|
-
function
|
|
2783
|
+
function qe(t) {
|
|
2778
2784
|
return b(!!t), bt.fromTimestamp(function(t) {
|
|
2779
|
-
const
|
|
2780
|
-
return new vt(
|
|
2785
|
+
const e = Vt(t);
|
|
2786
|
+
return new vt(e.seconds, e.nanos);
|
|
2781
2787
|
}(t));
|
|
2782
2788
|
}
|
|
2783
2789
|
|
|
2784
|
-
function
|
|
2790
|
+
function Oe(t, e) {
|
|
2785
2791
|
return function(t) {
|
|
2786
2792
|
return new Z([ "projects", t.projectId, "databases", t.database ]);
|
|
2787
|
-
}(t).child("documents").child(
|
|
2793
|
+
}(t).child("documents").child(e).canonicalString();
|
|
2788
2794
|
}
|
|
2789
2795
|
|
|
2790
|
-
function
|
|
2791
|
-
return
|
|
2796
|
+
function Ce(t, e) {
|
|
2797
|
+
return Oe(t.databaseId, e.path);
|
|
2792
2798
|
}
|
|
2793
2799
|
|
|
2794
|
-
function
|
|
2795
|
-
const
|
|
2796
|
-
const
|
|
2797
|
-
return b(
|
|
2798
|
-
}(
|
|
2799
|
-
if (
|
|
2800
|
-
if (
|
|
2801
|
-
return new
|
|
2800
|
+
function Le(t, e) {
|
|
2801
|
+
const n = function(t) {
|
|
2802
|
+
const e = Z.fromString(t);
|
|
2803
|
+
return b(He(e)), e;
|
|
2804
|
+
}(e);
|
|
2805
|
+
if (n.get(1) !== t.databaseId.projectId) throw new U(R, "Tried to deserialize key from different project: " + n.get(1) + " vs " + t.databaseId.projectId);
|
|
2806
|
+
if (n.get(3) !== t.databaseId.database) throw new U(R, "Tried to deserialize key from different database: " + n.get(3) + " vs " + t.databaseId.database);
|
|
2807
|
+
return new nt((b((r = n).length > 4 && "documents" === r.get(4)), r.popFirst(5)));
|
|
2802
2808
|
var r;
|
|
2803
2809
|
/** Creates a Document proto from key and fields (but no create/update time) */}
|
|
2804
2810
|
|
|
2805
|
-
function
|
|
2806
|
-
return
|
|
2811
|
+
function ke(t, e) {
|
|
2812
|
+
return Oe(t.databaseId, e);
|
|
2807
2813
|
}
|
|
2808
2814
|
|
|
2809
|
-
function
|
|
2815
|
+
function Ue(t) {
|
|
2810
2816
|
return new Z([ "projects", t.databaseId.projectId, "databases", t.databaseId.database ]).canonicalString();
|
|
2811
2817
|
}
|
|
2812
2818
|
|
|
2813
|
-
function
|
|
2819
|
+
function je(t, e, n) {
|
|
2814
2820
|
return {
|
|
2815
|
-
name:
|
|
2816
|
-
fields:
|
|
2821
|
+
name: Ce(t, e),
|
|
2822
|
+
fields: n.value.mapValue.fields
|
|
2817
2823
|
};
|
|
2818
2824
|
}
|
|
2819
2825
|
|
|
2820
|
-
function
|
|
2821
|
-
return "found" in
|
|
2822
|
-
b(!!
|
|
2823
|
-
const
|
|
2826
|
+
function Me(t, e) {
|
|
2827
|
+
return "found" in e ? function(t, e) {
|
|
2828
|
+
b(!!e.found), e.found.name, e.found.updateTime;
|
|
2829
|
+
const n = Le(t, e.found.name), r = qe(e.found.updateTime), s = new Qt({
|
|
2824
2830
|
mapValue: {
|
|
2825
|
-
fields:
|
|
2831
|
+
fields: e.found.fields
|
|
2826
2832
|
}
|
|
2827
2833
|
});
|
|
2828
|
-
return
|
|
2829
|
-
}(t,
|
|
2830
|
-
b(!!
|
|
2831
|
-
const
|
|
2832
|
-
return
|
|
2833
|
-
}(t,
|
|
2834
|
-
}
|
|
2835
|
-
|
|
2836
|
-
function
|
|
2837
|
-
let
|
|
2838
|
-
if (
|
|
2839
|
-
update:
|
|
2840
|
-
}; else if (
|
|
2841
|
-
delete:
|
|
2842
|
-
}; else if (
|
|
2843
|
-
update:
|
|
2844
|
-
updateMask:
|
|
2834
|
+
return Wt.newFoundDocument(n, r, s);
|
|
2835
|
+
}(t, e) : "missing" in e ? function(t, e) {
|
|
2836
|
+
b(!!e.missing), b(!!e.readTime);
|
|
2837
|
+
const n = Le(t, e.missing), r = qe(e.readTime);
|
|
2838
|
+
return Wt.newNoDocument(n, r);
|
|
2839
|
+
}(t, e) : v();
|
|
2840
|
+
}
|
|
2841
|
+
|
|
2842
|
+
function Be(t, e) {
|
|
2843
|
+
let n;
|
|
2844
|
+
if (e instanceof Ie) n = {
|
|
2845
|
+
update: je(t, e.key, e.value)
|
|
2846
|
+
}; else if (e instanceof Pe) n = {
|
|
2847
|
+
delete: Ce(t, e.key)
|
|
2848
|
+
}; else if (e instanceof Re) n = {
|
|
2849
|
+
update: je(t, e.key, e.data),
|
|
2850
|
+
updateMask: Ye(e.fieldMask)
|
|
2845
2851
|
}; else {
|
|
2846
|
-
if (!(
|
|
2847
|
-
|
|
2848
|
-
verify:
|
|
2852
|
+
if (!(e instanceof Ve)) return v();
|
|
2853
|
+
n = {
|
|
2854
|
+
verify: Ce(t, e.key)
|
|
2849
2855
|
};
|
|
2850
2856
|
}
|
|
2851
|
-
return
|
|
2852
|
-
const
|
|
2853
|
-
if (
|
|
2854
|
-
fieldPath:
|
|
2857
|
+
return e.fieldTransforms.length > 0 && (n.updateTransforms = e.fieldTransforms.map((t => function(t, e) {
|
|
2858
|
+
const n = e.transform;
|
|
2859
|
+
if (n instanceof _e) return {
|
|
2860
|
+
fieldPath: e.field.canonicalString(),
|
|
2855
2861
|
setToServerValue: "REQUEST_TIME"
|
|
2856
2862
|
};
|
|
2857
|
-
if (
|
|
2858
|
-
fieldPath:
|
|
2863
|
+
if (n instanceof ge) return {
|
|
2864
|
+
fieldPath: e.field.canonicalString(),
|
|
2859
2865
|
appendMissingElements: {
|
|
2860
|
-
values:
|
|
2866
|
+
values: n.elements
|
|
2861
2867
|
}
|
|
2862
2868
|
};
|
|
2863
|
-
if (
|
|
2864
|
-
fieldPath:
|
|
2869
|
+
if (n instanceof ve) return {
|
|
2870
|
+
fieldPath: e.field.canonicalString(),
|
|
2865
2871
|
removeAllFromArray: {
|
|
2866
|
-
values:
|
|
2872
|
+
values: n.elements
|
|
2867
2873
|
}
|
|
2868
2874
|
};
|
|
2869
|
-
if (
|
|
2870
|
-
fieldPath:
|
|
2871
|
-
increment:
|
|
2875
|
+
if (n instanceof be) return {
|
|
2876
|
+
fieldPath: e.field.canonicalString(),
|
|
2877
|
+
increment: n.O
|
|
2872
2878
|
};
|
|
2873
2879
|
throw v();
|
|
2874
|
-
}(0, t)))),
|
|
2875
|
-
return void 0 !==
|
|
2876
|
-
updateTime:
|
|
2877
|
-
} : void 0 !==
|
|
2878
|
-
exists:
|
|
2880
|
+
}(0, t)))), e.precondition.isNone || (n.currentDocument = function(t, e) {
|
|
2881
|
+
return void 0 !== e.updateTime ? {
|
|
2882
|
+
updateTime: Fe(t, e.updateTime)
|
|
2883
|
+
} : void 0 !== e.exists ? {
|
|
2884
|
+
exists: e.exists
|
|
2879
2885
|
} : v();
|
|
2880
|
-
}(t,
|
|
2886
|
+
}(t, e.precondition)), n;
|
|
2881
2887
|
}
|
|
2882
2888
|
|
|
2883
|
-
function
|
|
2889
|
+
function ze(t, e) {
|
|
2884
2890
|
// Dissect the path into parent, collectionId, and optional key filter.
|
|
2885
|
-
const
|
|
2891
|
+
const n = {
|
|
2886
2892
|
structuredQuery: {}
|
|
2887
|
-
}, r =
|
|
2888
|
-
null !==
|
|
2889
|
-
collectionId:
|
|
2893
|
+
}, r = e.path;
|
|
2894
|
+
null !== e.collectionGroup ? (n.parent = ke(t, r), n.structuredQuery.from = [ {
|
|
2895
|
+
collectionId: e.collectionGroup,
|
|
2890
2896
|
allDescendants: !0
|
|
2891
|
-
} ]) : (
|
|
2897
|
+
} ]) : (n.parent = ke(t, r.popLast()), n.structuredQuery.from = [ {
|
|
2892
2898
|
collectionId: r.lastSegment()
|
|
2893
2899
|
} ]);
|
|
2894
2900
|
const s = function(t) {
|
|
2895
2901
|
if (0 === t.length) return;
|
|
2896
|
-
const
|
|
2902
|
+
const e = t.map((t =>
|
|
2897
2903
|
// visible for testing
|
|
2898
2904
|
function(t) {
|
|
2899
2905
|
if ("==" /* EQUAL */ === t.op) {
|
|
2900
|
-
if (
|
|
2906
|
+
if (Bt(t.value)) return {
|
|
2901
2907
|
unaryFilter: {
|
|
2902
|
-
field:
|
|
2908
|
+
field: We(t.field),
|
|
2903
2909
|
op: "IS_NAN"
|
|
2904
2910
|
}
|
|
2905
2911
|
};
|
|
2906
|
-
if (
|
|
2912
|
+
if (Mt(t.value)) return {
|
|
2907
2913
|
unaryFilter: {
|
|
2908
|
-
field:
|
|
2914
|
+
field: We(t.field),
|
|
2909
2915
|
op: "IS_NULL"
|
|
2910
2916
|
}
|
|
2911
2917
|
};
|
|
2912
2918
|
} else if ("!=" /* NOT_EQUAL */ === t.op) {
|
|
2913
|
-
if (
|
|
2919
|
+
if (Bt(t.value)) return {
|
|
2914
2920
|
unaryFilter: {
|
|
2915
|
-
field:
|
|
2921
|
+
field: We(t.field),
|
|
2916
2922
|
op: "IS_NOT_NAN"
|
|
2917
2923
|
}
|
|
2918
2924
|
};
|
|
2919
|
-
if (
|
|
2925
|
+
if (Mt(t.value)) return {
|
|
2920
2926
|
unaryFilter: {
|
|
2921
|
-
field:
|
|
2927
|
+
field: We(t.field),
|
|
2922
2928
|
op: "IS_NOT_NULL"
|
|
2923
2929
|
}
|
|
2924
2930
|
};
|
|
2925
2931
|
}
|
|
2926
2932
|
return {
|
|
2927
2933
|
fieldFilter: {
|
|
2928
|
-
field:
|
|
2929
|
-
op:
|
|
2934
|
+
field: We(t.field),
|
|
2935
|
+
op: Qe(t.op),
|
|
2930
2936
|
value: t.value
|
|
2931
2937
|
}
|
|
2932
2938
|
};
|
|
2933
2939
|
}(t)));
|
|
2934
|
-
if (1 ===
|
|
2940
|
+
if (1 === e.length) return e[0];
|
|
2935
2941
|
return {
|
|
2936
2942
|
compositeFilter: {
|
|
2937
2943
|
op: "AND",
|
|
2938
|
-
filters:
|
|
2944
|
+
filters: e
|
|
2939
2945
|
}
|
|
2940
2946
|
};
|
|
2941
|
-
}(
|
|
2942
|
-
s && (
|
|
2947
|
+
}(e.filters);
|
|
2948
|
+
s && (n.structuredQuery.where = s);
|
|
2943
2949
|
const i = function(t) {
|
|
2944
2950
|
if (0 === t.length) return;
|
|
2945
2951
|
return t.map((t =>
|
|
2946
2952
|
// visible for testing
|
|
2947
2953
|
function(t) {
|
|
2948
2954
|
return {
|
|
2949
|
-
field:
|
|
2950
|
-
direction:
|
|
2955
|
+
field: We(t.field),
|
|
2956
|
+
direction: Ge(t.dir)
|
|
2951
2957
|
};
|
|
2952
2958
|
}(t)));
|
|
2953
|
-
}(
|
|
2954
|
-
i && (
|
|
2955
|
-
const o = function(t,
|
|
2956
|
-
return t.F || at(
|
|
2957
|
-
value:
|
|
2959
|
+
}(e.orderBy);
|
|
2960
|
+
i && (n.structuredQuery.orderBy = i);
|
|
2961
|
+
const o = function(t, e) {
|
|
2962
|
+
return t.F || at(e) ? e : {
|
|
2963
|
+
value: e
|
|
2958
2964
|
};
|
|
2959
|
-
}(t,
|
|
2965
|
+
}(t, e.limit);
|
|
2960
2966
|
var u;
|
|
2961
|
-
return null !== o && (
|
|
2962
|
-
before: (u =
|
|
2967
|
+
return null !== o && (n.structuredQuery.limit = o), e.startAt && (n.structuredQuery.startAt = {
|
|
2968
|
+
before: (u = e.startAt).inclusive,
|
|
2963
2969
|
values: u.position
|
|
2964
|
-
}),
|
|
2970
|
+
}), e.endAt && (n.structuredQuery.endAt = function(t) {
|
|
2965
2971
|
return {
|
|
2966
2972
|
before: !t.inclusive,
|
|
2967
2973
|
values: t.position
|
|
2968
2974
|
};
|
|
2969
2975
|
}
|
|
2970
2976
|
// visible for testing
|
|
2971
|
-
(
|
|
2977
|
+
(e.endAt)), n;
|
|
2972
2978
|
}
|
|
2973
2979
|
|
|
2974
|
-
function
|
|
2975
|
-
return
|
|
2980
|
+
function Ge(t) {
|
|
2981
|
+
return Ne[t];
|
|
2976
2982
|
}
|
|
2977
2983
|
|
|
2978
2984
|
// visible for testing
|
|
2979
|
-
function
|
|
2980
|
-
return
|
|
2985
|
+
function Qe(t) {
|
|
2986
|
+
return De[t];
|
|
2981
2987
|
}
|
|
2982
2988
|
|
|
2983
|
-
function
|
|
2989
|
+
function We(t) {
|
|
2984
2990
|
return {
|
|
2985
2991
|
fieldPath: t.canonicalString()
|
|
2986
2992
|
};
|
|
2987
2993
|
}
|
|
2988
2994
|
|
|
2989
|
-
function
|
|
2990
|
-
const
|
|
2991
|
-
return t.fields.forEach((t =>
|
|
2992
|
-
fieldPaths:
|
|
2995
|
+
function Ye(t) {
|
|
2996
|
+
const e = [];
|
|
2997
|
+
return t.fields.forEach((t => e.push(t.canonicalString()))), {
|
|
2998
|
+
fieldPaths: e
|
|
2993
2999
|
};
|
|
2994
3000
|
}
|
|
2995
3001
|
|
|
2996
|
-
function
|
|
3002
|
+
function He(t) {
|
|
2997
3003
|
// Resource names have at least 4 components (project ID, database ID)
|
|
2998
3004
|
return t.length >= 4 && "projects" === t.get(0) && "databases" === t.get(2);
|
|
2999
3005
|
}
|
|
@@ -3013,8 +3019,8 @@ function Kn(t) {
|
|
|
3013
3019
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3014
3020
|
* See the License for the specific language governing permissions and
|
|
3015
3021
|
* limitations under the License.
|
|
3016
|
-
*/ function
|
|
3017
|
-
return new
|
|
3022
|
+
*/ function Ke(t) {
|
|
3023
|
+
return new $e(t, /* useProto3Json= */ !0);
|
|
3018
3024
|
}
|
|
3019
3025
|
|
|
3020
3026
|
/**
|
|
@@ -3042,7 +3048,7 @@ function Kn(t) {
|
|
|
3042
3048
|
* base delay. This prevents clients from accidentally synchronizing their
|
|
3043
3049
|
* delays causing spikes of load to the backend.
|
|
3044
3050
|
*/
|
|
3045
|
-
class
|
|
3051
|
+
class Je {
|
|
3046
3052
|
constructor(
|
|
3047
3053
|
/**
|
|
3048
3054
|
* The AsyncQueue to run backoff operations on.
|
|
@@ -3051,13 +3057,13 @@ class Xn {
|
|
|
3051
3057
|
/**
|
|
3052
3058
|
* The ID to use when scheduling backoff operations on the AsyncQueue.
|
|
3053
3059
|
*/
|
|
3054
|
-
|
|
3060
|
+
e,
|
|
3055
3061
|
/**
|
|
3056
3062
|
* The initial delay (used as the base delay on the first retry attempt).
|
|
3057
3063
|
* Note that jitter will still be applied, so the actual delay could be as
|
|
3058
3064
|
* little as 0.5*initialDelayMs.
|
|
3059
3065
|
*/
|
|
3060
|
-
|
|
3066
|
+
n = 1e3
|
|
3061
3067
|
/**
|
|
3062
3068
|
* The multiplier to use to determine the extended base delay after each
|
|
3063
3069
|
* attempt.
|
|
@@ -3067,7 +3073,7 @@ class Xn {
|
|
|
3067
3073
|
* Note that jitter will still be applied, so the actual delay could be as
|
|
3068
3074
|
* much as 1.5*maxDelayMs.
|
|
3069
3075
|
*/ , s = 6e4) {
|
|
3070
|
-
this.C = t, this.timerId =
|
|
3076
|
+
this.C = t, this.timerId = e, this.L = n, this.k = r, this.U = s, this.j = 0, this.M = null,
|
|
3071
3077
|
/** The last backoff attempt, as epoch milliseconds. */
|
|
3072
3078
|
this.B = Date.now(), this.reset();
|
|
3073
3079
|
}
|
|
@@ -3095,9 +3101,9 @@ class Xn {
|
|
|
3095
3101
|
this.cancel();
|
|
3096
3102
|
// First schedule using the current base (which may be 0 and should be
|
|
3097
3103
|
// honored as such).
|
|
3098
|
-
const
|
|
3104
|
+
const e = Math.floor(this.j + this.Y()), n = Math.max(0, Date.now() - this.B), r = Math.max(0, e - n);
|
|
3099
3105
|
// Guard against lastAttemptTime being in the future due to a clock change.
|
|
3100
|
-
r > 0 && p("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.j} ms, delay with jitter: ${
|
|
3106
|
+
r > 0 && p("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.j} ms, delay with jitter: ${e} ms, last attempt: ${n} ms ago)`),
|
|
3101
3107
|
this.M = this.C.enqueueAfterDelay(this.timerId, r, (() => (this.B = Date.now(),
|
|
3102
3108
|
t()))),
|
|
3103
3109
|
// Apply backoff factor to determine next delay and ensure it is within
|
|
@@ -3140,24 +3146,24 @@ class Xn {
|
|
|
3140
3146
|
* An implementation of Datastore that exposes additional state for internal
|
|
3141
3147
|
* consumption.
|
|
3142
3148
|
*/
|
|
3143
|
-
class
|
|
3144
|
-
constructor(t,
|
|
3145
|
-
super(), this.authCredentials = t, this.appCheckCredentials =
|
|
3149
|
+
class Xe extends class {} {
|
|
3150
|
+
constructor(t, e, n, r) {
|
|
3151
|
+
super(), this.authCredentials = t, this.appCheckCredentials = e, this.K = n, this.q = r,
|
|
3146
3152
|
this.J = !1;
|
|
3147
3153
|
}
|
|
3148
3154
|
X() {
|
|
3149
|
-
if (this.J) throw new U(
|
|
3155
|
+
if (this.J) throw new U(x, "The client has already been terminated.");
|
|
3150
3156
|
}
|
|
3151
|
-
/** Invokes the provided RPC with auth and AppCheck tokens. */ m(t,
|
|
3152
|
-
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.m(t,
|
|
3157
|
+
/** Invokes the provided RPC with auth and AppCheck tokens. */ m(t, e, n) {
|
|
3158
|
+
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.m(t, e, n, r, s))).catch((t => {
|
|
3153
3159
|
throw "FirebaseError" === t.name ? (t.code === $ && (this.authCredentials.invalidateToken(),
|
|
3154
|
-
this.appCheckCredentials.invalidateToken()), t) : new U(
|
|
3160
|
+
this.appCheckCredentials.invalidateToken()), t) : new U(I, t.toString());
|
|
3155
3161
|
}));
|
|
3156
3162
|
}
|
|
3157
|
-
/** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */ T(t,
|
|
3158
|
-
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.T(t,
|
|
3163
|
+
/** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */ T(t, e, n) {
|
|
3164
|
+
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.T(t, e, n, r, s))).catch((t => {
|
|
3159
3165
|
throw "FirebaseError" === t.name ? (t.code === $ && (this.authCredentials.invalidateToken(),
|
|
3160
|
-
this.appCheckCredentials.invalidateToken()), t) : new U(
|
|
3166
|
+
this.appCheckCredentials.invalidateToken()), t) : new U(I, t.toString());
|
|
3161
3167
|
}));
|
|
3162
3168
|
}
|
|
3163
3169
|
terminate() {
|
|
@@ -3167,40 +3173,40 @@ class Zn extends class {} {
|
|
|
3167
3173
|
|
|
3168
3174
|
// TODO(firestorexp): Make sure there is only one Datastore instance per
|
|
3169
3175
|
// firestore-exp client.
|
|
3170
|
-
async function
|
|
3171
|
-
const
|
|
3172
|
-
writes:
|
|
3176
|
+
async function Ze(t, e) {
|
|
3177
|
+
const n = E(t), r = Ue(n.q) + "/documents", s = {
|
|
3178
|
+
writes: e.map((t => Be(n.q, t)))
|
|
3173
3179
|
};
|
|
3174
|
-
await
|
|
3180
|
+
await n.m("Commit", r, s);
|
|
3175
3181
|
}
|
|
3176
3182
|
|
|
3177
|
-
async function
|
|
3178
|
-
const
|
|
3179
|
-
documents:
|
|
3180
|
-
}, i = await
|
|
3183
|
+
async function tn(t, e) {
|
|
3184
|
+
const n = E(t), r = Ue(n.q) + "/documents", s = {
|
|
3185
|
+
documents: e.map((t => Ce(n.q, t)))
|
|
3186
|
+
}, i = await n.T("BatchGetDocuments", r, s), o = new Map;
|
|
3181
3187
|
i.forEach((t => {
|
|
3182
|
-
const
|
|
3183
|
-
o.set(
|
|
3188
|
+
const e = Me(n.q, t);
|
|
3189
|
+
o.set(e.key.toString(), e);
|
|
3184
3190
|
}));
|
|
3185
3191
|
const u = [];
|
|
3186
|
-
return
|
|
3187
|
-
const
|
|
3188
|
-
b(!!
|
|
3192
|
+
return e.forEach((t => {
|
|
3193
|
+
const e = o.get(t.toString());
|
|
3194
|
+
b(!!e), u.push(e);
|
|
3189
3195
|
})), u;
|
|
3190
3196
|
}
|
|
3191
3197
|
|
|
3192
|
-
async function
|
|
3193
|
-
const
|
|
3194
|
-
return (await
|
|
3198
|
+
async function en(t, e) {
|
|
3199
|
+
const n = E(t), r = ze(n.q, we(e));
|
|
3200
|
+
return (await n.T("RunQuery", r.parent, {
|
|
3195
3201
|
structuredQuery: r.structuredQuery
|
|
3196
|
-
})).filter((t => !!t.document)).map((t => function(t,
|
|
3197
|
-
const r =
|
|
3202
|
+
})).filter((t => !!t.document)).map((t => function(t, e, n) {
|
|
3203
|
+
const r = Le(t, e.name), s = qe(e.updateTime), i = new Qt({
|
|
3198
3204
|
mapValue: {
|
|
3199
|
-
fields:
|
|
3205
|
+
fields: e.fields
|
|
3200
3206
|
}
|
|
3201
|
-
}), o =
|
|
3202
|
-
return
|
|
3203
|
-
}(
|
|
3207
|
+
}), o = Wt.newFoundDocument(r, s, i);
|
|
3208
|
+
return n && o.setHasCommittedMutations(), n ? o.setHasCommittedMutations() : o;
|
|
3209
|
+
}(n.q, t.document, void 0)));
|
|
3204
3210
|
}
|
|
3205
3211
|
|
|
3206
3212
|
/**
|
|
@@ -3218,7 +3224,7 @@ async function ee(t, n) {
|
|
|
3218
3224
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3219
3225
|
* See the License for the specific language governing permissions and
|
|
3220
3226
|
* limitations under the License.
|
|
3221
|
-
*/ const
|
|
3227
|
+
*/ const nn = new Map;
|
|
3222
3228
|
|
|
3223
3229
|
/**
|
|
3224
3230
|
* An instance map that ensures only one Datastore exists per Firestore
|
|
@@ -3229,19 +3235,19 @@ async function ee(t, n) {
|
|
|
3229
3235
|
* instance. Callers must invoke removeComponents() when the Firestore
|
|
3230
3236
|
* instance is terminated.
|
|
3231
3237
|
*/
|
|
3232
|
-
function
|
|
3233
|
-
if (t._terminated) throw new U(
|
|
3234
|
-
if (!
|
|
3238
|
+
function rn(t) {
|
|
3239
|
+
if (t._terminated) throw new U(x, "The client has already been terminated.");
|
|
3240
|
+
if (!nn.has(t)) {
|
|
3235
3241
|
p("ComponentProvider", "Initializing Datastore");
|
|
3236
3242
|
const i = function(t) {
|
|
3237
3243
|
return new mt(t, fetch.bind(null));
|
|
3238
|
-
}((
|
|
3239
|
-
new K(
|
|
3240
|
-
return new
|
|
3244
|
+
}((e = t._databaseId, n = t.app.options.appId || "", r = t._persistenceKey, s = t._freezeSettings(),
|
|
3245
|
+
new K(e, n, r, s.host, s.ssl, s.experimentalForceLongPolling, s.experimentalAutoDetectLongPolling, s.useFetchStreams))), o = Ke(t._databaseId), u = function(t, e, n, r) {
|
|
3246
|
+
return new Xe(t, e, n, r);
|
|
3241
3247
|
}(t._authCredentials, t._appCheckCredentials, i, o);
|
|
3242
|
-
|
|
3248
|
+
nn.set(t, u);
|
|
3243
3249
|
}
|
|
3244
|
-
var
|
|
3250
|
+
var e, n, r, s;
|
|
3245
3251
|
/**
|
|
3246
3252
|
* @license
|
|
3247
3253
|
* Copyright 2018 Google LLC
|
|
@@ -3257,7 +3263,7 @@ function se(t) {
|
|
|
3257
3263
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3258
3264
|
* See the License for the specific language governing permissions and
|
|
3259
3265
|
* limitations under the License.
|
|
3260
|
-
*/ return
|
|
3266
|
+
*/ return nn.get(t);
|
|
3261
3267
|
}
|
|
3262
3268
|
|
|
3263
3269
|
/**
|
|
@@ -3269,21 +3275,21 @@ function se(t) {
|
|
|
3269
3275
|
* user-supplied `FirestoreSettings` object. This is a separate type so that
|
|
3270
3276
|
* defaults can be supplied and the value can be checked for equality.
|
|
3271
3277
|
*/
|
|
3272
|
-
class
|
|
3278
|
+
class sn {
|
|
3273
3279
|
constructor(t) {
|
|
3274
|
-
var
|
|
3280
|
+
var e;
|
|
3275
3281
|
if (void 0 === t.host) {
|
|
3276
3282
|
if (void 0 !== t.ssl) throw new U(R, "Can't provide ssl option if host option is not set");
|
|
3277
3283
|
this.host = "firestore.googleapis.com", this.ssl = true;
|
|
3278
|
-
} else this.host = t.host, this.ssl = null === (
|
|
3284
|
+
} else this.host = t.host, this.ssl = null === (e = t.ssl) || void 0 === e || e;
|
|
3279
3285
|
if (this.credentials = t.credentials, this.ignoreUndefinedProperties = !!t.ignoreUndefinedProperties,
|
|
3280
3286
|
void 0 === t.cacheSizeBytes) this.cacheSizeBytes = 41943040; else {
|
|
3281
3287
|
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new U(R, "cacheSizeBytes must be at least 1048576");
|
|
3282
3288
|
this.cacheSizeBytes = t.cacheSizeBytes;
|
|
3283
3289
|
}
|
|
3284
3290
|
this.experimentalForceLongPolling = !!t.experimentalForceLongPolling, this.experimentalAutoDetectLongPolling = !!t.experimentalAutoDetectLongPolling,
|
|
3285
|
-
this.useFetchStreams = !!t.useFetchStreams, function(t,
|
|
3286
|
-
if (!0 ===
|
|
3291
|
+
this.useFetchStreams = !!t.useFetchStreams, function(t, e, n, r) {
|
|
3292
|
+
if (!0 === e && !0 === r) throw new U(R, `${t} and ${n} cannot be used together.`);
|
|
3287
3293
|
}("experimentalForceLongPolling", t.experimentalForceLongPolling, "experimentalAutoDetectLongPolling", t.experimentalAutoDetectLongPolling);
|
|
3288
3294
|
}
|
|
3289
3295
|
isEqual(t) {
|
|
@@ -3311,14 +3317,14 @@ class ie {
|
|
|
3311
3317
|
* The Cloud Firestore service interface.
|
|
3312
3318
|
*
|
|
3313
3319
|
* Do not call this constructor directly. Instead, use {@link getFirestore}.
|
|
3314
|
-
*/ class
|
|
3320
|
+
*/ class on {
|
|
3315
3321
|
/** @hideconstructor */
|
|
3316
|
-
constructor(t,
|
|
3317
|
-
this._authCredentials =
|
|
3322
|
+
constructor(t, e, n) {
|
|
3323
|
+
this._authCredentials = e, this._appCheckCredentials = n,
|
|
3318
3324
|
/**
|
|
3319
3325
|
* Whether it's a Firestore or Firestore Lite instance.
|
|
3320
3326
|
*/
|
|
3321
|
-
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new
|
|
3327
|
+
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new sn({}),
|
|
3322
3328
|
this._settingsFrozen = !1, t instanceof J ? this._databaseId = t : (this._app = t,
|
|
3323
3329
|
this._databaseId = function(t) {
|
|
3324
3330
|
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new U(R, '"projectId" not provided in firebase.initializeApp.');
|
|
@@ -3340,7 +3346,7 @@ class ie {
|
|
|
3340
3346
|
* The {@link @firebase/app#FirebaseApp} associated with this `Firestore` service
|
|
3341
3347
|
* instance.
|
|
3342
3348
|
*/ get app() {
|
|
3343
|
-
if (!this._app) throw new U(
|
|
3349
|
+
if (!this._app) throw new U(x, "Firestore was not initialized using the Firebase SDK. 'app' is not available");
|
|
3344
3350
|
return this._app;
|
|
3345
3351
|
}
|
|
3346
3352
|
get _initialized() {
|
|
@@ -3350,15 +3356,15 @@ class ie {
|
|
|
3350
3356
|
return void 0 !== this._terminateTask;
|
|
3351
3357
|
}
|
|
3352
3358
|
_setSettings(t) {
|
|
3353
|
-
if (this._settingsFrozen) throw new U(
|
|
3354
|
-
this._settings = new
|
|
3359
|
+
if (this._settingsFrozen) throw new U(x, "Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");
|
|
3360
|
+
this._settings = new sn(t), void 0 !== t.credentials && (this._authCredentials = function(t) {
|
|
3355
3361
|
if (!t) return new B;
|
|
3356
3362
|
switch (t.type) {
|
|
3357
3363
|
case "gapi":
|
|
3358
|
-
const
|
|
3364
|
+
const e = t.client;
|
|
3359
3365
|
// Make sure this really is a Gapi client.
|
|
3360
|
-
return b(!("object" != typeof
|
|
3361
|
-
new W(
|
|
3366
|
+
return b(!("object" != typeof e || null === e || !e.auth || !e.auth.getAuthHeaderValueForFirstParty)),
|
|
3367
|
+
new W(e, t.sessionIndex || "0", t.iamToken || null);
|
|
3362
3368
|
|
|
3363
3369
|
case "provider":
|
|
3364
3370
|
return t.client;
|
|
@@ -3392,17 +3398,17 @@ class ie {
|
|
|
3392
3398
|
* Only ever called once.
|
|
3393
3399
|
*/ _terminate() {
|
|
3394
3400
|
return function(t) {
|
|
3395
|
-
const
|
|
3396
|
-
|
|
3401
|
+
const e = nn.get(t);
|
|
3402
|
+
e && (p("ComponentProvider", "Removing Datastore"), nn.delete(t), e.terminate());
|
|
3397
3403
|
}(this), Promise.resolve();
|
|
3398
3404
|
}
|
|
3399
3405
|
}
|
|
3400
3406
|
|
|
3401
|
-
function
|
|
3402
|
-
const
|
|
3403
|
-
if (
|
|
3404
|
-
return
|
|
3405
|
-
options:
|
|
3407
|
+
function un(t, e) {
|
|
3408
|
+
const n = _getProvider(t, "firestore/lite");
|
|
3409
|
+
if (n.isInitialized()) throw new U(x, "Firestore can only be initialized once per app.");
|
|
3410
|
+
return n.initialize({
|
|
3411
|
+
options: e
|
|
3406
3412
|
});
|
|
3407
3413
|
}
|
|
3408
3414
|
|
|
@@ -3414,8 +3420,8 @@ function ue(t, n) {
|
|
|
3414
3420
|
* @param app - The {@link @firebase/app#FirebaseApp} instance that the returned `Firestore`
|
|
3415
3421
|
* instance is associated with.
|
|
3416
3422
|
* @returns The `Firestore` instance of the provided app.
|
|
3417
|
-
*/ function
|
|
3418
|
-
return _getProvider(
|
|
3423
|
+
*/ function cn(e = t()) {
|
|
3424
|
+
return _getProvider(e, "firestore/lite").getImmediate();
|
|
3419
3425
|
}
|
|
3420
3426
|
|
|
3421
3427
|
/**
|
|
@@ -3430,24 +3436,24 @@ function ue(t, n) {
|
|
|
3430
3436
|
* @param port - the emulator port (ex: 9000).
|
|
3431
3437
|
* @param options.mockUserToken - the mock auth token to use for unit testing
|
|
3432
3438
|
* Security Rules.
|
|
3433
|
-
*/ function
|
|
3439
|
+
*/ function an(t, e, n, r = {}) {
|
|
3434
3440
|
var s;
|
|
3435
|
-
const i = (t = ut(t,
|
|
3436
|
-
if ("firestore.googleapis.com" !== i.host && i.host !==
|
|
3441
|
+
const i = (t = ut(t, on))._getSettings();
|
|
3442
|
+
if ("firestore.googleapis.com" !== i.host && i.host !== e && _("Host has been set in both settings() and useEmulator(), emulator host will be used"),
|
|
3437
3443
|
t._setSettings(Object.assign(Object.assign({}, i), {
|
|
3438
|
-
host: `${
|
|
3444
|
+
host: `${e}:${n}`,
|
|
3439
3445
|
ssl: !1
|
|
3440
3446
|
})), r.mockUserToken) {
|
|
3441
|
-
let
|
|
3442
|
-
if ("string" == typeof r.mockUserToken)
|
|
3447
|
+
let e, n;
|
|
3448
|
+
if ("string" == typeof r.mockUserToken) e = r.mockUserToken, n = f.MOCK_USER; else {
|
|
3443
3449
|
// Let createMockUserToken validate first (catches common mistakes like
|
|
3444
3450
|
// invalid field "uid" and missing field "sub" / "user_id".)
|
|
3445
|
-
|
|
3451
|
+
e = h(r.mockUserToken, null === (s = t._app) || void 0 === s ? void 0 : s.options.projectId);
|
|
3446
3452
|
const i = r.mockUserToken.sub || r.mockUserToken.user_id;
|
|
3447
3453
|
if (!i) throw new U(R, "mockUserToken must contain 'sub' or 'user_id' field!");
|
|
3448
|
-
|
|
3454
|
+
n = new f(i);
|
|
3449
3455
|
}
|
|
3450
|
-
t._authCredentials = new z(new M(
|
|
3456
|
+
t._authCredentials = new z(new M(e, n));
|
|
3451
3457
|
}
|
|
3452
3458
|
}
|
|
3453
3459
|
|
|
@@ -3470,8 +3476,8 @@ function ue(t, n) {
|
|
|
3470
3476
|
* @param firestore - The `Firestore` instance to terminate.
|
|
3471
3477
|
* @returns A `Promise` that is resolved when the instance has been successfully
|
|
3472
3478
|
* terminated.
|
|
3473
|
-
*/ function
|
|
3474
|
-
return t = ut(t,
|
|
3479
|
+
*/ function hn(t) {
|
|
3480
|
+
return t = ut(t, on), e(t.app, "firestore/lite"), t._delete();
|
|
3475
3481
|
}
|
|
3476
3482
|
|
|
3477
3483
|
/**
|
|
@@ -3511,14 +3517,14 @@ function ue(t, n) {
|
|
|
3511
3517
|
* and can be used to write, read, or listen to the location. The document at
|
|
3512
3518
|
* the referenced location may or may not exist.
|
|
3513
3519
|
*/
|
|
3514
|
-
class
|
|
3520
|
+
class ln {
|
|
3515
3521
|
/** @hideconstructor */
|
|
3516
3522
|
constructor(t,
|
|
3517
3523
|
/**
|
|
3518
3524
|
* If provided, the `FirestoreDataConverter` associated with this instance.
|
|
3519
3525
|
*/
|
|
3520
|
-
|
|
3521
|
-
this.converter =
|
|
3526
|
+
e, n) {
|
|
3527
|
+
this.converter = e, this._key = n,
|
|
3522
3528
|
/** The type of this Firestore reference. */
|
|
3523
3529
|
this.type = "document", this.firestore = t;
|
|
3524
3530
|
}
|
|
@@ -3539,40 +3545,40 @@ class le {
|
|
|
3539
3545
|
/**
|
|
3540
3546
|
* The collection this `DocumentReference` belongs to.
|
|
3541
3547
|
*/ get parent() {
|
|
3542
|
-
return new
|
|
3548
|
+
return new dn(this.firestore, this.converter, this._key.path.popLast());
|
|
3543
3549
|
}
|
|
3544
3550
|
withConverter(t) {
|
|
3545
|
-
return new
|
|
3551
|
+
return new ln(this.firestore, t, this._key);
|
|
3546
3552
|
}
|
|
3547
3553
|
}
|
|
3548
3554
|
|
|
3549
3555
|
/**
|
|
3550
3556
|
* A `Query` refers to a query which you can read or listen to. You can also
|
|
3551
3557
|
* construct refined `Query` objects by adding filters and ordering.
|
|
3552
|
-
*/ class
|
|
3558
|
+
*/ class fn {
|
|
3553
3559
|
// This is the lite version of the Query class in the main SDK.
|
|
3554
3560
|
/** @hideconstructor protected */
|
|
3555
3561
|
constructor(t,
|
|
3556
3562
|
/**
|
|
3557
3563
|
* If provided, the `FirestoreDataConverter` associated with this instance.
|
|
3558
3564
|
*/
|
|
3559
|
-
|
|
3560
|
-
this.converter =
|
|
3565
|
+
e, n) {
|
|
3566
|
+
this.converter = e, this._query = n,
|
|
3561
3567
|
/** The type of this Firestore reference. */
|
|
3562
3568
|
this.type = "query", this.firestore = t;
|
|
3563
3569
|
}
|
|
3564
3570
|
withConverter(t) {
|
|
3565
|
-
return new
|
|
3571
|
+
return new fn(this.firestore, t, this._query);
|
|
3566
3572
|
}
|
|
3567
3573
|
}
|
|
3568
3574
|
|
|
3569
3575
|
/**
|
|
3570
3576
|
* A `CollectionReference` object can be used for adding documents, getting
|
|
3571
3577
|
* document references, and querying for documents (using {@link query}).
|
|
3572
|
-
*/ class
|
|
3578
|
+
*/ class dn extends fn {
|
|
3573
3579
|
/** @hideconstructor */
|
|
3574
|
-
constructor(t,
|
|
3575
|
-
super(t,
|
|
3580
|
+
constructor(t, e, n) {
|
|
3581
|
+
super(t, e, new ae(n)), this._path = n,
|
|
3576
3582
|
/** The type of this Firestore reference. */
|
|
3577
3583
|
this.type = "collection";
|
|
3578
3584
|
}
|
|
@@ -3590,23 +3596,23 @@ class le {
|
|
|
3590
3596
|
* subcollection. If this isn't a subcollection, the reference is null.
|
|
3591
3597
|
*/ get parent() {
|
|
3592
3598
|
const t = this._path.popLast();
|
|
3593
|
-
return t.isEmpty() ? null : new
|
|
3594
|
-
/* converter= */ null, new
|
|
3599
|
+
return t.isEmpty() ? null : new ln(this.firestore,
|
|
3600
|
+
/* converter= */ null, new nt(t));
|
|
3595
3601
|
}
|
|
3596
3602
|
withConverter(t) {
|
|
3597
|
-
return new
|
|
3603
|
+
return new dn(this.firestore, t, this._path);
|
|
3598
3604
|
}
|
|
3599
3605
|
}
|
|
3600
3606
|
|
|
3601
|
-
function
|
|
3602
|
-
if (t = l(t), rt("collection", "path",
|
|
3603
|
-
const r = Z.fromString(
|
|
3604
|
-
return it(r), new
|
|
3607
|
+
function wn(t, e, ...n) {
|
|
3608
|
+
if (t = l(t), rt("collection", "path", e), t instanceof on) {
|
|
3609
|
+
const r = Z.fromString(e, ...n);
|
|
3610
|
+
return it(r), new dn(t, /* converter= */ null, r);
|
|
3605
3611
|
}
|
|
3606
3612
|
{
|
|
3607
|
-
if (!(t instanceof
|
|
3608
|
-
const r = t._path.child(Z.fromString(
|
|
3609
|
-
return it(r), new
|
|
3613
|
+
if (!(t instanceof ln || t instanceof dn)) throw new U(R, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3614
|
+
const r = t._path.child(Z.fromString(e, ...n));
|
|
3615
|
+
return it(r), new dn(t.firestore,
|
|
3610
3616
|
/* converter= */ null, r);
|
|
3611
3617
|
}
|
|
3612
3618
|
}
|
|
@@ -3623,32 +3629,32 @@ function we(t, n, ...e) {
|
|
|
3623
3629
|
* collection or subcollection with this ID as the last segment of its path
|
|
3624
3630
|
* will be included. Cannot contain a slash.
|
|
3625
3631
|
* @returns The created `Query`.
|
|
3626
|
-
*/ function
|
|
3627
|
-
if (t = ut(t,
|
|
3628
|
-
return new
|
|
3632
|
+
*/ function mn(t, e) {
|
|
3633
|
+
if (t = ut(t, on), rt("collectionGroup", "collection id", e), e.indexOf("/") >= 0) throw new U(R, `Invalid collection ID '${e}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);
|
|
3634
|
+
return new fn(t,
|
|
3629
3635
|
/* converter= */ null,
|
|
3630
3636
|
/**
|
|
3631
3637
|
* Creates a new Query for a collection group query that matches all documents
|
|
3632
3638
|
* within the provided collection group.
|
|
3633
3639
|
*/
|
|
3634
3640
|
function(t) {
|
|
3635
|
-
return new
|
|
3636
|
-
}(
|
|
3641
|
+
return new ae(Z.emptyPath(), t);
|
|
3642
|
+
}(e));
|
|
3637
3643
|
}
|
|
3638
3644
|
|
|
3639
|
-
function
|
|
3645
|
+
function pn(t, e, ...n) {
|
|
3640
3646
|
if (t = l(t),
|
|
3641
3647
|
// We allow omission of 'pathString' but explicitly prohibit passing in both
|
|
3642
3648
|
// 'undefined' and 'null'.
|
|
3643
|
-
1 === arguments.length && (
|
|
3644
|
-
const r = Z.fromString(
|
|
3645
|
-
return st(r), new
|
|
3646
|
-
/* converter= */ null, new
|
|
3649
|
+
1 === arguments.length && (e = yt.R()), rt("doc", "path", e), t instanceof on) {
|
|
3650
|
+
const r = Z.fromString(e, ...n);
|
|
3651
|
+
return st(r), new ln(t,
|
|
3652
|
+
/* converter= */ null, new nt(r));
|
|
3647
3653
|
}
|
|
3648
3654
|
{
|
|
3649
|
-
if (!(t instanceof
|
|
3650
|
-
const r = t._path.child(Z.fromString(
|
|
3651
|
-
return st(r), new
|
|
3655
|
+
if (!(t instanceof ln || t instanceof dn)) throw new U(R, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3656
|
+
const r = t._path.child(Z.fromString(e, ...n));
|
|
3657
|
+
return st(r), new ln(t.firestore, t instanceof dn ? t.converter : null, new nt(r));
|
|
3652
3658
|
}
|
|
3653
3659
|
}
|
|
3654
3660
|
|
|
@@ -3659,8 +3665,8 @@ function pe(t, n, ...e) {
|
|
|
3659
3665
|
* @param right - A reference to compare.
|
|
3660
3666
|
* @returns true if the references point to the same location in the same
|
|
3661
3667
|
* Firestore database.
|
|
3662
|
-
*/ function
|
|
3663
|
-
return t = l(t),
|
|
3668
|
+
*/ function yn(t, e) {
|
|
3669
|
+
return t = l(t), e = l(e), (t instanceof ln || t instanceof dn) && (e instanceof ln || e instanceof dn) && (t.firestore === e.firestore && t.path === e.path && t.converter === e.converter);
|
|
3664
3670
|
}
|
|
3665
3671
|
|
|
3666
3672
|
/**
|
|
@@ -3671,8 +3677,8 @@ function pe(t, n, ...e) {
|
|
|
3671
3677
|
* @param right - A `Query` to compare.
|
|
3672
3678
|
* @returns true if the references point to the same location in the same
|
|
3673
3679
|
* Firestore database.
|
|
3674
|
-
*/ function
|
|
3675
|
-
return t = l(t),
|
|
3680
|
+
*/ function _n(t, e) {
|
|
3681
|
+
return t = l(t), e = l(e), t instanceof fn && e instanceof fn && (t.firestore === e.firestore && me(t._query, e._query) && t.converter === e.converter);
|
|
3676
3682
|
}
|
|
3677
3683
|
|
|
3678
3684
|
/**
|
|
@@ -3698,7 +3704,7 @@ function pe(t, n, ...e) {
|
|
|
3698
3704
|
*
|
|
3699
3705
|
* Create a `FieldPath` by providing field names. If more than one field
|
|
3700
3706
|
* name is provided, the path will point to a nested field in a document.
|
|
3701
|
-
*/ class
|
|
3707
|
+
*/ class gn {
|
|
3702
3708
|
/**
|
|
3703
3709
|
* Creates a `FieldPath` from the provided field names. If more than one field
|
|
3704
3710
|
* name is provided, the path will point to a nested field in a document.
|
|
@@ -3706,8 +3712,8 @@ function pe(t, n, ...e) {
|
|
|
3706
3712
|
* @param fieldNames - A list of field names.
|
|
3707
3713
|
*/
|
|
3708
3714
|
constructor(...t) {
|
|
3709
|
-
for (let
|
|
3710
|
-
this._internalPath = new
|
|
3715
|
+
for (let e = 0; e < t.length; ++e) if (0 === t[e].length) throw new U(R, "Invalid field name at argument $(i + 1). Field names must not be empty.");
|
|
3716
|
+
this._internalPath = new et(t);
|
|
3711
3717
|
}
|
|
3712
3718
|
/**
|
|
3713
3719
|
* Returns true if this `FieldPath` is equal to the provided one.
|
|
@@ -3722,8 +3728,8 @@ function pe(t, n, ...e) {
|
|
|
3722
3728
|
/**
|
|
3723
3729
|
* Returns a special sentinel `FieldPath` to refer to the ID of a document.
|
|
3724
3730
|
* It can be used in queries to sort or filter by the document ID.
|
|
3725
|
-
*/ function
|
|
3726
|
-
return new
|
|
3731
|
+
*/ function vn() {
|
|
3732
|
+
return new gn("__name__");
|
|
3727
3733
|
}
|
|
3728
3734
|
|
|
3729
3735
|
/**
|
|
@@ -3744,7 +3750,7 @@ function pe(t, n, ...e) {
|
|
|
3744
3750
|
*/
|
|
3745
3751
|
/**
|
|
3746
3752
|
* An immutable object representing an array of bytes.
|
|
3747
|
-
*/ class
|
|
3753
|
+
*/ class bn {
|
|
3748
3754
|
/** @hideconstructor */
|
|
3749
3755
|
constructor(t) {
|
|
3750
3756
|
this._byteString = t;
|
|
@@ -3756,7 +3762,7 @@ function pe(t, n, ...e) {
|
|
|
3756
3762
|
* @param base64 - The Base64 string used to create the `Bytes` object.
|
|
3757
3763
|
*/ static fromBase64String(t) {
|
|
3758
3764
|
try {
|
|
3759
|
-
return new
|
|
3765
|
+
return new bn(Rt.fromBase64String(t));
|
|
3760
3766
|
} catch (t) {
|
|
3761
3767
|
throw new U(R, "Failed to construct data from Base64 string: " + t);
|
|
3762
3768
|
}
|
|
@@ -3766,7 +3772,7 @@ function pe(t, n, ...e) {
|
|
|
3766
3772
|
*
|
|
3767
3773
|
* @param array - The Uint8Array used to create the `Bytes` object.
|
|
3768
3774
|
*/ static fromUint8Array(t) {
|
|
3769
|
-
return new
|
|
3775
|
+
return new bn(Rt.fromUint8Array(t));
|
|
3770
3776
|
}
|
|
3771
3777
|
/**
|
|
3772
3778
|
* Returns the underlying bytes as a Base64-encoded string.
|
|
@@ -3818,7 +3824,7 @@ function pe(t, n, ...e) {
|
|
|
3818
3824
|
/**
|
|
3819
3825
|
* Sentinel values that can be used when writing document fields with `set()`
|
|
3820
3826
|
* or `update()`.
|
|
3821
|
-
*/ class
|
|
3827
|
+
*/ class En {
|
|
3822
3828
|
/**
|
|
3823
3829
|
* @param _methodName - The public API endpoint that returns this class.
|
|
3824
3830
|
* @hideconstructor
|
|
@@ -3850,17 +3856,17 @@ function pe(t, n, ...e) {
|
|
|
3850
3856
|
*
|
|
3851
3857
|
* Latitude values are in the range of [-90, 90].
|
|
3852
3858
|
* Longitude values are in the range of [-180, 180].
|
|
3853
|
-
*/ class
|
|
3859
|
+
*/ class Tn {
|
|
3854
3860
|
/**
|
|
3855
3861
|
* Creates a new immutable `GeoPoint` object with the provided latitude and
|
|
3856
3862
|
* longitude values.
|
|
3857
3863
|
* @param latitude - The latitude as number between -90 and 90.
|
|
3858
3864
|
* @param longitude - The longitude as number between -180 and 180.
|
|
3859
3865
|
*/
|
|
3860
|
-
constructor(t,
|
|
3866
|
+
constructor(t, e) {
|
|
3861
3867
|
if (!isFinite(t) || t < -90 || t > 90) throw new U(R, "Latitude must be a number between -90 and 90, but was: " + t);
|
|
3862
|
-
if (!isFinite(
|
|
3863
|
-
this._lat = t, this._long =
|
|
3868
|
+
if (!isFinite(e) || e < -180 || e > 180) throw new U(R, "Longitude must be a number between -180 and 180, but was: " + e);
|
|
3869
|
+
this._lat = t, this._long = e;
|
|
3864
3870
|
}
|
|
3865
3871
|
/**
|
|
3866
3872
|
* The latitude of this `GeoPoint` instance.
|
|
@@ -3909,29 +3915,29 @@ function pe(t, n, ...e) {
|
|
|
3909
3915
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3910
3916
|
* See the License for the specific language governing permissions and
|
|
3911
3917
|
* limitations under the License.
|
|
3912
|
-
*/ const
|
|
3918
|
+
*/ const An = /^__.*__$/;
|
|
3913
3919
|
|
|
3914
|
-
/** The result of parsing document data (e.g. for a setData call). */ class
|
|
3915
|
-
constructor(t,
|
|
3916
|
-
this.data = t, this.fieldMask =
|
|
3920
|
+
/** The result of parsing document data (e.g. for a setData call). */ class In {
|
|
3921
|
+
constructor(t, e, n) {
|
|
3922
|
+
this.data = t, this.fieldMask = e, this.fieldTransforms = n;
|
|
3917
3923
|
}
|
|
3918
|
-
toMutation(t,
|
|
3919
|
-
return null !== this.fieldMask ? new
|
|
3924
|
+
toMutation(t, e) {
|
|
3925
|
+
return null !== this.fieldMask ? new Re(t, this.data, this.fieldMask, e, this.fieldTransforms) : new Ie(t, this.data, e, this.fieldTransforms);
|
|
3920
3926
|
}
|
|
3921
3927
|
}
|
|
3922
3928
|
|
|
3923
|
-
/** The result of parsing "update" data (i.e. for an updateData call). */ class
|
|
3929
|
+
/** The result of parsing "update" data (i.e. for an updateData call). */ class Rn {
|
|
3924
3930
|
constructor(t,
|
|
3925
3931
|
// The fieldMask does not include document transforms.
|
|
3926
|
-
|
|
3927
|
-
this.data = t, this.fieldMask =
|
|
3932
|
+
e, n) {
|
|
3933
|
+
this.data = t, this.fieldMask = e, this.fieldTransforms = n;
|
|
3928
3934
|
}
|
|
3929
|
-
toMutation(t,
|
|
3930
|
-
return new
|
|
3935
|
+
toMutation(t, e) {
|
|
3936
|
+
return new Re(t, this.data, this.fieldMask, e, this.fieldTransforms);
|
|
3931
3937
|
}
|
|
3932
3938
|
}
|
|
3933
3939
|
|
|
3934
|
-
function
|
|
3940
|
+
function Pn(t) {
|
|
3935
3941
|
switch (t) {
|
|
3936
3942
|
case 0 /* Set */ :
|
|
3937
3943
|
// fall through
|
|
@@ -3949,7 +3955,7 @@ function Pe(t) {
|
|
|
3949
3955
|
}
|
|
3950
3956
|
}
|
|
3951
3957
|
|
|
3952
|
-
/** A "context" object passed around while parsing user data. */ class
|
|
3958
|
+
/** A "context" object passed around while parsing user data. */ class Vn {
|
|
3953
3959
|
/**
|
|
3954
3960
|
* Initializes a ParseContext with the given source and path.
|
|
3955
3961
|
*
|
|
@@ -3968,8 +3974,8 @@ function Pe(t) {
|
|
|
3968
3974
|
* which case certain features will not work and errors will be somewhat
|
|
3969
3975
|
* compromised).
|
|
3970
3976
|
*/
|
|
3971
|
-
constructor(t,
|
|
3972
|
-
this.settings = t, this.databaseId =
|
|
3977
|
+
constructor(t, e, n, r, s, i) {
|
|
3978
|
+
this.settings = t, this.databaseId = e, this.q = n, this.ignoreUndefinedProperties = r,
|
|
3973
3979
|
// Minor hack: If fieldTransforms is undefined, we assume this is an
|
|
3974
3980
|
// external call and we need to validate the entire path.
|
|
3975
3981
|
void 0 === s && this.Z(), this.fieldTransforms = s || [], this.fieldMask = i || [];
|
|
@@ -3980,21 +3986,21 @@ function Pe(t) {
|
|
|
3980
3986
|
get tt() {
|
|
3981
3987
|
return this.settings.tt;
|
|
3982
3988
|
}
|
|
3983
|
-
/** Returns a new context with the specified settings overwritten. */
|
|
3984
|
-
return new
|
|
3989
|
+
/** Returns a new context with the specified settings overwritten. */ et(t) {
|
|
3990
|
+
return new Vn(Object.assign(Object.assign({}, this.settings), t), this.databaseId, this.q, this.ignoreUndefinedProperties, this.fieldTransforms, this.fieldMask);
|
|
3985
3991
|
}
|
|
3986
|
-
|
|
3987
|
-
var
|
|
3988
|
-
const
|
|
3989
|
-
path:
|
|
3992
|
+
nt(t) {
|
|
3993
|
+
var e;
|
|
3994
|
+
const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), r = this.et({
|
|
3995
|
+
path: n,
|
|
3990
3996
|
rt: !1
|
|
3991
3997
|
});
|
|
3992
3998
|
return r.st(t), r;
|
|
3993
3999
|
}
|
|
3994
4000
|
it(t) {
|
|
3995
|
-
var
|
|
3996
|
-
const
|
|
3997
|
-
path:
|
|
4001
|
+
var e;
|
|
4002
|
+
const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), r = this.et({
|
|
4003
|
+
path: n,
|
|
3998
4004
|
rt: !1
|
|
3999
4005
|
});
|
|
4000
4006
|
return r.Z(), r;
|
|
@@ -4002,16 +4008,16 @@ function Pe(t) {
|
|
|
4002
4008
|
ot(t) {
|
|
4003
4009
|
// TODO(b/34871131): We don't support array paths right now; so make path
|
|
4004
4010
|
// undefined.
|
|
4005
|
-
return this.
|
|
4011
|
+
return this.et({
|
|
4006
4012
|
path: void 0,
|
|
4007
4013
|
rt: !0
|
|
4008
4014
|
});
|
|
4009
4015
|
}
|
|
4010
4016
|
ut(t) {
|
|
4011
|
-
return
|
|
4017
|
+
return Yn(t, this.settings.methodName, this.settings.ct || !1, this.path, this.settings.at);
|
|
4012
4018
|
}
|
|
4013
4019
|
/** Returns 'true' if 'fieldPath' was traversed when creating this context. */ contains(t) {
|
|
4014
|
-
return void 0 !== this.fieldMask.find((
|
|
4020
|
+
return void 0 !== this.fieldMask.find((e => t.isPrefixOf(e))) || void 0 !== this.fieldTransforms.find((e => t.isPrefixOf(e.field)));
|
|
4015
4021
|
}
|
|
4016
4022
|
Z() {
|
|
4017
4023
|
// TODO(b/34871131): Remove null check once we have proper paths for fields
|
|
@@ -4020,52 +4026,52 @@ function Pe(t) {
|
|
|
4020
4026
|
}
|
|
4021
4027
|
st(t) {
|
|
4022
4028
|
if (0 === t.length) throw this.ut("Document fields must not be empty");
|
|
4023
|
-
if (
|
|
4029
|
+
if (Pn(this.tt) && An.test(t)) throw this.ut('Document fields cannot begin and end with "__"');
|
|
4024
4030
|
}
|
|
4025
4031
|
}
|
|
4026
4032
|
|
|
4027
4033
|
/**
|
|
4028
4034
|
* Helper for parsing raw user input (provided via the API) into internal model
|
|
4029
4035
|
* classes.
|
|
4030
|
-
*/ class
|
|
4031
|
-
constructor(t,
|
|
4032
|
-
this.databaseId = t, this.ignoreUndefinedProperties =
|
|
4036
|
+
*/ class Nn {
|
|
4037
|
+
constructor(t, e, n) {
|
|
4038
|
+
this.databaseId = t, this.ignoreUndefinedProperties = e, this.q = n || Ke(t);
|
|
4033
4039
|
}
|
|
4034
|
-
/** Creates a new top-level parse context. */ ht(t,
|
|
4035
|
-
return new
|
|
4040
|
+
/** Creates a new top-level parse context. */ ht(t, e, n, r = !1) {
|
|
4041
|
+
return new Vn({
|
|
4036
4042
|
tt: t,
|
|
4037
|
-
methodName:
|
|
4038
|
-
at:
|
|
4039
|
-
path:
|
|
4043
|
+
methodName: e,
|
|
4044
|
+
at: n,
|
|
4045
|
+
path: et.emptyPath(),
|
|
4040
4046
|
rt: !1,
|
|
4041
4047
|
ct: r
|
|
4042
4048
|
}, this.databaseId, this.q, this.ignoreUndefinedProperties);
|
|
4043
4049
|
}
|
|
4044
4050
|
}
|
|
4045
4051
|
|
|
4046
|
-
function
|
|
4047
|
-
const
|
|
4048
|
-
return new
|
|
4052
|
+
function Dn(t) {
|
|
4053
|
+
const e = t._freezeSettings(), n = Ke(t._databaseId);
|
|
4054
|
+
return new Nn(t._databaseId, !!e.ignoreUndefinedProperties, n);
|
|
4049
4055
|
}
|
|
4050
4056
|
|
|
4051
|
-
/** Parse document data from a set() call. */ function $
|
|
4052
|
-
const o = t.ht(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ ,
|
|
4053
|
-
|
|
4054
|
-
const u =
|
|
4057
|
+
/** Parse document data from a set() call. */ function $n(t, e, n, r, s, i = {}) {
|
|
4058
|
+
const o = t.ht(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ , e, n, s);
|
|
4059
|
+
zn("Data must be an object, but it was:", o, r);
|
|
4060
|
+
const u = Mn(r, o);
|
|
4055
4061
|
let c, a;
|
|
4056
|
-
if (i.merge) c = new
|
|
4062
|
+
if (i.merge) c = new At(o.fieldMask), a = o.fieldTransforms; else if (i.mergeFields) {
|
|
4057
4063
|
const t = [];
|
|
4058
4064
|
for (const r of i.mergeFields) {
|
|
4059
|
-
const s =
|
|
4065
|
+
const s = Gn(e, r, n);
|
|
4060
4066
|
if (!o.contains(s)) throw new U(R, `Field '${s}' is specified in your field mask but missing from your input data.`);
|
|
4061
|
-
|
|
4067
|
+
Hn(t, s) || t.push(s);
|
|
4062
4068
|
}
|
|
4063
|
-
c = new
|
|
4069
|
+
c = new At(t), a = o.fieldTransforms.filter((t => c.covers(t.field)));
|
|
4064
4070
|
} else c = null, a = o.fieldTransforms;
|
|
4065
|
-
return new
|
|
4071
|
+
return new In(new Qt(u), c, a);
|
|
4066
4072
|
}
|
|
4067
4073
|
|
|
4068
|
-
class
|
|
4074
|
+
class Sn extends En {
|
|
4069
4075
|
_toFieldTransform(t) {
|
|
4070
4076
|
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}`);
|
|
4071
4077
|
// No transform to add for a delete, but we need to add it to our
|
|
@@ -4073,7 +4079,7 @@ class Se extends Ee {
|
|
|
4073
4079
|
return t.fieldMask.push(t.path), null;
|
|
4074
4080
|
}
|
|
4075
4081
|
isEqual(t) {
|
|
4076
|
-
return t instanceof
|
|
4082
|
+
return t instanceof Sn;
|
|
4077
4083
|
}
|
|
4078
4084
|
}
|
|
4079
4085
|
|
|
@@ -4092,32 +4098,32 @@ class Se extends Ee {
|
|
|
4092
4098
|
* context.
|
|
4093
4099
|
* @param context - The parent context.
|
|
4094
4100
|
* @param arrayElement - Whether or not the FieldValue has an array.
|
|
4095
|
-
*/ function
|
|
4096
|
-
return new
|
|
4101
|
+
*/ function xn(t, e, n) {
|
|
4102
|
+
return new Vn({
|
|
4097
4103
|
tt: 3 /* Argument */ ,
|
|
4098
|
-
at:
|
|
4104
|
+
at: e.settings.at,
|
|
4099
4105
|
methodName: t._methodName,
|
|
4100
|
-
rt:
|
|
4101
|
-
},
|
|
4106
|
+
rt: n
|
|
4107
|
+
}, e.databaseId, e.q, e.ignoreUndefinedProperties);
|
|
4102
4108
|
}
|
|
4103
4109
|
|
|
4104
|
-
class
|
|
4110
|
+
class Fn extends En {
|
|
4105
4111
|
_toFieldTransform(t) {
|
|
4106
|
-
return new
|
|
4112
|
+
return new Ee(t.path, new _e);
|
|
4107
4113
|
}
|
|
4108
4114
|
isEqual(t) {
|
|
4109
|
-
return t instanceof
|
|
4115
|
+
return t instanceof Fn;
|
|
4110
4116
|
}
|
|
4111
4117
|
}
|
|
4112
4118
|
|
|
4113
|
-
class
|
|
4114
|
-
constructor(t,
|
|
4115
|
-
super(t), this.lt =
|
|
4119
|
+
class qn extends En {
|
|
4120
|
+
constructor(t, e) {
|
|
4121
|
+
super(t), this.lt = e;
|
|
4116
4122
|
}
|
|
4117
4123
|
_toFieldTransform(t) {
|
|
4118
|
-
const
|
|
4119
|
-
/*array=*/ !0),
|
|
4120
|
-
return new
|
|
4124
|
+
const e = xn(this, t,
|
|
4125
|
+
/*array=*/ !0), n = this.lt.map((t => jn(t, e))), r = new ge(n);
|
|
4126
|
+
return new Ee(t.path, r);
|
|
4121
4127
|
}
|
|
4122
4128
|
isEqual(t) {
|
|
4123
4129
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4125,14 +4131,14 @@ class qe extends Ee {
|
|
|
4125
4131
|
}
|
|
4126
4132
|
}
|
|
4127
4133
|
|
|
4128
|
-
class
|
|
4129
|
-
constructor(t,
|
|
4130
|
-
super(t), this.lt =
|
|
4134
|
+
class On extends En {
|
|
4135
|
+
constructor(t, e) {
|
|
4136
|
+
super(t), this.lt = e;
|
|
4131
4137
|
}
|
|
4132
4138
|
_toFieldTransform(t) {
|
|
4133
|
-
const
|
|
4134
|
-
/*array=*/ !0),
|
|
4135
|
-
return new
|
|
4139
|
+
const e = xn(this, t,
|
|
4140
|
+
/*array=*/ !0), n = this.lt.map((t => jn(t, e))), r = new ve(n);
|
|
4141
|
+
return new Ee(t.path, r);
|
|
4136
4142
|
}
|
|
4137
4143
|
isEqual(t) {
|
|
4138
4144
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4140,13 +4146,13 @@ class Oe extends Ee {
|
|
|
4140
4146
|
}
|
|
4141
4147
|
}
|
|
4142
4148
|
|
|
4143
|
-
class
|
|
4144
|
-
constructor(t,
|
|
4145
|
-
super(t), this.ft =
|
|
4149
|
+
class Cn extends En {
|
|
4150
|
+
constructor(t, e) {
|
|
4151
|
+
super(t), this.ft = e;
|
|
4146
4152
|
}
|
|
4147
4153
|
_toFieldTransform(t) {
|
|
4148
|
-
const
|
|
4149
|
-
return new
|
|
4154
|
+
const e = new be(t.q, pe(t.q, this.ft));
|
|
4155
|
+
return new Ee(t.path, e);
|
|
4150
4156
|
}
|
|
4151
4157
|
isEqual(t) {
|
|
4152
4158
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4154,50 +4160,50 @@ class Ce extends Ee {
|
|
|
4154
4160
|
}
|
|
4155
4161
|
}
|
|
4156
4162
|
|
|
4157
|
-
/** Parse update data from an update() call. */ function
|
|
4158
|
-
const s = t.ht(1 /* Update */ ,
|
|
4159
|
-
|
|
4160
|
-
const i = [], o =
|
|
4163
|
+
/** Parse update data from an update() call. */ function Ln(t, e, n, r) {
|
|
4164
|
+
const s = t.ht(1 /* Update */ , e, n);
|
|
4165
|
+
zn("Data must be an object, but it was:", s, r);
|
|
4166
|
+
const i = [], o = Qt.empty();
|
|
4161
4167
|
Tt(r, ((t, r) => {
|
|
4162
|
-
const u =
|
|
4168
|
+
const u = Wn(e, t, n);
|
|
4163
4169
|
// For Compat types, we have to "extract" the underlying types before
|
|
4164
4170
|
// performing validation.
|
|
4165
4171
|
r = l(r);
|
|
4166
4172
|
const c = s.it(u);
|
|
4167
|
-
if (r instanceof
|
|
4173
|
+
if (r instanceof Sn)
|
|
4168
4174
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4169
4175
|
i.push(u); else {
|
|
4170
|
-
const t =
|
|
4176
|
+
const t = jn(r, c);
|
|
4171
4177
|
null != t && (i.push(u), o.set(u, t));
|
|
4172
4178
|
}
|
|
4173
4179
|
}));
|
|
4174
|
-
const u = new
|
|
4175
|
-
return new
|
|
4180
|
+
const u = new At(i);
|
|
4181
|
+
return new Rn(o, u, s.fieldTransforms);
|
|
4176
4182
|
}
|
|
4177
4183
|
|
|
4178
|
-
/** Parse update data from a list of field/value arguments. */ function
|
|
4179
|
-
const o = t.ht(1 /* Update */ ,
|
|
4180
|
-
if (i.length % 2 != 0) throw new U(R, `Function ${
|
|
4181
|
-
for (let t = 0; t < i.length; t += 2) u.push(
|
|
4182
|
-
const a = [], h =
|
|
4184
|
+
/** Parse update data from a list of field/value arguments. */ function kn(t, e, n, r, s, i) {
|
|
4185
|
+
const o = t.ht(1 /* Update */ , e, n), u = [ Gn(e, r, n) ], c = [ s ];
|
|
4186
|
+
if (i.length % 2 != 0) throw new U(R, `Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);
|
|
4187
|
+
for (let t = 0; t < i.length; t += 2) u.push(Gn(e, i[t])), c.push(i[t + 1]);
|
|
4188
|
+
const a = [], h = Qt.empty();
|
|
4183
4189
|
// We iterate in reverse order to pick the last value for a field if the
|
|
4184
4190
|
// user specified the field multiple times.
|
|
4185
|
-
for (let t = u.length - 1; t >= 0; --t) if (!
|
|
4186
|
-
const
|
|
4187
|
-
let
|
|
4191
|
+
for (let t = u.length - 1; t >= 0; --t) if (!Hn(a, u[t])) {
|
|
4192
|
+
const e = u[t];
|
|
4193
|
+
let n = c[t];
|
|
4188
4194
|
// For Compat types, we have to "extract" the underlying types before
|
|
4189
4195
|
// performing validation.
|
|
4190
|
-
|
|
4191
|
-
const r = o.it(
|
|
4192
|
-
if (
|
|
4196
|
+
n = l(n);
|
|
4197
|
+
const r = o.it(e);
|
|
4198
|
+
if (n instanceof Sn)
|
|
4193
4199
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4194
|
-
a.push(
|
|
4195
|
-
const t =
|
|
4196
|
-
null != t && (a.push(
|
|
4200
|
+
a.push(e); else {
|
|
4201
|
+
const t = jn(n, r);
|
|
4202
|
+
null != t && (a.push(e), h.set(e, t));
|
|
4197
4203
|
}
|
|
4198
4204
|
}
|
|
4199
|
-
const f = new
|
|
4200
|
-
return new
|
|
4205
|
+
const f = new At(a);
|
|
4206
|
+
return new Rn(h, f, o.fieldTransforms);
|
|
4201
4207
|
}
|
|
4202
4208
|
|
|
4203
4209
|
/**
|
|
@@ -4206,8 +4212,8 @@ class Ce extends Ee {
|
|
|
4206
4212
|
*
|
|
4207
4213
|
* @param allowArrays - Whether the query value is an array that may directly
|
|
4208
4214
|
* contain additional arrays (e.g. the operand of an `in` query).
|
|
4209
|
-
*/ function
|
|
4210
|
-
return
|
|
4215
|
+
*/ function Un(t, e, n, r = !1) {
|
|
4216
|
+
return jn(n, t.ht(r ? 4 /* ArrayArgument */ : 3 /* Argument */ , e));
|
|
4211
4217
|
}
|
|
4212
4218
|
|
|
4213
4219
|
/**
|
|
@@ -4218,12 +4224,12 @@ class Ce extends Ee {
|
|
|
4218
4224
|
* the source of the data being parsed, etc.
|
|
4219
4225
|
* @returns The parsed value, or null if the value was a FieldValue sentinel
|
|
4220
4226
|
* that should not be included in the resulting parsed data.
|
|
4221
|
-
*/ function
|
|
4222
|
-
if (
|
|
4227
|
+
*/ function jn(t, e) {
|
|
4228
|
+
if (Bn(
|
|
4223
4229
|
// Unwrap the API type from the Compat SDK. This will return the API type
|
|
4224
4230
|
// from firestore-exp.
|
|
4225
|
-
t = l(t))) return
|
|
4226
|
-
if (t instanceof
|
|
4231
|
+
t = l(t))) return zn("Unsupported field value:", e, t), Mn(t, e);
|
|
4232
|
+
if (t instanceof En)
|
|
4227
4233
|
// FieldValues usually parse into transforms (except deleteField())
|
|
4228
4234
|
// in which case we do not want to include this field in our parsed data
|
|
4229
4235
|
// (as doing so will overwrite the field directly prior to the transform
|
|
@@ -4233,19 +4239,19 @@ class Ce extends Ee {
|
|
|
4233
4239
|
* "Parses" the provided FieldValueImpl, adding any necessary transforms to
|
|
4234
4240
|
* context.fieldTransforms.
|
|
4235
4241
|
*/
|
|
4236
|
-
return function(t,
|
|
4242
|
+
return function(t, e) {
|
|
4237
4243
|
// Sentinels are only supported with writes, and not within arrays.
|
|
4238
|
-
if (!
|
|
4239
|
-
if (!
|
|
4240
|
-
const
|
|
4241
|
-
|
|
4244
|
+
if (!Pn(e.tt)) throw e.ut(`${t._methodName}() can only be used with update() and set()`);
|
|
4245
|
+
if (!e.path) throw e.ut(`${t._methodName}() is not currently supported inside arrays`);
|
|
4246
|
+
const n = t._toFieldTransform(e);
|
|
4247
|
+
n && e.fieldTransforms.push(n);
|
|
4242
4248
|
}
|
|
4243
4249
|
/**
|
|
4244
4250
|
* Helper to parse a scalar value (i.e. not an Object, Array, or FieldValue)
|
|
4245
4251
|
*
|
|
4246
4252
|
* @returns The parsed value
|
|
4247
|
-
*/ (t,
|
|
4248
|
-
if (void 0 === t &&
|
|
4253
|
+
*/ (t, e), null;
|
|
4254
|
+
if (void 0 === t && e.ignoreUndefinedProperties)
|
|
4249
4255
|
// If the input is undefined it can never participate in the fieldMask, so
|
|
4250
4256
|
// don't handle this below. If `ignoreUndefinedProperties` is false,
|
|
4251
4257
|
// `parseScalarValue` will reject an undefined value.
|
|
@@ -4253,38 +4259,38 @@ class Ce extends Ee {
|
|
|
4253
4259
|
if (
|
|
4254
4260
|
// If context.path is null we are inside an array and we don't support
|
|
4255
4261
|
// field mask paths more granular than the top-level array.
|
|
4256
|
-
|
|
4262
|
+
e.path && e.fieldMask.push(e.path), t instanceof Array) {
|
|
4257
4263
|
// TODO(b/34871131): Include the path containing the array in the error
|
|
4258
4264
|
// message.
|
|
4259
4265
|
// In the case of IN queries, the parsed data is an array (representing
|
|
4260
4266
|
// the set of values to be included for the IN query) that may directly
|
|
4261
4267
|
// contain additional arrays (each representing an individual field
|
|
4262
4268
|
// value), so we disable this validation.
|
|
4263
|
-
if (
|
|
4264
|
-
return function(t,
|
|
4265
|
-
const
|
|
4269
|
+
if (e.settings.rt && 4 /* ArrayArgument */ !== e.tt) throw e.ut("Nested arrays are not supported");
|
|
4270
|
+
return function(t, e) {
|
|
4271
|
+
const n = [];
|
|
4266
4272
|
let r = 0;
|
|
4267
4273
|
for (const s of t) {
|
|
4268
|
-
let t =
|
|
4274
|
+
let t = jn(s, e.ot(r));
|
|
4269
4275
|
null == t && (
|
|
4270
4276
|
// Just include nulls in the array for fields being replaced with a
|
|
4271
4277
|
// sentinel.
|
|
4272
4278
|
t = {
|
|
4273
4279
|
nullValue: "NULL_VALUE"
|
|
4274
|
-
}),
|
|
4280
|
+
}), n.push(t), r++;
|
|
4275
4281
|
}
|
|
4276
4282
|
return {
|
|
4277
4283
|
arrayValue: {
|
|
4278
|
-
values:
|
|
4284
|
+
values: n
|
|
4279
4285
|
}
|
|
4280
4286
|
};
|
|
4281
|
-
}(t,
|
|
4287
|
+
}(t, e);
|
|
4282
4288
|
}
|
|
4283
|
-
return function(t,
|
|
4289
|
+
return function(t, e) {
|
|
4284
4290
|
if (null === (t = l(t))) return {
|
|
4285
4291
|
nullValue: "NULL_VALUE"
|
|
4286
4292
|
};
|
|
4287
|
-
if ("number" == typeof t) return
|
|
4293
|
+
if ("number" == typeof t) return pe(e.q, t);
|
|
4288
4294
|
if ("boolean" == typeof t) return {
|
|
4289
4295
|
booleanValue: t
|
|
4290
4296
|
};
|
|
@@ -4292,37 +4298,37 @@ class Ce extends Ee {
|
|
|
4292
4298
|
stringValue: t
|
|
4293
4299
|
};
|
|
4294
4300
|
if (t instanceof Date) {
|
|
4295
|
-
const
|
|
4301
|
+
const n = vt.fromDate(t);
|
|
4296
4302
|
return {
|
|
4297
|
-
timestampValue:
|
|
4303
|
+
timestampValue: Se(e.q, n)
|
|
4298
4304
|
};
|
|
4299
4305
|
}
|
|
4300
4306
|
if (t instanceof vt) {
|
|
4301
4307
|
// Firestore backend truncates precision down to microseconds. To ensure
|
|
4302
4308
|
// offline mode works the same with regards to truncation, perform the
|
|
4303
4309
|
// truncation immediately without waiting for the backend to do that.
|
|
4304
|
-
const
|
|
4310
|
+
const n = new vt(t.seconds, 1e3 * Math.floor(t.nanoseconds / 1e3));
|
|
4305
4311
|
return {
|
|
4306
|
-
timestampValue:
|
|
4312
|
+
timestampValue: Se(e.q, n)
|
|
4307
4313
|
};
|
|
4308
4314
|
}
|
|
4309
|
-
if (t instanceof
|
|
4315
|
+
if (t instanceof Tn) return {
|
|
4310
4316
|
geoPointValue: {
|
|
4311
4317
|
latitude: t.latitude,
|
|
4312
4318
|
longitude: t.longitude
|
|
4313
4319
|
}
|
|
4314
4320
|
};
|
|
4315
|
-
if (t instanceof
|
|
4316
|
-
bytesValue:
|
|
4321
|
+
if (t instanceof bn) return {
|
|
4322
|
+
bytesValue: xe(e.q, t._byteString)
|
|
4317
4323
|
};
|
|
4318
|
-
if (t instanceof
|
|
4319
|
-
const
|
|
4320
|
-
if (!r.isEqual(
|
|
4324
|
+
if (t instanceof ln) {
|
|
4325
|
+
const n = e.databaseId, r = t.firestore._databaseId;
|
|
4326
|
+
if (!r.isEqual(n)) throw e.ut(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);
|
|
4321
4327
|
return {
|
|
4322
|
-
referenceValue:
|
|
4328
|
+
referenceValue: Oe(t.firestore._databaseId || e.databaseId, t._key.path)
|
|
4323
4329
|
};
|
|
4324
4330
|
}
|
|
4325
|
-
throw
|
|
4331
|
+
throw e.ut(`Unsupported field value: ${ot(t)}`);
|
|
4326
4332
|
}
|
|
4327
4333
|
/**
|
|
4328
4334
|
* Checks whether an object looks like a JSON object that should be converted
|
|
@@ -4330,56 +4336,56 @@ class Ce extends Ee {
|
|
|
4330
4336
|
* JSON objects since they should be converted to a struct value. Arrays, Dates,
|
|
4331
4337
|
* GeoPoints, etc. are not considered to look like JSON objects since they map
|
|
4332
4338
|
* to specific FieldValue types other than ObjectValue.
|
|
4333
|
-
*/ (t,
|
|
4339
|
+
*/ (t, e);
|
|
4334
4340
|
}
|
|
4335
4341
|
|
|
4336
|
-
function
|
|
4337
|
-
const
|
|
4342
|
+
function Mn(t, e) {
|
|
4343
|
+
const n = {};
|
|
4338
4344
|
return !function(t) {
|
|
4339
|
-
for (const
|
|
4345
|
+
for (const e in t) if (Object.prototype.hasOwnProperty.call(t, e)) return !1;
|
|
4340
4346
|
return !0;
|
|
4341
4347
|
}(t) ? Tt(t, ((t, r) => {
|
|
4342
|
-
const s =
|
|
4343
|
-
null != s && (
|
|
4348
|
+
const s = jn(r, e.nt(t));
|
|
4349
|
+
null != s && (n[t] = s);
|
|
4344
4350
|
})) :
|
|
4345
4351
|
// If we encounter an empty object, we explicitly add it to the update
|
|
4346
4352
|
// mask to ensure that the server creates a map entry.
|
|
4347
|
-
|
|
4353
|
+
e.path && e.path.length > 0 && e.fieldMask.push(e.path), {
|
|
4348
4354
|
mapValue: {
|
|
4349
|
-
fields:
|
|
4355
|
+
fields: n
|
|
4350
4356
|
}
|
|
4351
4357
|
};
|
|
4352
4358
|
}
|
|
4353
4359
|
|
|
4354
|
-
function
|
|
4355
|
-
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof vt || t instanceof
|
|
4360
|
+
function Bn(t) {
|
|
4361
|
+
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof vt || t instanceof Tn || t instanceof bn || t instanceof ln || t instanceof En);
|
|
4356
4362
|
}
|
|
4357
4363
|
|
|
4358
|
-
function
|
|
4359
|
-
if (!
|
|
4364
|
+
function zn(t, e, n) {
|
|
4365
|
+
if (!Bn(n) || !function(t) {
|
|
4360
4366
|
return "object" == typeof t && null !== t && (Object.getPrototypeOf(t) === Object.prototype || null === Object.getPrototypeOf(t));
|
|
4361
|
-
}(
|
|
4362
|
-
const r = ot(
|
|
4363
|
-
throw "an object" === r ?
|
|
4367
|
+
}(n)) {
|
|
4368
|
+
const r = ot(n);
|
|
4369
|
+
throw "an object" === r ? e.ut(t + " a custom object") : e.ut(t + " " + r);
|
|
4364
4370
|
}
|
|
4365
4371
|
}
|
|
4366
4372
|
|
|
4367
4373
|
/**
|
|
4368
4374
|
* Helper that calls fromDotSeparatedString() but wraps any error thrown.
|
|
4369
|
-
*/ function
|
|
4375
|
+
*/ function Gn(t, e, n) {
|
|
4370
4376
|
if ((
|
|
4371
4377
|
// If required, replace the FieldPath Compat class with with the firestore-exp
|
|
4372
4378
|
// FieldPath.
|
|
4373
|
-
|
|
4374
|
-
if ("string" == typeof
|
|
4375
|
-
throw
|
|
4379
|
+
e = l(e)) instanceof gn) return e._internalPath;
|
|
4380
|
+
if ("string" == typeof e) return Wn(t, e);
|
|
4381
|
+
throw Yn("Field path arguments must be of type string or ", t,
|
|
4376
4382
|
/* hasConverter= */ !1,
|
|
4377
|
-
/* path= */ void 0,
|
|
4383
|
+
/* path= */ void 0, n);
|
|
4378
4384
|
}
|
|
4379
4385
|
|
|
4380
4386
|
/**
|
|
4381
4387
|
* Matches any characters in a field path string that are reserved.
|
|
4382
|
-
*/ const
|
|
4388
|
+
*/ const Qn = new RegExp("[~\\*/\\[\\]]");
|
|
4383
4389
|
|
|
4384
4390
|
/**
|
|
4385
4391
|
* Wraps fromDotSeparatedString with an error message about the method that
|
|
@@ -4389,30 +4395,30 @@ function ze(t, n, e) {
|
|
|
4389
4395
|
* split on dots.
|
|
4390
4396
|
* @param targetDoc - The document against which the field path will be
|
|
4391
4397
|
* evaluated.
|
|
4392
|
-
*/ function
|
|
4393
|
-
if (
|
|
4398
|
+
*/ function Wn(t, e, n) {
|
|
4399
|
+
if (e.search(Qn) >= 0) throw Yn(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`, t,
|
|
4394
4400
|
/* hasConverter= */ !1,
|
|
4395
|
-
/* path= */ void 0,
|
|
4401
|
+
/* path= */ void 0, n);
|
|
4396
4402
|
try {
|
|
4397
|
-
return new
|
|
4403
|
+
return new gn(...e.split("."))._internalPath;
|
|
4398
4404
|
} catch (r) {
|
|
4399
|
-
throw
|
|
4405
|
+
throw Yn(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`, t,
|
|
4400
4406
|
/* hasConverter= */ !1,
|
|
4401
|
-
/* path= */ void 0,
|
|
4407
|
+
/* path= */ void 0, n);
|
|
4402
4408
|
}
|
|
4403
4409
|
}
|
|
4404
4410
|
|
|
4405
|
-
function
|
|
4411
|
+
function Yn(t, e, n, r, s) {
|
|
4406
4412
|
const i = r && !r.isEmpty(), o = void 0 !== s;
|
|
4407
|
-
let u = `Function ${
|
|
4408
|
-
|
|
4413
|
+
let u = `Function ${e}() called with invalid data`;
|
|
4414
|
+
n && (u += " (via `toFirestore()`)"), u += ". ";
|
|
4409
4415
|
let c = "";
|
|
4410
4416
|
return (i || o) && (c += " (found", i && (c += ` in field ${r}`), o && (c += ` in document ${s}`),
|
|
4411
4417
|
c += ")"), new U(R, u + t + c);
|
|
4412
4418
|
}
|
|
4413
4419
|
|
|
4414
|
-
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function
|
|
4415
|
-
return t.some((t => t.isEqual(
|
|
4420
|
+
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function Hn(t, e) {
|
|
4421
|
+
return t.some((t => t.isEqual(e)));
|
|
4416
4422
|
}
|
|
4417
4423
|
|
|
4418
4424
|
/**
|
|
@@ -4439,14 +4445,14 @@ function Ye(t, n, e, r, s) {
|
|
|
4439
4445
|
* For a `DocumentSnapshot` that points to a non-existing document, any data
|
|
4440
4446
|
* access will return 'undefined'. You can use the `exists()` method to
|
|
4441
4447
|
* explicitly verify a document's existence.
|
|
4442
|
-
*/ class
|
|
4448
|
+
*/ class Kn {
|
|
4443
4449
|
// Note: This class is stripped down version of the DocumentSnapshot in
|
|
4444
4450
|
// the legacy SDK. The changes are:
|
|
4445
4451
|
// - No support for SnapshotMetadata.
|
|
4446
4452
|
// - No support for SnapshotOptions.
|
|
4447
4453
|
/** @hideconstructor protected */
|
|
4448
|
-
constructor(t,
|
|
4449
|
-
this._firestore = t, this._userDataWriter =
|
|
4454
|
+
constructor(t, e, n, r, s) {
|
|
4455
|
+
this._firestore = t, this._userDataWriter = e, this._key = n, this._document = r,
|
|
4450
4456
|
this._converter = s;
|
|
4451
4457
|
}
|
|
4452
4458
|
/** Property of the `DocumentSnapshot` that provides the document's ID. */ get id() {
|
|
@@ -4455,7 +4461,7 @@ function Ye(t, n, e, r, s) {
|
|
|
4455
4461
|
/**
|
|
4456
4462
|
* The `DocumentReference` for the document included in the `DocumentSnapshot`.
|
|
4457
4463
|
*/ get ref() {
|
|
4458
|
-
return new
|
|
4464
|
+
return new ln(this._firestore, this._converter, this._key);
|
|
4459
4465
|
}
|
|
4460
4466
|
/**
|
|
4461
4467
|
* Signals whether or not the document at the snapshot's location exists.
|
|
@@ -4475,7 +4481,7 @@ function Ye(t, n, e, r, s) {
|
|
|
4475
4481
|
if (this._converter) {
|
|
4476
4482
|
// We only want to use the converter and create a new DocumentSnapshot
|
|
4477
4483
|
// if a converter has been provided.
|
|
4478
|
-
const t = new
|
|
4484
|
+
const t = new Jn(this._firestore, this._userDataWriter, this._key, this._document,
|
|
4479
4485
|
/* converter= */ null);
|
|
4480
4486
|
return this._converter.fromFirestore(t);
|
|
4481
4487
|
}
|
|
@@ -4495,8 +4501,8 @@ function Ye(t, n, e, r, s) {
|
|
|
4495
4501
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4496
4502
|
get(t) {
|
|
4497
4503
|
if (this._document) {
|
|
4498
|
-
const
|
|
4499
|
-
if (null !==
|
|
4504
|
+
const e = this._document.data.field(tr("DocumentSnapshot.get", t));
|
|
4505
|
+
if (null !== e) return this._userDataWriter.convertValue(e);
|
|
4500
4506
|
}
|
|
4501
4507
|
}
|
|
4502
4508
|
}
|
|
@@ -4511,7 +4517,7 @@ function Ye(t, n, e, r, s) {
|
|
|
4511
4517
|
* `DocumentSnapshot`. Since query results contain only existing documents, the
|
|
4512
4518
|
* `exists` property will always be true and `data()` will never return
|
|
4513
4519
|
* 'undefined'.
|
|
4514
|
-
*/ class
|
|
4520
|
+
*/ class Jn extends Kn {
|
|
4515
4521
|
/**
|
|
4516
4522
|
* Retrieves all fields in the document as an `Object`.
|
|
4517
4523
|
*
|
|
@@ -4529,10 +4535,10 @@ function Ye(t, n, e, r, s) {
|
|
|
4529
4535
|
* array via the `docs` property or enumerated using the `forEach` method. The
|
|
4530
4536
|
* number of documents can be determined via the `empty` and `size`
|
|
4531
4537
|
* properties.
|
|
4532
|
-
*/ class
|
|
4538
|
+
*/ class Xn {
|
|
4533
4539
|
/** @hideconstructor */
|
|
4534
|
-
constructor(t,
|
|
4535
|
-
this._docs =
|
|
4540
|
+
constructor(t, e) {
|
|
4541
|
+
this._docs = e, this.query = t;
|
|
4536
4542
|
}
|
|
4537
4543
|
/** An array of all the documents in the `QuerySnapshot`. */ get docs() {
|
|
4538
4544
|
return [ ...this._docs ];
|
|
@@ -4549,8 +4555,8 @@ function Ye(t, n, e, r, s) {
|
|
|
4549
4555
|
* @param callback - A callback to be called with a `QueryDocumentSnapshot` for
|
|
4550
4556
|
* each document in the snapshot.
|
|
4551
4557
|
* @param thisArg - The `this` binding for the callback.
|
|
4552
|
-
*/ forEach(t,
|
|
4553
|
-
this._docs.forEach(t,
|
|
4558
|
+
*/ forEach(t, e) {
|
|
4559
|
+
this._docs.forEach(t, e);
|
|
4554
4560
|
}
|
|
4555
4561
|
}
|
|
4556
4562
|
|
|
@@ -4560,14 +4566,14 @@ function Ye(t, n, e, r, s) {
|
|
|
4560
4566
|
* @param left - A snapshot to compare.
|
|
4561
4567
|
* @param right - A snapshot to compare.
|
|
4562
4568
|
* @returns true if the snapshots are equal.
|
|
4563
|
-
*/ function
|
|
4564
|
-
return t = l(t),
|
|
4569
|
+
*/ function Zn(t, e) {
|
|
4570
|
+
return t = l(t), e = l(e), t instanceof Kn && e instanceof Kn ? t._firestore === e._firestore && t._key.isEqual(e._key) && (null === t._document ? null === e._document : t._document.isEqual(e._document)) && t._converter === e._converter : t instanceof Xn && e instanceof Xn && (_n(t.query, e.query) && gt(t.docs, e.docs, Zn));
|
|
4565
4571
|
}
|
|
4566
4572
|
|
|
4567
4573
|
/**
|
|
4568
4574
|
* Helper that calls `fromDotSeparatedString()` but wraps any error thrown.
|
|
4569
|
-
*/ function tr(t,
|
|
4570
|
-
return "string" == typeof
|
|
4575
|
+
*/ function tr(t, e) {
|
|
4576
|
+
return "string" == typeof e ? Wn(t, e) : e instanceof gn ? e._internalPath : e._delegate._internalPath;
|
|
4571
4577
|
}
|
|
4572
4578
|
|
|
4573
4579
|
/**
|
|
@@ -4594,7 +4600,7 @@ function Ye(t, n, e, r, s) {
|
|
|
4594
4600
|
* can then be passed to {@link query} to create a new query instance that
|
|
4595
4601
|
* also contains this `QueryConstraint`.
|
|
4596
4602
|
*/
|
|
4597
|
-
class
|
|
4603
|
+
class er {}
|
|
4598
4604
|
|
|
4599
4605
|
/**
|
|
4600
4606
|
* Creates a new immutable instance of {@link Query} that is extended to also include
|
|
@@ -4604,43 +4610,43 @@ class nr {}
|
|
|
4604
4610
|
* @param queryConstraints - The list of {@link QueryConstraint}s to apply.
|
|
4605
4611
|
* @throws if any of the provided query constraints cannot be combined with the
|
|
4606
4612
|
* existing or new constraints.
|
|
4607
|
-
*/ function
|
|
4608
|
-
for (const
|
|
4613
|
+
*/ function nr(t, ...e) {
|
|
4614
|
+
for (const n of e) t = n._apply(t);
|
|
4609
4615
|
return t;
|
|
4610
4616
|
}
|
|
4611
4617
|
|
|
4612
|
-
class rr extends
|
|
4613
|
-
constructor(t,
|
|
4614
|
-
super(), this.dt = t, this.wt =
|
|
4618
|
+
class rr extends er {
|
|
4619
|
+
constructor(t, e, n) {
|
|
4620
|
+
super(), this.dt = t, this.wt = e, this.yt = n, this.type = "where";
|
|
4615
4621
|
}
|
|
4616
4622
|
_apply(t) {
|
|
4617
|
-
const
|
|
4623
|
+
const e = Dn(t.firestore), n = function(t, e, n, r, s, i, o) {
|
|
4618
4624
|
let u;
|
|
4619
4625
|
if (s.isKeyField()) {
|
|
4620
4626
|
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new U(R, `Invalid Query. You can't perform '${i}' queries on documentId().`);
|
|
4621
4627
|
if ("in" /* IN */ === i || "not-in" /* NOT_IN */ === i) {
|
|
4622
4628
|
_r(o, i);
|
|
4623
|
-
const
|
|
4624
|
-
for (const
|
|
4629
|
+
const e = [];
|
|
4630
|
+
for (const n of o) e.push(yr(r, t, n));
|
|
4625
4631
|
u = {
|
|
4626
4632
|
arrayValue: {
|
|
4627
|
-
values:
|
|
4633
|
+
values: e
|
|
4628
4634
|
}
|
|
4629
4635
|
};
|
|
4630
4636
|
} else u = yr(r, t, o);
|
|
4631
4637
|
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i || _r(o, i),
|
|
4632
|
-
u =
|
|
4638
|
+
u = Un(n, e, o,
|
|
4633
4639
|
/* allowArrays= */ "in" /* IN */ === i || "not-in" /* NOT_IN */ === i);
|
|
4634
|
-
const c =
|
|
4635
|
-
return function(t,
|
|
4636
|
-
if (
|
|
4637
|
-
const
|
|
4638
|
-
if (null !==
|
|
4639
|
-
const r =
|
|
4640
|
-
null !== r && gr(t,
|
|
4640
|
+
const c = Kt.create(s, i, u);
|
|
4641
|
+
return function(t, e) {
|
|
4642
|
+
if (e.D()) {
|
|
4643
|
+
const n = le(t);
|
|
4644
|
+
if (null !== n && !n.isEqual(e.field)) throw new U(R, `Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '${n.toString()}' and '${e.field.toString()}'`);
|
|
4645
|
+
const r = he(t);
|
|
4646
|
+
null !== r && gr(t, e.field, r);
|
|
4641
4647
|
}
|
|
4642
|
-
const
|
|
4643
|
-
for (const
|
|
4648
|
+
const n = function(t, e) {
|
|
4649
|
+
for (const n of t.filters) if (e.indexOf(n.op) >= 0) return n.op;
|
|
4644
4650
|
return null;
|
|
4645
4651
|
}(t,
|
|
4646
4652
|
/**
|
|
@@ -4675,16 +4681,16 @@ class rr extends nr {
|
|
|
4675
4681
|
default:
|
|
4676
4682
|
return [];
|
|
4677
4683
|
}
|
|
4678
|
-
}(
|
|
4679
|
-
if (null !==
|
|
4684
|
+
}(e.op));
|
|
4685
|
+
if (null !== n)
|
|
4680
4686
|
// Special case when it's a duplicate op to give a slightly clearer error message.
|
|
4681
|
-
throw
|
|
4687
|
+
throw n === e.op ? new U(R, `Invalid query. You cannot use more than one '${e.op.toString()}' filter.`) : new U(R, `Invalid query. You cannot use '${e.op.toString()}' filters with '${n.toString()}' filters.`);
|
|
4682
4688
|
}(t, c), c;
|
|
4683
|
-
}(t._query, "where",
|
|
4684
|
-
return new
|
|
4685
|
-
const
|
|
4686
|
-
return new
|
|
4687
|
-
}(t._query,
|
|
4689
|
+
}(t._query, "where", e, t.firestore._databaseId, this.dt, this.wt, this.yt);
|
|
4690
|
+
return new fn(t.firestore, t.converter, function(t, e) {
|
|
4691
|
+
const n = t.filters.concat([ e ]);
|
|
4692
|
+
return new ae(t.path, t.collectionGroup, t.explicitOrderBy.slice(), n, t.limit, t.limitType, t.startAt, t.endAt);
|
|
4693
|
+
}(t._query, n));
|
|
4688
4694
|
}
|
|
4689
4695
|
}
|
|
4690
4696
|
|
|
@@ -4698,25 +4704,25 @@ class rr extends nr {
|
|
|
4698
4704
|
* "<=", "!=").
|
|
4699
4705
|
* @param value - The value for comparison
|
|
4700
4706
|
* @returns The created {@link Query}.
|
|
4701
|
-
*/ function sr(t,
|
|
4702
|
-
const r =
|
|
4703
|
-
return new rr(s, r,
|
|
4707
|
+
*/ function sr(t, e, n) {
|
|
4708
|
+
const r = e, s = tr("where", t);
|
|
4709
|
+
return new rr(s, r, n);
|
|
4704
4710
|
}
|
|
4705
4711
|
|
|
4706
|
-
class ir extends
|
|
4707
|
-
constructor(t,
|
|
4708
|
-
super(), this.dt = t, this._t =
|
|
4712
|
+
class ir extends er {
|
|
4713
|
+
constructor(t, e) {
|
|
4714
|
+
super(), this.dt = t, this._t = e, this.type = "orderBy";
|
|
4709
4715
|
}
|
|
4710
4716
|
_apply(t) {
|
|
4711
|
-
const
|
|
4717
|
+
const e = function(t, e, n) {
|
|
4712
4718
|
if (null !== t.startAt) throw new U(R, "Invalid query. You must not call startAt() or startAfter() before calling orderBy().");
|
|
4713
4719
|
if (null !== t.endAt) throw new U(R, "Invalid query. You must not call endAt() or endBefore() before calling orderBy().");
|
|
4714
|
-
const r = new
|
|
4715
|
-
return function(t,
|
|
4716
|
-
if (null ===
|
|
4720
|
+
const r = new oe(e, n);
|
|
4721
|
+
return function(t, e) {
|
|
4722
|
+
if (null === he(t)) {
|
|
4717
4723
|
// This is the first order by. It must match any inequality.
|
|
4718
|
-
const
|
|
4719
|
-
null !==
|
|
4724
|
+
const n = le(t);
|
|
4725
|
+
null !== n && gr(t, n, e.field);
|
|
4720
4726
|
}
|
|
4721
4727
|
}(t, r), r;
|
|
4722
4728
|
}
|
|
@@ -4731,11 +4737,11 @@ class ir extends nr {
|
|
|
4731
4737
|
* of the query or if any of the fields in the order by are an uncommitted
|
|
4732
4738
|
* server timestamp.
|
|
4733
4739
|
*/ (t._query, this.dt, this._t);
|
|
4734
|
-
return new
|
|
4740
|
+
return new fn(t.firestore, t.converter, function(t, e) {
|
|
4735
4741
|
// TODO(dimond): validate that orderBy does not list the same key twice.
|
|
4736
|
-
const
|
|
4737
|
-
return new
|
|
4738
|
-
}(t._query,
|
|
4742
|
+
const n = t.explicitOrderBy.concat([ e ]);
|
|
4743
|
+
return new ae(t.path, t.collectionGroup, n, t.filters.slice(), t.limit, t.limitType, t.startAt, t.endAt);
|
|
4744
|
+
}(t._query, e));
|
|
4739
4745
|
}
|
|
4740
4746
|
}
|
|
4741
4747
|
|
|
@@ -4747,18 +4753,18 @@ class ir extends nr {
|
|
|
4747
4753
|
* @param directionStr - Optional direction to sort by ('asc' or 'desc'). If
|
|
4748
4754
|
* not specified, order will be ascending.
|
|
4749
4755
|
* @returns The created {@link Query}.
|
|
4750
|
-
*/ function or(t,
|
|
4751
|
-
const
|
|
4752
|
-
return new ir(r,
|
|
4756
|
+
*/ function or(t, e = "asc") {
|
|
4757
|
+
const n = e, r = tr("orderBy", t);
|
|
4758
|
+
return new ir(r, n);
|
|
4753
4759
|
}
|
|
4754
4760
|
|
|
4755
|
-
class ur extends
|
|
4756
|
-
constructor(t,
|
|
4757
|
-
super(), this.type = t, this.gt =
|
|
4761
|
+
class ur extends er {
|
|
4762
|
+
constructor(t, e, n) {
|
|
4763
|
+
super(), this.type = t, this.gt = e, this.vt = n;
|
|
4758
4764
|
}
|
|
4759
4765
|
_apply(t) {
|
|
4760
|
-
return new
|
|
4761
|
-
return new
|
|
4766
|
+
return new fn(t.firestore, t.converter, function(t, e, n) {
|
|
4767
|
+
return new ae(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), e, n, t.startAt, t.endAt);
|
|
4762
4768
|
}(t._query, this.gt, this.vt));
|
|
4763
4769
|
}
|
|
4764
4770
|
}
|
|
@@ -4784,15 +4790,15 @@ class ur extends nr {
|
|
|
4784
4790
|
return ct("limitToLast", t), new ur("limitToLast", t, "L" /* Last */);
|
|
4785
4791
|
}
|
|
4786
4792
|
|
|
4787
|
-
class hr extends
|
|
4788
|
-
constructor(t,
|
|
4789
|
-
super(), this.type = t, this.bt =
|
|
4793
|
+
class hr extends er {
|
|
4794
|
+
constructor(t, e, n) {
|
|
4795
|
+
super(), this.type = t, this.bt = e, this.Et = n;
|
|
4790
4796
|
}
|
|
4791
4797
|
_apply(t) {
|
|
4792
|
-
const
|
|
4793
|
-
return new
|
|
4794
|
-
return new
|
|
4795
|
-
}(t._query,
|
|
4798
|
+
const e = pr(t, this.type, this.bt, this.Et);
|
|
4799
|
+
return new fn(t.firestore, t.converter, function(t, e) {
|
|
4800
|
+
return new ae(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, e, t.endAt);
|
|
4801
|
+
}(t._query, e));
|
|
4796
4802
|
}
|
|
4797
4803
|
}
|
|
4798
4804
|
|
|
@@ -4806,15 +4812,15 @@ function fr(...t) {
|
|
|
4806
4812
|
/*inclusive=*/ !1);
|
|
4807
4813
|
}
|
|
4808
4814
|
|
|
4809
|
-
class dr extends
|
|
4810
|
-
constructor(t,
|
|
4811
|
-
super(), this.type = t, this.bt =
|
|
4815
|
+
class dr extends er {
|
|
4816
|
+
constructor(t, e, n) {
|
|
4817
|
+
super(), this.type = t, this.bt = e, this.Et = n;
|
|
4812
4818
|
}
|
|
4813
4819
|
_apply(t) {
|
|
4814
|
-
const
|
|
4815
|
-
return new
|
|
4816
|
-
return new
|
|
4817
|
-
}(t._query,
|
|
4820
|
+
const e = pr(t, this.type, this.bt, this.Et);
|
|
4821
|
+
return new fn(t.firestore, t.converter, function(t, e) {
|
|
4822
|
+
return new ae(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, t.startAt, e);
|
|
4823
|
+
}(t._query, e));
|
|
4818
4824
|
}
|
|
4819
4825
|
}
|
|
4820
4826
|
|
|
@@ -4827,9 +4833,9 @@ function mr(...t) {
|
|
|
4827
4833
|
return new dr("endAt", t, /*inclusive=*/ !0);
|
|
4828
4834
|
}
|
|
4829
4835
|
|
|
4830
|
-
/** Helper function to create a bound from a document or fields */ function pr(t,
|
|
4831
|
-
if (
|
|
4832
|
-
if (!r) throw new U(V, `Can't use a DocumentSnapshot that doesn't exist for ${
|
|
4836
|
+
/** Helper function to create a bound from a document or fields */ function pr(t, e, n, r) {
|
|
4837
|
+
if (n[0] = l(n[0]), n[0] instanceof Kn) return function(t, e, n, r, s) {
|
|
4838
|
+
if (!r) throw new U(V, `Can't use a DocumentSnapshot that doesn't exist for ${n}().`);
|
|
4833
4839
|
const i = [];
|
|
4834
4840
|
// Because people expect to continue/end a query at the exact document
|
|
4835
4841
|
// provided, we need to use the implicit sort order rather than the explicit
|
|
@@ -4838,23 +4844,23 @@ function mr(...t) {
|
|
|
4838
4844
|
// the provided document. Without the key (by using the explicit sort
|
|
4839
4845
|
// orders), multiple documents could match the position, yielding duplicate
|
|
4840
4846
|
// results.
|
|
4841
|
-
for (const
|
|
4842
|
-
const t = r.data.field(
|
|
4843
|
-
if ($t(t)) throw new U(R, 'Invalid query. You are trying to start or end a query using a document for which the field "' +
|
|
4847
|
+
for (const n of de(t)) if (n.field.isKeyField()) i.push(Ut(e, r.key)); else {
|
|
4848
|
+
const t = r.data.field(n.field);
|
|
4849
|
+
if ($t(t)) throw new U(R, 'Invalid query. You are trying to start or end a query using a document for which the field "' + n.field + '" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');
|
|
4844
4850
|
if (null === t) {
|
|
4845
|
-
const t =
|
|
4851
|
+
const t = n.field.canonicalString();
|
|
4846
4852
|
throw new U(R, `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.`);
|
|
4847
4853
|
}
|
|
4848
4854
|
i.push(t);
|
|
4849
4855
|
}
|
|
4850
|
-
return new
|
|
4856
|
+
return new ie(i, s);
|
|
4851
4857
|
}
|
|
4852
4858
|
/**
|
|
4853
4859
|
* Converts a list of field values to a `Bound` for the given query.
|
|
4854
|
-
*/ (t._query, t.firestore._databaseId,
|
|
4860
|
+
*/ (t._query, t.firestore._databaseId, e, n[0]._document, r);
|
|
4855
4861
|
{
|
|
4856
|
-
const s =
|
|
4857
|
-
return function(t,
|
|
4862
|
+
const s = Dn(t.firestore);
|
|
4863
|
+
return function(t, e, n, r, s, i) {
|
|
4858
4864
|
// Use explicit order by's because it has to match the query the user made
|
|
4859
4865
|
const o = t.explicitOrderBy;
|
|
4860
4866
|
if (s.length > o.length) throw new U(R, `Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);
|
|
@@ -4863,48 +4869,48 @@ function mr(...t) {
|
|
|
4863
4869
|
const c = s[i];
|
|
4864
4870
|
if (o[i].field.isKeyField()) {
|
|
4865
4871
|
if ("string" != typeof c) throw new U(R, `Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);
|
|
4866
|
-
if (!
|
|
4867
|
-
const
|
|
4868
|
-
if (!
|
|
4869
|
-
const s = new
|
|
4870
|
-
u.push(
|
|
4872
|
+
if (!fe(t) && -1 !== c.indexOf("/")) throw new U(R, `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.`);
|
|
4873
|
+
const n = t.path.child(Z.fromString(c));
|
|
4874
|
+
if (!nt.isDocumentKey(n)) throw new U(R, `Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${r}() must result in a valid document path, but '${n}' is not because it contains an odd number of segments.`);
|
|
4875
|
+
const s = new nt(n);
|
|
4876
|
+
u.push(Ut(e, s));
|
|
4871
4877
|
} else {
|
|
4872
|
-
const t =
|
|
4878
|
+
const t = Un(n, r, c);
|
|
4873
4879
|
u.push(t);
|
|
4874
4880
|
}
|
|
4875
4881
|
}
|
|
4876
|
-
return new
|
|
4882
|
+
return new ie(u, i);
|
|
4877
4883
|
}
|
|
4878
4884
|
/**
|
|
4879
4885
|
* Parses the given `documentIdValue` into a `ReferenceValue`, throwing
|
|
4880
4886
|
* appropriate errors if the value is anything other than a `DocumentReference`
|
|
4881
4887
|
* or `string`, or if the string is malformed.
|
|
4882
|
-
*/ (t._query, t.firestore._databaseId, s,
|
|
4888
|
+
*/ (t._query, t.firestore._databaseId, s, e, n, r);
|
|
4883
4889
|
}
|
|
4884
4890
|
}
|
|
4885
4891
|
|
|
4886
|
-
function yr(t,
|
|
4887
|
-
if ("string" == typeof (
|
|
4888
|
-
if ("" ===
|
|
4889
|
-
if (!
|
|
4890
|
-
const r =
|
|
4891
|
-
if (!
|
|
4892
|
-
return
|
|
4892
|
+
function yr(t, e, n) {
|
|
4893
|
+
if ("string" == typeof (n = l(n))) {
|
|
4894
|
+
if ("" === n) throw new U(R, "Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");
|
|
4895
|
+
if (!fe(e) && -1 !== n.indexOf("/")) throw new U(R, `Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);
|
|
4896
|
+
const r = e.path.child(Z.fromString(n));
|
|
4897
|
+
if (!nt.isDocumentKey(r)) throw new U(R, `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}).`);
|
|
4898
|
+
return Ut(t, new nt(r));
|
|
4893
4899
|
}
|
|
4894
|
-
if (
|
|
4895
|
-
throw new U(R, `Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${ot(
|
|
4900
|
+
if (n instanceof ln) return Ut(t, n._key);
|
|
4901
|
+
throw new U(R, `Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${ot(n)}.`);
|
|
4896
4902
|
}
|
|
4897
4903
|
|
|
4898
4904
|
/**
|
|
4899
4905
|
* Validates that the value passed into a disjunctive filter satisfies all
|
|
4900
4906
|
* array requirements.
|
|
4901
|
-
*/ function _r(t,
|
|
4902
|
-
if (!Array.isArray(t) || 0 === t.length) throw new U(R, `Invalid Query. A non-empty array is required for '${
|
|
4903
|
-
if (t.length > 10) throw new U(R, `Invalid Query. '${
|
|
4907
|
+
*/ function _r(t, e) {
|
|
4908
|
+
if (!Array.isArray(t) || 0 === t.length) throw new U(R, `Invalid Query. A non-empty array is required for '${e.toString()}' filters.`);
|
|
4909
|
+
if (t.length > 10) throw new U(R, `Invalid Query. '${e.toString()}' filters support a maximum of 10 elements in the value array.`);
|
|
4904
4910
|
}
|
|
4905
4911
|
|
|
4906
|
-
function gr(t,
|
|
4907
|
-
if (!
|
|
4912
|
+
function gr(t, e, n) {
|
|
4913
|
+
if (!n.isEqual(e)) throw new U(R, `Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '${e.toString()}' and so you must also use '${e.toString()}' as your first argument to orderBy(), but your first orderBy() is on field '${n.toString()}' instead.`);
|
|
4908
4914
|
}
|
|
4909
4915
|
|
|
4910
4916
|
/**
|
|
@@ -4954,18 +4960,18 @@ function gr(t, n, e) {
|
|
|
4954
4960
|
* their `set()` or fails due to invalid data originating from a `toFirestore()`
|
|
4955
4961
|
* call.
|
|
4956
4962
|
*/
|
|
4957
|
-
function vr(t,
|
|
4963
|
+
function vr(t, e, n) {
|
|
4958
4964
|
let r;
|
|
4959
4965
|
// Cast to `any` in order to satisfy the union type constraint on
|
|
4960
4966
|
// toFirestore().
|
|
4961
4967
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4962
|
-
return r = t ?
|
|
4968
|
+
return r = t ? n && (n.merge || n.mergeFields) ? t.toFirestore(e, n) : t.toFirestore(e) : e,
|
|
4963
4969
|
r;
|
|
4964
4970
|
}
|
|
4965
4971
|
|
|
4966
4972
|
class br extends class {
|
|
4967
|
-
convertValue(t,
|
|
4968
|
-
switch (
|
|
4973
|
+
convertValue(t, e = "none") {
|
|
4974
|
+
switch (qt(t)) {
|
|
4969
4975
|
case 0 /* NullValue */ :
|
|
4970
4976
|
return null;
|
|
4971
4977
|
|
|
@@ -4979,7 +4985,7 @@ class br extends class {
|
|
|
4979
4985
|
return this.convertTimestamp(t.timestampValue);
|
|
4980
4986
|
|
|
4981
4987
|
case 4 /* ServerTimestampValue */ :
|
|
4982
|
-
return this.convertServerTimestamp(t,
|
|
4988
|
+
return this.convertServerTimestamp(t, e);
|
|
4983
4989
|
|
|
4984
4990
|
case 5 /* StringValue */ :
|
|
4985
4991
|
return t.stringValue;
|
|
@@ -4994,51 +5000,51 @@ class br extends class {
|
|
|
4994
5000
|
return this.convertGeoPoint(t.geoPointValue);
|
|
4995
5001
|
|
|
4996
5002
|
case 9 /* ArrayValue */ :
|
|
4997
|
-
return this.convertArray(t.arrayValue,
|
|
5003
|
+
return this.convertArray(t.arrayValue, e);
|
|
4998
5004
|
|
|
4999
5005
|
case 10 /* ObjectValue */ :
|
|
5000
|
-
return this.convertObject(t.mapValue,
|
|
5006
|
+
return this.convertObject(t.mapValue, e);
|
|
5001
5007
|
|
|
5002
5008
|
default:
|
|
5003
5009
|
throw v();
|
|
5004
5010
|
}
|
|
5005
5011
|
}
|
|
5006
|
-
convertObject(t,
|
|
5007
|
-
const
|
|
5012
|
+
convertObject(t, e) {
|
|
5013
|
+
const n = {};
|
|
5008
5014
|
return Tt(t.fields, ((t, r) => {
|
|
5009
|
-
|
|
5010
|
-
})),
|
|
5015
|
+
n[t] = this.convertValue(r, e);
|
|
5016
|
+
})), n;
|
|
5011
5017
|
}
|
|
5012
5018
|
convertGeoPoint(t) {
|
|
5013
|
-
return new
|
|
5019
|
+
return new Tn(Nt(t.latitude), Nt(t.longitude));
|
|
5014
5020
|
}
|
|
5015
|
-
convertArray(t,
|
|
5016
|
-
return (t.values || []).map((t => this.convertValue(t,
|
|
5021
|
+
convertArray(t, e) {
|
|
5022
|
+
return (t.values || []).map((t => this.convertValue(t, e)));
|
|
5017
5023
|
}
|
|
5018
|
-
convertServerTimestamp(t,
|
|
5019
|
-
switch (
|
|
5024
|
+
convertServerTimestamp(t, e) {
|
|
5025
|
+
switch (e) {
|
|
5020
5026
|
case "previous":
|
|
5021
|
-
const
|
|
5022
|
-
return null ==
|
|
5027
|
+
const n = St(t);
|
|
5028
|
+
return null == n ? null : this.convertValue(n, e);
|
|
5023
5029
|
|
|
5024
5030
|
case "estimate":
|
|
5025
|
-
return this.convertTimestamp(
|
|
5031
|
+
return this.convertTimestamp(xt(t));
|
|
5026
5032
|
|
|
5027
5033
|
default:
|
|
5028
5034
|
return null;
|
|
5029
5035
|
}
|
|
5030
5036
|
}
|
|
5031
5037
|
convertTimestamp(t) {
|
|
5032
|
-
const
|
|
5033
|
-
return new vt(
|
|
5038
|
+
const e = Vt(t);
|
|
5039
|
+
return new vt(e.seconds, e.nanos);
|
|
5034
5040
|
}
|
|
5035
|
-
convertDocumentKey(t,
|
|
5036
|
-
const
|
|
5037
|
-
b(
|
|
5038
|
-
const r = new J(
|
|
5039
|
-
return r.isEqual(
|
|
5041
|
+
convertDocumentKey(t, e) {
|
|
5042
|
+
const n = Z.fromString(t);
|
|
5043
|
+
b(He(n));
|
|
5044
|
+
const r = new J(n.get(1), n.get(3)), s = new nt(n.popFirst(5));
|
|
5045
|
+
return r.isEqual(e) ||
|
|
5040
5046
|
// TODO(b/64130202): Somehow support foreign references.
|
|
5041
|
-
y(`Document ${s} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${
|
|
5047
|
+
y(`Document ${s} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${e.projectId}/${e.database}) instead.`),
|
|
5042
5048
|
s;
|
|
5043
5049
|
}
|
|
5044
5050
|
} {
|
|
@@ -5046,11 +5052,11 @@ class br extends class {
|
|
|
5046
5052
|
super(), this.firestore = t;
|
|
5047
5053
|
}
|
|
5048
5054
|
convertBytes(t) {
|
|
5049
|
-
return new
|
|
5055
|
+
return new bn(t);
|
|
5050
5056
|
}
|
|
5051
5057
|
convertReference(t) {
|
|
5052
|
-
const
|
|
5053
|
-
return new
|
|
5058
|
+
const e = this.convertDocumentKey(t, this.firestore._databaseId);
|
|
5059
|
+
return new ln(this.firestore, /* converter= */ null, e);
|
|
5054
5060
|
}
|
|
5055
5061
|
}
|
|
5056
5062
|
|
|
@@ -5067,11 +5073,11 @@ class br extends class {
|
|
|
5067
5073
|
* @returns A Promise resolved with a `DocumentSnapshot` containing the current
|
|
5068
5074
|
* document contents.
|
|
5069
5075
|
*/ function Er(t) {
|
|
5070
|
-
const
|
|
5071
|
-
return
|
|
5072
|
-
b(1 ===
|
|
5073
|
-
const r =
|
|
5074
|
-
return new
|
|
5076
|
+
const e = rn((t = ut(t, ln)).firestore), n = new br(t.firestore);
|
|
5077
|
+
return tn(e, [ t._key ]).then((e => {
|
|
5078
|
+
b(1 === e.length);
|
|
5079
|
+
const r = e[0];
|
|
5080
|
+
return new Kn(t.firestore, n, t._key, r.isFoundDocument() ? r : null, t.converter);
|
|
5075
5081
|
}));
|
|
5076
5082
|
}
|
|
5077
5083
|
|
|
@@ -5088,31 +5094,31 @@ class br extends class {
|
|
|
5088
5094
|
* @returns A Promise that will be resolved with the results of the query.
|
|
5089
5095
|
*/ function Tr(t) {
|
|
5090
5096
|
!function(t) {
|
|
5091
|
-
if (
|
|
5092
|
-
}((t = ut(t,
|
|
5093
|
-
const
|
|
5094
|
-
return
|
|
5095
|
-
const r =
|
|
5096
|
-
return
|
|
5097
|
+
if ("L" /* Last */ === t.limitType && 0 === t.explicitOrderBy.length) throw new U(O, "limitToLast() queries require specifying at least one orderBy() clause");
|
|
5098
|
+
}((t = ut(t, fn))._query);
|
|
5099
|
+
const e = rn(t.firestore), n = new br(t.firestore);
|
|
5100
|
+
return en(e, t._query).then((e => {
|
|
5101
|
+
const r = e.map((e => new Jn(t.firestore, n, e.key, e, t.converter)));
|
|
5102
|
+
return "L" /* Last */ === t._query.limitType &&
|
|
5097
5103
|
// Limit to last queries reverse the orderBy constraint that was
|
|
5098
5104
|
// specified by the user. As such, we need to reverse the order of the
|
|
5099
5105
|
// results to return the documents in the expected order.
|
|
5100
|
-
r.reverse(), new
|
|
5106
|
+
r.reverse(), new Xn(t, r);
|
|
5101
5107
|
}));
|
|
5102
5108
|
}
|
|
5103
5109
|
|
|
5104
|
-
function
|
|
5105
|
-
const r = vr((t = ut(t,
|
|
5106
|
-
return
|
|
5110
|
+
function Ar(t, e, n) {
|
|
5111
|
+
const r = vr((t = ut(t, ln)).converter, e, n), s = $n(Dn(t.firestore), "setDoc", t._key, r, null !== t.converter, n);
|
|
5112
|
+
return Ze(rn(t.firestore), [ s.toMutation(t._key, Te.none()) ]);
|
|
5107
5113
|
}
|
|
5108
5114
|
|
|
5109
|
-
function
|
|
5110
|
-
const s =
|
|
5115
|
+
function Ir(t, e, n, ...r) {
|
|
5116
|
+
const s = Dn((t = ut(t, ln)).firestore);
|
|
5111
5117
|
// For Compat types, we have to "extract" the underlying types before
|
|
5112
5118
|
// performing validation.
|
|
5113
5119
|
let i;
|
|
5114
|
-
i = "string" == typeof (
|
|
5115
|
-
return
|
|
5120
|
+
i = "string" == typeof (e = l(e)) || e instanceof gn ? kn(s, "updateDoc", t._key, e, n, r) : Ln(s, "updateDoc", t._key, e);
|
|
5121
|
+
return Ze(rn(t.firestore), [ i.toMutation(t._key, Te.exists(!0)) ]);
|
|
5116
5122
|
}
|
|
5117
5123
|
|
|
5118
5124
|
/**
|
|
@@ -5127,7 +5133,7 @@ function Ar(t, n, e, ...r) {
|
|
|
5127
5133
|
* @returns A `Promise` resolved once the document has been successfully
|
|
5128
5134
|
* deleted from the backend.
|
|
5129
5135
|
*/ function Rr(t) {
|
|
5130
|
-
return
|
|
5136
|
+
return Ze(rn((t = ut(t, ln)).firestore), [ new Pe(t._key, Te.none()) ]);
|
|
5131
5137
|
}
|
|
5132
5138
|
|
|
5133
5139
|
/**
|
|
@@ -5144,9 +5150,9 @@ function Ar(t, n, e, ...r) {
|
|
|
5144
5150
|
* @throws Error - If the provided input is not a valid Firestore document.
|
|
5145
5151
|
* @returns A `Promise` resolved with a `DocumentReference` pointing to the
|
|
5146
5152
|
* newly created document after it has been written to the backend.
|
|
5147
|
-
*/ function Pr(t,
|
|
5148
|
-
const
|
|
5149
|
-
return
|
|
5153
|
+
*/ function Pr(t, e) {
|
|
5154
|
+
const n = pn(t = ut(t, dn)), r = vr(t.converter, e), s = $n(Dn(t.firestore), "addDoc", n._key, r, null !== n.converter, {});
|
|
5155
|
+
return Ze(rn(t.firestore), [ s.toMutation(n._key, Te.exists(!1)) ]).then((() => n));
|
|
5150
5156
|
}
|
|
5151
5157
|
|
|
5152
5158
|
/**
|
|
@@ -5169,14 +5175,14 @@ function Ar(t, n, e, ...r) {
|
|
|
5169
5175
|
* Returns a sentinel for use with {@link @firebase/firestore/lite#(updateDoc:1)} or
|
|
5170
5176
|
* {@link @firebase/firestore/lite#(setDoc:1)} with `{merge: true}` to mark a field for deletion.
|
|
5171
5177
|
*/ function Vr() {
|
|
5172
|
-
return new
|
|
5178
|
+
return new Sn("deleteField");
|
|
5173
5179
|
}
|
|
5174
5180
|
|
|
5175
5181
|
/**
|
|
5176
5182
|
* Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
|
|
5177
5183
|
* include a server-generated timestamp in the written data.
|
|
5178
5184
|
*/ function Nr() {
|
|
5179
|
-
return new
|
|
5185
|
+
return new Fn("serverTimestamp");
|
|
5180
5186
|
}
|
|
5181
5187
|
|
|
5182
5188
|
/**
|
|
@@ -5193,7 +5199,7 @@ function Ar(t, n, e, ...r) {
|
|
|
5193
5199
|
*/ function Dr(...t) {
|
|
5194
5200
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5195
5201
|
// update() since we'd need the Firestore instance to do this.
|
|
5196
|
-
return new
|
|
5202
|
+
return new qn("arrayUnion", t);
|
|
5197
5203
|
}
|
|
5198
5204
|
|
|
5199
5205
|
/**
|
|
@@ -5209,7 +5215,7 @@ function Ar(t, n, e, ...r) {
|
|
|
5209
5215
|
*/ function $r(...t) {
|
|
5210
5216
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5211
5217
|
// update() since we'd need the Firestore instance to do this.
|
|
5212
|
-
return new
|
|
5218
|
+
return new On("arrayRemove", t);
|
|
5213
5219
|
}
|
|
5214
5220
|
|
|
5215
5221
|
/**
|
|
@@ -5231,7 +5237,7 @@ function Ar(t, n, e, ...r) {
|
|
|
5231
5237
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5232
5238
|
* `updateDoc()`
|
|
5233
5239
|
*/ function Sr(t) {
|
|
5234
|
-
return new
|
|
5240
|
+
return new Cn("increment", t);
|
|
5235
5241
|
}
|
|
5236
5242
|
|
|
5237
5243
|
/**
|
|
@@ -5257,25 +5263,25 @@ function Ar(t, n, e, ...r) {
|
|
|
5257
5263
|
* provides methods for adding writes to the write batch. None of the writes
|
|
5258
5264
|
* will be committed (or visible locally) until {@link WriteBatch.commit} is
|
|
5259
5265
|
* called.
|
|
5260
|
-
*/ class
|
|
5266
|
+
*/ class xr {
|
|
5261
5267
|
/** @hideconstructor */
|
|
5262
|
-
constructor(t,
|
|
5263
|
-
this._firestore = t, this._commitHandler =
|
|
5264
|
-
this._dataReader =
|
|
5268
|
+
constructor(t, e) {
|
|
5269
|
+
this._firestore = t, this._commitHandler = e, this._mutations = [], this._committed = !1,
|
|
5270
|
+
this._dataReader = Dn(t);
|
|
5265
5271
|
}
|
|
5266
|
-
set(t,
|
|
5272
|
+
set(t, e, n) {
|
|
5267
5273
|
this._verifyNotCommitted();
|
|
5268
|
-
const r =
|
|
5269
|
-
return this._mutations.push(i.toMutation(r._key,
|
|
5274
|
+
const r = Fr(t, this._firestore), s = vr(r.converter, e, n), i = $n(this._dataReader, "WriteBatch.set", r._key, s, null !== r.converter, n);
|
|
5275
|
+
return this._mutations.push(i.toMutation(r._key, Te.none())), this;
|
|
5270
5276
|
}
|
|
5271
|
-
update(t,
|
|
5277
|
+
update(t, e, n, ...r) {
|
|
5272
5278
|
this._verifyNotCommitted();
|
|
5273
|
-
const s =
|
|
5279
|
+
const s = Fr(t, this._firestore);
|
|
5274
5280
|
// For Compat types, we have to "extract" the underlying types before
|
|
5275
5281
|
// performing validation.
|
|
5276
5282
|
let i;
|
|
5277
|
-
return i = "string" == typeof (
|
|
5278
|
-
this._mutations.push(i.toMutation(s._key,
|
|
5283
|
+
return i = "string" == typeof (e = l(e)) || e instanceof gn ? kn(this._dataReader, "WriteBatch.update", s._key, e, n, r) : Ln(this._dataReader, "WriteBatch.update", s._key, e),
|
|
5284
|
+
this._mutations.push(i.toMutation(s._key, Te.exists(!0))), this;
|
|
5279
5285
|
}
|
|
5280
5286
|
/**
|
|
5281
5287
|
* Deletes the document referred to by the provided {@link DocumentReference}.
|
|
@@ -5284,8 +5290,8 @@ function Ar(t, n, e, ...r) {
|
|
|
5284
5290
|
* @returns This `WriteBatch` instance. Used for chaining method calls.
|
|
5285
5291
|
*/ delete(t) {
|
|
5286
5292
|
this._verifyNotCommitted();
|
|
5287
|
-
const
|
|
5288
|
-
return this._mutations = this._mutations.concat(new
|
|
5293
|
+
const e = Fr(t, this._firestore);
|
|
5294
|
+
return this._mutations = this._mutations.concat(new Pe(e._key, Te.none())), this;
|
|
5289
5295
|
}
|
|
5290
5296
|
/**
|
|
5291
5297
|
* Commits all of the writes in this write batch as a single atomic unit.
|
|
@@ -5302,12 +5308,12 @@ function Ar(t, n, e, ...r) {
|
|
|
5302
5308
|
return this._verifyNotCommitted(), this._committed = !0, this._mutations.length > 0 ? this._commitHandler(this._mutations) : Promise.resolve();
|
|
5303
5309
|
}
|
|
5304
5310
|
_verifyNotCommitted() {
|
|
5305
|
-
if (this._committed) throw new U(
|
|
5311
|
+
if (this._committed) throw new U(x, "A write batch can no longer be used after commit() has been called.");
|
|
5306
5312
|
}
|
|
5307
5313
|
}
|
|
5308
5314
|
|
|
5309
|
-
function
|
|
5310
|
-
if ((t = l(t)).firestore !==
|
|
5315
|
+
function Fr(t, e) {
|
|
5316
|
+
if ((t = l(t)).firestore !== e) throw new U(R, "Provided document reference is from a different Firestore instance.");
|
|
5311
5317
|
return t;
|
|
5312
5318
|
}
|
|
5313
5319
|
|
|
@@ -5324,8 +5330,8 @@ function xr(t, n) {
|
|
|
5324
5330
|
* @returns A `WriteBatch` that can be used to atomically execute multiple
|
|
5325
5331
|
* writes.
|
|
5326
5332
|
*/ function qr(t) {
|
|
5327
|
-
const
|
|
5328
|
-
return new
|
|
5333
|
+
const e = rn(t = ut(t, on));
|
|
5334
|
+
return new xr(t, (t => Ze(e, t)));
|
|
5329
5335
|
}
|
|
5330
5336
|
|
|
5331
5337
|
/**
|
|
@@ -5367,66 +5373,66 @@ function xr(t, n) {
|
|
|
5367
5373
|
}
|
|
5368
5374
|
async lookup(t) {
|
|
5369
5375
|
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new U(R, "Firestore transactions require all reads to be executed before all writes.");
|
|
5370
|
-
const
|
|
5371
|
-
return
|
|
5376
|
+
const e = await tn(this.datastore, t);
|
|
5377
|
+
return e.forEach((t => this.recordVersion(t))), e;
|
|
5372
5378
|
}
|
|
5373
|
-
set(t,
|
|
5374
|
-
this.write(
|
|
5379
|
+
set(t, e) {
|
|
5380
|
+
this.write(e.toMutation(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5375
5381
|
}
|
|
5376
|
-
update(t,
|
|
5382
|
+
update(t, e) {
|
|
5377
5383
|
try {
|
|
5378
|
-
this.write(
|
|
5384
|
+
this.write(e.toMutation(t, this.preconditionForUpdate(t)));
|
|
5379
5385
|
} catch (t) {
|
|
5380
5386
|
this.lastWriteError = t;
|
|
5381
5387
|
}
|
|
5382
5388
|
this.writtenDocs.add(t.toString());
|
|
5383
5389
|
}
|
|
5384
5390
|
delete(t) {
|
|
5385
|
-
this.write(new
|
|
5391
|
+
this.write(new Pe(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5386
5392
|
}
|
|
5387
5393
|
async commit() {
|
|
5388
5394
|
if (this.ensureCommitNotCalled(), this.lastWriteError) throw this.lastWriteError;
|
|
5389
5395
|
const t = this.readVersions;
|
|
5390
5396
|
// For each mutation, note that the doc was written.
|
|
5391
|
-
this.mutations.forEach((
|
|
5392
|
-
t.delete(
|
|
5397
|
+
this.mutations.forEach((e => {
|
|
5398
|
+
t.delete(e.key.toString());
|
|
5393
5399
|
})),
|
|
5394
5400
|
// For each document that was read but not written to, we want to perform
|
|
5395
5401
|
// a `verify` operation.
|
|
5396
|
-
t.forEach(((t,
|
|
5397
|
-
const
|
|
5398
|
-
this.mutations.push(new
|
|
5399
|
-
})), await
|
|
5402
|
+
t.forEach(((t, e) => {
|
|
5403
|
+
const n = nt.fromPath(e);
|
|
5404
|
+
this.mutations.push(new Ve(n, this.precondition(n)));
|
|
5405
|
+
})), await Ze(this.datastore, this.mutations), this.committed = !0;
|
|
5400
5406
|
}
|
|
5401
5407
|
recordVersion(t) {
|
|
5402
|
-
let
|
|
5403
|
-
if (t.isFoundDocument())
|
|
5408
|
+
let e;
|
|
5409
|
+
if (t.isFoundDocument()) e = t.version; else {
|
|
5404
5410
|
if (!t.isNoDocument()) throw v();
|
|
5405
5411
|
// For deleted docs, we must use baseVersion 0 when we overwrite them.
|
|
5406
|
-
|
|
5412
|
+
e = bt.min();
|
|
5407
5413
|
}
|
|
5408
|
-
const
|
|
5409
|
-
if (
|
|
5410
|
-
if (!
|
|
5414
|
+
const n = this.readVersions.get(t.key.toString());
|
|
5415
|
+
if (n) {
|
|
5416
|
+
if (!e.isEqual(n))
|
|
5411
5417
|
// This transaction will fail no matter what.
|
|
5412
|
-
throw new U(
|
|
5413
|
-
} else this.readVersions.set(t.key.toString(),
|
|
5418
|
+
throw new U(F, "Document version changed between two reads.");
|
|
5419
|
+
} else this.readVersions.set(t.key.toString(), e);
|
|
5414
5420
|
}
|
|
5415
5421
|
/**
|
|
5416
5422
|
* Returns the version of this document when it was read in this transaction,
|
|
5417
5423
|
* as a precondition, or no precondition if it was not read.
|
|
5418
5424
|
*/ precondition(t) {
|
|
5419
|
-
const
|
|
5420
|
-
return !this.writtenDocs.has(t.toString()) &&
|
|
5425
|
+
const e = this.readVersions.get(t.toString());
|
|
5426
|
+
return !this.writtenDocs.has(t.toString()) && e ? Te.updateTime(e) : Te.none();
|
|
5421
5427
|
}
|
|
5422
5428
|
/**
|
|
5423
5429
|
* Returns the precondition for a document if the operation is an update.
|
|
5424
5430
|
*/ preconditionForUpdate(t) {
|
|
5425
|
-
const
|
|
5431
|
+
const e = this.readVersions.get(t.toString());
|
|
5426
5432
|
// The first time a document is written, we want to take into account the
|
|
5427
5433
|
// read time and existence
|
|
5428
|
-
if (!this.writtenDocs.has(t.toString()) &&
|
|
5429
|
-
if (
|
|
5434
|
+
if (!this.writtenDocs.has(t.toString()) && e) {
|
|
5435
|
+
if (e.isEqual(bt.min()))
|
|
5430
5436
|
// The document doesn't exist, so fail the transaction.
|
|
5431
5437
|
// This has to be validated locally because you can't send a
|
|
5432
5438
|
// precondition that a document does not exist without changing the
|
|
@@ -5438,11 +5444,11 @@ function xr(t, n) {
|
|
|
5438
5444
|
// transaction.
|
|
5439
5445
|
throw new U(R, "Can't update a document that doesn't exist.");
|
|
5440
5446
|
// Document exists, base precondition on document update time.
|
|
5441
|
-
return
|
|
5447
|
+
return Te.updateTime(e);
|
|
5442
5448
|
}
|
|
5443
5449
|
// Document was not read, so we just use the preconditions for a blind
|
|
5444
5450
|
// update.
|
|
5445
|
-
return
|
|
5451
|
+
return Te.exists(!0);
|
|
5446
5452
|
}
|
|
5447
5453
|
write(t) {
|
|
5448
5454
|
this.ensureCommitNotCalled(), this.mutations.push(t);
|
|
@@ -5450,6 +5456,25 @@ function xr(t, n) {
|
|
|
5450
5456
|
ensureCommitNotCalled() {}
|
|
5451
5457
|
}
|
|
5452
5458
|
|
|
5459
|
+
/**
|
|
5460
|
+
* @license
|
|
5461
|
+
* Copyright 2022 Google LLC
|
|
5462
|
+
*
|
|
5463
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5464
|
+
* you may not use this file except in compliance with the License.
|
|
5465
|
+
* You may obtain a copy of the License at
|
|
5466
|
+
*
|
|
5467
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
5468
|
+
*
|
|
5469
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
5470
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
5471
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5472
|
+
* See the License for the specific language governing permissions and
|
|
5473
|
+
* limitations under the License.
|
|
5474
|
+
*/ const Cr = {
|
|
5475
|
+
maxAttempts: 5
|
|
5476
|
+
};
|
|
5477
|
+
|
|
5453
5478
|
/**
|
|
5454
5479
|
* @license
|
|
5455
5480
|
* Copyright 2019 Google LLC
|
|
@@ -5470,20 +5495,20 @@ function xr(t, n) {
|
|
|
5470
5495
|
* TransactionRunner encapsulates the logic needed to run and retry transactions
|
|
5471
5496
|
* with backoff.
|
|
5472
5497
|
*/
|
|
5473
|
-
class
|
|
5474
|
-
constructor(t, n,
|
|
5475
|
-
this.asyncQueue = t, this.datastore =
|
|
5476
|
-
this.Tt =
|
|
5498
|
+
class Lr {
|
|
5499
|
+
constructor(t, e, n, r, s) {
|
|
5500
|
+
this.asyncQueue = t, this.datastore = e, this.options = n, this.updateFunction = r,
|
|
5501
|
+
this.deferred = s, this.Tt = n.maxAttempts, this.At = new Je(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
|
|
5477
5502
|
}
|
|
5478
5503
|
/** Runs the transaction and sets the result on deferred. */ run() {
|
|
5479
|
-
this.Tt -= 1, this.
|
|
5504
|
+
this.Tt -= 1, this.It();
|
|
5480
5505
|
}
|
|
5481
|
-
|
|
5482
|
-
this.
|
|
5483
|
-
const t = new Or(this.datastore),
|
|
5484
|
-
|
|
5506
|
+
It() {
|
|
5507
|
+
this.At.W((async () => {
|
|
5508
|
+
const t = new Or(this.datastore), e = this.Rt(t);
|
|
5509
|
+
e && e.then((e => {
|
|
5485
5510
|
this.asyncQueue.enqueueAndForget((() => t.commit().then((() => {
|
|
5486
|
-
this.deferred.resolve(
|
|
5511
|
+
this.deferred.resolve(e);
|
|
5487
5512
|
})).catch((t => {
|
|
5488
5513
|
this.Pt(t);
|
|
5489
5514
|
}))));
|
|
@@ -5494,8 +5519,8 @@ class Cr {
|
|
|
5494
5519
|
}
|
|
5495
5520
|
Rt(t) {
|
|
5496
5521
|
try {
|
|
5497
|
-
const
|
|
5498
|
-
return !at(
|
|
5522
|
+
const e = this.updateFunction(t);
|
|
5523
|
+
return !at(e) && e.catch && e.then ? e : (this.deferred.reject(Error("Transaction callback must return a Promise")),
|
|
5499
5524
|
null);
|
|
5500
5525
|
} catch (t) {
|
|
5501
5526
|
// Do not retry errors thrown by user provided updateFunction.
|
|
@@ -5503,15 +5528,15 @@ class Cr {
|
|
|
5503
5528
|
}
|
|
5504
5529
|
}
|
|
5505
5530
|
Pt(t) {
|
|
5506
|
-
this.Tt > 0 && this.Vt(t) ? (this.Tt -= 1, this.asyncQueue.enqueueAndForget((() => (this.
|
|
5531
|
+
this.Tt > 0 && this.Vt(t) ? (this.Tt -= 1, this.asyncQueue.enqueueAndForget((() => (this.It(),
|
|
5507
5532
|
Promise.resolve())))) : this.deferred.reject(t);
|
|
5508
5533
|
}
|
|
5509
5534
|
Vt(t) {
|
|
5510
5535
|
if ("FirebaseError" === t.name) {
|
|
5511
5536
|
// In transactions, the backend will fail outdated reads with FAILED_PRECONDITION and
|
|
5512
5537
|
// non-matching document versions with ABORTED. These errors should be retried.
|
|
5513
|
-
const
|
|
5514
|
-
return "aborted" ===
|
|
5538
|
+
const e = t.code;
|
|
5539
|
+
return "aborted" === e || "failed-precondition" === e || !
|
|
5515
5540
|
/**
|
|
5516
5541
|
* Determines whether an error code represents a permanent error when received
|
|
5517
5542
|
* in response to a non-write operation.
|
|
@@ -5523,8 +5548,8 @@ class Cr {
|
|
|
5523
5548
|
default:
|
|
5524
5549
|
return v();
|
|
5525
5550
|
|
|
5526
|
-
case I:
|
|
5527
5551
|
case A:
|
|
5552
|
+
case I:
|
|
5528
5553
|
case P:
|
|
5529
5554
|
case S:
|
|
5530
5555
|
case C:
|
|
@@ -5538,17 +5563,17 @@ class Cr {
|
|
|
5538
5563
|
case V:
|
|
5539
5564
|
case N:
|
|
5540
5565
|
case D:
|
|
5541
|
-
case
|
|
5566
|
+
case x:
|
|
5542
5567
|
// Aborted might be retried in some scenarios, but that is dependant on
|
|
5543
5568
|
// the context and should handled individually by the calling code.
|
|
5544
5569
|
// See https://cloud.google.com/apis/design/errors.
|
|
5545
|
-
case
|
|
5570
|
+
case F:
|
|
5546
5571
|
case q:
|
|
5547
5572
|
case O:
|
|
5548
5573
|
case k:
|
|
5549
5574
|
return !0;
|
|
5550
5575
|
}
|
|
5551
|
-
}(
|
|
5576
|
+
}(e);
|
|
5552
5577
|
}
|
|
5553
5578
|
return !1;
|
|
5554
5579
|
}
|
|
@@ -5570,7 +5595,7 @@ class Cr {
|
|
|
5570
5595
|
* See the License for the specific language governing permissions and
|
|
5571
5596
|
* limitations under the License.
|
|
5572
5597
|
*/
|
|
5573
|
-
/** The Platform's 'document' implementation or null if not available. */ function
|
|
5598
|
+
/** The Platform's 'document' implementation or null if not available. */ function kr() {
|
|
5574
5599
|
// `document` is not always available, e.g. in ReactNative and WebWorkers.
|
|
5575
5600
|
// eslint-disable-next-line no-restricted-globals
|
|
5576
5601
|
return "undefined" != typeof document ? document : null;
|
|
@@ -5602,9 +5627,9 @@ class Cr {
|
|
|
5602
5627
|
* Note: We implement `PromiseLike` instead of `Promise`, as the `Promise` type
|
|
5603
5628
|
* in newer versions of TypeScript defines `finally`, which is not available in
|
|
5604
5629
|
* IE.
|
|
5605
|
-
*/ class
|
|
5606
|
-
constructor(t,
|
|
5607
|
-
this.asyncQueue = t, this.timerId =
|
|
5630
|
+
*/ class Ur {
|
|
5631
|
+
constructor(t, e, n, r, s) {
|
|
5632
|
+
this.asyncQueue = t, this.timerId = e, this.targetTimeMs = n, this.op = r, this.removalCallback = s,
|
|
5608
5633
|
this.deferred = new j, this.then = this.deferred.promise.then.bind(this.deferred.promise),
|
|
5609
5634
|
// It's normal for the deferred promise to be canceled (due to cancellation)
|
|
5610
5635
|
// and so we attach a dummy catch callback to avoid
|
|
@@ -5624,9 +5649,9 @@ class Cr {
|
|
|
5624
5649
|
* from its delayedOperations list.
|
|
5625
5650
|
* PORTING NOTE: This exists to prevent making removeDelayedOperation() and
|
|
5626
5651
|
* the DelayedOperation class public.
|
|
5627
|
-
*/ static createAndSchedule(t,
|
|
5628
|
-
const i = Date.now() +
|
|
5629
|
-
return o.start(
|
|
5652
|
+
*/ static createAndSchedule(t, e, n, r, s) {
|
|
5653
|
+
const i = Date.now() + n, o = new Ur(t, e, i, r, s);
|
|
5654
|
+
return o.start(n), o;
|
|
5630
5655
|
}
|
|
5631
5656
|
/**
|
|
5632
5657
|
* Starts the timer. This is called immediately after construction by
|
|
@@ -5647,7 +5672,7 @@ class Cr {
|
|
|
5647
5672
|
* As long as the operation has not yet been run, calling cancel() provides a
|
|
5648
5673
|
* guarantee that the operation will not be run.
|
|
5649
5674
|
*/ cancel(t) {
|
|
5650
|
-
null !== this.timerHandle && (this.clearTimeout(), this.deferred.reject(new U(
|
|
5675
|
+
null !== this.timerHandle && (this.clearTimeout(), this.deferred.reject(new U(A, "Operation cancelled" + (t ? ": " + t : ""))));
|
|
5651
5676
|
}
|
|
5652
5677
|
handleDelayElapsed() {
|
|
5653
5678
|
this.asyncQueue.enqueueAndForget((() => null !== this.timerHandle ? (this.clearTimeout(),
|
|
@@ -5674,7 +5699,7 @@ class Cr {
|
|
|
5674
5699
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5675
5700
|
* See the License for the specific language governing permissions and
|
|
5676
5701
|
* limitations under the License.
|
|
5677
|
-
*/ class
|
|
5702
|
+
*/ class jr {
|
|
5678
5703
|
constructor() {
|
|
5679
5704
|
// The last promise in the queue.
|
|
5680
5705
|
this.Nt = Promise.resolve(),
|
|
@@ -5688,24 +5713,24 @@ class Cr {
|
|
|
5688
5713
|
// automatically removed after they are run or canceled.
|
|
5689
5714
|
this.St = [],
|
|
5690
5715
|
// visible for testing
|
|
5691
|
-
this.
|
|
5716
|
+
this.xt = null,
|
|
5692
5717
|
// Flag set while there's an outstanding AsyncQueue operation, used for
|
|
5693
5718
|
// assertion sanity-checks.
|
|
5694
|
-
this.
|
|
5719
|
+
this.Ft = !1,
|
|
5695
5720
|
// Enabled during shutdown on Safari to prevent future access to IndexedDB.
|
|
5696
5721
|
this.qt = !1,
|
|
5697
5722
|
// List of TimerIds to fast-forward delays for.
|
|
5698
5723
|
this.Ot = [],
|
|
5699
5724
|
// Backoff timer used to schedule retries for retryable operations
|
|
5700
|
-
this.
|
|
5725
|
+
this.At = new Je(this, "async_queue_retry" /* AsyncQueueRetry */),
|
|
5701
5726
|
// Visibility handler that triggers an immediate retry of all retryable
|
|
5702
5727
|
// operations. Meant to speed up recovery when we regain file system access
|
|
5703
5728
|
// after page comes into foreground.
|
|
5704
5729
|
this.Ct = () => {
|
|
5705
|
-
const t =
|
|
5706
|
-
t && p("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.
|
|
5730
|
+
const t = kr();
|
|
5731
|
+
t && p("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.At.H();
|
|
5707
5732
|
};
|
|
5708
|
-
const t =
|
|
5733
|
+
const t = kr();
|
|
5709
5734
|
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.Ct);
|
|
5710
5735
|
}
|
|
5711
5736
|
get isShuttingDown() {
|
|
@@ -5726,8 +5751,8 @@ class Cr {
|
|
|
5726
5751
|
enterRestrictedMode(t) {
|
|
5727
5752
|
if (!this.$t) {
|
|
5728
5753
|
this.$t = !0, this.qt = t || !1;
|
|
5729
|
-
const
|
|
5730
|
-
|
|
5754
|
+
const e = kr();
|
|
5755
|
+
e && "function" == typeof e.removeEventListener && e.removeEventListener("visibilitychange", this.Ct);
|
|
5731
5756
|
}
|
|
5732
5757
|
}
|
|
5733
5758
|
enqueue(t) {
|
|
@@ -5737,9 +5762,9 @@ class Cr {
|
|
|
5737
5762
|
// Create a deferred Promise that we can return to the callee. This
|
|
5738
5763
|
// allows us to return a "hanging Promise" only to the callee and still
|
|
5739
5764
|
// advance the queue even when the operation is not run.
|
|
5740
|
-
const
|
|
5741
|
-
return this.kt((() => this.$t && this.qt ? Promise.resolve() : (t().then(
|
|
5742
|
-
|
|
5765
|
+
const e = new j;
|
|
5766
|
+
return this.kt((() => this.$t && this.qt ? Promise.resolve() : (t().then(e.resolve, e.reject),
|
|
5767
|
+
e.promise))).then((() => e.promise));
|
|
5743
5768
|
}
|
|
5744
5769
|
enqueueRetryable(t) {
|
|
5745
5770
|
this.enqueueAndForget((() => (this.Dt.push(t), this.Ut())));
|
|
@@ -5750,7 +5775,7 @@ class Cr {
|
|
|
5750
5775
|
*/ async Ut() {
|
|
5751
5776
|
if (0 !== this.Dt.length) {
|
|
5752
5777
|
try {
|
|
5753
|
-
await this.Dt[0](), this.Dt.shift(), this.
|
|
5778
|
+
await this.Dt[0](), this.Dt.shift(), this.At.reset();
|
|
5754
5779
|
} catch (t) {
|
|
5755
5780
|
if (!
|
|
5756
5781
|
/**
|
|
@@ -5805,22 +5830,22 @@ class Cr {
|
|
|
5805
5830
|
// Since `backoffAndRun()` cancels an existing backoff and schedules a
|
|
5806
5831
|
// new backoff on every call, there is only ever a single additional
|
|
5807
5832
|
// operation in the queue.
|
|
5808
|
-
this.
|
|
5833
|
+
this.At.W((() => this.Ut()));
|
|
5809
5834
|
}
|
|
5810
5835
|
}
|
|
5811
5836
|
kt(t) {
|
|
5812
|
-
const
|
|
5813
|
-
this.
|
|
5814
|
-
const
|
|
5837
|
+
const e = this.Nt.then((() => (this.Ft = !0, t().catch((t => {
|
|
5838
|
+
this.xt = t, this.Ft = !1;
|
|
5839
|
+
const e =
|
|
5815
5840
|
/**
|
|
5816
5841
|
* Chrome includes Error.message in Error.stack. Other browsers do not.
|
|
5817
5842
|
* This returns expected output of message + stack when available.
|
|
5818
5843
|
* @param error - Error or FirestoreError
|
|
5819
5844
|
*/
|
|
5820
5845
|
function(t) {
|
|
5821
|
-
let
|
|
5822
|
-
t.stack && (
|
|
5823
|
-
return
|
|
5846
|
+
let e = t.message || "";
|
|
5847
|
+
t.stack && (e = t.stack.includes(t.message) ? t.stack : t.message + "\n" + t.stack);
|
|
5848
|
+
return e;
|
|
5824
5849
|
}
|
|
5825
5850
|
/**
|
|
5826
5851
|
* @license
|
|
@@ -5850,19 +5875,19 @@ class Cr {
|
|
|
5850
5875
|
// Re-throw the error so that this.tail becomes a rejected Promise and
|
|
5851
5876
|
// all further attempts to chain (via .then) will just short-circuit
|
|
5852
5877
|
// and return the rejected Promise.
|
|
5853
|
-
throw y("INTERNAL UNHANDLED ERROR: ",
|
|
5854
|
-
})).then((t => (this.
|
|
5855
|
-
return this.Nt =
|
|
5878
|
+
throw y("INTERNAL UNHANDLED ERROR: ", e), t;
|
|
5879
|
+
})).then((t => (this.Ft = !1, t))))));
|
|
5880
|
+
return this.Nt = e, e;
|
|
5856
5881
|
}
|
|
5857
|
-
enqueueAfterDelay(t,
|
|
5882
|
+
enqueueAfterDelay(t, e, n) {
|
|
5858
5883
|
this.Lt(),
|
|
5859
5884
|
// Fast-forward delays for timerIds that have been overriden.
|
|
5860
|
-
this.Ot.indexOf(t) > -1 && (
|
|
5861
|
-
const r =
|
|
5885
|
+
this.Ot.indexOf(t) > -1 && (e = 0);
|
|
5886
|
+
const r = Ur.createAndSchedule(this, t, e, n, (t => this.jt(t)));
|
|
5862
5887
|
return this.St.push(r), r;
|
|
5863
5888
|
}
|
|
5864
5889
|
Lt() {
|
|
5865
|
-
this.
|
|
5890
|
+
this.xt && v();
|
|
5866
5891
|
}
|
|
5867
5892
|
verifyOperationInProgress() {}
|
|
5868
5893
|
/**
|
|
@@ -5882,7 +5907,7 @@ class Cr {
|
|
|
5882
5907
|
* For Tests: Determine if a delayed operation with a particular TimerId
|
|
5883
5908
|
* exists.
|
|
5884
5909
|
*/ Bt(t) {
|
|
5885
|
-
for (const
|
|
5910
|
+
for (const e of this.St) if (e.timerId === t) return !0;
|
|
5886
5911
|
return !1;
|
|
5887
5912
|
}
|
|
5888
5913
|
/**
|
|
@@ -5895,8 +5920,8 @@ class Cr {
|
|
|
5895
5920
|
// Note that draining may generate more delayed ops, so we do that first.
|
|
5896
5921
|
return this.Mt().then((() => {
|
|
5897
5922
|
// Run ops in the same order they'd run if they ran naturally.
|
|
5898
|
-
this.St.sort(((t,
|
|
5899
|
-
for (const
|
|
5923
|
+
this.St.sort(((t, e) => t.targetTimeMs - e.targetTimeMs));
|
|
5924
|
+
for (const e of this.St) if (e.skipDelay(), "all" /* All */ !== t && e.timerId === t) break;
|
|
5900
5925
|
return this.Mt();
|
|
5901
5926
|
}));
|
|
5902
5927
|
}
|
|
@@ -5907,15 +5932,15 @@ class Cr {
|
|
|
5907
5932
|
}
|
|
5908
5933
|
/** Called once a DelayedOperation is run or canceled. */ jt(t) {
|
|
5909
5934
|
// NOTE: indexOf / slice are O(n), but delayedOperations is expected to be small.
|
|
5910
|
-
const
|
|
5911
|
-
this.St.splice(
|
|
5935
|
+
const e = this.St.indexOf(t);
|
|
5936
|
+
this.St.splice(e, 1);
|
|
5912
5937
|
}
|
|
5913
5938
|
}
|
|
5914
5939
|
|
|
5915
|
-
class
|
|
5940
|
+
class Mr {
|
|
5916
5941
|
/** @hideconstructor */
|
|
5917
|
-
constructor(t,
|
|
5918
|
-
this._firestore = t, this._transaction =
|
|
5942
|
+
constructor(t, e) {
|
|
5943
|
+
this._firestore = t, this._transaction = e, this._dataReader = Dn(t);
|
|
5919
5944
|
}
|
|
5920
5945
|
/**
|
|
5921
5946
|
* Reads the document referenced by the provided {@link DocumentReference}.
|
|
@@ -5923,25 +5948,25 @@ class jr {
|
|
|
5923
5948
|
* @param documentRef - A reference to the document to be read.
|
|
5924
5949
|
* @returns A `DocumentSnapshot` with the read data.
|
|
5925
5950
|
*/ get(t) {
|
|
5926
|
-
const
|
|
5927
|
-
return this._transaction.lookup([
|
|
5951
|
+
const e = Fr(t, this._firestore), n = new br(this._firestore);
|
|
5952
|
+
return this._transaction.lookup([ e._key ]).then((t => {
|
|
5928
5953
|
if (!t || 1 !== t.length) return v();
|
|
5929
5954
|
const r = t[0];
|
|
5930
|
-
if (r.isFoundDocument()) return new
|
|
5931
|
-
if (r.isNoDocument()) return new
|
|
5955
|
+
if (r.isFoundDocument()) return new Kn(this._firestore, n, r.key, r, e.converter);
|
|
5956
|
+
if (r.isNoDocument()) return new Kn(this._firestore, n, e._key, null, e.converter);
|
|
5932
5957
|
throw v();
|
|
5933
5958
|
}));
|
|
5934
5959
|
}
|
|
5935
|
-
set(t,
|
|
5936
|
-
const r =
|
|
5960
|
+
set(t, e, n) {
|
|
5961
|
+
const r = Fr(t, this._firestore), s = vr(r.converter, e, n), i = $n(this._dataReader, "Transaction.set", r._key, s, null !== r.converter, n);
|
|
5937
5962
|
return this._transaction.set(r._key, i), this;
|
|
5938
5963
|
}
|
|
5939
|
-
update(t,
|
|
5940
|
-
const s =
|
|
5964
|
+
update(t, e, n, ...r) {
|
|
5965
|
+
const s = Fr(t, this._firestore);
|
|
5941
5966
|
// For Compat types, we have to "extract" the underlying types before
|
|
5942
5967
|
// performing validation.
|
|
5943
5968
|
let i;
|
|
5944
|
-
return i = "string" == typeof (
|
|
5969
|
+
return i = "string" == typeof (e = l(e)) || e instanceof gn ? kn(this._dataReader, "Transaction.update", s._key, e, n, r) : Ln(this._dataReader, "Transaction.update", s._key, e),
|
|
5945
5970
|
this._transaction.update(s._key, i), this;
|
|
5946
5971
|
}
|
|
5947
5972
|
/**
|
|
@@ -5950,8 +5975,8 @@ class jr {
|
|
|
5950
5975
|
* @param documentRef - A reference to the document to be deleted.
|
|
5951
5976
|
* @returns This `Transaction` instance. Used for chaining method calls.
|
|
5952
5977
|
*/ delete(t) {
|
|
5953
|
-
const
|
|
5954
|
-
return this._transaction.delete(
|
|
5978
|
+
const e = Fr(t, this._firestore);
|
|
5979
|
+
return this._transaction.delete(e._key), this;
|
|
5955
5980
|
}
|
|
5956
5981
|
}
|
|
5957
5982
|
|
|
@@ -5971,9 +5996,13 @@ class jr {
|
|
|
5971
5996
|
* (the `updateFunction` returned a failed promise), the promise returned by the
|
|
5972
5997
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
5973
5998
|
* rejected promise with the corresponding failure error is returned.
|
|
5974
|
-
*/ function
|
|
5975
|
-
const
|
|
5976
|
-
|
|
5999
|
+
*/ function Br(t, e, n) {
|
|
6000
|
+
const r = rn(t = ut(t, on)), s = Object.assign(Object.assign({}, Cr), n);
|
|
6001
|
+
!function(t) {
|
|
6002
|
+
if (t.maxAttempts < 1) throw new U(R, "Max attempts must be at least 1");
|
|
6003
|
+
}(s);
|
|
6004
|
+
const i = new j;
|
|
6005
|
+
return new Lr(new jr, r, s, (n => e(new Mr(t, n))), i).run(), i.promise;
|
|
5977
6006
|
}
|
|
5978
6007
|
|
|
5979
6008
|
/**
|
|
@@ -5985,12 +6014,12 @@ class jr {
|
|
|
5985
6014
|
* @packageDocumentation
|
|
5986
6015
|
*/ !function(t) {
|
|
5987
6016
|
d = t;
|
|
5988
|
-
}(`${s}_lite`),
|
|
5989
|
-
const
|
|
5990
|
-
return
|
|
6017
|
+
}(`${s}_lite`), n(new i("firestore/lite", ((t, {options: e}) => {
|
|
6018
|
+
const n = t.getProvider("app").getImmediate(), r = new on(n, new G(t.getProvider("auth-internal")), new H(t.getProvider("app-check-internal")));
|
|
6019
|
+
return e && r._setSettings(e), r;
|
|
5991
6020
|
}), "PUBLIC")),
|
|
5992
6021
|
// RUNTIME_ENV and BUILD_TARGET are replaced by real values during the compilation
|
|
5993
|
-
r("firestore-lite", "3.4.
|
|
6022
|
+
r("firestore-lite", "3.4.9", "rn"), r("firestore-lite", "3.4.9", "esm2017");
|
|
5994
6023
|
|
|
5995
|
-
export {
|
|
6024
|
+
export { bn as Bytes, dn as CollectionReference, ln as DocumentReference, Kn as DocumentSnapshot, gn as FieldPath, En as FieldValue, on as Firestore, U as FirestoreError, Tn as GeoPoint, fn as Query, er as QueryConstraint, Jn as QueryDocumentSnapshot, Xn as QuerySnapshot, vt as Timestamp, Mr as Transaction, xr as WriteBatch, Pr as addDoc, $r as arrayRemove, Dr as arrayUnion, wn as collection, mn as collectionGroup, an as connectFirestoreEmulator, Rr as deleteDoc, Vr as deleteField, pn as doc, vn as documentId, mr as endAt, wr as endBefore, Er as getDoc, Tr as getDocs, cn as getFirestore, Sr as increment, un as initializeFirestore, cr as limit, ar as limitToLast, or as orderBy, nr as query, _n as queryEqual, yn as refEqual, Br as runTransaction, Nr as serverTimestamp, Ar as setDoc, m as setLogLevel, Zn as snapshotEqual, fr as startAfter, lr as startAt, hn as terminate, Ir as updateDoc, sr as where, qr as writeBatch };
|
|
5996
6025
|
//# sourceMappingURL=index.rn.esm2017.js.map
|