@firebase/firestore 4.7.14 → 4.7.15-canary.2fe754727

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.
@@ -14,19 +14,36 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
+ import { DbIndexEntry } from '../local/indexeddb_schema';
18
+ import { DbIndexEntryKey, KeySafeBytes } from '../local/indexeddb_sentinels';
17
19
  import { DocumentKey } from '../model/document_key';
18
20
  /** Represents an index entry saved by the SDK in persisted storage. */
19
21
  export declare class IndexEntry {
20
- readonly indexId: number;
21
- readonly documentKey: DocumentKey;
22
- readonly arrayValue: Uint8Array;
23
- readonly directionalValue: Uint8Array;
24
- constructor(indexId: number, documentKey: DocumentKey, arrayValue: Uint8Array, directionalValue: Uint8Array);
22
+ readonly _indexId: number;
23
+ readonly _documentKey: DocumentKey;
24
+ readonly _arrayValue: Uint8Array;
25
+ readonly _directionalValue: Uint8Array;
26
+ constructor(_indexId: number, _documentKey: DocumentKey, _arrayValue: Uint8Array, _directionalValue: Uint8Array);
25
27
  /**
26
28
  * Returns an IndexEntry entry that sorts immediately after the current
27
29
  * directional value.
28
30
  */
29
31
  successor(): IndexEntry;
32
+ dbIndexEntry(uid: string, orderedDocumentKey: Uint8Array, documentKey: DocumentKey): DbIndexEntry;
33
+ dbIndexEntryKey(uid: string, orderedDocumentKey: Uint8Array, documentKey: DocumentKey): DbIndexEntryKey;
30
34
  }
31
35
  export declare function indexEntryComparator(left: IndexEntry, right: IndexEntry): number;
32
36
  export declare function compareByteArrays(left: Uint8Array, right: Uint8Array): number;
37
+ /**
38
+ * Workaround for WebKit bug: https://bugs.webkit.org/show_bug.cgi?id=292721
39
+ * Create a key safe representation of Uint8Array values.
40
+ * If the browser is detected as Safari or WebKit, then
41
+ * the input array will be converted to "sortable byte string".
42
+ * Otherwise, the input array will be returned in its original type.
43
+ */
44
+ export declare function encodeKeySafeBytes(array: Uint8Array): KeySafeBytes;
45
+ /**
46
+ * Reverts the key safe representation of Uint8Array (created by
47
+ * encodeKeySafeBytes) to a normal Uint8Array.
48
+ */
49
+ export declare function decodeKeySafeBytes(input: KeySafeBytes): Uint8Array;
@@ -19,7 +19,7 @@ import { IndexKind } from '../model/field_index';
19
19
  import { BundledQuery } from '../protos/firestore_bundle_proto';
20
20
  import { Document as ProtoDocument, DocumentsTarget as ProtoDocumentsTarget, QueryTarget as ProtoQueryTarget, Write as ProtoWrite } from '../protos/firestore_proto_api';
21
21
  import { EncodedResourcePath } from './encoded_resource_path';
22
- import { DbTimestampKey } from './indexeddb_sentinels';
22
+ import { DbTimestampKey, KeySafeBytes } from './indexeddb_sentinels';
23
23
  /**
24
24
  * Schema Version for the Web client:
25
25
  * 1. Initial version including Mutation Queue, Query Cache, and Remote
@@ -44,8 +44,10 @@ import { DbTimestampKey } from './indexeddb_sentinels';
44
44
  * 14. Add overlays.
45
45
  * 15. Add indexing support.
46
46
  * 16. Parse timestamp strings before creating index entries.
47
+ * 17. TODO(tomandersen)
48
+ * 18. Encode key safe representations of IndexEntry in DbIndexEntryStore.
47
49
  */
48
- export declare const SCHEMA_VERSION = 17;
50
+ export declare const SCHEMA_VERSION = 18;
49
51
  /**
50
52
  * Wrapper class to store timestamps (seconds and nanos) in IndexedDb objects.
51
53
  */
@@ -468,14 +470,14 @@ export interface DbIndexEntry {
468
470
  /** The user id for this entry. */
469
471
  uid: string;
470
472
  /** The encoded array index value for this entry. */
471
- arrayValue: Uint8Array;
473
+ arrayValue: KeySafeBytes;
472
474
  /** The encoded directional value for equality and inequality filters. */
473
- directionalValue: Uint8Array;
475
+ directionalValue: KeySafeBytes;
474
476
  /**
475
477
  * The document key this entry points to. This entry is encoded by an ordered
476
478
  * encoder to match the key order of the index.
477
479
  */
478
- orderedDocumentKey: Uint8Array;
480
+ orderedDocumentKey: KeySafeBytes;
479
481
  /** The segments of the document key this entry points to. */
480
482
  documentKey: string[];
481
483
  }
