Skip to content

Commit

Permalink
organize index.d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed Dec 10, 2023
1 parent 72d5202 commit e4b36af
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 42 deletions.
99 changes: 70 additions & 29 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// --- SERVICE BROKER ---

import ServiceBroker = require("./src/service-broker");
export { ServiceBroker };
export type { ServiceBrokerOptions, CallingOptions } from "./src/service-broker";
export type { BrokerOptions, CallingOptions } from "./src/service-broker";

// --- SERVICE ---

import Service = require("./src/service");
export { Service };
Expand All @@ -17,64 +21,101 @@ export type {
ServiceActions
} from "./src/service";

// --- CONTEXT ---

import Context = require("./src/context");
export { Context };

export * as Loggers from "./src/loggers";
export type { LogLevels } from "./src/loggers";
export type { Logger, LoggerConfig } from "./src/logger-factory";
// --- TRANSIT ---

export * as Cachers from "./src/cachers";
import Transit = require("./src/transit");
export { Transit };
export * as Packet from "./src/packets";

export * as Transporters from "./src/transporters";
// --- RUNNER ---

export * as Serializers from "./src/serializers";
import Runner = require("./src/runner");
export { Runner };
export type { RunnerFlags } from "./src/runner";

export * as Strategies from "./src/strategies";
// --- ERRORS ---

export * as Validators from "./src/validators";
export type { ValidatorNames } from "./src/validators";
export * as Errors from "./src/errors";

export type { Span, TracerOptions } from "./src/tracing";
export * as TracerExporters from "./src/tracing/exporters";
// --- UTILS ---

export * as MetricTypes from "./src/metrics/types";
export * as Utils from "./src/utils";

export * as MetricReporters from "./src/metrics/reporters";
// --- CONSTANTS ---

export type {
CIRCUIT_CLOSE,
CIRCUIT_HALF_OPEN,
CIRCUIT_HALF_OPEN_WAIT,
CIRCUIT_OPEN
} from "./src/constants";

export declare const MOLECULER_VERSION: string;
export declare const PROTOCOL_VERSION: string;
export declare const INTERNAL_MIDDLEWARES: string[];

// --- CACHERS ---

export * as Cachers from "./src/cachers";

// --- LOGGERS ---

export * as Loggers from "./src/loggers";
export type { LogLevels } from "./src/loggers";
export type { Logger, LoggerConfig } from "./src/logger-factory";

// --- METRICS ---

export * as MetricTypes from "./src/metrics/types";
export * as MetricReporters from "./src/metrics/reporters";
import MetricRegistry = require("./src/metrics/registry");
export { MetricRegistry };
export * as METRIC from "./src/metrics/constants";

import Transit = require("./src/transit");
export { Transit };
// --- MIDDLEWARES ---

export type { CallMiddlewareHandler, Middleware } from "./src/middleware";

// --- SERVICE REGISTRY ---

import Registry = require("./src/registry");
export { Registry };

import type EndpointList = require("./src/registry/endpoint-list");
export type { EndpointList };
import type Endpoint = require("./src/registry/endpoint");
export type { Endpoint };
import type ActionEndpoint = require("./src/registry/endpoint-action");
export type { ActionEndpoint };
import type EventEndpoint = require("./src/registry/endpoint-event");
import { Packet } from "./src/packets";
export type { EventEndpoint };

export * as Discoverers from "./src/registry/discoverers";

export * as Errors from "./src/errors";
// --- SERIALIZERS ---

export * as Utils from "./src/utils";
export * as Serializers from "./src/serializers";

export type {
CIRCUIT_CLOSE,
CIRCUIT_HALF_OPEN,
CIRCUIT_HALF_OPEN_WAIT,
CIRCUIT_OPEN
} from "./src/constants";
// --- STRATEGIES ---

export declare const MOLECULER_VERSION: string;
export declare const PROTOCOL_VERSION: string;
export declare const INTERNAL_MIDDLEWARES: string[];
export * as Strategies from "./src/strategies";

// Below this point are type exports which are part of modules not exported as part of the main index.js file
// --- TRACING ---

export type { CallMiddlewareHandler, Middleware } from "./src/middleware";
export type { Tracer, Span, TracerOptions } from "./src/tracing";
export * as TracerExporters from "./src/tracing/exporters";

// --- TRANSPORTERS ---

