@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
@@ -8,7 +8,7 @@ import * as grpc from '@grpc/grpc-js';
8
8
  import * as protoLoader from '@grpc/proto-loader';
9
9
 
10
10
  const name = "@firebase/firestore";
11
- const version$1 = "3.8.4";
11
+ const version$1 = "3.9.0-20230314181055";
12
12
 
13
13
  /**
14
14
  * @license
@@ -61,7 +61,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
61
61
  User.FIRST_PARTY = new User('first-party-uid');
62
62
  User.MOCK_USER = new User('mock-user');
63
63
 
64
- const version = "9.17.2";
64
+ const version = "9.18.0-20230314181055";
65
65
 
66
66
  /**
67
67
  * @license
@@ -15835,8 +15835,11 @@ class IndexedDbPersistence {
15835
15835
  // accesses internal state. We execute this code directly during shutdown
15836
15836
  // to make sure it gets a chance to run.
15837
15837
  this.markClientZombied();
15838
- if (isSafari() && navigator.appVersion.match(/Version\/1[45]/)) {
15839
- // On Safari 14 and 15, we do not run any cleanup actions as it might
15838
+ const safariIndexdbBugVersionRegex = /(?:Version|Mobile)\/1[456]/;
15839
+ if (isSafari() &&
15840
+ (navigator.appVersion.match(safariIndexdbBugVersionRegex) ||
15841
+ navigator.userAgent.match(safariIndexdbBugVersionRegex))) {
15842
+ // On Safari 14, 15, and 16, we do not run any cleanup actions as it might
15840
15843
  // trigger a bug that prevents Safari from re-opening IndexedDB during
15841
15844
  // the next page load.
15842
15845
  // See https://bugs.webkit.org/show_bug.cgi?id=226547
@@ -17912,6 +17915,66 @@ class StreamBridge {
17912
17915
  }
17913
17916
  }
17914
17917
 
17918
+ /**
17919
+ * @license
17920
+ * Copyright 2023 Google LLC
17921
+ *
17922
+ * Licensed under the Apache License, Version 2.0 (the "License");
17923
+ * you may not use this file except in compliance with the License.
17924
+ * You may obtain a copy of the License at
17925
+ *
17926
+ * http://www.apache.org/licenses/LICENSE-2.0
17927
+ *
17928
+ * Unless required by applicable law or agreed to in writing, software
17929
+ * distributed under the License is distributed on an "AS IS" BASIS,
17930
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17931
+ * See the License for the specific language governing permissions and
17932
+ * limitations under the License.
17933
+ */
17934
+ /**
17935
+ * The value returned from the most recent invocation of
17936
+ * `generateUniqueDebugId()`, or null if it has never been invoked.
17937
+ */
17938
+ let lastUniqueDebugId = null;
17939
+ /**
17940
+ * Generates and returns an initial value for `lastUniqueDebugId`.
17941
+ *
17942
+ * The returned value is randomly selected from a range of integers that are
17943
+ * represented as 8 hexadecimal digits. This means that (within reason) any
17944
+ * numbers generated by incrementing the returned number by 1 will also be
17945
+ * represented by 8 hexadecimal digits. This leads to all "IDs" having the same
17946
+ * length when converted to a hexadecimal string, making reading logs containing
17947
+ * these IDs easier to follow. And since the return value is randomly selected
17948
+ * it will help to differentiate between logs from different executions.
17949
+ */
17950
+ function generateInitialUniqueDebugId() {
17951
+ const minResult = 0x10000000;
17952
+ const maxResult = 0x90000000;
17953
+ const resultRange = maxResult - minResult;
17954
+ const resultOffset = Math.round(resultRange * Math.random());
17955
+ return minResult + resultOffset;
17956
+ }
17957
+ /**
17958
+ * Generates and returns a unique ID as a hexadecimal string.
17959
+ *
17960
+ * The returned ID is intended to be used in debug logging messages to help
17961
+ * correlate log messages that may be spatially separated in the logs, but
17962
+ * logically related. For example, a network connection could include the same
17963
+ * "debug ID" string in all of its log messages to help trace a specific
17964
+ * connection over time.
17965
+ *
17966
+ * @return the 10-character generated ID (e.g. "0xa1b2c3d4").
17967
+ */
17968
+ function generateUniqueDebugId() {
17969
+ if (lastUniqueDebugId === null) {
17970
+ lastUniqueDebugId = generateInitialUniqueDebugId();
17971
+ }
17972
+ else {
17973
+ lastUniqueDebugId++;
17974
+ }
17975
+ return '0x' + lastUniqueDebugId.toString(16);
17976
+ }
17977
+
17915
17978
  /**
17916
17979
  * @license
17917
17980
  * Copyright 2017 Google LLC
@@ -17998,7 +18061,7 @@ function nodePromise(action) {
17998
18061
  // TODO: Fetch runtime version from grpc-js/package.json instead
17999
18062
  // when there's a cleaner way to dynamic require JSON in both Node ESM and CJS
18000
18063
  const grpcVersion = '1.7.3';
18001
- const LOG_TAG$9 = 'Connection';
18064
+ const LOG_TAG$9 = 'GrpcConnection';
18002
18065
  const X_GOOG_API_CLIENT_VALUE = `gl-node/${process.versions.node} fire/${SDK_VERSION} grpc/${grpcVersion}`;
18003
18066
  function createMetadata(databasePath, authToken, appCheckToken, appId) {
18004
18067
  hardAssert(authToken === null || authToken.type === 'OAuth');
@@ -18050,34 +18113,36 @@ class GrpcConnection {
18050
18113
  return this.cachedStub;
18051
18114
  }
18052
18115
  invokeRPC(rpcName, path, request, authToken, appCheckToken) {
18116
+ const streamId = generateUniqueDebugId();
18053
18117
  const stub = this.ensureActiveStub();
18054
18118
  const metadata = createMetadata(this.databasePath, authToken, appCheckToken, this.databaseInfo.appId);
18055
18119
  const jsonRequest = Object.assign({ database: this.databasePath }, request);
18056
18120
  return nodePromise((callback) => {
18057
- logDebug(LOG_TAG$9, `RPC '${rpcName}' invoked with request:`, request);
18121
+ logDebug(LOG_TAG$9, `RPC '${rpcName}' ${streamId} invoked with request:`, request);
18058
18122
  return stub[rpcName](jsonRequest, metadata, (grpcError, value) => {
18059
18123
  if (grpcError) {
18060
- logDebug(LOG_TAG$9, `RPC '${rpcName}' failed with error:`, grpcError);
18124
+ logDebug(LOG_TAG$9, `RPC '${rpcName}' ${streamId} failed with error:`, grpcError);
18061
18125
  callback(new FirestoreError(mapCodeFromRpcCode(grpcError.code), grpcError.message));
18062
18126
  }
18063
18127
  else {
18064
- logDebug(LOG_TAG$9, `RPC '${rpcName}' completed with response:`, value);
18128
+ logDebug(LOG_TAG$9, `RPC '${rpcName}' ${streamId} completed with response:`, value);
18065
18129
  callback(undefined, value);
18066
18130
  }
18067
18131
  });
18068
18132
  });
18069
18133
  }
18070
18134
  invokeStreamingRPC(rpcName, path, request, authToken, appCheckToken, expectedResponseCount) {
18135
+ const streamId = generateUniqueDebugId();
18071
18136
  const results = [];
18072
18137
  const responseDeferred = new Deferred();
18073
- logDebug(LOG_TAG$9, `RPC '${rpcName}' invoked (streaming) with request:`, request);
18138
+ logDebug(LOG_TAG$9, `RPC '${rpcName}' ${streamId} invoked (streaming) with request:`, request);
18074
18139
  const stub = this.ensureActiveStub();
18075
18140
  const metadata = createMetadata(this.databasePath, authToken, appCheckToken, this.databaseInfo.appId);
18076
18141
  const jsonRequest = Object.assign(Object.assign({}, request), { database: this.databasePath });
18077
18142
  const stream = stub[rpcName](jsonRequest, metadata);
18078
18143
  let callbackFired = false;
18079
18144
  stream.on('data', (response) => {
18080
- logDebug(LOG_TAG$9, `RPC ${rpcName} received result:`, response);
18145
+ logDebug(LOG_TAG$9, `RPC ${rpcName} ${streamId} received result:`, response);
18081
18146
  results.push(response);
18082
18147
  if (expectedResponseCount !== undefined &&
18083
18148
  results.length === expectedResponseCount) {
@@ -18086,14 +18151,14 @@ class GrpcConnection {
18086
18151
  }
18087
18152
  });
18088
18153
  stream.on('end', () => {
18089
- logDebug(LOG_TAG$9, `RPC '${rpcName}' completed.`);
18154
+ logDebug(LOG_TAG$9, `RPC '${rpcName}' ${streamId} completed.`);
18090
18155
  if (!callbackFired) {
18091
18156
  callbackFired = true;
18092
18157
  responseDeferred.resolve(results);
18093
18158
  }
18094
18159
  });
18095
18160
  stream.on('error', (grpcError) => {
18096
- logDebug(LOG_TAG$9, `RPC '${rpcName}' failed with error:`, grpcError);
18161
+ logDebug(LOG_TAG$9, `RPC '${rpcName}' ${streamId} failed with error:`, grpcError);
18097
18162
  const code = mapCodeFromRpcCode(grpcError.code);
18098
18163
  responseDeferred.reject(new FirestoreError(code, grpcError.message));
18099
18164
  });
@@ -18101,6 +18166,7 @@ class GrpcConnection {
18101
18166
  }
18102
18167
  // TODO(mikelehen): This "method" is a monster. Should be refactored.
18103
18168
  openStream(rpcName, authToken, appCheckToken) {
18169
+ const streamId = generateUniqueDebugId();
18104
18170
  const stub = this.ensureActiveStub();
18105
18171
  const metadata = createMetadata(this.databasePath, authToken, appCheckToken, this.databaseInfo.appId);
18106
18172
  const grpcStream = stub[rpcName](metadata);
@@ -18115,7 +18181,7 @@ class GrpcConnection {
18115
18181
  const stream = new StreamBridge({
18116
18182
  sendFn: (msg) => {
18117
18183
  if (!closed) {
18118
- logDebug(LOG_TAG$9, 'GRPC stream sending:', msg);
18184
+ logDebug(LOG_TAG$9, `RPC '${rpcName}' stream ${streamId} sending:`, msg);
18119
18185
  try {
18120
18186
  grpcStream.write(msg);
18121
18187
  }
@@ -18128,32 +18194,34 @@ class GrpcConnection {
18128
18194
  }
18129
18195
  }
18130
18196
  else {
18131
- logDebug(LOG_TAG$9, 'Not sending because gRPC stream is closed:', msg);
18197
+ logDebug(LOG_TAG$9, `RPC '${rpcName}' stream ${streamId} ` +
18198
+ 'not sending because gRPC stream is closed:', msg);
18132
18199
  }
18133
18200
  },
18134
18201
  closeFn: () => {
18135
- logDebug(LOG_TAG$9, 'GRPC stream closed locally via close().');
18202
+ logDebug(LOG_TAG$9, `RPC '${rpcName}' stream ${streamId} closed locally via close().`);
18136
18203
  close();
18137
18204
  }
18138
18205
  });
18139
18206
  grpcStream.on('data', (msg) => {
18140
18207
  if (!closed) {
18141
- logDebug(LOG_TAG$9, 'GRPC stream received:', msg);
18208
+ logDebug(LOG_TAG$9, `RPC '${rpcName}' stream ${streamId} received:`, msg);
18142
18209
  stream.callOnMessage(msg);
18143
18210
  }
18144
18211
  });
18145
18212
  grpcStream.on('end', () => {
18146
- logDebug(LOG_TAG$9, 'GRPC stream ended.');
18213
+ logDebug(LOG_TAG$9, `RPC '${rpcName}' stream ${streamId} ended.`);
18147
18214
  close();
18148
18215
  });
18149
18216
  grpcStream.on('error', (grpcError) => {
18150
18217
  if (!closed) {
18151
- logWarn(LOG_TAG$9, 'GRPC stream error. Code:', grpcError.code, 'Message:', grpcError.message);
18218
+ logWarn(LOG_TAG$9, `RPC '${rpcName}' stream ${streamId} error. Code:`, grpcError.code, 'Message:', grpcError.message);
18152
18219
  const code = mapCodeFromRpcCode(grpcError.code);
18153
18220
  close(new FirestoreError(code, grpcError.message));
18154
18221
  }
18155
18222
  });
18156
- logDebug(LOG_TAG$9, 'Opening GRPC stream');
18223
+ logDebug(LOG_TAG$9, `Opening RPC '${rpcName}' stream ${streamId} ` +
18224
+ `to ${this.databaseInfo.host}`);
18157
18225
  // TODO(dimond): Since grpc has no explicit open status (or does it?) we
18158
18226
  // simulate an onOpen in the next loop after the stream had it's listeners
18159
18227
  // registered
@@ -26558,7 +26626,7 @@ class Query {
26558
26626
  }
26559
26627
  /**
26560
26628
  * A `CollectionReference` object can be used for adding documents, getting
26561
- * document references, and querying for documents (using {@link query}).
26629
+ * document references, and querying for documents (using {@link (query:1)}).
26562
26630
  */
