@firebase/firestore 3.4.4 → 3.4.5-canary.8ac8fb099
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/api/{query.d.ts → filter.d.ts} +0 -0
- package/dist/firestore/src/api/snapshot.d.ts +1 -2
- package/dist/firestore/src/api.d.ts +1 -1
- package/dist/firestore/src/core/database_info.d.ts +1 -0
- package/dist/firestore/src/core/target.d.ts +34 -5
- package/dist/firestore/src/index/index_byte_encoder.d.ts +18 -1
- package/dist/firestore/src/index/index_entry.d.ts +32 -0
- package/dist/firestore/src/lite-api/query.d.ts +2 -2
- package/dist/firestore/src/local/document_overlay_cache.d.ts +72 -0
- package/dist/firestore/src/local/index_manager.d.ts +52 -0
- package/dist/firestore/src/local/indexeddb_document_overlay_cache.d.ts +45 -0
- package/dist/firestore/src/local/indexeddb_index_manager.d.ts +87 -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 +195 -7
- package/dist/firestore/src/local/local_documents_view.d.ts +0 -1
- package/dist/firestore/src/local/local_serializer.d.ts +19 -3
- package/dist/firestore/src/local/memory_document_overlay_cache.d.ts +37 -0
- package/dist/firestore/src/local/memory_index_manager.d.ts +11 -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/local/remote_document_change_buffer.d.ts +3 -12
- package/dist/firestore/src/local/simple_db.d.ts +12 -0
- package/dist/firestore/src/model/document.d.ts +7 -0
- package/dist/firestore/src/model/document_key.d.ts +6 -0
- package/dist/firestore/src/model/field_index.d.ts +89 -7
- 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/model/type_order.d.ts +2 -1
- package/dist/firestore/src/model/values.d.ts +7 -0
- package/dist/firestore/src/platform/node/base64.d.ts +1 -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 +5 -3
- package/dist/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
- package/dist/firestore/test/unit/model/field_index.test.d.ts +17 -0
- package/dist/firestore/test/unit/model/target.test.d.ts +17 -0
- package/dist/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
- package/dist/firestore/test/util/helpers.d.ts +8 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.esm2017.js +5415 -3839
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +5039 -3613
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +2908 -592
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +2888 -593
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +5396 -3862
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +265 -26
- package/dist/lite/firestore/src/api/credentials.d.ts +1 -0
- package/dist/lite/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
- package/dist/lite/firestore/src/api/snapshot.d.ts +1 -2
- package/dist/lite/firestore/src/api.d.ts +1 -1
- package/dist/lite/firestore/src/core/database_info.d.ts +1 -0
- package/dist/lite/firestore/src/core/target.d.ts +34 -5
- package/dist/lite/firestore/src/index/index_byte_encoder.d.ts +18 -1
- package/dist/lite/firestore/src/index/index_entry.d.ts +32 -0
- package/dist/lite/firestore/src/lite-api/query.d.ts +2 -2
- package/dist/lite/firestore/src/local/document_overlay_cache.d.ts +72 -0
- package/dist/lite/firestore/src/local/index_manager.d.ts +52 -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 +87 -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 +195 -7
- package/dist/lite/firestore/src/local/local_documents_view.d.ts +0 -1
- package/dist/lite/firestore/src/local/local_serializer.d.ts +19 -3
- package/dist/lite/firestore/src/local/memory_document_overlay_cache.d.ts +37 -0
- package/dist/lite/firestore/src/local/memory_index_manager.d.ts +11 -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/local/remote_document_change_buffer.d.ts +3 -12
- package/dist/lite/firestore/src/local/simple_db.d.ts +12 -0
- package/dist/lite/firestore/src/model/document.d.ts +7 -0
- package/dist/lite/firestore/src/model/document_key.d.ts +6 -0
- package/dist/lite/firestore/src/model/field_index.d.ts +89 -7
- 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/model/type_order.d.ts +2 -1
- package/dist/lite/firestore/src/model/values.d.ts +7 -0
- package/dist/lite/firestore/src/platform/node/base64.d.ts +1 -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 +5 -3
- package/dist/lite/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
- package/dist/lite/firestore/test/unit/model/field_index.test.d.ts +17 -0
- package/dist/lite/firestore/test/unit/model/target.test.d.ts +17 -0
- package/dist/lite/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
- package/dist/lite/firestore/test/util/helpers.d.ts +8 -2
- package/dist/lite/index.browser.esm2017.js +1207 -1174
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +370 -361
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.node.cjs.js +83 -41
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +83 -41
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +375 -342
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +16 -2
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +125 -124
- package/dist/lite/packages/firestore/src/api/credentials.d.ts +1 -0
- package/dist/lite/packages/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
- package/dist/lite/packages/firestore/src/api/snapshot.d.ts +1 -2
- package/dist/lite/packages/firestore/src/api.d.ts +1 -1
- package/dist/lite/packages/firestore/src/core/database_info.d.ts +1 -0
- package/dist/lite/packages/firestore/src/core/target.d.ts +34 -5
- 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 +32 -0
- package/dist/lite/packages/firestore/src/lite-api/query.d.ts +2 -2
- package/dist/lite/packages/firestore/src/local/document_overlay_cache.d.ts +72 -0
- package/dist/lite/packages/firestore/src/local/index_manager.d.ts +52 -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 +87 -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 +195 -7
- 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 +19 -3
- package/dist/lite/packages/firestore/src/local/memory_document_overlay_cache.d.ts +37 -0
- package/dist/lite/packages/firestore/src/local/memory_index_manager.d.ts +11 -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/local/remote_document_change_buffer.d.ts +3 -12
- package/dist/lite/packages/firestore/src/local/simple_db.d.ts +12 -0
- package/dist/lite/packages/firestore/src/model/document.d.ts +7 -0
- package/dist/lite/packages/firestore/src/model/document_key.d.ts +6 -0
- package/dist/lite/packages/firestore/src/model/field_index.d.ts +89 -7
- 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/model/type_order.d.ts +2 -1
- package/dist/lite/packages/firestore/src/model/values.d.ts +7 -0
- package/dist/lite/packages/firestore/src/platform/node/base64.d.ts +1 -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 +5 -3
- 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/field_index.test.d.ts +17 -0
- package/dist/lite/packages/firestore/test/unit/model/target.test.d.ts +17 -0
- package/dist/lite/packages/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
- package/dist/lite/packages/firestore/test/util/helpers.d.ts +8 -2
- package/dist/lite/private.d.ts +9 -2
- package/dist/packages/firestore/dist/index.esm2017.d.ts +199 -194
- package/dist/packages/firestore/src/api/credentials.d.ts +1 -0
- package/dist/packages/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
- package/dist/packages/firestore/src/api/snapshot.d.ts +1 -2
- package/dist/packages/firestore/src/api.d.ts +1 -1
- package/dist/packages/firestore/src/core/database_info.d.ts +1 -0
- package/dist/packages/firestore/src/core/target.d.ts +34 -5
- package/dist/packages/firestore/src/index/index_byte_encoder.d.ts +18 -1
- package/dist/packages/firestore/src/index/index_entry.d.ts +32 -0
- package/dist/packages/firestore/src/lite-api/query.d.ts +2 -2
- package/dist/packages/firestore/src/local/document_overlay_cache.d.ts +72 -0
- package/dist/packages/firestore/src/local/index_manager.d.ts +52 -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 +87 -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 +195 -7
- package/dist/packages/firestore/src/local/local_documents_view.d.ts +0 -1
- package/dist/packages/firestore/src/local/local_serializer.d.ts +19 -3
- package/dist/packages/firestore/src/local/memory_document_overlay_cache.d.ts +37 -0
- package/dist/packages/firestore/src/local/memory_index_manager.d.ts +11 -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/local/remote_document_change_buffer.d.ts +3 -12
- package/dist/packages/firestore/src/local/simple_db.d.ts +12 -0
- package/dist/packages/firestore/src/model/document.d.ts +7 -0
- package/dist/packages/firestore/src/model/document_key.d.ts +6 -0
- package/dist/packages/firestore/src/model/field_index.d.ts +89 -7
- 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/model/type_order.d.ts +2 -1
- package/dist/packages/firestore/src/model/values.d.ts +7 -0
- package/dist/packages/firestore/src/platform/node/base64.d.ts +1 -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 +5 -3
- package/dist/packages/firestore/test/unit/local/test_remote_document_change_buffer.d.ts +1 -1
- package/dist/packages/firestore/test/unit/model/field_index.test.d.ts +17 -0
- package/dist/packages/firestore/test/unit/model/target.test.d.ts +17 -0
- package/dist/packages/firestore/test/unit/model/target_index_matcher.test.d.ts +17 -0
- package/dist/packages/firestore/test/util/helpers.d.ts +8 -2
- package/dist/private.d.ts +258 -26
- 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-canary.8ac8fb099";
|
|
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 b(t, e) {
|
|
194
194
|
t || g();
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
/**
|
|
198
198
|
* Casts `obj` to `T`. In non-production builds, verifies that `obj` is an
|
|
199
199
|
* instance of `T` before casting.
|
|
200
|
-
*/ function
|
|
200
|
+
*/ function v(t,
|
|
201
201
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
202
|
-
|
|
202
|
+
e) {
|
|
203
203
|
return t;
|
|
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 ? (b("string" == typeof t.accessToken),
|
|
336
336
|
new j(t.accessToken, new l(this.auth.getUid()))) : null)) : Promise.resolve(null);
|
|
337
337
|
}
|
|
338
338
|
invalidateToken() {}
|
|
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 ? (b("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,11 @@ 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
|
+
}
|
|
450
|
+
static empty() {
|
|
451
|
+
return new K("", "");
|
|
449
452
|
}
|
|
450
453
|
get isDefaultDatabase() {
|
|
451
454
|
return "(default)" === this.database;
|
|
@@ -475,9 +478,9 @@ class K {
|
|
|
475
478
|
* Path represents an ordered sequence of string segments.
|
|
476
479
|
*/
|
|
477
480
|
class J {
|
|
478
|
-
constructor(t,
|
|
479
|
-
void 0 ===
|
|
480
|
-
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;
|
|
481
484
|
}
|
|
482
485
|
get length() {
|
|
483
486
|
return this.len;
|
|
@@ -486,10 +489,10 @@ class J {
|
|
|
486
489
|
return 0 === J.comparator(this, t);
|
|
487
490
|
}
|
|
488
491
|
child(t) {
|
|
489
|
-
const
|
|
492
|
+
const e = this.segments.slice(this.offset, this.limit());
|
|
490
493
|
return t instanceof J ? t.forEach((t => {
|
|
491
|
-
|
|
492
|
-
})) :
|
|
494
|
+
e.push(t);
|
|
495
|
+
})) : e.push(t), this.construct(e);
|
|
493
496
|
}
|
|
494
497
|
/** The index of one past the last segment of the path. */ limit() {
|
|
495
498
|
return this.offset + this.length;
|
|
@@ -514,28 +517,28 @@ class J {
|
|
|
514
517
|
}
|
|
515
518
|
isPrefixOf(t) {
|
|
516
519
|
if (t.length < this.length) return !1;
|
|
517
|
-
for (let
|
|
520
|
+
for (let e = 0; e < this.length; e++) if (this.get(e) !== t.get(e)) return !1;
|
|
518
521
|
return !0;
|
|
519
522
|
}
|
|
520
523
|
isImmediateParentOf(t) {
|
|
521
524
|
if (this.length + 1 !== t.length) return !1;
|
|
522
|
-
for (let
|
|
525
|
+
for (let e = 0; e < this.length; e++) if (this.get(e) !== t.get(e)) return !1;
|
|
523
526
|
return !0;
|
|
524
527
|
}
|
|
525
528
|
forEach(t) {
|
|
526
|
-
for (let
|
|
529
|
+
for (let e = this.offset, n = this.limit(); e < n; e++) t(this.segments[e]);
|
|
527
530
|
}
|
|
528
531
|
toArray() {
|
|
529
532
|
return this.segments.slice(this.offset, this.limit());
|
|
530
533
|
}
|
|
531
|
-
static comparator(t,
|
|
532
|
-
const
|
|
533
|
-
for (let r = 0; r <
|
|
534
|
-
const
|
|
535
|
-
if (
|
|
536
|
-
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;
|
|
537
540
|
}
|
|
538
|
-
return t.length <
|
|
541
|
+
return t.length < e.length ? -1 : t.length > e.length ? 1 : 0;
|
|
539
542
|
}
|
|
540
543
|
}
|
|
541
544
|
|
|
@@ -545,8 +548,8 @@ class J {
|
|
|
545
548
|
*
|
|
546
549
|
* @internal
|
|
547
550
|
*/ class X extends J {
|
|
548
|
-
construct(t,
|
|
549
|
-
return new X(t,
|
|
551
|
+
construct(t, e, n) {
|
|
552
|
+
return new X(t, e, n);
|
|
550
553
|
}
|
|
551
554
|
canonicalString() {
|
|
552
555
|
// NOTE: The client is ignorant of any path segments containing escape
|
|
@@ -565,13 +568,13 @@ class J {
|
|
|
565
568
|
// NOTE: The client is ignorant of any path segments containing escape
|
|
566
569
|
// sequences (e.g. __id123__) and just passes them through raw (they exist
|
|
567
570
|
// for legacy reasons and should not be used frequently).
|
|
568
|
-
const
|
|
569
|
-
for (const
|
|
570
|
-
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.`);
|
|
571
574
|
// Strip leading and traling slashed.
|
|
572
|
-
|
|
575
|
+
e.push(...n.split("/").filter((t => t.length > 0)));
|
|
573
576
|
}
|
|
574
|
-
return new X(
|
|
577
|
+
return new X(e);
|
|
575
578
|
}
|
|
576
579
|
static emptyPath() {
|
|
577
580
|
return new X([]);
|
|
@@ -584,8 +587,8 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
584
587
|
* A dot-separated path for navigating sub-objects within a document.
|
|
585
588
|
* @internal
|
|
586
589
|
*/ class tt extends J {
|
|
587
|
-
construct(t,
|
|
588
|
-
return new tt(t,
|
|
590
|
+
construct(t, e, n) {
|
|
591
|
+
return new tt(t, e, n);
|
|
589
592
|
}
|
|
590
593
|
/**
|
|
591
594
|
* Returns true if the string could be used as a segment in a field path
|
|
@@ -620,24 +623,24 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
620
623
|
* TODO(b/37244157): we should make this more strict. Right now, it allows
|
|
621
624
|
* non-identifier path components, even if they aren't escaped.
|
|
622
625
|
*/ static fromServerFormat(t) {
|
|
623
|
-
const
|
|
624
|
-
let
|
|
626
|
+
const e = [];
|
|
627
|
+
let n = "", r = 0;
|
|
625
628
|
const s = () => {
|
|
626
|
-
if (0 ===
|
|
627
|
-
|
|
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 = "";
|
|
628
631
|
};
|
|
629
632
|
let i = !1;
|
|
630
633
|
for (;r < t.length; ) {
|
|
631
|
-
const
|
|
632
|
-
if ("\\" ===
|
|
634
|
+
const e = t[r];
|
|
635
|
+
if ("\\" === e) {
|
|
633
636
|
if (r + 1 === t.length) throw new U(A, "Path has trailing escape character: " + t);
|
|
634
|
-
const
|
|
635
|
-
if ("\\" !==
|
|
636
|
-
|
|
637
|
-
} 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++);
|
|
638
641
|
}
|
|
639
642
|
if (s(), i) throw new U(A, "Unterminated ` in path: " + t);
|
|
640
|
-
return new tt(
|
|
643
|
+
return new tt(e);
|
|
641
644
|
}
|
|
642
645
|
static emptyPath() {
|
|
643
646
|
return new tt([]);
|
|
@@ -662,27 +665,39 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
662
665
|
*/
|
|
663
666
|
/**
|
|
664
667
|
* @internal
|
|
665
|
-
*/ class
|
|
668
|
+
*/ class et {
|
|
666
669
|
constructor(t) {
|
|
667
670
|
this.path = t;
|
|
668
671
|
}
|
|
669
672
|
static fromPath(t) {
|
|
670
|
-
return new
|
|
673
|
+
return new et(X.fromString(t));
|
|
671
674
|
}
|
|
672
675
|
static fromName(t) {
|
|
673
|
-
return new
|
|
676
|
+
return new et(X.fromString(t).popFirst(5));
|
|
677
|
+
}
|
|
678
|
+
static empty() {
|
|
679
|
+
return new et(X.emptyPath());
|
|
680
|
+
}
|
|
681
|
+
get collectionGroup() {
|
|
682
|
+
return this.path.popLast().lastSegment();
|
|
674
683
|
}
|
|
675
684
|
/** Returns true if the document is in the specified collectionId. */ hasCollectionId(t) {
|
|
676
685
|
return this.path.length >= 2 && this.path.get(this.path.length - 2) === t;
|
|
677
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
|
+
}
|
|
678
693
|
isEqual(t) {
|
|
679
694
|
return null !== t && 0 === X.comparator(this.path, t.path);
|
|
680
695
|
}
|
|
681
696
|
toString() {
|
|
682
697
|
return this.path.toString();
|
|
683
698
|
}
|
|
684
|
-
static comparator(t,
|
|
685
|
-
return X.comparator(t.path,
|
|
699
|
+
static comparator(t, e) {
|
|
700
|
+
return X.comparator(t.path, e.path);
|
|
686
701
|
}
|
|
687
702
|
static isDocumentKey(t) {
|
|
688
703
|
return t.length % 2 == 0;
|
|
@@ -693,7 +708,7 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
693
708
|
* @param segments - The segments of the path to the document
|
|
694
709
|
* @returns A new instance of DocumentKey
|
|
695
710
|
*/ static fromSegments(t) {
|
|
696
|
-
return new
|
|
711
|
+
return new et(new X(t.slice()));
|
|
697
712
|
}
|
|
698
713
|
}
|
|
699
714
|
|
|
@@ -712,8 +727,8 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
712
727
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
713
728
|
* See the License for the specific language governing permissions and
|
|
714
729
|
* limitations under the License.
|
|
715
|
-
*/ function
|
|
716
|
-
if (!
|
|
730
|
+
*/ function nt(t, e, n) {
|
|
731
|
+
if (!n) throw new U(A, `Function ${t}() cannot be called with an empty ${e}.`);
|
|
717
732
|
}
|
|
718
733
|
|
|
719
734
|
/**
|
|
@@ -725,14 +740,14 @@ const Z = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
|
|
|
725
740
|
* an even numbers of segments).
|
|
726
741
|
*/
|
|
727
742
|
function rt(t) {
|
|
728
|
-
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}.`);
|
|
729
744
|
}
|
|
730
745
|
|
|
731
746
|
/**
|
|
732
747
|
* Validates that `path` refers to a collection (indicated by the fact it
|
|
733
748
|
* contains an odd numbers of segments).
|
|
734
749
|
*/ function st(t) {
|
|
735
|
-
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}.`);
|
|
736
751
|
}
|
|
737
752
|
|
|
738
753
|
/**
|
|
@@ -749,7 +764,7 @@ function it(t) {
|
|
|
749
764
|
if ("object" == typeof t) {
|
|
750
765
|
if (t instanceof Array) return "an array";
|
|
751
766
|
{
|
|
752
|
-
const
|
|
767
|
+
const e =
|
|
753
768
|
/** try to get the constructor name for an object. */
|
|
754
769
|
function(t) {
|
|
755
770
|
if (t.constructor) return t.constructor.name;
|
|
@@ -763,7 +778,7 @@ function it(t) {
|
|
|
763
778
|
* arguments passed to the public API.
|
|
764
779
|
* @internal
|
|
765
780
|
*/ (t);
|
|
766
|
-
return
|
|
781
|
+
return e ? `a custom ${e} object` : "an object";
|
|
767
782
|
}
|
|
768
783
|
}
|
|
769
784
|
return "function" == typeof t ? "a function" : g();
|
|
@@ -771,22 +786,22 @@ function it(t) {
|
|
|
771
786
|
|
|
772
787
|
function ot(t,
|
|
773
788
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
774
|
-
|
|
789
|
+
e) {
|
|
775
790
|
if ("_delegate" in t && (
|
|
776
791
|
// Unwrap Compat types
|
|
777
792
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
778
|
-
t = t._delegate), !(t instanceof
|
|
779
|
-
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?");
|
|
780
795
|
{
|
|
781
|
-
const
|
|
782
|
-
throw new U(A, `Expected type '${
|
|
796
|
+
const n = it(t);
|
|
797
|
+
throw new U(A, `Expected type '${e.name}', but it was: ${n}`);
|
|
783
798
|
}
|
|
784
799
|
}
|
|
785
800
|
return t;
|
|
786
801
|
}
|
|
787
802
|
|
|
788
|
-
function ut(t,
|
|
789
|
-
if (
|
|
803
|
+
function ut(t, e) {
|
|
804
|
+
if (e <= 0) throw new U(A, `Function ${t}() requires a positive number, but it was: ${e}.`);
|
|
790
805
|
}
|
|
791
806
|
|
|
792
807
|
/**
|
|
@@ -993,58 +1008,58 @@ class wt extends
|
|
|
993
1008
|
class {
|
|
994
1009
|
constructor(t) {
|
|
995
1010
|
this.databaseInfo = t, this.databaseId = t.databaseId;
|
|
996
|
-
const
|
|
997
|
-
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";
|
|
998
1013
|
}
|
|
999
|
-
m(t,
|
|
1000
|
-
const i = this.p(t,
|
|
1001
|
-
m("RestConnection", "Sending: ", i,
|
|
1014
|
+
m(t, e, n, r, s) {
|
|
1015
|
+
const i = this.p(t, e);
|
|
1016
|
+
m("RestConnection", "Sending: ", i, n);
|
|
1002
1017
|
const o = {};
|
|
1003
|
-
return this.g(o, r, s), this.v(t, i, o,
|
|
1004
|
-
t)), (
|
|
1005
|
-
throw y("RestConnection", `${t} failed with error: `,
|
|
1006
|
-
|
|
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;
|
|
1007
1022
|
}));
|
|
1008
1023
|
}
|
|
1009
|
-
T(t,
|
|
1024
|
+
T(t, e, n, r, s) {
|
|
1010
1025
|
// The REST API automatically aggregates all of the streamed results, so we
|
|
1011
1026
|
// can just use the normal invoke() method.
|
|
1012
|
-
return this.m(t,
|
|
1027
|
+
return this.m(t, e, n, r, s);
|
|
1013
1028
|
}
|
|
1014
1029
|
/**
|
|
1015
1030
|
* Modifies the headers for a request, adding any authorization token if
|
|
1016
1031
|
* present and any additional headers for the request.
|
|
1017
|
-
*/ g(t,
|
|
1032
|
+
*/ g(t, e, n) {
|
|
1018
1033
|
t["X-Goog-Api-Client"] = "gl-js/ fire/" + f,
|
|
1019
1034
|
// Content-Type: text/plain will avoid preflight requests which might
|
|
1020
1035
|
// mess with CORS and redirects by proxies. If we add custom headers
|
|
1021
1036
|
// we will need to change this code to potentially use the $httpOverwrite
|
|
1022
1037
|
// parameter supported by ESF to avoid triggering preflight requests.
|
|
1023
1038
|
t["Content-Type"] = "text/plain", this.databaseInfo.appId && (t["X-Firebase-GMPID"] = this.databaseInfo.appId),
|
|
1024
|
-
|
|
1039
|
+
e && e.headers.forEach(((e, n) => t[n] = e)), n && n.headers.forEach(((e, n) => t[n] = e));
|
|
1025
1040
|
}
|
|
1026
|
-
p(t,
|
|
1027
|
-
const
|
|
1028
|
-
return `${this.h}/v1/${
|
|
1041
|
+
p(t, e) {
|
|
1042
|
+
const n = ht[t];
|
|
1043
|
+
return `${this.h}/v1/${e}:${n}`;
|
|
1029
1044
|
}
|
|
1030
1045
|
} {
|
|
1031
1046
|
/**
|
|
1032
1047
|
* @param databaseInfo - The connection info.
|
|
1033
1048
|
* @param fetchImpl - `fetch` or a Polyfill that implements the fetch API.
|
|
1034
1049
|
*/
|
|
1035
|
-
constructor(t,
|
|
1036
|
-
super(t), this.I =
|
|
1050
|
+
constructor(t, e) {
|
|
1051
|
+
super(t), this.I = e;
|
|
1037
1052
|
}
|
|
1038
|
-
A(t,
|
|
1053
|
+
A(t, e) {
|
|
1039
1054
|
throw new Error("Not supported by FetchConnection");
|
|
1040
1055
|
}
|
|
1041
|
-
async v(t,
|
|
1056
|
+
async v(t, e, n, r) {
|
|
1042
1057
|
const s = JSON.stringify(r);
|
|
1043
1058
|
let i;
|
|
1044
1059
|
try {
|
|
1045
|
-
i = await this.I(
|
|
1060
|
+
i = await this.I(e, {
|
|
1046
1061
|
method: "POST",
|
|
1047
|
-
headers:
|
|
1062
|
+
headers: n,
|
|
1048
1063
|
body: s
|
|
1049
1064
|
});
|
|
1050
1065
|
} catch (t) {
|
|
@@ -1095,13 +1110,13 @@ class {
|
|
|
1095
1110
|
*/
|
|
1096
1111
|
function mt(t) {
|
|
1097
1112
|
// Polyfills for IE and WebWorker by using `self` and `msCrypto` when `crypto` is not available.
|
|
1098
|
-
const
|
|
1113
|
+
const e =
|
|
1099
1114
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1100
|
-
"undefined" != typeof self && (self.crypto || self.msCrypto),
|
|
1101
|
-
if (
|
|
1115
|
+
"undefined" != typeof self && (self.crypto || self.msCrypto), n = new Uint8Array(t);
|
|
1116
|
+
if (e && "function" == typeof e.getRandomValues) e.getRandomValues(n); else
|
|
1102
1117
|
// Falls back to Math.random
|
|
1103
|
-
for (let
|
|
1104
|
-
return
|
|
1118
|
+
for (let e = 0; e < t; e++) n[e] = Math.floor(256 * Math.random());
|
|
1119
|
+
return n;
|
|
1105
1120
|
}
|
|
1106
1121
|
|
|
1107
1122
|
/**
|
|
@@ -1122,26 +1137,26 @@ function mt(t) {
|
|
|
1122
1137
|
*/ class pt {
|
|
1123
1138
|
static R() {
|
|
1124
1139
|
// Alphanumeric characters
|
|
1125
|
-
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
|
|
1140
|
+
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", e = Math.floor(256 / t.length) * t.length;
|
|
1126
1141
|
// The largest byte value that is a multiple of `char.length`.
|
|
1127
|
-
let
|
|
1128
|
-
for (;
|
|
1142
|
+
let n = "";
|
|
1143
|
+
for (;n.length < 20; ) {
|
|
1129
1144
|
const r = mt(40);
|
|
1130
1145
|
for (let s = 0; s < r.length; ++s)
|
|
1131
1146
|
// Only accept values that are [0, maxMultiple), this ensures they can
|
|
1132
1147
|
// be evenly mapped to indices of `chars` via a modulo operation.
|
|
1133
|
-
|
|
1148
|
+
n.length < 20 && r[s] < e && (n += t.charAt(r[s] % t.length));
|
|
1134
1149
|
}
|
|
1135
|
-
return
|
|
1150
|
+
return n;
|
|
1136
1151
|
}
|
|
1137
1152
|
}
|
|
1138
1153
|
|
|
1139
|
-
function yt(t,
|
|
1140
|
-
return t <
|
|
1154
|
+
function yt(t, e) {
|
|
1155
|
+
return t < e ? -1 : t > e ? 1 : 0;
|
|
1141
1156
|
}
|
|
1142
1157
|
|
|
1143
|
-
/** Helper to compare arrays using isEqual(). */ function _t(t,
|
|
1144
|
-
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])));
|
|
1145
1160
|
}
|
|
1146
1161
|
|
|
1147
1162
|
/**
|
|
@@ -1195,9 +1210,9 @@ class gt {
|
|
|
1195
1210
|
/**
|
|
1196
1211
|
* The fractions of a second at nanosecond resolution.*
|
|
1197
1212
|
*/
|
|
1198
|
-
|
|
1199
|
-
if (this.seconds = t, this.nanoseconds =
|
|
1200
|
-
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);
|
|
1201
1216
|
if (t < -62135596800) throw new U(A, "Timestamp seconds out of range: " + t);
|
|
1202
1217
|
// This will break in the year 10,000.
|
|
1203
1218
|
if (t >= 253402300800) throw new U(A, "Timestamp seconds out of range: " + t);
|
|
@@ -1226,8 +1241,8 @@ class gt {
|
|
|
1226
1241
|
* @returns A new `Timestamp` representing the same point in time as the given
|
|
1227
1242
|
* number of milliseconds.
|
|
1228
1243
|
*/ static fromMillis(t) {
|
|
1229
|
-
const
|
|
1230
|
-
return new gt(
|
|
1244
|
+
const e = Math.floor(t / 1e3), n = Math.floor(1e6 * (t - 1e3 * e));
|
|
1245
|
+
return new gt(e, n);
|
|
1231
1246
|
}
|
|
1232
1247
|
/**
|
|
1233
1248
|
* Converts a `Timestamp` to a JavaScript `Date` object. This conversion
|
|
@@ -1305,15 +1320,15 @@ class gt {
|
|
|
1305
1320
|
/**
|
|
1306
1321
|
* A version of a document in Firestore. This corresponds to the version
|
|
1307
1322
|
* timestamp, such as update_time or read_time.
|
|
1308
|
-
*/ class
|
|
1323
|
+
*/ class bt {
|
|
1309
1324
|
constructor(t) {
|
|
1310
1325
|
this.timestamp = t;
|
|
1311
1326
|
}
|
|
1312
1327
|
static fromTimestamp(t) {
|
|
1313
|
-
return new
|
|
1328
|
+
return new bt(t);
|
|
1314
1329
|
}
|
|
1315
1330
|
static min() {
|
|
1316
|
-
return new
|
|
1331
|
+
return new bt(new gt(0, 0));
|
|
1317
1332
|
}
|
|
1318
1333
|
compareTo(t) {
|
|
1319
1334
|
return this.timestamp._compareTo(t.timestamp);
|
|
@@ -1348,14 +1363,14 @@ class gt {
|
|
|
1348
1363
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1349
1364
|
* See the License for the specific language governing permissions and
|
|
1350
1365
|
* limitations under the License.
|
|
1351
|
-
*/ function
|
|
1352
|
-
let
|
|
1353
|
-
for (const
|
|
1354
|
-
return
|
|
1366
|
+
*/ function vt(t) {
|
|
1367
|
+
let e = 0;
|
|
1368
|
+
for (const n in t) Object.prototype.hasOwnProperty.call(t, n) && e++;
|
|
1369
|
+
return e;
|
|
1355
1370
|
}
|
|
1356
1371
|
|
|
1357
|
-
function Et(t,
|
|
1358
|
-
for (const
|
|
1372
|
+
function Et(t, e) {
|
|
1373
|
+
for (const n in t) Object.prototype.hasOwnProperty.call(t, n) && e(n, t[n]);
|
|
1359
1374
|
}
|
|
1360
1375
|
|
|
1361
1376
|
/**
|
|
@@ -1397,11 +1412,11 @@ class Tt {
|
|
|
1397
1412
|
*
|
|
1398
1413
|
* This is an O(n) operation, where `n` is the size of the field mask.
|
|
1399
1414
|
*/ covers(t) {
|
|
1400
|
-
for (const
|
|
1415
|
+
for (const e of this.fields) if (e.isPrefixOf(t)) return !0;
|
|
1401
1416
|
return !1;
|
|
1402
1417
|
}
|
|
1403
1418
|
isEqual(t) {
|
|
1404
|
-
return _t(this.fields, t.fields, ((t,
|
|
1419
|
+
return _t(this.fields, t.fields, ((t, e) => t.isEqual(e)));
|
|
1405
1420
|
}
|
|
1406
1421
|
}
|
|
1407
1422
|
|
|
@@ -1452,23 +1467,25 @@ class It {
|
|
|
1452
1467
|
this.binaryString = t;
|
|
1453
1468
|
}
|
|
1454
1469
|
static fromBase64String(t) {
|
|
1455
|
-
const
|
|
1456
|
-
return new It(
|
|
1470
|
+
const e = atob(t);
|
|
1471
|
+
return new It(e);
|
|
1457
1472
|
}
|
|
1458
1473
|
static fromUint8Array(t) {
|
|
1459
|
-
|
|
1474
|
+
// TODO(indexing); Remove the copy of the byte string here as this method
|
|
1475
|
+
// is frequently called during indexing.
|
|
1476
|
+
const e =
|
|
1460
1477
|
/**
|
|
1461
1478
|
* Helper function to convert an Uint8array to a binary string.
|
|
1462
1479
|
*/
|
|
1463
1480
|
function(t) {
|
|
1464
|
-
let
|
|
1465
|
-
for (let
|
|
1466
|
-
return
|
|
1481
|
+
let e = "";
|
|
1482
|
+
for (let n = 0; n < t.length; ++n) e += String.fromCharCode(t[n]);
|
|
1483
|
+
return e;
|
|
1467
1484
|
}
|
|
1468
1485
|
/**
|
|
1469
1486
|
* Helper function to convert a binary string to an Uint8Array.
|
|
1470
1487
|
*/ (t);
|
|
1471
|
-
return new It(
|
|
1488
|
+
return new It(e);
|
|
1472
1489
|
}
|
|
1473
1490
|
[Symbol.iterator]() {
|
|
1474
1491
|
let t = 0;
|
|
@@ -1489,9 +1506,9 @@ class It {
|
|
|
1489
1506
|
}
|
|
1490
1507
|
toUint8Array() {
|
|
1491
1508
|
return function(t) {
|
|
1492
|
-
const
|
|
1493
|
-
for (let
|
|
1494
|
-
return
|
|
1509
|
+
const e = new Uint8Array(t.length);
|
|
1510
|
+
for (let n = 0; n < t.length; n++) e[n] = t.charCodeAt(n);
|
|
1511
|
+
return e;
|
|
1495
1512
|
}
|
|
1496
1513
|
/**
|
|
1497
1514
|
* @license
|
|
@@ -1534,22 +1551,22 @@ const At = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1534
1551
|
// The json interface (for the browser) will return an iso timestamp string,
|
|
1535
1552
|
// while the proto js library (for node) will return a
|
|
1536
1553
|
// google.protobuf.Timestamp instance.
|
|
1537
|
-
if (
|
|
1554
|
+
if (b(!!t), "string" == typeof t) {
|
|
1538
1555
|
// The date string can have higher precision (nanos) than the Date class
|
|
1539
1556
|
// (millis), so we do some custom parsing here.
|
|
1540
1557
|
// Parse the nanos right out of the string.
|
|
1541
|
-
let
|
|
1542
|
-
const
|
|
1543
|
-
if (
|
|
1558
|
+
let e = 0;
|
|
1559
|
+
const n = At.exec(t);
|
|
1560
|
+
if (b(!!n), n[1]) {
|
|
1544
1561
|
// Pad the fraction out to 9 digits (nanos).
|
|
1545
|
-
let t =
|
|
1546
|
-
t = (t + "000000000").substr(0, 9),
|
|
1562
|
+
let t = n[1];
|
|
1563
|
+
t = (t + "000000000").substr(0, 9), e = Number(t);
|
|
1547
1564
|
}
|
|
1548
1565
|
// Parse the date to get the seconds.
|
|
1549
1566
|
const r = new Date(t);
|
|
1550
1567
|
return {
|
|
1551
1568
|
seconds: Math.floor(r.getTime() / 1e3),
|
|
1552
|
-
nanos:
|
|
1569
|
+
nanos: e
|
|
1553
1570
|
};
|
|
1554
1571
|
}
|
|
1555
1572
|
return {
|
|
@@ -1604,8 +1621,8 @@ const At = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1604
1621
|
* - With respect to other ServerTimestampValues, they sort by their
|
|
1605
1622
|
* localWriteTime.
|
|
1606
1623
|
*/ function Dt(t) {
|
|
1607
|
-
var
|
|
1608
|
-
return "server_timestamp" === (null === (
|
|
1624
|
+
var e, n;
|
|
1625
|
+
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);
|
|
1609
1626
|
}
|
|
1610
1627
|
|
|
1611
1628
|
/**
|
|
@@ -1614,15 +1631,15 @@ const At = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1614
1631
|
* Preserving the previous values allows the user to display the last resoled
|
|
1615
1632
|
* value until the backend responds with the timestamp.
|
|
1616
1633
|
*/ function Nt(t) {
|
|
1617
|
-
const
|
|
1618
|
-
return Dt(
|
|
1634
|
+
const e = t.mapValue.fields.__previous_value__;
|
|
1635
|
+
return Dt(e) ? Nt(e) : e;
|
|
1619
1636
|
}
|
|
1620
1637
|
|
|
1621
1638
|
/**
|
|
1622
1639
|
* Returns the local time at which this timestamp was first set.
|
|
1623
1640
|
*/ function $t(t) {
|
|
1624
|
-
const
|
|
1625
|
-
return new gt(
|
|
1641
|
+
const e = Rt(t.mapValue.fields.__local_write_time__.timestampValue);
|
|
1642
|
+
return new gt(e.seconds, e.nanos);
|
|
1626
1643
|
}
|
|
1627
1644
|
|
|
1628
1645
|
/**
|
|
@@ -1641,173 +1658,200 @@ const At = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
|
|
|
1641
1658
|
* See the License for the specific language governing permissions and
|
|
1642
1659
|
* limitations under the License.
|
|
1643
1660
|
*/
|
|
1644
|
-
/** Extracts the backend's type order for the provided value. */
|
|
1645
|
-
|
|
1661
|
+
/** Extracts the backend's type order for the provided value. */
|
|
1662
|
+
function St(t) {
|
|
1663
|
+
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 */ :
|
|
1664
|
+
/** Returns true if the Value represents the canonical {@link #MAX_VALUE} . */
|
|
1665
|
+
function(t) {
|
|
1666
|
+
return "__max__" === (((t.mapValue || {}).fields || {}).__type__ || {}).stringValue;
|
|
1667
|
+
}
|
|
1668
|
+
/**
|
|
1669
|
+
* @license
|
|
1670
|
+
* Copyright 2017 Google LLC
|
|
1671
|
+
*
|
|
1672
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1673
|
+
* you may not use this file except in compliance with the License.
|
|
1674
|
+
* You may obtain a copy of the License at
|
|
1675
|
+
*
|
|
1676
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1677
|
+
*
|
|
1678
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1679
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1680
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1681
|
+
* See the License for the specific language governing permissions and
|
|
1682
|
+
* limitations under the License.
|
|
1683
|
+
*/
|
|
1684
|
+
/**
|
|
1685
|
+
* An ObjectValue represents a MapValue in the Firestore Proto and offers the
|
|
1686
|
+
* ability to add and remove fields (via the ObjectValueBuilder).
|
|
1687
|
+
*/ (t) ? 9 /* ArrayValue */ : 10 /* ObjectValue */ : g();
|
|
1646
1688
|
}
|
|
1647
1689
|
|
|
1648
|
-
/** Tests `left` and `right` for equality based on the backend semantics. */ function Ft(t,
|
|
1649
|
-
if (t ===
|
|
1650
|
-
const
|
|
1651
|
-
if (
|
|
1652
|
-
switch (
|
|
1690
|
+
/** Tests `left` and `right` for equality based on the backend semantics. */ function Ft(t, e) {
|
|
1691
|
+
if (t === e) return !0;
|
|
1692
|
+
const n = St(t);
|
|
1693
|
+
if (n !== St(e)) return !1;
|
|
1694
|
+
switch (n) {
|
|
1653
1695
|
case 0 /* NullValue */ :
|
|
1696
|
+
case 9007199254740991 /* MaxValue */ :
|
|
1654
1697
|
return !0;
|
|
1655
1698
|
|
|
1656
1699
|
case 1 /* BooleanValue */ :
|
|
1657
|
-
return t.booleanValue ===
|
|
1700
|
+
return t.booleanValue === e.booleanValue;
|
|
1658
1701
|
|
|
1659
1702
|
case 4 /* ServerTimestampValue */ :
|
|
1660
|
-
return $t(t).isEqual($t(
|
|
1703
|
+
return $t(t).isEqual($t(e));
|
|
1661
1704
|
|
|
1662
1705
|
case 3 /* TimestampValue */ :
|
|
1663
|
-
return function(t,
|
|
1664
|
-
if ("string" == typeof t.timestampValue && "string" == typeof
|
|
1706
|
+
return function(t, e) {
|
|
1707
|
+
if ("string" == typeof t.timestampValue && "string" == typeof e.timestampValue && t.timestampValue.length === e.timestampValue.length)
|
|
1665
1708
|
// Use string equality for ISO 8601 timestamps
|
|
1666
|
-
return t.timestampValue ===
|
|
1667
|
-
const
|
|
1668
|
-
return
|
|
1669
|
-
}(t,
|
|
1709
|
+
return t.timestampValue === e.timestampValue;
|
|
1710
|
+
const n = Rt(t.timestampValue), r = Rt(e.timestampValue);
|
|
1711
|
+
return n.seconds === r.seconds && n.nanos === r.nanos;
|
|
1712
|
+
}(t, e);
|
|
1670
1713
|
|
|
1671
1714
|
case 5 /* StringValue */ :
|
|
1672
|
-
return t.stringValue ===
|
|
1715
|
+
return t.stringValue === e.stringValue;
|
|
1673
1716
|
|
|
1674
1717
|
case 6 /* BlobValue */ :
|
|
1675
|
-
return function(t,
|
|
1676
|
-
return Vt(t.bytesValue).isEqual(Vt(
|
|
1677
|
-
}(t,
|
|
1718
|
+
return function(t, e) {
|
|
1719
|
+
return Vt(t.bytesValue).isEqual(Vt(e.bytesValue));
|
|
1720
|
+
}(t, e);
|
|
1678
1721
|
|
|
1679
1722
|
case 7 /* RefValue */ :
|
|
1680
|
-
return t.referenceValue ===
|
|
1723
|
+
return t.referenceValue === e.referenceValue;
|
|
1681
1724
|
|
|
1682
1725
|
case 8 /* GeoPointValue */ :
|
|
1683
|
-
return function(t,
|
|
1684
|
-
return Pt(t.geoPointValue.latitude) === Pt(
|
|
1685
|
-
}(t,
|
|
1726
|
+
return function(t, e) {
|
|
1727
|
+
return Pt(t.geoPointValue.latitude) === Pt(e.geoPointValue.latitude) && Pt(t.geoPointValue.longitude) === Pt(e.geoPointValue.longitude);
|
|
1728
|
+
}(t, e);
|
|
1686
1729
|
|
|
1687
1730
|
case 2 /* NumberValue */ :
|
|
1688
|
-
return function(t,
|
|
1689
|
-
if ("integerValue" in t && "integerValue" in
|
|
1690
|
-
if ("doubleValue" in t && "doubleValue" in
|
|
1691
|
-
const
|
|
1692
|
-
return
|
|
1731
|
+
return function(t, e) {
|
|
1732
|
+
if ("integerValue" in t && "integerValue" in e) return Pt(t.integerValue) === Pt(e.integerValue);
|
|
1733
|
+
if ("doubleValue" in t && "doubleValue" in e) {
|
|
1734
|
+
const n = Pt(t.doubleValue), r = Pt(e.doubleValue);
|
|
1735
|
+
return n === r ? at(n) === at(r) : isNaN(n) && isNaN(r);
|
|
1693
1736
|
}
|
|
1694
1737
|
return !1;
|
|
1695
|
-
}(t,
|
|
1738
|
+
}(t, e);
|
|
1696
1739
|
|
|
1697
1740
|
case 9 /* ArrayValue */ :
|
|
1698
|
-
return _t(t.arrayValue.values || [],
|
|
1741
|
+
return _t(t.arrayValue.values || [], e.arrayValue.values || [], Ft);
|
|
1699
1742
|
|
|
1700
1743
|
case 10 /* ObjectValue */ :
|
|
1701
|
-
return function(t,
|
|
1702
|
-
const
|
|
1703
|
-
if (
|
|
1704
|
-
for (const t in
|
|
1744
|
+
return function(t, e) {
|
|
1745
|
+
const n = t.mapValue.fields || {}, r = e.mapValue.fields || {};
|
|
1746
|
+
if (vt(n) !== vt(r)) return !1;
|
|
1747
|
+
for (const t in n) if (n.hasOwnProperty(t) && (void 0 === r[t] || !Ft(n[t], r[t]))) return !1;
|
|
1705
1748
|
return !0;
|
|
1706
1749
|
}
|
|
1707
|
-
/** Returns true if the ArrayValue contains the specified element. */ (t,
|
|
1750
|
+
/** Returns true if the ArrayValue contains the specified element. */ (t, e);
|
|
1708
1751
|
|
|
1709
1752
|
default:
|
|
1710
1753
|
return g();
|
|
1711
1754
|
}
|
|
1712
1755
|
}
|
|
1713
1756
|
|
|
1714
|
-
function xt(t,
|
|
1715
|
-
return void 0 !== (t.values || []).find((t => Ft(t,
|
|
1757
|
+
function xt(t, e) {
|
|
1758
|
+
return void 0 !== (t.values || []).find((t => Ft(t, e)));
|
|
1716
1759
|
}
|
|
1717
1760
|
|
|
1718
|
-
function qt(t,
|
|
1719
|
-
if (t ===
|
|
1720
|
-
const
|
|
1721
|
-
if (
|
|
1722
|
-
switch (
|
|
1761
|
+
function qt(t, e) {
|
|
1762
|
+
if (t === e) return 0;
|
|
1763
|
+
const n = St(t), r = St(e);
|
|
1764
|
+
if (n !== r) return yt(n, r);
|
|
1765
|
+
switch (n) {
|
|
1723
1766
|
case 0 /* NullValue */ :
|
|
1767
|
+
case 9007199254740991 /* MaxValue */ :
|
|
1724
1768
|
return 0;
|
|
1725
1769
|
|
|
1726
1770
|
case 1 /* BooleanValue */ :
|
|
1727
|
-
return yt(t.booleanValue,
|
|
1771
|
+
return yt(t.booleanValue, e.booleanValue);
|
|
1728
1772
|
|
|
1729
1773
|
case 2 /* NumberValue */ :
|
|
1730
|
-
return function(t,
|
|
1731
|
-
const
|
|
1732
|
-
return
|
|
1774
|
+
return function(t, e) {
|
|
1775
|
+
const n = Pt(t.integerValue || t.doubleValue), r = Pt(e.integerValue || e.doubleValue);
|
|
1776
|
+
return n < r ? -1 : n > r ? 1 : n === r ? 0 :
|
|
1733
1777
|
// one or both are NaN.
|
|
1734
|
-
isNaN(
|
|
1735
|
-
}(t,
|
|
1778
|
+
isNaN(n) ? isNaN(r) ? 0 : -1 : 1;
|
|
1779
|
+
}(t, e);
|
|
1736
1780
|
|
|
1737
1781
|
case 3 /* TimestampValue */ :
|
|
1738
|
-
return Ot(t.timestampValue,
|
|
1782
|
+
return Ot(t.timestampValue, e.timestampValue);
|
|
1739
1783
|
|
|
1740
1784
|
case 4 /* ServerTimestampValue */ :
|
|
1741
|
-
return Ot($t(t), $t(
|
|
1785
|
+
return Ot($t(t), $t(e));
|
|
1742
1786
|
|
|
1743
1787
|
case 5 /* StringValue */ :
|
|
1744
|
-
return yt(t.stringValue,
|
|
1788
|
+
return yt(t.stringValue, e.stringValue);
|
|
1745
1789
|
|
|
1746
1790
|
case 6 /* BlobValue */ :
|
|
1747
|
-
return function(t,
|
|
1748
|
-
const
|
|
1749
|
-
return
|
|
1750
|
-
}(t.bytesValue,
|
|
1791
|
+
return function(t, e) {
|
|
1792
|
+
const n = Vt(t), r = Vt(e);
|
|
1793
|
+
return n.compareTo(r);
|
|
1794
|
+
}(t.bytesValue, e.bytesValue);
|
|
1751
1795
|
|
|
1752
1796
|
case 7 /* RefValue */ :
|
|
1753
|
-
return function(t,
|
|
1754
|
-
const
|
|
1755
|
-
for (let t = 0; t <
|
|
1756
|
-
const
|
|
1757
|
-
if (0 !==
|
|
1797
|
+
return function(t, e) {
|
|
1798
|
+
const n = t.split("/"), r = e.split("/");
|
|
1799
|
+
for (let t = 0; t < n.length && t < r.length; t++) {
|
|
1800
|
+
const e = yt(n[t], r[t]);
|
|
1801
|
+
if (0 !== e) return e;
|
|
1758
1802
|
}
|
|
1759
|
-
return yt(
|
|
1760
|
-
}(t.referenceValue,
|
|
1803
|
+
return yt(n.length, r.length);
|
|
1804
|
+
}(t.referenceValue, e.referenceValue);
|
|
1761
1805
|
|
|
1762
1806
|
case 8 /* GeoPointValue */ :
|
|
1763
|
-
return function(t,
|
|
1764
|
-
const
|
|
1765
|
-
if (0 !==
|
|
1766
|
-
return yt(Pt(t.longitude), Pt(
|
|
1767
|
-
}(t.geoPointValue,
|
|
1807
|
+
return function(t, e) {
|
|
1808
|
+
const n = yt(Pt(t.latitude), Pt(e.latitude));
|
|
1809
|
+
if (0 !== n) return n;
|
|
1810
|
+
return yt(Pt(t.longitude), Pt(e.longitude));
|
|
1811
|
+
}(t.geoPointValue, e.geoPointValue);
|
|
1768
1812
|
|
|
1769
1813
|
case 9 /* ArrayValue */ :
|
|
1770
|
-
return function(t,
|
|
1771
|
-
const
|
|
1772
|
-
for (let t = 0; t <
|
|
1773
|
-
const
|
|
1774
|
-
if (
|
|
1814
|
+
return function(t, e) {
|
|
1815
|
+
const n = t.values || [], r = e.values || [];
|
|
1816
|
+
for (let t = 0; t < n.length && t < r.length; ++t) {
|
|
1817
|
+
const e = qt(n[t], r[t]);
|
|
1818
|
+
if (e) return e;
|
|
1775
1819
|
}
|
|
1776
|
-
return yt(
|
|
1777
|
-
}(t.arrayValue,
|
|
1820
|
+
return yt(n.length, r.length);
|
|
1821
|
+
}(t.arrayValue, e.arrayValue);
|
|
1778
1822
|
|
|
1779
1823
|
case 10 /* ObjectValue */ :
|
|
1780
|
-
return function(t,
|
|
1781
|
-
const
|
|
1824
|
+
return function(t, e) {
|
|
1825
|
+
const n = t.fields || {}, r = Object.keys(n), s = e.fields || {}, i = Object.keys(s);
|
|
1782
1826
|
// Even though MapValues are likely sorted correctly based on their insertion
|
|
1783
1827
|
// order (e.g. when received from the backend), local modifications can bring
|
|
1784
1828
|
// elements out of order. We need to re-sort the elements to ensure that
|
|
1785
1829
|
// canonical IDs are independent of insertion order.
|
|
1786
1830
|
r.sort(), i.sort();
|
|
1787
1831
|
for (let t = 0; t < r.length && t < i.length; ++t) {
|
|
1788
|
-
const
|
|
1789
|
-
if (0 !==
|
|
1790
|
-
const o = qt(
|
|
1832
|
+
const e = yt(r[t], i[t]);
|
|
1833
|
+
if (0 !== e) return e;
|
|
1834
|
+
const o = qt(n[r[t]], s[i[t]]);
|
|
1791
1835
|
if (0 !== o) return o;
|
|
1792
1836
|
}
|
|
1793
1837
|
return yt(r.length, i.length);
|
|
1794
1838
|
}
|
|
1795
|
-
/** Returns a reference value for the provided database and key. */ (t.mapValue,
|
|
1839
|
+
/** Returns a reference value for the provided database and key. */ (t.mapValue, e.mapValue);
|
|
1796
1840
|
|
|
1797
1841
|
default:
|
|
1798
1842
|
throw g();
|
|
1799
1843
|
}
|
|
1800
1844
|
}
|
|
1801
1845
|
|
|
1802
|
-
function Ot(t,
|
|
1803
|
-
if ("string" == typeof t && "string" == typeof
|
|
1804
|
-
const
|
|
1805
|
-
return 0 !== s ? s : yt(
|
|
1846
|
+
function Ot(t, e) {
|
|
1847
|
+
if ("string" == typeof t && "string" == typeof e && t.length === e.length) return yt(t, e);
|
|
1848
|
+
const n = Rt(t), r = Rt(e), s = yt(n.seconds, r.seconds);
|
|
1849
|
+
return 0 !== s ? s : yt(n.nanos, r.nanos);
|
|
1806
1850
|
}
|
|
1807
1851
|
|
|
1808
|
-
function Ct(t,
|
|
1852
|
+
function Ct(t, e) {
|
|
1809
1853
|
return {
|
|
1810
|
-
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${
|
|
1854
|
+
referenceValue: `projects/${t.projectId}/databases/${t.database}/documents/${e.path.canonicalString()}`
|
|
1811
1855
|
};
|
|
1812
1856
|
}
|
|
1813
1857
|
|
|
@@ -1835,45 +1879,26 @@ function Ct(t, n) {
|
|
|
1835
1879
|
timestampValue: Object.assign({}, t.timestampValue)
|
|
1836
1880
|
};
|
|
1837
1881
|
if (t.mapValue) {
|
|
1838
|
-
const
|
|
1882
|
+
const e = {
|
|
1839
1883
|
mapValue: {
|
|
1840
1884
|
fields: {}
|
|
1841
1885
|
}
|
|
1842
1886
|
};
|
|
1843
|
-
return Et(t.mapValue.fields, ((t,
|
|
1887
|
+
return Et(t.mapValue.fields, ((t, n) => e.mapValue.fields[t] = Mt(n))), e;
|
|
1844
1888
|
}
|
|
1845
1889
|
if (t.arrayValue) {
|
|
1846
|
-
const
|
|
1890
|
+
const e = {
|
|
1847
1891
|
arrayValue: {
|
|
1848
1892
|
values: []
|
|
1849
1893
|
}
|
|
1850
1894
|
};
|
|
1851
|
-
for (let
|
|
1852
|
-
return
|
|
1895
|
+
for (let n = 0; n < (t.arrayValue.values || []).length; ++n) e.arrayValue.values[n] = Mt(t.arrayValue.values[n]);
|
|
1896
|
+
return e;
|
|
1853
1897
|
}
|
|
1854
1898
|
return Object.assign({}, t);
|
|
1855
1899
|
}
|
|
1856
1900
|
|
|
1857
|
-
|
|
1858
|
-
* @license
|
|
1859
|
-
* Copyright 2017 Google LLC
|
|
1860
|
-
*
|
|
1861
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1862
|
-
* you may not use this file except in compliance with the License.
|
|
1863
|
-
* You may obtain a copy of the License at
|
|
1864
|
-
*
|
|
1865
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1866
|
-
*
|
|
1867
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1868
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1869
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1870
|
-
* See the License for the specific language governing permissions and
|
|
1871
|
-
* limitations under the License.
|
|
1872
|
-
*/
|
|
1873
|
-
/**
|
|
1874
|
-
* An ObjectValue represents a MapValue in the Firestore Proto and offers the
|
|
1875
|
-
* ability to add and remove fields (via the ObjectValueBuilder).
|
|
1876
|
-
*/ class Bt {
|
|
1901
|
+
class Bt {
|
|
1877
1902
|
constructor(t) {
|
|
1878
1903
|
this.value = t;
|
|
1879
1904
|
}
|
|
@@ -1890,10 +1915,10 @@ function Ct(t, n) {
|
|
|
1890
1915
|
*/ field(t) {
|
|
1891
1916
|
if (t.isEmpty()) return this.value;
|
|
1892
1917
|
{
|
|
1893
|
-
let
|
|
1894
|
-
for (let
|
|
1895
|
-
!jt(
|
|
1896
|
-
return
|
|
1918
|
+
let e = this.value;
|
|
1919
|
+
for (let n = 0; n < t.length - 1; ++n) if (e = (e.mapValue.fields || {})[t.get(n)],
|
|
1920
|
+
!jt(e)) return null;
|
|
1921
|
+
return e = (e.mapValue.fields || {})[t.lastSegment()], e || null;
|
|
1897
1922
|
}
|
|
1898
1923
|
}
|
|
1899
1924
|
/**
|
|
@@ -1901,25 +1926,25 @@ function Ct(t, n) {
|
|
|
1901
1926
|
*
|
|
1902
1927
|
* @param path - The field path to set.
|
|
1903
1928
|
* @param value - The value to set.
|
|
1904
|
-
*/ set(t,
|
|
1905
|
-
this.getFieldsMap(t.popLast())[t.lastSegment()] = Mt(
|
|
1929
|
+
*/ set(t, e) {
|
|
1930
|
+
this.getFieldsMap(t.popLast())[t.lastSegment()] = Mt(e);
|
|
1906
1931
|
}
|
|
1907
1932
|
/**
|
|
1908
1933
|
* Sets the provided fields to the provided values.
|
|
1909
1934
|
*
|
|
1910
1935
|
* @param data - A map of fields to values (or null for deletes).
|
|
1911
1936
|
*/ setAll(t) {
|
|
1912
|
-
let
|
|
1937
|
+
let e = tt.emptyPath(), n = {}, r = [];
|
|
1913
1938
|
t.forEach(((t, s) => {
|
|
1914
|
-
if (!
|
|
1939
|
+
if (!e.isImmediateParentOf(s)) {
|
|
1915
1940
|
// Insert the accumulated changes at this parent location
|
|
1916
|
-
const t = this.getFieldsMap(
|
|
1917
|
-
this.applyChanges(t,
|
|
1941
|
+
const t = this.getFieldsMap(e);
|
|
1942
|
+
this.applyChanges(t, n, r), n = {}, r = [], e = s.popLast();
|
|
1918
1943
|
}
|
|
1919
|
-
t ?
|
|
1944
|
+
t ? n[s.lastSegment()] = Mt(t) : r.push(s.lastSegment());
|
|
1920
1945
|
}));
|
|
1921
|
-
const s = this.getFieldsMap(
|
|
1922
|
-
this.applyChanges(s,
|
|
1946
|
+
const s = this.getFieldsMap(e);
|
|
1947
|
+
this.applyChanges(s, n, r);
|
|
1923
1948
|
}
|
|
1924
1949
|
/**
|
|
1925
1950
|
* Removes the field at the specified path. If there is no field at the
|
|
@@ -1927,8 +1952,8 @@ function Ct(t, n) {
|
|
|
1927
1952
|
*
|
|
1928
1953
|
* @param path - The field path to remove.
|
|
1929
1954
|
*/ delete(t) {
|
|
1930
|
-
const
|
|
1931
|
-
jt(
|
|
1955
|
+
const e = this.field(t.popLast());
|
|
1956
|
+
jt(e) && e.mapValue.fields && delete e.mapValue.fields[t.lastSegment()];
|
|
1932
1957
|
}
|
|
1933
1958
|
isEqual(t) {
|
|
1934
1959
|
return Ft(this.value, t.value);
|
|
@@ -1937,26 +1962,26 @@ function Ct(t, n) {
|
|
|
1937
1962
|
* Returns the map that contains the leaf element of `path`. If the parent
|
|
1938
1963
|
* entry does not yet exist, or if it is not a map, a new map will be created.
|
|
1939
1964
|
*/ getFieldsMap(t) {
|
|
1940
|
-
let
|
|
1941
|
-
|
|
1965
|
+
let e = this.value;
|
|
1966
|
+
e.mapValue.fields || (e.mapValue = {
|
|
1942
1967
|
fields: {}
|
|
1943
1968
|
});
|
|
1944
|
-
for (let
|
|
1945
|
-
let r =
|
|
1969
|
+
for (let n = 0; n < t.length; ++n) {
|
|
1970
|
+
let r = e.mapValue.fields[t.get(n)];
|
|
1946
1971
|
jt(r) && r.mapValue.fields || (r = {
|
|
1947
1972
|
mapValue: {
|
|
1948
1973
|
fields: {}
|
|
1949
1974
|
}
|
|
1950
|
-
},
|
|
1975
|
+
}, e.mapValue.fields[t.get(n)] = r), e = r;
|
|
1951
1976
|
}
|
|
1952
|
-
return
|
|
1977
|
+
return e.mapValue.fields;
|
|
1953
1978
|
}
|
|
1954
1979
|
/**
|
|
1955
1980
|
* Modifies `fieldsMap` by adding, replacing or deleting the specified
|
|
1956
1981
|
* entries.
|
|
1957
|
-
*/ applyChanges(t,
|
|
1958
|
-
Et(
|
|
1959
|
-
for (const
|
|
1982
|
+
*/ applyChanges(t, e, n) {
|
|
1983
|
+
Et(e, ((e, n) => t[e] = n));
|
|
1984
|
+
for (const e of n) delete t[e];
|
|
1960
1985
|
}
|
|
1961
1986
|
clone() {
|
|
1962
1987
|
return new Bt(Mt(this.value));
|
|
@@ -1989,36 +2014,37 @@ function Ct(t, n) {
|
|
|
1989
2014
|
* applied, `isValidDocument()` returns false and the document should be removed
|
|
1990
2015
|
* from all views.
|
|
1991
2016
|
*/ class zt {
|
|
1992
|
-
constructor(t,
|
|
1993
|
-
this.key = t, this.documentType =
|
|
2017
|
+
constructor(t, e, n, r, s, i) {
|
|
2018
|
+
this.key = t, this.documentType = e, this.version = n, this.readTime = r, this.data = s,
|
|
2019
|
+
this.documentState = i;
|
|
1994
2020
|
}
|
|
1995
2021
|
/**
|
|
1996
2022
|
* Creates a document with no known version or data, but which can serve as
|
|
1997
2023
|
* base document for mutations.
|
|
1998
2024
|
*/ static newInvalidDocument(t) {
|
|
1999
|
-
return new zt(t, 0 /* INVALID */ ,
|
|
2025
|
+
return new zt(t, 0 /* INVALID */ , bt.min(), bt.min(), Bt.empty(), 0 /* SYNCED */);
|
|
2000
2026
|
}
|
|
2001
2027
|
/**
|
|
2002
2028
|
* Creates a new document that is known to exist with the given data at the
|
|
2003
2029
|
* given version.
|
|
2004
|
-
*/ static newFoundDocument(t,
|
|
2005
|
-
return new zt(t, 1 /* FOUND_DOCUMENT */ ,
|
|
2030
|
+
*/ static newFoundDocument(t, e, n) {
|
|
2031
|
+
return new zt(t, 1 /* FOUND_DOCUMENT */ , e, bt.min(), n, 0 /* SYNCED */);
|
|
2006
2032
|
}
|
|
2007
|
-
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t,
|
|
2008
|
-
return new zt(t, 2 /* NO_DOCUMENT */ ,
|
|
2033
|
+
/** Creates a new document that is known to not exist at the given version. */ static newNoDocument(t, e) {
|
|
2034
|
+
return new zt(t, 2 /* NO_DOCUMENT */ , e, bt.min(), Bt.empty(), 0 /* SYNCED */);
|
|
2009
2035
|
}
|
|
2010
2036
|
/**
|
|
2011
2037
|
* Creates a new document that is known to exist at the given version but
|
|
2012
2038
|
* whose data is not known (e.g. a document that was updated without a known
|
|
2013
2039
|
* base document).
|
|
2014
|
-
*/ static newUnknownDocument(t,
|
|
2015
|
-
return new zt(t, 3 /* UNKNOWN_DOCUMENT */ ,
|
|
2040
|
+
*/ static newUnknownDocument(t, e) {
|
|
2041
|
+
return new zt(t, 3 /* UNKNOWN_DOCUMENT */ , e, bt.min(), Bt.empty(), 2 /* HAS_COMMITTED_MUTATIONS */);
|
|
2016
2042
|
}
|
|
2017
2043
|
/**
|
|
2018
2044
|
* Changes the document type to indicate that it exists and that its version
|
|
2019
2045
|
* and data are known.
|
|
2020
|
-
*/ convertToFoundDocument(t,
|
|
2021
|
-
return this.version = t, this.documentType = 1 /* FOUND_DOCUMENT */ , this.data =
|
|
2046
|
+
*/ convertToFoundDocument(t, e) {
|
|
2047
|
+
return this.version = t, this.documentType = 1 /* FOUND_DOCUMENT */ , this.data = e,
|
|
2022
2048
|
this.documentState = 0 /* SYNCED */ , this;
|
|
2023
2049
|
}
|
|
2024
2050
|
/**
|
|
@@ -2042,6 +2068,9 @@ function Ct(t, n) {
|
|
|
2042
2068
|
setHasLocalMutations() {
|
|
2043
2069
|
return this.documentState = 1 /* HAS_LOCAL_MUTATIONS */ , this;
|
|
2044
2070
|
}
|
|
2071
|
+
setReadTime(t) {
|
|
2072
|
+
return this.readTime = t, this;
|
|
2073
|
+
}
|
|
2045
2074
|
get hasLocalMutations() {
|
|
2046
2075
|
return 1 /* HAS_LOCAL_MUTATIONS */ === this.documentState;
|
|
2047
2076
|
}
|
|
@@ -2067,7 +2096,7 @@ function Ct(t, n) {
|
|
|
2067
2096
|
return t instanceof zt && this.key.isEqual(t.key) && this.version.isEqual(t.version) && this.documentType === t.documentType && this.documentState === t.documentState && this.data.isEqual(t.data);
|
|
2068
2097
|
}
|
|
2069
2098
|
mutableCopy() {
|
|
2070
|
-
return new zt(this.key, this.documentType, this.version, this.data.clone(), this.documentState);
|
|
2099
|
+
return new zt(this.key, this.documentType, this.version, this.readTime, this.data.clone(), this.documentState);
|
|
2071
2100
|
}
|
|
2072
2101
|
toString() {
|
|
2073
2102
|
return `Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`;
|
|
@@ -2092,8 +2121,8 @@ function Ct(t, n) {
|
|
|
2092
2121
|
*/
|
|
2093
2122
|
// Visible for testing
|
|
2094
2123
|
class Gt {
|
|
2095
|
-
constructor(t,
|
|
2096
|
-
this.path = t, this.collectionGroup =
|
|
2124
|
+
constructor(t, e = null, n = [], r = [], s = null, i = null, o = null) {
|
|
2125
|
+
this.path = t, this.collectionGroup = e, this.orderBy = n, this.filters = r, this.limit = s,
|
|
2097
2126
|
this.startAt = i, this.endAt = o, this.P = null;
|
|
2098
2127
|
}
|
|
2099
2128
|
}
|
|
@@ -2105,26 +2134,26 @@ class Gt {
|
|
|
2105
2134
|
* NOTE: you should always construct `Target` from `Query.toTarget` instead of
|
|
2106
2135
|
* using this factory method, because `Query` provides an implicit `orderBy`
|
|
2107
2136
|
* property.
|
|
2108
|
-
*/ function Qt(t,
|
|
2109
|
-
return new Gt(t,
|
|
2137
|
+
*/ function Qt(t, e = null, n = [], r = [], s = null, i = null, o = null) {
|
|
2138
|
+
return new Gt(t, e, n, r, s, i, o);
|
|
2110
2139
|
}
|
|
2111
2140
|
|
|
2112
2141
|
class Wt extends class {} {
|
|
2113
|
-
constructor(t,
|
|
2114
|
-
super(), this.field = t, this.op =
|
|
2142
|
+
constructor(t, e, n) {
|
|
2143
|
+
super(), this.field = t, this.op = e, this.value = n;
|
|
2115
2144
|
}
|
|
2116
2145
|
/**
|
|
2117
2146
|
* Creates a filter based on the provided arguments.
|
|
2118
|
-
*/ static create(t,
|
|
2119
|
-
return t.isKeyField() ? "in" /* IN */ ===
|
|
2147
|
+
*/ static create(t, e, n) {
|
|
2148
|
+
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);
|
|
2120
2149
|
}
|
|
2121
|
-
static V(t,
|
|
2122
|
-
return "in" /* IN */ ===
|
|
2150
|
+
static V(t, e, n) {
|
|
2151
|
+
return "in" /* IN */ === e ? new Ht(t, n) : new Kt(t, n);
|
|
2123
2152
|
}
|
|
2124
2153
|
matches(t) {
|
|
2125
|
-
const
|
|
2154
|
+
const e = t.data.field(this.field);
|
|
2126
2155
|
// Types do not have to match in NOT_EQUAL filters.
|
|
2127
|
-
return "!=" /* NOT_EQUAL */ === this.op ? null !==
|
|
2156
|
+
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));
|
|
2128
2157
|
// Only compare types with matching backend order (such as double and int).
|
|
2129
2158
|
}
|
|
2130
2159
|
D(t) {
|
|
@@ -2158,78 +2187,78 @@ class Wt extends class {} {
|
|
|
2158
2187
|
|
|
2159
2188
|
/** Filter that matches on key fields (i.e. '__name__'). */
|
|
2160
2189
|
class Yt extends Wt {
|
|
2161
|
-
constructor(t,
|
|
2162
|
-
super(t,
|
|
2190
|
+
constructor(t, e, n) {
|
|
2191
|
+
super(t, e, n), this.key = et.fromName(n.referenceValue);
|
|
2163
2192
|
}
|
|
2164
2193
|
matches(t) {
|
|
2165
|
-
const
|
|
2166
|
-
return this.D(
|
|
2194
|
+
const e = et.comparator(t.key, this.key);
|
|
2195
|
+
return this.D(e);
|
|
2167
2196
|
}
|
|
2168
2197
|
}
|
|
2169
2198
|
|
|
2170
2199
|
/** Filter that matches on key fields within an array. */ class Ht extends Wt {
|
|
2171
|
-
constructor(t,
|
|
2172
|
-
super(t, "in" /* IN */ ,
|
|
2200
|
+
constructor(t, e) {
|
|
2201
|
+
super(t, "in" /* IN */ , e), this.keys = Jt("in" /* IN */ , e);
|
|
2173
2202
|
}
|
|
2174
2203
|
matches(t) {
|
|
2175
|
-
return this.keys.some((
|
|
2204
|
+
return this.keys.some((e => e.isEqual(t.key)));
|
|
2176
2205
|
}
|
|
2177
2206
|
}
|
|
2178
2207
|
|
|
2179
2208
|
/** Filter that matches on key fields not present within an array. */ class Kt extends Wt {
|
|
2180
|
-
constructor(t,
|
|
2181
|
-
super(t, "not-in" /* NOT_IN */ ,
|
|
2209
|
+
constructor(t, e) {
|
|
2210
|
+
super(t, "not-in" /* NOT_IN */ , e), this.keys = Jt("not-in" /* NOT_IN */ , e);
|
|
2182
2211
|
}
|
|
2183
2212
|
matches(t) {
|
|
2184
|
-
return !this.keys.some((
|
|
2213
|
+
return !this.keys.some((e => e.isEqual(t.key)));
|
|
2185
2214
|
}
|
|
2186
2215
|
}
|
|
2187
2216
|
|
|
2188
|
-
function Jt(t,
|
|
2189
|
-
var
|
|
2190
|
-
return ((null === (
|
|
2217
|
+
function Jt(t, e) {
|
|
2218
|
+
var n;
|
|
2219
|
+
return ((null === (n = e.arrayValue) || void 0 === n ? void 0 : n.values) || []).map((t => et.fromName(t.referenceValue)));
|
|
2191
2220
|
}
|
|
2192
2221
|
|
|
2193
2222
|
/** A Filter that implements the array-contains operator. */ class Xt extends Wt {
|
|
2194
|
-
constructor(t,
|
|
2195
|
-
super(t, "array-contains" /* ARRAY_CONTAINS */ ,
|
|
2223
|
+
constructor(t, e) {
|
|
2224
|
+
super(t, "array-contains" /* ARRAY_CONTAINS */ , e);
|
|
2196
2225
|
}
|
|
2197
2226
|
matches(t) {
|
|
2198
|
-
const
|
|
2199
|
-
return Lt(
|
|
2227
|
+
const e = t.data.field(this.field);
|
|
2228
|
+
return Lt(e) && xt(e.arrayValue, this.value);
|
|
2200
2229
|
}
|
|
2201
2230
|
}
|
|
2202
2231
|
|
|
2203
2232
|
/** A Filter that implements the IN operator. */ class Zt extends Wt {
|
|
2204
|
-
constructor(t,
|
|
2205
|
-
super(t, "in" /* IN */ ,
|
|
2233
|
+
constructor(t, e) {
|
|
2234
|
+
super(t, "in" /* IN */ , e);
|
|
2206
2235
|
}
|
|
2207
2236
|
matches(t) {
|
|
2208
|
-
const
|
|
2209
|
-
return null !==
|
|
2237
|
+
const e = t.data.field(this.field);
|
|
2238
|
+
return null !== e && xt(this.value.arrayValue, e);
|
|
2210
2239
|
}
|
|
2211
2240
|
}
|
|
2212
2241
|
|
|
2213
|
-
/** A Filter that implements the not-in operator. */ class
|
|
2214
|
-
constructor(t,
|
|
2215
|
-
super(t, "not-in" /* NOT_IN */ ,
|
|
2242
|
+
/** A Filter that implements the not-in operator. */ class te extends Wt {
|
|
2243
|
+
constructor(t, e) {
|
|
2244
|
+
super(t, "not-in" /* NOT_IN */ , e);
|
|
2216
2245
|
}
|
|
2217
2246
|
matches(t) {
|
|
2218
2247
|
if (xt(this.value.arrayValue, {
|
|
2219
2248
|
nullValue: "NULL_VALUE"
|
|
2220
2249
|
})) return !1;
|
|
2221
|
-
const
|
|
2222
|
-
return null !==
|
|
2250
|
+
const e = t.data.field(this.field);
|
|
2251
|
+
return null !== e && !xt(this.value.arrayValue, e);
|
|
2223
2252
|
}
|
|
2224
2253
|
}
|
|
2225
2254
|
|
|
2226
|
-
/** A Filter that implements the array-contains-any operator. */ class
|
|
2227
|
-
constructor(t,
|
|
2228
|
-
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ ,
|
|
2255
|
+
/** A Filter that implements the array-contains-any operator. */ class ee extends Wt {
|
|
2256
|
+
constructor(t, e) {
|
|
2257
|
+
super(t, "array-contains-any" /* ARRAY_CONTAINS_ANY */ , e);
|
|
2229
2258
|
}
|
|
2230
2259
|
matches(t) {
|
|
2231
|
-
const
|
|
2232
|
-
return !(!Lt(
|
|
2260
|
+
const e = t.data.field(this.field);
|
|
2261
|
+
return !(!Lt(e) || !e.arrayValue.values) && e.arrayValue.values.some((t => xt(this.value.arrayValue, t)));
|
|
2233
2262
|
}
|
|
2234
2263
|
}
|
|
2235
2264
|
|
|
@@ -2246,30 +2275,30 @@ function Jt(t, n) {
|
|
|
2246
2275
|
* Bound provides a function to determine whether a document comes before or
|
|
2247
2276
|
* after a bound. This is influenced by whether the position is just before or
|
|
2248
2277
|
* just after the provided values.
|
|
2249
|
-
*/ class
|
|
2250
|
-
constructor(t,
|
|
2251
|
-
this.position = t, this.
|
|
2278
|
+
*/ class ne {
|
|
2279
|
+
constructor(t, e) {
|
|
2280
|
+
this.position = t, this.inclusive = e;
|
|
2252
2281
|
}
|
|
2253
2282
|
}
|
|
2254
2283
|
|
|
2255
2284
|
/**
|
|
2256
2285
|
* An ordering on a field, in some Direction. Direction defaults to ASCENDING.
|
|
2257
|
-
*/ class
|
|
2258
|
-
constructor(t,
|
|
2259
|
-
this.field = t, this.dir =
|
|
2286
|
+
*/ class re {
|
|
2287
|
+
constructor(t, e = "asc" /* ASCENDING */) {
|
|
2288
|
+
this.field = t, this.dir = e;
|
|
2260
2289
|
}
|
|
2261
2290
|
}
|
|
2262
2291
|
|
|
2263
|
-
function
|
|
2264
|
-
return t.dir ===
|
|
2292
|
+
function se(t, e) {
|
|
2293
|
+
return t.dir === e.dir && t.field.isEqual(e.field);
|
|
2265
2294
|
}
|
|
2266
2295
|
|
|
2267
|
-
function
|
|
2268
|
-
if (null === t) return null ===
|
|
2269
|
-
if (null ===
|
|
2270
|
-
if (t.
|
|
2271
|
-
for (let
|
|
2272
|
-
if (!Ft(t.position[
|
|
2296
|
+
function ie(t, e) {
|
|
2297
|
+
if (null === t) return null === e;
|
|
2298
|
+
if (null === e) return !1;
|
|
2299
|
+
if (t.inclusive !== e.inclusive || t.position.length !== e.position.length) return !1;
|
|
2300
|
+
for (let n = 0; n < t.position.length; n++) {
|
|
2301
|
+
if (!Ft(t.position[n], e.position[n])) return !1;
|
|
2273
2302
|
}
|
|
2274
2303
|
return !0;
|
|
2275
2304
|
}
|
|
@@ -2296,29 +2325,29 @@ function on(t, n) {
|
|
|
2296
2325
|
* query the RemoteStore results.
|
|
2297
2326
|
*
|
|
2298
2327
|
* Visible for testing.
|
|
2299
|
-
*/ class
|
|
2328
|
+
*/ class oe {
|
|
2300
2329
|
/**
|
|
2301
2330
|
* Initializes a Query with a path and optional additional query constraints.
|
|
2302
2331
|
* Path must currently be empty if this is a collection group query.
|
|
2303
2332
|
*/
|
|
2304
|
-
constructor(t,
|
|
2305
|
-
this.path = t, this.collectionGroup =
|
|
2333
|
+
constructor(t, e = null, n = [], r = [], s = null, i = "F" /* First */ , o = null, u = null) {
|
|
2334
|
+
this.path = t, this.collectionGroup = e, this.explicitOrderBy = n, this.filters = r,
|
|
2306
2335
|
this.limit = s, this.limitType = i, this.startAt = o, this.endAt = u, this.$ = null,
|
|
2307
2336
|
// The corresponding `Target` of this `Query` instance.
|
|
2308
2337
|
this.S = null, this.startAt, this.endAt;
|
|
2309
2338
|
}
|
|
2310
2339
|
}
|
|
2311
2340
|
|
|
2312
|
-
/** Creates a new Query for a query that matches all documents at `path` */ function
|
|
2341
|
+
/** Creates a new Query for a query that matches all documents at `path` */ function ue(t) {
|
|
2313
2342
|
return !ct(t.limit) && "L" /* Last */ === t.limitType;
|
|
2314
2343
|
}
|
|
2315
2344
|
|
|
2316
|
-
function
|
|
2345
|
+
function ce(t) {
|
|
2317
2346
|
return t.explicitOrderBy.length > 0 ? t.explicitOrderBy[0].field : null;
|
|
2318
2347
|
}
|
|
2319
2348
|
|
|
2320
|
-
function
|
|
2321
|
-
for (const
|
|
2349
|
+
function ae(t) {
|
|
2350
|
+
for (const e of t.filters) if (e.N()) return e.field;
|
|
2322
2351
|
return null;
|
|
2323
2352
|
}
|
|
2324
2353
|
|
|
@@ -2330,7 +2359,7 @@ function hn(t) {
|
|
|
2330
2359
|
* Returns whether the query matches a collection group rather than a specific
|
|
2331
2360
|
* collection.
|
|
2332
2361
|
*/
|
|
2333
|
-
function
|
|
2362
|
+
function he(t) {
|
|
2334
2363
|
return null !== t.collectionGroup;
|
|
2335
2364
|
}
|
|
2336
2365
|
|
|
@@ -2338,59 +2367,59 @@ function ln(t) {
|
|
|
2338
2367
|
* Returns the implicit order by constraint that is used to execute the Query,
|
|
2339
2368
|
* which can be different from the order by constraints the user provided (e.g.
|
|
2340
2369
|
* the SDK and backend always orders by `__name__`).
|
|
2341
|
-
*/ function
|
|
2342
|
-
const
|
|
2343
|
-
if (null ===
|
|
2344
|
-
|
|
2345
|
-
const t =
|
|
2346
|
-
if (null !== t && null ===
|
|
2370
|
+
*/ function le(t) {
|
|
2371
|
+
const e = v(t);
|
|
2372
|
+
if (null === e.$) {
|
|
2373
|
+
e.$ = [];
|
|
2374
|
+
const t = ae(e), n = ce(e);
|
|
2375
|
+
if (null !== t && null === n)
|
|
2347
2376
|
// In order to implicitly add key ordering, we must also add the
|
|
2348
2377
|
// inequality filter field for it to be a valid query.
|
|
2349
2378
|
// Note that the default inequality field and key ordering is ascending.
|
|
2350
|
-
t.isKeyField() ||
|
|
2379
|
+
t.isKeyField() || e.$.push(new re(t)), e.$.push(new re(tt.keyField(), "asc" /* ASCENDING */)); else {
|
|
2351
2380
|
let t = !1;
|
|
2352
|
-
for (const
|
|
2381
|
+
for (const n of e.explicitOrderBy) e.$.push(n), n.field.isKeyField() && (t = !0);
|
|
2353
2382
|
if (!t) {
|
|
2354
2383
|
// The order of the implicit key ordering always matches the last
|
|
2355
2384
|
// explicit order by
|
|
2356
|
-
const t =
|
|
2357
|
-
|
|
2385
|
+
const t = e.explicitOrderBy.length > 0 ? e.explicitOrderBy[e.explicitOrderBy.length - 1].dir : "asc" /* ASCENDING */;
|
|
2386
|
+
e.$.push(new re(tt.keyField(), t));
|
|
2358
2387
|
}
|
|
2359
2388
|
}
|
|
2360
2389
|
}
|
|
2361
|
-
return
|
|
2390
|
+
return e.$;
|
|
2362
2391
|
}
|
|
2363
2392
|
|
|
2364
2393
|
/**
|
|
2365
2394
|
* Converts this `Query` instance to it's corresponding `Target` representation.
|
|
2366
|
-
*/ function
|
|
2367
|
-
const
|
|
2368
|
-
if (!
|
|
2395
|
+
*/ function fe(t) {
|
|
2396
|
+
const e = v(t);
|
|
2397
|
+
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 {
|
|
2369
2398
|
// Flip the orderBy directions since we want the last results
|
|
2370
2399
|
const t = [];
|
|
2371
|
-
for (const
|
|
2372
|
-
const
|
|
2373
|
-
t.push(new
|
|
2400
|
+
for (const n of le(e)) {
|
|
2401
|
+
const e = "desc" /* DESCENDING */ === n.dir ? "asc" /* ASCENDING */ : "desc" /* DESCENDING */;
|
|
2402
|
+
t.push(new re(n.field, e));
|
|
2374
2403
|
}
|
|
2375
2404
|
// We need to swap the cursors to match the now-flipped query ordering.
|
|
2376
|
-
const
|
|
2405
|
+
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;
|
|
2377
2406
|
// Now return as a LimitType.First query.
|
|
2378
|
-
|
|
2407
|
+
e.S = Qt(e.path, e.collectionGroup, t, e.filters, e.limit, n, r);
|
|
2379
2408
|
}
|
|
2380
|
-
return
|
|
2409
|
+
return e.S;
|
|
2381
2410
|
}
|
|
2382
2411
|
|
|
2383
|
-
function
|
|
2384
|
-
return function(t,
|
|
2385
|
-
if (t.limit !==
|
|
2386
|
-
if (t.orderBy.length !==
|
|
2387
|
-
for (let
|
|
2388
|
-
if (t.filters.length !==
|
|
2389
|
-
for (let s = 0; s < t.filters.length; s++) if (
|
|
2390
|
-
|
|
2391
|
-
var
|
|
2392
|
-
return t.collectionGroup ===
|
|
2393
|
-
}(
|
|
2412
|
+
function de(t, e) {
|
|
2413
|
+
return function(t, e) {
|
|
2414
|
+
if (t.limit !== e.limit) return !1;
|
|
2415
|
+
if (t.orderBy.length !== e.orderBy.length) return !1;
|
|
2416
|
+
for (let n = 0; n < t.orderBy.length; n++) if (!se(t.orderBy[n], e.orderBy[n])) return !1;
|
|
2417
|
+
if (t.filters.length !== e.filters.length) return !1;
|
|
2418
|
+
for (let s = 0; s < t.filters.length; s++) if (n = t.filters[s], r = e.filters[s],
|
|
2419
|
+
n.op !== r.op || !n.field.isEqual(r.field) || !Ft(n.value, r.value)) return !1;
|
|
2420
|
+
var n, r;
|
|
2421
|
+
return t.collectionGroup === e.collectionGroup && !!t.path.isEqual(e.path) && !!ie(t.startAt, e.startAt) && ie(t.endAt, e.endAt);
|
|
2422
|
+
}(fe(t), fe(e)) && t.limitType === e.limitType;
|
|
2394
2423
|
}
|
|
2395
2424
|
|
|
2396
2425
|
/**
|
|
@@ -2418,10 +2447,10 @@ function wn(t, n) {
|
|
|
2418
2447
|
* The return value is an IntegerValue if it can safely represent the value,
|
|
2419
2448
|
* otherwise a DoubleValue is returned.
|
|
2420
2449
|
*/
|
|
2421
|
-
function
|
|
2450
|
+
function we(t, e) {
|
|
2422
2451
|
return function(t) {
|
|
2423
2452
|
return "number" == typeof t && Number.isInteger(t) && !at(t) && t <= Number.MAX_SAFE_INTEGER && t >= Number.MIN_SAFE_INTEGER;
|
|
2424
|
-
}(
|
|
2453
|
+
}(e) ?
|
|
2425
2454
|
/**
|
|
2426
2455
|
* Returns an IntegerValue for `value`.
|
|
2427
2456
|
*/
|
|
@@ -2429,22 +2458,22 @@ function mn(t, n) {
|
|
|
2429
2458
|
return {
|
|
2430
2459
|
integerValue: "" + t
|
|
2431
2460
|
};
|
|
2432
|
-
}(
|
|
2461
|
+
}(e) : function(t, e) {
|
|
2433
2462
|
if (t.F) {
|
|
2434
|
-
if (isNaN(
|
|
2463
|
+
if (isNaN(e)) return {
|
|
2435
2464
|
doubleValue: "NaN"
|
|
2436
2465
|
};
|
|
2437
|
-
if (
|
|
2466
|
+
if (e === 1 / 0) return {
|
|
2438
2467
|
doubleValue: "Infinity"
|
|
2439
2468
|
};
|
|
2440
|
-
if (
|
|
2469
|
+
if (e === -1 / 0) return {
|
|
2441
2470
|
doubleValue: "-Infinity"
|
|
2442
2471
|
};
|
|
2443
2472
|
}
|
|
2444
2473
|
return {
|
|
2445
|
-
doubleValue: at(
|
|
2474
|
+
doubleValue: at(e) ? "-0" : e
|
|
2446
2475
|
};
|
|
2447
|
-
}(t,
|
|
2476
|
+
}(t, e);
|
|
2448
2477
|
}
|
|
2449
2478
|
|
|
2450
2479
|
/**
|
|
@@ -2463,7 +2492,7 @@ function mn(t, n) {
|
|
|
2463
2492
|
* See the License for the specific language governing permissions and
|
|
2464
2493
|
* limitations under the License.
|
|
2465
2494
|
*/
|
|
2466
|
-
/** Used to represent a field transform on a mutation. */ class
|
|
2495
|
+
/** Used to represent a field transform on a mutation. */ class me {
|
|
2467
2496
|
constructor() {
|
|
2468
2497
|
// Make sure that the structural type of `TransformOperation` is unique.
|
|
2469
2498
|
// See https://github.com/microsoft/TypeScript/issues/5451
|
|
@@ -2471,15 +2500,15 @@ function mn(t, n) {
|
|
|
2471
2500
|
}
|
|
2472
2501
|
}
|
|
2473
2502
|
|
|
2474
|
-
/** Transforms a value into a server-generated timestamp. */ class
|
|
2503
|
+
/** Transforms a value into a server-generated timestamp. */ class pe extends me {}
|
|
2475
2504
|
|
|
2476
|
-
/** Transforms an array value via a union operation. */ class
|
|
2505
|
+
/** Transforms an array value via a union operation. */ class ye extends me {
|
|
2477
2506
|
constructor(t) {
|
|
2478
2507
|
super(), this.elements = t;
|
|
2479
2508
|
}
|
|
2480
2509
|
}
|
|
2481
2510
|
|
|
2482
|
-
/** Transforms an array value via a remove operation. */ class
|
|
2511
|
+
/** Transforms an array value via a remove operation. */ class _e extends me {
|
|
2483
2512
|
constructor(t) {
|
|
2484
2513
|
super(), this.elements = t;
|
|
2485
2514
|
}
|
|
@@ -2490,9 +2519,9 @@ function mn(t, n) {
|
|
|
2490
2519
|
* transforms. Converts all field values to integers or doubles, but unlike the
|
|
2491
2520
|
* backend does not cap integer values at 2^63. Instead, JavaScript number
|
|
2492
2521
|
* arithmetic is used and precision loss can occur for values greater than 2^53.
|
|
2493
|
-
*/ class
|
|
2494
|
-
constructor(t,
|
|
2495
|
-
super(), this.q = t, this.O =
|
|
2522
|
+
*/ class ge extends me {
|
|
2523
|
+
constructor(t, e) {
|
|
2524
|
+
super(), this.q = t, this.O = e;
|
|
2496
2525
|
}
|
|
2497
2526
|
}
|
|
2498
2527
|
|
|
@@ -2512,9 +2541,9 @@ function mn(t, n) {
|
|
|
2512
2541
|
* See the License for the specific language governing permissions and
|
|
2513
2542
|
* limitations under the License.
|
|
2514
2543
|
*/
|
|
2515
|
-
/** A field path and the TransformOperation to perform upon it. */ class
|
|
2516
|
-
constructor(t,
|
|
2517
|
-
this.field = t, this.transform =
|
|
2544
|
+
/** A field path and the TransformOperation to perform upon it. */ class be {
|
|
2545
|
+
constructor(t, e) {
|
|
2546
|
+
this.field = t, this.transform = e;
|
|
2518
2547
|
}
|
|
2519
2548
|
}
|
|
2520
2549
|
|
|
@@ -2522,18 +2551,18 @@ function mn(t, n) {
|
|
|
2522
2551
|
* Encodes a precondition for a mutation. This follows the model that the
|
|
2523
2552
|
* backend accepts with the special case of an explicit "empty" precondition
|
|
2524
2553
|
* (meaning no precondition).
|
|
2525
|
-
*/ class
|
|
2526
|
-
constructor(t,
|
|
2527
|
-
this.updateTime = t, this.exists =
|
|
2554
|
+
*/ class ve {
|
|
2555
|
+
constructor(t, e) {
|
|
2556
|
+
this.updateTime = t, this.exists = e;
|
|
2528
2557
|
}
|
|
2529
2558
|
/** Creates a new empty Precondition. */ static none() {
|
|
2530
|
-
return new
|
|
2559
|
+
return new ve;
|
|
2531
2560
|
}
|
|
2532
2561
|
/** Creates a new Precondition with an exists flag. */ static exists(t) {
|
|
2533
|
-
return new
|
|
2562
|
+
return new ve(void 0, t);
|
|
2534
2563
|
}
|
|
2535
2564
|
/** Creates a new Precondition based on a version a document exists at. */ static updateTime(t) {
|
|
2536
|
-
return new
|
|
2565
|
+
return new ve(t);
|
|
2537
2566
|
}
|
|
2538
2567
|
/** Returns whether this Precondition is empty. */ get isNone() {
|
|
2539
2568
|
return void 0 === this.updateTime && void 0 === this.exists;
|
|
@@ -2586,14 +2615,14 @@ function mn(t, n) {
|
|
|
2586
2615
|
* applyToLocalView() to implement the actual behavior of applying the mutation
|
|
2587
2616
|
* to some source document (see `setMutationApplyToRemoteDocument()` for an
|
|
2588
2617
|
* example).
|
|
2589
|
-
*/ class
|
|
2618
|
+
*/ class Ee {}
|
|
2590
2619
|
|
|
2591
2620
|
/**
|
|
2592
2621
|
* A mutation that creates or replaces the document at the given key with the
|
|
2593
2622
|
* object value contents.
|
|
2594
|
-
*/ class
|
|
2595
|
-
constructor(t,
|
|
2596
|
-
super(), this.key = t, this.value =
|
|
2623
|
+
*/ class Te extends Ee {
|
|
2624
|
+
constructor(t, e, n, r = []) {
|
|
2625
|
+
super(), this.key = t, this.value = e, this.precondition = n, this.fieldTransforms = r,
|
|
2597
2626
|
this.type = 0 /* Set */;
|
|
2598
2627
|
}
|
|
2599
2628
|
}
|
|
@@ -2610,16 +2639,16 @@ function mn(t, n) {
|
|
|
2610
2639
|
* is deleted.
|
|
2611
2640
|
* * When a field is not in the mask but is in the values, the values map is
|
|
2612
2641
|
* ignored.
|
|
2613
|
-
*/ class
|
|
2614
|
-
constructor(t,
|
|
2615
|
-
super(), this.key = t, this.data =
|
|
2642
|
+
*/ class Ie extends Ee {
|
|
2643
|
+
constructor(t, e, n, r, s = []) {
|
|
2644
|
+
super(), this.key = t, this.data = e, this.fieldMask = n, this.precondition = r,
|
|
2616
2645
|
this.fieldTransforms = s, this.type = 1 /* Patch */;
|
|
2617
2646
|
}
|
|
2618
2647
|
}
|
|
2619
2648
|
|
|
2620
|
-
/** A mutation that deletes the document at the given key. */ class
|
|
2621
|
-
constructor(t,
|
|
2622
|
-
super(), this.key = t, this.precondition =
|
|
2649
|
+
/** A mutation that deletes the document at the given key. */ class Ae extends Ee {
|
|
2650
|
+
constructor(t, e) {
|
|
2651
|
+
super(), this.key = t, this.precondition = e, this.type = 2 /* Delete */ , this.fieldTransforms = [];
|
|
2623
2652
|
}
|
|
2624
2653
|
}
|
|
2625
2654
|
|
|
@@ -2629,9 +2658,9 @@ function mn(t, n) {
|
|
|
2629
2658
|
*
|
|
2630
2659
|
* The `verify` operation is only used in Transactions, and this class serves
|
|
2631
2660
|
* primarily to facilitate serialization into protos.
|
|
2632
|
-
*/ class
|
|
2633
|
-
constructor(t,
|
|
2634
|
-
super(), this.key = t, this.precondition =
|
|
2661
|
+
*/ class Re extends Ee {
|
|
2662
|
+
constructor(t, e) {
|
|
2663
|
+
super(), this.key = t, this.precondition = e, this.type = 3 /* Verify */ , this.fieldTransforms = [];
|
|
2635
2664
|
}
|
|
2636
2665
|
}
|
|
2637
2666
|
|
|
@@ -2650,13 +2679,13 @@ function mn(t, n) {
|
|
|
2650
2679
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2651
2680
|
* See the License for the specific language governing permissions and
|
|
2652
2681
|
* limitations under the License.
|
|
2653
|
-
*/ const
|
|
2682
|
+
*/ const Pe = (() => {
|
|
2654
2683
|
const t = {
|
|
2655
2684
|
asc: "ASCENDING",
|
|
2656
2685
|
desc: "DESCENDING"
|
|
2657
2686
|
};
|
|
2658
2687
|
return t;
|
|
2659
|
-
})(),
|
|
2688
|
+
})(), Ve = (() => {
|
|
2660
2689
|
const t = {
|
|
2661
2690
|
"<": "LESS_THAN",
|
|
2662
2691
|
"<=": "LESS_THAN_OR_EQUAL",
|
|
@@ -2686,9 +2715,9 @@ function mn(t, n) {
|
|
|
2686
2715
|
* TODO(klimt): We can remove the databaseId argument if we keep the full
|
|
2687
2716
|
* resource name in documents.
|
|
2688
2717
|
*/
|
|
2689
|
-
class
|
|
2690
|
-
constructor(t,
|
|
2691
|
-
this.databaseId = t, this.F =
|
|
2718
|
+
class De {
|
|
2719
|
+
constructor(t, e) {
|
|
2720
|
+
this.databaseId = t, this.F = e;
|
|
2692
2721
|
}
|
|
2693
2722
|
}
|
|
2694
2723
|
|
|
@@ -2703,13 +2732,13 @@ class Nn {
|
|
|
2703
2732
|
/**
|
|
2704
2733
|
* Returns a value for a Date that's appropriate to put into a proto.
|
|
2705
2734
|
*/
|
|
2706
|
-
function
|
|
2735
|
+
function Ne(t, e) {
|
|
2707
2736
|
if (t.F) {
|
|
2708
|
-
return `${new Date(1e3 *
|
|
2737
|
+
return `${new Date(1e3 * e.seconds).toISOString().replace(/\.\d*/, "").replace("Z", "")}.${("000000000" + e.nanoseconds).slice(-9)}Z`;
|
|
2709
2738
|
}
|
|
2710
2739
|
return {
|
|
2711
|
-
seconds: "" +
|
|
2712
|
-
nanos:
|
|
2740
|
+
seconds: "" + e.seconds,
|
|
2741
|
+
nanos: e.nanoseconds
|
|
2713
2742
|
};
|
|
2714
2743
|
}
|
|
2715
2744
|
|
|
@@ -2718,232 +2747,234 @@ function $n(t, n) {
|
|
|
2718
2747
|
*
|
|
2719
2748
|
* Visible for testing.
|
|
2720
2749
|
*/
|
|
2721
|
-
function
|
|
2722
|
-
return t.F ?
|
|
2750
|
+
function $e(t, e) {
|
|
2751
|
+
return t.F ? e.toBase64() : e.toUint8Array();
|
|
2723
2752
|
}
|
|
2724
2753
|
|
|
2725
|
-
function
|
|
2726
|
-
return
|
|
2754
|
+
function Se(t, e) {
|
|
2755
|
+
return Ne(t, e.toTimestamp());
|
|
2727
2756
|
}
|
|
2728
2757
|
|
|
2729
|
-
function
|
|
2730
|
-
return
|
|
2731
|
-
const
|
|
2732
|
-
return new gt(
|
|
2758
|
+
function Fe(t) {
|
|
2759
|
+
return b(!!t), bt.fromTimestamp(function(t) {
|
|
2760
|
+
const e = Rt(t);
|
|
2761
|
+
return new gt(e.seconds, e.nanos);
|
|
2733
2762
|
}(t));
|
|
2734
2763
|
}
|
|
2735
2764
|
|
|
2736
|
-
function
|
|
2765
|
+
function xe(t, e) {
|
|
2737
2766
|
return function(t) {
|
|
2738
2767
|
return new X([ "projects", t.projectId, "databases", t.database ]);
|
|
2739
|
-
}(t).child("documents").child(
|
|
2768
|
+
}(t).child("documents").child(e).canonicalString();
|
|
2740
2769
|
}
|
|
2741
2770
|
|
|
2742
|
-
function
|
|
2743
|
-
return
|
|
2771
|
+
function qe(t, e) {
|
|
2772
|
+
return xe(t.databaseId, e.path);
|
|
2744
2773
|
}
|
|
2745
2774
|
|
|
2746
|
-
function
|
|
2747
|
-
const
|
|
2748
|
-
const
|
|
2749
|
-
return
|
|
2750
|
-
}(
|
|
2751
|
-
if (
|
|
2752
|
-
if (
|
|
2753
|
-
return new
|
|
2775
|
+
function Oe(t, e) {
|
|
2776
|
+
const n = function(t) {
|
|
2777
|
+
const e = X.fromString(t);
|
|
2778
|
+
return b(We(e)), e;
|
|
2779
|
+
}(e);
|
|
2780
|
+
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);
|
|
2781
|
+
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);
|
|
2782
|
+
return new et((b((r = n).length > 4 && "documents" === r.get(4)), r.popFirst(5)));
|
|
2754
2783
|
var r;
|
|
2755
2784
|
/** Creates a Document proto from key and fields (but no create/update time) */}
|
|
2756
2785
|
|
|
2757
|
-
function
|
|
2758
|
-
return
|
|
2786
|
+
function Ce(t, e) {
|
|
2787
|
+
return xe(t.databaseId, e);
|
|
2759
2788
|
}
|
|
2760
2789
|
|
|
2761
|
-
function
|
|
2790
|
+
function Le(t) {
|
|
2762
2791
|
return new X([ "projects", t.databaseId.projectId, "databases", t.databaseId.database ]).canonicalString();
|
|
2763
2792
|
}
|
|
2764
2793
|
|
|
2765
|
-
function
|
|
2794
|
+
function Ue(t, e, n) {
|
|
2766
2795
|
return {
|
|
2767
|
-
name:
|
|
2768
|
-
fields:
|
|
2796
|
+
name: qe(t, e),
|
|
2797
|
+
fields: n.value.mapValue.fields
|
|
2769
2798
|
};
|
|
2770
2799
|
}
|
|
2771
2800
|
|
|
2772
|
-
function
|
|
2773
|
-
return "found" in
|
|
2774
|
-
|
|
2775
|
-
const
|
|
2801
|
+
function ke(t, e) {
|
|
2802
|
+
return "found" in e ? function(t, e) {
|
|
2803
|
+
b(!!e.found), e.found.name, e.found.updateTime;
|
|
2804
|
+
const n = Oe(t, e.found.name), r = Fe(e.found.updateTime), s = new Bt({
|
|
2776
2805
|
mapValue: {
|
|
2777
|
-
fields:
|
|
2806
|
+
fields: e.found.fields
|
|
2778
2807
|
}
|
|
2779
2808
|
});
|
|
2780
|
-
return zt.newFoundDocument(
|
|
2781
|
-
}(t,
|
|
2782
|
-
|
|
2783
|
-
const
|
|
2784
|
-
return zt.newNoDocument(
|
|
2785
|
-
}(t,
|
|
2786
|
-
}
|
|
2787
|
-
|
|
2788
|
-
function
|
|
2789
|
-
let
|
|
2790
|
-
if (
|
|
2791
|
-
update:
|
|
2792
|
-
}; else if (
|
|
2793
|
-
delete:
|
|
2794
|
-
}; else if (
|
|
2795
|
-
update:
|
|
2796
|
-
updateMask:
|
|
2809
|
+
return zt.newFoundDocument(n, r, s);
|
|
2810
|
+
}(t, e) : "missing" in e ? function(t, e) {
|
|
2811
|
+
b(!!e.missing), b(!!e.readTime);
|
|
2812
|
+
const n = Oe(t, e.missing), r = Fe(e.readTime);
|
|
2813
|
+
return zt.newNoDocument(n, r);
|
|
2814
|
+
}(t, e) : g();
|
|
2815
|
+
}
|
|
2816
|
+
|
|
2817
|
+
function je(t, e) {
|
|
2818
|
+
let n;
|
|
2819
|
+
if (e instanceof Te) n = {
|
|
2820
|
+
update: Ue(t, e.key, e.value)
|
|
2821
|
+
}; else if (e instanceof Ae) n = {
|
|
2822
|
+
delete: qe(t, e.key)
|
|
2823
|
+
}; else if (e instanceof Ie) n = {
|
|
2824
|
+
update: Ue(t, e.key, e.data),
|
|
2825
|
+
updateMask: Qe(e.fieldMask)
|
|
2797
2826
|
}; else {
|
|
2798
|
-
if (!(
|
|
2799
|
-
|
|
2800
|
-
verify:
|
|
2827
|
+
if (!(e instanceof Re)) return g();
|
|
2828
|
+
n = {
|
|
2829
|
+
verify: qe(t, e.key)
|
|
2801
2830
|
};
|
|
2802
2831
|
}
|
|
2803
|
-
return
|
|
2804
|
-
const
|
|
2805
|
-
if (
|
|
2806
|
-
fieldPath:
|
|
2832
|
+
return e.fieldTransforms.length > 0 && (n.updateTransforms = e.fieldTransforms.map((t => function(t, e) {
|
|
2833
|
+
const n = e.transform;
|
|
2834
|
+
if (n instanceof pe) return {
|
|
2835
|
+
fieldPath: e.field.canonicalString(),
|
|
2807
2836
|
setToServerValue: "REQUEST_TIME"
|
|
2808
2837
|
};
|
|
2809
|
-
if (
|
|
2810
|
-
fieldPath:
|
|
2838
|
+
if (n instanceof ye) return {
|
|
2839
|
+
fieldPath: e.field.canonicalString(),
|
|
2811
2840
|
appendMissingElements: {
|
|
2812
|
-
values:
|
|
2841
|
+
values: n.elements
|
|
2813
2842
|
}
|
|
2814
2843
|
};
|
|
2815
|
-
if (
|
|
2816
|
-
fieldPath:
|
|
2844
|
+
if (n instanceof _e) return {
|
|
2845
|
+
fieldPath: e.field.canonicalString(),
|
|
2817
2846
|
removeAllFromArray: {
|
|
2818
|
-
values:
|
|
2847
|
+
values: n.elements
|
|
2819
2848
|
}
|
|
2820
2849
|
};
|
|
2821
|
-
if (
|
|
2822
|
-
fieldPath:
|
|
2823
|
-
increment:
|
|
2850
|
+
if (n instanceof ge) return {
|
|
2851
|
+
fieldPath: e.field.canonicalString(),
|
|
2852
|
+
increment: n.O
|
|
2824
2853
|
};
|
|
2825
2854
|
throw g();
|
|
2826
|
-
}(0, t)))),
|
|
2827
|
-
return void 0 !==
|
|
2828
|
-
updateTime:
|
|
2829
|
-
} : void 0 !==
|
|
2830
|
-
exists:
|
|
2855
|
+
}(0, t)))), e.precondition.isNone || (n.currentDocument = function(t, e) {
|
|
2856
|
+
return void 0 !== e.updateTime ? {
|
|
2857
|
+
updateTime: Se(t, e.updateTime)
|
|
2858
|
+
} : void 0 !== e.exists ? {
|
|
2859
|
+
exists: e.exists
|
|
2831
2860
|
} : g();
|
|
2832
|
-
}(t,
|
|
2861
|
+
}(t, e.precondition)), n;
|
|
2833
2862
|
}
|
|
2834
2863
|
|
|
2835
|
-
function
|
|
2864
|
+
function Me(t, e) {
|
|
2836
2865
|
// Dissect the path into parent, collectionId, and optional key filter.
|
|
2837
|
-
const
|
|
2866
|
+
const n = {
|
|
2838
2867
|
structuredQuery: {}
|
|
2839
|
-
}, r =
|
|
2840
|
-
null !==
|
|
2841
|
-
collectionId:
|
|
2868
|
+
}, r = e.path;
|
|
2869
|
+
null !== e.collectionGroup ? (n.parent = Ce(t, r), n.structuredQuery.from = [ {
|
|
2870
|
+
collectionId: e.collectionGroup,
|
|
2842
2871
|
allDescendants: !0
|
|
2843
|
-
} ]) : (
|
|
2872
|
+
} ]) : (n.parent = Ce(t, r.popLast()), n.structuredQuery.from = [ {
|
|
2844
2873
|
collectionId: r.lastSegment()
|
|
2845
2874
|
} ]);
|
|
2846
2875
|
const s = function(t) {
|
|
2847
2876
|
if (0 === t.length) return;
|
|
2848
|
-
const
|
|
2877
|
+
const e = t.map((t =>
|
|
2849
2878
|
// visible for testing
|
|
2850
2879
|
function(t) {
|
|
2851
2880
|
if ("==" /* EQUAL */ === t.op) {
|
|
2852
2881
|
if (kt(t.value)) return {
|
|
2853
2882
|
unaryFilter: {
|
|
2854
|
-
field:
|
|
2883
|
+
field: Ge(t.field),
|
|
2855
2884
|
op: "IS_NAN"
|
|
2856
2885
|
}
|
|
2857
2886
|
};
|
|
2858
2887
|
if (Ut(t.value)) return {
|
|
2859
2888
|
unaryFilter: {
|
|
2860
|
-
field:
|
|
2889
|
+
field: Ge(t.field),
|
|
2861
2890
|
op: "IS_NULL"
|
|
2862
2891
|
}
|
|
2863
2892
|
};
|
|
2864
2893
|
} else if ("!=" /* NOT_EQUAL */ === t.op) {
|
|
2865
2894
|
if (kt(t.value)) return {
|
|
2866
2895
|
unaryFilter: {
|
|
2867
|
-
field:
|
|
2896
|
+
field: Ge(t.field),
|
|
2868
2897
|
op: "IS_NOT_NAN"
|
|
2869
2898
|
}
|
|
2870
2899
|
};
|
|
2871
2900
|
if (Ut(t.value)) return {
|
|
2872
2901
|
unaryFilter: {
|
|
2873
|
-
field:
|
|
2902
|
+
field: Ge(t.field),
|
|
2874
2903
|
op: "IS_NOT_NULL"
|
|
2875
2904
|
}
|
|
2876
2905
|
};
|
|
2877
2906
|
}
|
|
2878
2907
|
return {
|
|
2879
2908
|
fieldFilter: {
|
|
2880
|
-
field:
|
|
2881
|
-
op:
|
|
2909
|
+
field: Ge(t.field),
|
|
2910
|
+
op: ze(t.op),
|
|
2882
2911
|
value: t.value
|
|
2883
2912
|
}
|
|
2884
2913
|
};
|
|
2885
2914
|
}(t)));
|
|
2886
|
-
if (1 ===
|
|
2915
|
+
if (1 === e.length) return e[0];
|
|
2887
2916
|
return {
|
|
2888
2917
|
compositeFilter: {
|
|
2889
2918
|
op: "AND",
|
|
2890
|
-
filters:
|
|
2919
|
+
filters: e
|
|
2891
2920
|
}
|
|
2892
2921
|
};
|
|
2893
|
-
}(
|
|
2894
|
-
s && (
|
|
2922
|
+
}(e.filters);
|
|
2923
|
+
s && (n.structuredQuery.where = s);
|
|
2895
2924
|
const i = function(t) {
|
|
2896
2925
|
if (0 === t.length) return;
|
|
2897
2926
|
return t.map((t =>
|
|
2898
2927
|
// visible for testing
|
|
2899
2928
|
function(t) {
|
|
2900
2929
|
return {
|
|
2901
|
-
field:
|
|
2902
|
-
direction:
|
|
2930
|
+
field: Ge(t.field),
|
|
2931
|
+
direction: Be(t.dir)
|
|
2903
2932
|
};
|
|
2904
2933
|
}(t)));
|
|
2905
|
-
}(
|
|
2906
|
-
i && (
|
|
2907
|
-
const o = function(t,
|
|
2908
|
-
return t.F || ct(
|
|
2909
|
-
value:
|
|
2934
|
+
}(e.orderBy);
|
|
2935
|
+
i && (n.structuredQuery.orderBy = i);
|
|
2936
|
+
const o = function(t, e) {
|
|
2937
|
+
return t.F || ct(e) ? e : {
|
|
2938
|
+
value: e
|
|
2910
2939
|
};
|
|
2911
|
-
}(t,
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2940
|
+
}(t, e.limit);
|
|
2941
|
+
var u;
|
|
2942
|
+
return null !== o && (n.structuredQuery.limit = o), e.startAt && (n.structuredQuery.startAt = {
|
|
2943
|
+
before: (u = e.startAt).inclusive,
|
|
2944
|
+
values: u.position
|
|
2945
|
+
}), e.endAt && (n.structuredQuery.endAt = function(t) {
|
|
2946
|
+
return {
|
|
2947
|
+
before: !t.inclusive,
|
|
2948
|
+
values: t.position
|
|
2949
|
+
};
|
|
2950
|
+
}
|
|
2951
|
+
// visible for testing
|
|
2952
|
+
(e.endAt)), n;
|
|
2921
2953
|
}
|
|
2922
2954
|
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
return Vn[t];
|
|
2955
|
+
function Be(t) {
|
|
2956
|
+
return Pe[t];
|
|
2926
2957
|
}
|
|
2927
2958
|
|
|
2928
2959
|
// visible for testing
|
|
2929
|
-
function
|
|
2930
|
-
return
|
|
2960
|
+
function ze(t) {
|
|
2961
|
+
return Ve[t];
|
|
2931
2962
|
}
|
|
2932
2963
|
|
|
2933
|
-
function
|
|
2964
|
+
function Ge(t) {
|
|
2934
2965
|
return {
|
|
2935
2966
|
fieldPath: t.canonicalString()
|
|
2936
2967
|
};
|
|
2937
2968
|
}
|
|
2938
2969
|
|
|
2939
|
-
function
|
|
2940
|
-
const
|
|
2941
|
-
return t.fields.forEach((t =>
|
|
2942
|
-
fieldPaths:
|
|
2970
|
+
function Qe(t) {
|
|
2971
|
+
const e = [];
|
|
2972
|
+
return t.fields.forEach((t => e.push(t.canonicalString()))), {
|
|
2973
|
+
fieldPaths: e
|
|
2943
2974
|
};
|
|
2944
2975
|
}
|
|
2945
2976
|
|
|
2946
|
-
function
|
|
2977
|
+
function We(t) {
|
|
2947
2978
|
// Resource names have at least 4 components (project ID, database ID)
|
|
2948
2979
|
return t.length >= 4 && "projects" === t.get(0) && "databases" === t.get(2);
|
|
2949
2980
|
}
|
|
@@ -2963,8 +2994,8 @@ function Hn(t) {
|
|
|
2963
2994
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2964
2995
|
* See the License for the specific language governing permissions and
|
|
2965
2996
|
* limitations under the License.
|
|
2966
|
-
*/ function
|
|
2967
|
-
return new
|
|
2997
|
+
*/ function Ye(t) {
|
|
2998
|
+
return new De(t, /* useProto3Json= */ !0);
|
|
2968
2999
|
}
|
|
2969
3000
|
|
|
2970
3001
|
/**
|
|
@@ -2992,7 +3023,7 @@ function Hn(t) {
|
|
|
2992
3023
|
* base delay. This prevents clients from accidentally synchronizing their
|
|
2993
3024
|
* delays causing spikes of load to the backend.
|
|
2994
3025
|
*/
|
|
2995
|
-
class
|
|
3026
|
+
class He {
|
|
2996
3027
|
constructor(
|
|
2997
3028
|
/**
|
|
2998
3029
|
* The AsyncQueue to run backoff operations on.
|
|
@@ -3001,13 +3032,13 @@ class Jn {
|
|
|
3001
3032
|
/**
|
|
3002
3033
|
* The ID to use when scheduling backoff operations on the AsyncQueue.
|
|
3003
3034
|
*/
|
|
3004
|
-
|
|
3035
|
+
e,
|
|
3005
3036
|
/**
|
|
3006
3037
|
* The initial delay (used as the base delay on the first retry attempt).
|
|
3007
3038
|
* Note that jitter will still be applied, so the actual delay could be as
|
|
3008
3039
|
* little as 0.5*initialDelayMs.
|
|
3009
3040
|
*/
|
|
3010
|
-
|
|
3041
|
+
n = 1e3
|
|
3011
3042
|
/**
|
|
3012
3043
|
* The multiplier to use to determine the extended base delay after each
|
|
3013
3044
|
* attempt.
|
|
@@ -3017,7 +3048,7 @@ class Jn {
|
|
|
3017
3048
|
* Note that jitter will still be applied, so the actual delay could be as
|
|
3018
3049
|
* much as 1.5*maxDelayMs.
|
|
3019
3050
|
*/ , s = 6e4) {
|
|
3020
|
-
this.C = t, this.timerId =
|
|
3051
|
+
this.C = t, this.timerId = e, this.L = n, this.U = r, this.k = s, this.j = 0, this.M = null,
|
|
3021
3052
|
/** The last backoff attempt, as epoch milliseconds. */
|
|
3022
3053
|
this.B = Date.now(), this.reset();
|
|
3023
3054
|
}
|
|
@@ -3045,9 +3076,9 @@ class Jn {
|
|
|
3045
3076
|
this.cancel();
|
|
3046
3077
|
// First schedule using the current base (which may be 0 and should be
|
|
3047
3078
|
// honored as such).
|
|
3048
|
-
const
|
|
3079
|
+
const e = Math.floor(this.j + this.Y()), n = Math.max(0, Date.now() - this.B), r = Math.max(0, e - n);
|
|
3049
3080
|
// Guard against lastAttemptTime being in the future due to a clock change.
|
|
3050
|
-
r > 0 && m("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.j} ms, delay with jitter: ${
|
|
3081
|
+
r > 0 && m("ExponentialBackoff", `Backing off for ${r} ms (base delay: ${this.j} ms, delay with jitter: ${e} ms, last attempt: ${n} ms ago)`),
|
|
3051
3082
|
this.M = this.C.enqueueAfterDelay(this.timerId, r, (() => (this.B = Date.now(),
|
|
3052
3083
|
t()))),
|
|
3053
3084
|
// Apply backoff factor to determine next delay and ensure it is within
|
|
@@ -3090,22 +3121,22 @@ class Jn {
|
|
|
3090
3121
|
* An implementation of Datastore that exposes additional state for internal
|
|
3091
3122
|
* consumption.
|
|
3092
3123
|
*/
|
|
3093
|
-
class
|
|
3094
|
-
constructor(t,
|
|
3095
|
-
super(), this.authCredentials = t, this.appCheckCredentials =
|
|
3124
|
+
class Ke extends class {} {
|
|
3125
|
+
constructor(t, e, n, r) {
|
|
3126
|
+
super(), this.authCredentials = t, this.appCheckCredentials = e, this.K = n, this.q = r,
|
|
3096
3127
|
this.J = !1;
|
|
3097
3128
|
}
|
|
3098
3129
|
X() {
|
|
3099
3130
|
if (this.J) throw new U(S, "The client has already been terminated.");
|
|
3100
3131
|
}
|
|
3101
|
-
/** Invokes the provided RPC with auth and AppCheck tokens. */ m(t,
|
|
3102
|
-
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.m(t,
|
|
3132
|
+
/** Invokes the provided RPC with auth and AppCheck tokens. */ m(t, e, n) {
|
|
3133
|
+
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.m(t, e, n, r, s))).catch((t => {
|
|
3103
3134
|
throw "FirebaseError" === t.name ? (t.code === N && (this.authCredentials.invalidateToken(),
|
|
3104
3135
|
this.appCheckCredentials.invalidateToken()), t) : new U(I, t.toString());
|
|
3105
3136
|
}));
|
|
3106
3137
|
}
|
|
3107
|
-
/** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */ T(t,
|
|
3108
|
-
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.T(t,
|
|
3138
|
+
/** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */ T(t, e, n) {
|
|
3139
|
+
return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([r, s]) => this.K.T(t, e, n, r, s))).catch((t => {
|
|
3109
3140
|
throw "FirebaseError" === t.name ? (t.code === N && (this.authCredentials.invalidateToken(),
|
|
3110
3141
|
this.appCheckCredentials.invalidateToken()), t) : new U(I, t.toString());
|
|
3111
3142
|
}));
|
|
@@ -3117,40 +3148,40 @@ class Xn extends class {} {
|
|
|
3117
3148
|
|
|
3118
3149
|
// TODO(firestorexp): Make sure there is only one Datastore instance per
|
|
3119
3150
|
// firestore-exp client.
|
|
3120
|
-
async function
|
|
3121
|
-
const
|
|
3122
|
-
writes:
|
|
3151
|
+
async function Je(t, e) {
|
|
3152
|
+
const n = v(t), r = Le(n.q) + "/documents", s = {
|
|
3153
|
+
writes: e.map((t => je(n.q, t)))
|
|
3123
3154
|
};
|
|
3124
|
-
await
|
|
3155
|
+
await n.m("Commit", r, s);
|
|
3125
3156
|
}
|
|
3126
3157
|
|
|
3127
|
-
async function
|
|
3128
|
-
const
|
|
3129
|
-
documents:
|
|
3130
|
-
}, i = await
|
|
3158
|
+
async function Xe(t, e) {
|
|
3159
|
+
const n = v(t), r = Le(n.q) + "/documents", s = {
|
|
3160
|
+
documents: e.map((t => qe(n.q, t)))
|
|
3161
|
+
}, i = await n.T("BatchGetDocuments", r, s), o = new Map;
|
|
3131
3162
|
i.forEach((t => {
|
|
3132
|
-
const
|
|
3133
|
-
o.set(
|
|
3163
|
+
const e = ke(n.q, t);
|
|
3164
|
+
o.set(e.key.toString(), e);
|
|
3134
3165
|
}));
|
|
3135
3166
|
const u = [];
|
|
3136
|
-
return
|
|
3137
|
-
const
|
|
3138
|
-
|
|
3167
|
+
return e.forEach((t => {
|
|
3168
|
+
const e = o.get(t.toString());
|
|
3169
|
+
b(!!e), u.push(e);
|
|
3139
3170
|
})), u;
|
|
3140
3171
|
}
|
|
3141
3172
|
|
|
3142
|
-
async function
|
|
3143
|
-
const
|
|
3144
|
-
return (await
|
|
3173
|
+
async function Ze(t, e) {
|
|
3174
|
+
const n = v(t), r = Me(n.q, fe(e));
|
|
3175
|
+
return (await n.T("RunQuery", r.parent, {
|
|
3145
3176
|
structuredQuery: r.structuredQuery
|
|
3146
|
-
})).filter((t => !!t.document)).map((t => function(t,
|
|
3147
|
-
const r =
|
|
3177
|
+
})).filter((t => !!t.document)).map((t => function(t, e, n) {
|
|
3178
|
+
const r = Oe(t, e.name), s = Fe(e.updateTime), i = new Bt({
|
|
3148
3179
|
mapValue: {
|
|
3149
|
-
fields:
|
|
3180
|
+
fields: e.fields
|
|
3150
3181
|
}
|
|
3151
3182
|
}), o = zt.newFoundDocument(r, s, i);
|
|
3152
|
-
return
|
|
3153
|
-
}(
|
|
3183
|
+
return n && o.setHasCommittedMutations(), n ? o.setHasCommittedMutations() : o;
|
|
3184
|
+
}(n.q, t.document, void 0)));
|
|
3154
3185
|
}
|
|
3155
3186
|
|
|
3156
3187
|
/**
|
|
@@ -3168,7 +3199,7 @@ async function ne(t, n) {
|
|
|
3168
3199
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3169
3200
|
* See the License for the specific language governing permissions and
|
|
3170
3201
|
* limitations under the License.
|
|
3171
|
-
*/ const
|
|
3202
|
+
*/ const tn = new Map;
|
|
3172
3203
|
|
|
3173
3204
|
/**
|
|
3174
3205
|
* An instance map that ensures only one Datastore exists per Firestore
|
|
@@ -3179,19 +3210,19 @@ async function ne(t, n) {
|
|
|
3179
3210
|
* instance. Callers must invoke removeComponents() when the Firestore
|
|
3180
3211
|
* instance is terminated.
|
|
3181
3212
|
*/
|
|
3182
|
-
function
|
|
3213
|
+
function en(t) {
|
|
3183
3214
|
if (t._terminated) throw new U(S, "The client has already been terminated.");
|
|
3184
|
-
if (!
|
|
3215
|
+
if (!tn.has(t)) {
|
|
3185
3216
|
m("ComponentProvider", "Initializing Datastore");
|
|
3186
3217
|
const i = function(t) {
|
|
3187
3218
|
return new wt(t, fetch.bind(null));
|
|
3188
|
-
}((
|
|
3189
|
-
new H(
|
|
3190
|
-
return new
|
|
3219
|
+
}((e = t._databaseId, n = t.app.options.appId || "", r = t._persistenceKey, s = t._freezeSettings(),
|
|
3220
|
+
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) {
|
|
3221
|
+
return new Ke(t, e, n, r);
|
|
3191
3222
|
}(t._authCredentials, t._appCheckCredentials, i, o);
|
|
3192
|
-
|
|
3223
|
+
tn.set(t, u);
|
|
3193
3224
|
}
|
|
3194
|
-
var
|
|
3225
|
+
var e, n, r, s;
|
|
3195
3226
|
/**
|
|
3196
3227
|
* @license
|
|
3197
3228
|
* Copyright 2018 Google LLC
|
|
@@ -3207,7 +3238,7 @@ function re(t) {
|
|
|
3207
3238
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3208
3239
|
* See the License for the specific language governing permissions and
|
|
3209
3240
|
* limitations under the License.
|
|
3210
|
-
*/ return
|
|
3241
|
+
*/ return tn.get(t);
|
|
3211
3242
|
}
|
|
3212
3243
|
|
|
3213
3244
|
/**
|
|
@@ -3219,21 +3250,21 @@ function re(t) {
|
|
|
3219
3250
|
* user-supplied `FirestoreSettings` object. This is a separate type so that
|
|
3220
3251
|
* defaults can be supplied and the value can be checked for equality.
|
|
3221
3252
|
*/
|
|
3222
|
-
class
|
|
3253
|
+
class nn {
|
|
3223
3254
|
constructor(t) {
|
|
3224
|
-
var
|
|
3255
|
+
var e;
|
|
3225
3256
|
if (void 0 === t.host) {
|
|
3226
3257
|
if (void 0 !== t.ssl) throw new U(A, "Can't provide ssl option if host option is not set");
|
|
3227
3258
|
this.host = "firestore.googleapis.com", this.ssl = true;
|
|
3228
|
-
} else this.host = t.host, this.ssl = null === (
|
|
3259
|
+
} else this.host = t.host, this.ssl = null === (e = t.ssl) || void 0 === e || e;
|
|
3229
3260
|
if (this.credentials = t.credentials, this.ignoreUndefinedProperties = !!t.ignoreUndefinedProperties,
|
|
3230
3261
|
void 0 === t.cacheSizeBytes) this.cacheSizeBytes = 41943040; else {
|
|
3231
3262
|
if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new U(A, "cacheSizeBytes must be at least 1048576");
|
|
3232
3263
|
this.cacheSizeBytes = t.cacheSizeBytes;
|
|
3233
3264
|
}
|
|
3234
3265
|
this.experimentalForceLongPolling = !!t.experimentalForceLongPolling, this.experimentalAutoDetectLongPolling = !!t.experimentalAutoDetectLongPolling,
|
|
3235
|
-
this.useFetchStreams = !!t.useFetchStreams, function(t,
|
|
3236
|
-
if (!0 ===
|
|
3266
|
+
this.useFetchStreams = !!t.useFetchStreams, function(t, e, n, r) {
|
|
3267
|
+
if (!0 === e && !0 === r) throw new U(A, `${t} and ${n} cannot be used together.`);
|
|
3237
3268
|
}("experimentalForceLongPolling", t.experimentalForceLongPolling, "experimentalAutoDetectLongPolling", t.experimentalAutoDetectLongPolling);
|
|
3238
3269
|
}
|
|
3239
3270
|
isEqual(t) {
|
|
@@ -3261,14 +3292,14 @@ class se {
|
|
|
3261
3292
|
* The Cloud Firestore service interface.
|
|
3262
3293
|
*
|
|
3263
3294
|
* Do not call this constructor directly. Instead, use {@link getFirestore}.
|
|
3264
|
-
*/ class
|
|
3295
|
+
*/ class rn {
|
|
3265
3296
|
/** @hideconstructor */
|
|
3266
|
-
constructor(t,
|
|
3267
|
-
this._authCredentials =
|
|
3297
|
+
constructor(t, e, n) {
|
|
3298
|
+
this._authCredentials = e, this._appCheckCredentials = n,
|
|
3268
3299
|
/**
|
|
3269
3300
|
* Whether it's a Firestore or Firestore Lite instance.
|
|
3270
3301
|
*/
|
|
3271
|
-
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new
|
|
3302
|
+
this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new nn({}),
|
|
3272
3303
|
this._settingsFrozen = !1, t instanceof K ? this._databaseId = t : (this._app = t,
|
|
3273
3304
|
this._databaseId = function(t) {
|
|
3274
3305
|
if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new U(A, '"projectId" not provided in firebase.initializeApp.');
|
|
@@ -3301,14 +3332,14 @@ class se {
|
|
|
3301
3332
|
}
|
|
3302
3333
|
_setSettings(t) {
|
|
3303
3334
|
if (this._settingsFrozen) throw new U(S, "Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");
|
|
3304
|
-
this._settings = new
|
|
3335
|
+
this._settings = new nn(t), void 0 !== t.credentials && (this._authCredentials = function(t) {
|
|
3305
3336
|
if (!t) return new M;
|
|
3306
3337
|
switch (t.type) {
|
|
3307
3338
|
case "gapi":
|
|
3308
|
-
const
|
|
3339
|
+
const e = t.client;
|
|
3309
3340
|
// Make sure this really is a Gapi client.
|
|
3310
|
-
return
|
|
3311
|
-
new Q(
|
|
3341
|
+
return b(!("object" != typeof e || null === e || !e.auth || !e.auth.getAuthHeaderValueForFirstParty)),
|
|
3342
|
+
new Q(e, t.sessionIndex || "0", t.iamToken || null);
|
|
3312
3343
|
|
|
3313
3344
|
case "provider":
|
|
3314
3345
|
return t.client;
|
|
@@ -3342,17 +3373,17 @@ class se {
|
|
|
3342
3373
|
* Only ever called once.
|
|
3343
3374
|
*/ _terminate() {
|
|
3344
3375
|
return function(t) {
|
|
3345
|
-
const
|
|
3346
|
-
|
|
3376
|
+
const e = tn.get(t);
|
|
3377
|
+
e && (m("ComponentProvider", "Removing Datastore"), tn.delete(t), e.terminate());
|
|
3347
3378
|
}(this), Promise.resolve();
|
|
3348
3379
|
}
|
|
3349
3380
|
}
|
|
3350
3381
|
|
|
3351
|
-
function
|
|
3352
|
-
const
|
|
3353
|
-
if (
|
|
3354
|
-
return
|
|
3355
|
-
options:
|
|
3382
|
+
function sn(t, e) {
|
|
3383
|
+
const n = _getProvider(t, "firestore/lite");
|
|
3384
|
+
if (n.isInitialized()) throw new U(S, "Firestore can only be initialized once per app.");
|
|
3385
|
+
return n.initialize({
|
|
3386
|
+
options: e
|
|
3356
3387
|
});
|
|
3357
3388
|
}
|
|
3358
3389
|
|
|
@@ -3364,8 +3395,8 @@ function oe(t, n) {
|
|
|
3364
3395
|
* @param app - The {@link @firebase/app#FirebaseApp} instance that the returned `Firestore`
|
|
3365
3396
|
* instance is associated with.
|
|
3366
3397
|
* @returns The `Firestore` instance of the provided app.
|
|
3367
|
-
*/ function
|
|
3368
|
-
return _getProvider(
|
|
3398
|
+
*/ function on(e = getApp()) {
|
|
3399
|
+
return _getProvider(e, "firestore/lite").getImmediate();
|
|
3369
3400
|
}
|
|
3370
3401
|
|
|
3371
3402
|
/**
|
|
@@ -3380,24 +3411,24 @@ function oe(t, n) {
|
|
|
3380
3411
|
* @param port - the emulator port (ex: 9000).
|
|
3381
3412
|
* @param options.mockUserToken - the mock auth token to use for unit testing
|
|
3382
3413
|
* Security Rules.
|
|
3383
|
-
*/ function
|
|
3414
|
+
*/ function un(t, e, n, r = {}) {
|
|
3384
3415
|
var s;
|
|
3385
|
-
const i = (t = ot(t,
|
|
3386
|
-
if ("firestore.googleapis.com" !== i.host && i.host !==
|
|
3416
|
+
const i = (t = ot(t, rn))._getSettings();
|
|
3417
|
+
if ("firestore.googleapis.com" !== i.host && i.host !== e && y("Host has been set in both settings() and useEmulator(), emulator host will be used"),
|
|
3387
3418
|
t._setSettings(Object.assign(Object.assign({}, i), {
|
|
3388
|
-
host: `${
|
|
3419
|
+
host: `${e}:${n}`,
|
|
3389
3420
|
ssl: !1
|
|
3390
3421
|
})), r.mockUserToken) {
|
|
3391
|
-
let
|
|
3392
|
-
if ("string" == typeof r.mockUserToken)
|
|
3422
|
+
let e, n;
|
|
3423
|
+
if ("string" == typeof r.mockUserToken) e = r.mockUserToken, n = l.MOCK_USER; else {
|
|
3393
3424
|
// Let createMockUserToken validate first (catches common mistakes like
|
|
3394
3425
|
// invalid field "uid" and missing field "sub" / "user_id".)
|
|
3395
|
-
|
|
3426
|
+
e = createMockUserToken(r.mockUserToken, null === (s = t._app) || void 0 === s ? void 0 : s.options.projectId);
|
|
3396
3427
|
const i = r.mockUserToken.sub || r.mockUserToken.user_id;
|
|
3397
3428
|
if (!i) throw new U(A, "mockUserToken must contain 'sub' or 'user_id' field!");
|
|
3398
|
-
|
|
3429
|
+
n = new l(i);
|
|
3399
3430
|
}
|
|
3400
|
-
t._authCredentials = new B(new j(
|
|
3431
|
+
t._authCredentials = new B(new j(e, n));
|
|
3401
3432
|
}
|
|
3402
3433
|
}
|
|
3403
3434
|
|
|
@@ -3420,8 +3451,8 @@ function oe(t, n) {
|
|
|
3420
3451
|
* @param firestore - The `Firestore` instance to terminate.
|
|
3421
3452
|
* @returns A `Promise` that is resolved when the instance has been successfully
|
|
3422
3453
|
* terminated.
|
|
3423
|
-
*/ function
|
|
3424
|
-
return t = ot(t,
|
|
3454
|
+
*/ function cn(t) {
|
|
3455
|
+
return t = ot(t, rn), _removeServiceInstance(t.app, "firestore/lite"), t._delete();
|
|
3425
3456
|
}
|
|
3426
3457
|
|
|
3427
3458
|
/**
|
|
@@ -3461,14 +3492,14 @@ function oe(t, n) {
|
|
|
3461
3492
|
* and can be used to write, read, or listen to the location. The document at
|
|
3462
3493
|
* the referenced location may or may not exist.
|
|
3463
3494
|
*/
|
|
3464
|
-
class
|
|
3495
|
+
class an {
|
|
3465
3496
|
/** @hideconstructor */
|
|
3466
3497
|
constructor(t,
|
|
3467
3498
|
/**
|
|
3468
3499
|
* If provided, the `FirestoreDataConverter` associated with this instance.
|
|
3469
3500
|
*/
|
|
3470
|
-
|
|
3471
|
-
this.converter =
|
|
3501
|
+
e, n) {
|
|
3502
|
+
this.converter = e, this._key = n,
|
|
3472
3503
|
/** The type of this Firestore reference. */
|
|
3473
3504
|
this.type = "document", this.firestore = t;
|
|
3474
3505
|
}
|
|
@@ -3489,40 +3520,40 @@ class he {
|
|
|
3489
3520
|
/**
|
|
3490
3521
|
* The collection this `DocumentReference` belongs to.
|
|
3491
3522
|
*/ get parent() {
|
|
3492
|
-
return new
|
|
3523
|
+
return new ln(this.firestore, this.converter, this._key.path.popLast());
|
|
3493
3524
|
}
|
|
3494
3525
|
withConverter(t) {
|
|
3495
|
-
return new
|
|
3526
|
+
return new an(this.firestore, t, this._key);
|
|
3496
3527
|
}
|
|
3497
3528
|
}
|
|
3498
3529
|
|
|
3499
3530
|
/**
|
|
3500
3531
|
* A `Query` refers to a query which you can read or listen to. You can also
|
|
3501
3532
|
* construct refined `Query` objects by adding filters and ordering.
|
|
3502
|
-
*/ class
|
|
3533
|
+
*/ class hn {
|
|
3503
3534
|
// This is the lite version of the Query class in the main SDK.
|
|
3504
3535
|
/** @hideconstructor protected */
|
|
3505
3536
|
constructor(t,
|
|
3506
3537
|
/**
|
|
3507
3538
|
* If provided, the `FirestoreDataConverter` associated with this instance.
|
|
3508
3539
|
*/
|
|
3509
|
-
|
|
3510
|
-
this.converter =
|
|
3540
|
+
e, n) {
|
|
3541
|
+
this.converter = e, this._query = n,
|
|
3511
3542
|
/** The type of this Firestore reference. */
|
|
3512
3543
|
this.type = "query", this.firestore = t;
|
|
3513
3544
|
}
|
|
3514
3545
|
withConverter(t) {
|
|
3515
|
-
return new
|
|
3546
|
+
return new hn(this.firestore, t, this._query);
|
|
3516
3547
|
}
|
|
3517
3548
|
}
|
|
3518
3549
|
|
|
3519
3550
|
/**
|
|
3520
3551
|
* A `CollectionReference` object can be used for adding documents, getting
|
|
3521
3552
|
* document references, and querying for documents (using {@link query}).
|
|
3522
|
-
*/ class
|
|
3553
|
+
*/ class ln extends hn {
|
|
3523
3554
|
/** @hideconstructor */
|
|
3524
|
-
constructor(t,
|
|
3525
|
-
super(t,
|
|
3555
|
+
constructor(t, e, n) {
|
|
3556
|
+
super(t, e, new oe(n)), this._path = n,
|
|
3526
3557
|
/** The type of this Firestore reference. */
|
|
3527
3558
|
this.type = "collection";
|
|
3528
3559
|
}
|
|
@@ -3540,23 +3571,23 @@ class he {
|
|
|
3540
3571
|
* subcollection. If this isn't a subcollection, the reference is null.
|
|
3541
3572
|
*/ get parent() {
|
|
3542
3573
|
const t = this._path.popLast();
|
|
3543
|
-
return t.isEmpty() ? null : new
|
|
3544
|
-
/* converter= */ null, new
|
|
3574
|
+
return t.isEmpty() ? null : new an(this.firestore,
|
|
3575
|
+
/* converter= */ null, new et(t));
|
|
3545
3576
|
}
|
|
3546
3577
|
withConverter(t) {
|
|
3547
|
-
return new
|
|
3578
|
+
return new ln(this.firestore, t, this._path);
|
|
3548
3579
|
}
|
|
3549
3580
|
}
|
|
3550
3581
|
|
|
3551
|
-
function
|
|
3552
|
-
if (t = getModularInstance(t),
|
|
3553
|
-
const r = X.fromString(
|
|
3554
|
-
return st(r), new
|
|
3582
|
+
function fn(t, e, ...n) {
|
|
3583
|
+
if (t = getModularInstance(t), nt("collection", "path", e), t instanceof rn) {
|
|
3584
|
+
const r = X.fromString(e, ...n);
|
|
3585
|
+
return st(r), new ln(t, /* converter= */ null, r);
|
|
3555
3586
|
}
|
|
3556
3587
|
{
|
|
3557
|
-
if (!(t instanceof
|
|
3558
|
-
const r = t._path.child(X.fromString(
|
|
3559
|
-
return st(r), new
|
|
3588
|
+
if (!(t instanceof an || t instanceof ln)) throw new U(A, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3589
|
+
const r = t._path.child(X.fromString(e, ...n));
|
|
3590
|
+
return st(r), new ln(t.firestore,
|
|
3560
3591
|
/* converter= */ null, r);
|
|
3561
3592
|
}
|
|
3562
3593
|
}
|
|
@@ -3573,32 +3604,32 @@ function de(t, n, ...e) {
|
|
|
3573
3604
|
* collection or subcollection with this ID as the last segment of its path
|
|
3574
3605
|
* will be included. Cannot contain a slash.
|
|
3575
3606
|
* @returns The created `Query`.
|
|
3576
|
-
*/ function
|
|
3577
|
-
if (t = ot(t,
|
|
3578
|
-
return new
|
|
3607
|
+
*/ function dn(t, e) {
|
|
3608
|
+
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 '/'.`);
|
|
3609
|
+
return new hn(t,
|
|
3579
3610
|
/* converter= */ null,
|
|
3580
3611
|
/**
|
|
3581
3612
|
* Creates a new Query for a collection group query that matches all documents
|
|
3582
3613
|
* within the provided collection group.
|
|
3583
3614
|
*/
|
|
3584
3615
|
function(t) {
|
|
3585
|
-
return new
|
|
3586
|
-
}(
|
|
3616
|
+
return new oe(X.emptyPath(), t);
|
|
3617
|
+
}(e));
|
|
3587
3618
|
}
|
|
3588
3619
|
|
|
3589
|
-
function
|
|
3620
|
+
function wn(t, e, ...n) {
|
|
3590
3621
|
if (t = getModularInstance(t),
|
|
3591
3622
|
// We allow omission of 'pathString' but explicitly prohibit passing in both
|
|
3592
3623
|
// 'undefined' and 'null'.
|
|
3593
|
-
1 === arguments.length && (
|
|
3594
|
-
const r = X.fromString(
|
|
3595
|
-
return rt(r), new
|
|
3596
|
-
/* converter= */ null, new
|
|
3624
|
+
1 === arguments.length && (e = pt.R()), nt("doc", "path", e), t instanceof rn) {
|
|
3625
|
+
const r = X.fromString(e, ...n);
|
|
3626
|
+
return rt(r), new an(t,
|
|
3627
|
+
/* converter= */ null, new et(r));
|
|
3597
3628
|
}
|
|
3598
3629
|
{
|
|
3599
|
-
if (!(t instanceof
|
|
3600
|
-
const r = t._path.child(X.fromString(
|
|
3601
|
-
return rt(r), new
|
|
3630
|
+
if (!(t instanceof an || t instanceof ln)) throw new U(A, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
|
|
3631
|
+
const r = t._path.child(X.fromString(e, ...n));
|
|
3632
|
+
return rt(r), new an(t.firestore, t instanceof ln ? t.converter : null, new et(r));
|
|
3602
3633
|
}
|
|
3603
3634
|
}
|
|
3604
3635
|
|
|
@@ -3609,8 +3640,8 @@ function me(t, n, ...e) {
|
|
|
3609
3640
|
* @param right - A reference to compare.
|
|
3610
3641
|
* @returns true if the references point to the same location in the same
|
|
3611
3642
|
* Firestore database.
|
|
3612
|
-
*/ function
|
|
3613
|
-
return t = getModularInstance(t),
|
|
3643
|
+
*/ function mn(t, e) {
|
|
3644
|
+
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);
|
|
3614
3645
|
}
|
|
3615
3646
|
|
|
3616
3647
|
/**
|
|
@@ -3621,8 +3652,8 @@ function me(t, n, ...e) {
|
|
|
3621
3652
|
* @param right - A `Query` to compare.
|
|
3622
3653
|
* @returns true if the references point to the same location in the same
|
|
3623
3654
|
* Firestore database.
|
|
3624
|
-
*/ function
|
|
3625
|
-
return t = getModularInstance(t),
|
|
3655
|
+
*/ function pn(t, e) {
|
|
3656
|
+
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);
|
|
3626
3657
|
}
|
|
3627
3658
|
|
|
3628
3659
|
/**
|
|
@@ -3648,7 +3679,7 @@ function me(t, n, ...e) {
|
|
|
3648
3679
|
*
|
|
3649
3680
|
* Create a `FieldPath` by providing field names. If more than one field
|
|
3650
3681
|
* name is provided, the path will point to a nested field in a document.
|
|
3651
|
-
*/ class
|
|
3682
|
+
*/ class yn {
|
|
3652
3683
|
/**
|
|
3653
3684
|
* Creates a `FieldPath` from the provided field names. If more than one field
|
|
3654
3685
|
* name is provided, the path will point to a nested field in a document.
|
|
@@ -3656,7 +3687,7 @@ function me(t, n, ...e) {
|
|
|
3656
3687
|
* @param fieldNames - A list of field names.
|
|
3657
3688
|
*/
|
|
3658
3689
|
constructor(...t) {
|
|
3659
|
-
for (let
|
|
3690
|
+
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.");
|
|
3660
3691
|
this._internalPath = new tt(t);
|
|
3661
3692
|
}
|
|
3662
3693
|
/**
|
|
@@ -3672,8 +3703,8 @@ function me(t, n, ...e) {
|
|
|
3672
3703
|
/**
|
|
3673
3704
|
* Returns a special sentinel `FieldPath` to refer to the ID of a document.
|
|
3674
3705
|
* It can be used in queries to sort or filter by the document ID.
|
|
3675
|
-
*/ function
|
|
3676
|
-
return new
|
|
3706
|
+
*/ function _n() {
|
|
3707
|
+
return new yn("__name__");
|
|
3677
3708
|
}
|
|
3678
3709
|
|
|
3679
3710
|
/**
|
|
@@ -3694,7 +3725,7 @@ function me(t, n, ...e) {
|
|
|
3694
3725
|
*/
|
|
3695
3726
|
/**
|
|
3696
3727
|
* An immutable object representing an array of bytes.
|
|
3697
|
-
*/ class
|
|
3728
|
+
*/ class gn {
|
|
3698
3729
|
/** @hideconstructor */
|
|
3699
3730
|
constructor(t) {
|
|
3700
3731
|
this._byteString = t;
|
|
@@ -3706,7 +3737,7 @@ function me(t, n, ...e) {
|
|
|
3706
3737
|
* @param base64 - The Base64 string used to create the `Bytes` object.
|
|
3707
3738
|
*/ static fromBase64String(t) {
|
|
3708
3739
|
try {
|
|
3709
|
-
return new
|
|
3740
|
+
return new gn(It.fromBase64String(t));
|
|
3710
3741
|
} catch (t) {
|
|
3711
3742
|
throw new U(A, "Failed to construct data from Base64 string: " + t);
|
|
3712
3743
|
}
|
|
@@ -3716,7 +3747,7 @@ function me(t, n, ...e) {
|
|
|
3716
3747
|
*
|
|
3717
3748
|
* @param array - The Uint8Array used to create the `Bytes` object.
|
|
3718
3749
|
*/ static fromUint8Array(t) {
|
|
3719
|
-
return new
|
|
3750
|
+
return new gn(It.fromUint8Array(t));
|
|
3720
3751
|
}
|
|
3721
3752
|
/**
|
|
3722
3753
|
* Returns the underlying bytes as a Base64-encoded string.
|
|
@@ -3768,7 +3799,7 @@ function me(t, n, ...e) {
|
|
|
3768
3799
|
/**
|
|
3769
3800
|
* Sentinel values that can be used when writing document fields with `set()`
|
|
3770
3801
|
* or `update()`.
|
|
3771
|
-
*/ class
|
|
3802
|
+
*/ class bn {
|
|
3772
3803
|
/**
|
|
3773
3804
|
* @param _methodName - The public API endpoint that returns this class.
|
|
3774
3805
|
* @hideconstructor
|
|
@@ -3800,17 +3831,17 @@ function me(t, n, ...e) {
|
|
|
3800
3831
|
*
|
|
3801
3832
|
* Latitude values are in the range of [-90, 90].
|
|
3802
3833
|
* Longitude values are in the range of [-180, 180].
|
|
3803
|
-
*/ class
|
|
3834
|
+
*/ class vn {
|
|
3804
3835
|
/**
|
|
3805
3836
|
* Creates a new immutable `GeoPoint` object with the provided latitude and
|
|
3806
3837
|
* longitude values.
|
|
3807
3838
|
* @param latitude - The latitude as number between -90 and 90.
|
|
3808
3839
|
* @param longitude - The longitude as number between -180 and 180.
|
|
3809
3840
|
*/
|
|
3810
|
-
constructor(t,
|
|
3841
|
+
constructor(t, e) {
|
|
3811
3842
|
if (!isFinite(t) || t < -90 || t > 90) throw new U(A, "Latitude must be a number between -90 and 90, but was: " + t);
|
|
3812
|
-
if (!isFinite(
|
|
3813
|
-
this._lat = t, this._long =
|
|
3843
|
+
if (!isFinite(e) || e < -180 || e > 180) throw new U(A, "Longitude must be a number between -180 and 180, but was: " + e);
|
|
3844
|
+
this._lat = t, this._long = e;
|
|
3814
3845
|
}
|
|
3815
3846
|
/**
|
|
3816
3847
|
* The latitude of this `GeoPoint` instance.
|
|
@@ -3859,29 +3890,29 @@ function me(t, n, ...e) {
|
|
|
3859
3890
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3860
3891
|
* See the License for the specific language governing permissions and
|
|
3861
3892
|
* limitations under the License.
|
|
3862
|
-
*/ const
|
|
3893
|
+
*/ const En = /^__.*__$/;
|
|
3863
3894
|
|
|
3864
|
-
/** The result of parsing document data (e.g. for a setData call). */ class
|
|
3865
|
-
constructor(t,
|
|
3866
|
-
this.data = t, this.fieldMask =
|
|
3895
|
+
/** The result of parsing document data (e.g. for a setData call). */ class Tn {
|
|
3896
|
+
constructor(t, e, n) {
|
|
3897
|
+
this.data = t, this.fieldMask = e, this.fieldTransforms = n;
|
|
3867
3898
|
}
|
|
3868
|
-
toMutation(t,
|
|
3869
|
-
return null !== this.fieldMask ? new
|
|
3899
|
+
toMutation(t, e) {
|
|
3900
|
+
return null !== this.fieldMask ? new Ie(t, this.data, this.fieldMask, e, this.fieldTransforms) : new Te(t, this.data, e, this.fieldTransforms);
|
|
3870
3901
|
}
|
|
3871
3902
|
}
|
|
3872
3903
|
|
|
3873
|
-
/** The result of parsing "update" data (i.e. for an updateData call). */ class
|
|
3904
|
+
/** The result of parsing "update" data (i.e. for an updateData call). */ class In {
|
|
3874
3905
|
constructor(t,
|
|
3875
3906
|
// The fieldMask does not include document transforms.
|
|
3876
|
-
|
|
3877
|
-
this.data = t, this.fieldMask =
|
|
3907
|
+
e, n) {
|
|
3908
|
+
this.data = t, this.fieldMask = e, this.fieldTransforms = n;
|
|
3878
3909
|
}
|
|
3879
|
-
toMutation(t,
|
|
3880
|
-
return new
|
|
3910
|
+
toMutation(t, e) {
|
|
3911
|
+
return new Ie(t, this.data, this.fieldMask, e, this.fieldTransforms);
|
|
3881
3912
|
}
|
|
3882
3913
|
}
|
|
3883
3914
|
|
|
3884
|
-
function
|
|
3915
|
+
function An(t) {
|
|
3885
3916
|
switch (t) {
|
|
3886
3917
|
case 0 /* Set */ :
|
|
3887
3918
|
// fall through
|
|
@@ -3899,7 +3930,7 @@ function Re(t) {
|
|
|
3899
3930
|
}
|
|
3900
3931
|
}
|
|
3901
3932
|
|
|
3902
|
-
/** A "context" object passed around while parsing user data. */ class
|
|
3933
|
+
/** A "context" object passed around while parsing user data. */ class Rn {
|
|
3903
3934
|
/**
|
|
3904
3935
|
* Initializes a ParseContext with the given source and path.
|
|
3905
3936
|
*
|
|
@@ -3918,8 +3949,8 @@ function Re(t) {
|
|
|
3918
3949
|
* which case certain features will not work and errors will be somewhat
|
|
3919
3950
|
* compromised).
|
|
3920
3951
|
*/
|
|
3921
|
-
constructor(t,
|
|
3922
|
-
this.settings = t, this.databaseId =
|
|
3952
|
+
constructor(t, e, n, r, s, i) {
|
|
3953
|
+
this.settings = t, this.databaseId = e, this.q = n, this.ignoreUndefinedProperties = r,
|
|
3923
3954
|
// Minor hack: If fieldTransforms is undefined, we assume this is an
|
|
3924
3955
|
// external call and we need to validate the entire path.
|
|
3925
3956
|
void 0 === s && this.Z(), this.fieldTransforms = s || [], this.fieldMask = i || [];
|
|
@@ -3930,21 +3961,21 @@ function Re(t) {
|
|
|
3930
3961
|
get tt() {
|
|
3931
3962
|
return this.settings.tt;
|
|
3932
3963
|
}
|
|
3933
|
-
/** Returns a new context with the specified settings overwritten. */
|
|
3934
|
-
return new
|
|
3964
|
+
/** Returns a new context with the specified settings overwritten. */ et(t) {
|
|
3965
|
+
return new Rn(Object.assign(Object.assign({}, this.settings), t), this.databaseId, this.q, this.ignoreUndefinedProperties, this.fieldTransforms, this.fieldMask);
|
|
3935
3966
|
}
|
|
3936
|
-
|
|
3937
|
-
var
|
|
3938
|
-
const
|
|
3939
|
-
path:
|
|
3967
|
+
nt(t) {
|
|
3968
|
+
var e;
|
|
3969
|
+
const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), r = this.et({
|
|
3970
|
+
path: n,
|
|
3940
3971
|
rt: !1
|
|
3941
3972
|
});
|
|
3942
3973
|
return r.st(t), r;
|
|
3943
3974
|
}
|
|
3944
3975
|
it(t) {
|
|
3945
|
-
var
|
|
3946
|
-
const
|
|
3947
|
-
path:
|
|
3976
|
+
var e;
|
|
3977
|
+
const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), r = this.et({
|
|
3978
|
+
path: n,
|
|
3948
3979
|
rt: !1
|
|
3949
3980
|
});
|
|
3950
3981
|
return r.Z(), r;
|
|
@@ -3952,16 +3983,16 @@ function Re(t) {
|
|
|
3952
3983
|
ot(t) {
|
|
3953
3984
|
// TODO(b/34871131): We don't support array paths right now; so make path
|
|
3954
3985
|
// undefined.
|
|
3955
|
-
return this.
|
|
3986
|
+
return this.et({
|
|
3956
3987
|
path: void 0,
|
|
3957
3988
|
rt: !0
|
|
3958
3989
|
});
|
|
3959
3990
|
}
|
|
3960
3991
|
ut(t) {
|
|
3961
|
-
return
|
|
3992
|
+
return Qn(t, this.settings.methodName, this.settings.ct || !1, this.path, this.settings.at);
|
|
3962
3993
|
}
|
|
3963
3994
|
/** Returns 'true' if 'fieldPath' was traversed when creating this context. */ contains(t) {
|
|
3964
|
-
return void 0 !== this.fieldMask.find((
|
|
3995
|
+
return void 0 !== this.fieldMask.find((e => t.isPrefixOf(e))) || void 0 !== this.fieldTransforms.find((e => t.isPrefixOf(e.field)));
|
|
3965
3996
|
}
|
|
3966
3997
|
Z() {
|
|
3967
3998
|
// TODO(b/34871131): Remove null check once we have proper paths for fields
|
|
@@ -3970,22 +4001,22 @@ function Re(t) {
|
|
|
3970
4001
|
}
|
|
3971
4002
|
st(t) {
|
|
3972
4003
|
if (0 === t.length) throw this.ut("Document fields must not be empty");
|
|
3973
|
-
if (
|
|
4004
|
+
if (An(this.tt) && En.test(t)) throw this.ut('Document fields cannot begin and end with "__"');
|
|
3974
4005
|
}
|
|
3975
4006
|
}
|
|
3976
4007
|
|
|
3977
4008
|
/**
|
|
3978
4009
|
* Helper for parsing raw user input (provided via the API) into internal model
|
|
3979
4010
|
* classes.
|
|
3980
|
-
*/ class
|
|
3981
|
-
constructor(t,
|
|
3982
|
-
this.databaseId = t, this.ignoreUndefinedProperties =
|
|
4011
|
+
*/ class Pn {
|
|
4012
|
+
constructor(t, e, n) {
|
|
4013
|
+
this.databaseId = t, this.ignoreUndefinedProperties = e, this.q = n || Ye(t);
|
|
3983
4014
|
}
|
|
3984
|
-
/** Creates a new top-level parse context. */ ht(t,
|
|
3985
|
-
return new
|
|
4015
|
+
/** Creates a new top-level parse context. */ ht(t, e, n, r = !1) {
|
|
4016
|
+
return new Rn({
|
|
3986
4017
|
tt: t,
|
|
3987
|
-
methodName:
|
|
3988
|
-
at:
|
|
4018
|
+
methodName: e,
|
|
4019
|
+
at: n,
|
|
3989
4020
|
path: tt.emptyPath(),
|
|
3990
4021
|
rt: !1,
|
|
3991
4022
|
ct: r
|
|
@@ -3993,29 +4024,29 @@ function Re(t) {
|
|
|
3993
4024
|
}
|
|
3994
4025
|
}
|
|
3995
4026
|
|
|
3996
|
-
function
|
|
3997
|
-
const
|
|
3998
|
-
return new
|
|
4027
|
+
function Vn(t) {
|
|
4028
|
+
const e = t._freezeSettings(), n = Ye(t._databaseId);
|
|
4029
|
+
return new Pn(t._databaseId, !!e.ignoreUndefinedProperties, n);
|
|
3999
4030
|
}
|
|
4000
4031
|
|
|
4001
|
-
/** Parse document data from a set() call. */ function
|
|
4002
|
-
const o = t.ht(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ ,
|
|
4003
|
-
|
|
4004
|
-
const u =
|
|
4032
|
+
/** Parse document data from a set() call. */ function Dn(t, e, n, r, s, i = {}) {
|
|
4033
|
+
const o = t.ht(i.merge || i.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ , e, n, s);
|
|
4034
|
+
Mn("Data must be an object, but it was:", o, r);
|
|
4035
|
+
const u = kn(r, o);
|
|
4005
4036
|
let c, a;
|
|
4006
4037
|
if (i.merge) c = new Tt(o.fieldMask), a = o.fieldTransforms; else if (i.mergeFields) {
|
|
4007
4038
|
const t = [];
|
|
4008
4039
|
for (const r of i.mergeFields) {
|
|
4009
|
-
const s =
|
|
4040
|
+
const s = Bn(e, r, n);
|
|
4010
4041
|
if (!o.contains(s)) throw new U(A, `Field '${s}' is specified in your field mask but missing from your input data.`);
|
|
4011
|
-
|
|
4042
|
+
Wn(t, s) || t.push(s);
|
|
4012
4043
|
}
|
|
4013
4044
|
c = new Tt(t), a = o.fieldTransforms.filter((t => c.covers(t.field)));
|
|
4014
4045
|
} else c = null, a = o.fieldTransforms;
|
|
4015
|
-
return new
|
|
4046
|
+
return new Tn(new Bt(u), c, a);
|
|
4016
4047
|
}
|
|
4017
4048
|
|
|
4018
|
-
class
|
|
4049
|
+
class Nn extends bn {
|
|
4019
4050
|
_toFieldTransform(t) {
|
|
4020
4051
|
if (2 /* MergeSet */ !== t.tt) throw 1 /* Update */ === t.tt ? t.ut(`${this._methodName}() can only appear at the top level of your update data`) : t.ut(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);
|
|
4021
4052
|
// No transform to add for a delete, but we need to add it to our
|
|
@@ -4023,7 +4054,7 @@ class $e extends be {
|
|
|
4023
4054
|
return t.fieldMask.push(t.path), null;
|
|
4024
4055
|
}
|
|
4025
4056
|
isEqual(t) {
|
|
4026
|
-
return t instanceof
|
|
4057
|
+
return t instanceof Nn;
|
|
4027
4058
|
}
|
|
4028
4059
|
}
|
|
4029
4060
|
|
|
@@ -4042,32 +4073,32 @@ class $e extends be {
|
|
|
4042
4073
|
* context.
|
|
4043
4074
|
* @param context - The parent context.
|
|
4044
4075
|
* @param arrayElement - Whether or not the FieldValue has an array.
|
|
4045
|
-
*/ function
|
|
4046
|
-
return new
|
|
4076
|
+
*/ function $n(t, e, n) {
|
|
4077
|
+
return new Rn({
|
|
4047
4078
|
tt: 3 /* Argument */ ,
|
|
4048
|
-
at:
|
|
4079
|
+
at: e.settings.at,
|
|
4049
4080
|
methodName: t._methodName,
|
|
4050
|
-
rt:
|
|
4051
|
-
},
|
|
4081
|
+
rt: n
|
|
4082
|
+
}, e.databaseId, e.q, e.ignoreUndefinedProperties);
|
|
4052
4083
|
}
|
|
4053
4084
|
|
|
4054
|
-
class
|
|
4085
|
+
class Sn extends bn {
|
|
4055
4086
|
_toFieldTransform(t) {
|
|
4056
|
-
return new
|
|
4087
|
+
return new be(t.path, new pe);
|
|
4057
4088
|
}
|
|
4058
4089
|
isEqual(t) {
|
|
4059
|
-
return t instanceof
|
|
4090
|
+
return t instanceof Sn;
|
|
4060
4091
|
}
|
|
4061
4092
|
}
|
|
4062
4093
|
|
|
4063
|
-
class
|
|
4064
|
-
constructor(t,
|
|
4065
|
-
super(t), this.lt =
|
|
4094
|
+
class Fn extends bn {
|
|
4095
|
+
constructor(t, e) {
|
|
4096
|
+
super(t), this.lt = e;
|
|
4066
4097
|
}
|
|
4067
4098
|
_toFieldTransform(t) {
|
|
4068
|
-
const
|
|
4069
|
-
/*array=*/ !0),
|
|
4070
|
-
return new
|
|
4099
|
+
const e = $n(this, t,
|
|
4100
|
+
/*array=*/ !0), n = this.lt.map((t => Un(t, e))), r = new ye(n);
|
|
4101
|
+
return new be(t.path, r);
|
|
4071
4102
|
}
|
|
4072
4103
|
isEqual(t) {
|
|
4073
4104
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4075,14 +4106,14 @@ class xe extends be {
|
|
|
4075
4106
|
}
|
|
4076
4107
|
}
|
|
4077
4108
|
|
|
4078
|
-
class
|
|
4079
|
-
constructor(t,
|
|
4080
|
-
super(t), this.lt =
|
|
4109
|
+
class xn extends bn {
|
|
4110
|
+
constructor(t, e) {
|
|
4111
|
+
super(t), this.lt = e;
|
|
4081
4112
|
}
|
|
4082
4113
|
_toFieldTransform(t) {
|
|
4083
|
-
const
|
|
4084
|
-
/*array=*/ !0),
|
|
4085
|
-
return new
|
|
4114
|
+
const e = $n(this, t,
|
|
4115
|
+
/*array=*/ !0), n = this.lt.map((t => Un(t, e))), r = new _e(n);
|
|
4116
|
+
return new be(t.path, r);
|
|
4086
4117
|
}
|
|
4087
4118
|
isEqual(t) {
|
|
4088
4119
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4090,13 +4121,13 @@ class qe extends be {
|
|
|
4090
4121
|
}
|
|
4091
4122
|
}
|
|
4092
4123
|
|
|
4093
|
-
class
|
|
4094
|
-
constructor(t,
|
|
4095
|
-
super(t), this.ft =
|
|
4124
|
+
class qn extends bn {
|
|
4125
|
+
constructor(t, e) {
|
|
4126
|
+
super(t), this.ft = e;
|
|
4096
4127
|
}
|
|
4097
4128
|
_toFieldTransform(t) {
|
|
4098
|
-
const
|
|
4099
|
-
return new
|
|
4129
|
+
const e = new ge(t.q, we(t.q, this.ft));
|
|
4130
|
+
return new be(t.path, e);
|
|
4100
4131
|
}
|
|
4101
4132
|
isEqual(t) {
|
|
4102
4133
|
// TODO(mrschmidt): Implement isEquals
|
|
@@ -4104,50 +4135,50 @@ class Oe extends be {
|
|
|
4104
4135
|
}
|
|
4105
4136
|
}
|
|
4106
4137
|
|
|
4107
|
-
/** Parse update data from an update() call. */ function
|
|
4108
|
-
const s = t.ht(1 /* Update */ ,
|
|
4109
|
-
|
|
4138
|
+
/** Parse update data from an update() call. */ function On(t, e, n, r) {
|
|
4139
|
+
const s = t.ht(1 /* Update */ , e, n);
|
|
4140
|
+
Mn("Data must be an object, but it was:", s, r);
|
|
4110
4141
|
const i = [], o = Bt.empty();
|
|
4111
4142
|
Et(r, ((t, r) => {
|
|
4112
|
-
const u =
|
|
4143
|
+
const u = Gn(e, t, n);
|
|
4113
4144
|
// For Compat types, we have to "extract" the underlying types before
|
|
4114
4145
|
// performing validation.
|
|
4115
4146
|
r = getModularInstance(r);
|
|
4116
4147
|
const c = s.it(u);
|
|
4117
|
-
if (r instanceof
|
|
4148
|
+
if (r instanceof Nn)
|
|
4118
4149
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4119
4150
|
i.push(u); else {
|
|
4120
|
-
const t =
|
|
4151
|
+
const t = Un(r, c);
|
|
4121
4152
|
null != t && (i.push(u), o.set(u, t));
|
|
4122
4153
|
}
|
|
4123
4154
|
}));
|
|
4124
4155
|
const u = new Tt(i);
|
|
4125
|
-
return new
|
|
4156
|
+
return new In(o, u, s.fieldTransforms);
|
|
4126
4157
|
}
|
|
4127
4158
|
|
|
4128
|
-
/** Parse update data from a list of field/value arguments. */ function
|
|
4129
|
-
const o = t.ht(1 /* Update */ ,
|
|
4130
|
-
if (i.length % 2 != 0) throw new U(A, `Function ${
|
|
4131
|
-
for (let t = 0; t < i.length; t += 2) u.push(
|
|
4159
|
+
/** Parse update data from a list of field/value arguments. */ function Cn(t, e, n, r, s, i) {
|
|
4160
|
+
const o = t.ht(1 /* Update */ , e, n), u = [ Bn(e, r, n) ], c = [ s ];
|
|
4161
|
+
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.`);
|
|
4162
|
+
for (let t = 0; t < i.length; t += 2) u.push(Bn(e, i[t])), c.push(i[t + 1]);
|
|
4132
4163
|
const a = [], l = Bt.empty();
|
|
4133
4164
|
// We iterate in reverse order to pick the last value for a field if the
|
|
4134
4165
|
// user specified the field multiple times.
|
|
4135
|
-
for (let t = u.length - 1; t >= 0; --t) if (!
|
|
4136
|
-
const
|
|
4137
|
-
let
|
|
4166
|
+
for (let t = u.length - 1; t >= 0; --t) if (!Wn(a, u[t])) {
|
|
4167
|
+
const e = u[t];
|
|
4168
|
+
let n = c[t];
|
|
4138
4169
|
// For Compat types, we have to "extract" the underlying types before
|
|
4139
4170
|
// performing validation.
|
|
4140
|
-
|
|
4141
|
-
const r = o.it(
|
|
4142
|
-
if (
|
|
4171
|
+
n = getModularInstance(n);
|
|
4172
|
+
const r = o.it(e);
|
|
4173
|
+
if (n instanceof Nn)
|
|
4143
4174
|
// Add it to the field mask, but don't add anything to updateData.
|
|
4144
|
-
a.push(
|
|
4145
|
-
const t =
|
|
4146
|
-
null != t && (a.push(
|
|
4175
|
+
a.push(e); else {
|
|
4176
|
+
const t = Un(n, r);
|
|
4177
|
+
null != t && (a.push(e), l.set(e, t));
|
|
4147
4178
|
}
|
|
4148
4179
|
}
|
|
4149
4180
|
const f = new Tt(a);
|
|
4150
|
-
return new
|
|
4181
|
+
return new In(l, f, o.fieldTransforms);
|
|
4151
4182
|
}
|
|
4152
4183
|
|
|
4153
4184
|
/**
|
|
@@ -4156,8 +4187,8 @@ class Oe extends be {
|
|
|
4156
4187
|
*
|
|
4157
4188
|
* @param allowArrays - Whether the query value is an array that may directly
|
|
4158
4189
|
* contain additional arrays (e.g. the operand of an `in` query).
|
|
4159
|
-
*/ function
|
|
4160
|
-
return
|
|
4190
|
+
*/ function Ln(t, e, n, r = !1) {
|
|
4191
|
+
return Un(n, t.ht(r ? 4 /* ArrayArgument */ : 3 /* Argument */ , e));
|
|
4161
4192
|
}
|
|
4162
4193
|
|
|
4163
4194
|
/**
|
|
@@ -4168,12 +4199,12 @@ class Oe extends be {
|
|
|
4168
4199
|
* the source of the data being parsed, etc.
|
|
4169
4200
|
* @returns The parsed value, or null if the value was a FieldValue sentinel
|
|
4170
4201
|
* that should not be included in the resulting parsed data.
|
|
4171
|
-
*/ function
|
|
4172
|
-
if (
|
|
4202
|
+
*/ function Un(t, e) {
|
|
4203
|
+
if (jn(
|
|
4173
4204
|
// Unwrap the API type from the Compat SDK. This will return the API type
|
|
4174
4205
|
// from firestore-exp.
|
|
4175
|
-
t = getModularInstance(t))) return
|
|
4176
|
-
if (t instanceof
|
|
4206
|
+
t = getModularInstance(t))) return Mn("Unsupported field value:", e, t), kn(t, e);
|
|
4207
|
+
if (t instanceof bn)
|
|
4177
4208
|
// FieldValues usually parse into transforms (except deleteField())
|
|
4178
4209
|
// in which case we do not want to include this field in our parsed data
|
|
4179
4210
|
// (as doing so will overwrite the field directly prior to the transform
|
|
@@ -4183,19 +4214,19 @@ class Oe extends be {
|
|
|
4183
4214
|
* "Parses" the provided FieldValueImpl, adding any necessary transforms to
|
|
4184
4215
|
* context.fieldTransforms.
|
|
4185
4216
|
*/
|
|
4186
|
-
return function(t,
|
|
4217
|
+
return function(t, e) {
|
|
4187
4218
|
// Sentinels are only supported with writes, and not within arrays.
|
|
4188
|
-
if (!
|
|
4189
|
-
if (!
|
|
4190
|
-
const
|
|
4191
|
-
|
|
4219
|
+
if (!An(e.tt)) throw e.ut(`${t._methodName}() can only be used with update() and set()`);
|
|
4220
|
+
if (!e.path) throw e.ut(`${t._methodName}() is not currently supported inside arrays`);
|
|
4221
|
+
const n = t._toFieldTransform(e);
|
|
4222
|
+
n && e.fieldTransforms.push(n);
|
|
4192
4223
|
}
|
|
4193
4224
|
/**
|
|
4194
4225
|
* Helper to parse a scalar value (i.e. not an Object, Array, or FieldValue)
|
|
4195
4226
|
*
|
|
4196
4227
|
* @returns The parsed value
|
|
4197
|
-
*/ (t,
|
|
4198
|
-
if (void 0 === t &&
|
|
4228
|
+
*/ (t, e), null;
|
|
4229
|
+
if (void 0 === t && e.ignoreUndefinedProperties)
|
|
4199
4230
|
// If the input is undefined it can never participate in the fieldMask, so
|
|
4200
4231
|
// don't handle this below. If `ignoreUndefinedProperties` is false,
|
|
4201
4232
|
// `parseScalarValue` will reject an undefined value.
|
|
@@ -4203,38 +4234,38 @@ class Oe extends be {
|
|
|
4203
4234
|
if (
|
|
4204
4235
|
// If context.path is null we are inside an array and we don't support
|
|
4205
4236
|
// field mask paths more granular than the top-level array.
|
|
4206
|
-
|
|
4237
|
+
e.path && e.fieldMask.push(e.path), t instanceof Array) {
|
|
4207
4238
|
// TODO(b/34871131): Include the path containing the array in the error
|
|
4208
4239
|
// message.
|
|
4209
4240
|
// In the case of IN queries, the parsed data is an array (representing
|
|
4210
4241
|
// the set of values to be included for the IN query) that may directly
|
|
4211
4242
|
// contain additional arrays (each representing an individual field
|
|
4212
4243
|
// value), so we disable this validation.
|
|
4213
|
-
if (
|
|
4214
|
-
return function(t,
|
|
4215
|
-
const
|
|
4244
|
+
if (e.settings.rt && 4 /* ArrayArgument */ !== e.tt) throw e.ut("Nested arrays are not supported");
|
|
4245
|
+
return function(t, e) {
|
|
4246
|
+
const n = [];
|
|
4216
4247
|
let r = 0;
|
|
4217
4248
|
for (const s of t) {
|
|
4218
|
-
let t =
|
|
4249
|
+
let t = Un(s, e.ot(r));
|
|
4219
4250
|
null == t && (
|
|
4220
4251
|
// Just include nulls in the array for fields being replaced with a
|
|
4221
4252
|
// sentinel.
|
|
4222
4253
|
t = {
|
|
4223
4254
|
nullValue: "NULL_VALUE"
|
|
4224
|
-
}),
|
|
4255
|
+
}), n.push(t), r++;
|
|
4225
4256
|
}
|
|
4226
4257
|
return {
|
|
4227
4258
|
arrayValue: {
|
|
4228
|
-
values:
|
|
4259
|
+
values: n
|
|
4229
4260
|
}
|
|
4230
4261
|
};
|
|
4231
|
-
}(t,
|
|
4262
|
+
}(t, e);
|
|
4232
4263
|
}
|
|
4233
|
-
return function(t,
|
|
4264
|
+
return function(t, e) {
|
|
4234
4265
|
if (null === (t = getModularInstance(t))) return {
|
|
4235
4266
|
nullValue: "NULL_VALUE"
|
|
4236
4267
|
};
|
|
4237
|
-
if ("number" == typeof t) return
|
|
4268
|
+
if ("number" == typeof t) return we(e.q, t);
|
|
4238
4269
|
if ("boolean" == typeof t) return {
|
|
4239
4270
|
booleanValue: t
|
|
4240
4271
|
};
|
|
@@ -4242,37 +4273,37 @@ class Oe extends be {
|
|
|
4242
4273
|
stringValue: t
|
|
4243
4274
|
};
|
|
4244
4275
|
if (t instanceof Date) {
|
|
4245
|
-
const
|
|
4276
|
+
const n = gt.fromDate(t);
|
|
4246
4277
|
return {
|
|
4247
|
-
timestampValue:
|
|
4278
|
+
timestampValue: Ne(e.q, n)
|
|
4248
4279
|
};
|
|
4249
4280
|
}
|
|
4250
4281
|
if (t instanceof gt) {
|
|
4251
4282
|
// Firestore backend truncates precision down to microseconds. To ensure
|
|
4252
4283
|
// offline mode works the same with regards to truncation, perform the
|
|
4253
4284
|
// truncation immediately without waiting for the backend to do that.
|
|
4254
|
-
const
|
|
4285
|
+
const n = new gt(t.seconds, 1e3 * Math.floor(t.nanoseconds / 1e3));
|
|
4255
4286
|
return {
|
|
4256
|
-
timestampValue:
|
|
4287
|
+
timestampValue: Ne(e.q, n)
|
|
4257
4288
|
};
|
|
4258
4289
|
}
|
|
4259
|
-
if (t instanceof
|
|
4290
|
+
if (t instanceof vn) return {
|
|
4260
4291
|
geoPointValue: {
|
|
4261
4292
|
latitude: t.latitude,
|
|
4262
4293
|
longitude: t.longitude
|
|
4263
4294
|
}
|
|
4264
4295
|
};
|
|
4265
|
-
if (t instanceof
|
|
4266
|
-
bytesValue:
|
|
4296
|
+
if (t instanceof gn) return {
|
|
4297
|
+
bytesValue: $e(e.q, t._byteString)
|
|
4267
4298
|
};
|
|
4268
|
-
if (t instanceof
|
|
4269
|
-
const
|
|
4270
|
-
if (!r.isEqual(
|
|
4299
|
+
if (t instanceof an) {
|
|
4300
|
+
const n = e.databaseId, r = t.firestore._databaseId;
|
|
4301
|
+
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}`);
|
|
4271
4302
|
return {
|
|
4272
|
-
referenceValue:
|
|
4303
|
+
referenceValue: xe(t.firestore._databaseId || e.databaseId, t._key.path)
|
|
4273
4304
|
};
|
|
4274
4305
|
}
|
|
4275
|
-
throw
|
|
4306
|
+
throw e.ut(`Unsupported field value: ${it(t)}`);
|
|
4276
4307
|
}
|
|
4277
4308
|
/**
|
|
4278
4309
|
* Checks whether an object looks like a JSON object that should be converted
|
|
@@ -4280,56 +4311,56 @@ class Oe extends be {
|
|
|
4280
4311
|
* JSON objects since they should be converted to a struct value. Arrays, Dates,
|
|
4281
4312
|
* GeoPoints, etc. are not considered to look like JSON objects since they map
|
|
4282
4313
|
* to specific FieldValue types other than ObjectValue.
|
|
4283
|
-
*/ (t,
|
|
4314
|
+
*/ (t, e);
|
|
4284
4315
|
}
|
|
4285
4316
|
|
|
4286
|
-
function
|
|
4287
|
-
const
|
|
4317
|
+
function kn(t, e) {
|
|
4318
|
+
const n = {};
|
|
4288
4319
|
return !function(t) {
|
|
4289
|
-
for (const
|
|
4320
|
+
for (const e in t) if (Object.prototype.hasOwnProperty.call(t, e)) return !1;
|
|
4290
4321
|
return !0;
|
|
4291
4322
|
}(t) ? Et(t, ((t, r) => {
|
|
4292
|
-
const s =
|
|
4293
|
-
null != s && (
|
|
4323
|
+
const s = Un(r, e.nt(t));
|
|
4324
|
+
null != s && (n[t] = s);
|
|
4294
4325
|
})) :
|
|
4295
4326
|
// If we encounter an empty object, we explicitly add it to the update
|
|
4296
4327
|
// mask to ensure that the server creates a map entry.
|
|
4297
|
-
|
|
4328
|
+
e.path && e.path.length > 0 && e.fieldMask.push(e.path), {
|
|
4298
4329
|
mapValue: {
|
|
4299
|
-
fields:
|
|
4330
|
+
fields: n
|
|
4300
4331
|
}
|
|
4301
4332
|
};
|
|
4302
4333
|
}
|
|
4303
4334
|
|
|
4304
|
-
function
|
|
4305
|
-
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof gt || t instanceof
|
|
4335
|
+
function jn(t) {
|
|
4336
|
+
return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof gt || t instanceof vn || t instanceof gn || t instanceof an || t instanceof bn);
|
|
4306
4337
|
}
|
|
4307
4338
|
|
|
4308
|
-
function
|
|
4309
|
-
if (!
|
|
4339
|
+
function Mn(t, e, n) {
|
|
4340
|
+
if (!jn(n) || !function(t) {
|
|
4310
4341
|
return "object" == typeof t && null !== t && (Object.getPrototypeOf(t) === Object.prototype || null === Object.getPrototypeOf(t));
|
|
4311
|
-
}(
|
|
4312
|
-
const r = it(
|
|
4313
|
-
throw "an object" === r ?
|
|
4342
|
+
}(n)) {
|
|
4343
|
+
const r = it(n);
|
|
4344
|
+
throw "an object" === r ? e.ut(t + " a custom object") : e.ut(t + " " + r);
|
|
4314
4345
|
}
|
|
4315
4346
|
}
|
|
4316
4347
|
|
|
4317
4348
|
/**
|
|
4318
4349
|
* Helper that calls fromDotSeparatedString() but wraps any error thrown.
|
|
4319
|
-
*/ function
|
|
4350
|
+
*/ function Bn(t, e, n) {
|
|
4320
4351
|
if ((
|
|
4321
4352
|
// If required, replace the FieldPath Compat class with with the firestore-exp
|
|
4322
4353
|
// FieldPath.
|
|
4323
|
-
|
|
4324
|
-
if ("string" == typeof
|
|
4325
|
-
throw
|
|
4354
|
+
e = getModularInstance(e)) instanceof yn) return e._internalPath;
|
|
4355
|
+
if ("string" == typeof e) return Gn(t, e);
|
|
4356
|
+
throw Qn("Field path arguments must be of type string or ", t,
|
|
4326
4357
|
/* hasConverter= */ !1,
|
|
4327
|
-
/* path= */ void 0,
|
|
4358
|
+
/* path= */ void 0, n);
|
|
4328
4359
|
}
|
|
4329
4360
|
|
|
4330
4361
|
/**
|
|
4331
4362
|
* Matches any characters in a field path string that are reserved.
|
|
4332
|
-
*/ const
|
|
4363
|
+
*/ const zn = new RegExp("[~\\*/\\[\\]]");
|
|
4333
4364
|
|
|
4334
4365
|
/**
|
|
4335
4366
|
* Wraps fromDotSeparatedString with an error message about the method that
|
|
@@ -4339,30 +4370,30 @@ function Be(t, n, e) {
|
|
|
4339
4370
|
* split on dots.
|
|
4340
4371
|
* @param targetDoc - The document against which the field path will be
|
|
4341
4372
|
* evaluated.
|
|
4342
|
-
*/ function
|
|
4343
|
-
if (
|
|
4373
|
+
*/ function Gn(t, e, n) {
|
|
4374
|
+
if (e.search(zn) >= 0) throw Qn(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`, t,
|
|
4344
4375
|
/* hasConverter= */ !1,
|
|
4345
|
-
/* path= */ void 0,
|
|
4376
|
+
/* path= */ void 0, n);
|
|
4346
4377
|
try {
|
|
4347
|
-
return new
|
|
4378
|
+
return new yn(...e.split("."))._internalPath;
|
|
4348
4379
|
} catch (r) {
|
|
4349
|
-
throw
|
|
4380
|
+
throw Qn(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`, t,
|
|
4350
4381
|
/* hasConverter= */ !1,
|
|
4351
|
-
/* path= */ void 0,
|
|
4382
|
+
/* path= */ void 0, n);
|
|
4352
4383
|
}
|
|
4353
4384
|
}
|
|
4354
4385
|
|
|
4355
|
-
function
|
|
4386
|
+
function Qn(t, e, n, r, s) {
|
|
4356
4387
|
const i = r && !r.isEmpty(), o = void 0 !== s;
|
|
4357
|
-
let u = `Function ${
|
|
4358
|
-
|
|
4388
|
+
let u = `Function ${e}() called with invalid data`;
|
|
4389
|
+
n && (u += " (via `toFirestore()`)"), u += ". ";
|
|
4359
4390
|
let c = "";
|
|
4360
4391
|
return (i || o) && (c += " (found", i && (c += ` in field ${r}`), o && (c += ` in document ${s}`),
|
|
4361
4392
|
c += ")"), new U(A, u + t + c);
|
|
4362
4393
|
}
|
|
4363
4394
|
|
|
4364
|
-
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function
|
|
4365
|
-
return t.some((t => t.isEqual(
|
|
4395
|
+
/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */ function Wn(t, e) {
|
|
4396
|
+
return t.some((t => t.isEqual(e)));
|
|
4366
4397
|
}
|
|
4367
4398
|
|
|
4368
4399
|
/**
|
|
@@ -4389,14 +4420,14 @@ function We(t, n, e, r, s) {
|
|
|
4389
4420
|
* For a `DocumentSnapshot` that points to a non-existing document, any data
|
|
4390
4421
|
* access will return 'undefined'. You can use the `exists()` method to
|
|
4391
4422
|
* explicitly verify a document's existence.
|
|
4392
|
-
*/ class
|
|
4423
|
+
*/ class Yn {
|
|
4393
4424
|
// Note: This class is stripped down version of the DocumentSnapshot in
|
|
4394
4425
|
// the legacy SDK. The changes are:
|
|
4395
4426
|
// - No support for SnapshotMetadata.
|
|
4396
4427
|
// - No support for SnapshotOptions.
|
|
4397
4428
|
/** @hideconstructor protected */
|
|
4398
|
-
constructor(t,
|
|
4399
|
-
this._firestore = t, this._userDataWriter =
|
|
4429
|
+
constructor(t, e, n, r, s) {
|
|
4430
|
+
this._firestore = t, this._userDataWriter = e, this._key = n, this._document = r,
|
|
4400
4431
|
this._converter = s;
|
|
4401
4432
|
}
|
|
4402
4433
|
/** Property of the `DocumentSnapshot` that provides the document's ID. */ get id() {
|
|
@@ -4405,7 +4436,7 @@ function We(t, n, e, r, s) {
|
|
|
4405
4436
|
/**
|
|
4406
4437
|
* The `DocumentReference` for the document included in the `DocumentSnapshot`.
|
|
4407
4438
|
*/ get ref() {
|
|
4408
|
-
return new
|
|
4439
|
+
return new an(this._firestore, this._converter, this._key);
|
|
4409
4440
|
}
|
|
4410
4441
|
/**
|
|
4411
4442
|
* Signals whether or not the document at the snapshot's location exists.
|
|
@@ -4425,7 +4456,7 @@ function We(t, n, e, r, s) {
|
|
|
4425
4456
|
if (this._converter) {
|
|
4426
4457
|
// We only want to use the converter and create a new DocumentSnapshot
|
|
4427
4458
|
// if a converter has been provided.
|
|
4428
|
-
const t = new
|
|
4459
|
+
const t = new Hn(this._firestore, this._userDataWriter, this._key, this._document,
|
|
4429
4460
|
/* converter= */ null);
|
|
4430
4461
|
return this._converter.fromFirestore(t);
|
|
4431
4462
|
}
|
|
@@ -4445,8 +4476,8 @@ function We(t, n, e, r, s) {
|
|
|
4445
4476
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4446
4477
|
get(t) {
|
|
4447
4478
|
if (this._document) {
|
|
4448
|
-
const
|
|
4449
|
-
if (null !==
|
|
4479
|
+
const e = this._document.data.field(Xn("DocumentSnapshot.get", t));
|
|
4480
|
+
if (null !== e) return this._userDataWriter.convertValue(e);
|
|
4450
4481
|
}
|
|
4451
4482
|
}
|
|
4452
4483
|
}
|
|
@@ -4461,7 +4492,7 @@ function We(t, n, e, r, s) {
|
|
|
4461
4492
|
* `DocumentSnapshot`. Since query results contain only existing documents, the
|
|
4462
4493
|
* `exists` property will always be true and `data()` will never return
|
|
4463
4494
|
* 'undefined'.
|
|
4464
|
-
*/ class
|
|
4495
|
+
*/ class Hn extends Yn {
|
|
4465
4496
|
/**
|
|
4466
4497
|
* Retrieves all fields in the document as an `Object`.
|
|
4467
4498
|
*
|
|
@@ -4479,10 +4510,10 @@ function We(t, n, e, r, s) {
|
|
|
4479
4510
|
* array via the `docs` property or enumerated using the `forEach` method. The
|
|
4480
4511
|
* number of documents can be determined via the `empty` and `size`
|
|
4481
4512
|
* properties.
|
|
4482
|
-
*/ class
|
|
4513
|
+
*/ class Kn {
|
|
4483
4514
|
/** @hideconstructor */
|
|
4484
|
-
constructor(t,
|
|
4485
|
-
this._docs =
|
|
4515
|
+
constructor(t, e) {
|
|
4516
|
+
this._docs = e, this.query = t;
|
|
4486
4517
|
}
|
|
4487
4518
|
/** An array of all the documents in the `QuerySnapshot`. */ get docs() {
|
|
4488
4519
|
return [ ...this._docs ];
|
|
@@ -4499,8 +4530,8 @@ function We(t, n, e, r, s) {
|
|
|
4499
4530
|
* @param callback - A callback to be called with a `QueryDocumentSnapshot` for
|
|
4500
4531
|
* each document in the snapshot.
|
|
4501
4532
|
* @param thisArg - The `this` binding for the callback.
|
|
4502
|
-
*/ forEach(t,
|
|
4503
|
-
this._docs.forEach(t,
|
|
4533
|
+
*/ forEach(t, e) {
|
|
4534
|
+
this._docs.forEach(t, e);
|
|
4504
4535
|
}
|
|
4505
4536
|
}
|
|
4506
4537
|
|
|
@@ -4510,14 +4541,14 @@ function We(t, n, e, r, s) {
|
|
|
4510
4541
|
* @param left - A snapshot to compare.
|
|
4511
4542
|
* @param right - A snapshot to compare.
|
|
4512
4543
|
* @returns true if the snapshots are equal.
|
|
4513
|
-
*/ function
|
|
4514
|
-
return t = getModularInstance(t),
|
|
4544
|
+
*/ function Jn(t, e) {
|
|
4545
|
+
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));
|
|
4515
4546
|
}
|
|
4516
4547
|
|
|
4517
4548
|
/**
|
|
4518
4549
|
* Helper that calls `fromDotSeparatedString()` but wraps any error thrown.
|
|
4519
|
-
*/ function
|
|
4520
|
-
return "string" == typeof
|
|
4550
|
+
*/ function Xn(t, e) {
|
|
4551
|
+
return "string" == typeof e ? Gn(t, e) : e instanceof yn ? e._internalPath : e._delegate._internalPath;
|
|
4521
4552
|
}
|
|
4522
4553
|
|
|
4523
4554
|
/**
|
|
@@ -4544,7 +4575,7 @@ function We(t, n, e, r, s) {
|
|
|
4544
4575
|
* can then be passed to {@link query} to create a new query instance that
|
|
4545
4576
|
* also contains this `QueryConstraint`.
|
|
4546
4577
|
*/
|
|
4547
|
-
class
|
|
4578
|
+
class Zn {}
|
|
4548
4579
|
|
|
4549
4580
|
/**
|
|
4550
4581
|
* Creates a new immutable instance of {@link Query} that is extended to also include
|
|
@@ -4554,43 +4585,43 @@ class tr {}
|
|
|
4554
4585
|
* @param queryConstraints - The list of {@link QueryConstraint}s to apply.
|
|
4555
4586
|
* @throws if any of the provided query constraints cannot be combined with the
|
|
4556
4587
|
* existing or new constraints.
|
|
4557
|
-
*/ function
|
|
4558
|
-
for (const
|
|
4588
|
+
*/ function tr(t, ...e) {
|
|
4589
|
+
for (const n of e) t = n._apply(t);
|
|
4559
4590
|
return t;
|
|
4560
4591
|
}
|
|
4561
4592
|
|
|
4562
|
-
class er extends
|
|
4563
|
-
constructor(t,
|
|
4564
|
-
super(), this.dt = t, this.wt =
|
|
4593
|
+
class er extends Zn {
|
|
4594
|
+
constructor(t, e, n) {
|
|
4595
|
+
super(), this.dt = t, this.wt = e, this.yt = n, this.type = "where";
|
|
4565
4596
|
}
|
|
4566
4597
|
_apply(t) {
|
|
4567
|
-
const
|
|
4598
|
+
const e = Vn(t.firestore), n = function(t, e, n, r, s, i, o) {
|
|
4568
4599
|
let u;
|
|
4569
4600
|
if (s.isKeyField()) {
|
|
4570
4601
|
if ("array-contains" /* ARRAY_CONTAINS */ === i || "array-contains-any" /* ARRAY_CONTAINS_ANY */ === i) throw new U(A, `Invalid Query. You can't perform '${i}' queries on documentId().`);
|
|
4571
4602
|
if ("in" /* IN */ === i || "not-in" /* NOT_IN */ === i) {
|
|
4572
|
-
|
|
4573
|
-
const
|
|
4574
|
-
for (const
|
|
4603
|
+
pr(o, i);
|
|
4604
|
+
const e = [];
|
|
4605
|
+
for (const n of o) e.push(mr(r, t, n));
|
|
4575
4606
|
u = {
|
|
4576
4607
|
arrayValue: {
|
|
4577
|
-
values:
|
|
4608
|
+
values: e
|
|
4578
4609
|
}
|
|
4579
4610
|
};
|
|
4580
|
-
} else u =
|
|
4581
|
-
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i ||
|
|
4582
|
-
u =
|
|
4611
|
+
} else u = mr(r, t, o);
|
|
4612
|
+
} else "in" /* IN */ !== i && "not-in" /* NOT_IN */ !== i && "array-contains-any" /* ARRAY_CONTAINS_ANY */ !== i || pr(o, i),
|
|
4613
|
+
u = Ln(n, e, o,
|
|
4583
4614
|
/* allowArrays= */ "in" /* IN */ === i || "not-in" /* NOT_IN */ === i);
|
|
4584
4615
|
const c = Wt.create(s, i, u);
|
|
4585
|
-
return function(t,
|
|
4586
|
-
if (
|
|
4587
|
-
const
|
|
4588
|
-
if (null !==
|
|
4589
|
-
const r =
|
|
4590
|
-
null !== r &&
|
|
4616
|
+
return function(t, e) {
|
|
4617
|
+
if (e.N()) {
|
|
4618
|
+
const n = ae(t);
|
|
4619
|
+
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()}'`);
|
|
4620
|
+
const r = ce(t);
|
|
4621
|
+
null !== r && yr(t, e.field, r);
|
|
4591
4622
|
}
|
|
4592
|
-
const
|
|
4593
|
-
for (const
|
|
4623
|
+
const n = function(t, e) {
|
|
4624
|
+
for (const n of t.filters) if (e.indexOf(n.op) >= 0) return n.op;
|
|
4594
4625
|
return null;
|
|
4595
4626
|
}(t,
|
|
4596
4627
|
/**
|
|
@@ -4625,16 +4656,16 @@ class er extends tr {
|
|
|
4625
4656
|
default:
|
|
4626
4657
|
return [];
|
|
4627
4658
|
}
|
|
4628
|
-
}(
|
|
4629
|
-
if (null !==
|
|
4659
|
+
}(e.op));
|
|
4660
|
+
if (null !== n)
|
|
4630
4661
|
// Special case when it's a duplicate op to give a slightly clearer error message.
|
|
4631
|
-
throw
|
|
4662
|
+
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.`);
|
|
4632
4663
|
}(t, c), c;
|
|
4633
|
-
}(t._query, "where",
|
|
4634
|
-
return new
|
|
4635
|
-
const
|
|
4636
|
-
return new
|
|
4637
|
-
}(t._query,
|
|
4664
|
+
}(t._query, "where", e, t.firestore._databaseId, this.dt, this.wt, this.yt);
|
|
4665
|
+
return new hn(t.firestore, t.converter, function(t, e) {
|
|
4666
|
+
const n = t.filters.concat([ e ]);
|
|
4667
|
+
return new oe(t.path, t.collectionGroup, t.explicitOrderBy.slice(), n, t.limit, t.limitType, t.startAt, t.endAt);
|
|
4668
|
+
}(t._query, n));
|
|
4638
4669
|
}
|
|
4639
4670
|
}
|
|
4640
4671
|
|
|
@@ -4648,25 +4679,25 @@ class er extends tr {
|
|
|
4648
4679
|
* "<=", "!=").
|
|
4649
4680
|
* @param value - The value for comparison
|
|
4650
4681
|
* @returns The created {@link Query}.
|
|
4651
|
-
*/ function
|
|
4652
|
-
const r =
|
|
4653
|
-
return new er(s, r,
|
|
4682
|
+
*/ function nr(t, e, n) {
|
|
4683
|
+
const r = e, s = Xn("where", t);
|
|
4684
|
+
return new er(s, r, n);
|
|
4654
4685
|
}
|
|
4655
4686
|
|
|
4656
|
-
class
|
|
4657
|
-
constructor(t,
|
|
4658
|
-
super(), this.dt = t, this._t =
|
|
4687
|
+
class rr extends Zn {
|
|
4688
|
+
constructor(t, e) {
|
|
4689
|
+
super(), this.dt = t, this._t = e, this.type = "orderBy";
|
|
4659
4690
|
}
|
|
4660
4691
|
_apply(t) {
|
|
4661
|
-
const
|
|
4692
|
+
const e = function(t, e, n) {
|
|
4662
4693
|
if (null !== t.startAt) throw new U(A, "Invalid query. You must not call startAt() or startAfter() before calling orderBy().");
|
|
4663
4694
|
if (null !== t.endAt) throw new U(A, "Invalid query. You must not call endAt() or endBefore() before calling orderBy().");
|
|
4664
|
-
const r = new
|
|
4665
|
-
return function(t,
|
|
4666
|
-
if (null ===
|
|
4695
|
+
const r = new re(e, n);
|
|
4696
|
+
return function(t, e) {
|
|
4697
|
+
if (null === ce(t)) {
|
|
4667
4698
|
// This is the first order by. It must match any inequality.
|
|
4668
|
-
const
|
|
4669
|
-
null !==
|
|
4699
|
+
const n = ae(t);
|
|
4700
|
+
null !== n && yr(t, n, e.field);
|
|
4670
4701
|
}
|
|
4671
4702
|
}(t, r), r;
|
|
4672
4703
|
}
|
|
@@ -4681,11 +4712,11 @@ class sr extends tr {
|
|
|
4681
4712
|
* of the query or if any of the fields in the order by are an uncommitted
|
|
4682
4713
|
* server timestamp.
|
|
4683
4714
|
*/ (t._query, this.dt, this._t);
|
|
4684
|
-
return new
|
|
4715
|
+
return new hn(t.firestore, t.converter, function(t, e) {
|
|
4685
4716
|
// TODO(dimond): validate that orderBy does not list the same key twice.
|
|
4686
|
-
const
|
|
4687
|
-
return new
|
|
4688
|
-
}(t._query,
|
|
4717
|
+
const n = t.explicitOrderBy.concat([ e ]);
|
|
4718
|
+
return new oe(t.path, t.collectionGroup, n, t.filters.slice(), t.limit, t.limitType, t.startAt, t.endAt);
|
|
4719
|
+
}(t._query, e));
|
|
4689
4720
|
}
|
|
4690
4721
|
}
|
|
4691
4722
|
|
|
@@ -4697,19 +4728,19 @@ class sr extends tr {
|
|
|
4697
4728
|
* @param directionStr - Optional direction to sort by ('asc' or 'desc'). If
|
|
4698
4729
|
* not specified, order will be ascending.
|
|
4699
4730
|
* @returns The created {@link Query}.
|
|
4700
|
-
*/ function
|
|
4701
|
-
const
|
|
4702
|
-
return new
|
|
4731
|
+
*/ function sr(t, e = "asc") {
|
|
4732
|
+
const n = e, r = Xn("orderBy", t);
|
|
4733
|
+
return new rr(r, n);
|
|
4703
4734
|
}
|
|
4704
4735
|
|
|
4705
|
-
class
|
|
4706
|
-
constructor(t,
|
|
4707
|
-
super(), this.type = t, this.gt =
|
|
4736
|
+
class ir extends Zn {
|
|
4737
|
+
constructor(t, e, n) {
|
|
4738
|
+
super(), this.type = t, this.gt = e, this.bt = n;
|
|
4708
4739
|
}
|
|
4709
4740
|
_apply(t) {
|
|
4710
|
-
return new
|
|
4711
|
-
return new
|
|
4712
|
-
}(t._query, this.gt, this.
|
|
4741
|
+
return new hn(t.firestore, t.converter, function(t, e, n) {
|
|
4742
|
+
return new oe(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), e, n, t.startAt, t.endAt);
|
|
4743
|
+
}(t._query, this.gt, this.bt));
|
|
4713
4744
|
}
|
|
4714
4745
|
}
|
|
4715
4746
|
|
|
@@ -4718,8 +4749,8 @@ class or extends tr {
|
|
|
4718
4749
|
*
|
|
4719
4750
|
* @param limit - The maximum number of items to return.
|
|
4720
4751
|
* @returns The created {@link Query}.
|
|
4721
|
-
*/ function
|
|
4722
|
-
return ut("limit", t), new
|
|
4752
|
+
*/ function or(t) {
|
|
4753
|
+
return ut("limit", t), new ir("limit", t, "F" /* First */);
|
|
4723
4754
|
}
|
|
4724
4755
|
|
|
4725
4756
|
/**
|
|
@@ -4730,54 +4761,56 @@ class or extends tr {
|
|
|
4730
4761
|
*
|
|
4731
4762
|
* @param limit - The maximum number of items to return.
|
|
4732
4763
|
* @returns The created {@link Query}.
|
|
4733
|
-
*/ function
|
|
4734
|
-
return ut("limitToLast", t), new
|
|
4764
|
+
*/ function ur(t) {
|
|
4765
|
+
return ut("limitToLast", t), new ir("limitToLast", t, "L" /* Last */);
|
|
4735
4766
|
}
|
|
4736
4767
|
|
|
4737
|
-
class
|
|
4738
|
-
constructor(t,
|
|
4739
|
-
super(), this.type = t, this.
|
|
4768
|
+
class cr extends Zn {
|
|
4769
|
+
constructor(t, e, n) {
|
|
4770
|
+
super(), this.type = t, this.vt = e, this.Et = n;
|
|
4740
4771
|
}
|
|
4741
4772
|
_apply(t) {
|
|
4742
|
-
const
|
|
4743
|
-
return new
|
|
4744
|
-
return new
|
|
4745
|
-
}(t._query,
|
|
4773
|
+
const e = wr(t, this.type, this.vt, this.Et);
|
|
4774
|
+
return new hn(t.firestore, t.converter, function(t, e) {
|
|
4775
|
+
return new oe(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, e, t.endAt);
|
|
4776
|
+
}(t._query, e));
|
|
4746
4777
|
}
|
|
4747
4778
|
}
|
|
4748
4779
|
|
|
4749
|
-
function
|
|
4750
|
-
return new
|
|
4780
|
+
function ar(...t) {
|
|
4781
|
+
return new cr("startAt", t,
|
|
4782
|
+
/*inclusive=*/ !0);
|
|
4751
4783
|
}
|
|
4752
4784
|
|
|
4753
|
-
function
|
|
4754
|
-
return new
|
|
4755
|
-
/*
|
|
4785
|
+
function hr(...t) {
|
|
4786
|
+
return new cr("startAfter", t,
|
|
4787
|
+
/*inclusive=*/ !1);
|
|
4756
4788
|
}
|
|
4757
4789
|
|
|
4758
|
-
class
|
|
4759
|
-
constructor(t,
|
|
4760
|
-
super(), this.type = t, this.
|
|
4790
|
+
class lr extends Zn {
|
|
4791
|
+
constructor(t, e, n) {
|
|
4792
|
+
super(), this.type = t, this.vt = e, this.Et = n;
|
|
4761
4793
|
}
|
|
4762
4794
|
_apply(t) {
|
|
4763
|
-
const
|
|
4764
|
-
return new
|
|
4765
|
-
return new
|
|
4766
|
-
}(t._query,
|
|
4795
|
+
const e = wr(t, this.type, this.vt, this.Et);
|
|
4796
|
+
return new hn(t.firestore, t.converter, function(t, e) {
|
|
4797
|
+
return new oe(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, t.startAt, e);
|
|
4798
|
+
}(t._query, e));
|
|
4767
4799
|
}
|
|
4768
4800
|
}
|
|
4769
4801
|
|
|
4770
|
-
function
|
|
4771
|
-
return new
|
|
4802
|
+
function fr(...t) {
|
|
4803
|
+
return new lr("endBefore", t,
|
|
4804
|
+
/*inclusive=*/ !1);
|
|
4772
4805
|
}
|
|
4773
4806
|
|
|
4774
|
-
function
|
|
4775
|
-
return new
|
|
4807
|
+
function dr(...t) {
|
|
4808
|
+
return new lr("endAt", t, /*inclusive=*/ !0);
|
|
4776
4809
|
}
|
|
4777
4810
|
|
|
4778
|
-
/** Helper function to create a bound from a document or fields */ function
|
|
4779
|
-
if (
|
|
4780
|
-
if (!r) throw new U(P, `Can't use a DocumentSnapshot that doesn't exist for ${
|
|
4811
|
+
/** Helper function to create a bound from a document or fields */ function wr(t, e, n, r) {
|
|
4812
|
+
if (n[0] = getModularInstance(n[0]), n[0] instanceof Yn) return function(t, e, n, r, s) {
|
|
4813
|
+
if (!r) throw new U(P, `Can't use a DocumentSnapshot that doesn't exist for ${n}().`);
|
|
4781
4814
|
const i = [];
|
|
4782
4815
|
// Because people expect to continue/end a query at the exact document
|
|
4783
4816
|
// provided, we need to use the implicit sort order rather than the explicit
|
|
@@ -4786,23 +4819,23 @@ function wr(...t) {
|
|
|
4786
4819
|
// the provided document. Without the key (by using the explicit sort
|
|
4787
4820
|
// orders), multiple documents could match the position, yielding duplicate
|
|
4788
4821
|
// results.
|
|
4789
|
-
for (const
|
|
4790
|
-
const t = r.data.field(
|
|
4791
|
-
if (Dt(t)) throw new U(A, 'Invalid query. You are trying to start or end a query using a document for which the field "' +
|
|
4822
|
+
for (const n of le(t)) if (n.field.isKeyField()) i.push(Ct(e, r.key)); else {
|
|
4823
|
+
const t = r.data.field(n.field);
|
|
4824
|
+
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.)');
|
|
4792
4825
|
if (null === t) {
|
|
4793
|
-
const t =
|
|
4826
|
+
const t = n.field.canonicalString();
|
|
4794
4827
|
throw new U(A, `Invalid query. You are trying to start or end a query using a document for which the field '${t}' (used as the orderBy) does not exist.`);
|
|
4795
4828
|
}
|
|
4796
4829
|
i.push(t);
|
|
4797
4830
|
}
|
|
4798
|
-
return new
|
|
4831
|
+
return new ne(i, s);
|
|
4799
4832
|
}
|
|
4800
4833
|
/**
|
|
4801
4834
|
* Converts a list of field values to a `Bound` for the given query.
|
|
4802
|
-
*/ (t._query, t.firestore._databaseId,
|
|
4835
|
+
*/ (t._query, t.firestore._databaseId, e, n[0]._document, r);
|
|
4803
4836
|
{
|
|
4804
|
-
const s =
|
|
4805
|
-
return function(t,
|
|
4837
|
+
const s = Vn(t.firestore);
|
|
4838
|
+
return function(t, e, n, r, s, i) {
|
|
4806
4839
|
// Use explicit order by's because it has to match the query the user made
|
|
4807
4840
|
const o = t.explicitOrderBy;
|
|
4808
4841
|
if (s.length > o.length) throw new U(A, `Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);
|
|
@@ -4811,48 +4844,48 @@ function wr(...t) {
|
|
|
4811
4844
|
const c = s[i];
|
|
4812
4845
|
if (o[i].field.isKeyField()) {
|
|
4813
4846
|
if ("string" != typeof c) throw new U(A, `Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);
|
|
4814
|
-
if (!
|
|
4815
|
-
const
|
|
4816
|
-
if (!
|
|
4817
|
-
const s = new
|
|
4818
|
-
u.push(Ct(
|
|
4847
|
+
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.`);
|
|
4848
|
+
const n = t.path.child(X.fromString(c));
|
|
4849
|
+
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.`);
|
|
4850
|
+
const s = new et(n);
|
|
4851
|
+
u.push(Ct(e, s));
|
|
4819
4852
|
} else {
|
|
4820
|
-
const t =
|
|
4853
|
+
const t = Ln(n, r, c);
|
|
4821
4854
|
u.push(t);
|
|
4822
4855
|
}
|
|
4823
4856
|
}
|
|
4824
|
-
return new
|
|
4857
|
+
return new ne(u, i);
|
|
4825
4858
|
}
|
|
4826
4859
|
/**
|
|
4827
4860
|
* Parses the given `documentIdValue` into a `ReferenceValue`, throwing
|
|
4828
4861
|
* appropriate errors if the value is anything other than a `DocumentReference`
|
|
4829
4862
|
* or `string`, or if the string is malformed.
|
|
4830
|
-
*/ (t._query, t.firestore._databaseId, s,
|
|
4863
|
+
*/ (t._query, t.firestore._databaseId, s, e, n, r);
|
|
4831
4864
|
}
|
|
4832
4865
|
}
|
|
4833
4866
|
|
|
4834
|
-
function
|
|
4835
|
-
if ("string" == typeof (
|
|
4836
|
-
if ("" ===
|
|
4837
|
-
if (!
|
|
4838
|
-
const r =
|
|
4839
|
-
if (!
|
|
4840
|
-
return Ct(t, new
|
|
4867
|
+
function mr(t, e, n) {
|
|
4868
|
+
if ("string" == typeof (n = getModularInstance(n))) {
|
|
4869
|
+
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.");
|
|
4870
|
+
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.`);
|
|
4871
|
+
const r = e.path.child(X.fromString(n));
|
|
4872
|
+
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}).`);
|
|
4873
|
+
return Ct(t, new et(r));
|
|
4841
4874
|
}
|
|
4842
|
-
if (
|
|
4843
|
-
throw new U(A, `Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${it(
|
|
4875
|
+
if (n instanceof an) return Ct(t, n._key);
|
|
4876
|
+
throw new U(A, `Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${it(n)}.`);
|
|
4844
4877
|
}
|
|
4845
4878
|
|
|
4846
4879
|
/**
|
|
4847
4880
|
* Validates that the value passed into a disjunctive filter satisfies all
|
|
4848
4881
|
* array requirements.
|
|
4849
|
-
*/ function
|
|
4850
|
-
if (!Array.isArray(t) || 0 === t.length) throw new U(A, `Invalid Query. A non-empty array is required for '${
|
|
4851
|
-
if (t.length > 10) throw new U(A, `Invalid Query. '${
|
|
4882
|
+
*/ function pr(t, e) {
|
|
4883
|
+
if (!Array.isArray(t) || 0 === t.length) throw new U(A, `Invalid Query. A non-empty array is required for '${e.toString()}' filters.`);
|
|
4884
|
+
if (t.length > 10) throw new U(A, `Invalid Query. '${e.toString()}' filters support a maximum of 10 elements in the value array.`);
|
|
4852
4885
|
}
|
|
4853
4886
|
|
|
4854
|
-
function
|
|
4855
|
-
if (!
|
|
4887
|
+
function yr(t, e, n) {
|
|
4888
|
+
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.`);
|
|
4856
4889
|
}
|
|
4857
4890
|
|
|
4858
4891
|
/**
|
|
@@ -4902,17 +4935,17 @@ function _r(t, n, e) {
|
|
|
4902
4935
|
* their `set()` or fails due to invalid data originating from a `toFirestore()`
|
|
4903
4936
|
* call.
|
|
4904
4937
|
*/
|
|
4905
|
-
function
|
|
4938
|
+
function _r(t, e, n) {
|
|
4906
4939
|
let r;
|
|
4907
4940
|
// Cast to `any` in order to satisfy the union type constraint on
|
|
4908
4941
|
// toFirestore().
|
|
4909
4942
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4910
|
-
return r = t ?
|
|
4943
|
+
return r = t ? n && (n.merge || n.mergeFields) ? t.toFirestore(e, n) : t.toFirestore(e) : e,
|
|
4911
4944
|
r;
|
|
4912
4945
|
}
|
|
4913
4946
|
|
|
4914
|
-
class
|
|
4915
|
-
convertValue(t,
|
|
4947
|
+
class gr extends class {
|
|
4948
|
+
convertValue(t, e = "none") {
|
|
4916
4949
|
switch (St(t)) {
|
|
4917
4950
|
case 0 /* NullValue */ :
|
|
4918
4951
|
return null;
|
|
@@ -4927,7 +4960,7 @@ class vr extends class {
|
|
|
4927
4960
|
return this.convertTimestamp(t.timestampValue);
|
|
4928
4961
|
|
|
4929
4962
|
case 4 /* ServerTimestampValue */ :
|
|
4930
|
-
return this.convertServerTimestamp(t,
|
|
4963
|
+
return this.convertServerTimestamp(t, e);
|
|
4931
4964
|
|
|
4932
4965
|
case 5 /* StringValue */ :
|
|
4933
4966
|
return t.stringValue;
|
|
@@ -4942,32 +4975,32 @@ class vr extends class {
|
|
|
4942
4975
|
return this.convertGeoPoint(t.geoPointValue);
|
|
4943
4976
|
|
|
4944
4977
|
case 9 /* ArrayValue */ :
|
|
4945
|
-
return this.convertArray(t.arrayValue,
|
|
4978
|
+
return this.convertArray(t.arrayValue, e);
|
|
4946
4979
|
|
|
4947
4980
|
case 10 /* ObjectValue */ :
|
|
4948
|
-
return this.convertObject(t.mapValue,
|
|
4981
|
+
return this.convertObject(t.mapValue, e);
|
|
4949
4982
|
|
|
4950
4983
|
default:
|
|
4951
4984
|
throw g();
|
|
4952
4985
|
}
|
|
4953
4986
|
}
|
|
4954
|
-
convertObject(t,
|
|
4955
|
-
const
|
|
4987
|
+
convertObject(t, e) {
|
|
4988
|
+
const n = {};
|
|
4956
4989
|
return Et(t.fields, ((t, r) => {
|
|
4957
|
-
|
|
4958
|
-
})),
|
|
4990
|
+
n[t] = this.convertValue(r, e);
|
|
4991
|
+
})), n;
|
|
4959
4992
|
}
|
|
4960
4993
|
convertGeoPoint(t) {
|
|
4961
|
-
return new
|
|
4994
|
+
return new vn(Pt(t.latitude), Pt(t.longitude));
|
|
4962
4995
|
}
|
|
4963
|
-
convertArray(t,
|
|
4964
|
-
return (t.values || []).map((t => this.convertValue(t,
|
|
4996
|
+
convertArray(t, e) {
|
|
4997
|
+
return (t.values || []).map((t => this.convertValue(t, e)));
|
|
4965
4998
|
}
|
|
4966
|
-
convertServerTimestamp(t,
|
|
4967
|
-
switch (
|
|
4999
|
+
convertServerTimestamp(t, e) {
|
|
5000
|
+
switch (e) {
|
|
4968
5001
|
case "previous":
|
|
4969
|
-
const
|
|
4970
|
-
return null ==
|
|
5002
|
+
const n = Nt(t);
|
|
5003
|
+
return null == n ? null : this.convertValue(n, e);
|
|
4971
5004
|
|
|
4972
5005
|
case "estimate":
|
|
4973
5006
|
return this.convertTimestamp($t(t));
|
|
@@ -4977,16 +5010,16 @@ class vr extends class {
|
|
|
4977
5010
|
}
|
|
4978
5011
|
}
|
|
4979
5012
|
convertTimestamp(t) {
|
|
4980
|
-
const
|
|
4981
|
-
return new gt(
|
|
5013
|
+
const e = Rt(t);
|
|
5014
|
+
return new gt(e.seconds, e.nanos);
|
|
4982
5015
|
}
|
|
4983
|
-
convertDocumentKey(t,
|
|
4984
|
-
const
|
|
4985
|
-
|
|
4986
|
-
const r = new K(
|
|
4987
|
-
return r.isEqual(
|
|
5016
|
+
convertDocumentKey(t, e) {
|
|
5017
|
+
const n = X.fromString(t);
|
|
5018
|
+
b(We(n));
|
|
5019
|
+
const r = new K(n.get(1), n.get(3)), s = new et(n.popFirst(5));
|
|
5020
|
+
return r.isEqual(e) ||
|
|
4988
5021
|
// TODO(b/64130202): Somehow support foreign references.
|
|
4989
|
-
p(`Document ${s} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${
|
|
5022
|
+
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.`),
|
|
4990
5023
|
s;
|
|
4991
5024
|
}
|
|
4992
5025
|
} {
|
|
@@ -4994,11 +5027,11 @@ class vr extends class {
|
|
|
4994
5027
|
super(), this.firestore = t;
|
|
4995
5028
|
}
|
|
4996
5029
|
convertBytes(t) {
|
|
4997
|
-
return new
|
|
5030
|
+
return new gn(t);
|
|
4998
5031
|
}
|
|
4999
5032
|
convertReference(t) {
|
|
5000
|
-
const
|
|
5001
|
-
return new
|
|
5033
|
+
const e = this.convertDocumentKey(t, this.firestore._databaseId);
|
|
5034
|
+
return new an(this.firestore, /* converter= */ null, e);
|
|
5002
5035
|
}
|
|
5003
5036
|
}
|
|
5004
5037
|
|
|
@@ -5015,11 +5048,11 @@ class vr extends class {
|
|
|
5015
5048
|
* @returns A Promise resolved with a `DocumentSnapshot` containing the current
|
|
5016
5049
|
* document contents.
|
|
5017
5050
|
*/ function br(t) {
|
|
5018
|
-
const
|
|
5019
|
-
return
|
|
5020
|
-
|
|
5021
|
-
const r =
|
|
5022
|
-
return new
|
|
5051
|
+
const e = en((t = ot(t, an)).firestore), n = new gr(t.firestore);
|
|
5052
|
+
return Xe(e, [ t._key ]).then((e => {
|
|
5053
|
+
b(1 === e.length);
|
|
5054
|
+
const r = e[0];
|
|
5055
|
+
return new Yn(t.firestore, n, t._key, r.isFoundDocument() ? r : null, t.converter);
|
|
5023
5056
|
}));
|
|
5024
5057
|
}
|
|
5025
5058
|
|
|
@@ -5034,33 +5067,33 @@ class vr extends class {
|
|
|
5034
5067
|
*
|
|
5035
5068
|
* @param query - The `Query` to execute.
|
|
5036
5069
|
* @returns A Promise that will be resolved with the results of the query.
|
|
5037
|
-
*/ function
|
|
5070
|
+
*/ function vr(t) {
|
|
5038
5071
|
!function(t) {
|
|
5039
|
-
if (
|
|
5040
|
-
}((t = ot(t,
|
|
5041
|
-
const
|
|
5042
|
-
return
|
|
5043
|
-
const r =
|
|
5044
|
-
return
|
|
5072
|
+
if (ue(t) && 0 === t.explicitOrderBy.length) throw new U(q, "limitToLast() queries require specifying at least one orderBy() clause");
|
|
5073
|
+
}((t = ot(t, hn))._query);
|
|
5074
|
+
const e = en(t.firestore), n = new gr(t.firestore);
|
|
5075
|
+
return Ze(e, t._query).then((e => {
|
|
5076
|
+
const r = e.map((e => new Hn(t.firestore, n, e.key, e, t.converter)));
|
|
5077
|
+
return ue(t._query) &&
|
|
5045
5078
|
// Limit to last queries reverse the orderBy constraint that was
|
|
5046
5079
|
// specified by the user. As such, we need to reverse the order of the
|
|
5047
5080
|
// results to return the documents in the expected order.
|
|
5048
|
-
r.reverse(), new
|
|
5081
|
+
r.reverse(), new Kn(t, r);
|
|
5049
5082
|
}));
|
|
5050
5083
|
}
|
|
5051
5084
|
|
|
5052
|
-
function
|
|
5053
|
-
const r =
|
|
5054
|
-
return
|
|
5085
|
+
function Er(t, e, n) {
|
|
5086
|
+
const r = _r((t = ot(t, an)).converter, e, n), s = Dn(Vn(t.firestore), "setDoc", t._key, r, null !== t.converter, n);
|
|
5087
|
+
return Je(en(t.firestore), [ s.toMutation(t._key, ve.none()) ]);
|
|
5055
5088
|
}
|
|
5056
5089
|
|
|
5057
|
-
function
|
|
5058
|
-
const s =
|
|
5090
|
+
function Tr(t, e, n, ...r) {
|
|
5091
|
+
const s = Vn((t = ot(t, an)).firestore);
|
|
5059
5092
|
// For Compat types, we have to "extract" the underlying types before
|
|
5060
5093
|
// performing validation.
|
|
5061
5094
|
let i;
|
|
5062
|
-
i = "string" == typeof (
|
|
5063
|
-
return
|
|
5095
|
+
i = "string" == typeof (e = getModularInstance(e)) || e instanceof yn ? Cn(s, "updateDoc", t._key, e, n, r) : On(s, "updateDoc", t._key, e);
|
|
5096
|
+
return Je(en(t.firestore), [ i.toMutation(t._key, ve.exists(!0)) ]);
|
|
5064
5097
|
}
|
|
5065
5098
|
|
|
5066
5099
|
/**
|
|
@@ -5074,8 +5107,8 @@ function Ir(t, n, e, ...r) {
|
|
|
5074
5107
|
* @param reference - A reference to the document to delete.
|
|
5075
5108
|
* @returns A `Promise` resolved once the document has been successfully
|
|
5076
5109
|
* deleted from the backend.
|
|
5077
|
-
*/ function
|
|
5078
|
-
return
|
|
5110
|
+
*/ function Ir(t) {
|
|
5111
|
+
return Je(en((t = ot(t, an)).firestore), [ new Ae(t._key, ve.none()) ]);
|
|
5079
5112
|
}
|
|
5080
5113
|
|
|
5081
5114
|
/**
|
|
@@ -5092,9 +5125,9 @@ function Ir(t, n, e, ...r) {
|
|
|
5092
5125
|
* @throws Error - If the provided input is not a valid Firestore document.
|
|
5093
5126
|
* @returns A `Promise` resolved with a `DocumentReference` pointing to the
|
|
5094
5127
|
* newly created document after it has been written to the backend.
|
|
5095
|
-
*/ function
|
|
5096
|
-
const
|
|
5097
|
-
return
|
|
5128
|
+
*/ function Ar(t, e) {
|
|
5129
|
+
const n = wn(t = ot(t, ln)), r = _r(t.converter, e), s = Dn(Vn(t.firestore), "addDoc", n._key, r, null !== n.converter, {});
|
|
5130
|
+
return Je(en(t.firestore), [ s.toMutation(n._key, ve.exists(!1)) ]).then((() => n));
|
|
5098
5131
|
}
|
|
5099
5132
|
|
|
5100
5133
|
/**
|
|
@@ -5116,15 +5149,15 @@ function Ir(t, n, e, ...r) {
|
|
|
5116
5149
|
/**
|
|
5117
5150
|
* Returns a sentinel for use with {@link @firebase/firestore/lite#(updateDoc:1)} or
|
|
5118
5151
|
* {@link @firebase/firestore/lite#(setDoc:1)} with `{merge: true}` to mark a field for deletion.
|
|
5119
|
-
*/ function
|
|
5120
|
-
return new
|
|
5152
|
+
*/ function Rr() {
|
|
5153
|
+
return new Nn("deleteField");
|
|
5121
5154
|
}
|
|
5122
5155
|
|
|
5123
5156
|
/**
|
|
5124
5157
|
* Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
|
|
5125
5158
|
* include a server-generated timestamp in the written data.
|
|
5126
|
-
*/ function
|
|
5127
|
-
return new
|
|
5159
|
+
*/ function Pr() {
|
|
5160
|
+
return new Sn("serverTimestamp");
|
|
5128
5161
|
}
|
|
5129
5162
|
|
|
5130
5163
|
/**
|
|
@@ -5138,10 +5171,10 @@ function Ir(t, n, e, ...r) {
|
|
|
5138
5171
|
* @param elements - The elements to union into the array.
|
|
5139
5172
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5140
5173
|
* `updateDoc()`.
|
|
5141
|
-
*/ function
|
|
5174
|
+
*/ function Vr(...t) {
|
|
5142
5175
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5143
5176
|
// update() since we'd need the Firestore instance to do this.
|
|
5144
|
-
return new
|
|
5177
|
+
return new Fn("arrayUnion", t);
|
|
5145
5178
|
}
|
|
5146
5179
|
|
|
5147
5180
|
/**
|
|
@@ -5154,10 +5187,10 @@ function Ir(t, n, e, ...r) {
|
|
|
5154
5187
|
* @param elements - The elements to remove from the array.
|
|
5155
5188
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5156
5189
|
* `updateDoc()`
|
|
5157
|
-
*/ function
|
|
5190
|
+
*/ function Dr(...t) {
|
|
5158
5191
|
// NOTE: We don't actually parse the data until it's used in set() or
|
|
5159
5192
|
// update() since we'd need the Firestore instance to do this.
|
|
5160
|
-
return new
|
|
5193
|
+
return new xn("arrayRemove", t);
|
|
5161
5194
|
}
|
|
5162
5195
|
|
|
5163
5196
|
/**
|
|
@@ -5178,8 +5211,8 @@ function Ir(t, n, e, ...r) {
|
|
|
5178
5211
|
* @param n - The value to increment by.
|
|
5179
5212
|
* @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
|
|
5180
5213
|
* `updateDoc()`
|
|
5181
|
-
*/ function
|
|
5182
|
-
return new
|
|
5214
|
+
*/ function Nr(t) {
|
|
5215
|
+
return new qn("increment", t);
|
|
5183
5216
|
}
|
|
5184
5217
|
|
|
5185
5218
|
/**
|
|
@@ -5205,25 +5238,25 @@ function Ir(t, n, e, ...r) {
|
|
|
5205
5238
|
* provides methods for adding writes to the write batch. None of the writes
|
|
5206
5239
|
* will be committed (or visible locally) until {@link WriteBatch.commit} is
|
|
5207
5240
|
* called.
|
|
5208
|
-
*/ class
|
|
5241
|
+
*/ class $r {
|
|
5209
5242
|
/** @hideconstructor */
|
|
5210
|
-
constructor(t,
|
|
5211
|
-
this._firestore = t, this._commitHandler =
|
|
5212
|
-
this._dataReader =
|
|
5243
|
+
constructor(t, e) {
|
|
5244
|
+
this._firestore = t, this._commitHandler = e, this._mutations = [], this._committed = !1,
|
|
5245
|
+
this._dataReader = Vn(t);
|
|
5213
5246
|
}
|
|
5214
|
-
set(t,
|
|
5247
|
+
set(t, e, n) {
|
|
5215
5248
|
this._verifyNotCommitted();
|
|
5216
|
-
const r =
|
|
5217
|
-
return this._mutations.push(i.toMutation(r._key,
|
|
5249
|
+
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);
|
|
5250
|
+
return this._mutations.push(i.toMutation(r._key, ve.none())), this;
|
|
5218
5251
|
}
|
|
5219
|
-
update(t,
|
|
5252
|
+
update(t, e, n, ...r) {
|
|
5220
5253
|
this._verifyNotCommitted();
|
|
5221
|
-
const s =
|
|
5254
|
+
const s = Sr(t, this._firestore);
|
|
5222
5255
|
// For Compat types, we have to "extract" the underlying types before
|
|
5223
5256
|
// performing validation.
|
|
5224
5257
|
let i;
|
|
5225
|
-
return i = "string" == typeof (
|
|
5226
|
-
this._mutations.push(i.toMutation(s._key,
|
|
5258
|
+
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),
|
|
5259
|
+
this._mutations.push(i.toMutation(s._key, ve.exists(!0))), this;
|
|
5227
5260
|
}
|
|
5228
5261
|
/**
|
|
5229
5262
|
* Deletes the document referred to by the provided {@link DocumentReference}.
|
|
@@ -5232,8 +5265,8 @@ function Ir(t, n, e, ...r) {
|
|
|
5232
5265
|
* @returns This `WriteBatch` instance. Used for chaining method calls.
|
|
5233
5266
|
*/ delete(t) {
|
|
5234
5267
|
this._verifyNotCommitted();
|
|
5235
|
-
const
|
|
5236
|
-
return this._mutations = this._mutations.concat(new
|
|
5268
|
+
const e = Sr(t, this._firestore);
|
|
5269
|
+
return this._mutations = this._mutations.concat(new Ae(e._key, ve.none())), this;
|
|
5237
5270
|
}
|
|
5238
5271
|
/**
|
|
5239
5272
|
* Commits all of the writes in this write batch as a single atomic unit.
|
|
@@ -5254,8 +5287,8 @@ function Ir(t, n, e, ...r) {
|
|
|
5254
5287
|
}
|
|
5255
5288
|
}
|
|
5256
5289
|
|
|
5257
|
-
function
|
|
5258
|
-
if ((t = getModularInstance(t)).firestore !==
|
|
5290
|
+
function Sr(t, e) {
|
|
5291
|
+
if ((t = getModularInstance(t)).firestore !== e) throw new U(A, "Provided document reference is from a different Firestore instance.");
|
|
5259
5292
|
return t;
|
|
5260
5293
|
}
|
|
5261
5294
|
|
|
@@ -5271,9 +5304,9 @@ function Fr(t, n) {
|
|
|
5271
5304
|
*
|
|
5272
5305
|
* @returns A `WriteBatch` that can be used to atomically execute multiple
|
|
5273
5306
|
* writes.
|
|
5274
|
-
*/ function
|
|
5275
|
-
const
|
|
5276
|
-
return new
|
|
5307
|
+
*/ function Fr(t) {
|
|
5308
|
+
const e = en(t = ot(t, rn));
|
|
5309
|
+
return new $r(t, (t => Je(e, t)));
|
|
5277
5310
|
}
|
|
5278
5311
|
|
|
5279
5312
|
/**
|
|
@@ -5295,7 +5328,7 @@ function Fr(t, n) {
|
|
|
5295
5328
|
/**
|
|
5296
5329
|
* Internal transaction object responsible for accumulating the mutations to
|
|
5297
5330
|
* perform and the base versions for any documents read.
|
|
5298
|
-
*/ class
|
|
5331
|
+
*/ class xr {
|
|
5299
5332
|
constructor(t) {
|
|
5300
5333
|
this.datastore = t,
|
|
5301
5334
|
// The version of each document that was read during this transaction.
|
|
@@ -5315,66 +5348,66 @@ function Fr(t, n) {
|
|
|
5315
5348
|
}
|
|
5316
5349
|
async lookup(t) {
|
|
5317
5350
|
if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new U(A, "Firestore transactions require all reads to be executed before all writes.");
|
|
5318
|
-
const
|
|
5319
|
-
return
|
|
5351
|
+
const e = await Xe(this.datastore, t);
|
|
5352
|
+
return e.forEach((t => this.recordVersion(t))), e;
|
|
5320
5353
|
}
|
|
5321
|
-
set(t,
|
|
5322
|
-
this.write(
|
|
5354
|
+
set(t, e) {
|
|
5355
|
+
this.write(e.toMutation(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5323
5356
|
}
|
|
5324
|
-
update(t,
|
|
5357
|
+
update(t, e) {
|
|
5325
5358
|
try {
|
|
5326
|
-
this.write(
|
|
5359
|
+
this.write(e.toMutation(t, this.preconditionForUpdate(t)));
|
|
5327
5360
|
} catch (t) {
|
|
5328
5361
|
this.lastWriteError = t;
|
|
5329
5362
|
}
|
|
5330
5363
|
this.writtenDocs.add(t.toString());
|
|
5331
5364
|
}
|
|
5332
5365
|
delete(t) {
|
|
5333
|
-
this.write(new
|
|
5366
|
+
this.write(new Ae(t, this.precondition(t))), this.writtenDocs.add(t.toString());
|
|
5334
5367
|
}
|
|
5335
5368
|
async commit() {
|
|
5336
5369
|
if (this.ensureCommitNotCalled(), this.lastWriteError) throw this.lastWriteError;
|
|
5337
5370
|
const t = this.readVersions;
|
|
5338
5371
|
// For each mutation, note that the doc was written.
|
|
5339
|
-
this.mutations.forEach((
|
|
5340
|
-
t.delete(
|
|
5372
|
+
this.mutations.forEach((e => {
|
|
5373
|
+
t.delete(e.key.toString());
|
|
5341
5374
|
})),
|
|
5342
5375
|
// For each document that was read but not written to, we want to perform
|
|
5343
5376
|
// a `verify` operation.
|
|
5344
|
-
t.forEach(((t,
|
|
5345
|
-
const
|
|
5346
|
-
this.mutations.push(new
|
|
5347
|
-
})), await
|
|
5377
|
+
t.forEach(((t, e) => {
|
|
5378
|
+
const n = et.fromPath(e);
|
|
5379
|
+
this.mutations.push(new Re(n, this.precondition(n)));
|
|
5380
|
+
})), await Je(this.datastore, this.mutations), this.committed = !0;
|
|
5348
5381
|
}
|
|
5349
5382
|
recordVersion(t) {
|
|
5350
|
-
let
|
|
5351
|
-
if (t.isFoundDocument())
|
|
5383
|
+
let e;
|
|
5384
|
+
if (t.isFoundDocument()) e = t.version; else {
|
|
5352
5385
|
if (!t.isNoDocument()) throw g();
|
|
5353
5386
|
// For deleted docs, we must use baseVersion 0 when we overwrite them.
|
|
5354
|
-
|
|
5387
|
+
e = bt.min();
|
|
5355
5388
|
}
|
|
5356
|
-
const
|
|
5357
|
-
if (
|
|
5358
|
-
if (!
|
|
5389
|
+
const n = this.readVersions.get(t.key.toString());
|
|
5390
|
+
if (n) {
|
|
5391
|
+
if (!e.isEqual(n))
|
|
5359
5392
|
// This transaction will fail no matter what.
|
|
5360
5393
|
throw new U(F, "Document version changed between two reads.");
|
|
5361
|
-
} else this.readVersions.set(t.key.toString(),
|
|
5394
|
+
} else this.readVersions.set(t.key.toString(), e);
|
|
5362
5395
|
}
|
|
5363
5396
|
/**
|
|
5364
5397
|
* Returns the version of this document when it was read in this transaction,
|
|
5365
5398
|
* as a precondition, or no precondition if it was not read.
|
|
5366
5399
|
*/ precondition(t) {
|
|
5367
|
-
const
|
|
5368
|
-
return !this.writtenDocs.has(t.toString()) &&
|
|
5400
|
+
const e = this.readVersions.get(t.toString());
|
|
5401
|
+
return !this.writtenDocs.has(t.toString()) && e ? ve.updateTime(e) : ve.none();
|
|
5369
5402
|
}
|
|
5370
5403
|
/**
|
|
5371
5404
|
* Returns the precondition for a document if the operation is an update.
|
|
5372
5405
|
*/ preconditionForUpdate(t) {
|
|
5373
|
-
const
|
|
5406
|
+
const e = this.readVersions.get(t.toString());
|
|
5374
5407
|
// The first time a document is written, we want to take into account the
|
|
5375
5408
|
// read time and existence
|
|
5376
|
-
if (!this.writtenDocs.has(t.toString()) &&
|
|
5377
|
-
if (
|
|
5409
|
+
if (!this.writtenDocs.has(t.toString()) && e) {
|
|
5410
|
+
if (e.isEqual(bt.min()))
|
|
5378
5411
|
// The document doesn't exist, so fail the transaction.
|
|
5379
5412
|
// This has to be validated locally because you can't send a
|
|
5380
5413
|
// precondition that a document does not exist without changing the
|
|
@@ -5386,11 +5419,11 @@ function Fr(t, n) {
|
|
|
5386
5419
|
// transaction.
|
|
5387
5420
|
throw new U(A, "Can't update a document that doesn't exist.");
|
|
5388
5421
|
// Document exists, base precondition on document update time.
|
|
5389
|
-
return
|
|
5422
|
+
return ve.updateTime(e);
|
|
5390
5423
|
}
|
|
5391
5424
|
// Document was not read, so we just use the preconditions for a blind
|
|
5392
5425
|
// update.
|
|
5393
|
-
return
|
|
5426
|
+
return ve.exists(!0);
|
|
5394
5427
|
}
|
|
5395
5428
|
write(t) {
|
|
5396
5429
|
this.ensureCommitNotCalled(), this.mutations.push(t);
|
|
@@ -5418,20 +5451,20 @@ function Fr(t, n) {
|
|
|
5418
5451
|
* TransactionRunner encapsulates the logic needed to run and retry transactions
|
|
5419
5452
|
* with backoff.
|
|
5420
5453
|
*/
|
|
5421
|
-
class
|
|
5422
|
-
constructor(t,
|
|
5423
|
-
this.asyncQueue = t, this.datastore =
|
|
5424
|
-
this.Tt = 5, this.It = new
|
|
5454
|
+
class qr {
|
|
5455
|
+
constructor(t, e, n, r) {
|
|
5456
|
+
this.asyncQueue = t, this.datastore = e, this.updateFunction = n, this.deferred = r,
|
|
5457
|
+
this.Tt = 5, this.It = new He(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
|
|
5425
5458
|
}
|
|
5426
5459
|
/** Runs the transaction and sets the result on deferred. */ run() {
|
|
5427
5460
|
this.Tt -= 1, this.At();
|
|
5428
5461
|
}
|
|
5429
5462
|
At() {
|
|
5430
5463
|
this.It.W((async () => {
|
|
5431
|
-
const t = new
|
|
5432
|
-
|
|
5464
|
+
const t = new xr(this.datastore), e = this.Rt(t);
|
|
5465
|
+
e && e.then((e => {
|
|
5433
5466
|
this.asyncQueue.enqueueAndForget((() => t.commit().then((() => {
|
|
5434
|
-
this.deferred.resolve(
|
|
5467
|
+
this.deferred.resolve(e);
|
|
5435
5468
|
})).catch((t => {
|
|
5436
5469
|
this.Pt(t);
|
|
5437
5470
|
}))));
|
|
@@ -5442,8 +5475,8 @@ class Or {
|
|
|
5442
5475
|
}
|
|
5443
5476
|
Rt(t) {
|
|
5444
5477
|
try {
|
|
5445
|
-
const
|
|
5446
|
-
return !ct(
|
|
5478
|
+
const e = this.updateFunction(t);
|
|
5479
|
+
return !ct(e) && e.catch && e.then ? e : (this.deferred.reject(Error("Transaction callback must return a Promise")),
|
|
5447
5480
|
null);
|
|
5448
5481
|
} catch (t) {
|
|
5449
5482
|
// Do not retry errors thrown by user provided updateFunction.
|
|
@@ -5458,8 +5491,8 @@ class Or {
|
|
|
5458
5491
|
if ("FirebaseError" === t.name) {
|
|
5459
5492
|
// In transactions, the backend will fail outdated reads with FAILED_PRECONDITION and
|
|
5460
5493
|
// non-matching document versions with ABORTED. These errors should be retried.
|
|
5461
|
-
const
|
|
5462
|
-
return "aborted" ===
|
|
5494
|
+
const e = t.code;
|
|
5495
|
+
return "aborted" === e || "failed-precondition" === e || !
|
|
5463
5496
|
/**
|
|
5464
5497
|
* Determines whether an error code represents a permanent error when received
|
|
5465
5498
|
* in response to a non-write operation.
|
|
@@ -5496,7 +5529,7 @@ class Or {
|
|
|
5496
5529
|
case L:
|
|
5497
5530
|
return !0;
|
|
5498
5531
|
}
|
|
5499
|
-
}(
|
|
5532
|
+
}(e);
|
|
5500
5533
|
}
|
|
5501
5534
|
return !1;
|
|
5502
5535
|
}
|
|
@@ -5518,7 +5551,7 @@ class Or {
|
|
|
5518
5551
|
* See the License for the specific language governing permissions and
|
|
5519
5552
|
* limitations under the License.
|
|
5520
5553
|
*/
|
|
5521
|
-
/** The Platform's 'document' implementation or null if not available. */ function
|
|
5554
|
+
/** The Platform's 'document' implementation or null if not available. */ function Or() {
|
|
5522
5555
|
// `document` is not always available, e.g. in ReactNative and WebWorkers.
|
|
5523
5556
|
// eslint-disable-next-line no-restricted-globals
|
|
5524
5557
|
return "undefined" != typeof document ? document : null;
|
|
@@ -5550,9 +5583,9 @@ class Or {
|
|
|
5550
5583
|
* Note: We implement `PromiseLike` instead of `Promise`, as the `Promise` type
|
|
5551
5584
|
* in newer versions of TypeScript defines `finally`, which is not available in
|
|
5552
5585
|
* IE.
|
|
5553
|
-
*/ class
|
|
5554
|
-
constructor(t,
|
|
5555
|
-
this.asyncQueue = t, this.timerId =
|
|
5586
|
+
*/ class Cr {
|
|
5587
|
+
constructor(t, e, n, r, s) {
|
|
5588
|
+
this.asyncQueue = t, this.timerId = e, this.targetTimeMs = n, this.op = r, this.removalCallback = s,
|
|
5556
5589
|
this.deferred = new k, this.then = this.deferred.promise.then.bind(this.deferred.promise),
|
|
5557
5590
|
// It's normal for the deferred promise to be canceled (due to cancellation)
|
|
5558
5591
|
// and so we attach a dummy catch callback to avoid
|
|
@@ -5572,9 +5605,9 @@ class Or {
|
|
|
5572
5605
|
* from its delayedOperations list.
|
|
5573
5606
|
* PORTING NOTE: This exists to prevent making removeDelayedOperation() and
|
|
5574
5607
|
* the DelayedOperation class public.
|
|
5575
|
-
*/ static createAndSchedule(t,
|
|
5576
|
-
const i = Date.now() +
|
|
5577
|
-
return o.start(
|
|
5608
|
+
*/ static createAndSchedule(t, e, n, r, s) {
|
|
5609
|
+
const i = Date.now() + n, o = new Cr(t, e, i, r, s);
|
|
5610
|
+
return o.start(n), o;
|
|
5578
5611
|
}
|
|
5579
5612
|
/**
|
|
5580
5613
|
* Starts the timer. This is called immediately after construction by
|
|
@@ -5622,7 +5655,7 @@ class Or {
|
|
|
5622
5655
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5623
5656
|
* See the License for the specific language governing permissions and
|
|
5624
5657
|
* limitations under the License.
|
|
5625
|
-
*/ class
|
|
5658
|
+
*/ class Lr {
|
|
5626
5659
|
constructor() {
|
|
5627
5660
|
// The last promise in the queue.
|
|
5628
5661
|
this.Dt = Promise.resolve(),
|
|
@@ -5645,15 +5678,15 @@ class Or {
|
|
|
5645
5678
|
// List of TimerIds to fast-forward delays for.
|
|
5646
5679
|
this.Ot = [],
|
|
5647
5680
|
// Backoff timer used to schedule retries for retryable operations
|
|
5648
|
-
this.It = new
|
|
5681
|
+
this.It = new He(this, "async_queue_retry" /* AsyncQueueRetry */),
|
|
5649
5682
|
// Visibility handler that triggers an immediate retry of all retryable
|
|
5650
5683
|
// operations. Meant to speed up recovery when we regain file system access
|
|
5651
5684
|
// after page comes into foreground.
|
|
5652
5685
|
this.Ct = () => {
|
|
5653
|
-
const t =
|
|
5686
|
+
const t = Or();
|
|
5654
5687
|
t && m("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.It.H();
|
|
5655
5688
|
};
|
|
5656
|
-
const t =
|
|
5689
|
+
const t = Or();
|
|
5657
5690
|
t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.Ct);
|
|
5658
5691
|
}
|
|
5659
5692
|
get isShuttingDown() {
|
|
@@ -5674,8 +5707,8 @@ class Or {
|
|
|
5674
5707
|
enterRestrictedMode(t) {
|
|
5675
5708
|
if (!this.$t) {
|
|
5676
5709
|
this.$t = !0, this.qt = t || !1;
|
|
5677
|
-
const
|
|
5678
|
-
|
|
5710
|
+
const e = Or();
|
|
5711
|
+
e && "function" == typeof e.removeEventListener && e.removeEventListener("visibilitychange", this.Ct);
|
|
5679
5712
|
}
|
|
5680
5713
|
}
|
|
5681
5714
|
enqueue(t) {
|
|
@@ -5685,9 +5718,9 @@ class Or {
|
|
|
5685
5718
|
// Create a deferred Promise that we can return to the callee. This
|
|
5686
5719
|
// allows us to return a "hanging Promise" only to the callee and still
|
|
5687
5720
|
// advance the queue even when the operation is not run.
|
|
5688
|
-
const
|
|
5689
|
-
return this.Ut((() => this.$t && this.qt ? Promise.resolve() : (t().then(
|
|
5690
|
-
|
|
5721
|
+
const e = new k;
|
|
5722
|
+
return this.Ut((() => this.$t && this.qt ? Promise.resolve() : (t().then(e.resolve, e.reject),
|
|
5723
|
+
e.promise))).then((() => e.promise));
|
|
5691
5724
|
}
|
|
5692
5725
|
enqueueRetryable(t) {
|
|
5693
5726
|
this.enqueueAndForget((() => (this.Nt.push(t), this.kt())));
|
|
@@ -5757,18 +5790,18 @@ class Or {
|
|
|
5757
5790
|
}
|
|
5758
5791
|
}
|
|
5759
5792
|
Ut(t) {
|
|
5760
|
-
const
|
|
5793
|
+
const e = this.Dt.then((() => (this.xt = !0, t().catch((t => {
|
|
5761
5794
|
this.Ft = t, this.xt = !1;
|
|
5762
|
-
const
|
|
5795
|
+
const e =
|
|
5763
5796
|
/**
|
|
5764
5797
|
* Chrome includes Error.message in Error.stack. Other browsers do not.
|
|
5765
5798
|
* This returns expected output of message + stack when available.
|
|
5766
5799
|
* @param error - Error or FirestoreError
|
|
5767
5800
|
*/
|
|
5768
5801
|
function(t) {
|
|
5769
|
-
let
|
|
5770
|
-
t.stack && (
|
|
5771
|
-
return
|
|
5802
|
+
let e = t.message || "";
|
|
5803
|
+
t.stack && (e = t.stack.includes(t.message) ? t.stack : t.message + "\n" + t.stack);
|
|
5804
|
+
return e;
|
|
5772
5805
|
}
|
|
5773
5806
|
/**
|
|
5774
5807
|
* @license
|
|
@@ -5798,15 +5831,15 @@ class Or {
|
|
|
5798
5831
|
// Re-throw the error so that this.tail becomes a rejected Promise and
|
|
5799
5832
|
// all further attempts to chain (via .then) will just short-circuit
|
|
5800
5833
|
// and return the rejected Promise.
|
|
5801
|
-
throw p("INTERNAL UNHANDLED ERROR: ",
|
|
5834
|
+
throw p("INTERNAL UNHANDLED ERROR: ", e), t;
|
|
5802
5835
|
})).then((t => (this.xt = !1, t))))));
|
|
5803
|
-
return this.Dt =
|
|
5836
|
+
return this.Dt = e, e;
|
|
5804
5837
|
}
|
|
5805
|
-
enqueueAfterDelay(t,
|
|
5838
|
+
enqueueAfterDelay(t, e, n) {
|
|
5806
5839
|
this.Lt(),
|
|
5807
5840
|
// Fast-forward delays for timerIds that have been overriden.
|
|
5808
|
-
this.Ot.indexOf(t) > -1 && (
|
|
5809
|
-
const r =
|
|
5841
|
+
this.Ot.indexOf(t) > -1 && (e = 0);
|
|
5842
|
+
const r = Cr.createAndSchedule(this, t, e, n, (t => this.jt(t)));
|
|
5810
5843
|
return this.St.push(r), r;
|
|
5811
5844
|
}
|
|
5812
5845
|
Lt() {
|
|
@@ -5830,7 +5863,7 @@ class Or {
|
|
|
5830
5863
|
* For Tests: Determine if a delayed operation with a particular TimerId
|
|
5831
5864
|
* exists.
|
|
5832
5865
|
*/ Bt(t) {
|
|
5833
|
-
for (const
|
|
5866
|
+
for (const e of this.St) if (e.timerId === t) return !0;
|
|
5834
5867
|
return !1;
|
|
5835
5868
|
}
|
|
5836
5869
|
/**
|
|
@@ -5843,8 +5876,8 @@ class Or {
|
|
|
5843
5876
|
// Note that draining may generate more delayed ops, so we do that first.
|
|
5844
5877
|
return this.Mt().then((() => {
|
|
5845
5878
|
// Run ops in the same order they'd run if they ran naturally.
|
|
5846
|
-
this.St.sort(((t,
|
|
5847
|
-
for (const
|
|
5879
|
+
this.St.sort(((t, e) => t.targetTimeMs - e.targetTimeMs));
|
|
5880
|
+
for (const e of this.St) if (e.skipDelay(), "all" /* All */ !== t && e.timerId === t) break;
|
|
5848
5881
|
return this.Mt();
|
|
5849
5882
|
}));
|
|
5850
5883
|
}
|
|
@@ -5855,15 +5888,15 @@ class Or {
|
|
|
5855
5888
|
}
|
|
5856
5889
|
/** Called once a DelayedOperation is run or canceled. */ jt(t) {
|
|
5857
5890
|
// NOTE: indexOf / slice are O(n), but delayedOperations is expected to be small.
|
|
5858
|
-
const
|
|
5859
|
-
this.St.splice(
|
|
5891
|
+
const e = this.St.indexOf(t);
|
|
5892
|
+
this.St.splice(e, 1);
|
|
5860
5893
|
}
|
|
5861
5894
|
}
|
|
5862
5895
|
|
|
5863
|
-
class
|
|
5896
|
+
class Ur {
|
|
5864
5897
|
/** @hideconstructor */
|
|
5865
|
-
constructor(t,
|
|
5866
|
-
this._firestore = t, this._transaction =
|
|
5898
|
+
constructor(t, e) {
|
|
5899
|
+
this._firestore = t, this._transaction = e, this._dataReader = Vn(t);
|
|
5867
5900
|
}
|
|
5868
5901
|
/**
|
|
5869
5902
|
* Reads the document referenced by the provided {@link DocumentReference}.
|
|
@@ -5871,25 +5904,25 @@ class kr {
|
|
|
5871
5904
|
* @param documentRef - A reference to the document to be read.
|
|
5872
5905
|
* @returns A `DocumentSnapshot` with the read data.
|
|
5873
5906
|
*/ get(t) {
|
|
5874
|
-
const
|
|
5875
|
-
return this._transaction.lookup([
|
|
5907
|
+
const e = Sr(t, this._firestore), n = new gr(this._firestore);
|
|
5908
|
+
return this._transaction.lookup([ e._key ]).then((t => {
|
|
5876
5909
|
if (!t || 1 !== t.length) return g();
|
|
5877
5910
|
const r = t[0];
|
|
5878
|
-
if (r.isFoundDocument()) return new
|
|
5879
|
-
if (r.isNoDocument()) return new
|
|
5911
|
+
if (r.isFoundDocument()) return new Yn(this._firestore, n, r.key, r, e.converter);
|
|
5912
|
+
if (r.isNoDocument()) return new Yn(this._firestore, n, e._key, null, e.converter);
|
|
5880
5913
|
throw g();
|
|
5881
5914
|
}));
|
|
5882
5915
|
}
|
|
5883
|
-
set(t,
|
|
5884
|
-
const r =
|
|
5916
|
+
set(t, e, n) {
|
|
5917
|
+
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);
|
|
5885
5918
|
return this._transaction.set(r._key, i), this;
|
|
5886
5919
|
}
|
|
5887
|
-
update(t,
|
|
5888
|
-
const s =
|
|
5920
|
+
update(t, e, n, ...r) {
|
|
5921
|
+
const s = Sr(t, this._firestore);
|
|
5889
5922
|
// For Compat types, we have to "extract" the underlying types before
|
|
5890
5923
|
// performing validation.
|
|
5891
5924
|
let i;
|
|
5892
|
-
return i = "string" == typeof (
|
|
5925
|
+
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),
|
|
5893
5926
|
this._transaction.update(s._key, i), this;
|
|
5894
5927
|
}
|
|
5895
5928
|
/**
|
|
@@ -5898,8 +5931,8 @@ class kr {
|
|
|
5898
5931
|
* @param documentRef - A reference to the document to be deleted.
|
|
5899
5932
|
* @returns This `Transaction` instance. Used for chaining method calls.
|
|
5900
5933
|
*/ delete(t) {
|
|
5901
|
-
const
|
|
5902
|
-
return this._transaction.delete(
|
|
5934
|
+
const e = Sr(t, this._firestore);
|
|
5935
|
+
return this._transaction.delete(e._key), this;
|
|
5903
5936
|
}
|
|
5904
5937
|
}
|
|
5905
5938
|
|
|
@@ -5919,9 +5952,9 @@ class kr {
|
|
|
5919
5952
|
* (the `updateFunction` returned a failed promise), the promise returned by the
|
|
5920
5953
|
* `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
|
5921
5954
|
* rejected promise with the corresponding failure error is returned.
|
|
5922
|
-
*/ function
|
|
5923
|
-
const
|
|
5924
|
-
return new
|
|
5955
|
+
*/ function kr(t, e) {
|
|
5956
|
+
const n = en(t = ot(t, rn)), r = new k;
|
|
5957
|
+
return new qr(new Lr, n, (n => e(new Ur(t, n))), r).run(), r.promise;
|
|
5925
5958
|
}
|
|
5926
5959
|
|
|
5927
5960
|
/**
|
|
@@ -5933,12 +5966,12 @@ class kr {
|
|
|
5933
5966
|
* @packageDocumentation
|
|
5934
5967
|
*/ !function(t) {
|
|
5935
5968
|
f = t;
|
|
5936
|
-
}(`${SDK_VERSION}_lite`), _registerComponent(new Component("firestore/lite", ((t, {options:
|
|
5937
|
-
const
|
|
5938
|
-
return
|
|
5969
|
+
}(`${SDK_VERSION}_lite`), _registerComponent(new Component("firestore/lite", ((t, {options: e}) => {
|
|
5970
|
+
const n = t.getProvider("app").getImmediate(), r = new rn(n, new z(t.getProvider("auth-internal")), new Y(t.getProvider("app-check-internal")));
|
|
5971
|
+
return e && r._setSettings(e), r;
|
|
5939
5972
|
}), "PUBLIC")),
|
|
5940
5973
|
// RUNTIME_ENV and BUILD_TARGET are replaced by real values during the compilation
|
|
5941
|
-
registerVersion("firestore-lite", "3.4.
|
|
5974
|
+
registerVersion("firestore-lite", "3.4.5-canary.8ac8fb099", ""), registerVersion("firestore-lite", "3.4.5-canary.8ac8fb099", "esm2017");
|
|
5942
5975
|
|
|
5943
|
-
export {
|
|
5976
|
+
export { gn as Bytes, ln as CollectionReference, an as DocumentReference, Yn as DocumentSnapshot, yn as FieldPath, bn as FieldValue, rn as Firestore, U as FirestoreError, vn as GeoPoint, hn as Query, Zn as QueryConstraint, Hn as QueryDocumentSnapshot, Kn as QuerySnapshot, gt as Timestamp, 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, br as getDoc, vr as getDocs, on as getFirestore, Nr as increment, sn as initializeFirestore, or as limit, ur as limitToLast, sr as orderBy, tr as query, pn as queryEqual, mn as refEqual, 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 };
|
|
5944
5977
|
//# sourceMappingURL=index.browser.esm2017.js.map
|