From 337f1b8d33fe9898a2ec609d058483fc9e0e7b99 Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Mon, 24 Feb 2020 11:11:41 +0100 Subject: [PATCH] Types --- package.json | 2 ++ persistence.d.ts | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 persistence.d.ts diff --git a/package.json b/package.json index 69264a8..987c44f 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "7.2.1", "description": "The spec for an Aedes persistence, with abstract tests and a fast in-memory implementation.", "main": "persistence.js", + "types": "persistence.d.ts", "scripts": { "lint": "standard --verbose | snazzy", "unit": "tape test.js | faucet", @@ -37,6 +38,7 @@ }, "homepage": "https://github.com/moscajs/aedes-persistence#readme", "devDependencies": { + "aedes": "^0.40.1", "concat-stream": "^2.0.0", "faucet": "0.0.1", "license-checker": "^25.0.1", diff --git a/persistence.d.ts b/persistence.d.ts new file mode 100644 index 0000000..2c14c2f --- /dev/null +++ b/persistence.d.ts @@ -0,0 +1,36 @@ + + +import EventEmitter = NodeJS.EventEmitter +import { AedesPacket } from 'aedes-packet' +import { Client } from 'aedes' + +declare function persistence(): persistence.MemoryPersistence + +// eslint-disable-next-line no-redeclare +declare namespace persistence { + interface MemoryPersistence { + storeRetained(packet: AedesPacket, cb: (error: Error | null) => void): void + createRetainedStream(pattern: String): ReadableStream + createRetainedStreamCombi(pattern: Array): ReadableStream + addSubscriptions(client: Client, subs: Array, cb: (error: Error | null, client: Client) => void): void + removeSubscriptions(client: Client, subs: Array, cb: (error: Error | null, client: Client) => void): void + subscriptionsByClient(client: Client, cb: (error: Error | null, subs: Array, client: Client) => void): void + countOffline(cb: (error: Error | null, subscriptionsCount: Number, clientsCount: Number) => void): void + subscriptionsByTopic(pattern: String, cb: (error: Error | null, subs: Array) => void): void + cleanSubscriptions(client: Client, cb: (error: Error | null, client: Client) => void): void + outgoingEnqueue(sub: String, packet: AedesPacket, cb: (error: Error | null) => void): void + outgoingEnqueueCombi(sub: Array, packet: AedesPacket, cb: (error: Error | null) => void): void + outgoingUpdate(client: Client, packet: AedesPacket, cb: (error: Error | null, client: Client, packet: AedesPacket) => void): void + outgoingClearMessageId(client: Client, packet: AedesPacket, cb: (error: Error | null, packet: AedesPacket) => AedesPacket): void + outgoingStream(client: Client): ReadableStream + incomingStorePacket(client: Client, packet: AedesPacket, cb: (error: Error | null) => void): void + incomingGetPacket(client: Client, packet: AedesPacket, cb: (error: Error | null, packet: AedesPacket) => void): void + incomingDelPacket(client: Client, packet: AedesPacket, cb: (error: Error | null) => void): void + putWill(client: Client, packet: AedesPacket, cb: (error: Error | null, client: Client) => void): void + getWill(client: Client, cb: (error: Error | null, will: AedesPacket, client: Client) => void): void + delWill(client: Client, cb: (error: Error | null, will: AedesPacket, client: Client) => void): void + streamWill(brokers: Record): ReadableStream + getClientList(topic: String): ReadableStream + destroy(cb: (error: Error | null) => void): void + } +} \ No newline at end of file