@firebase/firestore 3.4.4-canary.f5ac47fb1 → 3.4.5
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 +12 -0
- package/dist/firestore/src/api/credentials.d.ts +1 -0
- package/dist/firestore/src/index/index_byte_encoder.d.ts +18 -1
- package/dist/firestore/src/index/index_entry.d.ts +26 -0
- package/dist/firestore/src/local/document_overlay_cache.d.ts +72 -0
- package/dist/firestore/src/local/indexeddb_document_overlay_cache.d.ts +45 -0
- package/dist/firestore/src/local/indexeddb_index_manager.d.ts +29 -2
- package/dist/firestore/src/local/indexeddb_persistence.d.ts +6 -4
- package/dist/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
- package/dist/firestore/src/local/indexeddb_schema.d.ts +83 -9
- package/dist/firestore/src/local/local_documents_view.d.ts +0 -1
- package/dist/firestore/src/local/local_serializer.d.ts +18 -2
- package/dist/firestore/src/local/memory_document_overlay_cache.d.ts +37 -0
- package/dist/firestore/src/local/memory_persistence.d.ts +6 -2
- package/dist/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
- package/dist/firestore/src/local/persistence.d.ts +8 -2
- package/dist/firestore/src/local/remote_document_cache.d.ts +7 -9
- package/dist/firestore/src/model/document_key.d.ts +5 -0
- package/dist/firestore/src/model/field_index.d.ts +2 -2
- package/dist/firestore/src/model/overlay.d.ts +32 -0
- package/dist/firestore/src/model/target_index_matcher.d.ts +70 -0
- package/dist/firestore/src/platform/node/grpc_connection.d.ts +2 -2
- package/dist/firestore/src/platform/node/load_protos.d.ts +2 -2
- package/dist/firestore/src/util/sorted_set.d.ts +18 -0
- package/dist/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
- package/dist/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
- package/dist/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
- package/dist/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
- package/dist/firestore/test/unit/local/test_index_manager.d.ts +11 -0
- package/dist/firestore/test/unit/local/test_remote_document_cache.d.ts +4 -2
- package/dist/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
- package/dist/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
- package/dist/index.esm2017.js +4367 -3517
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +4226 -3437
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +1519 -242
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +1501 -245
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +4355 -3509
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +84 -12
- package/dist/lite/firestore/src/api/credentials.d.ts +1 -0
- package/dist/lite/firestore/src/index/index_byte_encoder.d.ts +18 -1
- package/dist/lite/firestore/src/index/index_entry.d.ts +26 -0
- package/dist/lite/firestore/src/local/document_overlay_cache.d.ts +72 -0
- package/dist/lite/firestore/src/local/indexeddb_document_overlay_cache.d.ts +45 -0
- package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +29 -2
- package/dist/lite/firestore/src/local/indexeddb_persistence.d.ts +6 -4
- package/dist/lite/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
- package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +83 -9
- package/dist/lite/firestore/src/local/local_documents_view.d.ts +0 -1
- package/dist/lite/firestore/src/local/local_serializer.d.ts +18 -2
- package/dist/lite/firestore/src/local/memory_document_overlay_cache.d.ts +37 -0
- package/dist/lite/firestore/src/local/memory_persistence.d.ts +6 -2
- package/dist/lite/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
- package/dist/lite/firestore/src/local/persistence.d.ts +8 -2
- package/dist/lite/firestore/src/local/remote_document_cache.d.ts +7 -9
- package/dist/lite/firestore/src/model/document_key.d.ts +5 -0
- package/dist/lite/firestore/src/model/field_index.d.ts +2 -2
- package/dist/lite/firestore/src/model/overlay.d.ts +32 -0
- package/dist/lite/firestore/src/model/target_index_matcher.d.ts +70 -0
- package/dist/lite/firestore/src/platform/node/grpc_connection.d.ts +2 -2
- package/dist/lite/firestore/src/platform/node/load_protos.d.ts +2 -2
- package/dist/lite/firestore/src/util/sorted_set.d.ts +18 -0
- package/dist/lite/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
- package/dist/lite/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
- package/dist/lite/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
- package/dist/lite/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
- package/dist/lite/firestore/test/unit/local/test_index_manager.d.ts +11 -0
- package/dist/lite/firestore/test/unit/local/test_remote_document_cache.d.ts +4 -2
- package/dist/lite/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
- package/dist/lite/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
- package/dist/lite/index.browser.esm2017.js +1121 -1112
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +60 -48
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.node.cjs.js +13 -2
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +13 -2
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +46 -37
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +5 -0
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +112 -112
- package/dist/lite/packages/firestore/src/api/credentials.d.ts +1 -0
- package/dist/lite/packages/firestore/src/index/index_byte_encoder.d.ts +18 -1
- package/dist/lite/packages/firestore/src/index/index_entry.d.ts +26 -0
- package/dist/lite/packages/firestore/src/local/document_overlay_cache.d.ts +72 -0
- package/dist/lite/packages/firestore/src/local/indexeddb_document_overlay_cache.d.ts +45 -0
- package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +29 -2
- package/dist/lite/packages/firestore/src/local/indexeddb_persistence.d.ts +6 -4
- package/dist/lite/packages/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
- package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +83 -9
- package/dist/lite/packages/firestore/src/local/local_documents_view.d.ts +0 -1
- package/dist/lite/packages/firestore/src/local/local_serializer.d.ts +18 -2
- package/dist/lite/packages/firestore/src/local/memory_document_overlay_cache.d.ts +37 -0
- package/dist/lite/packages/firestore/src/local/memory_persistence.d.ts +6 -2
- package/dist/lite/packages/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
- package/dist/lite/packages/firestore/src/local/persistence.d.ts +8 -2
- package/dist/lite/packages/firestore/src/local/remote_document_cache.d.ts +7 -9
- package/dist/lite/packages/firestore/src/model/document_key.d.ts +5 -0
- package/dist/lite/packages/firestore/src/model/field_index.d.ts +2 -2
- package/dist/lite/packages/firestore/src/model/overlay.d.ts +32 -0
- package/dist/lite/packages/firestore/src/model/target_index_matcher.d.ts +70 -0
- package/dist/lite/packages/firestore/src/platform/node/grpc_connection.d.ts +2 -2
- package/dist/lite/packages/firestore/src/platform/node/load_protos.d.ts +2 -2
- package/dist/lite/packages/firestore/src/util/sorted_set.d.ts +18 -0
- package/dist/lite/packages/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
- package/dist/lite/packages/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
- package/dist/lite/packages/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
- package/dist/lite/packages/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
- package/dist/lite/packages/firestore/test/unit/local/test_index_manager.d.ts +11 -0
- package/dist/lite/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +4 -2
- package/dist/lite/packages/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
- package/dist/lite/packages/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
- package/dist/packages/firestore/dist/index.esm2017.d.ts +187 -184
- package/dist/packages/firestore/src/api/credentials.d.ts +1 -0
- package/dist/packages/firestore/src/index/index_byte_encoder.d.ts +18 -1
- package/dist/packages/firestore/src/index/index_entry.d.ts +26 -0
- package/dist/packages/firestore/src/local/document_overlay_cache.d.ts +72 -0
- package/dist/packages/firestore/src/local/indexeddb_document_overlay_cache.d.ts +45 -0
- package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +29 -2
- package/dist/packages/firestore/src/local/indexeddb_persistence.d.ts +6 -4
- package/dist/packages/firestore/src/local/indexeddb_remote_document_cache.d.ts +2 -8
- package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +83 -9
- package/dist/packages/firestore/src/local/local_documents_view.d.ts +0 -1
- package/dist/packages/firestore/src/local/local_serializer.d.ts +18 -2
- package/dist/packages/firestore/src/local/memory_document_overlay_cache.d.ts +37 -0
- package/dist/packages/firestore/src/local/memory_persistence.d.ts +6 -2
- package/dist/packages/firestore/src/local/memory_remote_document_cache.d.ts +1 -3
- package/dist/packages/firestore/src/local/persistence.d.ts +8 -2
- package/dist/packages/firestore/src/local/remote_document_cache.d.ts +7 -9
- package/dist/packages/firestore/src/model/document_key.d.ts +5 -0
- package/dist/packages/firestore/src/model/field_index.d.ts +2 -2
- package/dist/packages/firestore/src/model/overlay.d.ts +32 -0
- package/dist/packages/firestore/src/model/target_index_matcher.d.ts +70 -0
- package/dist/packages/firestore/src/platform/node/grpc_connection.d.ts +2 -2
- package/dist/packages/firestore/src/platform/node/load_protos.d.ts +2 -2
- package/dist/packages/firestore/src/util/sorted_set.d.ts +18 -0
- package/dist/packages/firestore/test/unit/local/counting_query_engine.d.ts +3 -3
- package/dist/packages/firestore/test/unit/local/document_overlay_cache.test.d.ts +1 -0
- package/dist/packages/firestore/test/unit/local/persistence_test_helpers.d.ts +1 -0
- package/dist/packages/firestore/test/unit/local/test_document_overlay_cache.d.ts +38 -0
- package/dist/packages/firestore/test/unit/local/test_index_manager.d.ts +11 -0
- package/dist/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +4 -2
- package/dist/packages/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
- package/dist/packages/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
- package/dist/private.d.ts +79 -12
- package/package.json +9 -9
|
@@ -63,7 +63,7 @@ l.MOCK_USER = new l("mock-user");
|
|
|
63
63
|
* See the License for the specific language governing permissions and
|
|
64
64
|
* limitations under the License.
|
|
65
65
|
*/
|
|
66
|
-
let f = "9.6.
|
|
66
|
+
let f = "9.6.7";
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* @license
|
|
@@ -99,26 +99,26 @@ const d = new Logger("@firebase/firestore");
|
|
|
99
99
|
d.setLogLevel(t);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
function m(t, ...
|
|
102
|
+
function m(t, ...e) {
|
|
103
103
|
if (d.logLevel <= LogLevel.DEBUG) {
|
|
104
|
-
const
|
|
105
|
-
d.debug(`Firestore (${f}): ${t}`, ...
|
|
104
|
+
const n = e.map(_);
|
|
105
|
+
d.debug(`Firestore (${f}): ${t}`, ...n);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
function p(t, ...
|
|
109
|
+
function p(t, ...e) {
|
|
110
110
|
if (d.logLevel <= LogLevel.ERROR) {
|
|
111
|
-
const
|
|
112
|
-
d.error(`Firestore (${f}): ${t}`, ...
|
|
111
|
+
const n = e.map(_);
|
|
112
|
+
d.error(`Firestore (${f}): ${t}`, ...n);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
/**
|
|
117
117
|
* @internal
|
|
118
|
-
*/ function y(t, ...
|
|
118
|
+
*/ function y(t, ...e) {
|
|
119
119
|
if (d.logLevel <= LogLevel.WARN) {
|
|
120
|
-
const
|
|
121
|
-
d.warn(`Firestore (${f}): ${t}`, ...
|
|
120
|
+
const n = e.map(_);
|
|
121
|
+
d.warn(`Firestore (${f}): ${t}`, ...n);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
@@ -127,8 +127,8 @@ function p(t, ...n) {
|
|
|
127
127
|
*/ function _(t) {
|
|
128
128
|
if ("string" == typeof t) return t;
|
|
129
129
|
try {
|
|
130
|
-
return
|
|
131
|
-
} catch (
|
|
130
|
+
return e = t, JSON.stringify(e);
|
|
131
|
+
} catch (e) {
|
|
132
132
|
// Converting to JSON failed, just log the object directly
|
|
133
133
|
return t;
|
|
134
134
|
}
|
|
@@ -149,7 +149,7 @@ function p(t, ...n) {
|
|
|
149
149
|
* limitations under the License.
|
|
150
150
|
*/
|
|
151
151
|
/** Formats an object as a JSON string, suitable for logging. */
|
|
152
|
-
var
|
|
152
|
+
var e;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
/**
|
|
@@ -178,11 +178,11 @@ function p(t, ...n) {
|
|
|
178
178
|
*/ function g(t = "Unexpected state") {
|
|
179
179
|
// Log the failure in addition to throw an exception, just in case the
|
|
180
180
|
// exception is swallowed.
|
|
181
|
-
const
|
|
181
|
+
const e = `FIRESTORE (${f}) INTERNAL ASSERTION FAILED: ` + t;
|
|
182
182
|
// NOTE: We don't use FirestoreError here because these are internal failures
|
|
183
183
|
// that cannot be handled by the user. (Also it would create a circular
|
|
184
184
|
// dependency between the error and assert modules which doesn't work.)
|
|
185
|
-
throw p(
|
|
185
|
+
throw p(e), new Error(e);
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
/**
|
|
@@ -190,16 +190,16 @@ function p(t, ...n) {
|
|
|
190
190
|
* given message if it did.
|
|
191
191
|
*
|
|
192
192
|
* Messages are stripped in production builds.
|
|
193
|
-
*/ function
|
|
193
|
+
*/ function v(t, e) {
|
|
194
194
|
t || g();
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
/**
|
|
198
198
|
* Casts `obj` to `T`. In non-production builds, verifies that `obj` is an
|
|
199
199
|
* instance of `T` before casting.
|
|
200
|
-
*/ function
|
|
200
|
+
*/ function b(t,
|
|
201
201
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
202
|
-
|
|
202
|
+
e) {
|
|
203
203
|
return t;
|
|
204
204
|
}
|
|
205
205
|
|
|
@@ -230,8 +230,8 @@ n) {
|
|
|
230
230
|
/**
|
|
231
231
|
* A custom error description.
|
|
232
232
|
*/
|
|
233
|
-
|
|
234
|
-
super(t,
|
|
233
|
+
e) {
|
|
234
|
+
super(t, e), this.code = t, this.message = e,
|
|
235
235
|
// HACK: We write a toString property directly because Error is not a real
|
|
236
236
|
// class and so inheritance does not work correctly. We could alternatively
|
|
237
237
|
// do the same "back-door inheritance" trick that FirebaseError does.
|
|
@@ -256,8 +256,8 @@ n) {
|
|
|
256
256
|
* limitations under the License.
|
|
257
257
|
*/ class k {
|
|
258
258
|
constructor() {
|
|
259
|
-
this.promise = new Promise(((t,
|
|
260
|
-
this.resolve = t, this.reject =
|
|
259
|
+
this.promise = new Promise(((t, e) => {
|
|
260
|
+
this.resolve = t, this.reject = e;
|
|
261
261
|
}));
|
|
262
262
|
}
|
|
263
263
|
}
|
|
@@ -278,8 +278,8 @@ n) {
|
|
|
278
278
|
* See the License for the specific language governing permissions and
|
|
279
279
|
* limitations under the License.
|
|
280
280
|
*/ class j {
|
|
281
|
-
constructor(t,
|
|
282
|
-
this.user =
|
|
281
|
+
constructor(t, e) {
|
|
282
|
+
this.user = e, this.type = "OAuth", this.headers = new Map, this.headers.set("Authorization", `Bearer ${t}`);
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
285
|
|
|
@@ -291,9 +291,9 @@ n) {
|
|
|
291
291
|
return Promise.resolve(null);
|
|
292
292
|
}
|
|
293
293
|
invalidateToken() {}
|
|
294
|
-
start(t,
|
|
294
|
+
start(t, e) {
|
|
295
295
|
// Fire with initial user.
|
|
296
|
-
t.enqueueRetryable((() =>
|
|
296
|
+
t.enqueueRetryable((() => e(l.UNAUTHENTICATED)));
|
|
297
297
|
}
|
|
298
298
|
shutdown() {}
|
|
299
299
|
}
|
|
@@ -315,10 +315,10 @@ n) {
|
|
|
315
315
|
return Promise.resolve(this.token);
|
|
316
316
|
}
|
|
317
317
|
invalidateToken() {}
|
|
318
|
-
start(t,
|
|
319
|
-
this.changeListener =
|
|
318
|
+
start(t, e) {
|
|
319
|
+
this.changeListener = e,
|
|
320
320
|
// Fire with initial user.
|
|
321
|
-
t.enqueueRetryable((() =>
|
|
321
|
+
t.enqueueRetryable((() => e(this.token.user)));
|
|
322
322
|
}
|
|
323
323
|
shutdown() {
|
|
324
324
|
this.changeListener = null;
|
|
@@ -332,11 +332,11 @@ n) {
|
|
|
332
332
|
}));
|
|
333
333
|
}
|
|
334
334
|
getToken() {
|
|
335
|
-
return this.auth ? this.auth.getToken().then((t => t ? (
|
|
335
|
+
return this.auth ? this.auth.getToken().then((t => t ? (v("string" == typeof t.accessToken),
|
|
336
336
|
new j(t.accessToken, new l(this.auth.getUid()))) : null)) : Promise.resolve(null);
|
|
337
337
|
}
|
|
338
338
|
invalidateToken() {}
|
|
339
|
-
start(t,
|
|
339
|
+
start(t, e) {}
|
|
340
340
|
shutdown() {}
|
|
341
341
|
}
|
|
342
342
|
|
|
@@ -347,10 +347,10 @@ n) {
|
|
|
347
347
|
* recover from unauthenticated errors (see b/33147818 for context), but it's
|
|
348
348
|
* safer to keep the implementation as-is.
|
|
349
349
|
*/ class G {
|
|
350
|
-
constructor(t,
|
|
351
|
-
this.type = "FirstParty", this.user = l.FIRST_PARTY, this.headers = new Map, this.headers.set("X-Goog-AuthUser",
|
|
350
|
+
constructor(t, e, n) {
|
|
351
|
+
this.type = "FirstParty", this.user = l.FIRST_PARTY, this.headers = new Map, this.headers.set("X-Goog-AuthUser", e);
|
|
352
352
|
const r = t.auth.getAuthHeaderValueForFirstParty([]);
|
|
353
|
-
r && this.headers.set("Authorization", r),
|
|
353
|
+
r && this.headers.set("Authorization", r), n && this.headers.set("X-Goog-Iam-Authorization-Token", n);
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
356
|
|
|
@@ -359,15 +359,15 @@ n) {
|
|
|
359
359
|
* to authenticate the user, using technique that is only available
|
|
360
360
|
* to applications hosted by Google.
|
|
361
361
|
*/ class Q {
|
|
362
|
-
constructor(t,
|
|
363
|
-
this.t = t, this.i =
|
|
362
|
+
constructor(t, e, n) {
|
|
363
|
+
this.t = t, this.i = e, this.o = n;
|
|
364
364
|
}
|
|
365
365
|
getToken() {
|
|
366
366
|
return Promise.resolve(new G(this.t, this.i, this.o));
|
|
367
367
|
}
|
|
368
|
-
start(t,
|
|
368
|
+
start(t, e) {
|
|
369
369
|
// Fire with initial uid.
|
|
370
|
-
t.enqueueRetryable((() =>
|
|
370
|
+
t.enqueueRetryable((() => e(l.FIRST_PARTY)));
|
|
371
371
|
}
|
|
372
372
|
shutdown() {}
|
|
373
373
|
invalidateToken() {}
|
|
@@ -386,11 +386,11 @@ class W {
|
|
|
386
386
|
}));
|
|
387
387
|
}
|
|
388
388
|
getToken() {
|
|
389
|
-
return this.appCheck ? this.appCheck.getToken().then((t => t ? (
|
|
389
|
+
return this.appCheck ? this.appCheck.getToken().then((t => t ? (v("string" == typeof t.token),
|
|
390
390
|
new W(t.token)) : null)) : Promise.resolve(null);
|
|
391
391
|
}
|
|
392
392
|
invalidateToken() {}
|
|
393
|
-
start(t,
|
|
393
|
+
start(t, e) {}
|
|
394
394
|
shutdown() {}
|
|
395
395
|
}
|
|
396
396
|
|
|
@@ -432,8 +432,8 @@ class H {
|
|
|
432
432
|
* @param useFetchStreams Whether to use the Fetch API instead of
|
|
433
433
|
* XMLHTTPRequest
|
|
434
434
|
*/
|
|
435
|
-
constructor(t,
|
|
436
|
-
this.databaseId = t, this.appId =
|
|
435
|
+
constructor(t, e, n, r, s, i, o, u) {
|
|
436
|
+
this.databaseId = t, this.appId = e, this.persistenceKey = n, this.host = r, this.ssl = s,
|
|
437
437
|
this.forceLongPolling = i, this.autoDetectLongPolling = o, this.useFetchStreams = u;
|
|
438
438
|
}
|
|
439
439
|
}
|
|
@@ -444,8 +444,8 @@ class H {
|
|
|
444
444
|
* @internal
|
|
445
445
|
*/
|
|
446
446
|
class K {
|
|
447
|
-
constructor(t,
|
|
448
|
-
this.projectId = t, this.database =
|
|
447
|
+
constructor(t, e) {
|
|
448
|
+
this.projectId = t, this.database = e || "(default)";
|
|
449
449
|
}
|
|
450
450
|
static empty() {
|
|
451
451
|
return new K("", "");
|
|
@@ -478,9 +478,9 @@ class K {
|
|
|
478
478
|
* Path represents an ordered sequence of string segments.
|
|
479
479
|
*/
|
|
480
480
|
class J {
|
|
481
|
-
constructor(t,
|
|
482
|
-
void 0 ===
|
|
483
|
-
this.segments = t, this.offset =
|
|
481
|
+
constructor(t, e, n) {
|
|
482
|
+
void 0 === e ? e = 0 : e > t.length && g(), void 0 === n ? n = t.length - e : n > t.length - e && g(),
|
|
483
|
+
this.segments = t, this.offset = e, this.len = n;
|
|
484
484
|
}
|
|
485
485
|
get length() {
|
|
486
486
|
return this.len;
|
|
@@ -489,10 +489,10 @@ class J {
|
|
|
489
489
|
return 0 === J.comparator(this, t);
|
|
490
490
|
}
|
|
491
491
|
child(t) {
|
|
492
|
-
const
|
|
492
|
+
const e = this.segments.slice(this.offset, this.limit());
|
|
493
493
|
return t instanceof J ? t.forEach((t => {
|
|
494
|
-
|
|
495
|
-
})) :
|
|
494
|
+
e.push(t);
|
|
495
|
+
})) : e.push(t), this.construct(e);
|
|
496
496
|
}
|
|
497
497
|
/** The index of one past the last segment of the path. */ limit() {
|
|
498
498
|
return this.offset + this.length;
|
|
@@ -517,28 +517,28 @@ class J {
|
|
|
517
517
|
}
|
|
518
518
|
isPrefixOf(t) {
|
|
519
519
|
if (t.length < this.length) return !1;
|
|
520
|
-
for (let
|
|
520
|
+
for (let e = 0; e < this.length; e++) if (this.get(e) !== t.get(e)) return !1;
|
|
521
521
|
return !0;
|
|
522
522
|
}
|
|
523
523
|
isImmediateParentOf(t) {
|
|
524
524
|
if (this.length + 1 !== t.length) return !1;
|
|
525
|
-
for (let
|
|
525
|
+
for (let e = 0; e < this.length; e++) if (this.get(e) !== t.get(e)) return !1;
|
|
526
526
|
return !0;
|
|
527
527
|
}
|
|
528
528
|
forEach(t) {
|
|
529
|
-
for (let
|
|
529
|
+
for (let e = this.offset, n = this.limit(); e < n; e++) t(this.segments[e]);
|
|
530
530
|
}
|
|
531
531
|
toArray() {
|
|
532
532
|
return this.segments.slice(this.offset, this.limit());
|
|
533
533
|
}
|
|
534
|
-
static comparator(t,
|
|
535
|
-
const
|
|
536
|
-
for (let r = 0; r <
|
|
537
|
-
const
|
|
538
|
-
if (
|
|
539
|
-
if (
|
|
534
|
+
static comparator(t, e) {
|
|
535
|
+
const n = Math.min(t.length, e.length);
|
|
536
|
+
for (let r = 0; r < n; r++) {
|
|
537
|
+
const n = t.get(r), s = e.get(r);
|
|
538
|
+
if (n < s) return -1;
|
|
539
|
+
if (n > s) return 1;
|
|
540
540
|
}
|
|
541
|
-
return t.length <
|
|
541
|
+
return t.length < e.length ? -1 : t.length > e.length ? 1 : 0;
|
|
542
542
|
}
|
|
543
543
|
}
|
|
544
544
|
|
|
@@ -548,8 +548,8 @@ class J {
|
|
|
548
548
|
*
|
|
549
549
|
* @internal
|
|
550
550
|
*/ class X extends J {
|
|
551
|
-
construct(t,
|
|
552
|
-
return new X(t,
|
|
551
|
+
construct(t, e, n) {
|
|
552
|
+
return new X(t, e, n);
|
|
553
553
|
}
|
|
554
554
|
canonicalString() {
|
|
555
555
|
// NOTE: The client is ignorant of any path segments containing escape
|
|
@@ -568,13 +568,13 @@ class J {
|
|
|
568
568
|
// NOTE: The client is ignorant of any path segments containing escape
|
|
569
569
|
// sequences (e.g. __id123__) and just passes them through raw (they exist
|
|
570
570
|
// for legacy reasons and should not be used frequently).
|
|
571
|
-
const
|
|
572
|
-
for (const
|
|
573
|
-
if (
|
|
571
|
+
const e = [];
|
|
572
|
+
for (const n of t) {
|
|
573
|
+
if (n.indexOf("//") >= 0) throw new U(A, `Invalid segment (${n}). Paths must not contain // in them.`);
|
|
574
574
|
// Strip leading and traling slashed.
|
|
575
|
-
|
|
575
|
+
e.push(...n.split("/").filter((t => t.length > 0)));
|
|
576
576
|
}
|
|
577
|
-
return new X(
|
|
577
|
+
return new X(e);
|
|
578
578
|
}
|
|
579
579
|
static emptyPath() {
|
|
580
580
|
return new X([]);
|
|
@@ -587,8 +587,8 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
587
587
|
* A dot-separated path for navigating sub-objects within a document.
|
|
588
588
|
* @internal
|
|
589
589
|
*/ class tt extends J {
|
|
590
|
-
construct(t,
|
|
591
|
-
return new tt(t,
|
|
590
|
+
construct(t, e, n) {
|
|
591
|
+
return new tt(t, e, n);
|
|
592
592
|
}
|
|
593
593
|
/**
|
|
594
594
|
* Returns true if the string could be used as a segment in a field path
|
|
@@ -623,24 +623,24 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
623
623
|
* TODO(b/37244157): we should make this more strict. Right now, it allows
|
|
624
624
|
* non-identifier path components, even if they aren't escaped.
|
|
625
625
|
*/ static fromServerFormat(t) {
|
|
626
|
-
const
|
|
627
|
-
let
|
|
626
|
+
const e = [];
|
|
627
|
+
let n = "", r = 0;
|
|
628
628
|
const s = () => {
|
|
629
|
-
if (0 ===
|
|
630
|
-
|
|
629
|
+
if (0 === n.length) throw new U(A, `Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);
|
|
630
|
+
e.push(n), n = "";
|
|
631
631
|
};
|
|
632
632
|
let i = !1;
|
|
633
633
|
for (;r < t.length; ) {
|
|
634
|
-
const
|
|
635
|
-
if ("\\" ===
|
|
634
|
+
const e = t[r];
|
|
635
|
+
if ("\\" === e) {
|
|
636
636
|
if (r + 1 === t.length) throw new U(A, "Path has trailing escape character: " + t);
|
|
637
|
-
const
|
|
638
|
-
if ("\\" !==
|
|
639
|
-
|
|
640
|
-
} else "`" ===
|
|
637
|
+
const e = t[r + 1];
|
|
638
|
+
if ("\\" !== e && "." !== e && "`" !== e) throw new U(A, "Path has invalid escape sequence: " + t);
|
|
639
|
+
n += e, r += 2;
|
|
640
|
+
} else "`" === e ? (i = !i, r++) : "." !== e || i ? (n += e, r++) : (s(), r++);
|
|
641
641
|
}
|
|
642
642
|
if (s(), i) throw new U(A, "Unterminated ` in path: " + t);
|
|
643
|
-
return new tt(
|
|
643
|
+
return new tt(e);
|
|
644
644
|
}
|
|
645
645
|
static emptyPath() {
|
|
646
646
|
return new tt([]);
|
|
@@ -665,30 +665,39 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
665
665
|
*/
|
|
666
666
|
/**
|
|
667
667
|
* @internal
|
|
668
|
-
*/ class
|
|
668
|
+
*/ class et {
|
|
669
669
|
constructor(t) {
|
|
670
670
|
this.path = t;
|
|
671
671
|
}
|
|
672
672
|
static fromPath(t) {
|
|
673
|
-
return new
|
|
673
|
+
return new et(X.fromString(t));
|
|
674
674
|
}
|
|
675
675
|
static fromName(t) {
|
|
676
|
-
return new
|
|
676
|
+
return new et(X.fromString(t).popFirst(5));
|
|
677
677
|
}
|
|
678
678
|
static empty() {
|
|
679
|
-
return new
|
|
679
|
+
return new et(X.emptyPath());
|
|
680
|
+
}
|
|
681
|
+
get collectionGroup() {
|
|
682
|
+
return this.path.popLast().lastSegment();
|
|
680
683
|
}
|
|
681
684
|
/** Returns true if the document is in the specified collectionId. */ hasCollectionId(t) {
|
|
682
685
|
return this.path.length >= 2 && this.path.get(this.path.length - 2) === t;
|
|
683
686
|
}
|
|
687
|
+
/** Returns the collection group (i.e. the name of the parent collection) for this key. */ getCollectionGroup() {
|
|
688
|
+
return this.path.get(this.path.length - 2);
|
|
689
|
+
}
|
|
690
|
+
/** Returns the fully qualified path to the parent collection. */ getCollectionPath() {
|
|
691
|
+
return this.path.popLast();
|
|
692
|
+
}
|
|
684
693
|
isEqual(t) {
|
|
685
694
|
return null !== t && 0 === X.comparator(this.path, t.path);
|
|
686
695
|
}
|
|
687
696
|
toString() {
|
|
688
697
|
return this.path.toString();
|
|
689
698
|
}
|
|
690
|
-
static comparator(t,
|
|
691
|
-
return X.comparator(t.path,
|
|
699
|
+
static comparator(t, e) {
|
|
700
|
+
return X.comparator(t.path, e.path);
|
|
692
701
|
}
|
|
693
702
|
static isDocumentKey(t) {
|
|
694
703
|
return t.length % 2 == 0;
|
|
@@ -699,7 +708,7 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
699
708
|
* @param segments - The segments of the path to the document
|
|
700
709
|
* @returns A new instance of DocumentKey
|
|
701
710
|
*/ static fromSegments(t) {
|
|
702
|
-
return new
|
|
711
|
+
return new et(new X(t.slice()));
|
|
703
712
|
}
|
|
704
713
|
}
|
|
705
714
|
|
|
@@ -718,8 +727,8 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
718
727
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
719
728
|
* See the License for the specific language governing permissions and
|
|
720
729
|
* limitations under the License.
|
|
721
|
-
*/ function
|
|
722
|
-
if (!
|
|
730
|
+
*/ function nt(t, e, n) {
|
|
731
|
+
if (!n) throw new U(A, `Function ${t}() cannot be called with an empty ${e}.`);
|
|
723
732
|
}
|
|
724
733
|
|
|
725
734
|
/**
|
|
@@ -731,14 +740,14 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
731
740
|
* an even numbers of segments).
|
|
732
741
|
*/
|
|
733
742
|
function rt(t) {
|
|
734
|
-
if (!
|
|
743
|
+
if (!et.isDocumentKey(t)) throw new U(A, `Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`);
|
|
735
744
|
}
|
|
736
745
|
|
|
737
746
|
/**
|
|
738
747
|
* Validates that `path` refers to a collection (indicated by the fact it
|
|
739
748
|
* contains an odd numbers of segments).
|
|
740
749
|
*/ function st(t) {
|
|
741
|
-
if (
|
|
750
|
+
if (et.isDocumentKey(t)) throw new U(A, `Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`);
|
|
742
751
|
}
|
|
743
752
|
|
|
744
753
|
/**
|
|
@@ -755,7 +764,7 @@ function it(t) {
|
|
|
755
764
|
if ("object" == typeof t) {
|
|
756
765
|
if (t instanceof Array) return "an array";
|
|
757
766
|
{
|
|
758
|
-
const
|
|
767
|
+
const e =
|
|
759
768
|
/** try to get the constructor name for an object. */
|
|
760
769
|
function(t) {
|
|
761
770
|
if (t.constructor) return t.constructor.name;
|
|
@@ -769,7 +778,7 @@ function it(t) {
|
|
|
769
778
|
* arguments passed to the public API.
|
|
770
779
|
* @internal
|
|
771
780
|
*/ (t);
|
|
772
|
-
return
|
|
781
|
+
return e ? `a custom ${e} object` : "an object";
|
|
773
782
|
}
|
|
774
783
|
}
|
|
775
784
|
return "function" == typeof t ? "a function" : g();
|
|
@@ -777,22 +786,22 @@ function it(t) {
|
|
|
777
786
|
|
|
778
787
|
function ot(t,
|
|
779
788
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
780
|
-
|
|
789
|
+
e) {
|
|
781
790
|
if ("_delegate" in t && (
|
|
782
791
|
// Unwrap Compat types
|
|
783
792
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
784
|
-
t = t._delegate), !(t instanceof
|
|
785
|
-
if (
|
|
793
|
+
t = t._delegate), !(t instanceof e)) {
|
|
794
|
+
if (e.name === t.constructor.name) throw new U(A, "Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");
|
|
786
795
|
{
|
|
787
|
-
const
|
|
788
|
-
throw new U(A, `Expected type '${
|
|
796
|
+
const n = it(t);
|
|
797
|
+
throw new U(A, `Expected type '${e.name}', but it was: ${n}`);
|
|
789
798
|
}
|
|
790
799
|
}
|
|
791
800
|
return t;
|
|
792
801
|
}
|
|
793
802
|
|
|
794
|
-
function ut(t,
|
|
795
|
-
if (
|
|
803
|
+
function ut(t, e) {
|
|
804
|
+
if (e <= 0) throw new U(A, `Function ${t}() requires a positive number, but it was: ${e}.`);
|
|
796
805
|
}
|
|
797
806
|
|
|
798
807
|
/**
|
|
@@ -999,58 +1008,58 @@ class wt extends
|
|
|
999
1008
|
class {
|
|
1000
1009
|
constructor(t) {
|
|
1001
1010
|
this.databaseInfo = t, this.databaseId = t.databaseId;
|
|
1002
|
-
const
|
|
1003
|
-
this.h =
|
|
1011
|
+
const e = t.ssl ? "https" : "http";
|
|
1012
|
+
this.h = e + "://" + t.host, this.l = "projects/" + this.databaseId.projectId + "/databases/" + this.databaseId.database + "/documents";
|
|
1004
1013
|
}
|
|
1005
|
-
m(t,
|
|
1006
|
-
const i = this.p(t,
|
|
1007
|
-
m("RestConnection", "Sending: ", i,
|
|
1014
|
+
m(t, e, n, r, s) {
|
|
1015
|
+
const i = this.p(t, e);
|
|
1016
|
+
m("RestConnection", "Sending: ", i, n);
|
|
1008
1017
|
const o = {};
|
|
1009
|
-
return this.g(o, r, s), this.v(t, i, o,
|
|
1010
|
-
t)), (
|
|
1011
|
-
throw y("RestConnection", `${t} failed with error: `,
|
|
1012
|
-
|
|
1018
|
+
return this.g(o, r, s), this.v(t, i, o, n).then((t => (m("RestConnection", "Received: ", t),
|
|
1019
|
+
t)), (e => {
|
|
1020
|
+
throw y("RestConnection", `${t} failed with error: `, e, "url: ", i, "request:", n),
|
|
1021
|
+
e;
|
|
1013
1022
|
}));
|
|
1014
1023
|
}
|
|
1015
|
-
T(t,
|
|
1024
|
+
T(t, e, n, r, s) {
|
|
1016
1025
|
// The REST API automatically aggregates all of the streamed results, so we
|
|
1017
1026
|
// can just use the normal invoke() method.
|
|
1018
|
-
return this.m(t,
|
|
1027
|
+
return this.m(t, e, n, r, s);
|
|
1019
1028
|
}
|
|
1020
1029
|
/**
|
|
1021
1030
|
* Modifies the headers for a request, adding any authorization token if
|
|
1022
1031
|
* present and any additional headers for the request.
|
|
1023
|
-
*/ g(t,
|
|
1032
|
+
*/ g(t, e, n) {
|
|
1024
1033
|
t["X-Goog-Api-Client"] = "gl-js/ fire/" + f,
|
|
1025
1034
|
// Content-Type: text/plain will avoid preflight requests which might
|
|
1026
1035
|
// mess with CORS and redirects by proxies. If we add custom headers
|
|
1027
1036
|
// we will need to change this code to potentially use the $httpOverwrite
|
|
1028
1037
|
// parameter supported by ESF to avoid triggering preflight requests.
|
|
1029
1038
|
t["Content-Type"] = "text/plain", this.databaseInfo.appId && (t["X-Firebase-GMPID"] = this.databaseInfo.appId),
|
|
1030
|
-
|
|
1039
|
+
e && e.headers.forEach(((e, n) => t[n] = e)), n && n.headers.forEach(((e, n) => t[n] = e));
|
|
1031
1040
|
}
|
|
1032
|
-
p(t,
|
|
1033
|
-
const
|
|
1034
|
-
return `${this.h}/v1/${
|
|
1041
|
+
p(t, e) {
|
|
1042
|
+
const n = ht[t];
|
|
1043
|
+
return `${this.h}/v1/${e}:${n}`;
|
|
1035
1044
|
}
|
|
1036
1045
|
} {
|
|
1037
1046
|
/**
|
|
1038
1047
|
* @param databaseInfo - The connection info.
|
|
1039
1048
|
* @param fetchImpl - `fetch` or a Polyfill that implements the fetch API.
|
|
1040
1049
|
*/
|
|
1041
|
-
constructor(t,
|
|
1042
|
-
super(t), this.I =
|
|
1050
|
+
constructor(t, e) {
|
|
1051
|
+
super(t), this.I = e;
|
|
1043
1052
|
}
|
|
1044
|
-
A(t,
|
|
1053
|
+
A(t, e) {
|
|
1045
1054
|
throw new Error("Not supported by FetchConnection");
|
|
1046
1055
|
}
|
|
1047
|
-
async v(t,
|
|
1056
|
+
async v(t, e, n, r) {
|
|
1048
1057
|
const s = JSON.stringify(r);
|
|
1049
1058
|
let i;
|
|
1050
1059
|
try {
|
|
1051
|
-
i = await this.I(
|
|
1060
|
+
i = await this.I(e, {
|
|
1052
1061
|
method: "POST",
|
|
1053
|
-
headers:
|
|
1062
|
+
headers: n,
|
|
1054
1063
|
body: s
|
|
1055
1064
|
});
|
|
1056
1065
|
} catch (t) {
|
|
@@ -1101,13 +1110,13 @@ class {
|
|
|
1101
1110
|
*/
|
|
1102
1111
|
function mt(t) {
|
|
1103
1112
|
// Polyfills for IE and WebWorker by using `self` and `msCrypto` when `crypto` is not available.
|
|
1104
|
-
const
|
|
1113
|
+
const e =
|
|
1105
1114
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1106
|
-
"undefined" != typeof self && (self.crypto || self.msCrypto),
|
|
1107
|
-
if (
|
|
1115
|
+
"undefined" != typeof self && (self.crypto || self.msCrypto), n = new Uint8Array(t);
|
|
1116
|
+
if (e && "function" == typeof e.getRandomValues) e.getRandomValues(n); else
|
|
1108
1117
|
// Falls back to Math.random
|
|
1109
|
-
for (let
|
|
1110
|
-
return
|
|
1118
|
+
for (let e = 0; e < t; e++) n[e] = Math.floor(256 * Math.random());
|
|
1119
|
+
return n;
|
|
1111
1120
|
}
|
|
1112
1121
|
|
|
1113
1122
|
/**
|
|
@@ -1128,26 +1137,26 @@ function mt(t) {
|
|
|
1128
1137
|
*/ class pt {
|
|
1129
1138
|
static R() {
|
|
1130
1139
|
// Alphanumeric characters
|
|
1131
|
-
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
|
|
1140
|
+
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", e = Math.floor(256 / t.length) * t.length;
|
|
1132
1141
|
// The largest byte value that is a multiple of `char.length`.
|
|
1133
|
-
let
|
|
1134
|
-
for (;
|
|
1142
|
+
let n = "";
|
|
1143
|
+
for (;n.length < 20; ) {
|
|
1135
1144
|
const r = mt(40);
|
|
1136
1145
|
for (let s = 0; s < r.length; ++s)
|
|
1137
1146
|
// Only accept values that are [0, maxMultiple), this ensures they can
|
|
1138
1147
|
// be evenly mapped to indices of `chars` via a modulo operation.
|
|
1139
|
-
|
|
1148
|
+
n.length < 20 && r[s] < e && (n += t.charAt(r[s] % t.length));
|
|
1140
1149
|
}
|
|
1141
|
-
return
|
|
1150
|
+
return n;
|
|
1142
1151
|
}
|
|
1143
1152
|
}
|
|
1144
1153
|
|
|
1145
|
-
function yt(t,
|
|
1146
|
-
return t <
|
|
1154
|
+
function yt(t, e) {
|
|
1155
|
+
return t < e ? -1 : t > e ? 1 : 0;
|
|
1147
1156
|
}
|
|
1148
1157
|
|
|
1149
|
-
/** Helper to compare arrays using isEqual(). */ function _t(t,
|
|
1150
|
-
return t.length ===
|
|
1158
|
+
/** Helper to compare arrays using isEqual(). */ function _t(t, e, n) {
|
|
1159
|
+
return t.length === e.length && t.every(((t, r) => n(t, e[r])));
|
|
1151
1160
|
}
|
|
1152
1161
|
|
|
1153
1162
|
/**
|
|
@@ -1201,9 +1210,9 @@ class gt {
|
|
|
1201
1210
|
/**
|
|
1202
1211
|
* The fractions of a second at nanosecond resolution.*
|
|
1203
1212
|
*/
|
|
1204
|
-
|
|
1205
|
-
if (this.seconds = t, this.nanoseconds =
|
|
1206
|
-
if (
|
|
1213
|
+
e) {
|
|
1214
|
+
if (this.seconds = t, this.nanoseconds = e, e < 0) throw new U(A, "Timestamp nanoseconds out of range: " + e);
|
|
1215
|
+
if (e >= 1e9) throw new U(A, "Timestamp nanoseconds out of range: " + e);
|
|
1207
1216
|
if (t < -62135596800) throw new U(A, "Timestamp seconds out of range: " + t);
|
|
1208
1217
|
// This will break in the year 10,000.
|
|
1209
1218
|
if (t >= 253402300800) throw new U(A, "Timestamp seconds out of range: " + t);
|
|
@@ -1232,8 +1241,8 @@ class gt {
|
|
|
1232
1241
|
* @returns A new `Timestamp` representing the same point in time as the given
|
|
1233
1242
|
* number of milliseconds.
|
|
1234
1243
|
*/ static fromMillis(t) {
|
|
1235
|
-
const
|
|
1236
|
-
return new gt(
|
|
1244
|
+
const e = Math.floor(t / 1e3), n = Math.floor(1e6 * (t - 1e3 * e));
|
|
1245
|
+
return new gt(e, n);
|
|
1237
1246
|
}
|
|
1238
1247
|
/**
|
|
1239
1248
|
* Converts a `Timestamp` to a JavaScript `Date` object. This conversion
|
|
@@ -1311,15 +1320,15 @@ class gt {
|
|
|
1311
1320
|
/**
|
|
1312
1321
|
* A version of a document in Firestore. This corresponds to the version
|
|
1313
1322
|
* timestamp, such as update_time or read_time.
|
|
1314
|
-
*/ class
|
|
1323
|
+
*/ class vt {
|
|
1315
1324
|
constructor(t) {
|
|
1316
1325
|
this.timestamp = t;
|
|
1317
1326
|
}
|
|
1318
1327
|
static fromTimestamp(t) {
|
|
1319
|
-
return new
|
|
1328
|
+
return new vt(t);
|
|
1320
1329
|
}
|
|
1321
1330
|
static min() {
|
|
1322
|
-
return new
|
|
1331
|
+
return new vt(new gt(0, 0));
|
|
1323
1332
|
}
|
|
1324
1333
|
compareTo(t) {
|
|
1325
1334
|
return this.timestamp._compareTo(t.timestamp);
|
|
@@ -1354,14 +1363,14 @@ class gt {
|
|
|
1354
1363
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1355
1364
|
* See the License for the specific language governing permissions and
|
|
1356
1365
|
* limitations under the License.
|
|
1357
|
-
*/ function
|
|
1358
|
-
let
|
|
1359
|
-
for (const
|
|
1360
|
-
return
|
|
1366
|
+
*/ function bt(t) {
|
|
1367
|
+
let e = 0;
|
|
1368
|
+
for (const n in t) Object.prototype.hasOwnProperty.call(t, n) && e++;
|
|
1369
|
+
return e;
|
|
1361
1370
|
}
|
|
1362
1371
|
|
|
1363
|
-
function Et(t,
|
|
1364
|
-
for (const
|
|
1372
|
+
function Et(t, e) {
|
|
1373
|
+
for (const n in t) Object.prototype.hasOwnProperty.call(t, n) && e(n, t[n]);
|
|
1365
1374
|
}
|
|
1366
1375
|
|
|
1367
1376
|
/**
|
|
@@ -1403,11 +1412,11 @@ class Tt {
|
|
|
1403
1412
|
*
|
|
1404
1413
|
* This is an O(n) operation, where `n` is the size of the field mask.
|
|
1405
1414
|
*/ covers(t) {
|
|
1406
|
-
for (const
|
|
1415
|
+
for (const e of this.fields) if (e.isPrefixOf(t)) return !0;
|
|
1407
1416
|
return !1;
|
|
1408
1417
|
}
|
|
1409
1418
|
isEqual(t) {
|
|
1410
|
-
return _t(this.fields, t.fields, ((t,
|
|
1419
|
+
return _t(this.fields, t.fields, ((t, e) => t.isEqual(e)));
|
|
1411
1420
|
}
|
|
1412
1421
|
}
|
|
1413
1422
|
|
|
@@ -1458,23 +1467,23 @@ class It {
|
|
|
1458
1467
|
this.binaryString = t;
|
|
1459
1468
|
}
|
|
1460
1469
|
static fromBase64String(t) {
|
|
1461
|
-
const
|
|
1462
|
-
return new It(
|
|
1470
|
+
const e = atob(t);
|
|
1471
|
+
return new It(e);
|
|
1463
1472
|
}
|
|
1464
1473
|
static fromUint8Array(t) {
|
|
1465
|
-
const
|
|
1474
|
+
const e =
|
|
1466
1475
|
/**
|
|
1467
1476
|
* Helper function to convert an Uint8array to a binary string.
|
|
1468
1477
|
*/
|
|
1469
1478
|
function(t) {
|
|
1470
|
-
let
|
|
1471
|
-
for (let
|
|
1472
|
-
return
|
|
1479
|
+
let e = "";
|
|
1480
|
+
for (let n = 0; n < t.length; ++n) e += String.fromCharCode(t[n]);
|
|
1481
|
+
return e;
|
|
1473
1482
|
}
|
|
1474
1483
|
/**
|
|
1475
1484
|
* Helper function to convert a binary string to an Uint8Array.
|
|
1476
1485
|
*/ (t);
|
|
1477
|
-
return new It(
|
|
1486
|
+
return new It(e);
|
|
1478
1487
|
}
|
|
1479
1488
|
[Symbol.iterator]() {
|
|
1480
1489
|
let t = 0;
|
|
@@ -1495,9 +1504,9 @@ class It {
|
|
|
1495
1504
|
}
|
|
1496
1505
|
toUint8Array() {
|
|
1497
1506
|
return function(t) {
|
|
1498
|
-
const
|
|
1499
|
-
for (let
|
|
1500
|
-
return
|
|
1507
|
+
const e = new Uint8Array(t.length);
|
|
1508
|
+
for (let n = 0; n < t.length; n++) e[n] = t.charCodeAt(n);
|
|
1509
|
+
return e;
|
|
1501
1510
|
}
|
|
1502
1511
|
/**
|
|
1503
1512
|
* @license
|
|
@@ -1540,22 +1549,22 @@ const At = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1540
1549
|
// The json interface (for the browser) will return an iso timestamp string,
|
|
1541
1550
|
// while the proto js library (for node) will return a
|
|
1542
1551
|
// google.protobuf.Timestamp instance.
|
|
1543
|
-
if (
|
|
1552
|
+
if (v(!!t), "string" == typeof t) {
|
|
1544
1553
|
// The date string can have higher precision (nanos) than the Date class
|
|
1545
1554
|
// (millis), so we do some custom parsing here.
|
|
1546
1555
|
// Parse the nanos right out of the string.
|
|
1547
|
-
let
|
|
1548
|
-
const
|
|
1549
|
-
if (
|
|
1556
|
+
let e = 0;
|
|
1557
|
+
const n = At.exec(t);
|
|
1558
|
+
if (v(!!n), n[1]) {
|
|
1550
1559
|
// Pad the fraction out to 9 digits (nanos).
|
|
1551
|
-
let t =
|
|
1552
|
-
t = (t + "000000000").substr(0, 9),
|
|
1560
|
+
let t = n[1];
|
|
1561
|
+
t = (t + "000000000").substr(0, 9), e = Number(t);
|
|
1553
1562
|
}
|
|
1554
1563
|
// Parse the date to get the seconds.
|
|
1555
1564
|
const r = new Date(t);
|
|
1556
1565
|
return {
|
|
1557
1566
|
seconds: Math.floor(r.getTime() / 1e3),
|
|
1558
|
-
nanos:
|
|
1567
|
+
nanos: e
|
|
1559
1568
|
};
|
|
1560
1569
|
}
|
|
1561
1570
|
return {
|
|
@@ -1610,8 +1619,8 @@ const At = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1610
1619
|
* - With respect to other ServerTimestampValues, they sort by their
|
|
1611
1620
|
* localWriteTime.
|
|
1612
1621
|
*/ function Dt(t) {
|
|
1613
|
-
var
|
|
1614
|
-
return "server_timestamp" === (null === (
|
|
1622
|
+
var e, n;
|
|
1623
|
+
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);
|
|
1615
1624
|
}
|
|
1616
1625
|
|
|
1617
1626
|
/**
|
|
@@ -1620,15 +1629,15 @@ const At = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1620
1629
|
* Preserving the previous values allows the user to display the last resoled
|
|
1621
1630
|
* value until the backend responds with the timestamp.
|
|
1622
1631
|
*/ function Nt(t) {
|
|
1623
|
-
const
|
|
1624
|
-
return Dt(
|
|
1632
|
+
const e = t.mapValue.fields.__previous_value__;
|
|
1633
|
+
return Dt(e) ? Nt(e) : e;
|
|
1625
1634
|
}
|
|
1626
1635
|
|
|
1627
1636
|
/**
|
|
1628
1637
|
* Returns the local time at which this timestamp was first set.
|
|
1629
1638
|
*/ function $t(t) {
|
|
1630
|
-
const
|
|
1631
|
-
return new gt(
|
|
1639
|
+
const e = Rt(t.mapValue.fields.__local_write_time__.timestampValue);
|
|
1640
|
+
return new gt(e.seconds, e.nanos);
|
|
1632
1641
|
}
|
|
1633
1642
|
|
|
1634
1643
|
/**
|
|
@@ -1651,169 +1660,169 @@ const At = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1651
1660
|
return "nullValue" in t ? 0 /* NullValue */ : "booleanValue" in t ? 1 /* BooleanValue */ : "integerValue" in t || "doubleValue" in t ? 2 /* NumberValue */ : "timestampValue" in t ? 3 /* TimestampValue */ : "stringValue" in t ? 5 /* StringValue */ : "bytesValue" in t ? 6 /* BlobValue */ : "referenceValue" in t ? 7 /* RefValue */ : "geoPointValue" in t ? 8 /* GeoPointValue */ : "arrayValue" in t ? 9 /* ArrayValue */ : "mapValue" in t ? Dt(t) ? 4 /* ServerTimestampValue */ : 10 /* ObjectValue */ : g();
|
|
1652
1661
|
}
|
|
1653
1662
|
|
|
1654
|
-
/** Tests `left` and `right` for equality based on the backend semantics. */ function Ft(t,
|
|
1655
|
-
if (t ===
|
|
1656
|
-
const
|
|
1657
|
-
if (
|
|
1658
|
-
switch (
|
|
1663
|
+
/** Tests `left` and `right` for equality based on the backend semantics. */ function Ft(t, e) {
|
|
1664
|
+
if (t === e) return !0;
|
|
1665
|
+
const n = St(t);
|
|
1666
|
+
if (n !== St(e)) return !1;
|
|
1667
|
+
switch (n) {
|
|
1659
1668
|
case 0 /* NullValue */ :
|
|
1660
1669
|
return !0;
|
|
1661
1670
|
|
|
1662
1671
|
case 1 /* BooleanValue */ :
|
|
1663
|
-
return t.booleanValue ===
|
|
1672
|
+
return t.booleanValue === e.booleanValue;
|
|
1664
1673
|
|
|
1665
1674
|
case 4 /* ServerTimestampValue */ :
|
|
1666
|
-
return $t(t).isEqual($t(
|
|
1675
|
+
return $t(t).isEqual($t(e));
|
|
1667
1676
|
|
|
1668
1677
|
case 3 /* TimestampValue */ :
|
|
1669
|
-
return function(t,
|
|
1670
|
-
if ("string" == typeof t.timestampValue && "string" == typeof
|
|
1678
|
+
return function(t, e) {
|
|
1679
|
+
if ("string" == typeof t.timestampValue && "string" == typeof e.timestampValue && t.timestampValue.length === e.timestampValue.length)
|
|
1671
1680
|
// Use string equality for ISO 8601 timestamps
|
|
1672
|
-
return t.timestampValue ===
|
|
1673
|
-
const
|
|
1674
|
-
return
|
|
1675
|
-
}(t,
|
|
1681
|
+
return t.timestampValue === e.timestampValue;
|
|
1682
|
+
const n = Rt(t.timestampValue), r = Rt(e.timestampValue);
|
|
1683
|
+
return n.seconds === r.seconds && n.nanos === r.nanos;
|
|
1684
|
+
}(t, e);
|
|
1676
1685
|
|
|
1677
1686
|
case 5 /* StringValue */ :
|
|
1678
|
-
return t.stringValue ===
|
|
1687
|
+
return t.stringValue === e.stringValue;
|
|
1679
1688
|
|
|
1680
1689
|
case 6 /* BlobValue */ :
|
|
1681
|
-
return function(t,
|
|
1682
|
-
return Vt(t.bytesValue).isEqual(Vt(
|
|
1683
|
-
}(t,
|
|
1690
|
+
return function(t, e) {
|
|
1691
|
+
return Vt(t.bytesValue).isEqual(Vt(e.bytesValue));
|
|
1692
|
+
}(t, e);
|
|
1684
1693
|
|
|
1685
1694
|
case 7 /* RefValue */ :
|
|
1686
|
-
return t.referenceValue ===
|
|
1695
|
+
return t.referenceValue === e.referenceValue;
|
|
1687
1696
|
|
|
1688
1697
|
case 8 /* GeoPointValue */ :
|
|
1689
|
-
return function(t,
|
|
1690
|
-
return Pt(t.geoPointValue.latitude) === Pt(
|
|
1691
|
-
}(t,
|
|
1698
|
+
return function(t, e) {
|
|
1699
|
+
return Pt(t.geoPointValue.latitude) === Pt(e.geoPointValue.latitude) && Pt(t.geoPointValue.longitude) === Pt(e.geoPointValue.longitude);
|
|
1700
|
+
}(t, e);
|
|
1692
1701
|
|
|
1693
1702
|
case 2 /* NumberValue */ :
|
|
1694
|
-
return function(t,
|
|
1695
|
-
if ("integerValue" in t && "integerValue" in
|
|
1696
|
-
if ("doubleValue" in t && "doubleValue" in
|
|
1697
|
-
const
|
|
1698
|
-
return
|
|
1703
|
+
return function(t, e) {
|
|
1704
|
+
if ("integerValue" in t && "integerValue" in e) return Pt(t.integerValue) === Pt(e.integerValue);
|
|
1705
|
+
if ("doubleValue" in t && "doubleValue" in e) {
|
|
1706
|
+
const n = Pt(t.doubleValue), r = Pt(e.doubleValue);
|
|
1707
|
+
return n === r ? at(n) === at(r) : isNaN(n) && isNaN(r);
|
|
1699
1708
|
}
|
|
1700
1709
|
return !1;
|
|
1701
|
-
}(t,
|
|
1710
|
+
}(t, e);
|
|
1702
1711
|
|
|
1703
1712
|
case 9 /* ArrayValue */ :
|
|
1704
|
-
return _t(t.arrayValue.values || [],
|
|
1713
|
+
return _t(t.arrayValue.values || [], e.arrayValue.values || [], Ft);
|
|
1705
1714
|
|
|
1706
1715
|
case 10 /* ObjectValue */ :
|
|
1707
|
-
return function(t,
|
|
1708
|
-
const
|
|
1709
|
-
if (
|
|
1710
|
-
for (const t in
|
|
1716
|
+
return function(t, e) {
|
|
1717
|
+
const n = t.mapValue.fields || {}, r = e.mapValue.fields || {};
|
|
1718
|
+
if (bt(n) !== bt(r)) return !1;
|
|
1719
|
+
for (const t in n) if (n.hasOwnProperty(t) && (void 0 === r[t] || !Ft(n[t], r[t]))) return !1;
|
|
1711
1720
|
return !0;
|
|
1712
1721
|
}
|
|
1713
|
-
/** Returns true if the ArrayValue contains the specified element. */ (t,
|
|
1722
|
+
/** Returns true if the ArrayValue contains the specified element. */ (t, e);
|
|
1714
1723
|
|
|
1715
1724
|
default:
|
|
1716
1725
|
return g();
|
|
1717
1726
|
}
|
|
1718
1727
|
}
|
|
1719
1728
|
|
|
1720
|
-
function xt(t,
|
|
1721
|
-
return void 0 !== (t.values || []).find((t => Ft(t,
|
|
1729
|
+
function xt(t, e) {
|
|
1730
|
+
return void 0 !== (t.values || []).find((t => Ft(t, e)));
|
|
1722
1731
|
}
|
|
1723
1732
|
|
|
1724
|
-
function qt(t,
|
|
1725
|
-
if (t ===
|
|
1726
|
-
const
|
|
1727
|
-
if (
|
|
1728
|
-
switch (
|
|
1733
|
+
function qt(t, e) {
|
|
1734
|
+
if (t === e) return 0;
|
|
1735
|
+
const n = St(t), r = St(e);
|
|
1736
|
+
if (n !== r) return yt(n, r);
|
|
1737
|
+
switch (n) {
|
|
1729
1738
|
case 0 /* NullValue */ :
|
|
1730
1739
|
return 0;
|
|
1731
1740
|
|
|
1732
1741
|
case 1 /* BooleanValue */ :
|
|
1733
|
-
return yt(t.booleanValue,
|
|
1742
|
+
return yt(t.booleanValue, e.booleanValue);
|
|
1734
1743
|
|
|
1735
1744
|
case 2 /* NumberValue */ :
|
|
1736
|
-
return function(t,
|
|
1737
|
-
const
|
|
1738
|
-
return
|
|
1745
|
+
return function(t, e) {
|
|
1746
|
+
const n = Pt(t.integerValue || t.doubleValue), r = Pt(e.integerValue || e.doubleValue);
|
|
1747
|
+
return n < r ? -1 : n > r ? 1 : n === r ? 0 :
|
|
1739
1748
|
// one or both are NaN.
|
|
1740
|
-
isNaN(
|
|
1741
|
-
}(t,
|
|
1749
|
+
isNaN(n) ? isNaN(r) ? 0 : -1 : 1;
|
|
1750
|
+
}(t, e);
|
|
1742
1751
|
|
|
1743
1752
|
case 3 /* TimestampValue */ :
|
|
1744
|
-
return Ot(t.timestampValue,
|
|
1753
|
+
return Ot(t.timestampValue, e.timestampValue);
|
|
1745
1754
|
|
|
1746
1755
|
case 4 /* ServerTimestampValue */ :
|
|
1747
|
-
return Ot($t(t), $t(
|
|
1756
|
+
return Ot($t(t), $t(e));
|
|
1748
1757
|
|
|
1749
1758
|
case 5 /* StringValue */ :
|
|
1750
|
-
return yt(t.stringValue,
|
|
1759
|
+
return yt(t.stringValue, e.stringValue);
|
|
1751
1760
|
|
|
1752
1761
|
case 6 /* BlobValue */ :
|
|
1753
|
-
return function(t,
|
|
1754
|
-
const
|
|
1755
|
-
return
|
|
1756
|
-
}(t.bytesValue,
|
|
1762
|
+
return function(t, e) {
|
|
1763
|
+
const n = Vt(t), r = Vt(e);
|
|
1764
|
+
return n.compareTo(r);
|
|
1765
|
+
}(t.bytesValue, e.bytesValue);
|
|
1757
1766
|
|
|
1758
1767
|
case 7 /* RefValue */ :
|
|
1759
|
-
return function(t,
|
|
1760
|
-
const
|
|
1761
|
-
for (let t = 0; t <
|
|
1762
|
-
const
|
|
1763
|
-
if (0 !==
|
|
1768
|
+
return function(t, e) {
|
|
1769
|
+
const n = t.split("/"), r = e.split("/");
|
|
1770
|
+
for (let t = 0; t < n.length && t < r.length; t++) {
|
|
1771
|
+
const e = yt(n[t], r[t]);
|
|
1772
|
+
if (0 !== e) return e;
|
|
1764
1773
|
}
|
|
1765
|
-
return yt(
|
|
1766
|
-
}(t.referenceValue,
|
|
1774
|
+
return yt(n.length, r.length);
|
|
1775
|
+
}(t.referenceValue, e.referenceValue);
|
|
1767
1776
|
|
|
1768
1777
|
case 8 /* GeoPointValue */ :
|
|
1769
|
-
return function(t,
|
|
1770
|
-
const
|
|
1771
|
-
if (0 !==
|
|
1772
|
-
return yt(Pt(t.longitude), Pt(
|
|
1773
|
-
}(t.geoPointValue,
|
|
1778
|
+
return function(t, e) {
|
|
1779
|
+
const n = yt(Pt(t.latitude), Pt(e.latitude));
|
|
1780
|
+
if (0 !== n) return n;
|
|
1781
|
+
return yt(Pt(t.longitude), Pt(e.longitude));
|
|
1782
|
+
}(t.geoPointValue, e.geoPointValue);
|
|
1774
1783
|
|
|
1775
1784
|
case 9 /* ArrayValue */ :
|
|
1776
|
-
return function(t,
|
|
1777
|
-
const
|
|
1778
|
-
for (let t = 0; t <
|
|
1779
|
-
const
|
|
1780
|
-
if (
|
|
1785
|
+
return function(t, e) {
|
|
1786
|
+
const n = t.values || [], r = e.values || [];
|
|
1787
|
+
for (let t = 0; t < n.length && t < r.length; ++t) {
|
|
1788
|
+
const e = qt(n[t], r[t]);
|
|
1789
|
+
if (e) return e;
|
|
1781
1790
|
}
|
|
1782
|
-
return yt(
|
|
1783
|
-
}(t.arrayValue,
|
|
1791
|
+
return yt(n.length, r.length);
|
|
1792
|
+
}(t.arrayValue, e.arrayValue);
|
|
1784
1793
|
|
|
1785
1794
|
case 10 /* ObjectValue */ :
|
|
1786
|
-
return function(t,
|
|
1787
|
-
const
|
|
1795
|
+
return function(t, e) {
|
|
1796
|
+
const n = t.fields || {}, r = Object.keys(n), s = e.fields || {}, i = Object.keys(s);
|
|
1788
1797
|
// Even though MapValues are likely sorted correctly based on their insertion
|
|
1789
1798
|
// order (e.g. when received from the backend), local modifications can bring
|
|
1790
1799
|
// elements out of order. We need to re-sort the elements to ensure that
|
|
1791
1800
|
// canonical IDs are independent of insertion order.
|
|
1792
1801
|
r.sort(), i.sort();
|
|
1793
1802
|
for (let t = 0; t < r.length && t < i.length; ++t) {
|
|
1794
|
-
const
|
|
1795
|
-
if (0 !==
|
|
1796
|
-
const o = qt(
|
|
1803
|
+
const e = yt(r[t], i[t]);
|
|
1804
|
+
if (0 !== e) return e;
|
|
1805
|
+
const o = qt(n[r[t]], s[i[t]]);
|
|
1797
1806
|
if (0 !== o) return o;
|
|
1798
1807
|
}
|
|
1799
1808
|
return yt(r.length, i.length);
|
|
1800
1809
|
}
|
|
1801
|
-
/** Returns a reference value for the provided database and key. */ (t.mapValue,
|
|
1810
|
+
/** Returns a reference value for the provided database and key. */ (t.mapValue, e.mapValue);
|
|
1802
1811
|
|
|
1803
1812
|
default:
|
|
1804
1813
|
throw g();
|
|
1805
1814
|
}
|
|
1806
1815
|
}
|
|
1807
1816
|
|
|
1808
|
-
function Ot(t,
|
|
1809
|
-
if ("string" == typeof t && "string" == typeof
|
|
1810
|
-
const
|
|
1811
|
-
return 0 !== s ? s : yt(
|
|
1817
|
+
function Ot(t, e) {
|
|
1818
|
+
if ("string" == typeof t && "string" == typeof e && t.length === e.length) return yt(t, e);
|
|
1819
|
+
const n = Rt(t), r = Rt(e), s = yt(n.seconds, r.seconds);
|
|
1820
|
+
return 0 !== s ? s : yt(n.nanos, r.nanos);
|
|
1812
1821
|
}
|
|
1813
1822
|
|
|
1814
|
-
function Ct(t,
|
|
1823
|
+
function Ct(t, e) {
|
|
1815
1824
|
return {
|
|
1816
|
-
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${
|
|
1825
|
+
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${e.path.canonicalString()}`
|
|
1817
1826
|
};
|
|
1818
1827
|
}
|
|
1819
1828
|
|
|
@@ -1841,21 +1850,21 @@ function Ct(t, n) {
|
|
|
1841
1850
|
timestampValue: Object.assign({}, t.timestampValue)
|
|
1842
1851
|
};
|
|
1843
1852
|
if (t.mapValue) {
|
|
1844
|
-
const
|
|
1853
|
+
const e = {
|
|
1845
1854
|
mapValue: {
|
|
1846
1855
|
fields: {}
|
|
1847
1856
|
}
|
|
1848
1857
|
};
|
|
1849
|
-
return Et(t.mapValue.fields, ((t,
|
|
1858
|
+
return Et(t.mapValue.fields, ((t, n) => e.mapValue.fields[t] = Mt(n))), e;
|
|
1850
1859
|
}
|
|
1851
1860
|
if (t.arrayValue) {
|
|
1852
|
-
const
|
|
1861
|
+
const e = {
|
|
1853
1862
|
arrayValue: {
|
|
1854
1863
|
values: []
|
|
1855
1864
|
}
|
|
1856
1865
|
};
|
|
1857
|
-
for (let
|
|
1858
|
-
return
|
|
1866
|
+
for (let n = 0; n < (t.arrayValue.values || []).length; ++n) e.arrayValue.values[n] = Mt(t.arrayValue.values[n]);
|
|
1867
|
+
return e;
|
|
1859
1868
|
}
|
|
1860
1869
|
return Object.assign({}, t);
|
|
1861
1870
|
}
|
|
@@ -1896,10 +1905,10 @@ function Ct(t, n) {
|
|
|
1896
1905
|
*/ field(t) {
|
|
1897
1906
|
if (t.isEmpty()) return this.value;
|
|
1898
1907
|
{
|
|
1899
|
-
let
|
|
1900
|
-
for (let
|
|
1901
|
-
!jt(
|
|
1902
|
-
return
|
|
1908
|
+
let e = this.value;
|
|
1909
|
+
for (let n = 0; n < t.length - 1; ++n) if (e = (e.mapValue.fields || {})[t.get(n)],
|
|
1910
|
+
!jt(e)) return null;
|
|
1911
|
+
return e = (e.mapValue.fields || {})[t.lastSegment()], e || null;
|
|
1903
1912
|
}
|
|
1904
1913
|
}
|
|
1905
1914
|
/**
|
|
@@ -1907,25 +1916,25 @@ function Ct(t, n) {
|
|
|
1907
1916
|
*
|
|
1908
1917
|
* @param path - The field path to set.
|
|
1909
1918
|
* @param value - The value to set.
|
|
1910
|
-
*/ set(t,
|
|
1911
|
-
this.getFieldsMap(t.popLast())[t.lastSegment()] = Mt(
|
|
1919
|
+
*/ set(t, e) {
|
|
1920
|
+
this.getFieldsMap(t.popLast())[t.lastSegment()] = Mt(e);
|
|
1912
1921
|
}
|
|
1913
1922
|
/**
|
|
1914
1923
|
* Sets the provided fields to the provided values.
|
|
1915
1924
|
*
|
|
1916
1925
|
* @param data - A map of fields to values (or null for deletes).
|
|
1917
1926
|
*/ setAll(t) {
|
|
1918
|
-
let
|
|
1927
|
+
let e = tt.emptyPath(), n = {}, r = [];
|
|
1919
1928
|
t.forEach(((t, s) => {
|
|
1920
|
-
if (!
|
|
1929
|
+
if (!e.isImmediateParentOf(s)) {
|
|
1921
1930
|
// Insert the accumulated changes at this parent location
|
|
1922
|
-
const t = this.getFieldsMap(
|
|
1923
|
-
this.applyChanges(t,
|
|
1931
|
+
const t = this.getFieldsMap(e);
|
|
1932
|
+
this.applyChanges(t, n, r), n = {}, r = [], e = s.popLast();
|
|
1924
1933
|
}
|
|
1925
|
-
t ?
|
|
1934
|
+
t ? n[s.lastSegment()] = Mt(t) : r.push(s.lastSegment());
|
|
1926
1935
|
}));
|
|
1927
|
-
const s = this.getFieldsMap(
|
|
1928
|
-
this.applyChanges(s,
|
|
1936
|
+
const s = this.getFieldsMap(e);
|
|
1937
|
+
this.applyChanges(s, n, r);
|
|
1929
1938
|
}
|
|
1930
1939
|
/**
|
|
1931
1940
|
* Removes the field at the specified path. If there is no field at the
|
|
@@ -1933,8 +1942,8 @@ function Ct(t, n) {
|
|
|
1933
1942
|
*
|
|
1934
1943
|
* @param path - The field path to remove.
|
|
1935
1944
|
*/ delete(t) {
|
|
1936
|
-
const
|
|
1937
|
-
jt(
|
|
1945
|
+
const e = this.field(t.popLast());
|
|
1946
|
+
jt(e) && e.mapValue.fields && delete e.mapValue.fields[t.lastSegment()];
|
|
1938
1947
|
}
|
|
1939
1948
|
isEqual(t) {
|
|
1940
1949
|
return Ft(this.value, t.value);
|
|
@@ -1943,26 +1952,26 @@ function Ct(t, n) {
|
|
|
1943
1952
|
* Returns the map that contains the leaf element of `path`. If the parent
|
|
1944
1953
|
* entry does not yet exist, or if it is not a map, a new map will be created.
|
|
1945
1954
|
*/ getFieldsMap(t) {
|
|
1946
|
-
let
|
|
1947
|
-
|
|
1955
|
+
let e = this.value;
|
|
1956
|
+
e.mapValue.fields || (e.mapValue = {
|
|
1948
1957
|
fields: {}
|
|
1949
1958
|
});
|
|
1950
|
-
for (let
|
|
1951
|
-
let r =
|
|
1959
|
+
for (let n = 0; n < t.length; ++n) {
|
|
1960
|
+
let r = e.mapValue.fields[t.get(n)];
|
|
1952
1961
|
jt(r) && r.mapValue.fields || (r = {
|
|
1953
1962
|
mapValue: {
|
|
1954
1963
|
fields: {}
|
|
1955
1964
|
}
|
|
1956
|
-
},
|
|
1965
|
+
}, e.mapValue.fields[t.get(n)] = r), e = r;
|
|
1957
1966
|
}
|
|
1958
|
-
return
|
|
1967
|
+
return e.mapValue.fields;
|
|
1959
1968
|
}
|
|
1960
1969
|
/**
|
|
1961
1970
|
* Modifies `fieldsMap` by adding, replacing or deleting the specified
|
|
1962
1971
|
* entries.
|
|
1963
|
-
*/ applyChanges(t,
|
|
1964
|
-
Et(
|
|
1965
|
-
for (const
|
|
1972
|
+
*/ applyChanges(t, e, n) {
|
|
1973
|
+
Et(e, ((e, n) => t[e] = n));
|
|
1974
|
+
for (const e of n) delete t[e];
|
|
1966
1975
|
}
|
|
1967
1976
|
clone() {
|
|
1968
1977
|
return new Bt(Mt(this.value));
|
|
@@ -1995,37 +2004,37 @@ function Ct(t, n) {
|
|
|
1995
2004
|
* applied, `isValidDocument()` returns false and the document should be removed
|
|
1996
2005
|
* from all views.
|
|
1997
2006
|
*/ class zt {
|
|
1998
|
-
constructor(t,
|
|
1999
|
-
this.key = t, this.documentType =
|
|
2007
|
+
constructor(t, e, n, r, s, i) {
|
|
2008
|
+
this.key = t, this.documentType = e, this.version = n, this.readTime = r, this.data = s,
|
|
2000
2009
|
this.documentState = i;
|
|
2001
2010
|
}
|
|
2002
2011
|
/**
|
|
2003
2012
|
* Creates a document with no known version or data, but which can serve as
|
|
2004
2013
|
* base document for mutations.
|
|
2005
2014
|
*/ static newInvalidDocument(t) {
|
|
2006
|
-
return new zt(t, 0 /* INVALID */ ,
|
|
2015
|
+
return new zt(t, 0 /* INVALID */ , vt.min(), vt.min(), Bt.empty(), 0 /* SYNCED */);
|
|
2007
2016
|
}
|
|
2008
2017
|
/**
|
|
2009
2018
|
* Creates a new document that is known to exist with the given data at the
|
|
2010
2019
|
* given version.
|
|
2011
|
-
*/ static newFoundDocument(t,
|
|
2012
|
-
return new zt(t, 1 /* FOUND_DOCUMENT */ ,
|
|
2020
|
+
*/ static newFoundDocument(t, e, n) {
|
|
2021
|
+
return new zt(t, 1 /* FOUND_DOCUMENT */ , e, vt.min(), n, 0 /* SYNCED */);
|
|
2013
2022
|
}
|
|
2014
|
-
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t,
|
|
2015
|
-
return new zt(t, 2 /* NO_DOCUMENT */ ,
|
|
2023
|
+
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t, e) {
|
|
2024
|
+
return new zt(t, 2 /* NO_DOCUMENT */ , e, vt.min(), Bt.empty(), 0 /* SYNCED */);
|
|
2016
2025
|
}
|
|
2017
2026
|
/**
|
|
2018
2027
|
* Creates a new document that is known to exist at the given version but
|
|
2019
2028
|
* whose data is not known (e.g. a document that was updated without a known
|
|
2020
2029
|
* base document).
|
|
2021
|
-
*/ static newUnknownDocument(t,
|
|
2022
|
-
return new zt(t, 3 /* UNKNOWN_DOCUMENT */ ,
|
|
2030
|
+
*/ static newUnknownDocument(t, e) {
|
|
2031
|
+
return new zt(t, 3 /* UNKNOWN_DOCUMENT */ , e, vt.min(), Bt.empty(), 2 /* HAS_COMMITTED_MUTATIONS */);
|
|
2023
2032
|
}
|
|
2024
2033
|
/**
|
|
2025
2034
|
* Changes the document type to indicate that it exists and that its version
|
|
2026
2035
|
* and data are known.
|
|
2027
|
-
*/ convertToFoundDocument(t,
|
|
2028
|
-
return this.version = t, this.documentType = 1 /* FOUND_DOCUMENT */ , this.data =
|
|
2036
|
+
*/ convertToFoundDocument(t, e) {
|
|
2037
|
+
return this.version = t, this.documentType = 1 /* FOUND_DOCUMENT */ , this.data = e,
|
|
2029
2038
|
this.documentState = 0 /* SYNCED */ , this;
|
|
2030
2039
|
}
|
|
2031
2040
|
/**
|
|
@@ -2102,8 +2111,8 @@ function Ct(t, n) {
|
|
|
2102
2111
|
*/
|
|
2103
2112
|
// Visible for testing
|
|
2104
2113
|
class Gt {
|
|
2105
|
-
constructor(t,
|
|
2106
|
-
this.path = t, this.collectionGroup =
|
|
2114
|
+
constructor(t, e = null, n = [], r = [], s = null, i = null, o = null) {
|
|
2115
|
+
this.path = t, this.collectionGroup = e, this.orderBy = n, this.filters = r, this.limit = s,
|
|
2107
2116
|
this.startAt = i, this.endAt = o, this.P = null;
|
|
2108
2117
|
}
|
|
2109
2118
|
}
|
|
@@ -2115,26 +2124,26 @@ class Gt {
|
|
|
2115
2124
|
* NOTE: you should always construct `Target` from `Query.toTarget` instead of
|
|
2116
2125
|
* using this factory method, because `Query` provides an implicit `orderBy`
|
|
2117
2126
|
* property.
|
|
2118
|
-
*/ function Qt(t,
|
|
2119
|
-
return new Gt(t,
|
|
2127
|
+
*/ function Qt(t, e = null, n = [], r = [], s = null, i = null, o = null) {
|
|
2128
|
+
return new Gt(t, e, n, r, s, i, o);
|
|
2120
2129
|
}
|
|
2121
2130
|
|
|
2122
2131
|
class Wt extends class {} {
|
|
2123
|
-
constructor(t,
|
|
2124
|
-
super(), this.field = t, this.op =
|
|
2132
|
+
constructor(t, e, n) {
|
|
2133
|
+
super(), this.field = t, this.op = e, this.value = n;
|
|
2125
2134
|
}
|
|
2126
2135
|
/**
|
|
2127
2136
|
* Creates a filter based on the provided arguments.
|
|
2128
|
-
*/ static create(t,
|
|
2129
|
-
return t.isKeyField() ? "in" /* IN */ ===
|
|
2137
|
+
*/ static create(t, e, n) {
|
|
2138
|
+
return t.isKeyField() ? "in" /* IN */ === e || "not-in" /* NOT_IN */ === e ? this.V(t, e, n) : new Yt(t, e, n) : "array-contains" /* ARRAY_CONTAINS */ === e ? new Xt(t, n) : "in" /* IN */ === e ? new Zt(t, n) : "not-in" /* NOT_IN */ === e ? new te(t, n) : "array-contains-any" /* ARRAY_CONTAINS_ANY */ === e ? new ee(t, n) : new Wt(t, e, n);
|
|
2130
2139
|
}
|
|
2131
|
-
static V(t,
|
|
2132
|
-
return "in" /* IN */ ===
|
|
2140
|
+
static V(t, e, n) {
|
|
2141
|
+
return "in" /* IN */ === e ? new Ht(t, n) : new Kt(t, n);
|
|
2133
2142
|
}
|
|
2134
2143
|
matches(t) {
|
|
2135
|
-
const
|
|
2144
|
+
const e = t.data.field(this.field);
|
|
2136
2145
|
// Types do not have to match in NOT_EQUAL filters.
|
|
2137
|
-
return "!=" /* NOT_EQUAL */ === this.op ? null !==
|
|
2146
|
+
return "!=" /* NOT_EQUAL */ === this.op ? null !== e && this.D(qt(e, this.value)) : null !== e && St(this.value) === St(e) && this.D(qt(e, this.value));
|
|
2138
2147
|
// Only compare types with matching backend order (such as double and int).
|
|
2139
2148
|
}
|
|
2140
2149
|
D(t) {
|
|
@@ -2168,78 +2177,78 @@ class Wt extends class {} {
|
|
|
2168
2177
|
|
|
2169
2178
|
/** Filter that matches on key fields (i.e. '__name__'). */
|
|
2170
2179
|
class Yt extends Wt {
|
|
2171
|
-
constructor(t,
|
|
2172
|
-
super(t,
|
|
2180
|
+
constructor(t, e, n) {
|
|
2181
|
+
super(t, e, n), this.key = et.fromName(n.referenceValue);
|
|
2173
2182
|
}
|
|
2174
2183
|
matches(t) {
|
|
2175
|
-
const
|
|
2176
|
-
return this.D(
|
|
2184
|
+
const e = et.comparator(t.key, this.key);
|
|
2185
|
+
return this.D(e);
|
|
2177
2186
|
}
|
|
2178
2187
|
}
|
|
2179
2188
|
|
|
2180
2189
|
/** Filter that matches on key fields within an array. */ class Ht extends Wt {
|
|
2181
|
-
constructor(t,
|
|
2182
|
-
super(t, "in" /* IN */ ,
|
|
2190
|
+
constructor(t, e) {
|
|
2191
|
+
super(t, "in" /* IN */ , e), this.keys = Jt("in" /* IN */ , e);
|
|
2183
2192
|
}
|
|
2184
2193
|
matches(t) {
|
|
2185
|
-
return this.keys.some((
|
|
2194
|
+
return this.keys.some((e => e.isEqual(t.key)));
|
|
2186
2195
|
}
|
|
2187
2196
|
}
|
|
2188
2197
|
|
|
2189
2198
|
/** Filter that matches on key fields not present within an array. */ class Kt extends Wt {
|
|
2190
|
-
constructor(t,
|
|
2191
|
-
super(t, "not-in" /* NOT_IN */ ,
|
|
2199
|
+
constructor(t, e) {
|
|
2200
|
+
super(t, "not-in" /* NOT_IN */ , e), this.keys = Jt("not-in" /* NOT_IN */ , e);
|
|
2192
2201
|
}
|
|
2193
2202
|
matches(t) {
|
|
2194
|
-
return !this.keys.some((
|
|
2203
|
+
return !this.keys.some((e => e.isEqual(t.key)));
|
|
2195
2204
|
}
|
|
2196
2205
|
}
|
|
2197
2206
|
|
|
2198
|
-
function Jt(t,
|
|
2199
|
-
var
|
|
2200
|
-
return ((null === (
|
|
2207
|
+
function Jt(t, e) {
|
|
2208
|
+
var n;
|
|
2209
|
+
return ((null === (n = e.arrayValue) || void 0 === n ? void 0 : n.values) || []).map((t => et.fromName(t.referenceValue)));
|
|
2201
2210
|
}
|
|
2202
2211
|
|
|
2203
2212
|
/** A Filter that implements the array-contains operator. */ class Xt extends Wt {
|
|
2204
|
-
constructor(t,
|
|
2205
|
-
super(t, "array-contains" /* ARRAY_CONTAINS */ ,
|
|
2213
|
+
constructor(t, e) {
|
|
2214
|
+
super(t, "array-contains" /* ARRAY_CONTAINS */ , e);
|
|
2206
2215
|
}
|
|
2207
2216
|
matches(t) {
|
|
2208
|
-
const
|
|
2209
|
-
return Lt(
|
|
2217
|
+
const e = t.data.field(this.field);
|
|
2218
|
+
return Lt(e) && xt(e.arrayValue, this.value);
|
|
2210
2219
|
}
|
|
2211
2220
|
}
|
|
2212
2221
|
|
|
2213
2222
|
/** A Filter that implements the IN operator. */ class Zt extends Wt {
|
|
2214
|
-
constructor(t,
|
|
2215
|
-
super(t, "in" /* IN */ ,
|
|
2223
|
+
constructor(t, e) {
|
|
2224
|
+
super(t, "in" /* IN */ , e);
|
|
2216
2225
|
}
|
|
2217
2226
|
matches(t) {
|
|
2218
|
-
const
|
|
2219
|
-
return null !==
|
|
2227
|
+
const e = t.data.field(this.field);
|
|
2228
|
+
return null !== e && xt(this.value.arrayValue, e);
|
|
2220
2229
|
}
|
|
2221
2230
|
}
|
|
2222
2231
|
|
|
2223
|
-
/** A Filter that implements the not-in operator. */ class
|
|
2224
|
-
constructor(t,
|
|
2225
|
-
super(t, "not-in" /* NOT_IN */ ,
|
|
2232
|
+
/** A Filter that implements the not-in operator. */ class te extends Wt {
|
|
2233
|
+
constructor(t, e) {
|
|
2234
|
+
super(t, "not-in" /* NOT_IN */ , e);
|
|
2226
2235
|
}
|
|
2227
2236
|
matches(t) {
|
|
2228
2237
|
if (xt(this.value.arrayValue, {
|
|
2229
2238
|
nullValue: "NULL_VALUE"
|
|
2230
2239
|
})) return !1;
|
|
2231
|
-
const
|
|
2232
|
-
return null !==
|
|
2240
|
+
const e = t.data.field(this.field);
|
|
2241
|
+
return null !== e && !xt(this.value.arrayValue, e);
|
|
2233
2242
|
}
|
|
2234
2243
|
}
|
|
2235
2244
|
|
|
2236
|
-
/** A Filter that implements the array-contains-any operator. */ class
|
|
2237
|
-
constructor(t,
|
|
2238
|
-
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ ,
|
|
2245
|
+
/** A Filter that implements the array-contains-any operator. */ class ee extends Wt {
|
|
2246
|
+
constructor(t, e) {
|
|
2247
|
+
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ , e);
|
|
2239
2248
|
}
|
|
2240
2249
|
matches(t) {
|
|
2241
|
-
const
|
|
2242
|
-
return !(!Lt(
|
|
2250
|
+
const e = t.data.field(this.field);
|
|
2251
|
+
return !(!Lt(e) || !e.arrayValue.values) && e.arrayValue.values.some((t => xt(this.value.arrayValue, t)));
|
|
2243
2252
|
}
|
|
2244
2253
|
}
|
|
2245
2254
|
|
|
@@ -2256,30 +2265,30 @@ function Jt(t, n) {
|
|
|
2256
2265
|
* Bound provides a function to determine whether a document comes before or
|
|
2257
2266
|
* after a bound. This is influenced by whether the position is just before or
|
|
2258
2267
|
* just after the provided values.
|
|
2259
|
-
*/ class
|
|
2260
|
-
constructor(t,
|
|
2261
|
-
this.position = t, this.inclusive =
|
|
2268
|
+
*/ class ne {
|
|
2269
|
+
constructor(t, e) {
|
|
2270
|
+
this.position = t, this.inclusive = e;
|
|
2262
2271
|
}
|
|
2263
2272
|
}
|
|
2264
2273
|
|
|
2265
2274
|
/**
|
|
2266
2275
|
* An ordering on a field, in some Direction. Direction defaults to ASCENDING.
|
|
2267
|
-
*/ class
|
|
2268
|
-
constructor(t,
|
|
2269
|
-
this.field = t, this.dir =
|
|
2276
|
+
*/ class re {
|
|
2277
|
+
constructor(t, e = "asc" /* ASCENDING */) {
|
|
2278
|
+
this.field = t, this.dir = e;
|
|
2270
2279
|
}
|
|
2271
2280
|
}
|
|
2272
2281
|
|
|
2273
|
-
function
|
|
2274
|
-
return t.dir ===
|
|
2282
|
+
function se(t, e) {
|
|
2283
|
+
return t.dir === e.dir && t.field.isEqual(e.field);
|
|
2275
2284
|
}
|
|
2276
2285
|
|
|
2277
|
-
function
|
|
2278
|
-
if (null === t) return null ===
|
|
2279
|
-
if (null ===
|
|
2280
|
-
if (t.inclusive !==
|
|
2281
|
-
for (let
|
|
2282
|
-
if (!Ft(t.position[
|
|
2286
|
+
function ie(t, e) {
|
|
2287
|
+
if (null === t) return null === e;
|
|
2288
|
+
if (null === e) return !1;
|
|
2289
|
+
if (t.inclusive !== e.inclusive || t.position.length !== e.position.length) return !1;
|
|
2290
|
+
for (let n = 0; n < t.position.length; n++) {
|
|
2291
|
+
if (!Ft(t.position[n], e.position[n])) return !1;
|
|
2283
2292
|
}
|
|
2284
2293
|
return !0;
|
|
2285
2294
|
}
|
|
@@ -2306,29 +2315,29 @@ function on(t, n) {
|
|
|
2306
2315
|
* query the RemoteStore results.
|
|
2307
2316
|
*
|
|
2308
2317
|
* Visible for testing.
|
|
2309
|
-
*/ class
|
|
2318
|
+
*/ class oe {
|
|
2310
2319
|
/**
|
|
2311
2320
|
* Initializes a Query with a path and optional additional query constraints.
|
|
2312
2321
|
* Path must currently be empty if this is a collection group query.
|
|
2313
2322
|
*/
|
|
2314
|
-
constructor(t,
|
|
2315
|
-
this.path = t, this.collectionGroup =
|
|
2323
|
+
constructor(t, e = null, n = [], r = [], s = null, i = "F" /* First */ , o = null, u = null) {
|
|
2324
|
+
this.path = t, this.collectionGroup = e, this.explicitOrderBy = n, this.filters = r,
|
|
2316
2325
|
this.limit = s, this.limitType = i, this.startAt = o, this.endAt = u, this.$ = null,
|
|
2317
2326
|
// The corresponding `Target` of this `Query` instance.
|
|
2318
2327
|
this.S = null, this.startAt, this.endAt;
|
|
2319
2328
|
}
|
|
2320
2329
|
}
|
|
2321
2330
|
|
|
2322
|
-
/** Creates a new Query for a query that matches all documents at `path` */ function
|
|
2331
|
+
/** Creates a new Query for a query that matches all documents at `path` */ function ue(t) {
|
|
2323
2332
|
return !ct(t.limit) && "L" /* Last */ === t.limitType;
|
|
2324
2333
|
}
|
|
2325
2334
|
|
|
2326
|
-
function
|
|
2335
|
+
function ce(t) {
|
|
2327
2336
|
return t.explicitOrderBy.length > 0 ? t.explicitOrderBy[0].field : null;
|
|
2328
2337
|
}
|
|
2329
2338
|
|
|
2330
|
-
function
|
|
2331
|
-
for (const
|
|
2339
|
+
function ae(t) {
|
|
2340
|
+
for (const e of t.filters) if (e.N()) return e.field;
|
|
2332
2341
|
return null;
|
|
2333
2342
|
}
|
|
2334
2343
|
|
|
@@ -2340,7 +2349,7 @@ function hn(t) {
|
|
|
2340
2349
|
* Returns whether the query matches a collection group rather than a specific
|
|
2341
2350
|
* collection.
|
|
2342
2351
|
*/
|
|
2343
|
-
function
|
|
2352
|
+
function he(t) {
|
|
2344
2353
|
return null !== t.collectionGroup;
|
|
2345
2354
|
}
|
|
2346
2355
|
|
|
@@ -2348,59 +2357,59 @@ function ln(t) {
|
|
|
2348
2357
|
* Returns the implicit order by constraint that is used to execute the Query,
|
|
2349
2358
|
* which can be different from the order by constraints the user provided (e.g.
|
|
2350
2359
|
* the SDK and backend always orders by `__name__`).
|
|
2351
|
-
*/ function
|
|
2352
|
-
const
|
|
2353
|
-
if (null ===
|
|
2354
|
-
|
|
2355
|
-
const t =
|
|
2356
|
-
if (null !== t && null ===
|
|
2360
|
+
*/ function le(t) {
|
|
2361
|
+
const e = b(t);
|
|
2362
|
+
if (null === e.$) {
|
|
2363
|
+
e.$ = [];
|
|
2364
|
+
const t = ae(e), n = ce(e);
|
|
2365
|
+
if (null !== t && null === n)
|
|
2357
2366
|
// In order to implicitly add key ordering, we must also add the
|
|
2358
2367
|
// inequality filter field for it to be a valid query.
|
|
2359
2368
|
// Note that the default inequality field and key ordering is ascending.
|
|
2360
|
-
t.isKeyField() ||
|
|
2369
|
+
t.isKeyField() || e.$.push(new re(t)), e.$.push(new re(tt.keyField(), "asc" /* ASCENDING */)); else {
|
|
2361
2370
|
let t = !1;
|
|
2362
|
-
for (const
|
|
2371
|
+
for (const n of e.explicitOrderBy) e.$.push(n), n.field.isKeyField() && (t = !0);
|
|
2363
2372
|
if (!t) {
|
|
2364
2373
|
// The order of the implicit key ordering always matches the last
|
|
2365
2374
|
// explicit order by
|
|
2366
|
-
const t =
|
|
2367
|
-
|
|
2375
|
+
const t = e.explicitOrderBy.length > 0 ? e.explicitOrderBy[e.explicitOrderBy.length - 1].dir : "asc" /* ASCENDING */;
|
|
2376
|
+
e.$.push(new re(tt.keyField(), t));
|
|
2368
2377
|
}
|
|
2369
2378
|
}
|
|
2370
2379
|
}
|
|
2371
|
-
return
|
|
2380
|
+
return e.$;
|
|
2372
2381
|
}
|
|
2373
2382
|
|
|
2374
2383
|
/**
|
|
2375
2384
|
* Converts this `Query` instance to it's corresponding `Target` representation.
|
|
2376
|
-
*/ function
|
|
2377
|
-
const
|
|
2378
|
-
if (!
|
|
2385
|
+
*/ function fe(t) {
|
|
2386
|
+
const e = b(t);
|
|
2387
|
+
if (!e.S) if ("F" /* First */ === e.limitType) e.S = Qt(e.path, e.collectionGroup, le(e), e.filters, e.limit, e.startAt, e.endAt); else {
|
|
2379
2388
|
// Flip the orderBy directions since we want the last results
|
|
2380
2389
|
const t = [];
|
|
2381
|
-
for (const
|
|
2382
|
-
const
|
|
2383
|
-
t.push(new
|
|
2390
|
+
for (const n of le(e)) {
|
|
2391
|
+
const e = "desc" /* DESCENDING */ === n.dir ? "asc" /* ASCENDING */ : "desc" /* DESCENDING */;
|
|
2392
|
+
t.push(new re(n.field, e));
|
|
2384
2393
|
}
|
|
2385
2394
|
// We need to swap the cursors to match the now-flipped query ordering.
|
|
2386
|
-
const
|
|
2395
|
+
const n = e.endAt ? new ne(e.endAt.position, !e.endAt.inclusive) : null, r = e.startAt ? new ne(e.startAt.position, !e.startAt.inclusive) : null;
|
|
2387
2396
|
// Now return as a LimitType.First query.
|
|
2388
|
-
|
|
2397
|
+
e.S = Qt(e.path, e.collectionGroup, t, e.filters, e.limit, n, r);
|
|
2389
2398
|
}
|
|
2390
|
-
return
|
|
2399
|
+
return e.S;
|
|
2391
2400
|
}
|
|
2392
2401
|
|
|
2393
|
-
function
|
|
2394
|
-
return function(t,
|
|
2395
|
-
if (t.limit !==
|
|
2396
|
-
if (t.orderBy.length !==
|
|
2397
|
-
for (let
|
|
2398
|
-
if (t.filters.length !==
|
|
2399
|
-
for (let s = 0; s < t.filters.length; s++) if (
|
|
2400
|
-
|
|
2401
|
-
var
|
|
2402
|
-
return t.collectionGroup ===
|
|
2403
|
-
}(
|
|
2402
|
+
function de(t, e) {
|
|
2403
|
+
return function(t, e) {
|
|
2404
|
+
if (t.limit !== e.limit) return !1;
|
|
2405
|
+
if (t.orderBy.length !== e.orderBy.length) return !1;
|
|
2406
|
+
for (let n = 0; n < t.orderBy.length; n++) if (!se(t.orderBy[n], e.orderBy[n])) return !1;
|
|
2407
|
+
if (t.filters.length !== e.filters.length) return !1;
|
|
2408
|
+
for (let s = 0; s < t.filters.length; s++) if (n = t.filters[s], r = e.filters[s],
|
|
2409
|
+
n.op !== r.op || !n.field.isEqual(r.field) || !Ft(n.value, r.value)) return !1;
|
|
2410
|
+
var n, r;
|
|
2411
|
+
return t.collectionGroup === e.collectionGroup && !!t.path.isEqual(e.path) && !!ie(t.startAt, e.startAt) && ie(t.endAt, e.endAt);
|
|
2412
|
+
}(fe(t), fe(e)) && t.limitType === e.limitType;
|
|
2404
2413
|
}
|
|
2405
2414
|
|
|
2406
2415
|
/**
|
|
@@ -2428,10 +2437,10 @@ function wn(t, n) {
|
|
|
2428
2437
|
* The return value is an IntegerValue if it can safely represent the value,
|
|
2429
2438
|
* otherwise a DoubleValue is returned.
|
|
2430
2439
|
*/
|
|
2431
|
-
function
|
|
2440
|
+
function we(t, e) {
|
|
2432
2441
|
return function(t) {
|
|
2433
2442
|
return "number" == typeof t && Number.isInteger(t) && !at(t) && t <= Number.MAX_SAFE_INTEGER && t >= Number.MIN_SAFE_INTEGER;
|
|
2434
|
-
}(
|
|
2443
|
+
}(e) ?
|
|
2435
2444
|
/**
|
|
2436
2445
|
* Returns an IntegerValue for `value`.
|
|
2437
2446
|
*/
|
|
@@ -2439,22 +2448,22 @@ function mn(t, n) {
|
|
|
2439
2448
|
return {
|
|
2440
2449
|
integerValue: "" + t
|
|
2441
2450
|
};
|
|
2442
|
-
}(
|
|
2451
|
+
}(e) : function(t, e) {
|
|
2443
2452
|
if (t.F) {
|
|
2444
|
-
if (isNaN(
|
|
2453
|
+
if (isNaN(e)) return {
|
|
2445
2454
|
doubleValue: "NaN"
|
|
2446
2455
|
};
|
|
2447
|
-
if (
|
|
2456
|
+
if (e === 1 / 0) return {
|
|
2448
2457
|
doubleValue: "Infinity"
|
|
2449
2458
|
};
|
|
2450
|
-
if (
|
|
2459
|
+
if (e === -1 / 0) return {
|
|
2451
2460
|
doubleValue: "-Infinity"
|
|
2452
2461
|
};
|
|
2453
2462
|
}
|
|
2454
2463
|
return {
|
|
2455
|
-
doubleValue: at(
|
|
2464
|
+
doubleValue: at(e) ? "-0" : e
|
|
2456
2465
|
};
|
|
2457
|
-
}(t,
|
|
2466
|
+
}(t, e);
|
|
2458
2467
|
}
|
|
2459
2468
|
|
|
2460
2469
|
/**
|
|
@@ -2473,7 +2482,7 @@ function mn(t, n) {
|
|
|
2473
2482
|
* See the License for the specific language governing permissions and
|
|
2474
2483
|
* limitations under the License.
|
|
2475
2484
|
*/
|
|
2476
|
-
/** Used to represent a field transform on a mutation. */ class
|
|
2485
|
+
/** Used to represent a field transform on a mutation. */ class me {
|
|
2477
2486
|
constructor() {
|
|
2478
2487
|
// Make sure that the structural type of `TransformOperation` is unique.
|
|
2479
2488
|
// See https://github.com/microsoft/TypeScript/issues/5451
|
|
@@ -2481,15 +2490,15 @@ function mn(t, n) {
|
|
|
2481
2490
|
}
|
|
2482
2491
|
}
|
|
2483
2492
|
|
|
2484
|
-
/** Transforms a value into a server-generated timestamp. */ class
|
|
2493
|
+
/** Transforms a value into a server-generated timestamp. */ class pe extends me {}
|
|
2485
2494
|
|
|
2486
|
-
/** Transforms an array value via a union operation. */ class
|
|
2495
|
+
/** Transforms an array value via a union operation. */ class ye extends me {
|
|
2487
2496
|
constructor(t) {
|
|
2488
2497
|
super(), this.elements = t;
|
|
2489
2498
|
}
|
|
2490
2499
|
}
|
|
2491
2500
|
|
|
2492
|
-
/** Transforms an array value via a remove operation. */ class
|
|
2501
|
+
/** Transforms an array value via a remove operation. */ class _e extends me {
|
|
2493
2502
|
constructor(t) {
|
|
2494
2503
|
super(), this.elements = t;
|
|
2495
2504
|
}
|
|
@@ -2500,9 +2509,9 @@ function mn(t, n) {
|
|
|
2500
2509
|
* transforms. Converts all field values to integers or doubles, but unlike the
|
|
2501
2510
|
* backend does not cap integer values at 2^63. Instead, JavaScript number
|
|
2502
2511
|
* arithmetic is used and precision loss can occur for values greater than 2^53.
|
|
2503
|
-
*/ class
|
|
2504
|
-
constructor(t,
|
|
2505
|
-
super(), this.q = t, this.O =
|
|
2512
|
+
*/ class ge extends me {
|
|
2513
|
+
constructor(t, e) {
|
|
2514
|
+
super(), this.q = t, this.O = e;
|
|
2506
2515
|
}
|
|
2507
2516
|
}
|
|
2508
2517
|
|
|
@@ -2522,9 +2531,9 @@ function mn(t, n) {
|
|
|
2522
2531
|
* See the License for the specific language governing permissions and
|
|
2523
2532
|
* limitations under the License.
|
|
2524
2533
|
*/
|
|
2525
|
-
/** A field path and the TransformOperation to perform upon it. */ class
|
|
2526
|
-
constructor(t,
|
|
2527
|
-
this.field = t, this.transform =
|
|
2534
|
+
/** A field path and the TransformOperation to perform upon it. */ class ve {
|
|
2535
|
+
constructor(t, e) {
|
|
2536
|
+
this.field = t, this.transform = e;
|
|
2528
2537
|
}
|
|
2529
2538
|
}
|
|
2530
2539
|
|
|
@@ -2532,18 +2541,18 @@ function mn(t, n) {
|
|
|
2532
2541
|
* Encodes a precondition for a mutation. This follows the model that the
|
|
2533
2542
|
* backend accepts with the special case of an explicit "empty" precondition
|
|
2534
2543
|
* (meaning no precondition).
|
|
2535
|
-
*/ class
|
|
2536
|
-
constructor(t,
|
|
2537
|
-
this.updateTime = t, this.exists =
|
|
2544
|
+
*/ class be {
|
|
2545
|
+
constructor(t, e) {
|
|
2546
|
+
this.updateTime = t, this.exists = e;
|
|
2538
2547
|
}
|
|
2539
2548
|
/** Creates a new empty Precondition. */ static none() {
|
|
2540
|
-
return new
|
|
2549
|
+
return new be;
|
|
2541
2550
|
}
|
|
2542
2551
|
/** Creates a new Precondition with an exists flag. */ static exists(t) {
|
|
2543
|
-
return new
|
|
2552
|
+
return new be(void 0, t);
|
|
2544
2553
|
}
|
|
2545
2554
|
/** Creates a new Precondition based on a version a document exists at. */ static updateTime(t) {
|
|
2546
|
-
return new
|
|
2555
|
+
return new be(t);
|
|
2547
2556
|
}
|
|
2548
2557
|
/** Returns whether this Precondition is empty. */ get isNone() {
|
|
2549
2558
|
return void 0 === this.updateTime && void 0 === this.exists;
|
|
@@ -2596,14 +2605,14 @@ function mn(t, n) {
|
|
|
2596
2605
|
* applyToLocalView() to implement the actual behavior of applying the mutation
|
|
2597
2606
|
* to some source document (see `setMutationApplyToRemoteDocument()` for an
|
|
2598
2607
|
* example).
|
|
2599
|
-
*/ class
|
|
2608
|
+
*/ class Ee {}
|
|
2600
2609
|
|
|
2601
2610
|
/**
|
|
2602
2611
|
* A mutation that creates or replaces the document at the given key with the
|
|
2603
2612
|
* object value contents.
|
|
2604
|
-
*/ class
|
|
2605
|
-
constructor(t,
|
|
2606
|
-
super(), this.key = t, this.value =
|
|
2613
|
+
*/ class Te extends Ee {
|
|
2614
|
+
constructor(t, e, n, r = []) {
|
|
2615
|
+
super(), this.key = t, this.value = e, this.precondition = n, this.fieldTransforms = r,
|
|
2607
2616
|
this.type = 0 /* Set */;
|
|
2608
2617
|
}
|
|
2609
2618
|
}
|
|
@@ -2620,16 +2629,16 @@ function mn(t, n) {
|
|
|
2620
2629
|
* is deleted.
|
|
2621
2630
|
* * When a field is not in the mask but is in the values, the values map is
|
|
2622
2631
|
* ignored.
|
|
2623
|
-
*/ class
|
|
2624
|
-
constructor(t,
|
|
2625
|
-
super(), this.key = t, this.data =
|
|
2632
|
+
*/ class Ie extends Ee {
|
|
2633
|
+
constructor(t, e, n, r, s = []) {
|
|
2634
|
+
super(), this.key = t, this.data = e, this.fieldMask = n, this.precondition = r,
|
|
2626
2635
|
this.fieldTransforms = s, this.type = 1 /* Patch */;
|
|
2627
2636
|
}
|
|
2628
2637
|
}
|
|
2629
2638
|
|
|
2630
|
-
/** A mutation that deletes the document at the given key. */ class
|
|
2631
|
-
constructor(t,
|
|
2632
|
-
super(), this.key = t, this.precondition =
|
|
2639
|
+
/** A mutation that deletes the document at the given key. */ class Ae extends Ee {
|
|
2640
|
+
constructor(t, e) {
|
|
2641
|
+
super(), this.key = t, this.precondition = e, this.type = 2 /* Delete */ , this.fieldTransforms = [];
|
|
2633
2642
|
}
|
|
2634
2643
|
}
|
|
2635
2644
|
|
|
@@ -2639,9 +2648,9 @@ function mn(t, n) {
|
|
|
2639
2648
|
*
|
|
2640
2649
|
* The `verify` operation is only used in Transactions, and this class serves
|
|
2641
2650
|
* primarily to facilitate serialization into protos.
|
|
2642
|
-
*/ class
|
|
2643
|
-
constructor(t,
|
|
2644
|
-
super(), this.key = t, this.precondition =
|
|
2651
|
+
*/ class Re extends Ee {
|
|
2652
|
+
constructor(t, e) {
|
|
2653
|
+
super(), this.key = t, this.precondition = e, this.type = 3 /* Verify */ , this.fieldTransforms = [];
|
|
2645
2654
|
}
|
|
2646
2655
|
}
|
|
2647
2656
|
|
|
@@ -2660,13 +2669,13 @@ function mn(t, n) {
|
|
|
2660
2669
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2661
2670
|
* See the License for the specific language governing permissions and
|
|
2662
2671
|
* limitations under the License.
|
|
2663
|
-
*/ const
|
|
2672
|
+
*/ const Pe = (() => {
|
|
2664
2673
|
const t = {
|
|
2665
2674
|
asc: "ASCENDING",
|
|
2666
2675
|
desc: "DESCENDING"
|
|
2667
2676
|
};
|
|
2668
2677
|
return t;
|
|
2669
|
-
})(),
|
|
2678
|
+
})(), Ve = (() => {
|
|
2670
2679
|
const t = {
|
|
2671
2680
|
"<": "LESS_THAN",
|
|
2672
2681
|
"<=": "LESS_THAN_OR_EQUAL",
|
|
@@ -2696,9 +2705,9 @@ function mn(t, n) {
|
|
|
2696
2705
|
* TODO(klimt): We can remove the databaseId argument if we keep the full
|
|
2697
2706
|
* resource name in documents.
|
|
2698
2707
|
*/
|
|
2699
|
-
class
|
|
2700
|
-
constructor(t,
|
|
2701
|
-
this.databaseId = t, this.F =
|
|
2708
|
+
class De {
|
|
2709
|
+
constructor(t, e) {
|
|
2710
|
+
this.databaseId = t, this.F = e;
|
|
2702
2711
|
}
|
|
2703
2712
|
}
|
|
2704
2713
|
|
|
@@ -2713,13 +2722,13 @@ class Nn {
|
|
|
2713
2722
|
/**
|
|
2714
2723
|
* Returns a value for a Date that's appropriate to put into a proto.
|
|
2715
2724
|
*/
|
|
2716
|
-
function
|
|
2725
|
+
function Ne(t, e) {
|
|
2717
2726
|
if (t.F) {
|
|
2718
|
-
return `${new Date(1e3 *
|
|
2727
|
+
return `${new Date(1e3 * e.seconds).toISOString().replace(/\.\d*/, "").replace("Z", "")}.${("000000000" + e.nanoseconds).slice(-9)}Z`;
|
|
2719
2728
|
}
|
|
2720
2729
|
return {
|
|
2721
|
-
seconds: "" +
|
|
2722
|
-
nanos:
|
|
2730
|
+
seconds: "" + e.seconds,
|
|
2731
|
+
nanos: e.nanoseconds
|
|
2723
2732
|
};
|
|
2724
2733
|
}
|
|
2725
2734
|
|
|
@@ -2728,234 +2737,234 @@ function $n(t, n) {
|
|
|
2728
2737
|
*
|
|
2729
2738
|
* Visible for testing.
|
|
2730
2739
|
*/
|
|
2731
|
-
function
|
|
2732
|
-
return t.F ?
|
|
2740
|
+
function $e(t, e) {
|
|
2741
|
+
return t.F ? e.toBase64() : e.toUint8Array();
|
|
2733
2742
|
}
|
|
2734
2743
|
|
|
2735
|
-
function
|
|
2736
|
-
return
|
|
2744
|
+
function Se(t, e) {
|
|
2745
|
+
return Ne(t, e.toTimestamp());
|
|
2737
2746
|
}
|
|
2738
2747
|
|
|
2739
|
-
function
|
|
2740
|
-
return
|
|
2741
|
-
const
|
|
2742
|
-
return new gt(
|
|
2748
|
+
function Fe(t) {
|
|
2749
|
+
return v(!!t), vt.fromTimestamp(function(t) {
|
|
2750
|
+
const e = Rt(t);
|
|
2751
|
+
return new gt(e.seconds, e.nanos);
|
|
2743
2752
|
}(t));
|
|
2744
2753
|
}
|
|
2745
2754
|
|
|
2746
|
-
function
|
|
2755
|
+
function xe(t, e) {
|
|
2747
2756
|
return function(t) {
|
|
2748
2757
|
return new X([ "projects", t.projectId, "databases", t.database ]);
|
|
2749
|
-
}(t).child("documents").child(
|
|
2758
|
+
}(t).child("documents").child(e).canonicalString();
|
|
2750
2759
|
}
|
|
2751
2760
|
|
|
2752
|
-
function
|
|
2753
|
-
return
|
|
2761
|
+
function qe(t, e) {
|
|
2762
|
+
return xe(t.databaseId, e.path);
|
|
2754
2763
|
}
|
|
2755
2764
|
|
|
2756
|
-
function
|
|
2757
|
-
const
|
|
2758
|
-
const
|
|
2759
|
-
return
|
|
2760
|
-
}(
|
|
2761
|
-
if (
|
|
2762
|
-
if (
|
|
2763
|
-
return new
|
|
2765
|
+
function Oe(t, e) {
|
|
2766
|
+
const n = function(t) {
|
|
2767
|
+
const e = X.fromString(t);
|
|
2768
|
+
return v(We(e)), e;
|
|
2769
|
+
}(e);
|
|
2770
|
+
if (n.get(1) !== t.databaseId.projectId) throw new U(A, "Tried to deserialize key from different project: " + n.get(1) + " vs " + t.databaseId.projectId);
|
|
2771
|
+
if (n.get(3) !== t.databaseId.database) throw new U(A, "Tried to deserialize key from different database: " + n.get(3) + " vs " + t.databaseId.database);
|
|
2772
|
+
return new et((v((r = n).length > 4 && "documents" === r.get(4)), r.popFirst(5)));
|
|
2764
2773
|
var r;
|
|
2765
2774
|
/** Creates a Document proto from key and fields (but no create/update time) */}
|
|
2766
2775
|
|
|
2767
|
-
function
|
|
2768
|
-
return
|
|
2776
|
+
function Ce(t, e) {
|
|
2777
|
+
return xe(t.databaseId, e);
|
|
2769
2778
|
}
|
|
2770
2779
|
|
|
2771
|
-
function
|
|
2780
|
+
function Le(t) {
|
|
2772
2781
|
return new X([ "projects", t.databaseId.projectId, "databases", t.databaseId.database ]).canonicalString();
|
|
2773
2782
|
}
|
|
2774
2783
|
|
|
2775
|
-
function
|
|
2784
|
+
function Ue(t, e, n) {
|
|
2776
2785
|
return {
|
|
2777
|
-
name:
|
|
2778
|
-
fields:
|
|
2786
|
+
name: qe(t, e),
|
|
2787
|
+
fields: n.value.mapValue.fields
|
|
2779
2788
|
};
|
|
2780
2789
|
}
|
|
2781
2790
|
|
|
2782
|
-
function
|
|
2783
|
-
return "found" in
|
|
2784
|
-
|
|
2785
|
-
const
|
|
2791
|
+
function ke(t, e) {
|
|
2792
|
+
return "found" in e ? function(t, e) {
|
|
2793
|
+
v(!!e.found), e.found.name, e.found.updateTime;
|
|
2794
|
+
const n = Oe(t, e.found.name), r = Fe(e.found.updateTime), s = new Bt({
|
|
2786
2795
|
mapValue: {
|
|
2787
|
-
fields:
|
|
2796
|
+
fields: e.found.fields
|
|
2788
2797
|
}
|
|
2789
2798
|
});
|
|
2790
|
-
return zt.newFoundDocument(
|
|
2791
|
-
}(t,
|
|
2792
|
-
|
|
2793
|
-
const
|
|
2794
|
-
return zt.newNoDocument(
|
|
2795
|
-
}(t,
|
|
2796
|
-
}
|
|
2797
|
-
|
|
2798
|
-
function
|
|
2799
|
-
let
|
|
2800
|
-
if (
|
|
2801
|
-
update:
|
|
2802
|
-
}; else if (
|
|
2803
|
-
delete:
|
|
2804
|
-
}; else if (
|
|
2805
|
-
update:
|
|
2806
|
-
updateMask:
|
|
2799
|
+
return zt.newFoundDocument(n, r, s);
|
|
2800
|
+
}(t, e) : "missing" in e ? function(t, e) {
|
|
2801
|
+
v(!!e.missing), v(!!e.readTime);
|
|
2802
|
+
const n = Oe(t, e.missing), r = Fe(e.readTime);
|
|
2803
|
+
return zt.newNoDocument(n, r);
|
|
2804
|
+
}(t, e) : g();
|
|
2805
|
+
}
|
|
2806
|
+
|
|
2807
|
+
function je(t, e) {
|
|
2808
|
+
let n;
|
|
2809
|
+
if (e instanceof Te) n = {
|
|
2810
|
+
update: Ue(t, e.key, e.value)
|
|
2811
|
+
}; else if (e instanceof Ae) n = {
|
|
2812
|
+
delete: qe(t, e.key)
|
|
2813
|
+
}; else if (e instanceof Ie) n = {
|
|
2814
|
+
update: Ue(t, e.key, e.data),
|
|
2815
|
+
updateMask: Qe(e.fieldMask)
|
|
2807
2816
|
}; else {
|
|
2808
|
-
if (!(
|
|
2809
|
-
|
|
2810
|
-
verify:
|
|
2817
|
+
if (!(e instanceof Re)) return g();
|
|
2818
|
+
n = {
|
|
2819
|
+
verify: qe(t, e.key)
|
|
2811
2820
|
};
|
|
2812
2821
|
}
|
|
2813
|
-
return
|
|
2814
|
-
const
|
|
2815
|
-
if (
|
|
2816
|
-
fieldPath:
|
|
2822
|
+
return e.fieldTransforms.length > 0 && (n.updateTransforms = e.fieldTransforms.map((t => function(t, e) {
|
|
2823
|
+
const n = e.transform;
|
|
2824
|
+
if (n instanceof pe) return {
|
|
2825
|
+
fieldPath: e.field.canonicalString(),
|
|
2817
2826
|
setToServerValue: "REQUEST_TIME"
|
|
2818
2827
|
};
|
|
2819
|
-
if (
|
|
2820
|
-
fieldPath:
|
|
2828
|
+
if (n instanceof ye) return {
|
|
2829
|
+
fieldPath: e.field.canonicalString(),
|
|
2821
2830
|
appendMissingElements: {
|
|
2822
|
-
values:
|
|
2831
|
+
values: n.elements
|
|
2823
2832
|
}
|
|
2824
2833
|
};
|
|
2825
|
-
if (
|
|
2826
|
-
fieldPath:
|
|
2834
|
+
if (n instanceof _e) return {
|
|
2835
|
+
fieldPath: e.field.canonicalString(),
|
|
2827
2836
|
removeAllFromArray: {
|
|
2828
|
-
values:
|
|
2837
|
+
values: n.elements
|
|
2829
2838
|
}
|
|
2830
2839
|
};
|
|
2831
|
-
if (
|
|
2832
|
-
fieldPath:
|
|
2833
|
-
increment:
|
|
2840
|
+
if (n instanceof ge) return {
|
|
2841
|
+
fieldPath: e.field.canonicalString(),
|
|
2842
|
+
increment: n.O
|
|
2834
2843
|
};
|
|
2835
2844
|
throw g();
|
|
2836
|
-
}(0, t)))),
|
|
2837
|
-
return void 0 !==
|
|
2838
|
-
updateTime:
|
|
2839
|
-
} : void 0 !==
|
|
2840
|
-
exists:
|
|
2845
|
+
}(0, t)))), e.precondition.isNone || (n.currentDocument = function(t, e) {
|
|
2846
|
+
return void 0 !== e.updateTime ? {
|
|
2847
|
+
updateTime: Se(t, e.updateTime)
|
|
2848
|
+
} : void 0 !== e.exists ? {
|
|
2849
|
+
exists: e.exists
|
|
2841
2850
|
} : g();
|
|
2842
|
-
}(t,
|
|
2851
|
+
}(t, e.precondition)), n;
|
|
2843
2852
|
}
|
|
2844
2853
|
|
|
2845
|
-
function
|
|
2854
|
+
function Me(t, e) {
|
|
2846
2855
|
// Dissect the path into parent, collectionId, and optional key filter.
|
|
2847
|
-
const
|
|
2856
|
+
const n = {
|
|
2848
2857
|
structuredQuery: {}
|
|
2849
|
-
}, r =
|
|
2850
|
-
null !==
|
|
2851
|
-
collectionId:
|
|
2858
|
+
}, r = e.path;
|
|
2859
|
+
null !== e.collectionGroup ? (n.parent = Ce(t, r), n.structuredQuery.from = [ {
|
|
2860
|
+
collectionId: e.collectionGroup,
|
|
2852
2861
|
allDescendants: !0
|
|
2853
|
-
} ]) : (
|
|
2862
|
+
} ]) : (n.parent = Ce(t, r.popLast()), n.structuredQuery.from = [ {
|
|
2854
2863
|
collectionId: r.lastSegment()
|
|
2855
2864
|
} ]);
|
|
2856
2865
|
const s = function(t) {
|
|
2857
2866
|
if (0 === t.length) return;
|
|
2858
|
-
const
|
|
2867
|
+
const e = t.map((t =>
|
|
2859
2868
|
// visible for testing
|
|
2860
2869
|
function(t) {
|
|
2861
2870
|
if ("==" /* EQUAL */ === t.op) {
|
|
2862
2871
|
if (kt(t.value)) return {
|
|
2863
2872
|
unaryFilter: {
|
|
2864
|
-
field:
|
|
2873
|
+
field: Ge(t.field),
|
|
2865
2874
|
op: "IS_NAN"
|
|
2866
2875
|
}
|
|
2867
2876
|
};
|
|
2868
2877
|
if (Ut(t.value)) return {
|
|
2869
2878
|
unaryFilter: {
|
|
2870
|
-
field:
|
|
2879
|
+
field: Ge(t.field),
|
|
2871
2880
|
op: "IS_NULL"
|
|
2872
2881
|
}
|
|
2873
2882
|
};
|
|
2874
2883
|
} else if ("!=" /* NOT_EQUAL */ === t.op) {
|
|
2875
2884
|
if (kt(t.value)) return {
|
|
2876
2885
|
unaryFilter: {
|
|
2877
|
-
field:
|
|
2886
|
+
field: Ge(t.field),
|
|
2878
2887
|
op: "IS_NOT_NAN"
|
|
2879
2888
|
}
|
|
2880
2889
|
};
|
|
2881
2890
|
if (Ut(t.value)) return {
|
|
2882
2891
|
unaryFilter: {
|
|
2883
|
-
field:
|
|
2892
|
+
field: Ge(t.field),
|
|
2884
2893
|
op: "IS_NOT_NULL"
|
|
2885
2894
|
}
|
|
2886
2895
|
};
|
|
2887
2896
|
}
|
|
2888
2897
|
return {
|
|
2889
2898
|
fieldFilter: {
|
|
2890
|
-
field:
|
|
2891
|
-
op:
|
|
2899
|
+
field: Ge(t.field),
|
|
2900
|
+
op: ze(t.op),
|
|
2892
2901
|
value: t.value
|
|
2893
2902
|
}
|
|
2894
2903
|
};
|
|
2895
2904
|
}(t)));
|
|
2896
|
-
if (1 ===
|
|
2905
|
+
if (1 === e.length) return e[0];
|
|
2897
2906
|
return {
|
|
2898
2907
|
compositeFilter: {
|
|
2899
2908
|
op: "AND",
|
|
2900
|
-
filters:
|
|
2909
|
+
filters: e
|
|
2901
2910
|
}
|
|
2902
2911
|
};
|
|
2903
|
-
}(
|
|
2904
|
-
s && (
|
|
2912
|
+
}(e.filters);
|
|
2913
|
+
s && (n.structuredQuery.where = s);
|
|
2905
2914
|
const i = function(t) {
|
|
2906
2915
|
if (0 === t.length) return;
|
|
2907
2916
|
return t.map((t =>
|
|
2908
2917
|
// visible for testing
|
|
2909
2918
|
function(t) {
|
|
2910
2919
|
return {
|
|
2911
|
-
field:
|
|
2912
|
-
direction:
|
|
2920
|
+
field: Ge(t.field),
|
|
2921
|
+
direction: Be(t.dir)
|
|
2913
2922
|
};
|
|
2914
2923
|
}(t)));
|
|
2915
|
-
}(
|
|
2916
|
-
i && (
|
|
2917
|
-
const o = function(t,
|
|
2918
|
-
return t.F || ct(
|
|
2919
|
-
value:
|
|
2924
|
+
}(e.orderBy);
|
|
2925
|
+
i && (n.structuredQuery.orderBy = i);
|
|
2926
|
+
const o = function(t, e) {
|
|
2927
|
+
return t.F || ct(e) ? e : {
|
|
2928
|
+
value: e
|
|
2920
2929
|
};
|
|
2921
|
-
}(t,
|
|
2930
|
+
}(t, e.limit);
|
|
2922
2931
|
var u;
|
|
2923
|
-
return null !== o && (
|
|
2924
|
-
before: (u =
|
|
2932
|
+
return null !== o && (n.structuredQuery.limit = o), e.startAt && (n.structuredQuery.startAt = {
|
|
2933
|
+
before: (u = e.startAt).inclusive,
|
|
2925
2934
|
values: u.position
|
|
2926
|
-
}),
|
|
2935
|
+
}), e.endAt && (n.structuredQuery.endAt = function(t) {
|
|
2927
2936
|
return {
|
|
2928
2937
|
before: !t.inclusive,
|
|
2929
2938
|
values: t.position
|
|
2930
2939
|
};
|
|
2931
2940
|
}
|
|
2932
2941
|
// visible for testing
|
|
2933
|
-
(
|
|
2942
|
+
(e.endAt)), n;
|
|
2934
2943
|
}
|
|
2935
2944
|
|
|
2936
|
-
function
|
|
2937
|
-
return
|
|
2945
|
+
function Be(t) {
|
|
2946
|
+
return Pe[t];
|
|
2938
2947
|
}
|
|
2939
2948
|
|
|
2940
2949
|
// visible for testing
|
|
2941
|
-
function
|
|
2942
|
-
return
|
|
2950
|
+
function ze(t) {
|
|
2951
|
+
return Ve[t];
|
|
2943
2952
|
}
|
|
2944
2953
|
|
|
2945
|
-
function
|
|
2954
|
+
function Ge(t) {
|
|
2946
2955
|
return {
|
|
2947
2956
|
fieldPath: t.canonicalString()
|
|
2948
2957
|
};
|
|
2949
2958
|
}
|
|
2950
2959
|
|
|
2951
|
-
function
|
|
2952
|
-
const
|
|
2953
|
-
return t.fields.forEach((t =>
|
|
2954
|
-
fieldPaths:
|
|
2960
|
+
function Qe(t) {
|
|
2961
|
+
const e = [];
|
|
2962
|
+
return t.fields.forEach((t => e.push(t.canonicalString()))), {
|
|
2963
|
+
fieldPaths: e
|
|
2955
2964
|
};
|
|
2956
2965
|
}
|
|
2957
2966
|
|
|
2958
|
-
function
|
|
2967
|
+
function We(t) {
|
|
2959
2968
|
// Resource names have at least 4 components (project ID, database ID)
|
|
2960
2969
|
return t.length >= 4 && "projects" === t.get(0) && "databases" === t.get(2);
|
|
2961
2970
|
}
|
|
@@ -2975,8 +2984,8 @@ function Yn(t) {
|
|
|
2975
2984
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2976
2985
|
* See the License for the specific language governing permissions and
|
|
2977
2986
|
* limitations under the License.
|
|
2978
|
-
*/ function
|
|
2979
|
-
return new
|
|
2987
|
+
*/ function Ye(t) {
|
|
2988
|
+
return new De(t, /* useProto3Json= */ !0);
|
|
2980
2989
|
}
|
|
2981
2990
|
|
|
2982
2991
|
/**
|
|
@@ -3004,7 +3013,7 @@ function Yn(t) {
|
|
|
3004
3013
|
* base delay. This prevents clients from accidentally synchronizing their
|
|
3005
3014
|
* delays causing spikes of load to the backend.
|
|
3006
3015
|
*/
|
|
3007
|
-
class
|
|
3016
|
+
class He {
|
|
3008
3017
|
constructor(
|
|
3009
3018
|
/**
|
|
3010
3019
|
* The AsyncQueue to run backoff operations on.
|
|
@@ -3013,13 +3022,13 @@ class Kn {
|
|
|
3013
3022
|
/**
|
|
3014
3023
|
* The ID to use when scheduling backoff operations on the AsyncQueue.
|
|
3015
3024
|
*/
|
|
3016
|
-
|
|
3025
|
+
e,
|
|
3017
3026
|
/**
|
|
3018
3027
|
* The initial delay (used as the base delay on the first retry attempt).
|
|
3019
3028
|
* Note that jitter will still be applied, so the actual delay could be as
|
|
3020
3029
|
* little as 0.5*initialDelayMs.
|
|
3021
3030
|
*/
|
|
3022
|
-
|
|
3031
|
+
n = 1e3
|
|
3023
3032
|
/**
|
|
3024
3033
|
* The multiplier to use to determine the extended base delay after each
|
|
3025
3034
|
* attempt.
|
|
@@ -3029,7 +3038,7 @@ class Kn {
|
|
|
3029
3038
|
* Note that jitter will still be applied, so the actual delay could be as
|
|
3030
3039
|
* much as 1.5*maxDelayMs.
|
|
3031
3040
|
*/ , s = 6e4) {
|
|
3032
|
-
this.C = t, this.timerId =
|
|
3041
|
+
this.C = t, this.timerId = e, this.L = n, this.U = r, this.k = s, this.j = 0, this.M = null,
|
|
3033
3042
|
/** The last backoff attempt, as epoch milliseconds. */
|
|
3034
3043
|
this.B = Date.now(), this.reset();
|
|
3035
3044
|
}
|
|
@@ -3057,9 +3066,9 @@ class Kn {
|
|
|
3057
3066
|
this.cancel();
|
|
3058
3067
|
// First schedule using the current base (which may be 0 and should be
|
|
3059
3068
|
// honored as such).
|
|
3060
|
-
const
|
|
3069
|
+
const e = Math.floor(this.j + this.Y()), n = Math.max(0, Date.now() - this.B), r = Math.max(0, e - n);
|
|
3061
3070
|
// Guard against lastAttemptTime being in the future due to a clock change.
|
|
3062
|
-
r > 0 && m("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.j} ms, delay with jitter: ${
|
|
3071
|
+
r > 0 && m("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.j} ms, delay with jitter: ${e} ms, last attempt: ${n} ms ago)`),
|
|
3063
3072
|
this.M = this.C.enqueueAfterDelay(this.timerId, r, (() => (this.B = Date.now(),
|
|
3064
3073
|
t()))),
|
|
3065
3074
|
// Apply backoff factor to determine next delay and ensure it is within
|
|
@@ -3102,22 +3111,22 @@ class Kn {
|
|
|
3102
3111
|
* An implementation of Datastore that exposes additional state for internal
|
|
3103
3112
|
* consumption.
|
|
3104
3113
|
*/
|
|
3105
|
-
class
|
|
3106
|
-
constructor(t,
|
|
3107
|
-
super(), this.authCredentials = t, this.appCheckCredentials =
|
|
3114
|
+
class Ke extends class {} {
|
|
3115
|
+
constructor(t, e, n, r) {
|
|
3116
|
+
super(), this.authCredentials = t, this.appCheckCredentials = e, this.K = n, this.q = r,
|
|
3108
3117
|
this.J = !1;
|
|
3109
3118
|
}
|
|
3110
3119
|
X() {
|
|
3111
3120
|
if (this.J) throw new U(S, "The client has already been terminated.");
|
|
3112
3121
|
}
|
|
3113
|
-
/** Invokes the provided RPC with auth and AppCheck tokens. */ m(t,
|
|
3114
|
-
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.m(t,
|
|
3122
|
+
/** Invokes the provided RPC with auth and AppCheck tokens. */ m(t, e, n) {
|
|
3123
|
+
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.m(t, e, n, r, s))).catch((t => {
|
|
3115
3124
|
throw "FirebaseError" === t.name ? (t.code === N && (this.authCredentials.invalidateToken(),
|
|
3116
3125
|
this.appCheckCredentials.invalidateToken()), t) : new U(I, t.toString());
|
|
3117
3126
|
}));
|
|
3118
3127
|
}
|
|
3119
|
-
/** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */ T(t,
|
|
3120
|
-
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.T(t,
|
|
3128
|
+
/** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */ T(t, e, n) {
|
|
3129
|
+
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.T(t, e, n, r, s))).catch((t => {
|
|
3121
3130
|
throw "FirebaseError" === t.name ? (t.code === N && (this.authCredentials.invalidateToken(),
|
|
3122
3131
|
this.appCheckCredentials.invalidateToken()), t) : new U(I, t.toString());
|
|
3123
3132
|
}));
|
|
@@ -3129,40 +3138,40 @@ class Jn extends class {} {
|
|
|
3129
3138
|
|
|
3130
3139
|
// TODO(firestorexp): Make sure there is only one Datastore instance per
|
|
3131
3140
|
// firestore-exp client.
|
|
3132
|
-
async function
|
|
3133
|
-
const
|
|
3134
|
-
writes:
|
|
3141
|
+
async function Je(t, e) {
|
|
3142
|
+
const n = b(t), r = Le(n.q) + "/documents", s = {
|
|
3143
|
+
writes: e.map((t => je(n.q, t)))
|
|
3135
3144
|
};
|
|
3136
|
-
await
|
|
3145
|
+
await n.m("Commit", r, s);
|
|
3137
3146
|
}
|
|
3138
3147
|
|
|
3139
|
-
async function
|
|
3140
|
-
const
|
|
3141
|
-
documents:
|
|
3142
|
-
}, i = await
|
|
3148
|
+
async function Xe(t, e) {
|
|
3149
|
+
const n = b(t), r = Le(n.q) + "/documents", s = {
|
|
3150
|
+
documents: e.map((t => qe(n.q, t)))
|
|
3151
|
+
}, i = await n.T("BatchGetDocuments", r, s), o = new Map;
|
|
3143
3152
|
i.forEach((t => {
|
|
3144
|
-
const
|
|
3145
|
-
o.set(
|
|
3153
|
+
const e = ke(n.q, t);
|
|
3154
|
+
o.set(e.key.toString(), e);
|
|
3146
3155
|
}));
|
|
3147
3156
|
const u = [];
|
|
3148
|
-
return
|
|
3149
|
-
const
|
|
3150
|
-
|
|
3157
|
+
return e.forEach((t => {
|
|
3158
|
+
const e = o.get(t.toString());
|
|
3159
|
+
v(!!e), u.push(e);
|
|
3151
3160
|
})), u;
|
|
3152
3161
|
}
|
|
3153
3162
|
|
|
3154
|
-
async function
|
|
3155
|
-
const
|
|
3156
|
-
return (await
|
|
3163
|
+
async function Ze(t, e) {
|
|
3164
|
+
const n = b(t), r = Me(n.q, fe(e));
|
|
3165
|
+
return (await n.T("RunQuery", r.parent, {
|
|
3157
3166
|
structuredQuery: r.structuredQuery
|
|
3158
|
-
})).filter((t => !!t.document)).map((t => function(t,
|
|
3159
|
-
const r =
|
|
3167
|
+
})).filter((t => !!t.document)).map((t => function(t, e, n) {
|
|
3168
|
+
const r = Oe(t, e.name), s = Fe(e.updateTime), i = new Bt({
|
|
3160
3169
|
mapValue: {
|
|
3161
|
-
fields:
|
|
3170
|
+
fields: e.fields
|
|
3162
3171
|
}
|
|
3163
3172
|
}), o = zt.newFoundDocument(r, s, i);
|
|
3164
|
-
return
|
|
3165
|
-
}(
|
|
3173
|
+
return n && o.setHasCommittedMutations(), n ? o.setHasCommittedMutations() : o;
|
|
3174
|
+
}(n.q, t.document, void 0)));
|
|
3166
3175
|
}
|
|
3167
3176
|
|
|
3168
3177
|
/**
|
|
@@ -3180,7 +3189,7 @@ async function te(t, n) {
|
|
|
3180
3189
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3181
3190
|
* See the License for the specific language governing permissions and
|
|
3182
3191
|
* limitations under the License.
|
|
3183
|
-
*/ const
|
|
3192
|
+
*/ const tn = new Map;
|
|
3184
3193
|
|
|
3185
3194
|
/**
|
|
3186
3195
|
* An instance map that ensures only one Datastore exists per Firestore
|
|
@@ -3191,19 +3200,19 @@ async function te(t, n) {
|
|
|
3191
3200
|
* instance. Callers must invoke removeComponents() when the Firestore
|
|
3192
3201
|
* instance is terminated.
|
|
3193
3202
|
*/
|
|
3194
|
-
function
|
|
3203
|
+
function en(t) {
|
|
3195
3204
|
if (t._terminated) throw new U(S, "The client has already been terminated.");
|
|
3196
|
-
if (!
|
|
3205
|
+
if (!tn.has(t)) {
|
|
3197
3206
|
m("ComponentProvider", "Initializing Datastore");
|
|
3198
3207
|
const i = function(t) {
|
|
3199
3208
|
return new wt(t, fetch.bind(null));
|
|
3200
|
-
}((
|
|
3201
|
-
new H(
|
|
3202
|
-
return new
|
|
3209
|
+
}((e = t._databaseId, n = t.app.options.appId || "", r = t._persistenceKey, s = t._freezeSettings(),
|
|
3210
|
+
new H(e, n, r, s.host, s.ssl, s.experimentalForceLongPolling, s.experimentalAutoDetectLongPolling, s.useFetchStreams))), o = Ye(t._databaseId), u = function(t, e, n, r) {
|
|
3211
|
+
return new Ke(t, e, n, r);
|
|
3203
3212
|
}(t._authCredentials, t._appCheckCredentials, i, o);
|
|
3204
|
-
|
|
3213
|
+
tn.set(t, u);
|
|
3205
3214
|
}
|
|
3206
|
-
var
|
|
3215
|
+
var e, n, r, s;
|
|
3207
3216
|
/**
|
|
3208
3217
|
* @license
|
|
3209
3218
|
* Copyright 2018 Google LLC
|
|
@@ -3219,7 +3228,7 @@ function ee(t) {
|
|
|
3219
3228
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3220
3229
|
* See the License for the specific language governing permissions and
|
|
3221
3230
|
* limitations under the License.
|
|
3222
|
-
*/ return
|
|
3231
|
+
*/ return tn.get(t);
|
|
3223
3232
|
}
|
|
3224
3233
|
|
|
3225
3234
|
/**
|
|
@@ -3231,21 +3240,21 @@ function ee(t) {
|
|
|
3231
3240
|
* user-supplied `FirestoreSettings` object. This is a separate type so that
|
|
3232
3241
|
* defaults can be supplied and the value can be checked for equality.
|
|
3233
3242
|
*/
|
|
3234
|
-
class
|
|
3243
|
+
class nn {
|
|
3235
3244
|
constructor(t) {
|
|
3236
|
-
var
|
|
3245
|
+
var e;
|
|
3237
3246
|
if (void 0 === t.host) {
|
|
3238
3247
|
if (void 0 !== t.ssl) throw new U(A, "Can't provide ssl option if host option is not set");
|
|
3239
3248
|
this.host = "firestore.googleapis.com", this.ssl = true;
|
|
3240
|
-
} else this.host = t.host, this.ssl = null === (
|
|
3249
|
+
} else this.host = t.host, this.ssl = null === (e = t.ssl) || void 0 === e || e;
|
|
3241
3250
|
if (this.credentials = t.credentials, this.ignoreUndefinedProperties = !!t.ignoreUndefinedProperties,
|
|
3242
3251
|
void 0 === t.cacheSizeBytes) this.cacheSizeBytes = 41943040; else {
|
|
3243
3252
|
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new U(A, "cacheSizeBytes must be at least 1048576");
|
|
3244
3253
|
this.cacheSizeBytes = t.cacheSizeBytes;
|
|
3245
3254
|
}
|
|
3246
3255
|
this.experimentalForceLongPolling = !!t.experimentalForceLongPolling, this.experimentalAutoDetectLongPolling = !!t.experimentalAutoDetectLongPolling,
|
|
3247
|
-
this.useFetchStreams = !!t.useFetchStreams, function(t,
|
|
3248
|
-
if (!0 ===
|
|
3256
|
+
this.useFetchStreams = !!t.useFetchStreams, function(t, e, n, r) {
|
|
3257
|
+
if (!0 === e && !0 === r) throw new U(A, `${t} and ${n} cannot be used together.`);
|
|
3249
3258
|
}("experimentalForceLongPolling", t.experimentalForceLongPolling, "experimentalAutoDetectLongPolling", t.experimentalAutoDetectLongPolling);
|
|
3250
3259
|
}
|
|
3251
3260
|
isEqual(t) {
|
|
@@ -3273,14 +3282,14 @@ class re {
|
|
|
3273
3282
|
* The Cloud Firestore service interface.
|
|
3274
3283
|
*
|
|
3275
3284
|
* Do not call this constructor directly. Instead, use {@link getFirestore}.
|
|
3276
|
-
*/ class
|
|
3285
|
+
*/ class rn {
|
|
3277
3286
|
/** @hideconstructor */
|
|
3278
|
-
constructor(t,
|
|
3279
|
-
this._authCredentials =
|
|
3287
|
+
constructor(t, e, n) {
|
|
3288
|
+
this._authCredentials = e, this._appCheckCredentials = n,
|
|
3280
3289
|
/**
|
|
3281
3290
|
* Whether it's a Firestore or Firestore Lite instance.
|
|
3282
3291
|
*/
|
|
3283
|
-
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new
|
|
3292
|
+
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new nn({}),
|
|
3284
3293
|
this._settingsFrozen = !1, t instanceof K ? this._databaseId = t : (this._app = t,
|
|
3285
3294
|
this._databaseId = function(t) {
|
|
3286
3295
|
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new U(A, '"projectId" not provided in firebase.initializeApp.');
|
|
@@ -3313,14 +3322,14 @@ class re {
|
|
|
3313
3322
|
}
|
|
3314
3323
|
_setSettings(t) {
|
|
3315
3324
|
if (this._settingsFrozen) throw new U(S, "Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");
|
|
3316
|
-
this._settings = new
|
|
3325
|
+
this._settings = new nn(t), void 0 !== t.credentials && (this._authCredentials = function(t) {
|
|
3317
3326
|
if (!t) return new M;
|
|
3318
3327
|
switch (t.type) {
|
|
3319
3328
|
case "gapi":
|
|
3320
|
-
const
|
|
3329
|
+
const e = t.client;
|
|
3321
3330
|
// Make sure this really is a Gapi client.
|
|
3322
|
-
return
|
|
3323
|
-
new Q(
|
|
3331
|
+
return v(!("object" != typeof e || null === e || !e.auth || !e.auth.getAuthHeaderValueForFirstParty)),
|
|
3332
|
+
new Q(e, t.sessionIndex || "0", t.iamToken || null);
|
|
3324
3333
|
|
|
3325
3334
|
case "provider":
|
|
3326
3335
|
return t.client;
|
|
@@ -3354,17 +3363,17 @@ class re {
|
|
|
3354
3363
|
* Only ever called once.
|
|
3355
3364
|
*/ _terminate() {
|
|
3356
3365
|
return function(t) {
|
|
3357
|
-
const
|
|
3358
|
-
|
|
3366
|
+
const e = tn.get(t);
|
|
3367
|
+
e && (m("ComponentProvider", "Removing Datastore"), tn.delete(t), e.terminate());
|
|
3359
3368
|
}(this), Promise.resolve();
|
|
3360
3369
|
}
|
|
3361
3370
|
}
|
|
3362
3371
|
|
|
3363
|
-
function
|
|
3364
|
-
const
|
|
3365
|
-
if (
|
|
3366
|
-
return
|
|
3367
|
-
options:
|
|
3372
|
+
function sn(t, e) {
|
|
3373
|
+
const n = _getProvider(t, "firestore/lite");
|
|
3374
|
+
if (n.isInitialized()) throw new U(S, "Firestore can only be initialized once per app.");
|
|
3375
|
+
return n.initialize({
|
|
3376
|
+
options: e
|
|
3368
3377
|
});
|
|
3369
3378
|
}
|
|
3370
3379
|
|
|
@@ -3376,8 +3385,8 @@ function ie(t, n) {
|
|
|
3376
3385
|
* @param app - The {@link @firebase/app#FirebaseApp} instance that the returned `Firestore`
|
|
3377
3386
|
* instance is associated with.
|
|
3378
3387
|
* @returns The `Firestore` instance of the provided app.
|
|
3379
|
-
*/ function
|
|
3380
|
-
return _getProvider(
|
|
3388
|
+
*/ function on(e = getApp()) {
|
|
3389
|
+
return _getProvider(e, "firestore/lite").getImmediate();
|
|
3381
3390
|
}
|
|
3382
3391
|
|
|
3383
3392
|
/**
|
|
@@ -3392,24 +3401,24 @@ function ie(t, n) {
|
|
|
3392
3401
|
* @param port - the emulator port (ex: 9000).
|
|
3393
3402
|
* @param options.mockUserToken - the mock auth token to use for unit testing
|
|
3394
3403
|
* Security Rules.
|
|
3395
|
-
*/ function
|
|
3404
|
+
*/ function un(t, e, n, r = {}) {
|
|
3396
3405
|
var s;
|
|
3397
|
-
const i = (t = ot(t,
|
|
3398
|
-
if ("firestore.googleapis.com" !== i.host && i.host !==
|
|
3406
|
+
const i = (t = ot(t, rn))._getSettings();
|
|
3407
|
+
if ("firestore.googleapis.com" !== i.host && i.host !== e && y("Host has been set in both settings() and useEmulator(), emulator host will be used"),
|
|
3399
3408
|
t._setSettings(Object.assign(Object.assign({}, i), {
|
|
3400
|
-
host: `${
|
|
3409
|
+
host: `${e}:${n}`,
|
|
3401
3410
|
ssl: !1
|
|
3402
3411
|
})), r.mockUserToken) {
|
|
3403
|
-
let
|
|
3404
|
-
if ("string" == typeof r.mockUserToken)
|
|
3412
|
+
let e, n;
|
|
3413
|
+
if ("string" == typeof r.mockUserToken) e = r.mockUserToken, n = l.MOCK_USER; else {
|
|
3405
3414
|
// Let createMockUserToken validate first (catches common mistakes like
|
|
3406
3415
|
// invalid field "uid" and missing field "sub" / "user_id".)
|
|
3407
|
-
|
|
3416
|
+
e = createMockUserToken(r.mockUserToken, null === (s = t._app) || void 0 === s ? void 0 : s.options.projectId);
|
|
3408
3417
|
const i = r.mockUserToken.sub || r.mockUserToken.user_id;
|
|
3409
3418
|
if (!i) throw new U(A, "mockUserToken must contain 'sub' or 'user_id' field!");
|
|
3410
|
-
|
|
3419
|
+
n = new l(i);
|
|
3411
3420
|
}
|
|
3412
|
-
t._authCredentials = new B(new j(
|
|
3421
|
+
t._authCredentials = new B(new j(e, n));
|
|
3413
3422
|
}
|
|
3414
3423
|
}
|
|
3415
3424
|
|
|
@@ -3432,8 +3441,8 @@ function ie(t, n) {
|
|
|
3432
3441
|
* @param firestore - The `Firestore` instance to terminate.
|
|
3433
3442
|
* @returns A `Promise` that is resolved when the instance has been successfully
|
|
3434
3443
|
* terminated.
|
|
3435
|
-
*/ function
|
|
3436
|
-
return t = ot(t,
|
|
3444
|
+
*/ function cn(t) {
|
|
3445
|
+
return t = ot(t, rn), _removeServiceInstance(t.app, "firestore/lite"), t._delete();
|
|
3437
3446
|
}
|
|
3438
3447
|
|
|
3439
3448
|
/**
|
|
@@ -3473,14 +3482,14 @@ function ie(t, n) {
|
|
|
3473
3482
|
* and can be used to write, read, or listen to the location. The document at
|
|
3474
3483
|
* the referenced location may or may not exist.
|
|
3475
3484
|
*/
|
|
3476
|
-
class
|
|
3485
|
+
class an {
|
|
3477
3486
|
/** @hideconstructor */
|
|
3478
3487
|
constructor(t,
|
|
3479
3488
|
/**
|
|
3480
3489
|
* If provided, the `FirestoreDataConverter` associated with this instance.
|
|
3481
3490
|
*/
|
|
3482
|
-
|
|
3483
|
-
this.converter =
|
|
3491
|
+
e, n) {
|
|
3492
|
+
this.converter = e, this._key = n,
|
|
3484
3493
|
/** The type of this Firestore reference. */
|
|
3485
3494
|
this.type = "document", this.firestore = t;
|
|
3486
3495
|
}
|
|
@@ -3501,40 +3510,40 @@ class ae {
|
|
|
3501
3510
|
/**
|
|
3502
3511
|
* The collection this `DocumentReference` belongs to.
|
|
3503
3512
|
*/ get parent() {
|
|
3504
|
-
return new
|
|
3513
|
+
return new ln(this.firestore, this.converter, this._key.path.popLast());
|
|
3505
3514
|
}
|
|
3506
3515
|
withConverter(t) {
|
|
3507
|
-
return new
|
|
3516
|
+
return new an(this.firestore, t, this._key);
|
|
3508
3517
|
}
|
|
3509
3518
|
}
|
|
3510
3519
|
|
|
3511
3520
|
/**
|
|
3512
3521
|
* A `Query` refers to a query which you can read or listen to. You can also
|
|
3513
3522
|
* construct refined `Query` objects by adding filters and ordering.
|
|
3514
|
-
*/ class
|
|
3523
|
+
*/ class hn {
|
|
3515
3524
|
// This is the lite version of the Query class in the main SDK.
|
|
3516
3525
|
/** @hideconstructor protected */
|
|
3517
3526
|
constructor(t,
|
|
3518
3527
|
/**
|
|
3519
3528
|
* If provided, the `FirestoreDataConverter` associated with this instance.
|
|
3520
3529
|
*/
|
|
3521
|
-
|
|
3522
|
-
this.converter =
|
|
3530
|
+
e, n) {
|
|
3531
|
+
this.converter = e, this._query = n,
|
|
3523
3532
|
/** The type of this Firestore reference. */
|
|
3524
3533
|
this.type = "query", this.firestore = t;
|
|
3525
3534
|
}
|
|
3526
3535
|
withConverter(t) {
|
|
3527
|
-
return new
|
|
3536
|
+
return new hn(this.firestore, t, this._query);
|
|
3528
3537
|
}
|
|
3529
3538
|
}
|
|
3530
3539
|
|
|
3531
3540
|
/**
|
|
3532
3541
|
* A `CollectionReference` object can be used for adding documents, getting
|
|
3533
3542
|
* document references, and querying for documents (using {@link query}).
|
|
3534
|
-
*/ class
|
|
3543
|
+
*/ class ln extends hn {
|
|
3535
3544
|
/** @hideconstructor */
|
|
3536
|
-
constructor(t,
|
|
3537
|
-
super(t,
|
|
3545
|
+
constructor(t, e, n) {
|
|
3546
|
+
super(t, e, new oe(n)), this._path = n,
|
|
3538
3547
|
/** The type of this Firestore reference. */
|
|
3539
3548
|
this.type = "collection";
|
|
3540
3549
|
}
|
|
@@ -3552,23 +3561,23 @@ class ae {
|
|
|
3552
3561
|
* subcollection. If this isn't a subcollection, the reference is null.
|
|
3553
3562
|
*/ get parent() {
|
|
3554
3563
|
const t = this._path.popLast();
|
|
3555
|
-
return t.isEmpty() ? null : new
|
|
3556
|
-
/* converter= */ null, new
|
|
3564
|
+
return t.isEmpty() ? null : new an(this.firestore,
|
|
3565
|
+
/* converter= */ null, new et(t));
|
|
3557
3566
|
}
|
|
3558
3567
|
withConverter(t) {
|
|
3559
|
-
return new
|
|
3568
|
+
return new ln(this.firestore, t, this._path);
|
|
3560
3569
|
}
|
|
3561
3570
|
}
|
|
3562
3571
|
|
|
3563
|
-
function
|
|
3564
|
-
if (t = getModularInstance(t),
|
|
3565
|
-
const r = X.fromString(
|
|
3566
|
-
return st(r), new
|
|
3572
|
+
function fn(t, e, ...n) {
|
|
3573
|
+
if (t = getModularInstance(t), nt("collection", "path", e), t instanceof rn) {
|
|
3574
|
+
const r = X.fromString(e, ...n);
|
|
3575
|
+
return st(r), new ln(t, /* converter= */ null, r);
|
|
3567
3576
|
}
|
|
3568
3577
|
{
|
|
3569
|
-
if (!(t instanceof
|
|
3570
|
-
const r = t._path.child(X.fromString(
|
|
3571
|
-
return st(r), new
|
|
3578
|
+
if (!(t instanceof an || t instanceof ln)) throw new U(A, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3579
|
+
const r = t._path.child(X.fromString(e, ...n));
|
|
3580
|
+
return st(r), new ln(t.firestore,
|
|
3572
3581
|
/* converter= */ null, r);
|
|
3573
3582
|
}
|
|
3574
3583
|
}
|
|
@@ -3585,32 +3594,32 @@ function fe(t, n, ...e) {
|
|
|
3585
3594
|
* collection or subcollection with this ID as the last segment of its path
|
|
3586
3595
|
* will be included. Cannot contain a slash.
|
|
3587
3596
|
* @returns The created `Query`.
|
|
3588
|
-
*/ function
|
|
3589
|
-
if (t = ot(t,
|
|
3590
|
-
return new
|
|
3597
|
+
*/ function dn(t, e) {
|
|
3598
|
+
if (t = ot(t, rn), nt("collectionGroup", "collection id", e), e.indexOf("/") >= 0) throw new U(A, `Invalid collection ID '${e}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);
|
|
3599
|
+
return new hn(t,
|
|
3591
3600
|
/* converter= */ null,
|
|
3592
3601
|
/**
|
|
3593
3602
|
* Creates a new Query for a collection group query that matches all documents
|
|
3594
3603
|
* within the provided collection group.
|
|
3595
3604
|
*/
|
|
3596
3605
|
function(t) {
|
|
3597
|
-
return new
|
|
3598
|
-
}(
|
|
3606
|
+
return new oe(X.emptyPath(), t);
|
|
3607
|
+
}(e));
|
|
3599
3608
|
}
|
|
3600
3609
|
|
|
3601
|
-
function
|
|
3610
|
+
function wn(t, e, ...n) {
|
|
3602
3611
|
if (t = getModularInstance(t),
|
|
3603
3612
|
// We allow omission of 'pathString' but explicitly prohibit passing in both
|
|
3604
3613
|
// 'undefined' and 'null'.
|
|
3605
|
-
1 === arguments.length && (
|
|
3606
|
-
const r = X.fromString(
|
|
3607
|
-
return rt(r), new
|
|
3608
|
-
/* converter= */ null, new
|
|
3614
|
+
1 === arguments.length && (e = pt.R()), nt("doc", "path", e), t instanceof rn) {
|
|
3615
|
+
const r = X.fromString(e, ...n);
|
|
3616
|
+
return rt(r), new an(t,
|
|
3617
|
+
/* converter= */ null, new et(r));
|
|
3609
3618
|
}
|
|
3610
3619
|
{
|
|
3611
|
-
if (!(t instanceof
|
|
3612
|
-
const r = t._path.child(X.fromString(
|
|
3613
|
-
return rt(r), new
|
|
3620
|
+
if (!(t instanceof an || t instanceof ln)) throw new U(A, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3621
|
+
const r = t._path.child(X.fromString(e, ...n));
|
|
3622
|
+
return rt(r), new an(t.firestore, t instanceof ln ? t.converter : null, new et(r));
|
|
3614
3623
|
}
|
|
3615
3624
|
}
|
|
3616
3625
|
|
|
@@ -3621,8 +3630,8 @@ function we(t, n, ...e) {
|
|
|
3621
3630
|
* @param right - A reference to compare.
|
|
3622
3631
|
* @returns true if the references point to the same location in the same
|
|
3623
3632
|
* Firestore database.
|
|
3624
|
-
*/ function
|
|
3625
|
-
return t = getModularInstance(t),
|
|
3633
|
+
*/ function mn(t, e) {
|
|
3634
|
+
return t = getModularInstance(t), e = getModularInstance(e), (t instanceof an || t instanceof ln) && (e instanceof an || e instanceof ln) && (t.firestore === e.firestore && t.path === e.path && t.converter === e.converter);
|
|
3626
3635
|
}
|
|
3627
3636
|
|
|
3628
3637
|
/**
|
|
@@ -3633,8 +3642,8 @@ function we(t, n, ...e) {
|
|
|
3633
3642
|
* @param right - A `Query` to compare.
|
|
3634
3643
|
* @returns true if the references point to the same location in the same
|
|
3635
3644
|
* Firestore database.
|
|
3636
|
-
*/ function
|
|
3637
|
-
return t = getModularInstance(t),
|
|
3645
|
+
*/ function pn(t, e) {
|
|
3646
|
+
return t = getModularInstance(t), e = getModularInstance(e), t instanceof hn && e instanceof hn && (t.firestore === e.firestore && de(t._query, e._query) && t.converter === e.converter);
|
|
3638
3647
|
}
|
|
3639
3648
|
|
|
3640
3649
|
/**
|
|
@@ -3660,7 +3669,7 @@ function we(t, n, ...e) {
|
|
|
3660
3669
|
*
|
|
3661
3670
|
* Create a `FieldPath` by providing field names. If more than one field
|
|
3662
3671
|
* name is provided, the path will point to a nested field in a document.
|
|
3663
|
-
*/ class
|
|
3672
|
+
*/ class yn {
|
|
3664
3673
|
/**
|
|
3665
3674
|
* Creates a `FieldPath` from the provided field names. If more than one field
|
|
3666
3675
|
* name is provided, the path will point to a nested field in a document.
|
|
@@ -3668,7 +3677,7 @@ function we(t, n, ...e) {
|
|
|
3668
3677
|
* @param fieldNames - A list of field names.
|
|
3669
3678
|
*/
|
|
3670
3679
|
constructor(...t) {
|
|
3671
|
-
for (let
|
|
3680
|
+
for (let e = 0; e < t.length; ++e) if (0 === t[e].length) throw new U(A, "Invalid field name at argument $(i + 1). Field names must not be empty.");
|
|
3672
3681
|
this._internalPath = new tt(t);
|
|
3673
3682
|
}
|
|
3674
3683
|
/**
|
|
@@ -3684,8 +3693,8 @@ function we(t, n, ...e) {
|
|
|
3684
3693
|
/**
|
|
3685
3694
|
* Returns a special sentinel `FieldPath` to refer to the ID of a document.
|
|
3686
3695
|
* It can be used in queries to sort or filter by the document ID.
|
|
3687
|
-
*/ function
|
|
3688
|
-
return new
|
|
3696
|
+
*/ function _n() {
|
|
3697
|
+
return new yn("__name__");
|
|
3689
3698
|
}
|
|
3690
3699
|
|
|
3691
3700
|
/**
|
|
@@ -3706,7 +3715,7 @@ function we(t, n, ...e) {
|
|
|
3706
3715
|
*/
|
|
3707
3716
|
/**
|
|
3708
3717
|
* An immutable object representing an array of bytes.
|
|
3709
|
-
*/ class
|
|
3718
|
+
*/ class gn {
|
|
3710
3719
|
/** @hideconstructor */
|
|
3711
3720
|
constructor(t) {
|
|
3712
3721
|
this._byteString = t;
|
|
@@ -3718,7 +3727,7 @@ function we(t, n, ...e) {
|
|
|
3718
3727
|
* @param base64 - The Base64 string used to create the `Bytes` object.
|
|
3719
3728
|
*/ static fromBase64String(t) {
|
|
3720
3729
|
try {
|
|
3721
|
-
return new
|
|
3730
|
+
return new gn(It.fromBase64String(t));
|
|
3722
3731
|
} catch (t) {
|
|
3723
3732
|
throw new U(A, "Failed to construct data from Base64 string: " + t);
|
|
3724
3733
|
}
|
|
@@ -3728,7 +3737,7 @@ function we(t, n, ...e) {
|
|
|
3728
3737
|
*
|
|
3729
3738
|
* @param array - The Uint8Array used to create the `Bytes` object.
|
|
3730
3739
|
*/ static fromUint8Array(t) {
|
|
3731
|
-
return new
|
|
3740
|
+
return new gn(It.fromUint8Array(t));
|
|
3732
3741
|
}
|
|
3733
3742
|
/**
|
|
3734
3743
|
* Returns the underlying bytes as a Base64-encoded string.
|
|
@@ -3780,7 +3789,7 @@ function we(t, n, ...e) {
|
|
|
3780
3789
|
/**
|
|
3781
3790
|
* Sentinel values that can be used when writing document fields with `set()`
|
|
3782
3791
|
* or `update()`.
|
|
3783
|
-
*/ class
|
|
3792
|
+
*/ class vn {
|
|
3784
3793
|
/**
|
|
3785
3794
|
* @param _methodName - The public API endpoint that returns this class.
|
|
3786
3795
|
* @hideconstructor
|
|
@@ -3812,17 +3821,17 @@ function we(t, n, ...e) {
|
|
|
3812
3821
|
*
|
|
3813
3822
|
* Latitude values are in the range of [-90, 90].
|
|
3814
3823
|
* Longitude values are in the range of [-180, 180].
|
|
3815
|
-
*/ class
|
|
3824
|
+
*/ class bn {
|
|
3816
3825
|
/**
|
|
3817
3826
|
* Creates a new immutable `GeoPoint` object with the provided latitude and
|
|
3818
3827
|
* longitude values.
|
|
3819
3828
|
* @param latitude - The latitude as number between -90 and 90.
|
|
3820
3829
|
* @param longitude - The longitude as number between -180 and 180.
|
|
3821
3830
|
*/
|
|
3822
|
-
constructor(t,
|
|
3831
|
+
constructor(t, e) {
|
|
3823
3832
|
if (!isFinite(t) || t < -90 || t > 90) throw new U(A, "Latitude must be a number between -90 and 90, but was: " + t);
|
|
3824
|
-
if (!isFinite(
|
|
3825
|
-
this._lat = t, this._long =
|
|
3833
|
+
if (!isFinite(e) || e < -180 || e > 180) throw new U(A, "Longitude must be a number between -180 and 180, but was: " + e);
|
|
3834
|
+
this._lat = t, this._long = e;
|
|
3826
3835
|
}
|
|
3827
3836
|
/**
|
|
3828
3837
|
* The latitude of this `GeoPoint` instance.
|
|
@@ -3871,29 +3880,29 @@ function we(t, n, ...e) {
|
|
|
3871
3880
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3872
3881
|
* See the License for the specific language governing permissions and
|
|
3873
3882
|
* limitations under the License.
|
|
3874
|
-
*/ const
|
|
3883
|
+
*/ const En = /^__.*__$/;
|
|
3875
3884
|
|
|
3876
|
-
/** The result of parsing document data (e.g. for a setData call). */ class
|
|
3877
|
-
constructor(t,
|
|
3878
|
-
this.data = t, this.fieldMask =
|
|
3885
|
+
/** The result of parsing document data (e.g. for a setData call). */ class Tn {
|
|
3886
|
+
constructor(t, e, n) {
|
|
3887
|
+
this.data = t, this.fieldMask = e, this.fieldTransforms = n;
|
|
3879
3888
|
}
|
|
3880
|
-
toMutation(t,
|
|
3881
|
-
return null !== this.fieldMask ? new
|
|
3889
|
+
toMutation(t, e) {
|
|
3890
|
+
return null !== this.fieldMask ? new Ie(t, this.data, this.fieldMask, e, this.fieldTransforms) : new Te(t, this.data, e, this.fieldTransforms);
|
|
3882
3891
|
}
|
|
3883
3892
|
}
|
|
3884
3893
|
|
|
3885
|
-
/** The result of parsing "update" data (i.e. for an updateData call). */ class
|
|
3894
|
+
/** The result of parsing "update" data (i.e. for an updateData call). */ class In {
|
|
3886
3895
|
constructor(t,
|
|
3887
3896
|
// The fieldMask does not include document transforms.
|
|
3888
|
-
|
|
3889
|
-
this.data = t, this.fieldMask =
|
|
3897
|
+
e, n) {
|
|
3898
|
+
this.data = t, this.fieldMask = e, this.fieldTransforms = n;
|
|
3890
3899
|
}
|
|
3891
|
-
toMutation(t,
|
|
3892
|
-
return new
|
|
3900
|
+
toMutation(t, e) {
|
|
3901
|
+
return new Ie(t, this.data, this.fieldMask, e, this.fieldTransforms);
|
|
3893
3902
|
}
|
|
3894
3903
|
}
|
|
3895
3904
|
|
|
3896
|
-
function
|
|
3905
|
+
function An(t) {
|
|
3897
3906
|
switch (t) {
|
|
3898
3907
|
case 0 /* Set */ :
|
|
3899
3908
|
// fall through
|
|
@@ -3911,7 +3920,7 @@ function Ae(t) {
|
|
|
3911
3920
|
}
|
|
3912
3921
|
}
|
|
3913
3922
|
|
|
3914
|
-
/** A "context" object passed around while parsing user data. */ class
|
|
3923
|
+
/** A "context" object passed around while parsing user data. */ class Rn {
|
|
3915
3924
|
/**
|
|
3916
3925
|
* Initializes a ParseContext with the given source and path.
|
|
3917
3926
|
*
|
|
@@ -3930,8 +3939,8 @@ function Ae(t) {
|
|
|
3930
3939
|
* which case certain features will not work and errors will be somewhat
|
|
3931
3940
|
* compromised).
|
|
3932
3941
|
*/
|
|
3933
|
-
constructor(t,
|
|
3934
|
-
this.settings = t, this.databaseId =
|
|
3942
|
+
constructor(t, e, n, r, s, i) {
|
|
3943
|
+
this.settings = t, this.databaseId = e, this.q = n, this.ignoreUndefinedProperties = r,
|
|
3935
3944
|
// Minor hack: If fieldTransforms is undefined, we assume this is an
|
|
3936
3945
|
// external call and we need to validate the entire path.
|
|
3937
3946
|
void 0 === s && this.Z(), this.fieldTransforms = s || [], this.fieldMask = i || [];
|
|
@@ -3942,21 +3951,21 @@ function Ae(t) {
|
|
|
3942
3951
|
get tt() {
|
|
3943
3952
|
return this.settings.tt;
|
|
3944
3953
|
}
|
|
3945
|
-
/** Returns a new context with the specified settings overwritten. */
|
|
3946
|
-
return new
|
|
3954
|
+
/** Returns a new context with the specified settings overwritten. */ et(t) {
|
|
3955
|
+
return new Rn(Object.assign(Object.assign({}, this.settings), t), this.databaseId, this.q, this.ignoreUndefinedProperties, this.fieldTransforms, this.fieldMask);
|
|
3947
3956
|
}
|
|
3948
|
-
|
|
3949
|
-
var
|
|
3950
|
-
const
|
|
3951
|
-
path:
|
|
3957
|
+
nt(t) {
|
|
3958
|
+
var e;
|
|
3959
|
+
const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), r = this.et({
|
|
3960
|
+
path: n,
|
|
3952
3961
|
rt: !1
|
|
3953
3962
|
});
|
|
3954
3963
|
return r.st(t), r;
|
|
3955
3964
|
}
|
|
3956
3965
|
it(t) {
|
|
3957
|
-
var
|
|
3958
|
-
const
|
|
3959
|
-
path:
|
|
3966
|
+
var e;
|
|
3967
|
+
const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), r = this.et({
|
|
3968
|
+
path: n,
|
|
3960
3969
|
rt: !1
|
|
3961
3970
|
});
|
|
3962
3971
|
return r.Z(), r;
|
|
@@ -3964,16 +3973,16 @@ function Ae(t) {
|
|
|
3964
3973
|
ot(t) {
|
|
3965
3974
|
// TODO(b/34871131): We don't support array paths right now; so make path
|
|
3966
3975
|
// undefined.
|
|
3967
|
-
return this.
|
|
3976
|
+
return this.et({
|
|
3968
3977
|
path: void 0,
|
|
3969
3978
|
rt: !0
|
|
3970
3979
|
});
|
|
3971
3980
|
}
|
|
3972
3981
|
ut(t) {
|
|
3973
|
-
return
|
|
3982
|
+
return Qn(t, this.settings.methodName, this.settings.ct || !1, this.path, this.settings.at);
|
|
3974
3983
|
}
|
|
3975
3984
|
/** Returns 'true' if 'fieldPath' was traversed when creating this context. */ contains(t) {
|
|
3976
|
-
return void 0 !== this.fieldMask.find((
|
|
3985
|
+
return void 0 !== this.fieldMask.find((e => t.isPrefixOf(e))) || void 0 !== this.fieldTransforms.find((e => t.isPrefixOf(e.field)));
|
|
3977
3986
|
}
|
|
3978
3987
|
Z() {
|
|
3979
3988
|
// TODO(b/34871131): Remove null check once we have proper paths for fields
|
|
@@ -3982,22 +3991,22 @@ function Ae(t) {
|
|
|
3982
3991
|
}
|
|
3983
3992
|
st(t) {
|
|
3984
3993
|
if (0 === t.length) throw this.ut("Document fields must not be empty");
|
|
3985
|
-
if (
|
|
3994
|
+
if (An(this.tt) && En.test(t)) throw this.ut('Document fields cannot begin and end with "__"');
|
|
3986
3995
|
}
|
|
3987
3996
|
}
|
|
3988
3997
|
|
|
3989
3998
|
/**
|
|
3990
3999
|
* Helper for parsing raw user input (provided via the API) into internal model
|
|
3991
4000
|
* classes.
|
|
3992
|
-
*/ class
|
|
3993
|
-
constructor(t,
|
|
3994
|
-
this.databaseId = t, this.ignoreUndefinedProperties =
|
|
4001
|
+
*/ class Pn {
|
|
4002
|
+
constructor(t, e, n) {
|
|
4003
|
+
this.databaseId = t, this.ignoreUndefinedProperties = e, this.q = n || Ye(t);
|
|
3995
4004
|
}
|
|
3996
|
-
/** Creates a new top-level parse context. */ ht(t,
|
|
3997
|
-
return new
|
|
4005
|
+
/** Creates a new top-level parse context. */ ht(t, e, n, r = !1) {
|
|
4006
|
+
return new Rn({
|
|
3998
4007
|
tt: t,
|
|
3999
|
-
methodName:
|
|
4000
|
-
at:
|
|
4008
|
+
methodName: e,
|
|
4009
|
+
at: n,
|
|
4001
4010
|
path: tt.emptyPath(),
|
|
4002
4011
|
rt: !1,
|
|
4003
4012
|
ct: r
|
|
@@ -4005,29 +4014,29 @@ function Ae(t) {
|
|
|
4005
4014
|
}
|
|
4006
4015
|
}
|
|
4007
4016
|
|
|
4008
|
-
function
|
|
4009
|
-
const
|
|
4010
|
-
return new
|
|
4017
|
+
function Vn(t) {
|
|
4018
|
+
const e = t._freezeSettings(), n = Ye(t._databaseId);
|
|
4019
|
+
return new Pn(t._databaseId, !!e.ignoreUndefinedProperties, n);
|
|
4011
4020
|
}
|
|
4012
4021
|
|
|
4013
|
-
/** Parse document data from a set() call. */ function
|
|
4014
|
-
const o = t.ht(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ ,
|
|
4015
|
-
|
|
4016
|
-
const u =
|
|
4022
|
+
/** Parse document data from a set() call. */ function Dn(t, e, n, r, s, i = {}) {
|
|
4023
|
+
const o = t.ht(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ , e, n, s);
|
|
4024
|
+
Mn("Data must be an object, but it was:", o, r);
|
|
4025
|
+
const u = kn(r, o);
|
|
4017
4026
|
let c, a;
|
|
4018
4027
|
if (i.merge) c = new Tt(o.fieldMask), a = o.fieldTransforms; else if (i.mergeFields) {
|
|
4019
4028
|
const t = [];
|
|
4020
4029
|
for (const r of i.mergeFields) {
|
|
4021
|
-
const s =
|
|
4030
|
+
const s = Bn(e, r, n);
|
|
4022
4031
|
if (!o.contains(s)) throw new U(A, `Field '${s}' is specified in your field mask but missing from your input data.`);
|
|
4023
|
-
|
|
4032
|
+
Wn(t, s) || t.push(s);
|
|
4024
4033
|
}
|
|
4025
4034
|
c = new Tt(t), a = o.fieldTransforms.filter((t => c.covers(t.field)));
|
|
4026
4035
|
} else c = null, a = o.fieldTransforms;
|
|
4027
|
-
return new
|
|
4036
|
+
return new Tn(new Bt(u), c, a);
|
|
4028
4037
|
}
|
|
4029
4038
|
|
|
4030
|
-
class
|
|
4039
|
+
class Nn extends vn {
|
|
4031
4040
|
_toFieldTransform(t) {
|
|
4032
4041
|
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}`);
|
|
4033
4042
|
// No transform to add for a delete, but we need to add it to our
|
|
@@ -4035,7 +4044,7 @@ class Ne extends be {
|
|
|
4035
4044
|
return t.fieldMask.push(t.path), null;
|
|
4036
4045
|
}
|
|
4037
4046
|
isEqual(t) {
|
|
4038
|
-
return t instanceof
|
|
4047
|
+
return t instanceof Nn;
|
|
4039
4048
|
}
|
|
4040
4049
|
}
|
|
4041
4050
|
|
|
@@ -4054,32 +4063,32 @@ class Ne extends be {
|
|
|
4054
4063
|
* context.
|
|
4055
4064
|
* @param context - The parent context.
|
|
4056
4065
|
* @param arrayElement - Whether or not the FieldValue has an array.
|
|
4057
|
-
*/ function $
|
|
4058
|
-
return new
|
|
4066
|
+
*/ function $n(t, e, n) {
|
|
4067
|
+
return new Rn({
|
|
4059
4068
|
tt: 3 /* Argument */ ,
|
|
4060
|
-
at:
|
|
4069
|
+
at: e.settings.at,
|
|
4061
4070
|
methodName: t._methodName,
|
|
4062
|
-
rt:
|
|
4063
|
-
},
|
|
4071
|
+
rt: n
|
|
4072
|
+
}, e.databaseId, e.q, e.ignoreUndefinedProperties);
|
|
4064
4073
|
}
|
|
4065
4074
|
|
|
4066
|
-
class
|
|
4075
|
+
class Sn extends vn {
|
|
4067
4076
|
_toFieldTransform(t) {
|
|
4068
|
-
return new
|
|
4077
|
+
return new ve(t.path, new pe);
|
|
4069
4078
|
}
|
|
4070
4079
|
isEqual(t) {
|
|
4071
|
-
return t instanceof
|
|
4080
|
+
return t instanceof Sn;
|
|
4072
4081
|
}
|
|
4073
4082
|
}
|
|
4074
4083
|
|
|
4075
|
-
class
|
|
4076
|
-
constructor(t,
|
|
4077
|
-
super(t), this.lt =
|
|
4084
|
+
class Fn extends vn {
|
|
4085
|
+
constructor(t, e) {
|
|
4086
|
+
super(t), this.lt = e;
|
|
4078
4087
|
}
|
|
4079
4088
|
_toFieldTransform(t) {
|
|
4080
|
-
const
|
|
4081
|
-
/*array=*/ !0),
|
|
4082
|
-
return new
|
|
4089
|
+
const e = $n(this, t,
|
|
4090
|
+
/*array=*/ !0), n = this.lt.map((t => Un(t, e))), r = new ye(n);
|
|
4091
|
+
return new ve(t.path, r);
|
|
4083
4092
|
}
|
|
4084
4093
|
isEqual(t) {
|
|
4085
4094
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4087,14 +4096,14 @@ class Fe extends be {
|
|
|
4087
4096
|
}
|
|
4088
4097
|
}
|
|
4089
4098
|
|
|
4090
|
-
class
|
|
4091
|
-
constructor(t,
|
|
4092
|
-
super(t), this.lt =
|
|
4099
|
+
class xn extends vn {
|
|
4100
|
+
constructor(t, e) {
|
|
4101
|
+
super(t), this.lt = e;
|
|
4093
4102
|
}
|
|
4094
4103
|
_toFieldTransform(t) {
|
|
4095
|
-
const
|
|
4096
|
-
/*array=*/ !0),
|
|
4097
|
-
return new
|
|
4104
|
+
const e = $n(this, t,
|
|
4105
|
+
/*array=*/ !0), n = this.lt.map((t => Un(t, e))), r = new _e(n);
|
|
4106
|
+
return new ve(t.path, r);
|
|
4098
4107
|
}
|
|
4099
4108
|
isEqual(t) {
|
|
4100
4109
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4102,13 +4111,13 @@ class xe extends be {
|
|
|
4102
4111
|
}
|
|
4103
4112
|
}
|
|
4104
4113
|
|
|
4105
|
-
class
|
|
4106
|
-
constructor(t,
|
|
4107
|
-
super(t), this.ft =
|
|
4114
|
+
class qn extends vn {
|
|
4115
|
+
constructor(t, e) {
|
|
4116
|
+
super(t), this.ft = e;
|
|
4108
4117
|
}
|
|
4109
4118
|
_toFieldTransform(t) {
|
|
4110
|
-
const
|
|
4111
|
-
return new
|
|
4119
|
+
const e = new ge(t.q, we(t.q, this.ft));
|
|
4120
|
+
return new ve(t.path, e);
|
|
4112
4121
|
}
|
|
4113
4122
|
isEqual(t) {
|
|
4114
4123
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4116,50 +4125,50 @@ class qe extends be {
|
|
|
4116
4125
|
}
|
|
4117
4126
|
}
|
|
4118
4127
|
|
|
4119
|
-
/** Parse update data from an update() call. */ function
|
|
4120
|
-
const s = t.ht(1 /* Update */ ,
|
|
4121
|
-
|
|
4128
|
+
/** Parse update data from an update() call. */ function On(t, e, n, r) {
|
|
4129
|
+
const s = t.ht(1 /* Update */ , e, n);
|
|
4130
|
+
Mn("Data must be an object, but it was:", s, r);
|
|
4122
4131
|
const i = [], o = Bt.empty();
|
|
4123
4132
|
Et(r, ((t, r) => {
|
|
4124
|
-
const u =
|
|
4133
|
+
const u = Gn(e, t, n);
|
|
4125
4134
|
// For Compat types, we have to "extract" the underlying types before
|
|
4126
4135
|
// performing validation.
|
|
4127
4136
|
r = getModularInstance(r);
|
|
4128
4137
|
const c = s.it(u);
|
|
4129
|
-
if (r instanceof
|
|
4138
|
+
if (r instanceof Nn)
|
|
4130
4139
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4131
4140
|
i.push(u); else {
|
|
4132
|
-
const t =
|
|
4141
|
+
const t = Un(r, c);
|
|
4133
4142
|
null != t && (i.push(u), o.set(u, t));
|
|
4134
4143
|
}
|
|
4135
4144
|
}));
|
|
4136
4145
|
const u = new Tt(i);
|
|
4137
|
-
return new
|
|
4146
|
+
return new In(o, u, s.fieldTransforms);
|
|
4138
4147
|
}
|
|
4139
4148
|
|
|
4140
|
-
/** Parse update data from a list of field/value arguments. */ function
|
|
4141
|
-
const o = t.ht(1 /* Update */ ,
|
|
4142
|
-
if (i.length % 2 != 0) throw new U(A, `Function ${
|
|
4143
|
-
for (let t = 0; t < i.length; t += 2) u.push(
|
|
4149
|
+
/** Parse update data from a list of field/value arguments. */ function Cn(t, e, n, r, s, i) {
|
|
4150
|
+
const o = t.ht(1 /* Update */ , e, n), u = [ Bn(e, r, n) ], c = [ s ];
|
|
4151
|
+
if (i.length % 2 != 0) throw new U(A, `Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);
|
|
4152
|
+
for (let t = 0; t < i.length; t += 2) u.push(Bn(e, i[t])), c.push(i[t + 1]);
|
|
4144
4153
|
const a = [], l = Bt.empty();
|
|
4145
4154
|
// We iterate in reverse order to pick the last value for a field if the
|
|
4146
4155
|
// user specified the field multiple times.
|
|
4147
|
-
for (let t = u.length - 1; t >= 0; --t) if (!
|
|
4148
|
-
const
|
|
4149
|
-
let
|
|
4156
|
+
for (let t = u.length - 1; t >= 0; --t) if (!Wn(a, u[t])) {
|
|
4157
|
+
const e = u[t];
|
|
4158
|
+
let n = c[t];
|
|
4150
4159
|
// For Compat types, we have to "extract" the underlying types before
|
|
4151
4160
|
// performing validation.
|
|
4152
|
-
|
|
4153
|
-
const r = o.it(
|
|
4154
|
-
if (
|
|
4161
|
+
n = getModularInstance(n);
|
|
4162
|
+
const r = o.it(e);
|
|
4163
|
+
if (n instanceof Nn)
|
|
4155
4164
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4156
|
-
a.push(
|
|
4157
|
-
const t =
|
|
4158
|
-
null != t && (a.push(
|
|
4165
|
+
a.push(e); else {
|
|
4166
|
+
const t = Un(n, r);
|
|
4167
|
+
null != t && (a.push(e), l.set(e, t));
|
|
4159
4168
|
}
|
|
4160
4169
|
}
|
|
4161
4170
|
const f = new Tt(a);
|
|
4162
|
-
return new
|
|
4171
|
+
return new In(l, f, o.fieldTransforms);
|
|
4163
4172
|
}
|
|
4164
4173
|
|
|
4165
4174
|
/**
|
|
@@ -4168,8 +4177,8 @@ class qe extends be {
|
|
|
4168
4177
|
*
|
|
4169
4178
|
* @param allowArrays - Whether the query value is an array that may directly
|
|
4170
4179
|
* contain additional arrays (e.g. the operand of an `in` query).
|
|
4171
|
-
*/ function
|
|
4172
|
-
return
|
|
4180
|
+
*/ function Ln(t, e, n, r = !1) {
|
|
4181
|
+
return Un(n, t.ht(r ? 4 /* ArrayArgument */ : 3 /* Argument */ , e));
|
|
4173
4182
|
}
|
|
4174
4183
|
|
|
4175
4184
|
/**
|
|
@@ -4180,12 +4189,12 @@ class qe extends be {
|
|
|
4180
4189
|
* the source of the data being parsed, etc.
|
|
4181
4190
|
* @returns The parsed value, or null if the value was a FieldValue sentinel
|
|
4182
4191
|
* that should not be included in the resulting parsed data.
|
|
4183
|
-
*/ function
|
|
4184
|
-
if (
|
|
4192
|
+
*/ function Un(t, e) {
|
|
4193
|
+
if (jn(
|
|
4185
4194
|
// Unwrap the API type from the Compat SDK. This will return the API type
|
|
4186
4195
|
// from firestore-exp.
|
|
4187
|
-
t = getModularInstance(t))) return
|
|
4188
|
-
if (t instanceof
|
|
4196
|
+
t = getModularInstance(t))) return Mn("Unsupported field value:", e, t), kn(t, e);
|
|
4197
|
+
if (t instanceof vn)
|
|
4189
4198
|
// FieldValues usually parse into transforms (except deleteField())
|
|
4190
4199
|
// in which case we do not want to include this field in our parsed data
|
|
4191
4200
|
// (as doing so will overwrite the field directly prior to the transform
|
|
@@ -4195,19 +4204,19 @@ class qe extends be {
|
|
|
4195
4204
|
* "Parses" the provided FieldValueImpl, adding any necessary transforms to
|
|
4196
4205
|
* context.fieldTransforms.
|
|
4197
4206
|
*/
|
|
4198
|
-
return function(t,
|
|
4207
|
+
return function(t, e) {
|
|
4199
4208
|
// Sentinels are only supported with writes, and not within arrays.
|
|
4200
|
-
if (!
|
|
4201
|
-
if (!
|
|
4202
|
-
const
|
|
4203
|
-
|
|
4209
|
+
if (!An(e.tt)) throw e.ut(`${t._methodName}() can only be used with update() and set()`);
|
|
4210
|
+
if (!e.path) throw e.ut(`${t._methodName}() is not currently supported inside arrays`);
|
|
4211
|
+
const n = t._toFieldTransform(e);
|
|
4212
|
+
n && e.fieldTransforms.push(n);
|
|
4204
4213
|
}
|
|
4205
4214
|
/**
|
|
4206
4215
|
* Helper to parse a scalar value (i.e. not an Object, Array, or FieldValue)
|
|
4207
4216
|
*
|
|
4208
4217
|
* @returns The parsed value
|
|
4209
|
-
*/ (t,
|
|
4210
|
-
if (void 0 === t &&
|
|
4218
|
+
*/ (t, e), null;
|
|
4219
|
+
if (void 0 === t && e.ignoreUndefinedProperties)
|
|
4211
4220
|
// If the input is undefined it can never participate in the fieldMask, so
|
|
4212
4221
|
// don't handle this below. If `ignoreUndefinedProperties` is false,
|
|
4213
4222
|
// `parseScalarValue` will reject an undefined value.
|
|
@@ -4215,38 +4224,38 @@ class qe extends be {
|
|
|
4215
4224
|
if (
|
|
4216
4225
|
// If context.path is null we are inside an array and we don't support
|
|
4217
4226
|
// field mask paths more granular than the top-level array.
|
|
4218
|
-
|
|
4227
|
+
e.path && e.fieldMask.push(e.path), t instanceof Array) {
|
|
4219
4228
|
// TODO(b/34871131): Include the path containing the array in the error
|
|
4220
4229
|
// message.
|
|
4221
4230
|
// In the case of IN queries, the parsed data is an array (representing
|
|
4222
4231
|
// the set of values to be included for the IN query) that may directly
|
|
4223
4232
|
// contain additional arrays (each representing an individual field
|
|
4224
4233
|
// value), so we disable this validation.
|
|
4225
|
-
if (
|
|
4226
|
-
return function(t,
|
|
4227
|
-
const
|
|
4234
|
+
if (e.settings.rt && 4 /* ArrayArgument */ !== e.tt) throw e.ut("Nested arrays are not supported");
|
|
4235
|
+
return function(t, e) {
|
|
4236
|
+
const n = [];
|
|
4228
4237
|
let r = 0;
|
|
4229
4238
|
for (const s of t) {
|
|
4230
|
-
let t =
|
|
4239
|
+
let t = Un(s, e.ot(r));
|
|
4231
4240
|
null == t && (
|
|
4232
4241
|
// Just include nulls in the array for fields being replaced with a
|
|
4233
4242
|
// sentinel.
|
|
4234
4243
|
t = {
|
|
4235
4244
|
nullValue: "NULL_VALUE"
|
|
4236
|
-
}),
|
|
4245
|
+
}), n.push(t), r++;
|
|
4237
4246
|
}
|
|
4238
4247
|
return {
|
|
4239
4248
|
arrayValue: {
|
|
4240
|
-
values:
|
|
4249
|
+
values: n
|
|
4241
4250
|
}
|
|
4242
4251
|
};
|
|
4243
|
-
}(t,
|
|
4252
|
+
}(t, e);
|
|
4244
4253
|
}
|
|
4245
|
-
return function(t,
|
|
4254
|
+
return function(t, e) {
|
|
4246
4255
|
if (null === (t = getModularInstance(t))) return {
|
|
4247
4256
|
nullValue: "NULL_VALUE"
|
|
4248
4257
|
};
|
|
4249
|
-
if ("number" == typeof t) return
|
|
4258
|
+
if ("number" == typeof t) return we(e.q, t);
|
|
4250
4259
|
if ("boolean" == typeof t) return {
|
|
4251
4260
|
booleanValue: t
|
|
4252
4261
|
};
|
|
@@ -4254,37 +4263,37 @@ class qe extends be {
|
|
|
4254
4263
|
stringValue: t
|
|
4255
4264
|
};
|
|
4256
4265
|
if (t instanceof Date) {
|
|
4257
|
-
const
|
|
4266
|
+
const n = gt.fromDate(t);
|
|
4258
4267
|
return {
|
|
4259
|
-
timestampValue:
|
|
4268
|
+
timestampValue: Ne(e.q, n)
|
|
4260
4269
|
};
|
|
4261
4270
|
}
|
|
4262
4271
|
if (t instanceof gt) {
|
|
4263
4272
|
// Firestore backend truncates precision down to microseconds. To ensure
|
|
4264
4273
|
// offline mode works the same with regards to truncation, perform the
|
|
4265
4274
|
// truncation immediately without waiting for the backend to do that.
|
|
4266
|
-
const
|
|
4275
|
+
const n = new gt(t.seconds, 1e3 * Math.floor(t.nanoseconds / 1e3));
|
|
4267
4276
|
return {
|
|
4268
|
-
timestampValue:
|
|
4277
|
+
timestampValue: Ne(e.q, n)
|
|
4269
4278
|
};
|
|
4270
4279
|
}
|
|
4271
|
-
if (t instanceof
|
|
4280
|
+
if (t instanceof bn) return {
|
|
4272
4281
|
geoPointValue: {
|
|
4273
4282
|
latitude: t.latitude,
|
|
4274
4283
|
longitude: t.longitude
|
|
4275
4284
|
}
|
|
4276
4285
|
};
|
|
4277
|
-
if (t instanceof
|
|
4278
|
-
bytesValue:
|
|
4286
|
+
if (t instanceof gn) return {
|
|
4287
|
+
bytesValue: $e(e.q, t._byteString)
|
|
4279
4288
|
};
|
|
4280
|
-
if (t instanceof
|
|
4281
|
-
const
|
|
4282
|
-
if (!r.isEqual(
|
|
4289
|
+
if (t instanceof an) {
|
|
4290
|
+
const n = e.databaseId, r = t.firestore._databaseId;
|
|
4291
|
+
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}`);
|
|
4283
4292
|
return {
|
|
4284
|
-
referenceValue:
|
|
4293
|
+
referenceValue: xe(t.firestore._databaseId || e.databaseId, t._key.path)
|
|
4285
4294
|
};
|
|
4286
4295
|
}
|
|
4287
|
-
throw
|
|
4296
|
+
throw e.ut(`Unsupported field value: ${it(t)}`);
|
|
4288
4297
|
}
|
|
4289
4298
|
/**
|
|
4290
4299
|
* Checks whether an object looks like a JSON object that should be converted
|
|
@@ -4292,56 +4301,56 @@ class qe extends be {
|
|
|
4292
4301
|
* JSON objects since they should be converted to a struct value. Arrays, Dates,
|
|
4293
4302
|
* GeoPoints, etc. are not considered to look like JSON objects since they map
|
|
4294
4303
|
* to specific FieldValue types other than ObjectValue.
|
|
4295
|
-
*/ (t,
|
|
4304
|
+
*/ (t, e);
|
|
4296
4305
|
}
|
|
4297
4306
|
|
|
4298
|
-
function
|
|
4299
|
-
const
|
|
4307
|
+
function kn(t, e) {
|
|
4308
|
+
const n = {};
|
|
4300
4309
|
return !function(t) {
|
|
4301
|
-
for (const
|
|
4310
|
+
for (const e in t) if (Object.prototype.hasOwnProperty.call(t, e)) return !1;
|
|
4302
4311
|
return !0;
|
|
4303
4312
|
}(t) ? Et(t, ((t, r) => {
|
|
4304
|
-
const s =
|
|
4305
|
-
null != s && (
|
|
4313
|
+
const s = Un(r, e.nt(t));
|
|
4314
|
+
null != s && (n[t] = s);
|
|
4306
4315
|
})) :
|
|
4307
4316
|
// If we encounter an empty object, we explicitly add it to the update
|
|
4308
4317
|
// mask to ensure that the server creates a map entry.
|
|
4309
|
-
|
|
4318
|
+
e.path && e.path.length > 0 && e.fieldMask.push(e.path), {
|
|
4310
4319
|
mapValue: {
|
|
4311
|
-
fields:
|
|
4320
|
+
fields: n
|
|
4312
4321
|
}
|
|
4313
4322
|
};
|
|
4314
4323
|
}
|
|
4315
4324
|
|
|
4316
|
-
function
|
|
4317
|
-
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof gt || t instanceof
|
|
4325
|
+
function jn(t) {
|
|
4326
|
+
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof gt || t instanceof bn || t instanceof gn || t instanceof an || t instanceof vn);
|
|
4318
4327
|
}
|
|
4319
4328
|
|
|
4320
|
-
function
|
|
4321
|
-
if (!
|
|
4329
|
+
function Mn(t, e, n) {
|
|
4330
|
+
if (!jn(n) || !function(t) {
|
|
4322
4331
|
return "object" == typeof t && null !== t && (Object.getPrototypeOf(t) === Object.prototype || null === Object.getPrototypeOf(t));
|
|
4323
|
-
}(
|
|
4324
|
-
const r = it(
|
|
4325
|
-
throw "an object" === r ?
|
|
4332
|
+
}(n)) {
|
|
4333
|
+
const r = it(n);
|
|
4334
|
+
throw "an object" === r ? e.ut(t + " a custom object") : e.ut(t + " " + r);
|
|
4326
4335
|
}
|
|
4327
4336
|
}
|
|
4328
4337
|
|
|
4329
4338
|
/**
|
|
4330
4339
|
* Helper that calls fromDotSeparatedString() but wraps any error thrown.
|
|
4331
|
-
*/ function
|
|
4340
|
+
*/ function Bn(t, e, n) {
|
|
4332
4341
|
if ((
|
|
4333
4342
|
// If required, replace the FieldPath Compat class with with the firestore-exp
|
|
4334
4343
|
// FieldPath.
|
|
4335
|
-
|
|
4336
|
-
if ("string" == typeof
|
|
4337
|
-
throw
|
|
4344
|
+
e = getModularInstance(e)) instanceof yn) return e._internalPath;
|
|
4345
|
+
if ("string" == typeof e) return Gn(t, e);
|
|
4346
|
+
throw Qn("Field path arguments must be of type string or ", t,
|
|
4338
4347
|
/* hasConverter= */ !1,
|
|
4339
|
-
/* path= */ void 0,
|
|
4348
|
+
/* path= */ void 0, n);
|
|
4340
4349
|
}
|
|
4341
4350
|
|
|
4342
4351
|
/**
|
|
4343
4352
|
* Matches any characters in a field path string that are reserved.
|
|
4344
|
-
*/ const
|
|
4353
|
+
*/ const zn = new RegExp("[~\\*/\\[\\]]");
|
|
4345
4354
|
|
|
4346
4355
|
/**
|
|
4347
4356
|
* Wraps fromDotSeparatedString with an error message about the method that
|
|
@@ -4351,30 +4360,30 @@ function Me(t, n, e) {
|
|
|
4351
4360
|
* split on dots.
|
|
4352
4361
|
* @param targetDoc - The document against which the field path will be
|
|
4353
4362
|
* evaluated.
|
|
4354
|
-
*/ function
|
|
4355
|
-
if (
|
|
4363
|
+
*/ function Gn(t, e, n) {
|
|
4364
|
+
if (e.search(zn) >= 0) throw Qn(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`, t,
|
|
4356
4365
|
/* hasConverter= */ !1,
|
|
4357
|
-
/* path= */ void 0,
|
|
4366
|
+
/* path= */ void 0, n);
|
|
4358
4367
|
try {
|
|
4359
|
-
return new
|
|
4368
|
+
return new yn(...e.split("."))._internalPath;
|
|
4360
4369
|
} catch (r) {
|
|
4361
|
-
throw
|
|
4370
|
+
throw Qn(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`, t,
|
|
4362
4371
|
/* hasConverter= */ !1,
|
|
4363
|
-
/* path= */ void 0,
|
|
4372
|
+
/* path= */ void 0, n);
|
|
4364
4373
|
}
|
|
4365
4374
|
}
|
|
4366
4375
|
|
|
4367
|
-
function
|
|
4376
|
+
function Qn(t, e, n, r, s) {
|
|
4368
4377
|
const i = r && !r.isEmpty(), o = void 0 !== s;
|
|
4369
|
-
let u = `Function ${
|
|
4370
|
-
|
|
4378
|
+
let u = `Function ${e}() called with invalid data`;
|
|
4379
|
+
n && (u += " (via `toFirestore()`)"), u += ". ";
|
|
4371
4380
|
let c = "";
|
|
4372
4381
|
return (i || o) && (c += " (found", i && (c += ` in field ${r}`), o && (c += ` in document ${s}`),
|
|
4373
4382
|
c += ")"), new U(A, u + t + c);
|
|
4374
4383
|
}
|
|
4375
4384
|
|
|
4376
|
-
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function
|
|
4377
|
-
return t.some((t => t.isEqual(
|
|
4385
|
+
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function Wn(t, e) {
|
|
4386
|
+
return t.some((t => t.isEqual(e)));
|
|
4378
4387
|
}
|
|
4379
4388
|
|
|
4380
4389
|
/**
|
|
@@ -4401,14 +4410,14 @@ function Qe(t, n, e, r, s) {
|
|
|
4401
4410
|
* For a `DocumentSnapshot` that points to a non-existing document, any data
|
|
4402
4411
|
* access will return 'undefined'. You can use the `exists()` method to
|
|
4403
4412
|
* explicitly verify a document's existence.
|
|
4404
|
-
*/ class
|
|
4413
|
+
*/ class Yn {
|
|
4405
4414
|
// Note: This class is stripped down version of the DocumentSnapshot in
|
|
4406
4415
|
// the legacy SDK. The changes are:
|
|
4407
4416
|
// - No support for SnapshotMetadata.
|
|
4408
4417
|
// - No support for SnapshotOptions.
|
|
4409
4418
|
/** @hideconstructor protected */
|
|
4410
|
-
constructor(t,
|
|
4411
|
-
this._firestore = t, this._userDataWriter =
|
|
4419
|
+
constructor(t, e, n, r, s) {
|
|
4420
|
+
this._firestore = t, this._userDataWriter = e, this._key = n, this._document = r,
|
|
4412
4421
|
this._converter = s;
|
|
4413
4422
|
}
|
|
4414
4423
|
/** Property of the `DocumentSnapshot` that provides the document's ID. */ get id() {
|
|
@@ -4417,7 +4426,7 @@ function Qe(t, n, e, r, s) {
|
|
|
4417
4426
|
/**
|
|
4418
4427
|
* The `DocumentReference` for the document included in the `DocumentSnapshot`.
|
|
4419
4428
|
*/ get ref() {
|
|
4420
|
-
return new
|
|
4429
|
+
return new an(this._firestore, this._converter, this._key);
|
|
4421
4430
|
}
|
|
4422
4431
|
/**
|
|
4423
4432
|
* Signals whether or not the document at the snapshot's location exists.
|
|
@@ -4437,7 +4446,7 @@ function Qe(t, n, e, r, s) {
|
|
|
4437
4446
|
if (this._converter) {
|
|
4438
4447
|
// We only want to use the converter and create a new DocumentSnapshot
|
|
4439
4448
|
// if a converter has been provided.
|
|
4440
|
-
const t = new
|
|
4449
|
+
const t = new Hn(this._firestore, this._userDataWriter, this._key, this._document,
|
|
4441
4450
|
/* converter= */ null);
|
|
4442
4451
|
return this._converter.fromFirestore(t);
|
|
4443
4452
|
}
|
|
@@ -4457,8 +4466,8 @@ function Qe(t, n, e, r, s) {
|
|
|
4457
4466
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4458
4467
|
get(t) {
|
|
4459
4468
|
if (this._document) {
|
|
4460
|
-
const
|
|
4461
|
-
if (null !==
|
|
4469
|
+
const e = this._document.data.field(Xn("DocumentSnapshot.get", t));
|
|
4470
|
+
if (null !== e) return this._userDataWriter.convertValue(e);
|
|
4462
4471
|
}
|
|
4463
4472
|
}
|
|
4464
4473
|
}
|
|
@@ -4473,7 +4482,7 @@ function Qe(t, n, e, r, s) {
|
|
|
4473
4482
|
* `DocumentSnapshot`. Since query results contain only existing documents, the
|
|
4474
4483
|
* `exists` property will always be true and `data()` will never return
|
|
4475
4484
|
* 'undefined'.
|
|
4476
|
-
*/ class
|
|
4485
|
+
*/ class Hn extends Yn {
|
|
4477
4486
|
/**
|
|
4478
4487
|
* Retrieves all fields in the document as an `Object`.
|
|
4479
4488
|
*
|
|
@@ -4491,10 +4500,10 @@ function Qe(t, n, e, r, s) {
|
|
|
4491
4500
|
* array via the `docs` property or enumerated using the `forEach` method. The
|
|
4492
4501
|
* number of documents can be determined via the `empty` and `size`
|
|
4493
4502
|
* properties.
|
|
4494
|
-
*/ class
|
|
4503
|
+
*/ class Kn {
|
|
4495
4504
|
/** @hideconstructor */
|
|
4496
|
-
constructor(t,
|
|
4497
|
-
this._docs =
|
|
4505
|
+
constructor(t, e) {
|
|
4506
|
+
this._docs = e, this.query = t;
|
|
4498
4507
|
}
|
|
4499
4508
|
/** An array of all the documents in the `QuerySnapshot`. */ get docs() {
|
|
4500
4509
|
return [ ...this._docs ];
|
|
@@ -4511,8 +4520,8 @@ function Qe(t, n, e, r, s) {
|
|
|
4511
4520
|
* @param callback - A callback to be called with a `QueryDocumentSnapshot` for
|
|
4512
4521
|
* each document in the snapshot.
|
|
4513
4522
|
* @param thisArg - The `this` binding for the callback.
|
|
4514
|
-
*/ forEach(t,
|
|
4515
|
-
this._docs.forEach(t,
|
|
4523
|
+
*/ forEach(t, e) {
|
|
4524
|
+
this._docs.forEach(t, e);
|
|
4516
4525
|
}
|
|
4517
4526
|
}
|
|
4518
4527
|
|
|
@@ -4522,14 +4531,14 @@ function Qe(t, n, e, r, s) {
|
|
|
4522
4531
|
* @param left - A snapshot to compare.
|
|
4523
4532
|
* @param right - A snapshot to compare.
|
|
4524
4533
|
* @returns true if the snapshots are equal.
|
|
4525
|
-
*/ function
|
|
4526
|
-
return t = getModularInstance(t),
|
|
4534
|
+
*/ function Jn(t, e) {
|
|
4535
|
+
return t = getModularInstance(t), e = getModularInstance(e), t instanceof Yn && e instanceof Yn ? 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 Kn && e instanceof Kn && (pn(t.query, e.query) && _t(t.docs, e.docs, Jn));
|
|
4527
4536
|
}
|
|
4528
4537
|
|
|
4529
4538
|
/**
|
|
4530
4539
|
* Helper that calls `fromDotSeparatedString()` but wraps any error thrown.
|
|
4531
|
-
*/ function
|
|
4532
|
-
return "string" == typeof
|
|
4540
|
+
*/ function Xn(t, e) {
|
|
4541
|
+
return "string" == typeof e ? Gn(t, e) : e instanceof yn ? e._internalPath : e._delegate._internalPath;
|
|
4533
4542
|
}
|
|
4534
4543
|
|
|
4535
4544
|
/**
|
|
@@ -4556,7 +4565,7 @@ function Qe(t, n, e, r, s) {
|
|
|
4556
4565
|
* can then be passed to {@link query} to create a new query instance that
|
|
4557
4566
|
* also contains this `QueryConstraint`.
|
|
4558
4567
|
*/
|
|
4559
|
-
class
|
|
4568
|
+
class Zn {}
|
|
4560
4569
|
|
|
4561
4570
|
/**
|
|
4562
4571
|
* Creates a new immutable instance of {@link Query} that is extended to also include
|
|
@@ -4566,43 +4575,43 @@ class Ze {}
|
|
|
4566
4575
|
* @param queryConstraints - The list of {@link QueryConstraint}s to apply.
|
|
4567
4576
|
* @throws if any of the provided query constraints cannot be combined with the
|
|
4568
4577
|
* existing or new constraints.
|
|
4569
|
-
*/ function tr(t, ...
|
|
4570
|
-
for (const
|
|
4578
|
+
*/ function tr(t, ...e) {
|
|
4579
|
+
for (const n of e) t = n._apply(t);
|
|
4571
4580
|
return t;
|
|
4572
4581
|
}
|
|
4573
4582
|
|
|
4574
|
-
class
|
|
4575
|
-
constructor(t,
|
|
4576
|
-
super(), this.dt = t, this.wt =
|
|
4583
|
+
class er extends Zn {
|
|
4584
|
+
constructor(t, e, n) {
|
|
4585
|
+
super(), this.dt = t, this.wt = e, this.yt = n, this.type = "where";
|
|
4577
4586
|
}
|
|
4578
4587
|
_apply(t) {
|
|
4579
|
-
const
|
|
4588
|
+
const e = Vn(t.firestore), n = function(t, e, n, r, s, i, o) {
|
|
4580
4589
|
let u;
|
|
4581
4590
|
if (s.isKeyField()) {
|
|
4582
4591
|
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new U(A, `Invalid Query. You can't perform '${i}' queries on documentId().`);
|
|
4583
4592
|
if ("in" /* IN */ === i || "not-in" /* NOT_IN */ === i) {
|
|
4584
4593
|
pr(o, i);
|
|
4585
|
-
const
|
|
4586
|
-
for (const
|
|
4594
|
+
const e = [];
|
|
4595
|
+
for (const n of o) e.push(mr(r, t, n));
|
|
4587
4596
|
u = {
|
|
4588
4597
|
arrayValue: {
|
|
4589
|
-
values:
|
|
4598
|
+
values: e
|
|
4590
4599
|
}
|
|
4591
4600
|
};
|
|
4592
4601
|
} else u = mr(r, t, o);
|
|
4593
4602
|
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i || pr(o, i),
|
|
4594
|
-
u =
|
|
4603
|
+
u = Ln(n, e, o,
|
|
4595
4604
|
/* allowArrays= */ "in" /* IN */ === i || "not-in" /* NOT_IN */ === i);
|
|
4596
4605
|
const c = Wt.create(s, i, u);
|
|
4597
|
-
return function(t,
|
|
4598
|
-
if (
|
|
4599
|
-
const
|
|
4600
|
-
if (null !==
|
|
4601
|
-
const r =
|
|
4602
|
-
null !== r && yr(t,
|
|
4606
|
+
return function(t, e) {
|
|
4607
|
+
if (e.N()) {
|
|
4608
|
+
const n = ae(t);
|
|
4609
|
+
if (null !== n && !n.isEqual(e.field)) throw new U(A, `Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '${n.toString()}' and '${e.field.toString()}'`);
|
|
4610
|
+
const r = ce(t);
|
|
4611
|
+
null !== r && yr(t, e.field, r);
|
|
4603
4612
|
}
|
|
4604
|
-
const
|
|
4605
|
-
for (const
|
|
4613
|
+
const n = function(t, e) {
|
|
4614
|
+
for (const n of t.filters) if (e.indexOf(n.op) >= 0) return n.op;
|
|
4606
4615
|
return null;
|
|
4607
4616
|
}(t,
|
|
4608
4617
|
/**
|
|
@@ -4637,16 +4646,16 @@ class nr extends Ze {
|
|
|
4637
4646
|
default:
|
|
4638
4647
|
return [];
|
|
4639
4648
|
}
|
|
4640
|
-
}(
|
|
4641
|
-
if (null !==
|
|
4649
|
+
}(e.op));
|
|
4650
|
+
if (null !== n)
|
|
4642
4651
|
// Special case when it's a duplicate op to give a slightly clearer error message.
|
|
4643
|
-
throw
|
|
4652
|
+
throw n === e.op ? new U(A, `Invalid query. You cannot use more than one '${e.op.toString()}' filter.`) : new U(A, `Invalid query. You cannot use '${e.op.toString()}' filters with '${n.toString()}' filters.`);
|
|
4644
4653
|
}(t, c), c;
|
|
4645
|
-
}(t._query, "where",
|
|
4646
|
-
return new
|
|
4647
|
-
const
|
|
4648
|
-
return new
|
|
4649
|
-
}(t._query,
|
|
4654
|
+
}(t._query, "where", e, t.firestore._databaseId, this.dt, this.wt, this.yt);
|
|
4655
|
+
return new hn(t.firestore, t.converter, function(t, e) {
|
|
4656
|
+
const n = t.filters.concat([ e ]);
|
|
4657
|
+
return new oe(t.path, t.collectionGroup, t.explicitOrderBy.slice(), n, t.limit, t.limitType, t.startAt, t.endAt);
|
|
4658
|
+
}(t._query, n));
|
|
4650
4659
|
}
|
|
4651
4660
|
}
|
|
4652
4661
|
|
|
@@ -4660,25 +4669,25 @@ class nr extends Ze {
|
|
|
4660
4669
|
* "<=", "!=").
|
|
4661
4670
|
* @param value - The value for comparison
|
|
4662
4671
|
* @returns The created {@link Query}.
|
|
4663
|
-
*/ function
|
|
4664
|
-
const r =
|
|
4665
|
-
return new
|
|
4672
|
+
*/ function nr(t, e, n) {
|
|
4673
|
+
const r = e, s = Xn("where", t);
|
|
4674
|
+
return new er(s, r, n);
|
|
4666
4675
|
}
|
|
4667
4676
|
|
|
4668
|
-
class rr extends
|
|
4669
|
-
constructor(t,
|
|
4670
|
-
super(), this.dt = t, this._t =
|
|
4677
|
+
class rr extends Zn {
|
|
4678
|
+
constructor(t, e) {
|
|
4679
|
+
super(), this.dt = t, this._t = e, this.type = "orderBy";
|
|
4671
4680
|
}
|
|
4672
4681
|
_apply(t) {
|
|
4673
|
-
const
|
|
4682
|
+
const e = function(t, e, n) {
|
|
4674
4683
|
if (null !== t.startAt) throw new U(A, "Invalid query. You must not call startAt() or startAfter() before calling orderBy().");
|
|
4675
4684
|
if (null !== t.endAt) throw new U(A, "Invalid query. You must not call endAt() or endBefore() before calling orderBy().");
|
|
4676
|
-
const r = new
|
|
4677
|
-
return function(t,
|
|
4678
|
-
if (null ===
|
|
4685
|
+
const r = new re(e, n);
|
|
4686
|
+
return function(t, e) {
|
|
4687
|
+
if (null === ce(t)) {
|
|
4679
4688
|
// This is the first order by. It must match any inequality.
|
|
4680
|
-
const
|
|
4681
|
-
null !==
|
|
4689
|
+
const n = ae(t);
|
|
4690
|
+
null !== n && yr(t, n, e.field);
|
|
4682
4691
|
}
|
|
4683
4692
|
}(t, r), r;
|
|
4684
4693
|
}
|
|
@@ -4693,11 +4702,11 @@ class rr extends Ze {
|
|
|
4693
4702
|
* of the query or if any of the fields in the order by are an uncommitted
|
|
4694
4703
|
* server timestamp.
|
|
4695
4704
|
*/ (t._query, this.dt, this._t);
|
|
4696
|
-
return new
|
|
4705
|
+
return new hn(t.firestore, t.converter, function(t, e) {
|
|
4697
4706
|
// TODO(dimond): validate that orderBy does not list the same key twice.
|
|
4698
|
-
const
|
|
4699
|
-
return new
|
|
4700
|
-
}(t._query,
|
|
4707
|
+
const n = t.explicitOrderBy.concat([ e ]);
|
|
4708
|
+
return new oe(t.path, t.collectionGroup, n, t.filters.slice(), t.limit, t.limitType, t.startAt, t.endAt);
|
|
4709
|
+
}(t._query, e));
|
|
4701
4710
|
}
|
|
4702
4711
|
}
|
|
4703
4712
|
|
|
@@ -4709,19 +4718,19 @@ class rr extends Ze {
|
|
|
4709
4718
|
* @param directionStr - Optional direction to sort by ('asc' or 'desc'). If
|
|
4710
4719
|
* not specified, order will be ascending.
|
|
4711
4720
|
* @returns The created {@link Query}.
|
|
4712
|
-
*/ function sr(t,
|
|
4713
|
-
const
|
|
4714
|
-
return new rr(r,
|
|
4721
|
+
*/ function sr(t, e = "asc") {
|
|
4722
|
+
const n = e, r = Xn("orderBy", t);
|
|
4723
|
+
return new rr(r, n);
|
|
4715
4724
|
}
|
|
4716
4725
|
|
|
4717
|
-
class ir extends
|
|
4718
|
-
constructor(t,
|
|
4719
|
-
super(), this.type = t, this.gt =
|
|
4726
|
+
class ir extends Zn {
|
|
4727
|
+
constructor(t, e, n) {
|
|
4728
|
+
super(), this.type = t, this.gt = e, this.vt = n;
|
|
4720
4729
|
}
|
|
4721
4730
|
_apply(t) {
|
|
4722
|
-
return new
|
|
4723
|
-
return new
|
|
4724
|
-
}(t._query, this.gt, this.
|
|
4731
|
+
return new hn(t.firestore, t.converter, function(t, e, n) {
|
|
4732
|
+
return new oe(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), e, n, t.startAt, t.endAt);
|
|
4733
|
+
}(t._query, this.gt, this.vt));
|
|
4725
4734
|
}
|
|
4726
4735
|
}
|
|
4727
4736
|
|
|
@@ -4746,15 +4755,15 @@ class ir extends Ze {
|
|
|
4746
4755
|
return ut("limitToLast", t), new ir("limitToLast", t, "L" /* Last */);
|
|
4747
4756
|
}
|
|
4748
4757
|
|
|
4749
|
-
class cr extends
|
|
4750
|
-
constructor(t,
|
|
4751
|
-
super(), this.type = t, this.
|
|
4758
|
+
class cr extends Zn {
|
|
4759
|
+
constructor(t, e, n) {
|
|
4760
|
+
super(), this.type = t, this.bt = e, this.Et = n;
|
|
4752
4761
|
}
|
|
4753
4762
|
_apply(t) {
|
|
4754
|
-
const
|
|
4755
|
-
return new
|
|
4756
|
-
return new
|
|
4757
|
-
}(t._query,
|
|
4763
|
+
const e = wr(t, this.type, this.bt, this.Et);
|
|
4764
|
+
return new hn(t.firestore, t.converter, function(t, e) {
|
|
4765
|
+
return new oe(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, e, t.endAt);
|
|
4766
|
+
}(t._query, e));
|
|
4758
4767
|
}
|
|
4759
4768
|
}
|
|
4760
4769
|
|
|
@@ -4768,15 +4777,15 @@ function hr(...t) {
|
|
|
4768
4777
|
/*inclusive=*/ !1);
|
|
4769
4778
|
}
|
|
4770
4779
|
|
|
4771
|
-
class lr extends
|
|
4772
|
-
constructor(t,
|
|
4773
|
-
super(), this.type = t, this.
|
|
4780
|
+
class lr extends Zn {
|
|
4781
|
+
constructor(t, e, n) {
|
|
4782
|
+
super(), this.type = t, this.bt = e, this.Et = n;
|
|
4774
4783
|
}
|
|
4775
4784
|
_apply(t) {
|
|
4776
|
-
const
|
|
4777
|
-
return new
|
|
4778
|
-
return new
|
|
4779
|
-
}(t._query,
|
|
4785
|
+
const e = wr(t, this.type, this.bt, this.Et);
|
|
4786
|
+
return new hn(t.firestore, t.converter, function(t, e) {
|
|
4787
|
+
return new oe(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, t.startAt, e);
|
|
4788
|
+
}(t._query, e));
|
|
4780
4789
|
}
|
|
4781
4790
|
}
|
|
4782
4791
|
|
|
@@ -4789,9 +4798,9 @@ function dr(...t) {
|
|
|
4789
4798
|
return new lr("endAt", t, /*inclusive=*/ !0);
|
|
4790
4799
|
}
|
|
4791
4800
|
|
|
4792
|
-
/** Helper function to create a bound from a document or fields */ function wr(t,
|
|
4793
|
-
if (
|
|
4794
|
-
if (!r) throw new U(P, `Can't use a DocumentSnapshot that doesn't exist for ${
|
|
4801
|
+
/** Helper function to create a bound from a document or fields */ function wr(t, e, n, r) {
|
|
4802
|
+
if (n[0] = getModularInstance(n[0]), n[0] instanceof Yn) return function(t, e, n, r, s) {
|
|
4803
|
+
if (!r) throw new U(P, `Can't use a DocumentSnapshot that doesn't exist for ${n}().`);
|
|
4795
4804
|
const i = [];
|
|
4796
4805
|
// Because people expect to continue/end a query at the exact document
|
|
4797
4806
|
// provided, we need to use the implicit sort order rather than the explicit
|
|
@@ -4800,23 +4809,23 @@ function dr(...t) {
|
|
|
4800
4809
|
// the provided document. Without the key (by using the explicit sort
|
|
4801
4810
|
// orders), multiple documents could match the position, yielding duplicate
|
|
4802
4811
|
// results.
|
|
4803
|
-
for (const
|
|
4804
|
-
const t = r.data.field(
|
|
4805
|
-
if (Dt(t)) throw new U(A, 'Invalid query. You are trying to start or end a query using a document for which the field "' +
|
|
4812
|
+
for (const n of le(t)) if (n.field.isKeyField()) i.push(Ct(e, r.key)); else {
|
|
4813
|
+
const t = r.data.field(n.field);
|
|
4814
|
+
if (Dt(t)) throw new U(A, 'Invalid query. You are trying to start or end a query using a document for which the field "' + n.field + '" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');
|
|
4806
4815
|
if (null === t) {
|
|
4807
|
-
const t =
|
|
4816
|
+
const t = n.field.canonicalString();
|
|
4808
4817
|
throw new U(A, `Invalid query. You are trying to start or end a query using a document for which the field '${t}' (used as the orderBy) does not exist.`);
|
|
4809
4818
|
}
|
|
4810
4819
|
i.push(t);
|
|
4811
4820
|
}
|
|
4812
|
-
return new
|
|
4821
|
+
return new ne(i, s);
|
|
4813
4822
|
}
|
|
4814
4823
|
/**
|
|
4815
4824
|
* Converts a list of field values to a `Bound` for the given query.
|
|
4816
|
-
*/ (t._query, t.firestore._databaseId,
|
|
4825
|
+
*/ (t._query, t.firestore._databaseId, e, n[0]._document, r);
|
|
4817
4826
|
{
|
|
4818
|
-
const s =
|
|
4819
|
-
return function(t,
|
|
4827
|
+
const s = Vn(t.firestore);
|
|
4828
|
+
return function(t, e, n, r, s, i) {
|
|
4820
4829
|
// Use explicit order by's because it has to match the query the user made
|
|
4821
4830
|
const o = t.explicitOrderBy;
|
|
4822
4831
|
if (s.length > o.length) throw new U(A, `Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);
|
|
@@ -4825,48 +4834,48 @@ function dr(...t) {
|
|
|
4825
4834
|
const c = s[i];
|
|
4826
4835
|
if (o[i].field.isKeyField()) {
|
|
4827
4836
|
if ("string" != typeof c) throw new U(A, `Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);
|
|
4828
|
-
if (!
|
|
4829
|
-
const
|
|
4830
|
-
if (!
|
|
4831
|
-
const s = new
|
|
4832
|
-
u.push(Ct(
|
|
4837
|
+
if (!he(t) && -1 !== c.indexOf("/")) throw new U(A, `Invalid query. When querying a collection and ordering by documentId(), the value passed to ${r}() must be a plain document ID, but '${c}' contains a slash.`);
|
|
4838
|
+
const n = t.path.child(X.fromString(c));
|
|
4839
|
+
if (!et.isDocumentKey(n)) throw new U(A, `Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${r}() must result in a valid document path, but '${n}' is not because it contains an odd number of segments.`);
|
|
4840
|
+
const s = new et(n);
|
|
4841
|
+
u.push(Ct(e, s));
|
|
4833
4842
|
} else {
|
|
4834
|
-
const t =
|
|
4843
|
+
const t = Ln(n, r, c);
|
|
4835
4844
|
u.push(t);
|
|
4836
4845
|
}
|
|
4837
4846
|
}
|
|
4838
|
-
return new
|
|
4847
|
+
return new ne(u, i);
|
|
4839
4848
|
}
|
|
4840
4849
|
/**
|
|
4841
4850
|
* Parses the given `documentIdValue` into a `ReferenceValue`, throwing
|
|
4842
4851
|
* appropriate errors if the value is anything other than a `DocumentReference`
|
|
4843
4852
|
* or `string`, or if the string is malformed.
|
|
4844
|
-
*/ (t._query, t.firestore._databaseId, s,
|
|
4853
|
+
*/ (t._query, t.firestore._databaseId, s, e, n, r);
|
|
4845
4854
|
}
|
|
4846
4855
|
}
|
|
4847
4856
|
|
|
4848
|
-
function mr(t,
|
|
4849
|
-
if ("string" == typeof (
|
|
4850
|
-
if ("" ===
|
|
4851
|
-
if (!
|
|
4852
|
-
const r =
|
|
4853
|
-
if (!
|
|
4854
|
-
return Ct(t, new
|
|
4857
|
+
function mr(t, e, n) {
|
|
4858
|
+
if ("string" == typeof (n = getModularInstance(n))) {
|
|
4859
|
+
if ("" === n) throw new U(A, "Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");
|
|
4860
|
+
if (!he(e) && -1 !== n.indexOf("/")) throw new U(A, `Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);
|
|
4861
|
+
const r = e.path.child(X.fromString(n));
|
|
4862
|
+
if (!et.isDocumentKey(r)) throw new U(A, `Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);
|
|
4863
|
+
return Ct(t, new et(r));
|
|
4855
4864
|
}
|
|
4856
|
-
if (
|
|
4857
|
-
throw new U(A, `Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${it(
|
|
4865
|
+
if (n instanceof an) return Ct(t, n._key);
|
|
4866
|
+
throw new U(A, `Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${it(n)}.`);
|
|
4858
4867
|
}
|
|
4859
4868
|
|
|
4860
4869
|
/**
|
|
4861
4870
|
* Validates that the value passed into a disjunctive filter satisfies all
|
|
4862
4871
|
* array requirements.
|
|
4863
|
-
*/ function pr(t,
|
|
4864
|
-
if (!Array.isArray(t) || 0 === t.length) throw new U(A, `Invalid Query. A non-empty array is required for '${
|
|
4865
|
-
if (t.length > 10) throw new U(A, `Invalid Query. '${
|
|
4872
|
+
*/ function pr(t, e) {
|
|
4873
|
+
if (!Array.isArray(t) || 0 === t.length) throw new U(A, `Invalid Query. A non-empty array is required for '${e.toString()}' filters.`);
|
|
4874
|
+
if (t.length > 10) throw new U(A, `Invalid Query. '${e.toString()}' filters support a maximum of 10 elements in the value array.`);
|
|
4866
4875
|
}
|
|
4867
4876
|
|
|
4868
|
-
function yr(t,
|
|
4869
|
-
if (!
|
|
4877
|
+
function yr(t, e, n) {
|
|
4878
|
+
if (!n.isEqual(e)) throw new U(A, `Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '${e.toString()}' and so you must also use '${e.toString()}' as your first argument to orderBy(), but your first orderBy() is on field '${n.toString()}' instead.`);
|
|
4870
4879
|
}
|
|
4871
4880
|
|
|
4872
4881
|
/**
|
|
@@ -4916,17 +4925,17 @@ function yr(t, n, e) {
|
|
|
4916
4925
|
* their `set()` or fails due to invalid data originating from a `toFirestore()`
|
|
4917
4926
|
* call.
|
|
4918
4927
|
*/
|
|
4919
|
-
function _r(t,
|
|
4928
|
+
function _r(t, e, n) {
|
|
4920
4929
|
let r;
|
|
4921
4930
|
// Cast to `any` in order to satisfy the union type constraint on
|
|
4922
4931
|
// toFirestore().
|
|
4923
4932
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4924
|
-
return r = t ?
|
|
4933
|
+
return r = t ? n && (n.merge || n.mergeFields) ? t.toFirestore(e, n) : t.toFirestore(e) : e,
|
|
4925
4934
|
r;
|
|
4926
4935
|
}
|
|
4927
4936
|
|
|
4928
4937
|
class gr extends class {
|
|
4929
|
-
convertValue(t,
|
|
4938
|
+
convertValue(t, e = "none") {
|
|
4930
4939
|
switch (St(t)) {
|
|
4931
4940
|
case 0 /* NullValue */ :
|
|
4932
4941
|
return null;
|
|
@@ -4941,7 +4950,7 @@ class gr extends class {
|
|
|
4941
4950
|
return this.convertTimestamp(t.timestampValue);
|
|
4942
4951
|
|
|
4943
4952
|
case 4 /* ServerTimestampValue */ :
|
|
4944
|
-
return this.convertServerTimestamp(t,
|
|
4953
|
+
return this.convertServerTimestamp(t, e);
|
|
4945
4954
|
|
|
4946
4955
|
case 5 /* StringValue */ :
|
|
4947
4956
|
return t.stringValue;
|
|
@@ -4956,32 +4965,32 @@ class gr extends class {
|
|
|
4956
4965
|
return this.convertGeoPoint(t.geoPointValue);
|
|
4957
4966
|
|
|
4958
4967
|
case 9 /* ArrayValue */ :
|
|
4959
|
-
return this.convertArray(t.arrayValue,
|
|
4968
|
+
return this.convertArray(t.arrayValue, e);
|
|
4960
4969
|
|
|
4961
4970
|
case 10 /* ObjectValue */ :
|
|
4962
|
-
return this.convertObject(t.mapValue,
|
|
4971
|
+
return this.convertObject(t.mapValue, e);
|
|
4963
4972
|
|
|
4964
4973
|
default:
|
|
4965
4974
|
throw g();
|
|
4966
4975
|
}
|
|
4967
4976
|
}
|
|
4968
|
-
convertObject(t,
|
|
4969
|
-
const
|
|
4977
|
+
convertObject(t, e) {
|
|
4978
|
+
const n = {};
|
|
4970
4979
|
return Et(t.fields, ((t, r) => {
|
|
4971
|
-
|
|
4972
|
-
})),
|
|
4980
|
+
n[t] = this.convertValue(r, e);
|
|
4981
|
+
})), n;
|
|
4973
4982
|
}
|
|
4974
4983
|
convertGeoPoint(t) {
|
|
4975
|
-
return new
|
|
4984
|
+
return new bn(Pt(t.latitude), Pt(t.longitude));
|
|
4976
4985
|
}
|
|
4977
|
-
convertArray(t,
|
|
4978
|
-
return (t.values || []).map((t => this.convertValue(t,
|
|
4986
|
+
convertArray(t, e) {
|
|
4987
|
+
return (t.values || []).map((t => this.convertValue(t, e)));
|
|
4979
4988
|
}
|
|
4980
|
-
convertServerTimestamp(t,
|
|
4981
|
-
switch (
|
|
4989
|
+
convertServerTimestamp(t, e) {
|
|
4990
|
+
switch (e) {
|
|
4982
4991
|
case "previous":
|
|
4983
|
-
const
|
|
4984
|
-
return null ==
|
|
4992
|
+
const n = Nt(t);
|
|
4993
|
+
return null == n ? null : this.convertValue(n, e);
|
|
4985
4994
|
|
|
4986
4995
|
case "estimate":
|
|
4987
4996
|
return this.convertTimestamp($t(t));
|
|
@@ -4991,16 +5000,16 @@ class gr extends class {
|
|
|
4991
5000
|
}
|
|
4992
5001
|
}
|
|
4993
5002
|
convertTimestamp(t) {
|
|
4994
|
-
const
|
|
4995
|
-
return new gt(
|
|
5003
|
+
const e = Rt(t);
|
|
5004
|
+
return new gt(e.seconds, e.nanos);
|
|
4996
5005
|
}
|
|
4997
|
-
convertDocumentKey(t,
|
|
4998
|
-
const
|
|
4999
|
-
|
|
5000
|
-
const r = new K(
|
|
5001
|
-
return r.isEqual(
|
|
5006
|
+
convertDocumentKey(t, e) {
|
|
5007
|
+
const n = X.fromString(t);
|
|
5008
|
+
v(We(n));
|
|
5009
|
+
const r = new K(n.get(1), n.get(3)), s = new et(n.popFirst(5));
|
|
5010
|
+
return r.isEqual(e) ||
|
|
5002
5011
|
// TODO(b/64130202): Somehow support foreign references.
|
|
5003
|
-
p(`Document ${s} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${
|
|
5012
|
+
p(`Document ${s} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${e.projectId}/${e.database}) instead.`),
|
|
5004
5013
|
s;
|
|
5005
5014
|
}
|
|
5006
5015
|
} {
|
|
@@ -5008,11 +5017,11 @@ class gr extends class {
|
|
|
5008
5017
|
super(), this.firestore = t;
|
|
5009
5018
|
}
|
|
5010
5019
|
convertBytes(t) {
|
|
5011
|
-
return new
|
|
5020
|
+
return new gn(t);
|
|
5012
5021
|
}
|
|
5013
5022
|
convertReference(t) {
|
|
5014
|
-
const
|
|
5015
|
-
return new
|
|
5023
|
+
const e = this.convertDocumentKey(t, this.firestore._databaseId);
|
|
5024
|
+
return new an(this.firestore, /* converter= */ null, e);
|
|
5016
5025
|
}
|
|
5017
5026
|
}
|
|
5018
5027
|
|
|
@@ -5028,12 +5037,12 @@ class gr extends class {
|
|
|
5028
5037
|
* @param reference - The reference of the document to fetch.
|
|
5029
5038
|
* @returns A Promise resolved with a `DocumentSnapshot` containing the current
|
|
5030
5039
|
* document contents.
|
|
5031
|
-
*/ function
|
|
5032
|
-
const
|
|
5033
|
-
return
|
|
5034
|
-
|
|
5035
|
-
const r =
|
|
5036
|
-
return new
|
|
5040
|
+
*/ function vr(t) {
|
|
5041
|
+
const e = en((t = ot(t, an)).firestore), n = new gr(t.firestore);
|
|
5042
|
+
return Xe(e, [ t._key ]).then((e => {
|
|
5043
|
+
v(1 === e.length);
|
|
5044
|
+
const r = e[0];
|
|
5045
|
+
return new Yn(t.firestore, n, t._key, r.isFoundDocument() ? r : null, t.converter);
|
|
5037
5046
|
}));
|
|
5038
5047
|
}
|
|
5039
5048
|
|
|
@@ -5048,33 +5057,33 @@ class gr extends class {
|
|
|
5048
5057
|
*
|
|
5049
5058
|
* @param query - The `Query` to execute.
|
|
5050
5059
|
* @returns A Promise that will be resolved with the results of the query.
|
|
5051
|
-
*/ function
|
|
5060
|
+
*/ function br(t) {
|
|
5052
5061
|
!function(t) {
|
|
5053
|
-
if (
|
|
5054
|
-
}((t = ot(t,
|
|
5055
|
-
const
|
|
5056
|
-
return
|
|
5057
|
-
const r =
|
|
5058
|
-
return
|
|
5062
|
+
if (ue(t) && 0 === t.explicitOrderBy.length) throw new U(q, "limitToLast() queries require specifying at least one orderBy() clause");
|
|
5063
|
+
}((t = ot(t, hn))._query);
|
|
5064
|
+
const e = en(t.firestore), n = new gr(t.firestore);
|
|
5065
|
+
return Ze(e, t._query).then((e => {
|
|
5066
|
+
const r = e.map((e => new Hn(t.firestore, n, e.key, e, t.converter)));
|
|
5067
|
+
return ue(t._query) &&
|
|
5059
5068
|
// Limit to last queries reverse the orderBy constraint that was
|
|
5060
5069
|
// specified by the user. As such, we need to reverse the order of the
|
|
5061
5070
|
// results to return the documents in the expected order.
|
|
5062
|
-
r.reverse(), new
|
|
5071
|
+
r.reverse(), new Kn(t, r);
|
|
5063
5072
|
}));
|
|
5064
5073
|
}
|
|
5065
5074
|
|
|
5066
|
-
function Er(t,
|
|
5067
|
-
const r = _r((t = ot(t,
|
|
5068
|
-
return
|
|
5075
|
+
function Er(t, e, n) {
|
|
5076
|
+
const r = _r((t = ot(t, an)).converter, e, n), s = Dn(Vn(t.firestore), "setDoc", t._key, r, null !== t.converter, n);
|
|
5077
|
+
return Je(en(t.firestore), [ s.toMutation(t._key, be.none()) ]);
|
|
5069
5078
|
}
|
|
5070
5079
|
|
|
5071
|
-
function Tr(t,
|
|
5072
|
-
const s =
|
|
5080
|
+
function Tr(t, e, n, ...r) {
|
|
5081
|
+
const s = Vn((t = ot(t, an)).firestore);
|
|
5073
5082
|
// For Compat types, we have to "extract" the underlying types before
|
|
5074
5083
|
// performing validation.
|
|
5075
5084
|
let i;
|
|
5076
|
-
i = "string" == typeof (
|
|
5077
|
-
return
|
|
5085
|
+
i = "string" == typeof (e = getModularInstance(e)) || e instanceof yn ? Cn(s, "updateDoc", t._key, e, n, r) : On(s, "updateDoc", t._key, e);
|
|
5086
|
+
return Je(en(t.firestore), [ i.toMutation(t._key, be.exists(!0)) ]);
|
|
5078
5087
|
}
|
|
5079
5088
|
|
|
5080
5089
|
/**
|
|
@@ -5089,7 +5098,7 @@ function Tr(t, n, e, ...r) {
|
|
|
5089
5098
|
* @returns A `Promise` resolved once the document has been successfully
|
|
5090
5099
|
* deleted from the backend.
|
|
5091
5100
|
*/ function Ir(t) {
|
|
5092
|
-
return
|
|
5101
|
+
return Je(en((t = ot(t, an)).firestore), [ new Ae(t._key, be.none()) ]);
|
|
5093
5102
|
}
|
|
5094
5103
|
|
|
5095
5104
|
/**
|
|
@@ -5106,9 +5115,9 @@ function Tr(t, n, e, ...r) {
|
|
|
5106
5115
|
* @throws Error - If the provided input is not a valid Firestore document.
|
|
5107
5116
|
* @returns A `Promise` resolved with a `DocumentReference` pointing to the
|
|
5108
5117
|
* newly created document after it has been written to the backend.
|
|
5109
|
-
*/ function Ar(t,
|
|
5110
|
-
const
|
|
5111
|
-
return
|
|
5118
|
+
*/ function Ar(t, e) {
|
|
5119
|
+
const n = wn(t = ot(t, ln)), r = _r(t.converter, e), s = Dn(Vn(t.firestore), "addDoc", n._key, r, null !== n.converter, {});
|
|
5120
|
+
return Je(en(t.firestore), [ s.toMutation(n._key, be.exists(!1)) ]).then((() => n));
|
|
5112
5121
|
}
|
|
5113
5122
|
|
|
5114
5123
|
/**
|
|
@@ -5131,14 +5140,14 @@ function Tr(t, n, e, ...r) {
|
|
|
5131
5140
|
* Returns a sentinel for use with {@link @firebase/firestore/lite#(updateDoc:1)} or
|
|
5132
5141
|
* {@link @firebase/firestore/lite#(setDoc:1)} with `{merge: true}` to mark a field for deletion.
|
|
5133
5142
|
*/ function Rr() {
|
|
5134
|
-
return new
|
|
5143
|
+
return new Nn("deleteField");
|
|
5135
5144
|
}
|
|
5136
5145
|
|
|
5137
5146
|
/**
|
|
5138
5147
|
* Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
|
|
5139
5148
|
* include a server-generated timestamp in the written data.
|
|
5140
5149
|
*/ function Pr() {
|
|
5141
|
-
return new
|
|
5150
|
+
return new Sn("serverTimestamp");
|
|
5142
5151
|
}
|
|
5143
5152
|
|
|
5144
5153
|
/**
|
|
@@ -5155,7 +5164,7 @@ function Tr(t, n, e, ...r) {
|
|
|
5155
5164
|
*/ function Vr(...t) {
|
|
5156
5165
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5157
5166
|
// update() since we'd need the Firestore instance to do this.
|
|
5158
|
-
return new
|
|
5167
|
+
return new Fn("arrayUnion", t);
|
|
5159
5168
|
}
|
|
5160
5169
|
|
|
5161
5170
|
/**
|
|
@@ -5171,7 +5180,7 @@ function Tr(t, n, e, ...r) {
|
|
|
5171
5180
|
*/ function Dr(...t) {
|
|
5172
5181
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5173
5182
|
// update() since we'd need the Firestore instance to do this.
|
|
5174
|
-
return new
|
|
5183
|
+
return new xn("arrayRemove", t);
|
|
5175
5184
|
}
|
|
5176
5185
|
|
|
5177
5186
|
/**
|
|
@@ -5193,7 +5202,7 @@ function Tr(t, n, e, ...r) {
|
|
|
5193
5202
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5194
5203
|
* `updateDoc()`
|
|
5195
5204
|
*/ function Nr(t) {
|
|
5196
|
-
return new
|
|
5205
|
+
return new qn("increment", t);
|
|
5197
5206
|
}
|
|
5198
5207
|
|
|
5199
5208
|
/**
|
|
@@ -5221,23 +5230,23 @@ function Tr(t, n, e, ...r) {
|
|
|
5221
5230
|
* called.
|
|
5222
5231
|
*/ class $r {
|
|
5223
5232
|
/** @hideconstructor */
|
|
5224
|
-
constructor(t,
|
|
5225
|
-
this._firestore = t, this._commitHandler =
|
|
5226
|
-
this._dataReader =
|
|
5233
|
+
constructor(t, e) {
|
|
5234
|
+
this._firestore = t, this._commitHandler = e, this._mutations = [], this._committed = !1,
|
|
5235
|
+
this._dataReader = Vn(t);
|
|
5227
5236
|
}
|
|
5228
|
-
set(t,
|
|
5237
|
+
set(t, e, n) {
|
|
5229
5238
|
this._verifyNotCommitted();
|
|
5230
|
-
const r = Sr(t, this._firestore), s = _r(r.converter,
|
|
5231
|
-
return this._mutations.push(i.toMutation(r._key,
|
|
5239
|
+
const r = Sr(t, this._firestore), s = _r(r.converter, e, n), i = Dn(this._dataReader, "WriteBatch.set", r._key, s, null !== r.converter, n);
|
|
5240
|
+
return this._mutations.push(i.toMutation(r._key, be.none())), this;
|
|
5232
5241
|
}
|
|
5233
|
-
update(t,
|
|
5242
|
+
update(t, e, n, ...r) {
|
|
5234
5243
|
this._verifyNotCommitted();
|
|
5235
5244
|
const s = Sr(t, this._firestore);
|
|
5236
5245
|
// For Compat types, we have to "extract" the underlying types before
|
|
5237
5246
|
// performing validation.
|
|
5238
5247
|
let i;
|
|
5239
|
-
return i = "string" == typeof (
|
|
5240
|
-
this._mutations.push(i.toMutation(s._key,
|
|
5248
|
+
return i = "string" == typeof (e = getModularInstance(e)) || e instanceof yn ? Cn(this._dataReader, "WriteBatch.update", s._key, e, n, r) : On(this._dataReader, "WriteBatch.update", s._key, e),
|
|
5249
|
+
this._mutations.push(i.toMutation(s._key, be.exists(!0))), this;
|
|
5241
5250
|
}
|
|
5242
5251
|
/**
|
|
5243
5252
|
* Deletes the document referred to by the provided {@link DocumentReference}.
|
|
@@ -5246,8 +5255,8 @@ function Tr(t, n, e, ...r) {
|
|
|
5246
5255
|
* @returns This `WriteBatch` instance. Used for chaining method calls.
|
|
5247
5256
|
*/ delete(t) {
|
|
5248
5257
|
this._verifyNotCommitted();
|
|
5249
|
-
const
|
|
5250
|
-
return this._mutations = this._mutations.concat(new
|
|
5258
|
+
const e = Sr(t, this._firestore);
|
|
5259
|
+
return this._mutations = this._mutations.concat(new Ae(e._key, be.none())), this;
|
|
5251
5260
|
}
|
|
5252
5261
|
/**
|
|
5253
5262
|
* Commits all of the writes in this write batch as a single atomic unit.
|
|
@@ -5268,8 +5277,8 @@ function Tr(t, n, e, ...r) {
|
|
|
5268
5277
|
}
|
|
5269
5278
|
}
|
|
5270
5279
|
|
|
5271
|
-
function Sr(t,
|
|
5272
|
-
if ((t = getModularInstance(t)).firestore !==
|
|
5280
|
+
function Sr(t, e) {
|
|
5281
|
+
if ((t = getModularInstance(t)).firestore !== e) throw new U(A, "Provided document reference is from a different Firestore instance.");
|
|
5273
5282
|
return t;
|
|
5274
5283
|
}
|
|
5275
5284
|
|
|
@@ -5286,8 +5295,8 @@ function Sr(t, n) {
|
|
|
5286
5295
|
* @returns A `WriteBatch` that can be used to atomically execute multiple
|
|
5287
5296
|
* writes.
|
|
5288
5297
|
*/ function Fr(t) {
|
|
5289
|
-
const
|
|
5290
|
-
return new $r(t, (t =>
|
|
5298
|
+
const e = en(t = ot(t, rn));
|
|
5299
|
+
return new $r(t, (t => Je(e, t)));
|
|
5291
5300
|
}
|
|
5292
5301
|
|
|
5293
5302
|
/**
|
|
@@ -5329,66 +5338,66 @@ function Sr(t, n) {
|
|
|
5329
5338
|
}
|
|
5330
5339
|
async lookup(t) {
|
|
5331
5340
|
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new U(A, "Firestore transactions require all reads to be executed before all writes.");
|
|
5332
|
-
const
|
|
5333
|
-
return
|
|
5341
|
+
const e = await Xe(this.datastore, t);
|
|
5342
|
+
return e.forEach((t => this.recordVersion(t))), e;
|
|
5334
5343
|
}
|
|
5335
|
-
set(t,
|
|
5336
|
-
this.write(
|
|
5344
|
+
set(t, e) {
|
|
5345
|
+
this.write(e.toMutation(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5337
5346
|
}
|
|
5338
|
-
update(t,
|
|
5347
|
+
update(t, e) {
|
|
5339
5348
|
try {
|
|
5340
|
-
this.write(
|
|
5349
|
+
this.write(e.toMutation(t, this.preconditionForUpdate(t)));
|
|
5341
5350
|
} catch (t) {
|
|
5342
5351
|
this.lastWriteError = t;
|
|
5343
5352
|
}
|
|
5344
5353
|
this.writtenDocs.add(t.toString());
|
|
5345
5354
|
}
|
|
5346
5355
|
delete(t) {
|
|
5347
|
-
this.write(new
|
|
5356
|
+
this.write(new Ae(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5348
5357
|
}
|
|
5349
5358
|
async commit() {
|
|
5350
5359
|
if (this.ensureCommitNotCalled(), this.lastWriteError) throw this.lastWriteError;
|
|
5351
5360
|
const t = this.readVersions;
|
|
5352
5361
|
// For each mutation, note that the doc was written.
|
|
5353
|
-
this.mutations.forEach((
|
|
5354
|
-
t.delete(
|
|
5362
|
+
this.mutations.forEach((e => {
|
|
5363
|
+
t.delete(e.key.toString());
|
|
5355
5364
|
})),
|
|
5356
5365
|
// For each document that was read but not written to, we want to perform
|
|
5357
5366
|
// a `verify` operation.
|
|
5358
|
-
t.forEach(((t,
|
|
5359
|
-
const
|
|
5360
|
-
this.mutations.push(new
|
|
5361
|
-
})), await
|
|
5367
|
+
t.forEach(((t, e) => {
|
|
5368
|
+
const n = et.fromPath(e);
|
|
5369
|
+
this.mutations.push(new Re(n, this.precondition(n)));
|
|
5370
|
+
})), await Je(this.datastore, this.mutations), this.committed = !0;
|
|
5362
5371
|
}
|
|
5363
5372
|
recordVersion(t) {
|
|
5364
|
-
let
|
|
5365
|
-
if (t.isFoundDocument())
|
|
5373
|
+
let e;
|
|
5374
|
+
if (t.isFoundDocument()) e = t.version; else {
|
|
5366
5375
|
if (!t.isNoDocument()) throw g();
|
|
5367
5376
|
// For deleted docs, we must use baseVersion 0 when we overwrite them.
|
|
5368
|
-
|
|
5377
|
+
e = vt.min();
|
|
5369
5378
|
}
|
|
5370
|
-
const
|
|
5371
|
-
if (
|
|
5372
|
-
if (!
|
|
5379
|
+
const n = this.readVersions.get(t.key.toString());
|
|
5380
|
+
if (n) {
|
|
5381
|
+
if (!e.isEqual(n))
|
|
5373
5382
|
// This transaction will fail no matter what.
|
|
5374
5383
|
throw new U(F, "Document version changed between two reads.");
|
|
5375
|
-
} else this.readVersions.set(t.key.toString(),
|
|
5384
|
+
} else this.readVersions.set(t.key.toString(), e);
|
|
5376
5385
|
}
|
|
5377
5386
|
/**
|
|
5378
5387
|
* Returns the version of this document when it was read in this transaction,
|
|
5379
5388
|
* as a precondition, or no precondition if it was not read.
|
|
5380
5389
|
*/ precondition(t) {
|
|
5381
|
-
const
|
|
5382
|
-
return !this.writtenDocs.has(t.toString()) &&
|
|
5390
|
+
const e = this.readVersions.get(t.toString());
|
|
5391
|
+
return !this.writtenDocs.has(t.toString()) && e ? be.updateTime(e) : be.none();
|
|
5383
5392
|
}
|
|
5384
5393
|
/**
|
|
5385
5394
|
* Returns the precondition for a document if the operation is an update.
|
|
5386
5395
|
*/ preconditionForUpdate(t) {
|
|
5387
|
-
const
|
|
5396
|
+
const e = this.readVersions.get(t.toString());
|
|
5388
5397
|
// The first time a document is written, we want to take into account the
|
|
5389
5398
|
// read time and existence
|
|
5390
|
-
if (!this.writtenDocs.has(t.toString()) &&
|
|
5391
|
-
if (
|
|
5399
|
+
if (!this.writtenDocs.has(t.toString()) && e) {
|
|
5400
|
+
if (e.isEqual(vt.min()))
|
|
5392
5401
|
// The document doesn't exist, so fail the transaction.
|
|
5393
5402
|
// This has to be validated locally because you can't send a
|
|
5394
5403
|
// precondition that a document does not exist without changing the
|
|
@@ -5400,11 +5409,11 @@ function Sr(t, n) {
|
|
|
5400
5409
|
// transaction.
|
|
5401
5410
|
throw new U(A, "Can't update a document that doesn't exist.");
|
|
5402
5411
|
// Document exists, base precondition on document update time.
|
|
5403
|
-
return
|
|
5412
|
+
return be.updateTime(e);
|
|
5404
5413
|
}
|
|
5405
5414
|
// Document was not read, so we just use the preconditions for a blind
|
|
5406
5415
|
// update.
|
|
5407
|
-
return
|
|
5416
|
+
return be.exists(!0);
|
|
5408
5417
|
}
|
|
5409
5418
|
write(t) {
|
|
5410
5419
|
this.ensureCommitNotCalled(), this.mutations.push(t);
|
|
@@ -5433,19 +5442,19 @@ function Sr(t, n) {
|
|
|
5433
5442
|
* with backoff.
|
|
5434
5443
|
*/
|
|
5435
5444
|
class qr {
|
|
5436
|
-
constructor(t,
|
|
5437
|
-
this.asyncQueue = t, this.datastore =
|
|
5438
|
-
this.Tt = 5, this.It = new
|
|
5445
|
+
constructor(t, e, n, r) {
|
|
5446
|
+
this.asyncQueue = t, this.datastore = e, this.updateFunction = n, this.deferred = r,
|
|
5447
|
+
this.Tt = 5, this.It = new He(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
|
|
5439
5448
|
}
|
|
5440
5449
|
/** Runs the transaction and sets the result on deferred. */ run() {
|
|
5441
5450
|
this.Tt -= 1, this.At();
|
|
5442
5451
|
}
|
|
5443
5452
|
At() {
|
|
5444
5453
|
this.It.W((async () => {
|
|
5445
|
-
const t = new xr(this.datastore),
|
|
5446
|
-
|
|
5454
|
+
const t = new xr(this.datastore), e = this.Rt(t);
|
|
5455
|
+
e && e.then((e => {
|
|
5447
5456
|
this.asyncQueue.enqueueAndForget((() => t.commit().then((() => {
|
|
5448
|
-
this.deferred.resolve(
|
|
5457
|
+
this.deferred.resolve(e);
|
|
5449
5458
|
})).catch((t => {
|
|
5450
5459
|
this.Pt(t);
|
|
5451
5460
|
}))));
|
|
@@ -5456,8 +5465,8 @@ class qr {
|
|
|
5456
5465
|
}
|
|
5457
5466
|
Rt(t) {
|
|
5458
5467
|
try {
|
|
5459
|
-
const
|
|
5460
|
-
return !ct(
|
|
5468
|
+
const e = this.updateFunction(t);
|
|
5469
|
+
return !ct(e) && e.catch && e.then ? e : (this.deferred.reject(Error("Transaction callback must return a Promise")),
|
|
5461
5470
|
null);
|
|
5462
5471
|
} catch (t) {
|
|
5463
5472
|
// Do not retry errors thrown by user provided updateFunction.
|
|
@@ -5472,8 +5481,8 @@ class qr {
|
|
|
5472
5481
|
if ("FirebaseError" === t.name) {
|
|
5473
5482
|
// In transactions, the backend will fail outdated reads with FAILED_PRECONDITION and
|
|
5474
5483
|
// non-matching document versions with ABORTED. These errors should be retried.
|
|
5475
|
-
const
|
|
5476
|
-
return "aborted" ===
|
|
5484
|
+
const e = t.code;
|
|
5485
|
+
return "aborted" === e || "failed-precondition" === e || !
|
|
5477
5486
|
/**
|
|
5478
5487
|
* Determines whether an error code represents a permanent error when received
|
|
5479
5488
|
* in response to a non-write operation.
|
|
@@ -5510,7 +5519,7 @@ class qr {
|
|
|
5510
5519
|
case L:
|
|
5511
5520
|
return !0;
|
|
5512
5521
|
}
|
|
5513
|
-
}(
|
|
5522
|
+
}(e);
|
|
5514
5523
|
}
|
|
5515
5524
|
return !1;
|
|
5516
5525
|
}
|
|
@@ -5565,8 +5574,8 @@ class qr {
|
|
|
5565
5574
|
* in newer versions of TypeScript defines `finally`, which is not available in
|
|
5566
5575
|
* IE.
|
|
5567
5576
|
*/ class Cr {
|
|
5568
|
-
constructor(t,
|
|
5569
|
-
this.asyncQueue = t, this.timerId =
|
|
5577
|
+
constructor(t, e, n, r, s) {
|
|
5578
|
+
this.asyncQueue = t, this.timerId = e, this.targetTimeMs = n, this.op = r, this.removalCallback = s,
|
|
5570
5579
|
this.deferred = new k, this.then = this.deferred.promise.then.bind(this.deferred.promise),
|
|
5571
5580
|
// It's normal for the deferred promise to be canceled (due to cancellation)
|
|
5572
5581
|
// and so we attach a dummy catch callback to avoid
|
|
@@ -5586,9 +5595,9 @@ class qr {
|
|
|
5586
5595
|
* from its delayedOperations list.
|
|
5587
5596
|
* PORTING NOTE: This exists to prevent making removeDelayedOperation() and
|
|
5588
5597
|
* the DelayedOperation class public.
|
|
5589
|
-
*/ static createAndSchedule(t,
|
|
5590
|
-
const i = Date.now() +
|
|
5591
|
-
return o.start(
|
|
5598
|
+
*/ static createAndSchedule(t, e, n, r, s) {
|
|
5599
|
+
const i = Date.now() + n, o = new Cr(t, e, i, r, s);
|
|
5600
|
+
return o.start(n), o;
|
|
5592
5601
|
}
|
|
5593
5602
|
/**
|
|
5594
5603
|
* Starts the timer. This is called immediately after construction by
|
|
@@ -5659,7 +5668,7 @@ class qr {
|
|
|
5659
5668
|
// List of TimerIds to fast-forward delays for.
|
|
5660
5669
|
this.Ot = [],
|
|
5661
5670
|
// Backoff timer used to schedule retries for retryable operations
|
|
5662
|
-
this.It = new
|
|
5671
|
+
this.It = new He(this, "async_queue_retry" /* AsyncQueueRetry */),
|
|
5663
5672
|
// Visibility handler that triggers an immediate retry of all retryable
|
|
5664
5673
|
// operations. Meant to speed up recovery when we regain file system access
|
|
5665
5674
|
// after page comes into foreground.
|
|
@@ -5688,8 +5697,8 @@ class qr {
|
|
|
5688
5697
|
enterRestrictedMode(t) {
|
|
5689
5698
|
if (!this.$t) {
|
|
5690
5699
|
this.$t = !0, this.qt = t || !1;
|
|
5691
|
-
const
|
|
5692
|
-
|
|
5700
|
+
const e = Or();
|
|
5701
|
+
e && "function" == typeof e.removeEventListener && e.removeEventListener("visibilitychange", this.Ct);
|
|
5693
5702
|
}
|
|
5694
5703
|
}
|
|
5695
5704
|
enqueue(t) {
|
|
@@ -5699,9 +5708,9 @@ class qr {
|
|
|
5699
5708
|
// Create a deferred Promise that we can return to the callee. This
|
|
5700
5709
|
// allows us to return a "hanging Promise" only to the callee and still
|
|
5701
5710
|
// advance the queue even when the operation is not run.
|
|
5702
|
-
const
|
|
5703
|
-
return this.Ut((() => this.$t && this.qt ? Promise.resolve() : (t().then(
|
|
5704
|
-
|
|
5711
|
+
const e = new k;
|
|
5712
|
+
return this.Ut((() => this.$t && this.qt ? Promise.resolve() : (t().then(e.resolve, e.reject),
|
|
5713
|
+
e.promise))).then((() => e.promise));
|
|
5705
5714
|
}
|
|
5706
5715
|
enqueueRetryable(t) {
|
|
5707
5716
|
this.enqueueAndForget((() => (this.Nt.push(t), this.kt())));
|
|
@@ -5771,18 +5780,18 @@ class qr {
|
|
|
5771
5780
|
}
|
|
5772
5781
|
}
|
|
5773
5782
|
Ut(t) {
|
|
5774
|
-
const
|
|
5783
|
+
const e = this.Dt.then((() => (this.xt = !0, t().catch((t => {
|
|
5775
5784
|
this.Ft = t, this.xt = !1;
|
|
5776
|
-
const
|
|
5785
|
+
const e =
|
|
5777
5786
|
/**
|
|
5778
5787
|
* Chrome includes Error.message in Error.stack. Other browsers do not.
|
|
5779
5788
|
* This returns expected output of message + stack when available.
|
|
5780
5789
|
* @param error - Error or FirestoreError
|
|
5781
5790
|
*/
|
|
5782
5791
|
function(t) {
|
|
5783
|
-
let
|
|
5784
|
-
t.stack && (
|
|
5785
|
-
return
|
|
5792
|
+
let e = t.message || "";
|
|
5793
|
+
t.stack && (e = t.stack.includes(t.message) ? t.stack : t.message + "\n" + t.stack);
|
|
5794
|
+
return e;
|
|
5786
5795
|
}
|
|
5787
5796
|
/**
|
|
5788
5797
|
* @license
|
|
@@ -5812,15 +5821,15 @@ class qr {
|
|
|
5812
5821
|
// Re-throw the error so that this.tail becomes a rejected Promise and
|
|
5813
5822
|
// all further attempts to chain (via .then) will just short-circuit
|
|
5814
5823
|
// and return the rejected Promise.
|
|
5815
|
-
throw p("INTERNAL UNHANDLED ERROR: ",
|
|
5824
|
+
throw p("INTERNAL UNHANDLED ERROR: ", e), t;
|
|
5816
5825
|
})).then((t => (this.xt = !1, t))))));
|
|
5817
|
-
return this.Dt =
|
|
5826
|
+
return this.Dt = e, e;
|
|
5818
5827
|
}
|
|
5819
|
-
enqueueAfterDelay(t,
|
|
5828
|
+
enqueueAfterDelay(t, e, n) {
|
|
5820
5829
|
this.Lt(),
|
|
5821
5830
|
// Fast-forward delays for timerIds that have been overriden.
|
|
5822
|
-
this.Ot.indexOf(t) > -1 && (
|
|
5823
|
-
const r = Cr.createAndSchedule(this, t,
|
|
5831
|
+
this.Ot.indexOf(t) > -1 && (e = 0);
|
|
5832
|
+
const r = Cr.createAndSchedule(this, t, e, n, (t => this.jt(t)));
|
|
5824
5833
|
return this.St.push(r), r;
|
|
5825
5834
|
}
|
|
5826
5835
|
Lt() {
|
|
@@ -5844,7 +5853,7 @@ class qr {
|
|
|
5844
5853
|
* For Tests: Determine if a delayed operation with a particular TimerId
|
|
5845
5854
|
* exists.
|
|
5846
5855
|
*/ Bt(t) {
|
|
5847
|
-
for (const
|
|
5856
|
+
for (const e of this.St) if (e.timerId === t) return !0;
|
|
5848
5857
|
return !1;
|
|
5849
5858
|
}
|
|
5850
5859
|
/**
|
|
@@ -5857,8 +5866,8 @@ class qr {
|
|
|
5857
5866
|
// Note that draining may generate more delayed ops, so we do that first.
|
|
5858
5867
|
return this.Mt().then((() => {
|
|
5859
5868
|
// Run ops in the same order they'd run if they ran naturally.
|
|
5860
|
-
this.St.sort(((t,
|
|
5861
|
-
for (const
|
|
5869
|
+
this.St.sort(((t, e) => t.targetTimeMs - e.targetTimeMs));
|
|
5870
|
+
for (const e of this.St) if (e.skipDelay(), "all" /* All */ !== t && e.timerId === t) break;
|
|
5862
5871
|
return this.Mt();
|
|
5863
5872
|
}));
|
|
5864
5873
|
}
|
|
@@ -5869,15 +5878,15 @@ class qr {
|
|
|
5869
5878
|
}
|
|
5870
5879
|
/** Called once a DelayedOperation is run or canceled. */ jt(t) {
|
|
5871
5880
|
// NOTE: indexOf / slice are O(n), but delayedOperations is expected to be small.
|
|
5872
|
-
const
|
|
5873
|
-
this.St.splice(
|
|
5881
|
+
const e = this.St.indexOf(t);
|
|
5882
|
+
this.St.splice(e, 1);
|
|
5874
5883
|
}
|
|
5875
5884
|
}
|
|
5876
5885
|
|
|
5877
5886
|
class Ur {
|
|
5878
5887
|
/** @hideconstructor */
|
|
5879
|
-
constructor(t,
|
|
5880
|
-
this._firestore = t, this._transaction =
|
|
5888
|
+
constructor(t, e) {
|
|
5889
|
+
this._firestore = t, this._transaction = e, this._dataReader = Vn(t);
|
|
5881
5890
|
}
|
|
5882
5891
|
/**
|
|
5883
5892
|
* Reads the document referenced by the provided {@link DocumentReference}.
|
|
@@ -5885,25 +5894,25 @@ class Ur {
|
|
|
5885
5894
|
* @param documentRef - A reference to the document to be read.
|
|
5886
5895
|
* @returns A `DocumentSnapshot` with the read data.
|
|
5887
5896
|
*/ get(t) {
|
|
5888
|
-
const
|
|
5889
|
-
return this._transaction.lookup([
|
|
5897
|
+
const e = Sr(t, this._firestore), n = new gr(this._firestore);
|
|
5898
|
+
return this._transaction.lookup([ e._key ]).then((t => {
|
|
5890
5899
|
if (!t || 1 !== t.length) return g();
|
|
5891
5900
|
const r = t[0];
|
|
5892
|
-
if (r.isFoundDocument()) return new
|
|
5893
|
-
if (r.isNoDocument()) return new
|
|
5901
|
+
if (r.isFoundDocument()) return new Yn(this._firestore, n, r.key, r, e.converter);
|
|
5902
|
+
if (r.isNoDocument()) return new Yn(this._firestore, n, e._key, null, e.converter);
|
|
5894
5903
|
throw g();
|
|
5895
5904
|
}));
|
|
5896
5905
|
}
|
|
5897
|
-
set(t,
|
|
5898
|
-
const r = Sr(t, this._firestore), s = _r(r.converter,
|
|
5906
|
+
set(t, e, n) {
|
|
5907
|
+
const r = Sr(t, this._firestore), s = _r(r.converter, e, n), i = Dn(this._dataReader, "Transaction.set", r._key, s, null !== r.converter, n);
|
|
5899
5908
|
return this._transaction.set(r._key, i), this;
|
|
5900
5909
|
}
|
|
5901
|
-
update(t,
|
|
5910
|
+
update(t, e, n, ...r) {
|
|
5902
5911
|
const s = Sr(t, this._firestore);
|
|
5903
5912
|
// For Compat types, we have to "extract" the underlying types before
|
|
5904
5913
|
// performing validation.
|
|
5905
5914
|
let i;
|
|
5906
|
-
return i = "string" == typeof (
|
|
5915
|
+
return i = "string" == typeof (e = getModularInstance(e)) || e instanceof yn ? Cn(this._dataReader, "Transaction.update", s._key, e, n, r) : On(this._dataReader, "Transaction.update", s._key, e),
|
|
5907
5916
|
this._transaction.update(s._key, i), this;
|
|
5908
5917
|
}
|
|
5909
5918
|
/**
|
|
@@ -5912,8 +5921,8 @@ class Ur {
|
|
|
5912
5921
|
* @param documentRef - A reference to the document to be deleted.
|
|
5913
5922
|
* @returns This `Transaction` instance. Used for chaining method calls.
|
|
5914
5923
|
*/ delete(t) {
|
|
5915
|
-
const
|
|
5916
|
-
return this._transaction.delete(
|
|
5924
|
+
const e = Sr(t, this._firestore);
|
|
5925
|
+
return this._transaction.delete(e._key), this;
|
|
5917
5926
|
}
|
|
5918
5927
|
}
|
|
5919
5928
|
|
|
@@ -5933,9 +5942,9 @@ class Ur {
|
|
|
5933
5942
|
* (the `updateFunction` returned a failed promise), the promise returned by the
|
|
5934
5943
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
5935
5944
|
* rejected promise with the corresponding failure error is returned.
|
|
5936
|
-
*/ function kr(t,
|
|
5937
|
-
const
|
|
5938
|
-
return new qr(new Lr,
|
|
5945
|
+
*/ function kr(t, e) {
|
|
5946
|
+
const n = en(t = ot(t, rn)), r = new k;
|
|
5947
|
+
return new qr(new Lr, n, (n => e(new Ur(t, n))), r).run(), r.promise;
|
|
5939
5948
|
}
|
|
5940
5949
|
|
|
5941
5950
|
/**
|
|
@@ -5947,12 +5956,12 @@ class Ur {
|
|
|
5947
5956
|
* @packageDocumentation
|
|
5948
5957
|
*/ !function(t) {
|
|
5949
5958
|
f = t;
|
|
5950
|
-
}(`${SDK_VERSION}_lite`), _registerComponent(new Component("firestore/lite", ((t, {options:
|
|
5951
|
-
const
|
|
5952
|
-
return
|
|
5959
|
+
}(`${SDK_VERSION}_lite`), _registerComponent(new Component("firestore/lite", ((t, {options: e}) => {
|
|
5960
|
+
const n = t.getProvider("app").getImmediate(), r = new rn(n, new z(t.getProvider("auth-internal")), new Y(t.getProvider("app-check-internal")));
|
|
5961
|
+
return e && r._setSettings(e), r;
|
|
5953
5962
|
}), "PUBLIC")),
|
|
5954
5963
|
// RUNTIME_ENV and BUILD_TARGET are replaced by real values during the compilation
|
|
5955
|
-
registerVersion("firestore-lite", "3.4.
|
|
5964
|
+
registerVersion("firestore-lite", "3.4.5", ""), registerVersion("firestore-lite", "3.4.5", "esm2017");
|
|
5956
5965
|
|
|
5957
|
-
export {
|
|
5966
|
+
export { gn as Bytes, ln as CollectionReference, an as DocumentReference, Yn as DocumentSnapshot, yn as FieldPath, vn as FieldValue, rn as Firestore, U as FirestoreError, bn as GeoPoint, hn as Query, Zn as QueryConstraint, Hn as QueryDocumentSnapshot, Kn as QuerySnapshot, gt as Timestamp, Ur as Transaction, $r as WriteBatch, Ar as addDoc, Dr as arrayRemove, Vr as arrayUnion, fn as collection, dn as collectionGroup, un as connectFirestoreEmulator, Ir as deleteDoc, Rr as deleteField, wn as doc, _n as documentId, dr as endAt, fr as endBefore, vr as getDoc, br as getDocs, on as getFirestore, Nr as increment, sn as initializeFirestore, or as limit, ur as limitToLast, sr as orderBy, tr as query, pn as queryEqual, mn as refEqual, kr as runTransaction, Pr as serverTimestamp, Er as setDoc, w as setLogLevel, Jn as snapshotEqual, hr as startAfter, ar as startAt, cn as terminate, Tr as updateDoc, nr as where, Fr as writeBatch };
|
|
5958
5967
|
//# sourceMappingURL=index.browser.esm2017.js.map
|