@firebase/firestore 3.4.3 → 3.4.4-202202622812

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 (49) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/firestore/src/api/database.d.ts +14 -9
  3. package/dist/firestore/src/api/index_configuration.d.ts +117 -0
  4. package/dist/firestore/src/api.d.ts +1 -0
  5. package/dist/firestore/src/core/firestore_client.d.ts +2 -0
  6. package/dist/firestore/src/model/field_index.d.ts +76 -0
  7. package/dist/firestore/test/integration/api/index_configuration.test.d.ts +17 -0
  8. package/dist/index.d.ts +15 -9
  9. package/dist/index.esm2017.js +663 -602
  10. package/dist/index.esm2017.js.map +1 -1
  11. package/dist/index.esm5.js +680 -617
  12. package/dist/index.esm5.js.map +1 -1
  13. package/dist/index.node.cjs.js +100 -13
  14. package/dist/index.node.cjs.js.map +1 -1
  15. package/dist/index.node.mjs +100 -14
  16. package/dist/index.node.mjs.map +1 -1
  17. package/dist/index.rn.js +705 -602
  18. package/dist/index.rn.js.map +1 -1
  19. package/dist/internal.d.ts +120 -9
  20. package/dist/lite/firestore/src/api/database.d.ts +14 -9
  21. package/dist/lite/firestore/src/api/index_configuration.d.ts +117 -0
  22. package/dist/lite/firestore/src/api.d.ts +1 -0
  23. package/dist/lite/firestore/src/core/firestore_client.d.ts +2 -0
  24. package/dist/lite/firestore/src/model/field_index.d.ts +76 -0
  25. package/dist/lite/firestore/test/integration/api/index_configuration.test.d.ts +17 -0
  26. package/dist/lite/index.browser.esm2017.js +2 -2
  27. package/dist/lite/index.browser.esm2017.js.map +1 -1
  28. package/dist/lite/index.browser.esm5.js +2 -2
  29. package/dist/lite/index.browser.esm5.js.map +1 -1
  30. package/dist/lite/index.node.cjs.js +2 -2
  31. package/dist/lite/index.node.mjs +2 -2
  32. package/dist/lite/index.node.mjs.map +1 -1
  33. package/dist/lite/index.rn.esm2017.js +2 -2
  34. package/dist/lite/index.rn.esm2017.js.map +1 -1
  35. package/dist/lite/packages/firestore/src/api/database.d.ts +14 -9
  36. package/dist/lite/packages/firestore/src/api/index_configuration.d.ts +117 -0
  37. package/dist/lite/packages/firestore/src/api.d.ts +1 -0
  38. package/dist/lite/packages/firestore/src/core/firestore_client.d.ts +2 -0
  39. package/dist/lite/packages/firestore/src/model/field_index.d.ts +76 -0
  40. package/dist/lite/packages/firestore/test/integration/api/index_configuration.test.d.ts +17 -0
  41. package/dist/packages/firestore/dist/index.esm2017.d.ts +152 -131
  42. package/dist/packages/firestore/src/api/database.d.ts +14 -9
  43. package/dist/packages/firestore/src/api/index_configuration.d.ts +117 -0
  44. package/dist/packages/firestore/src/api.d.ts +1 -0
  45. package/dist/packages/firestore/src/core/firestore_client.d.ts +2 -0
  46. package/dist/packages/firestore/src/model/field_index.d.ts +76 -0
  47. package/dist/packages/firestore/test/integration/api/index_configuration.test.d.ts +17 -0
  48. package/dist/private.d.ts +24 -9
  49. package/package.json +5 -5
@@ -12,7 +12,7 @@ var grpcJs = require('@grpc/grpc-js');
12
12
  var protoLoader = require('@grpc/proto-loader');
13
13
 
14
14
  const name = "@firebase/firestore";
15
- const version$1 = "3.4.3";
15
+ const version$1 = "3.4.4-202202622812";
16
16
 
