Skip to content
Open
Changes from 5 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
80 changes: 66 additions & 14 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { EventEmitter2 } from "eventemitter2";
import type { Kleur } from "kleur";

declare namespace Moleculer {
/**
Expand Down Expand Up @@ -1342,21 +1343,24 @@ 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 @@ -1668,6 +1672,54 @@ declare namespace Moleculer {
}
}

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

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>;
};
type TransitLoggerOptions = {
logger?: LoggerInstance;
logLevel?: LogLevels;
logPacketData?: boolean;
folder?: string | null;
extension?: string;
colors?: {
receive?: KleurColor;
send?: KleurColor;
};
packetFilter?: Array<Packets.packetType>;
};
type CompressionOptions = {
method?: "deflate" | "deflateRaw" | "gzip";
threshold?: number | string;
};
export const Middlewares: {
Debugging: {
ActionLogger(options?: ActionLoggerOptions): Middleware;
TransitLogger(options?: TransitLoggerOptions): Middleware;
};
Transmit: {
Compression(options?: CompressionOptions): Middleware;
Encryption(password: string, algorithm: string, iv: string | Buffer): Middleware;
};
};

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