|
1 | 1 | import { DateTime } from "luxon"; |
2 | | -import Loki from "lokijs"; |
| 2 | +import Loki, { type Collection } from "lokijs"; |
3 | 3 | import { v4 } from "uuid"; |
4 | 4 | import { DriverError, MaxAttemptsExceededError } from "../error.js"; |
5 | 5 | import { QueueDoc } from "../types.js"; |
6 | 6 | import { BaseDriver } from "./base.js"; |
7 | 7 | import { loadModule } from "@brillout/load-module"; |
8 | 8 |
|
9 | | -// extract the loki memory adapter for convienence |
10 | | -const LokiMemoryAdapter = Loki.LokiMemoryAdapter; |
| 9 | +// not exported from @types/lokijs, so replicated here |
| 10 | +// src: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lokijs/index.d.ts |
| 11 | +interface LokiObj { |
| 12 | + $loki: number; |
| 13 | + meta: { |
| 14 | + created: number; // Date().getTime() |
| 15 | + revision: number; |
| 16 | + updated: number; // Date().getTime() |
| 17 | + version: number; |
| 18 | + }; |
| 19 | +} |
11 | 20 |
|
12 | 21 | /** A modified QueueDoc to support loki dates as strings */ |
13 | 22 | type LokiRepeat = Omit<QueueDoc["repeat"], "last"> & { |
@@ -78,7 +87,7 @@ const nullish = { |
78 | 87 | export const getClient = (identifier: string) => { |
79 | 88 | if (!clients[identifier]) { |
80 | 89 | clients[identifier] = new Loki(identifier, { |
81 | | - adapter: new LokiMemoryAdapter({ asyncResponses: true }), |
| 90 | + adapter: new Loki.LokiMemoryAdapter({ asyncResponses: true }), |
82 | 91 | }); |
83 | 92 | } |
84 | 93 | return clients[identifier]; |
|
0 commit comments