17
17
  /**
18
18
  * @license
@@ -65,7 +65,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
65
65
  User.FIRST_PARTY = new User('first-party-uid');
66
66
  User.MOCK_USER = new User('mock-user');
67
67
 
68
- const version = "9.6.3";
68
+ const version = "9.6.5-202202622812";
69
69
 
70
70
  /**
71
71
  * @license
@@ -21882,13 +21882,16 @@ class FirestoreClient {
21882
21882
  this.user = User.UNAUTHENTICATED;
21883
21883
  this.clientId = AutoId.newId();
21884
21884
  this.authCredentialListener = () => Promise.resolve();
21885
+ this.appCheckCredentialListener = () => Promise.resolve();
21885
21886
  this.authCredentials.start(asyncQueue, async (user) => {
21886
21887
  logDebug(LOG_TAG$2, 'Received user=', user.uid);
21887
21888
  await this.authCredentialListener(user);
21888
21889
  this.user = user;
21889
21890
  });
21890
- // Register an empty credentials change listener to activate token refresh.
21891
- this.appCheckCredentials.start(asyncQueue, () => Promise.resolve());
21891
+ this.appCheckCredentials.start(asyncQueue, newAppCheckToken => {
21892
+ logDebug(LOG_TAG$2, 'Received new app check token=', newAppCheckToken);
21893
+ return this.appCheckCredentialListener(newAppCheckToken, this.user);
21894
+ });
21892
21895
  }
21893
21896
  async getConfiguration() {
21894
21897
  return {
@@ -21904,6 +21907,9 @@ class FirestoreClient {
21904
21907
  setCredentialChangeListener(listener) {
21905
21908
  this.authCredentialListener = listener;
21906
21909
  }
21910
+ setAppCheckTokenChangeListener(listener) {
21911
+ this.appCheckCredentialListener = listener;
21912
+ }
21907
21913
  /**
21908
21914
  * Checks that the client has not been terminated. Ensures that other methods on
21909
21915
  * this class cannot be called after the client is terminated.
@@ -21965,6 +21971,7 @@ async function setOnlineComponentProvider(client, onlineComponentProvider) {
21965
21971
  // The CredentialChangeListener of the online component provider takes
21966
21972
  // precedence over the offline component provider.
21967
21973
  client.setCredentialChangeListener(user => remoteStoreHandleCredentialChange(onlineComponentProvider.remoteStore, user));
21974
+ client.setAppCheckTokenChangeListener((_, user) => remoteStoreHandleCredentialChange(onlineComponentProvider.remoteStore, user));
21968
21975
  client.onlineComponents = onlineComponentProvider;
21969
21976
  }
21970
21977
  async function ensureOfflineComponents(client) {
@@ -23517,13 +23524,13 @@ function terminate(firestore) {
23517
23524
  /**
23518
23525
  * Loads a Firestore bundle into the local cache.
23519
23526
  *
23520
- * @param firestore - The {@link Firestore} instance to load bundles for for.
23521
- * @param bundleData - An object representing the bundle to be loaded. Valid objects are
23522
- * `ArrayBuffer`, `ReadableStream<Uint8Array>` or `string`.
23527
+ * @param firestore - The {@link Firestore} instance to load bundles for.
23528
+ * @param bundleData - An object representing the bundle to be loaded. Valid
23529
+ * objects are `ArrayBuffer`, `ReadableStream<Uint8Array>` or `string`.
23523
23530
  *
23524
- * @returns
23525
- * A `LoadBundleTask` object, which notifies callers with progress updates, and completion
23526
- * or error events. It can be used as a `Promise<LoadBundleTaskProgress>`.
23531
+ * @returns A `LoadBundleTask` object, which notifies callers with progress
23532
+ * updates, and completion or error events. It can be used as a
23533
+ * `Promise<LoadBundleTaskProgress>`.
23527
23534
  */
