@firebase/firestore 3.8.4 → 3.9.0-20230314181055

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/firestore/src/lite-api/query.d.ts +11 -19
  3. package/dist/firestore/src/lite-api/reference.d.ts +1 -1
  4. package/dist/firestore/src/util/debug_uid.d.ts +28 -0
  5. package/dist/firestore/test/unit/specs/spec_builder.d.ts +3 -0
  6. package/dist/firestore/test/unit/specs/spec_test_components.d.ts +5 -1
  7. package/dist/index.cjs.js +1359 -1309
  8. package/dist/index.cjs.js.map +1 -1
  9. package/dist/index.d.ts +66 -14
  10. package/dist/index.esm2017.js +1272 -1222
  11. package/dist/index.esm2017.js.map +1 -1
  12. package/dist/index.esm5.js +1335 -1259
  13. package/dist/index.esm5.js.map +1 -1
  14. package/dist/index.node.cjs.js +97 -32
  15. package/dist/index.node.cjs.js.map +1 -1
  16. package/dist/index.node.mjs +97 -32
  17. package/dist/index.node.mjs.map +1 -1
  18. package/dist/index.rn.js +1380 -1330
  19. package/dist/index.rn.js.map +1 -1
  20. package/dist/internal.d.ts +12 -20
  21. package/dist/lite/firestore/src/lite-api/query.d.ts +11 -19
  22. package/dist/lite/firestore/src/lite-api/reference.d.ts +1 -1
  23. package/dist/lite/firestore/src/util/debug_uid.d.ts +28 -0
  24. package/dist/lite/firestore/test/unit/specs/spec_builder.d.ts +3 -0
  25. package/dist/lite/firestore/test/unit/specs/spec_test_components.d.ts +5 -1
  26. package/dist/lite/index.browser.esm2017.js +775 -730
  27. package/dist/lite/index.browser.esm2017.js.map +1 -1
  28. package/dist/lite/index.browser.esm5.js +736 -693
  29. package/dist/lite/index.browser.esm5.js.map +1 -1
  30. package/dist/lite/index.cjs.js +775 -730
  31. package/dist/lite/index.cjs.js.map +1 -1
  32. package/dist/lite/index.d.ts +66 -14
  33. package/dist/lite/index.node.cjs.js +76 -18
  34. package/dist/lite/index.node.cjs.js.map +1 -1
  35. package/dist/lite/index.node.mjs +76 -18
  36. package/dist/lite/index.node.mjs.map +1 -1
  37. package/dist/lite/index.rn.esm2017.js +777 -732
  38. package/dist/lite/index.rn.esm2017.js.map +1 -1
  39. package/dist/lite/internal.d.ts +12 -20
  40. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +139 -142
  41. package/dist/lite/packages/firestore/src/lite-api/query.d.ts +11 -19
  42. package/dist/lite/packages/firestore/src/lite-api/reference.d.ts +1 -1
  43. package/dist/lite/packages/firestore/src/util/debug_uid.d.ts +28 -0
  44. package/dist/lite/packages/firestore/test/unit/specs/spec_builder.d.ts +3 -0
  45. package/dist/lite/packages/firestore/test/unit/specs/spec_test_components.d.ts +5 -1
  46. package/dist/lite/private.d.ts +72 -16
  47. package/dist/packages/firestore/dist/index.esm2017.d.ts +157 -160
  48. package/dist/packages/firestore/src/lite-api/query.d.ts +11 -19
  49. package/dist/packages/firestore/src/lite-api/reference.d.ts +1 -1
  50. package/dist/packages/firestore/src/util/debug_uid.d.ts +28 -0
  51. package/dist/packages/firestore/test/unit/specs/spec_builder.d.ts +3 -0
  52. package/dist/packages/firestore/test/unit/specs/spec_test_components.d.ts +5 -1
  53. package/dist/private.d.ts +72 -16
  54. package/package.json +2 -2
