;
- port: number| null;
+ port: number | null;
hostname: string | null;
udpAddress: string | null;
@@ -521,7 +521,7 @@ declare namespace Moleculer {
disconnected(): void;
}
- class Context {
+ class Context
{
constructor(broker: ServiceBroker, endpoint: Endpoint);
id: string;
broker: ServiceBroker;
@@ -546,7 +546,7 @@ declare namespace Moleculer {
needAck: boolean | null;
ackID: string | null;
- locals: GenericObject;
+ locals: L;
level: number;
@@ -600,7 +600,7 @@ declare namespace Moleculer {
[name: string]: any;
}
- type ServiceEventLegacyHandler = (payload: any, sender: string, eventName: string, ctx: Context) => void;
+ type ServiceEventLegacyHandler = (payload: any, sender: string, eventName: string, ctx: Context) => void;
type ServiceEventHandler = (ctx: Context) => void;
@@ -616,17 +616,17 @@ declare namespace Moleculer {
type ServiceEvents = { [key: string]: ServiceEventHandler | ServiceEventLegacyHandler | ServiceEvent };
- type ServiceMethods = { [key: string]: (...args: any[]) => any } & ThisType;
+ type ServiceMethods = { [key: string]: (...args: any[]) => any } & ThisType;
type CallMiddlewareHandler = (actionName: string, params: any, opts: CallingOptions) => Promise;
type Middleware = {
[name: string]:
- | ((handler: ActionHandler, action: ActionSchema) => any)
- | ((handler: ActionHandler, event: ServiceEvent) => any)
- | ((handler: ActionHandler) => any)
- | ((service: Service) => any)
- | ((broker: ServiceBroker) => any)
- | ((handler: CallMiddlewareHandler) => CallMiddlewareHandler)
+ | ((handler: ActionHandler, action: ActionSchema) => any)
+ | ((handler: ActionHandler, event: ServiceEvent) => any)
+ | ((handler: ActionHandler) => any)
+ | ((service: Service) => any)
+ | ((broker: ServiceBroker) => any)
+ | ((handler: CallMiddlewareHandler) => CallMiddlewareHandler)
}
type MiddlewareInit = (broker: ServiceBroker) => Middleware;
@@ -687,7 +687,7 @@ declare namespace Moleculer {
[name: string]: any;
}
- type ServiceAction = , P extends GenericObject = GenericObject>(params?: P, opts?: CallingOptions) => T;
+ type ServiceAction = , P extends GenericObject = GenericObject>(params?: P, opts?: CallingOptions) => T;
interface ServiceActions {
[name: string]: ServiceAction;
@@ -695,7 +695,7 @@ declare namespace Moleculer {
interface WaitForServicesResult {
services: string[];
- statuses: Array<{ name: string; available: boolean}>;
+ statuses: Array<{ name: string; available: boolean }>;
}
class Service implements ServiceSchema {
@@ -781,7 +781,7 @@ declare namespace Moleculer {
options: DiscovererOptions
}
- interface DiscovererOptions extends GenericObject {
+ interface DiscovererOptions extends GenericObject {
heartbeatInterval?: number;
heartbeatTimeout?: number;
disableHeartbeatChecks?: boolean;
@@ -861,9 +861,6 @@ declare namespace Moleculer {
middlewares?: Array;
- replCommands?: Array;
- replDelimiter?: string;
-
metadata?: GenericObject;
ServiceFactory?: typeof Service;
@@ -943,7 +940,7 @@ declare namespace Moleculer {
caller?: string;
}
- interface MCallCallingOptions extends CallingOptions{
+ interface MCallCallingOptions extends CallingOptions {
settled?: boolean;
}
@@ -988,15 +985,9 @@ declare namespace Moleculer {
interface ServiceSearchObj {
name: string;
- version?: string|number;
- }
-
- interface MoleculerRepl extends Vorpal{
- removeIfExist(command:string): void;
+ version?: string | number;
}
-
-
namespace Loggers {
class Base {
constructor(opts?: GenericObject);
@@ -1047,8 +1038,6 @@ declare namespace Moleculer {
start(): Promise;
stop(): Promise;
- repl(): MoleculerRepl;
-
errorHandler(err: Error, info: GenericObject): void;
wrapMethod(method: string, handler: ActionHandler, bindTo?: any, opts?: MiddlewareCallHandlerOptions): typeof handler;
@@ -1235,9 +1224,9 @@ declare namespace Moleculer {
get(key: string): Promise;
getWithTTL(key: string): Promise;
set(key: string, data: any, ttl?: number): Promise;
- del(key: string|Array): Promise;
- clean(match?: string|Array): Promise;
- getCacheKey(actionName: string, params: object, meta: object, keys: Array | null) : string;
+ del(key: string | Array): Promise;
+ clean(match?: string | Array): Promise;
+ getCacheKey(actionName: string, params: object, meta: object, keys: Array | null): string;
defaultKeygen(actionName: string, params: object | null, meta: object | null, keys: Array | null): string;
}
@@ -1290,32 +1279,32 @@ declare namespace Moleculer {
convertSchemaToMoleculer(schema: any): GenericObject;
}
- class Validator extends BaseValidator {} // deprecated
+ class Validator extends BaseValidator { } // deprecated
abstract class BaseStrategy {
- constructor(registry:ServiceRegistry, broker:ServiceBroker, opts?:object);
+ constructor(registry: ServiceRegistry, broker: ServiceBroker, opts?: object);
select(list: any[], ctx?: Context): Endpoint;
}
type ValidatorNames = "Fastest"
- class RoundRobinStrategy extends BaseStrategy {}
- class RandomStrategy extends BaseStrategy {}
- class CpuUsageStrategy extends BaseStrategy {}
- class LatencyStrategy extends BaseStrategy {}
- class ShardStrategy extends BaseStrategy {}
+ class RoundRobinStrategy extends BaseStrategy { }
+ class RandomStrategy extends BaseStrategy { }
+ class CpuUsageStrategy extends BaseStrategy { }
+ class LatencyStrategy extends BaseStrategy { }
+ class ShardStrategy extends BaseStrategy { }
namespace Strategies {
- class Base extends BaseStrategy {}
- class RoundRobin extends RoundRobinStrategy {}
- class Random extends RandomStrategy {}
- class CpuUsage extends CpuUsageStrategy {}
- class Latency extends LatencyStrategy {}
- class Shard extends ShardStrategy {}
+ class Base extends BaseStrategy { }
+ class RoundRobin extends RoundRobinStrategy { }
+ class Random extends RandomStrategy { }
+ class CpuUsage extends CpuUsageStrategy { }
+ class Latency extends LatencyStrategy { }
+ class Shard extends ShardStrategy { }
}
abstract class BaseDiscoverer {
- constructor(opts?:DiscovererOptions);
+ constructor(opts?: DiscovererOptions);
transit?: Transit;
localNode?: BrokerNode;
@@ -1333,23 +1322,23 @@ declare namespace Moleculer {
beat(): Promise;
checkRemoteNodes(): void;
checkOfflineNodes(): void;
- heartbeatReceived(nodeID:string, payload:GenericObject): void;
- processRemoteNodeInfo(nodeID:string, payload:GenericObject): BrokerNode;
+ heartbeatReceived(nodeID: string, payload: GenericObject): void;
+ processRemoteNodeInfo(nodeID: string, payload: GenericObject): BrokerNode;
sendHeartbeat(): Promise;
discoverNode(nodeID: string): Promise;
discoverAllNodes(): Promise;
localNodeReady(): Promise;
sendLocalNodeInfo(nodeID: string): Promise;
localNodeDisconnected(): Promise;
- remoteNodeDisconnected(nodeID:string, isUnexpected:boolean): void;
+ remoteNodeDisconnected(nodeID: string, isUnexpected: boolean): void;
}
namespace Discoverers {
- class Base extends BaseDiscoverer {}
- class Local extends BaseDiscoverer {}
- class Redis extends BaseDiscoverer {}
- class Etcd3 extends BaseDiscoverer {}
+ class Base extends BaseDiscoverer { }
+ class Local extends BaseDiscoverer { }
+ class Redis extends BaseDiscoverer { }
+ class Etcd3 extends BaseDiscoverer { }
}
interface ValidatorOptions {
@@ -1358,12 +1347,12 @@ declare namespace Moleculer {
}
namespace Validators {
- class Base extends BaseValidator {}
- class Fastest extends BaseValidator {}
+ class Base extends BaseValidator { }
+ class Fastest extends BaseValidator { }
}
namespace Transporters {
- class Base extends Transporter {}
+ class Base extends Transporter { }
class Fake extends Base { }
class NATS extends Base { }
class MQTT extends Base { }
@@ -1496,10 +1485,10 @@ declare namespace Moleculer {
}
interface ActionCatalogListOptions {
- onlyLocal?:boolean;
- onlyAvailable?:boolean;
- skipInternal?:boolean;
- withEndpoints?:boolean;
+ onlyLocal?: boolean;
+ onlyAvailable?: boolean;
+ skipInternal?: boolean;
+ withEndpoints?: boolean;
}
class ServiceRegistry {
@@ -1537,85 +1526,6 @@ declare namespace Moleculer {
const CIRCUIT_HALF_OPEN: string;
const CIRCUIT_OPEN: string;
- class Vorpal {
- parse(argv: ReadonlyArray): this;
- delimiter(value: string): this;
- show(): this;
- hide(): this;
- find(command: string): Vorpal.Command;
- exec(command: string): Promise<{}>;
- execSync(command: string): Promise<{}>;
- log(value: string, ...values: string[]): this;
- history(id: string): this;
- localStorage(id: string): object;
- help(value: (cmd: string) => string): this;
- pipe(value: (stdout: string) => string): this;
- use(extension: Vorpal.Extension): this;
- catch(command: string, description?: string): Vorpal.Catch;
- command(command: string, description?: string): Vorpal.Command;
- version(version: string): this;
- sigint(value: () => void): this;
- ui: Vorpal.UI;
- activeCommand: Vorpal.CommandInstance;
- }
-
- namespace Vorpal {
- interface Args {
- [key: string]: any;
- options: {
- [key: string]: any;
- };
- }
-
- interface PromptObject {
- [key: string]: any;
- }
-
- type Action = (args: Args) => Promise;
- type Cancel = () => void;
-
- class Command {
- _name: string;
- _fn: Action;
- _cancel: Cancel | undefined;
- alias(command: string): this;
- parse(value: (command: string, args: Args) => string): this;
- option(option: string, description: string, autocomplete?: ReadonlyArray): this;
- types(types: { string?: ReadonlyArray }): this;
- hidden(): this;
- remove(): this;
- help(value: (args: Args) => void): this;
- validate(value: (args: Args) => boolean | string): this;
- autocomplete(values: ReadonlyArray | { data: () => Promise> }): this;
- action(action: Action): this;
- cancel(cancel: Cancel): this;
- allowUnknownOptions(): this;
- }
-
- class Catch extends Command { }
-
- class Extension { }
-
- class UI {
- delimiter(text?: string): string;
- input(text?: string): string;
- imprint(): void;
- submit(command: string): string;
- cancel(): void;
- redraw: {
- (text: string, ...texts: string[]): void;
- clear(): void;
- done(): void;
- };
- }
-
- class CommandInstance {
- log(value: string, ...values: string[]): void;
- prompt(prompt: object | ReadonlyArray