| 1 | import { UnidentifiedQueueStoreEntry, QueueStoreEntry } from './QueueDb.js';
|
|---|
| 2 | import '../_version.js';
|
|---|
| 3 | /**
|
|---|
| 4 | * A class to manage storing requests from a Queue in IndexedDB,
|
|---|
| 5 | * indexed by their queue name for easier access.
|
|---|
| 6 | *
|
|---|
| 7 | * Most developers will not need to access this class directly;
|
|---|
| 8 | * it is exposed for advanced use cases.
|
|---|
| 9 | */
|
|---|
| 10 | export declare class QueueStore {
|
|---|
| 11 | private readonly _queueName;
|
|---|
| 12 | private readonly _queueDb;
|
|---|
| 13 | /**
|
|---|
| 14 | * Associates this instance with a Queue instance, so entries added can be
|
|---|
| 15 | * identified by their queue name.
|
|---|
| 16 | *
|
|---|
| 17 | * @param {string} queueName
|
|---|
| 18 | */
|
|---|
| 19 | constructor(queueName: string);
|
|---|
| 20 | /**
|
|---|
| 21 | * Append an entry last in the queue.
|
|---|
| 22 | *
|
|---|
| 23 | * @param {Object} entry
|
|---|
| 24 | * @param {Object} entry.requestData
|
|---|
| 25 | * @param {number} [entry.timestamp]
|
|---|
| 26 | * @param {Object} [entry.metadata]
|
|---|
| 27 | */
|
|---|
| 28 | pushEntry(entry: UnidentifiedQueueStoreEntry): Promise<void>;
|
|---|
| 29 | /**
|
|---|
| 30 | * Prepend an entry first in the queue.
|
|---|
| 31 | *
|
|---|
| 32 | * @param {Object} entry
|
|---|
| 33 | * @param {Object} entry.requestData
|
|---|
| 34 | * @param {number} [entry.timestamp]
|
|---|
| 35 | * @param {Object} [entry.metadata]
|
|---|
| 36 | */
|
|---|
| 37 | unshiftEntry(entry: UnidentifiedQueueStoreEntry): Promise<void>;
|
|---|
| 38 | /**
|
|---|
| 39 | * Removes and returns the last entry in the queue matching the `queueName`.
|
|---|
| 40 | *
|
|---|
| 41 | * @return {Promise<QueueStoreEntry|undefined>}
|
|---|
| 42 | */
|
|---|
| 43 | popEntry(): Promise<QueueStoreEntry | undefined>;
|
|---|
| 44 | /**
|
|---|
| 45 | * Removes and returns the first entry in the queue matching the `queueName`.
|
|---|
| 46 | *
|
|---|
| 47 | * @return {Promise<QueueStoreEntry|undefined>}
|
|---|
| 48 | */
|
|---|
| 49 | shiftEntry(): Promise<QueueStoreEntry | undefined>;
|
|---|
| 50 | /**
|
|---|
| 51 | * Returns all entries in the store matching the `queueName`.
|
|---|
| 52 | *
|
|---|
| 53 | * @param {Object} options See {@link workbox-background-sync.Queue~getAll}
|
|---|
| 54 | * @return {Promise<Array<Object>>}
|
|---|
| 55 | */
|
|---|
| 56 | getAll(): Promise<QueueStoreEntry[]>;
|
|---|
| 57 | /**
|
|---|
| 58 | * Returns the number of entries in the store matching the `queueName`.
|
|---|
| 59 | *
|
|---|
| 60 | * @param {Object} options See {@link workbox-background-sync.Queue~size}
|
|---|
| 61 | * @return {Promise<number>}
|
|---|
| 62 | */
|
|---|
| 63 | size(): Promise<number>;
|
|---|
| 64 | /**
|
|---|
| 65 | * Deletes the entry for the given ID.
|
|---|
| 66 | *
|
|---|
| 67 | * WARNING: this method does not ensure the deleted entry belongs to this
|
|---|
| 68 | * queue (i.e. matches the `queueName`). But this limitation is acceptable
|
|---|
| 69 | * as this class is not publicly exposed. An additional check would make
|
|---|
| 70 | * this method slower than it needs to be.
|
|---|
| 71 | *
|
|---|
| 72 | * @param {number} id
|
|---|
| 73 | */
|
|---|
| 74 | deleteEntry(id: number): Promise<void>;
|
|---|
| 75 | /**
|
|---|
| 76 | * Removes and returns the first or last entry in the queue (based on the
|
|---|
| 77 | * `direction` argument) matching the `queueName`.
|
|---|
| 78 | *
|
|---|
| 79 | * @return {Promise<QueueStoreEntry|undefined>}
|
|---|
| 80 | * @private
|
|---|
| 81 | */
|
|---|
| 82 | _removeEntry(entry?: QueueStoreEntry): Promise<QueueStoreEntry | undefined>;
|
|---|
| 83 | }
|
|---|