@@ -33,7 +33,7 @@ var grpc__namespace = /*#__PURE__*/_interopNamespace(grpc);
33
33
  var protoLoader__namespace = /*#__PURE__*/_interopNamespace(protoLoader);
34
34
 
35
35
  const name = "@firebase/firestore";
36
- const version$1 = "3.8.4";
36
+ const version$1 = "3.9.0-20230314181055";
37
37
 
38
38
  /**
39
39
  * @license
@@ -86,7 +86,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
86
86
  User.FIRST_PARTY = new User('first-party-uid');
87
87
  User.MOCK_USER = new User('mock-user');
88
88
 
89
- const version = "9.17.2";
89
+ const version = "9.18.0-20230314181055";
90
90
 
91
91
  /**
92
92
  * @license
@@ -15860,8 +15860,11 @@ class IndexedDbPersistence {
15860
15860
  // accesses internal state. We execute this code directly during shutdown
15861
15861
  // to make sure it gets a chance to run.
15862
15862
  this.markClientZombied();
15863
- if (util.isSafari() && navigator.appVersion.match(/Version\/1[45]/)) {
15864
- // On Safari 14 and 15, we do not run any cleanup actions as it might
15863
+ const safariIndexdbBugVersionRegex = /(?:Version|Mobile)\/1[456]/;
15864
+ if (util.isSafari() &&
15865
+ (navigator.appVersion.match(safariIndexdbBugVersionRegex) ||
15866
+ navigator.userAgent.match(safariIndexdbBugVersionRegex))) {
15867
+ // On Safari 14, 15, and 16, we do not run any cleanup actions as it might
15865
15868
  // trigger a bug that prevents Safari from re-opening IndexedDB during
15866
15869
  // the next page load.
15867
15870
  // See https://bugs.webkit.org/show_bug.cgi?id=226547
@@ -17937,6 +17940,66 @@ class StreamBridge {
17937
17940
  }
17938
17941
  }
17939
17942
 
17943
+ /**
17944
+ * @license
17945
+ * Copyright 2023 Google LLC
17946
+ *
17947
+ * Licensed under the Apache License, Version 2.0 (the "License");
17948
+ * you may not use this file except in compliance with the License.
17949
+ * You may obtain a copy of the License at
17950
+ *
17951
+ * http://www.apache.org/licenses/LICENSE-2.0
17952
+ *
17953
+ * Unless required by applicable law or agreed to in writing, software
17954
+ * distributed under the License is distributed on an "AS IS" BASIS,
17955
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17956
+ * See the License for the specific language governing permissions and
17957
+ * limitations under the License.
17958
+ */
17959
+ /**
17960
+ * The value returned from the most recent invocation of
17961
+ * `generateUniqueDebugId()`, or null if it has never been invoked.
17962
+ */
17963
+ let lastUniqueDebugId = null;
17964
+ /**
17965
+ * Generates and returns an initial value for `lastUniqueDebugId`.
17966
+ *
17967
+ * The returned value is randomly selected from a range of integers that are
17968
+ * represented as 8 hexadecimal digits. This means that (within reason) any
17969
+ * numbers generated by incrementing the returned number by 1 will also be
17970
+ * represented by 8 hexadecimal digits. This leads to all "IDs" having the same
17971
+ * length when converted to a hexadecimal string, making reading logs containing
17972
+ * these IDs easier to follow. And since the return value is randomly selected
17973
+ * it will help to differentiate between logs from different executions.
17974
+ */
17975
+ function generateInitialUniqueDebugId() {
17976
+ const minResult = 0x10000000;
17977
+ const maxResult = 0x90000000;
17978
+ const resultRange = maxResult - minResult;
17979
+ const resultOffset = Math.round(resultRange * Math.random());
17980
+ return minResult + resultOffset;
17981
+ }
17982
+ /**
17983
+ * Generates and returns a unique ID as a hexadecimal string.
17984
+ *
17985
+ * The returned ID is intended to be used in debug logging messages to help
17986
+ * correlate log messages that may be spatially separated in the logs, but
17987
+ * logically related. For example, a network connection could include the same
17988
+ * "debug ID" string in all of its log messages to help trace a specific
17989
+ * connection over time.
17990
+ *
17991
+ * @return the 10-character generated ID (e.g. "0xa1b2c3d4").
17992
+ */
17993
+ function generateUniqueDebugId() {
17994
+ if (lastUniqueDebugId === null) {
17995
+ lastUniqueDebugId = generateInitialUniqueDebugId();
17996
+ }
17997
+ else {
17998
+ lastUniqueDebugId++;
17999
+ }
18000
+ return '0x' + lastUniqueDebugId.toString(16);
18001
+ }
18002
+
17940
18003
  /**
17941
18004
  * @license
17942
18005
  * Copyright 2017 Google LLC
@@ -18023,7 +18086,7 @@ function nodePromise(action) {
18023
18086
  // TODO: Fetch runtime version from grpc-js/package.json instead
18024
18087
  // when there's a cleaner way to dynamic require JSON in both Node ESM and CJS
18025
18088
  const grpcVersion = '1.7.3';
18026
- const LOG_TAG$9 = 'Connection';
18089
+ const LOG_TAG$9 = 'GrpcConnection';
18027
18090
  const X_GOOG_API_CLIENT_VALUE = `gl-node/${process.versions.node} fire/${SDK_VERSION} grpc/${grpcVersion}`;
18028
18091
  function createMetadata(databasePath, authToken, appCheckToken, appId) {
18029
18092
  hardAssert(authToken === null || authToken.type === 'OAuth');
@@ -18075,34 +18138,36 @@ class GrpcConnection {
18075
18138
  return this.cachedStub;
18076
18139
  }
18077
18140
  invokeRPC(rpcName, path, request, authToken, appCheckToken) {
18141
+ const streamId = generateUniqueDebugId();
18078
18142
  const stub = this.ensureActiveStub();
18079
18143
  const metadata = createMetadata(this.databasePath, authToken, appCheckToken, this.databaseInfo.appId);
18080
18144
  const jsonRequest = Object.assign({ database: this.databasePath }, request);
18081
18145
  return nodePromise((callback) => {
18082
- logDebug(LOG_TAG$9, `RPC '${rpcName}' invoked with request:`, request);
18146
+ logDebug(LOG_TAG$9, `RPC '${rpcName}' ${streamId} invoked with request:`, request);
18083
18147
  return stub[rpcName](jsonRequest, metadata, (grpcError, value) => {
18084
18148
  if (grpcError) {
18085
- logDebug(LOG_TAG$9, `RPC '${rpcName}' failed with error:`, grpcError);
18149
+ logDebug(LOG_TAG$9, `RPC '${rpcName}' ${streamId} failed with error:`, grpcError);
18086
18150
  callback(new FirestoreError(mapCodeFromRpcCode(grpcError.code), grpcError.message));
18087
18151
  }
18088
18152
  else {
18089
- logDebug(LOG_TAG$9, `RPC '${rpcName}' completed with response:`, value);
18153
+ logDebug(LOG_TAG$9, `RPC '${rpcName}' ${streamId} completed with response:`, value);
18090
18154
  callback(undefined, value);
18091
18155
  }
18092
18156
  });
18093
18157
  });
18094
18158
  }
18095
18159
  invokeStreamingRPC(rpcName, path, request, authToken, appCheckToken, expectedResponseCount) {
18160
+ const streamId = generateUniqueDebugId();
18096
18161
  const results = [];
18097
18162
  const responseDeferred = new Deferred();
18098
- logDebug(LOG_TAG$9, `RPC '${rpcName}' invoked (streaming) with request:`, request);
18163
+ logDebug(LOG_TAG$9, `RPC '${rpcName}' ${streamId} invoked (streaming) with request:`, request);
18099
18164
  const stub = this.ensureActiveStub();
18100
18165
  const metadata = createMetadata(this.databasePath, authToken, appCheckToken, this.databaseInfo.appId);
18101
18166
  const jsonRequest = Object.assign(Object.assign({}, request), { database: this.databasePath });
18102
18167
  const stream = stub[rpcName](jsonRequest, metadata);
18103
18168
  let callbackFired = false;
18104
18169
  stream.on('data', (response) => {
18105
- logDebug(LOG_TAG$9, `RPC ${rpcName} received result:`, response);
18170
+ logDebug(LOG_TAG$9, `RPC ${rpcName} ${streamId} received result:`, response);
18106
18171
  results.push(response);
18107
18172
  if (expectedResponseCount !== undefined &&
18108
18173
  results.length === expectedResponseCount) {
@@ -18111,14 +18176,14 @@ class GrpcConnection {
18111
18176
  }
18112
18177
  });
18113
18178
  stream.on('end', () => {
18114
- logDebug(LOG_TAG$9, `RPC '${rpcName}' completed.`);
18179
+ logDebug(LOG_TAG$9, `RPC '${rpcName}' ${streamId} completed.`);
18115
18180
  if (!callbackFired) {
18116
18181
  callbackFired = true;
18117
18182
  responseDeferred.resolve(results);
18118
18183
  }
18119
18184
  });
18120
18185
  stream.on('error', (grpcError) => {
18121
- logDebug(LOG_TAG$9, `RPC '${rpcName}' failed with error:`, grpcError);
18186
+ logDebug(LOG_TAG$9, `RPC '${rpcName}' ${streamId} failed with error:`, grpcError);
18122
18187
  const code = mapCodeFromRpcCode(grpcError.code);
18123
18188
  responseDeferred.reject(new FirestoreError(code, grpcError.message));
18124
18189
  });
@@ -18126,6 +18191,7 @@ class GrpcConnection {
18126
18191
  }
18127
18192
  // TODO(mikelehen): This "method" is a monster. Should be refactored.
18128
18193
  openStream(rpcName, authToken, appCheckToken) {
18194
+ const streamId = generateUniqueDebugId();
18129
18195
  const stub = this.ensureActiveStub();
18130
18196
  const metadata = createMetadata(this.databasePath, authToken, appCheckToken, this.databaseInfo.appId);
18131
18197
  const grpcStream = stub[rpcName](metadata);
@@ -18140,7 +18206,7 @@ class GrpcConnection {
18140
18206
  const stream = new StreamBridge({
18141
18207
  sendFn: (msg) => {
18142
18208
  if (!closed) {
18143
- logDebug(LOG_TAG$9, 'GRPC stream sending:', msg);
18209
+ logDebug(LOG_TAG$9, `RPC '${rpcName}' stream ${streamId} sending:`, msg);
18144
18210
  try {
18145
18211
  grpcStream.write(msg);
18146
18212
  }
@@ -18153,32 +18219,34 @@ class GrpcConnection {
18153
18219
  }
18154
18220
  }
18155
18221
  else {
18156
- logDebug(LOG_TAG$9, 'Not sending because gRPC stream is closed:', msg);
18222
+ logDebug(LOG_TAG$9, `RPC '${rpcName}' stream ${streamId} ` +
18223
+ 'not sending because gRPC stream is closed:', msg);
18157
18224
  }
18158
18225
  },
18159
18226
  closeFn: () => {
18160
- logDebug(LOG_TAG$9, 'GRPC stream closed locally via close().');
18227
+ logDebug(LOG_TAG$9, `RPC '${rpcName}' stream ${streamId} closed locally via close().`);
18161
18228
  close();
18162
18229
  }
18163
18230
  });
18164
18231
  grpcStream.on('data', (msg) => {
18165
18232
  if (!closed) {
18166
- logDebug(LOG_TAG$9, 'GRPC stream received:', msg);
18233
+ logDebug(LOG_TAG$9, `RPC '${rpcName}' stream ${streamId} received:`, msg);
18167
18234
  stream.callOnMessage(msg);
18168
18235
  }
18169
18236
  });
18170
18237
  grpcStream.on('end', () => {
18171
- logDebug(LOG_TAG$9, 'GRPC stream ended.');
18238
+ logDebug(LOG_TAG$9, `RPC '${rpcName}' stream ${streamId} ended.`);
18172
18239
  close();
18173
18240
  });
18174
18241
  grpcStream.on('error', (grpcError) => {
18175
18242
  if (!closed) {
18176
- logWarn(LOG_TAG$9, 'GRPC stream error. Code:', grpcError.code, 'Message:', grpcError.message);
18243
+ logWarn(LOG_TAG$9, `RPC '${rpcName}' stream ${streamId} error. Code:`, grpcError.code, 'Message:', grpcError.message);
18177
18244
  const code = mapCodeFromRpcCode(grpcError.code);
18178
18245
  close(new FirestoreError(code, grpcError.message));
18179
18246
  }
18180
18247
  });
18181
- logDebug(LOG_TAG$9, 'Opening GRPC stream');
18248
+ logDebug(LOG_TAG$9, `Opening RPC '${rpcName}' stream ${streamId} ` +
18249
+ `to ${this.databaseInfo.host}`);
18182
18250
  // TODO(dimond): Since grpc has no explicit open status (or does it?) we
18183
18251
  // simulate an onOpen in the next loop after the stream had it's listeners
18184
18252
  // registered
@@ -26583,7 +26651,7 @@ class Query {
26583
26651
  }
26584
26652
  /**
26585
26653
  * A `CollectionReference` object can be used for adding documents, getting
26586
- * document references, and querying for documents (using {@link query}).
26654
+ * document references, and querying for documents (using {@link (query:1)}).
26587
26655
  */
