@firebase/firestore 4.7.14 → 4.7.15

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