UNPKG

10.7 kBTypeScriptView Raw
1/// <reference types="node" />
2
3import { Container, ContainerSettings, Context, ILogger, ITypeRegistry, Identity, LogLevel, Logger, StoppableEvent, StoppableEventException, Symbols, Transporter } from '@e2/lib';
4import { Exception } from 'agentframework';
5
6export declare class Hash52 {
7 static toNumber(input: string): number;
8 static toBuffer(input: string): Buffer;
9 static toArray(input: string): Uint8Array;
10}
11export declare class Hash32 {
12 static toNumber(input: string): number;
13 static toBuffer(input: string): Buffer;
14 static toArray(input: string): Uint8Array;
15}
16export declare class Hash24 {
17 static toNumber(input: string): number;
18 static toBuffer(input: string): Buffer;
19 static toArray(input: string): Uint8Array;
20}
21export declare class Hash16 {
22 static toNumber(input: string): number;
23 static toBuffer(input: string): Buffer;
24 static toArray(input: string): Uint8Array;
25}
26export declare class BaseX {
27 map: object;
28 alphabet: string;
29 base: number;
30 leader: string;
31 constructor(alphabet: string);
32 static readonly singleton: BaseX;
33 fromBuffer(data: Buffer): string;
34 toBuffer(text: string): Buffer;
35 fromHex(hex: string): string;
36 toHex(text: string): string;
37 fromNumber(n: number): string;
38 toNumber(text: string): number;
39 private decodeUnsafe;
40}
41export declare class Base58 extends BaseX {
42 constructor();
43 static fromBuffer(data: Buffer): string;
44 static toBuffer(text: string): Buffer;
45 static fromHex(hex: string): string;
46 static toHex(text: string): string;
47 static fromNumber(n: number): string;
48 static toNumber(text: string): number;
49}
50export declare class Base62 extends BaseX {
51 constructor();
52 static fromBuffer(data: Buffer): string;
53 static toBuffer(text: string): Buffer;
54 static fromHex(hex: string): string;
55 static toHex(text: string): string;
56 static fromNumber(n: number): string;
57 static toNumber(text: string): number;
58}
59export declare class ObjectId {
60 _bsontype: string;
61 id: Buffer;
62 private static index;
63 constructor(id?: ObjectId | string | Buffer | number | Date);
64 generationTime: number;
65 getTimestamp(): Date;
66 equals(otherId: string | ObjectId): boolean;
67 toHexString(): string;
68 toString(format?: string): string;
69 inspect(): string;
70 toJSON(): string;
71 static createFromTime(time: number): ObjectId;
72 static createFromHexString(hex: string): ObjectId;
73 static isValid(id: any): boolean;
74 private static generate;
75 private static get_inc;
76}
77export declare function CreateHashedObjectId(inputs: Array<string | Buffer | number | any> | string | Buffer | number | any, algorithm?: string): ObjectId;
78export declare class FileStreamException extends Exception {
79}
80export declare class FileWriteException extends Exception {
81}
82export declare class File {
83 private _file;
84 private _permission;
85 private constructor();
86 static Read: number;
87 static ReadWrite: number;
88 static Write: number;
89 static resolve(root: string, filePath: string, permission: number): File;
90 toString(): string;
91 readonly path: string;
92 readonly permission: number;
93 readAll(): string;
94}
95export declare class Directory {
96 private _directory;
97 private _permission;
98 private constructor();
99 static cwd(): Directory;
100 static withReadPermission(directory: string): Directory;
101 static withReadWritePermission(directory: string): Directory;
102 static mkdir(dir: string, mode?: number): boolean;
103 private static resolve;
104 toString(): string;
105 readonly path: string;
106 directory(relativePath: string): Directory;
107 file(relativeFilePath: string): File;
108}
109export declare class ApplicationSettings extends ContainerSettings {
110 static [Symbols.Initializer](ctx: Container<ContainerSettings>, opts?: any): any;
111 AUTO_CREATE_DIRECTORY: boolean;
112 PACKAGE_FILE: string;
113 EXIT_WAIT_TIMEOUT: number;
114 HOME_DIR: string;
115 DATA_DIR: string;
116 CONF_DIR: string;
117 LOG_DIR: string;
118 LOG_LEVEL: string | 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
119}
120export declare class ApplicationLogger extends Logger {
121 static [Symbols.Initializer](app: Context<ApplicationSettings>): ILogger;
122}
123export declare class StandardOutputTransporter extends Transporter {
124 private formatter;
125 constructor(level: LogLevel, style: string);
126 format(data: string): string;
127 write(data: string): void;
128 writeSync(data: string): void;
129}
130export declare class FileLogTransporter extends Transporter {
131 private fd;
132 private stream;
133 private readonly filename;
134 constructor(level: LogLevel, filename: string);
135 openWritableFileStream(): void;
136 write(data: string): void;
137 writeSync(data: string): void;
138}
139export interface IApplicationOptions {
140 root: string;
141 confDir: string;
142 settings?: any;
143 registry?: ITypeRegistry;
144 params?: Array<any>;
145}
146export declare class Application<S extends ApplicationSettings> extends Container<S> {
147 protected readonly options: IApplicationOptions;
148 protected onCreatingState(): any;
149 protected onCreatingIdentity(): Identity;
150 protected onCreatingLogger(): ILogger;
151 protected onCreatingSettings(): S;
152 protected onCreatingRootDirectory(): Directory;
153 constructor(opts?: IApplicationOptions);
154 protected readonly root: Directory;
155 directory(relativePath?: string): Directory;
156 file(relativeFilePath: string): File;
157 exit(reason?: Error | object | string): void;
158 get(key: string, defaultValue?: any): any;
159 set(key: string, value: any): any;
160 has(key: string): boolean;
161}
162export declare class UncaughtExceptionEvent extends StoppableEvent {
163 exception: Exception | Error;
164 constructor(exception: Exception | Error);
165}
166export declare class UnhandledException extends StoppableEventException {
167 event: UncaughtExceptionEvent;
168 constructor(event: UncaughtExceptionEvent, error: Exception | Error);
169}
170export declare class SignalEvent extends StoppableEvent {
171 signal: string;
172 code: number;
173 constructor(signal: string, code: number);
174}
175export declare class UnhandledSignalEventException extends StoppableEventException {
176 event: SignalEvent;
177 constructor(event: SignalEvent, signal: string, code: number);
178}
179export declare enum ApplicationEvents {
180 signals = "signals",
181 uncaughtException = "uncaughtException",
182 unhandledRejection = "unhandledRejection",
183 exiting = "exiting",
184 exit = "exit"
185}
186export declare class ExitEvent extends StoppableEvent {
187}
188export declare function parseYAML(file: File): any;
189export declare function parseJSON(file: File): any;
190export declare function dumpYAML(data: any, filename: string): void;
191export declare function dumpJSON(data: any, filename: string): void;
192export declare function serialize(obj: any): string;
193export { Constructor, TypedConstructor, TypedConstructorWithParameters, TypedConstructorWithoutParameter } from 'agentframework';
194export { IAttribute, IAgentAttribute, IBeforeDecorateAttribute } from 'agentframework';
195export { IInterceptor } from 'agentframework';
196export { IInitializer } from 'agentframework';
197export { IInvocation } from 'agentframework';
198export { IDesign } from 'agentframework';
199export { PropertyFilter, Reflection, Property, Method, Parameter } from 'agentframework';
200export { PropertyFilters } from 'agentframework';
201export { Reflector } from 'agentframework';
202export { AgentAttribute } from 'agentframework';
203export { Decoratable } from 'agentframework';
204export { Target, UniversalDecorator, decorateAgent, decorateClass, decorateClassMember, decorateClassMethod, decorateClassField, decorateParameter, decorate } from 'agentframework';
205export { IsObject, IsFunction, IsNullOrUndefined, IsObjectOrFunction, IsSymbol, IsString, IsNumber, IsEqual, ToPropertyKey, GetPrototypeArray, GetPrototypeArrayReverse } from 'agentframework';
206export { Exception } from 'agentframework';
207export { padStart, padEnd } from '@e2/lib';
208export { ConfigurationAttribute } from '@e2/lib';
209export { ControllerAttribute } from '@e2/lib';
210export { MethodAttribute } from '@e2/lib';
211export { MiddlewareAttribute } from '@e2/lib';
212export { ParamsAttribute } from '@e2/lib';
213export { ServiceAttribute } from '@e2/lib';
214export { SingletonAttribute } from '@e2/lib';
215export { TransitAttribute } from '@e2/lib';
216export { ModelAttribute } from '@e2/lib';
217export { KeyAttribute } from '@e2/lib';
218export { PropertyAttribute } from '@e2/lib';
219export { controller, middleware, param, method, service, singleton, transit, conf } from '@e2/lib';
220export { model, key, property } from '@e2/lib';
221export { IsAssignable } from '@e2/lib';
222export { Resolvable } from '@e2/lib';
223export { IRouter, IRouterEventHandlers, RouteFunction, RouteHandler, Router } from '@e2/lib';
224export { RouterEventHandlers } from '@e2/lib';
225export { CreateObjectSignature } from '@e2/lib';
226export { CreateFlattenObject } from '@e2/lib';
227export { retry, sleep, RetryOptions, RetryContext, RetryFunction } from '@e2/lib';
228export { BeforeRetry, CalculateBackoff, HandleError, HandleTimeout } from '@e2/lib';
229export { ITypeRegistry } from '@e2/lib';
230export { TypeFinalizer, TypeInitializer } from '@e2/lib';
231export { TypeRegistry } from '@e2/lib';
232export { ITypeResolver } from '@e2/lib';
233export { TypeResolver } from '@e2/lib';
234export { Compositor } from '@e2/lib';
235export { Sequence } from '@e2/lib';
236export { StepFunction, NextFunction, LastFunction } from '@e2/lib';
237export { StoppableEvent } from '@e2/lib';
238export { PriorityEventEmitter } from '@e2/lib';
239export { ILogger } from '@e2/lib';
240export { LogLevel } from '@e2/lib';
241export { Logger } from '@e2/lib';
242export { Transporter } from '@e2/lib';
243export { AbstractLogger } from '@e2/lib';
244export { ChildLogger } from '@e2/lib';
245export { LoggerOptions } from '@e2/lib';
246export { Serializers } from '@e2/lib';
247export { ConsoleTransporter } from '@e2/lib';
248export { ConsoleFormatter } from '@e2/lib';
249export { ConsoleLogger } from '@e2/lib';
250export { DeserializationException } from '@e2/lib';
251export { SerializationException } from '@e2/lib';
252export { LoggerException } from '@e2/lib';
253export { TransporterException } from '@e2/lib';
254export { MissingConfigurationValueException } from '@e2/lib';
255export { StoppableEventException } from '@e2/lib';
256export { NotImplementedException } from '@e2/lib';
257export { NotSupportedException } from '@e2/lib';
258export { Route } from '@e2/lib';
259export { MatchedRoute } from '@e2/lib';
260export { Param } from '@e2/lib';
261export { ILoggerSettings } from '@e2/lib';
262export { Context } from '@e2/lib';
263export { Identity } from '@e2/lib';
264export { Container } from '@e2/lib';
265export { ContainerSettings } from '@e2/lib';
266export { IContainerOptions } from '@e2/lib';
267export { Symbols } from '@e2/lib';
268export { SafeJSON } from '@e2/lib';
269export { defineProperty } from '@e2/lib';
270export { IDisposable } from '@e2/lib';
271export { StringFormatter } from '@e2/lib';
\No newline at end of file