@@ -201,6 +201,14 @@ export declare const DbIndexStateKeyPath: string[];
201
201
  */
202
202
  export declare const DbIndexStateSequenceNumberIndex = "sequenceNumberIndex";
203
203
  export declare const DbIndexStateSequenceNumberIndexPath: string[];
204
+ /**
205
+ * Representation of a byte array that is safe for
206
+ * use in an IndexedDb key. The value is either
207
+ * a "sortable byte string", which is key safe in
208
+ * Safari/WebKit, or the value is a Uint8Array,
209
+ * which is key safe in other browsers.
210
+ */
211
+ export type KeySafeBytes = Uint8Array | string;
204
212
  /**
205
213
  * The key for each index entry consists of the index id and its user id,
206
214
  * the encoded array and directional value for the indexed fields as well as
@@ -209,9 +217,9 @@ export declare const DbIndexStateSequenceNumberIndexPath: string[];
209
217
  export type DbIndexEntryKey = [
210
218
  number,
211
219
  string,
212
- Uint8Array,
213
- Uint8Array,
214
- Uint8Array,
220
+ KeySafeBytes,
221
+ KeySafeBytes,
222
+ KeySafeBytes,
215
223
  string[]
216
224
  ];
217
225
  /** Name of the IndexedDb object store. */
@@ -248,6 +256,7 @@ export declare const V14_STORES: string[];
248
256
  export declare const V15_STORES: string[];
249
257
  export declare const V16_STORES: string[];
250
258
  export declare const V17_STORES: string[];
259
+ export declare const V18_STORES: string[];
251
260
  /**
252
261
  * The list of all default IndexedDB stores used throughout the SDK. This is
253
262
  * used when creating transactions so that access across all stores is done
@@ -4,7 +4,7 @@ import { Logger, LogLevel } from '@firebase/logger';
4
4
  import { FirebaseError, updateEmulatorBanner, getDefaultEmulatorHostnameAndPort, isCloudWorkstation, deepEqual, pingServer, createMockUserToken, getModularInstance } from '@firebase/util';
5
5
  import { Integer } from '@firebase/webchannel-wrapper/bloom-blob';
6
6
 
7
- const A = "4.7.14";
7
+ const A = "4.7.15-canary.2fe754727";
8
8
 
9
9
  /**
10
10
  * @license
@@ -65,7 +65,7 @@ User.MOCK_USER = new User("mock-user");
65
65
  * See the License for the specific language governing permissions and
66
66
  * limitations under the License.
67
67
  */
68
- let P = "11.7.3";
68
+ let P = "11.8.0-canary.2fe754727";
69
69
 
70
70
  /**
71
71
  * @license
@@ -5196,8 +5196,8 @@ function __PRIVATE_isWrite(t) {
5196
5196
  _t: !0
5197
5197
  });
5198
5198
  }
5199
- dt(t) {
5200
- return __PRIVATE_createError(t, this.settings.methodName, this.settings.ft || !1, this.path, this.settings.Et);
5199
+ ft(t) {
5200
+ return __PRIVATE_createError(t, this.settings.methodName, this.settings.dt || !1, this.path, this.settings.Et);
5201
5201
  }
5202
5202
  /** Returns 'true' if 'fieldPath' was traversed when creating this context. */ contains(t) {
5203
5203
  return void 0 !== this.fieldMask.find((e => t.isPrefixOf(e))) || void 0 !== this.fieldTransforms.find((e => t.isPrefixOf(e.field)));
@@ -5208,8 +5208,8 @@ function __PRIVATE_isWrite(t) {
5208
5208
  if (this.path) for (let t = 0; t < this.path.length; t++) this.ct(this.path.get(t));
5209
5209
  }
5210
5210
  ct(t) {
5211
- if (0 === t.length) throw this.dt("Document fields must not be empty");
5212
- if (__PRIVATE_isWrite(this.it) && ut.test(t)) throw this.dt('Document fields cannot begin and end with "__"');
5211
+ if (0 === t.length) throw this.ft("Document fields must not be empty");
5212
+ if (__PRIVATE_isWrite(this.it) && ut.test(t)) throw this.ft('Document fields cannot begin and end with "__"');
5213
5213
  }
5214
5214
  }
5215
5215
 
@@ -5227,7 +5227,7 @@ function __PRIVATE_isWrite(t) {
5227
5227
  Et: r,
5228
5228
  path: FieldPath$1.emptyPath(),
5229
5229
  _t: !1,
5230
- ft: n
5230
+ dt: n
5231
5231
  }, this.databaseId, this.serializer, this.ignoreUndefinedProperties);
5232
5232
  }
5233
5233
  }