26588
26656
  class CollectionReference extends Query {
26589
26657
  /** @hideconstructor */
@@ -28739,9 +28807,9 @@ class AppliableConstraint {
28739
28807
  /**
28740
28808
  * A `QueryConstraint` is used to narrow the set of documents returned by a
28741
28809
  * Firestore query. `QueryConstraint`s are created by invoking {@link where},
28742
- * {@link orderBy}, {@link startAt}, {@link startAfter}, {@link
28743
- * endBefore}, {@link endAt}, {@link limit}, {@link limitToLast} and
28744
- * can then be passed to {@link query} to create a new query instance that
28810
+ * {@link orderBy}, {@link (startAt:1)}, {@link (startAfter:1)}, {@link
28811
+ * (endBefore:1)}, {@link (endAt:1)}, {@link limit}, {@link limitToLast} and
28812
+ * can then be passed to {@link (query:1)} to create a new query instance that
28745
28813
  * also contains this `QueryConstraint`.
28746
28814
  */
28747
28815
  class QueryConstraint extends AppliableConstraint {
@@ -28762,7 +28830,7 @@ function query(query, queryConstraint, ...additionalQueryConstraints) {
28762
28830
  * A `QueryFieldFilterConstraint` is used to narrow the set of documents returned by
28763
28831
  * a Firestore query by filtering on one or more document fields.
28764
28832
  * `QueryFieldFilterConstraint`s are created by invoking {@link where} and can then
28765
- * be passed to {@link query} to create a new query instance that also contains
28833
+ * be passed to {@link (query:1)} to create a new query instance that also contains
28766
28834
  * this `QueryFieldFilterConstraint`.
28767
28835
  */
28768
28836
  class QueryFieldFilterConstraint extends QueryConstraint {
@@ -28812,9 +28880,8 @@ function where(fieldPath, opStr, value) {
28812
28880
  * returned by a Firestore query by performing the logical OR or AND of multiple
28813
28881
  * {@link QueryFieldFilterConstraint}s or {@link QueryCompositeFilterConstraint}s.
28814
28882
  * `QueryCompositeFilterConstraint`s are created by invoking {@link or} or
28815
- * {@link and} and can then be passed to {@link query} to create a new query
28883
+ * {@link and} and can then be passed to {@link (query:1)} to create a new query
28816
28884
  * instance that also contains the `QueryCompositeFilterConstraint`.
28817
- * @internal TODO remove this internal tag with OR Query support in the server
28818
28885
  */
28819
28886
  class QueryCompositeFilterConstraint extends AppliableConstraint {
28820
28887
  /**
@@ -28867,7 +28934,6 @@ class QueryCompositeFilterConstraint extends AppliableConstraint {
28867
28934
  * {@link QueryFilterConstraint}s to perform a disjunction for. These must be
28868
28935
  * created with calls to {@link where}, {@link or}, or {@link and}.
28869
28936
  * @returns The newly created {@link QueryCompositeFilterConstraint}.
28870
- * @internal TODO remove this internal tag with OR Query support in the server
28871
28937
  */
28872
28938
  function or(...queryConstraints) {
28873
28939
  // Only support QueryFilterConstraints
@@ -28883,7 +28949,6 @@ function or(...queryConstraints) {
28883
28949
  * {@link QueryFilterConstraint}s to perform a conjunction for. These must be
28884
28950
  * created with calls to {@link where}, {@link or}, or {@link and}.
28885
28951
  * @returns The newly created {@link QueryCompositeFilterConstraint}.
28886
- * @internal TODO remove this internal tag with OR Query support in the server
28887
28952
  */
28888
28953
  function and(...queryConstraints) {
28889
28954
  // Only support QueryFilterConstraints
@@ -28893,7 +28958,7 @@ function and(...queryConstraints) {
28893
28958
  /**
28894
28959
  * A `QueryOrderByConstraint` is used to sort the set of documents returned by a
28895
28960
  * Firestore query. `QueryOrderByConstraint`s are created by invoking
28896
- * {@link orderBy} and can then be passed to {@link query} to create a new query
28961
+ * {@link orderBy} and can then be passed to {@link (query:1)} to create a new query
28897
28962
  * instance that also contains this `QueryOrderByConstraint`.
28898
28963
  *
28899
28964
  * Note: Documents that do not contain the orderBy field will not be present in
@@ -28939,7 +29004,7 @@ function orderBy(fieldPath, directionStr = 'asc') {
28939
29004
  * A `QueryLimitConstraint` is used to limit the number of documents returned by
28940
29005
  * a Firestore query.
28941
29006
  * `QueryLimitConstraint`s are created by invoking {@link limit} or
28942
- * {@link limitToLast} and can then be passed to {@link query} to create a new
29007
+ * {@link limitToLast} and can then be passed to {@link (query:1)} to create a new
28943
29008
  * query instance that also contains this `QueryLimitConstraint`.
28944
29009
  */
28945
29010
  class QueryLimitConstraint extends QueryConstraint {
@@ -28990,7 +29055,7 @@ function limitToLast(limit) {
28990
29055
  * A `QueryStartAtConstraint` is used to exclude documents from the start of a
28991
29056
  * result set returned by a Firestore query.
28992
29057
  * `QueryStartAtConstraint`s are created by invoking {@link (startAt:1)} or
28993
- * {@link (startAfter:1)} and can then be passed to {@link query} to create a
29058
+ * {@link (startAfter:1)} and can then be passed to {@link (query:1)} to create a
28994
29059
  * new query instance that also contains this `QueryStartAtConstraint`.
28995
29060
  */
28996
29061
  class QueryStartAtConstraint extends QueryConstraint {
@@ -29025,7 +29090,7 @@ function startAfter(...docOrFields) {
29025
29090
  * A `QueryEndAtConstraint` is used to exclude documents from the end of a
29026
29091
  * result set returned by a Firestore query.
29027
29092
  * `QueryEndAtConstraint`s are created by invoking {@link (endAt:1)} or
29028
- * {@link (endBefore:1)} and can then be passed to {@link query} to create a new
29093
+ * {@link (endBefore:1)} and can then be passed to {@link (query:1)} to create a new
29029
29094
  * query instance that also contains this `QueryEndAtConstraint`.
29030
29095
  */
29031
29096
  class QueryEndAtConstraint extends QueryConstraint {