QueueDb.d.ts
2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import { RequestData } from './StorableRequest.js';
import '../_version.js';
export interface UnidentifiedQueueStoreEntry {
requestData: RequestData;
timestamp: number;
id?: number;
queueName?: string;
metadata?: object;
}
export interface QueueStoreEntry extends UnidentifiedQueueStoreEntry {
id: number;
}
/**
* A class to interact directly an IndexedDB created specifically to save and
* retrieve QueueStoreEntries. This class encapsulates all the schema details
* to store the representation of a Queue.
*
* @private
*/
export declare class QueueDb {
private _db;
/**
* Add QueueStoreEntry to underlying db.
*
* @param {UnidentifiedQueueStoreEntry} entry
*/
addEntry(entry: UnidentifiedQueueStoreEntry): Promise<void>;
/**
* Returns the first entry id in the ObjectStore.
*
* @return {number | undefined}
*/
getFirstEntryId(): Promise<number | undefined>;
/**
* Get all the entries filtered by index
*
* @param queueName
* @return {Promise<QueueStoreEntry[]>}
*/
getAllEntriesByQueueName(queueName: string): Promise<QueueStoreEntry[]>;
/**
* Returns the number of entries filtered by index
*
* @param queueName
* @return {Promise<number>}
*/
getEntryCountByQueueName(queueName: string): Promise<number>;
/**
* Deletes a single entry by id.
*
* @param {number} id the id of the entry to be deleted
*/
deleteEntry(id: number): Promise<void>;
/**
*
* @param queueName
* @returns {Promise<QueueStoreEntry | undefined>}
*/
getFirstEntryByQueueName(queueName: string): Promise<QueueStoreEntry | undefined>;
/**
*
* @param queueName
* @returns {Promise<QueueStoreEntry | undefined>}
*/
getLastEntryByQueueName(queueName: string): Promise<QueueStoreEntry | undefined>;
/**
* Returns either the first or the last entries, depending on direction.
* Filtered by index.
*
* @param {IDBCursorDirection} direction
* @param {IDBKeyRange} query
* @return {Promise<QueueStoreEntry | undefined>}
* @private
*/
getEndEntryFromIndex(query: IDBKeyRange, direction: IDBCursorDirection): Promise<QueueStoreEntry | undefined>;
/**
* Returns an open connection to the database.
*
* @private
*/
private getDb;
/**
* Upgrades QueueDB
*
* @param {IDBPDatabase<QueueDBSchema>} db
* @param {number} oldVersion
* @private
*/
private _upgradeDb;
}