@@ -5256,7 +5256,7 @@ function __PRIVATE_newUserDataReader(t) {
5256
5256
 
5257
5257
  class __PRIVATE_DeleteFieldValueImpl extends FieldValue {
5258
5258
  _toFieldTransform(t) {
5259
- if (2 /* UserDataSource.MergeSet */ !== t.it) throw 1 /* UserDataSource.Update */ === t.it ? t.dt(`${this._methodName}() can only appear at the top level of your update data`) : t.dt(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);
5259
+ if (2 /* UserDataSource.MergeSet */ !== t.it) throw 1 /* UserDataSource.Update */ === t.it ? t.ft(`${this._methodName}() can only appear at the top level of your update data`) : t.ft(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);
5260
5260
  // No transform to add for a delete, but we need to add it to our
5261
5261
  // fieldMask so it gets deleted.
5262
5262
  return t.fieldMask.push(t.path), null;
@@ -5423,8 +5423,8 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
5423
5423
  */
5424
5424
  return function __PRIVATE_parseSentinelFieldValue(t, e) {
5425
5425
  // Sentinels are only supported with writes, and not within arrays.
5426
- if (!__PRIVATE_isWrite(e.it)) throw e.dt(`${t._methodName}() can only be used with update() and set()`);
5427
- if (!e.path) throw e.dt(`${t._methodName}() is not currently supported inside arrays`);
5426
+ if (!__PRIVATE_isWrite(e.it)) throw e.ft(`${t._methodName}() can only be used with update() and set()`);
5427
+ if (!e.path) throw e.ft(`${t._methodName}() is not currently supported inside arrays`);
5428
5428
  const r = t._toFieldTransform(e);
5429
5429
  r && e.fieldTransforms.push(r);
5430
5430
  }
@@ -5448,7 +5448,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
5448
5448
  // the set of values to be included for the IN query) that may directly
5449
5449
  // contain additional arrays (each representing an individual field
5450
5450
  // value), so we disable this validation.
5451
- if (e.settings._t && 4 /* UserDataSource.ArrayArgument */ !== e.it) throw e.dt("Nested arrays are not supported");
5451
+ if (e.settings._t && 4 /* UserDataSource.ArrayArgument */ !== e.it) throw e.ft("Nested arrays are not supported");
5452
5452
  return function __PRIVATE_parseArray(t, e) {
5453
5453
  const r = [];
5454
5454
  let n = 0;
@@ -5505,7 +5505,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
5505
5505
  };
5506
5506
  if (t instanceof DocumentReference) {
5507
5507
  const r = e.databaseId, n = t.firestore._databaseId;
5508
- if (!n.isEqual(r)) throw e.dt(`Document reference is for database ${n.projectId}/${n.database} but should be for database ${r.projectId}/${r.database}`);
5508
+ if (!n.isEqual(r)) throw e.ft(`Document reference is for database ${n.projectId}/${n.database} but should be for database ${r.projectId}/${r.database}`);
5509
5509
  return {
5510
5510
  referenceValue: __PRIVATE_toResourceName(t.firestore._databaseId || e.databaseId, t._key.path)
5511
5511
  };
@@ -5523,7 +5523,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
5523
5523
  [X]: {
5524
5524
  arrayValue: {
5525
5525
  values: t.toArray().map((t => {
5526
- if ("number" != typeof t) throw e.dt("VectorValues must only contain numeric values.");
5526
+ if ("number" != typeof t) throw e.ft("VectorValues must only contain numeric values.");
5527
5527
  return __PRIVATE_toDouble(e.serializer, t);
5528
5528
  }))
5529
5529
  }
@@ -5541,7 +5541,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
5541
5541
  * GeoPoints, etc. are not considered to look like JSON objects since they map
5542
5542
  * to specific FieldValue types other than ObjectValue.
5543
5543
  */ (t, e);
5544
- throw e.dt(`Unsupported field value: ${__PRIVATE_valueDescription(t)}`);
5544
+ throw e.ft(`Unsupported field value: ${__PRIVATE_valueDescription(t)}`);
5545
5545
  }(t, e);
5546
5546
  }
5547
5547
 
@@ -5572,7 +5572,7 @@ function __PRIVATE_validatePlainObject(t, e, r) {
5572
5572
  return "object" == typeof t && null !== t && (Object.getPrototypeOf(t) === Object.prototype || null === Object.getPrototypeOf(t));
5573
5573
  }(r)) {
5574
5574
  const n = __PRIVATE_valueDescription(r);
5575
- throw "an object" === n ? e.dt(t + " a custom object") : e.dt(t + " " + n);
5575
+ throw "an object" === n ? e.ft(t + " a custom object") : e.ft(t + " " + n);
5576
5576
  }
5577
5577
  }
5578
5578