23528
23535
  function loadBundle(firestore, bundleData) {
23529
23536
  firestore = cast(firestore, Firestore);
@@ -23533,11 +23540,16 @@ function loadBundle(firestore, bundleData) {
23533
23540
  return resultTask;
23534
23541
  }
23535
23542
  /**
23536
- * Reads a Firestore {@link Query} from local cache, identified by the given name.
23543
+ * Reads a Firestore {@link Query} from local cache, identified by the given
23544
+ * name.
23537
23545
  *
23538
23546
  * The named queries are packaged into bundles on the server side (along
23539
- * with resulting documents), and loaded to local cache using `loadBundle`. Once in local
23540
- * cache, use this method to extract a {@link Query} by name.
23547
+ * with resulting documents), and loaded to local cache using `loadBundle`. Once
23548
+ * in local cache, use this method to extract a {@link Query} by name.
23549
+ *
23550
+ * @param firestore - The {@link Firestore} instance to read the query from.
23551
+ * @param name - The name of the query.
23552
+ * @returns A `Promise` that is resolved with the Query or `null`.
23541
23553
  */
23542
23554
  function namedQuery(firestore, name) {
23543
23555
  firestore = cast(firestore, Firestore);
@@ -26226,6 +26238,80 @@ function writeBatch(firestore) {
26226
26238
  ensureFirestoreConfigured(firestore);
26227
26239
  return new WriteBatch(firestore, mutations => executeWrite(firestore, mutations));
26228
26240
  }
26241
+ /** An index component consisting of field path and index type. */
26242
+ class Segment {
26243
+ constructor(
26244
+ /** The field path of the component. */
26245
+ fieldPath,
26246
+ /** The fields sorting order. */
26247
+ kind) {
26248
+ this.fieldPath = fieldPath;
26249
+ this.kind = kind;
26250
+ }
26251
+ }
26252
+
26253
+ /**
26254
+ * @license
26255
+ * Copyright 2021 Google LLC
26256
+ *
26257
+ * Licensed under the Apache License, Version 2.0 (the "License");
26258
+ * you may not use this file except in compliance with the License.
26259
+ * You may obtain a copy of the License at
26260
+ *
26261
+ * http://www.apache.org/licenses/LICENSE-2.0
26262
+ *
26263
+ * Unless required by applicable law or agreed to in writing, software
26264
+ * distributed under the License is distributed on an "AS IS" BASIS,
26265
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26266
+ * See the License for the specific language governing permissions and
26267
+ * limitations under the License.
26268
+ */
26269
+ function setIndexConfiguration(firestore, jsonOrConfiguration) {
26270
+ firestore = cast(firestore, Firestore);
26271
+ ensureFirestoreConfigured(firestore);
26272
+ const indexConfiguration = typeof jsonOrConfiguration === 'string'
26273
+ ? tryParseJson(jsonOrConfiguration)
26274
+ : jsonOrConfiguration;
26275
+ // PORTING NOTE: We don't return an error if the user has not enabled
26276
+ // persistence since `enableIndexeddbPersistence()` can fail on the Web.
26277
+ if (Array.isArray(indexConfiguration.indexes)) {
26278
+ for (const index of indexConfiguration.indexes) {
26279
+ tryGetString(index, 'collectionGroup');
26280
+ const segments = [];
26281
+ if (Array.isArray(index.fields)) {
26282
+ for (const field of index.fields) {
26283
+ const fieldPathString = tryGetString(field, 'fieldPath');
26284
+ const fieldPath = fieldPathFromDotSeparatedString('setIndexConfiguration', fieldPathString);
26285
+ if (field.arrayConfig === 'CONTAINS') {
26286
+ segments.push(new Segment(fieldPath, 2 /* CONTAINS */));
26287
+ }
26288
+ else if (field.order === 'ASCENDING') {
26289
+ segments.push(new Segment(fieldPath, 0 /* ASCENDING */));
26290
+ }
26291
+ else if (field.order === 'DESCENDING') {
26292
+ segments.push(new Segment(fieldPath, 1 /* DESCENDING */));
26293
+ }
26294
+ }
26295
+ }
26296
+ }
26297
+ }
26298
+ // TODO(indexing): Configure indexes
26299
+ return Promise.resolve();
26300
+ }
26301
+ function tryParseJson(json) {
26302
+ try {
26303
+ return JSON.parse(json);
26304
+ }
26305
+ catch (e) {
26306
+ throw new FirestoreError(Code.INVALID_ARGUMENT, 'Failed to parse JSON:' + e.message);
26307
+ }
26308
+ }
26309
+ function tryGetString(data, property) {
26310
+ if (typeof data[property] !== 'string') {
26311
+ throw new FirestoreError(Code.INVALID_ARGUMENT, 'Missing string value for: ' + property);
26312
+ }
26313
+ return data[property];
26314
+ }
26229
26315
 
26230
26316
  /**
26231
26317
  * @license
@@ -26274,6 +26360,7 @@ exports._cast = cast;
26274
26360
  exports._debugAssert = debugAssert;
26275
26361
  exports._isBase64Available = isBase64Available;
26276
26362
  exports._logWarn = logWarn;
26363
+ exports._setIndexConfiguration = setIndexConfiguration;
26277
26364
  exports._validateIsNotUsedTogether = validateIsNotUsedTogether;
26278
26365
  exports.addDoc = addDoc;
26279
26366
  exports.arrayRemove = arrayRemove;