export * as Transporters from "./src/transporters";

// --- VALIDATORS ---

export * as Validators from "./src/validators";
export type { ValidatorNames } from "./src/validators";
6 changes: 3 additions & 3 deletions src/runner.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ServiceBroker = require("./service-broker");
import Service = require("./service");
import type { ServiceBrokerOptions } from "./service-broker";
import type { BrokerOptions } from "./service-broker";
import { Worker } from "cluster";

declare namespace Runner {
Expand Down Expand Up @@ -72,12 +72,12 @@ declare class Runner {
/**
* Loaded configuration file
*/
configFile: Partial<ServiceBrokerOptions>;
configFile: Partial<BrokerOptions>;

/**
* Merged configuration
*/
config: Partial<ServiceBrokerOptions>;
config: Partial<BrokerOptions>;

/**
* Process command line arguments
Expand Down
8 changes: 4 additions & 4 deletions src/service-broker.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ declare namespace ServiceBroker {

type SerializerType = SerializerConfig["type"];

export interface ServiceBrokerOptions {
export interface BrokerOptions {
namespace?: string | null;
nodeID?: string | null;

Expand Down Expand Up @@ -322,13 +322,13 @@ declare class ServiceBroker {

static INTERNAL_MIDDLEWARES: string[];

static defaultOptions: ServiceBroker.ServiceBrokerOptions;
static defaultOptions: ServiceBroker.BrokerOptions;

MOLECULER_VERSION: string;

PROTOCOL_VERSION: string;

options: ServiceBroker.ServiceBrokerOptions;
options: ServiceBroker.BrokerOptions;

Promise: PromiseConstructor;

Expand Down Expand Up @@ -376,7 +376,7 @@ declare class ServiceBroker {

runner?: Runner;

constructor(options?: ServiceBroker.ServiceBrokerOptions);
constructor(options?: ServiceBroker.BrokerOptions);

registerMiddlewares(userMiddlewares: MiddlewareHandler.Middleware[]): void;
registerMoleculerMetrics(): void;
Expand Down
6 changes: 3 additions & 3 deletions src/service-broker.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const C = require("./constants");
* @typedef {import("./service").ServiceDependency} ServiceDependency
* @typedef {import("./service").ActionHandler} ActionHandler
* @typedef {import("./service-broker")} ServiceBrokerClass
* @typedef {import("./service-broker").ServiceBrokerOptions} ServiceBrokerOptions
* @typedef {import("./service-broker").BrokerOptions} BrokerOptions
* @typedef {import("./service-broker").CallingOptions} CallingOptions
* @typedef {import("./service-broker").NodeHealthStatus} NodeHealthStatus
* @typedef {import("./service-broker").MCallDefinition} MCallDefinition
Expand All @@ -55,7 +55,7 @@ const C = require("./constants");
/**
* Default broker options
*
* @type {ServiceBrokerOptions}
* @type {BrokerOptions}
*/
const defaultOptions = {
namespace: "",
Expand Down Expand Up @@ -190,7 +190,7 @@ class ServiceBroker {
/**
* Creates an instance of ServiceBroker.
*
* @param {ServiceBrokerOptions} options
* @param {BrokerOptions} options
*
* @memberof ServiceBroker
*/
Expand Down
4 changes: 2 additions & 2 deletions src/service.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ declare namespace Service {
started?: ServiceAsyncLifecycleHandler<S> | ServiceAsyncLifecycleHandler<S>[];
stopped?: ServiceAsyncLifecycleHandler<S> | ServiceAsyncLifecycleHandler<S>[];

[name: string]: any;
// [key: string]: any;
}

export interface ServiceSettingSchema {
Expand All @@ -49,7 +49,7 @@ declare namespace Service {
$dependencyTimeout?: number;
$shutdownTimeout?: number;
$secureSettings?: string[];
[name: string]: any;
//[key: string]: any;
}

export type ServiceAction = <
Expand Down
2 changes: 1 addition & 1 deletion src/tracing/exporters/console.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Color } from "kleur";

declare namespace ConsoleTraceExporter {
export interface ConsoleTraceExporterOptions extends BaseTraceExporterOptions {
logger?: Logger;
logger?: Logger | null;
colors?: boolean;
width?: number;
gaugeWidth?: number;
Expand Down

0 comments on commit e4b36af

Please sign in to comment.