26563
26631
  class CollectionReference extends Query {
26564
26632
  /** @hideconstructor */
@@ -28714,9 +28782,9 @@ class AppliableConstraint {
28714
28782
  /**
28715
28783
  * A `QueryConstraint` is used to narrow the set of documents returned by a
28716
28784
  * Firestore query. `QueryConstraint`s are created by invoking {@link where},
28717
- * {@link orderBy}, {@link startAt}, {@link startAfter}, {@link
28718
- * endBefore}, {@link endAt}, {@link limit}, {@link limitToLast} and
28719
- * can then be passed to {@link query} to create a new query instance that
28785
+ * {@link orderBy}, {@link (startAt:1)}, {@link (startAfter:1)}, {@link
28786
+ * (endBefore:1)}, {@link (endAt:1)}, {@link limit}, {@link limitToLast} and
28787
+ * can then be passed to {@link (query:1)} to create a new query instance that
28720
28788
  * also contains this `QueryConstraint`.
28721
28789
  */
28722
28790
  class QueryConstraint extends AppliableConstraint {
@@ -28737,7 +28805,7 @@ function query(query, queryConstraint, ...additionalQueryConstraints) {
28737
28805
  * A `QueryFieldFilterConstraint` is used to narrow the set of documents returned by
28738
28806
  * a Firestore query by filtering on one or more document fields.
28739
28807
  * `QueryFieldFilterConstraint`s are created by invoking {@link where} and can then
28740
- * be passed to {@link query} to create a new query instance that also contains
28808
+ * be passed to {@link (query:1)} to create a new query instance that also contains
28741
28809
  * this `QueryFieldFilterConstraint`.
28742
28810
  */
28743
28811
  class QueryFieldFilterConstraint extends QueryConstraint {
@@ -28787,9 +28855,8 @@ function where(fieldPath, opStr, value) {
28787
28855
  * returned by a Firestore query by performing the logical OR or AND of multiple
28788
28856
  * {@link QueryFieldFilterConstraint}s or {@link QueryCompositeFilterConstraint}s.
28789
28857
  * `QueryCompositeFilterConstraint`s are created by invoking {@link or} or
28790
- * {@link and} and can then be passed to {@link query} to create a new query
28858
+ * {@link and} and can then be passed to {@link (query:1)} to create a new query
28791
28859
  * instance that also contains the `QueryCompositeFilterConstraint`.
28792
- * @internal TODO remove this internal tag with OR Query support in the server
28793
28860
  */
28794
28861
  class QueryCompositeFilterConstraint extends AppliableConstraint {
28795
28862
  /**
@@ -28842,7 +28909,6 @@ class QueryCompositeFilterConstraint extends AppliableConstraint {
28842
28909
  * {@link QueryFilterConstraint}s to perform a disjunction for. These must be
28843
28910
  * created with calls to {@link where}, {@link or}, or {@link and}.
28844
28911
  * @returns The newly created {@link QueryCompositeFilterConstraint}.
28845
- * @internal TODO remove this internal tag with OR Query support in the server
28846
28912
  */
28847
28913
  function or(...queryConstraints) {
28848
28914
  // Only support QueryFilterConstraints
@@ -28858,7 +28924,6 @@ function or(...queryConstraints) {
28858
28924
  * {@link QueryFilterConstraint}s to perform a conjunction for. These must be
28859
28925
  * created with calls to {@link where}, {@link or}, or {@link and}.
28860
28926
  * @returns The newly created {@link QueryCompositeFilterConstraint}.
28861
- * @internal TODO remove this internal tag with OR Query support in the server
28862
28927
  */
28863
28928
  function and(...queryConstraints) {
28864
28929
  // Only support QueryFilterConstraints
@@ -28868,7 +28933,7 @@ function and(...queryConstraints) {
28868
28933
  /**
28869
28934
  * A `QueryOrderByConstraint` is used to sort the set of documents returned by a
28870
28935
  * Firestore query. `QueryOrderByConstraint`s are created by invoking
28871
- * {@link orderBy} and can then be passed to {@link query} to create a new query
28936
+ * {@link orderBy} and can then be passed to {@link (query:1)} to create a new query
28872
28937
  * instance that also contains this `QueryOrderByConstraint`.
28873
28938
  *
28874
28939
  * Note: Documents that do not contain the orderBy field will not be present in
@@ -28914,7 +28979,7 @@ function orderBy(fieldPath, directionStr = 'asc') {
28914
28979
  * A `QueryLimitConstraint` is used to limit the number of documents returned by
28915
28980
  * a Firestore query.
28916
28981
  * `QueryLimitConstraint`s are created by invoking {@link limit} or
28917
- * {@link limitToLast} and can then be passed to {@link query} to create a new
28982
+ * {@link limitToLast} and can then be passed to {@link (query:1)} to create a new
28918
28983
  * query instance that also contains this `QueryLimitConstraint`.
28919
28984
  */
28920
28985
  class QueryLimitConstraint extends QueryConstraint {
@@ -28965,7 +29030,7 @@ function limitToLast(limit) {
28965
29030
  * A `QueryStartAtConstraint` is used to exclude documents from the start of a
28966
29031
  * result set returned by a Firestore query.
28967
29032
  * `QueryStartAtConstraint`s are created by invoking {@link (startAt:1)} or
28968
- * {@link (startAfter:1)} and can then be passed to {@link query} to create a
29033
+ * {@link (startAfter:1)} and can then be passed to {@link (query:1)} to create a
28969
29034
  * new query instance that also contains this `QueryStartAtConstraint`.
28970
29035
  */
28971
29036
  class QueryStartAtConstraint extends QueryConstraint {
@@ -29000,7 +29065,7 @@ function startAfter(...docOrFields) {
29000
29065
  * A `QueryEndAtConstraint` is used to exclude documents from the end of a
29001
29066
  * result set returned by a Firestore query.
29002
29067
  * `QueryEndAtConstraint`s are created by invoking {@link (endAt:1)} or
29003
- * {@link (endBefore:1)} and can then be passed to {@link query} to create a new
29068
+ * {@link (endBefore:1)} and can then be passed to {@link (query:1)} to create a new
29004
29069
  * query instance that also contains this `QueryEndAtConstraint`.
29005
29070
  */
29006
29071
  class QueryEndAtConstraint extends QueryConstraint {