From 12af51d587b81ccc19146c6579ae6a2aa88240aa Mon Sep 17 00:00:00 2001 From: Jakob Heuser Date: Sat, 8 Oct 2022 14:16:36 -0700 Subject: [PATCH] deps: Moves peer @types to included deps --- package.json | 4 ++-- src/driver/loki.ts | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index e94e436..bfe1730 100644 --- a/package.json +++ b/package.json @@ -82,6 +82,8 @@ "packageManager": "yarn@3.2.0", "dependencies": { "@brillout/load-module": "^0.1.1", + "@types/lokijs": "^1.5.7", + "@types/pg": "^8", "abort-controller": "^3.0.0", "cron-parser": "^4.4.0", "lokijs": "^1.5.12", @@ -97,10 +99,8 @@ "@commitlint/config-conventional": "^15.0.0", "@types/benchmark": "^2", "@types/eslint": "*", - "@types/lokijs": "^1.5.7", "@types/luxon": "^2", "@types/node": "^17.0.41", - "@types/pg": "^8", "@types/uuid": "^8", "@typescript-eslint/eslint-plugin": "^5.23.0", "@typescript-eslint/parser": "^5.23.0", diff --git a/src/driver/loki.ts b/src/driver/loki.ts index 9dc18fd..aaf9d9a 100644 --- a/src/driver/loki.ts +++ b/src/driver/loki.ts @@ -1,13 +1,22 @@ import { DateTime } from "luxon"; -import Loki from "lokijs"; +import Loki, { type Collection } from "lokijs"; import { v4 } from "uuid"; import { DriverError, MaxAttemptsExceededError } from "../error.js"; import { QueueDoc } from "../types.js"; import { BaseDriver } from "./base.js"; import { loadModule } from "@brillout/load-module"; -// extract the loki memory adapter for convienence -const LokiMemoryAdapter = Loki.LokiMemoryAdapter; +// not exported from @types/lokijs, so replicated here +// src: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lokijs/index.d.ts +interface LokiObj { + $loki: number; + meta: { + created: number; // Date().getTime() + revision: number; + updated: number; // Date().getTime() + version: number; + }; +} /** A modified QueueDoc to support loki dates as strings */ type LokiRepeat = Omit & { @@ -78,7 +87,7 @@ const nullish = { export const getClient = (identifier: string) => { if (!clients[identifier]) { clients[identifier] = new Loki(identifier, { - adapter: new LokiMemoryAdapter({ asyncResponses: true }), + adapter: new Loki.LokiMemoryAdapter({ asyncResponses: true }), }); } return clients[identifier];