Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 70 additions & 14 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { EventEmitter2 } from "eventemitter2";
import type { Kleur } from "kleur";

declare namespace Moleculer {
/**
Expand Down Expand Up @@ -1340,21 +1341,23 @@ declare namespace Moleculer {
sender: string | null;
}

type packetType = | PACKET_UNKNOWN
| PACKET_EVENT
| PACKET_DISCONNECT
| PACKET_DISCOVER
| PACKET_INFO
| PACKET_HEARTBEAT
| PACKET_REQUEST
| PACKET_PING
| PACKET_PONG
| PACKET_RESPONSE
| PACKET_GOSSIP_REQ
| PACKET_GOSSIP_RES
| PACKET_GOSSIP_HELLO;

interface Packet {
type:
| PACKET_UNKNOWN
| PACKET_EVENT
| PACKET_DISCONNECT
| PACKET_DISCOVER
| PACKET_INFO
| PACKET_HEARTBEAT
| PACKET_REQUEST
| PACKET_PING
| PACKET_PONG
| PACKET_RESPONSE
| PACKET_GOSSIP_REQ
| PACKET_GOSSIP_RES
| PACKET_GOSSIP_HELLO;
type: packetType

target?: string;
payload: PacketPayload;
}
Expand Down Expand Up @@ -1666,6 +1669,59 @@ declare namespace Moleculer {
}
}

/**
* you can use multiple modifier with a dot
* e.g. `black.bgRed.bold`
*/
type KleurColor = keyof Kleur | string

namespace Middlewares {
namespace Debugging {
type actionLoggerOptions = {
logger?: LoggerInstance,
logLevel?: LogLevels,
logParams?: boolean,
logResponse?: boolean,
logMeta?: boolean,

folder?: string | null,
extension?: string,

colors?: {
request?: KleurColor,
response?: KleurColor,
error?: KleurColor
},
whitelist?: Array<string>
}
function ActionLogger(options?: actionLoggerOptions): Middleware;
type transitLoggerOptions = {
logger?: LoggerInstance,
logLevel?: LogLevels,
logPacketData?: boolean,

folder?: string | null,
extension?: string,

colors?: {
receive?: KleurColor,
send?: KleurColor
},

packetFilter?: Array<Packets.packetType>
}
function TransitLogger(options?: transitLoggerOptions): Middleware
}
namespace Transmit {
type compressionOptions = {
method?: "deflate" | "deflateRaw" | "gzip",
threshold?: number | string
}
function Compression(options?: compressionOptions): Middleware
function Encryption(password: string, algorithm: string, iv: string | Buffer): Middleware
}
}

interface TransitRequest {
action: string;
nodeID: string;
Expand Down