@e-mc/module 0.10.1 → 0.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,414 +1,420 @@
1
- # @e-mc/module
2
-
3
- * NodeJS 16
4
- * ES2020
5
-
6
- ## General Usage
7
-
8
- * [Read the Docs](https://e-mc.readthedocs.io)
9
-
10
- ## Interface
11
-
12
- * [View Source](https://www.unpkg.com/@e-mc/types@0.10.1/lib/index.d.ts)
13
-
14
- ```typescript
15
- import type { LogStatus } from "./squared";
16
-
17
- import type { IHost } from "./index";
18
- import type { IAbortComponent, IPermission } from "./core";
19
- import type { LOG_TYPE, STATUS_TYPE, ExecCommand, LogArguments, LogComponent, LogDate, LogFailOptions, LogMessageOptions, LogOptions, LogProcessOptions, LogTime, LogType, LogValue, LoggerFormat, StatusType } from "./logger";
20
- import type { AsHashOptions, CheckSemVerOptions, CopyDirOptions, CopyDirResult, CopyFileOptions, CreateDirOptions, DeleteFileOptions, MoveFileOptions, ParseFunctionOptions, PermissionOptions, ProtocolType, ReadBufferOptions, ReadFileCallback, ReadFileOptions, ReadHashOptions, ReadTextOptions, RemoveDirOptions, TempDirOptions, WriteFileOptions } from "./module";
21
- import type { Settings } from "./node";
22
- import type { LoggerFormatSettings } from "/settings";
23
-
24
- import type { SpawnOptions } from "child_process";
25
- import type { BinaryLike, HashOptions } from "crypto";
26
- import type { FileTypeResult } from "file-type";
27
- import type { NoParamCallback } from "fs";
28
- import type * as EventEmitter from "events";
29
-
30
- type BufferView = Buffer | string | NodeJS.ArrayBufferView;
31
- type CpuUsage = NodeJS.CpuUsage;
32
-
33
- interface IModule extends EventEmitter, IAbortComponent {
34
- readonly status: LogStatus<StatusType>[];
35
- readonly errors: unknown[];
36
- /** @deprecated Types.supported */
37
- supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
38
- supports(name: string, value?: boolean): boolean;
39
- getTempDir(options: TempDirOptions): string;
40
- getTempDir(uuidDir: boolean, createDir: boolean): string;
41
- getTempDir(pathname: string, createDir: boolean): string;
42
- getTempDir(uuidDir: boolean, filename?: string, createDir?: boolean): string;
43
- getTempDir(pathname?: string, filename?: string, createDir?: boolean): string;
44
- canRead(uri: string, options?: PermissionOptions): boolean;
45
- canWrite(uri: string, options?: PermissionOptions): boolean;
46
- readFile(src: string): Buffer | undefined;
47
- readFile(src: string, options?: ReadFileOptions): Promise<Buffer | string> | Buffer | string | undefined;
48
- readFile(src: string, promises: true): Promise<Buffer | undefined>;
49
- readFile(src: string, options: ReadFileOptions, promises: true): Promise<Buffer | string | undefined>;
50
- readFile(src: string, callback: ReadFileCallback<Buffer | string>): Buffer | string | undefined;
51
- readFile(src: string, options: ReadFileOptions, callback: ReadFileCallback<Buffer | string>): Buffer | string | undefined;
52
- writeFile(src: string, data: BufferView, options?: WriteFileOptions): boolean;
53
- writeFile(src: string, data: BufferView, promises: true): Promise<boolean>;
54
- writeFile(src: string, data: BufferView, options: WriteFileOptions, promises: true): Promise<boolean>;
55
- writeFile(src: string, data: BufferView, callback: NoParamCallback): void;
56
- writeFile(src: string, data: BufferView, options: WriteFileOptions, callback: NoParamCallback): void;
57
- deleteFile(src: string, options?: DeleteFileOptions): boolean;
58
- deleteFile(src: string, promises: true): Promise<boolean>;
59
- deleteFile(src: string, options: DeleteFileOptions, promises: true): Promise<boolean>;
60
- deleteFile(src: string, callback: NoParamCallback): void;
61
- deleteFile(src: string, options: DeleteFileOptions, callback: NoParamCallback): void;
62
- copyFile(src: string, dest: string, options?: CopyFileOptions): boolean;
63
- copyFile(src: string, dest: string, promises: true): Promise<boolean>;
64
- copyFile(src: string, dest: string, options: CopyFileOptions, promises: true): Promise<boolean>;
65
- copyFile(src: string, dest: string, callback: NoParamCallback): void;
66
- copyFile(src: string, dest: string, options: CopyFileOptions, callback: NoParamCallback): void;
67
- moveFile(src: string, dest: string, options?: MoveFileOptions): boolean;
68
- moveFile(src: string, dest: string, promises: true): Promise<boolean>;
69
- moveFile(src: string, dest: string, options: MoveFileOptions, promises: true): Promise<boolean>;
70
- moveFile(src: string, dest: string, callback: NoParamCallback): void;
71
- moveFile(src: string, dest: string, options: MoveFileOptions, callback: NoParamCallback): void;
72
- createDir(src: string, options?: CreateDirOptions): boolean;
73
- createDir(src: string, promises: true): Promise<boolean>;
74
- createDir(src: string, options: CreateDirOptions, promises: true): Promise<boolean>;
75
- createDir(src: string, callback: NoParamCallback): void;
76
- createDir(src: string, options: CreateDirOptions, callback: NoParamCallback): void;
77
- removeDir(src: string, options?: RemoveDirOptions): boolean;
78
- removeDir(src: string, promises: true): Promise<boolean>;
79
- removeDir(src: string, options: RemoveDirOptions, promises: true): Promise<boolean>;
80
- removeDir(src: string, callback: NoParamCallback): void;
81
- removeDir(src: string, options: RemoveDirOptions, callback: NoParamCallback): void;
82
- allSettled(values: readonly PromiseLike<unknown>[], rejected?: LogValue, type?: LogType): Promise<PromiseFulfilledResult<unknown>[]>;
83
- allSettled(values: readonly PromiseLike<unknown>[], rejected?: LogValue, options?: LogFailOptions): Promise<PromiseFulfilledResult<unknown>[]>;
84
- formatMessage(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogMessageOptions): void;
85
- formatFail(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogFailOptions): void;
86
- writeFail(value: LogValue, message?: unknown, type?: LogType): void;
87
- writeFail(value: LogValue, message?: unknown, options?: LogFailOptions): void;
88
- writeTimeProcess(title: string, value: string, startTime: LogTime, options?: LogProcessOptions): void;
89
- writeTimeElapsed(title: string, value: LogValue, startTime: LogTime, options?: LogMessageOptions): void;
90
- checkPackage(err: unknown, name: string | undefined, type: LogType): boolean;
91
- checkPackage(err: unknown, name: string | undefined, options: LogFailOptions): boolean;
92
- checkPackage(err: unknown, name: string | undefined, value?: LogValue, options?: LogFailOptions | LogType): boolean;
93
- checkFail(message: unknown, options: LogFailOptions): LogArguments | false | undefined;
94
- writeLog(component: LogComponent, queue?: boolean): void;
95
- writeLog(type: StatusType, value: unknown, options: LogOptions): void;
96
- writeLog(type: StatusType, value: unknown, timeStamp?: LogDate, duration?: number): void;
97
- addLog(component: LogComponent, queue?: boolean): void;
98
- addLog(type: StatusType, value: unknown, options: LogOptions): void;
99
- addLog(type: StatusType, value: unknown, from: string, source?: string): void;
100
- addLog(type: StatusType, value: unknown, timeStamp?: LogDate, from?: string, source?: string): void;
101
- addLog(type: StatusType, value: unknown, timeStamp?: LogDate, duration?: number, from?: string, source?: string): void;
102
- getLog(...type: StatusType[]): LogStatus<StatusType>[];
103
- flushLog(): void;
104
- willAbort(value: unknown): boolean;
105
- hasOwnPermission(): boolean;
106
- isFatal(err?: unknown): boolean;
107
- detach(): void;
108
- reset(): void;
109
- get moduleName(): string;
110
- set host(value);
111
- get host(): IHost | null;
112
- set permission(value);
113
- get permission(): IPermission | null;
114
- get aborted(): boolean;
115
- set abortable(value);
116
- get abortable(): boolean;
117
- get threadable(): boolean;
118
- set sessionId(value);
119
- get sessionId(): string;
120
- set broadcastId(value);
121
- get broadcastId(): string | string[];
122
- set silent(value);
123
- get silent(): boolean;
124
- get logType(): LOG_TYPE;
125
- set logLevel(value: number | string);
126
- get logLevel(): number;
127
- get statusType(): STATUS_TYPE;
128
- set tempDir(value);
129
- get tempDir(): string;
130
-
131
- /* EventEmitter */
132
- on(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
133
- on(event: "error", listener: (err: Error) => void): this;
134
- on(event: "file:read", listener: (src: string, data: Buffer | string, options?: ReadFileOptions) => void): this;
135
- on(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this;
136
- on(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
137
- on(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
138
- on(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
139
- on(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
140
- on(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
141
- once(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
142
- once(event: "error", listener: (err: Error) => void): this;
143
- once(event: "file:read", listener: (src: string, data: Buffer | string, options?: ReadFileOptions) => void): this;
144
- once(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this;
145
- once(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
146
- once(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
147
- once(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
148
- once(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
149
- once(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
150
- emit(event: "exec", command: ExecCommand, options?: SpawnOptions): boolean;
151
- emit(event: "error", err: Error): boolean;
152
- emit(event: "file:read", src: string, data: Buffer | string, options?: ReadFileOptions): boolean;
153
- emit(event: "file:write", src: string, options?: WriteFileOptions): boolean;
154
- emit(event: "file:delete", src: string, options?: DeleteFileOptions): boolean;
155
- emit(event: "file:copy", dest: string, options?: CopyFileOptions): boolean;
156
- emit(event: "file:move", dest: string, options?: MoveFileOptions): boolean;
157
- emit(event: "dir:create", src: string, options?: CreateDirOptions): boolean;
158
- emit(event: "dir:remove", src: string, options?: RemoveDirOptions): boolean;
159
- }
160
-
161
- interface ModuleConstructor {
162
- PROCESS_TIMEOUT: number;
163
- LOG_STYLE_FAIL: LogMessageOptions;
164
- LOG_STYLE_SUCCESS: LogMessageOptions;
165
- LOG_STYLE_INFO: LogMessageOptions;
166
- LOG_STYLE_WARN: LogMessageOptions;
167
- LOG_STYLE_NOTICE: LogMessageOptions;
168
- LOG_STYLE_REVERSE: LogMessageOptions;
169
- readonly VERSION: string;
170
- readonly LOG_TYPE: LOG_TYPE;
171
- readonly LOG_FORMAT: LoggerFormatSettings<LoggerFormat<number>>;
172
- readonly STATUS_TYPE: STATUS_TYPE;
173
- readonly PLATFORM_WIN32: boolean;
174
- readonly MAX_TIMEOUT: number;
175
- readonly TEMP_DIR: string;
176
- /** @deprecated Types.supported */
177
- supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
178
- formatMessage(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogMessageOptions): void;
179
- writeFail(value: LogValue, message?: unknown, options?: LogFailOptions | LogType): void;
180
- enabled(key: string, username?: string): boolean;
181
- parseFunction(value: unknown, options?: ParseFunctionOptions): ((...args: unknown[]) => Promise<unknown> | unknown) | null;
182
- parseFunction(value: unknown, absolute: boolean, sync?: boolean): ((...args: unknown[]) => Promise<unknown> | unknown) | null;
183
- asString(value: unknown, cacheKey?: boolean | "throws"): string;
184
- asHash(data: BinaryLike, options?: AsHashOptions): string;
185
- asHash(data: BinaryLike, algorithm?: string, options?: AsHashOptions): string;
186
- asHash(data: BinaryLike, algorithm?: string, digest?: BinaryToTextEncoding): string;
187
- readHash(value: string | URL, options?: ReadHashOptions): Promise<string>;
188
- toPosix(value: unknown, normalize: boolean): string;
189
- toPosix(value: unknown, filename?: string, normalize?: boolean): string;
190
- hasLogType(value: LogType): boolean;
191
- isURL(value: string, ...exclude: string[]): boolean;
192
- isFile(value: string | URL, type?: ProtocolType): boolean;
193
- isDir(value: string | URL): boolean;
194
- isPath(value: string | URL, type?: "unc" | "unc-exists"): boolean;
195
- isPath(value: string | URL, isFile?: boolean): boolean;
196
- isErrorCode(err: unknown, ...code: string[]): boolean;
197
- fromLocalPath(value: string): string;
198
- resolveFile(value: string): string;
199
- resolvePath(value: string, base: string | URL): string;
200
- joinPath(...values: [...paths: unknown[], normalize: boolean][]): string;
201
- joinPath(...values: unknown[]): string;
202
- normalizePath(value: unknown, flags?: boolean | number): string;
203
- createDir(value: string | URL, overwrite?: boolean): boolean;
204
- removeDir(value: string | URL, sinceCreated: number, recursive?: boolean): boolean;
205
- removeDir(value: string | URL, empty?: boolean, recursive?: boolean): boolean;
206
- copyDir(src: string | URL, dest: string | URL, move?: boolean, recursive?: boolean): Promise<CopyDirResult>;
207
- copyDir(src: string | URL, dest: string | URL, options?: CopyDirOptions): Promise<CopyDirResult>;
208
- renameFile(src: string | URL, dest: string | URL, throws?: boolean): boolean;
209
- streamFile(src: string, cache: boolean): Promise<Buffer | string>;
210
- streamFile(src: string, options: ReadBufferOptions): Promise<Buffer | string>;
211
- streamFile(src: string, cache?: boolean | ReadBufferOptions, options?: ReadBufferOptions): Promise<Buffer | string>;
212
- readText(value: string | URL, cache: boolean): string;
213
- readText(value: string | URL, options: ReadTextOptions): Promise<string> | string;
214
- readText(value: string | URL, encoding?: BufferEncoding | ReadTextOptions, cache?: boolean): string;
215
- readBuffer(value: string | URL, options: ReadBufferOptions): Promise<Buffer | null> | Buffer | null;
216
- readBuffer(value: string | URL, cache?: boolean | ReadBufferOptions): Buffer | null;
217
- resolveMime(data: string | Buffer | Uint8Array | ArrayBuffer): Promise<FileTypeResult | undefined>;
218
- lookupMime(value: string, extension?: boolean): string;
219
- initCpuUsage(instance?: IModule): CpuUsage;
220
- getCpuUsage(start: CpuUsage, format: true): string;
221
- getCpuUsage(start: CpuUsage, format?: boolean): number;
222
- getMemUsage(format: true): string;
223
- getMemUsage(format?: boolean): number;
224
- formatCpuMem(start: CpuUsage, all?: boolean): string;
225
- getPackageVersion(name: string | [string, string], startDir: string, baseDir?: string): string;
226
- getPackageVersion(name: string | [string, string], unstable?: boolean, startDir?: string, baseDir?: string): string;
227
- checkSemVer(name: string | [string, string], options: CheckSemVerOptions): boolean;
228
- checkSemVer(name: string | [string, string], min: number | string, max?: number | string, unstable?: boolean, startDir?: string): boolean;
229
- checkSemVer(name: string | [string, string], min: number | string, max: number | string, options?: CheckSemVerOptions): boolean;
230
- sanitizeCmd(value: string): string;
231
- sanitizeArgs(value: string, doubleQuote?: boolean): string;
232
- sanitizeArgs(values: string[], doubleQuote?: boolean): string[];
233
- purgeMemory(percent: number, parent: boolean): Promise<number>;
234
- purgeMemory(percent: number, limit: number, parent?: boolean): Promise<number>;
235
- purgeMemory(percent?: number, limit?: number | boolean, parent?: unknown): Promise<number>;
236
- canWrite(name: "temp" | "home"): boolean;
237
- loadSettings(settings: Settings, password?: string): boolean;
238
- readonly prototype: IModule<IHost>;
239
- new(): IModule<IHost>;
240
- }
241
- ```
242
-
243
- ## Settings
244
-
245
- ```typescript
246
- import type { BackgroundColor, ForegroundColor, LogMessageOptions, LogTypeValue, LoggerProgress, LoggerStatus } from "./logger";
247
- import type { LoggerProcessSettings } from "./settings";
248
-
249
- import type { BinaryLike, CipherGCMTypes } from "crypto";
250
- import type { SecureVersion } from "tls";
251
-
252
- interface NodeModule {
253
- process?: {
254
- cpu_usage?: boolean;
255
- memory_usage?: boolean;
256
- inline?: boolean;
257
- };
258
- require?: {
259
- ext?: string | string[] | boolean;
260
- npm?: boolean;
261
- inline?: boolean;
262
- };
263
- }
264
-
265
- interface ProcessModule {
266
- env?: {
267
- apply?: boolean;
268
- };
269
- cipher?: {
270
- algorithm?: CipherGCMTypes;
271
- key?: BinaryLike;
272
- iv?: BinaryLike;
273
- };
274
- password?: string;
275
- }
276
-
277
- interface MemoryModule {
278
- settings?: {
279
- users?: boolean | string[];
280
- cache_disk?: {
281
- enabled?: boolean;
282
- min_size?: number | string;
283
- max_size?: number | string;
284
- include?: string[];
285
- exclude?: string[];
286
- expires?: number | string;
287
- };
288
- };
289
- }
290
-
291
- interface PermissionModule {
292
- home_read?: boolean;
293
- home_write?: boolean;
294
- process_exec?: (string | ExecOptions)[];
295
- }
296
-
297
- interface ErrorModule {
298
- out?: string | (err: Error, data: LogTypeValue, require?: NodeRequire) => void;
299
- fatal?: boolean;
300
- }
301
-
302
- interface TempModule {
303
- dir?: string;
304
- env?: string;
305
- write?: boolean;
306
- }
307
-
308
- interface LoggerModule {
309
- enabled?: boolean;
310
- level?: number,
311
- production?: string[];
312
- format?: {
313
- title?: {
314
- width?: number;
315
- color?: ForegroundColor;
316
- bg_color?: BackgroundColor;
317
- bold?: boolean;
318
- justify?: "left" | "center" | "right";
319
- braces?: string;
320
- as?: StringMap;
321
- };
322
- value?: {
323
- width?: number;
324
- color?: ForegroundColor;
325
- bg_color?: BackgroundColor;
326
- bold?: boolean;
327
- justify?: "left" | "center" | "right";
328
- },
329
- hint?: {
330
- width?: number;
331
- color?: ForegroundColor;
332
- bg_color?: BackgroundColor;
333
- bold?: boolean;
334
- braces?: [string, string];
335
- as?: StringMap;
336
- unit?: "auto" | "s" | "ms";
337
- };
338
- message?: {
339
- width?: number;
340
- color?: ForegroundColor;
341
- bg_color?: BackgroundColor;
342
- bold?: boolean;
343
- braces?: [string, string];
344
- };
345
- meter?: {
346
- color?: ForegroundColor;
347
- bg_color?: BackgroundColor;
348
- bg_alt_color?: BackgroundColor;
349
- bold?: boolean;
350
- };
351
- error?: {
352
- color?: ForegroundColor;
353
- alt_color?: ForegroundColor;
354
- bg_color?: BackgroundColor;
355
- braces?: [string, string];
356
- };
357
- };
358
- meter?: {
359
- http?: number;
360
- image?: number;
361
- compress?: number;
362
- process?: number;
363
- };
364
- broadcast?: {
365
- enabled?: boolean;
366
- out?: string | (value: string, options: LogMessageOptions, require?: NodeRequire) => void;
367
- color?: boolean;
368
- port?: number | number[];
369
- secure?: {
370
- port?: number | number[];
371
- ca?: string;
372
- key?: string;
373
- cert?: string;
374
- version?: SecureVersion
375
- };
376
- };
377
- color?: boolean;
378
- message?: boolean;
379
- stdout?: boolean;
380
- abort?: boolean;
381
- status?: boolean | LoggerStatus;
382
- progress?: LoggerProgress;
383
- unknown?: boolean | LoggerColor;
384
- system?: boolean | LoggerColor;
385
- process?: boolean | LoggerProcessSettings;
386
- image?: boolean | LoggerColor;
387
- compress?: boolean | LoggerColor;
388
- watch?: boolean | LoggerColor;
389
- file?: boolean | LoggerColor;
390
- cloud?: boolean | LoggerColor;
391
- db?: boolean | LoggerColor;
392
- time_elapsed?: boolean | LoggerColor;
393
- time_process?: boolean | LoggerColor;
394
- exec?: boolean | LoggerColor;
395
- http?: boolean | LoggerColor;
396
- node?: boolean | LoggerColor;
397
- session_id?: boolean | number;
398
- stack_trace?: boolean | number;
399
- }
400
- ```
401
-
402
- ## References
403
-
404
- - https://www.unpkg.com/@e-mc/types@0.10.1/lib/core.d.ts
405
- - https://www.unpkg.com/@e-mc/types@0.10.1/lib/logger.d.ts
406
- - https://www.unpkg.com/@e-mc/types@0.10.1/lib/module.d.ts
407
- - https://www.unpkg.com/@e-mc/types@0.10.1/lib/node.d.ts
408
- - https://www.unpkg.com/@e-mc/types@0.10.1/lib/settings.d.ts
409
-
410
- * https://www.npmjs.com/package/@types/node
411
-
412
- ## LICENSE
413
-
1
+ # @e-mc/module
2
+
3
+ * NodeJS 16
4
+ * ES2020
5
+
6
+ ## General Usage
7
+
8
+ * [Read the Docs](https://e-mc.readthedocs.io)
9
+
10
+ ## Interface
11
+
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.10.3/lib/index.d.ts)
13
+
14
+ ```typescript
15
+ import type { LogStatus } from "./squared";
16
+
17
+ import type { IHost } from "./index";
18
+ import type { IAbortComponent, IPermission } from "./core";
19
+ import type { LOG_TYPE, STATUS_TYPE, ExecCommand, LogArguments, LogComponent, LogDate, LogFailOptions, LogMessageOptions, LogOptions, LogProcessOptions, LogTime, LogType, LogValue, LoggerFormat, StatusType } from "./logger";
20
+ import type { AsHashOptions, CheckSemVerOptions, CopyDirOptions, CopyDirResult, CopyFileOptions, CreateDirOptions, DeleteFileOptions, GlobDirOptions, MoveFileOptions, ParseFunctionOptions, PermissionOptions, ProtocolType, ReadBufferOptions, ReadFileCallback, ReadFileOptions, ReadHashOptions, ReadTextOptions, RemoveDirOptions, TempDirOptions, WriteFileOptions } from "./module";
21
+ import type { Settings } from "./node";
22
+ import type { LoggerFormatSettings } from "/settings";
23
+
24
+ import type { SpawnOptions } from "child_process";
25
+ import type { BinaryLike, HashOptions } from "crypto";
26
+ import type { FileTypeResult } from "file-type";
27
+ import type { NoParamCallback } from "fs";
28
+ import type * as EventEmitter from "events";
29
+
30
+ type BufferView = Buffer | string | NodeJS.ArrayBufferView;
31
+ type CpuUsage = NodeJS.CpuUsage;
32
+
33
+ interface IModule extends EventEmitter, IAbortComponent {
34
+ readonly status: LogStatus<StatusType>[];
35
+ readonly errors: unknown[];
36
+ /** @deprecated Types.supported */
37
+ supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
38
+ supports(name: string, value?: boolean): boolean;
39
+ getTempDir(options: TempDirOptions): string;
40
+ getTempDir(uuidDir: boolean, createDir: boolean): string;
41
+ getTempDir(pathname: string, createDir: boolean): string;
42
+ getTempDir(uuidDir: boolean, filename?: string, createDir?: boolean): string;
43
+ getTempDir(pathname?: string, filename?: string, createDir?: boolean): string;
44
+ canRead(uri: string, options?: PermissionOptions): boolean;
45
+ canWrite(uri: string, options?: PermissionOptions): boolean;
46
+ readFile(src: string): Buffer | undefined;
47
+ readFile(src: string, options?: ReadFileOptions): Promise<Buffer | string> | Buffer | string | undefined;
48
+ readFile(src: string, promises: true): Promise<Buffer | undefined>;
49
+ readFile(src: string, options: ReadFileOptions, promises: true): Promise<Buffer | string | undefined>;
50
+ readFile(src: string, callback: ReadFileCallback<Buffer | string>): Buffer | string | undefined;
51
+ readFile(src: string, options: ReadFileOptions, callback: ReadFileCallback<Buffer | string>): Buffer | string | undefined;
52
+ writeFile(src: string, data: BufferView, options?: WriteFileOptions): boolean;
53
+ writeFile(src: string, data: BufferView, promises: true): Promise<boolean>;
54
+ writeFile(src: string, data: BufferView, options: WriteFileOptions, promises: true): Promise<boolean>;
55
+ writeFile(src: string, data: BufferView, callback: NoParamCallback): void;
56
+ writeFile(src: string, data: BufferView, options: WriteFileOptions, callback: NoParamCallback): void;
57
+ deleteFile(src: string, options?: DeleteFileOptions): boolean;
58
+ deleteFile(src: string, promises: true): Promise<boolean>;
59
+ deleteFile(src: string, options: DeleteFileOptions, promises: true): Promise<boolean>;
60
+ deleteFile(src: string, callback: NoParamCallback): void;
61
+ deleteFile(src: string, options: DeleteFileOptions, callback: NoParamCallback): void;
62
+ copyFile(src: string, dest: string, options?: CopyFileOptions): boolean;
63
+ copyFile(src: string, dest: string, promises: true): Promise<boolean>;
64
+ copyFile(src: string, dest: string, options: CopyFileOptions, promises: true): Promise<boolean>;
65
+ copyFile(src: string, dest: string, callback: NoParamCallback): void;
66
+ copyFile(src: string, dest: string, options: CopyFileOptions, callback: NoParamCallback): void;
67
+ moveFile(src: string, dest: string, options?: MoveFileOptions): boolean;
68
+ moveFile(src: string, dest: string, promises: true): Promise<boolean>;
69
+ moveFile(src: string, dest: string, options: MoveFileOptions, promises: true): Promise<boolean>;
70
+ moveFile(src: string, dest: string, callback: NoParamCallback): void;
71
+ moveFile(src: string, dest: string, options: MoveFileOptions, callback: NoParamCallback): void;
72
+ createDir(src: string, options?: CreateDirOptions): boolean;
73
+ createDir(src: string, promises: true): Promise<boolean>;
74
+ createDir(src: string, options: CreateDirOptions, promises: true): Promise<boolean>;
75
+ createDir(src: string, callback: NoParamCallback): void;
76
+ createDir(src: string, options: CreateDirOptions, callback: NoParamCallback): void;
77
+ removeDir(src: string, options?: RemoveDirOptions): boolean;
78
+ removeDir(src: string, promises: true): Promise<boolean>;
79
+ removeDir(src: string, options: RemoveDirOptions, promises: true): Promise<boolean>;
80
+ removeDir(src: string, callback: NoParamCallback): void;
81
+ removeDir(src: string, options: RemoveDirOptions, callback: NoParamCallback): void;
82
+ allSettled(values: readonly PromiseLike<unknown>[], rejected?: LogValue, type?: LogType): Promise<PromiseFulfilledResult<unknown>[]>;
83
+ allSettled(values: readonly PromiseLike<unknown>[], rejected?: LogValue, options?: LogFailOptions): Promise<PromiseFulfilledResult<unknown>[]>;
84
+ formatMessage(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogMessageOptions): void;
85
+ formatFail(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogFailOptions): void;
86
+ writeFail(value: LogValue, message?: unknown, type?: LogType): void;
87
+ writeFail(value: LogValue, message?: unknown, options?: LogFailOptions): void;
88
+ writeTimeProcess(title: string, value: string, startTime: LogTime, options?: LogProcessOptions): void;
89
+ writeTimeElapsed(title: string, value: LogValue, startTime: LogTime, options?: LogMessageOptions): void;
90
+ checkPackage(err: unknown, name: string | undefined, type: LogType): boolean;
91
+ checkPackage(err: unknown, name: string | undefined, options: LogFailOptions): boolean;
92
+ checkPackage(err: unknown, name: string | undefined, value?: LogValue, options?: LogFailOptions | LogType): boolean;
93
+ checkFail(message: unknown, options: LogFailOptions): LogArguments | false | undefined;
94
+ writeLog(component: LogComponent, queue?: boolean): void;
95
+ writeLog(type: StatusType, value: unknown, options: LogOptions): void;
96
+ writeLog(type: StatusType, value: unknown, timeStamp?: LogDate, duration?: number): void;
97
+ addLog(component: LogComponent, queue?: boolean): void;
98
+ addLog(type: StatusType, value: unknown, options: LogOptions): void;
99
+ addLog(type: StatusType, value: unknown, from: string, source?: string): void;
100
+ addLog(type: StatusType, value: unknown, timeStamp?: LogDate, from?: string, source?: string): void;
101
+ addLog(type: StatusType, value: unknown, timeStamp?: LogDate, duration?: number, from?: string, source?: string): void;
102
+ getLog(...type: StatusType[]): LogStatus<StatusType>[];
103
+ flushLog(): void;
104
+ willAbort(value: unknown): boolean;
105
+ hasOwnPermission(): boolean;
106
+ isFatal(err?: unknown): boolean;
107
+ detach(): void;
108
+ reset(): void;
109
+ get moduleName(): string;
110
+ set host(value);
111
+ get host(): IHost | null;
112
+ set permission(value);
113
+ get permission(): IPermission | null;
114
+ get aborted(): boolean;
115
+ set abortable(value);
116
+ get abortable(): boolean;
117
+ get threadable(): boolean;
118
+ set sessionId(value);
119
+ get sessionId(): string;
120
+ set broadcastId(value);
121
+ get broadcastId(): string | string[];
122
+ set silent(value);
123
+ get silent(): boolean;
124
+ get logType(): LOG_TYPE;
125
+ set logLevel(value: number | string);
126
+ get logLevel(): number;
127
+ get statusType(): STATUS_TYPE;
128
+ set tempDir(value);
129
+ get tempDir(): string;
130
+
131
+ /* EventEmitter */
132
+ on(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
133
+ on(event: "error", listener: (err: Error) => void): this;
134
+ on(event: "file:read", listener: (src: string, data: Buffer | string, options?: ReadFileOptions) => void): this;
135
+ on(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this;
136
+ on(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
137
+ on(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
138
+ on(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
139
+ on(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
140
+ on(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
141
+ once(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
142
+ once(event: "error", listener: (err: Error) => void): this;
143
+ once(event: "file:read", listener: (src: string, data: Buffer | string, options?: ReadFileOptions) => void): this;
144
+ once(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this;
145
+ once(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
146
+ once(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
147
+ once(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
148
+ once(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
149
+ once(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
150
+ emit(event: "exec", command: ExecCommand, options?: SpawnOptions): boolean;
151
+ emit(event: "error", err: Error): boolean;
152
+ emit(event: "file:read", src: string, data: Buffer | string, options?: ReadFileOptions): boolean;
153
+ emit(event: "file:write", src: string, options?: WriteFileOptions): boolean;
154
+ emit(event: "file:delete", src: string, options?: DeleteFileOptions): boolean;
155
+ emit(event: "file:copy", dest: string, options?: CopyFileOptions): boolean;
156
+ emit(event: "file:move", dest: string, options?: MoveFileOptions): boolean;
157
+ emit(event: "dir:create", src: string, options?: CreateDirOptions): boolean;
158
+ emit(event: "dir:remove", src: string, options?: RemoveDirOptions): boolean;
159
+ }
160
+
161
+ interface ModuleConstructor {
162
+ PROCESS_TIMEOUT: number;
163
+ LOG_STYLE_FAIL: LogMessageOptions;
164
+ LOG_STYLE_SUCCESS: LogMessageOptions;
165
+ LOG_STYLE_INFO: LogMessageOptions;
166
+ LOG_STYLE_WARN: LogMessageOptions;
167
+ LOG_STYLE_NOTICE: LogMessageOptions;
168
+ LOG_STYLE_REVERSE: LogMessageOptions;
169
+ readonly VERSION: string;
170
+ readonly LOG_TYPE: LOG_TYPE;
171
+ readonly LOG_FORMAT: LoggerFormatSettings<LoggerFormat<number>>;
172
+ readonly STATUS_TYPE: STATUS_TYPE;
173
+ readonly PLATFORM_WIN32: boolean;
174
+ readonly MAX_TIMEOUT: number;
175
+ readonly TEMP_DIR: string;
176
+ /** @deprecated Types.supported */
177
+ supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
178
+ formatMessage(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogMessageOptions): void;
179
+ writeFail(value: LogValue, message?: unknown, options?: LogFailOptions | LogType): void;
180
+ enabled(key: string, username?: string): boolean;
181
+ parseFunction(value: unknown, options?: ParseFunctionOptions): ((...args: unknown[]) => Promise<unknown> | unknown) | null;
182
+ parseFunction(value: unknown, absolute: boolean, sync?: boolean): ((...args: unknown[]) => Promise<unknown> | unknown) | null;
183
+ asString(value: unknown, cacheKey?: boolean | "throws"): string;
184
+ asHash(data: BinaryLike, options?: AsHashOptions): string;
185
+ asHash(data: BinaryLike, algorithm?: string, options?: HashOptions): string;
186
+ asHash(data: BinaryLike, algorithm?: string, digest?: BinaryToTextEncoding): string;
187
+ readHash(value: string | URL, options?: ReadHashOptions): Promise<string>;
188
+ toPosix(value: unknown, normalize: boolean): string;
189
+ toPosix(value: unknown, filename?: string, normalize?: boolean): string;
190
+ hasLogType(value: LogType): boolean;
191
+ isURL(value: string, ...exclude: string[]): boolean;
192
+ isFile(value: string | URL, type?: ProtocolType): boolean;
193
+ isDir(value: string | URL): boolean;
194
+ isPath(value: string | URL, type?: "unc" | "unc-exists"): boolean;
195
+ isPath(value: string | URL, isFile?: boolean): boolean;
196
+ isErrorCode(err: unknown, ...code: string[]): boolean;
197
+ fromLocalPath(value: string): string;
198
+ resolveFile(value: string): string;
199
+ resolvePath(value: string, base: string | URL): string;
200
+ joinPath(...values: [...paths: unknown[], normalize: boolean][]): string;
201
+ joinPath(...values: unknown[]): string;
202
+ normalizePath(value: unknown, flags?: boolean | number): string;
203
+ createDir(value: string | URL, overwrite?: boolean): boolean;
204
+ removeDir(value: string | URL, sinceCreated: number, recursive?: boolean): boolean;
205
+ removeDir(value: string | URL, empty?: boolean, recursive?: boolean): boolean;
206
+ copyDir(src: string | URL, dest: string | URL, move?: boolean, recursive?: boolean): Promise<CopyDirResult>;
207
+ copyDir(src: string | URL, dest: string | URL, options?: CopyDirOptions): Promise<CopyDirResult>;
208
+ globDir(src: string | URL, pattern: string | string[], recursive: boolean | number): Promise<string[]>;
209
+ globDir(src: string | URL, pattern: string | string[], options?: GlobDirOptions): Promise<string[]>;
210
+ renameFile(src: string | URL, dest: string | URL, throws?: boolean): boolean;
211
+ streamFile(src: string, cache: boolean): Promise<Buffer | string>;
212
+ streamFile(src: string, options: ReadBufferOptions): Promise<Buffer | string>;
213
+ streamFile(src: string, cache?: boolean | ReadBufferOptions, options?: ReadBufferOptions): Promise<Buffer | string>;
214
+ readText(value: string | URL, cache: boolean): string;
215
+ readText(value: string | URL, options: ReadTextOptions): Promise<string> | string;
216
+ readText(value: string | URL, encoding?: BufferEncoding | ReadTextOptions, cache?: boolean): string;
217
+ readBuffer(value: string | URL, options: ReadBufferOptions): Promise<Buffer | null> | Buffer | null;
218
+ readBuffer(value: string | URL, cache?: boolean | ReadBufferOptions): Buffer | null;
219
+ resolveMime(data: string | Buffer | Uint8Array | ArrayBuffer): Promise<FileTypeResult | undefined>;
220
+ lookupMime(value: string, extension?: boolean): string;
221
+ initCpuUsage(instance?: IModule): CpuUsage;
222
+ getCpuUsage(start: CpuUsage, format: true): string;
223
+ getCpuUsage(start: CpuUsage, format?: boolean): number;
224
+ getMemUsage(format: true): string;
225
+ getMemUsage(format?: boolean): number;
226
+ formatCpuMem(start: CpuUsage, all?: boolean): string;
227
+ getPackageVersion(name: string | [string, string], startDir: string, baseDir?: string): string;
228
+ getPackageVersion(name: string | [string, string], unstable?: boolean, startDir?: string, baseDir?: string): string;
229
+ checkSemVer(name: string | [string, string], options: CheckSemVerOptions): boolean;
230
+ /** @deprecated options */
231
+ checkSemVer(name: string | [string, string], min: number | string, max?: number | string, unstable?: boolean, startDir?: string): boolean;
232
+ checkSemVer(name: string | [string, string], min: number | string, max: number | string, options?: Omit<CheckSemVerOptions, "min" | "max" | "equals">): boolean;
233
+ sanitizeCmd(value: string): string;
234
+ sanitizeArgs(value: string, doubleQuote?: boolean): string;
235
+ sanitizeArgs(values: string[], doubleQuote?: boolean): string[];
236
+ purgeMemory(percent: number, parent: boolean): Promise<number>;
237
+ purgeMemory(percent: number, limit: number, parent?: boolean): Promise<number>;
238
+ purgeMemory(percent?: number, limit?: number | boolean, parent?: unknown): Promise<number>;
239
+ canWrite(name: "temp" | "home"): boolean;
240
+ loadSettings(settings: Settings, password?: string): boolean;
241
+ readonly prototype: IModule<IHost>;
242
+ new(): IModule<IHost>;
243
+ }
244
+ ```
245
+
246
+ ## Settings
247
+
248
+ ```typescript
249
+ import type { BackgroundColor, ForegroundColor, LogMessageOptions, LogTypeValue, LoggerProgress, LoggerStatus } from "./logger";
250
+ import type { LoggerProcessSettings } from "./settings";
251
+
252
+ import type { BinaryLike, CipherGCMTypes } from "crypto";
253
+ import type { SecureVersion } from "tls";
254
+
255
+ interface NodeModule {
256
+ process?: {
257
+ cpu_usage?: boolean;
258
+ memory_usage?: boolean;
259
+ inline?: boolean;
260
+ };
261
+ require?: {
262
+ ext?: string | string[] | boolean;
263
+ npm?: boolean;
264
+ inline?: boolean;
265
+ };
266
+ settings?: {
267
+ package_manager?: "npm" | "yarn" | "pnpm";
268
+ };
269
+ }
270
+
271
+ interface ProcessModule {
272
+ env?: {
273
+ apply?: boolean;
274
+ };
275
+ cipher?: {
276
+ algorithm?: CipherGCMTypes;
277
+ key?: BinaryLike;
278
+ iv?: BinaryLike;
279
+ };
280
+ password?: string;
281
+ }
282
+
283
+ interface MemoryModule {
284
+ settings?: {
285
+ users?: boolean | string[];
286
+ cache_disk?: {
287
+ enabled?: boolean;
288
+ min_size?: number | string;
289
+ max_size?: number | string;
290
+ include?: string[];
291
+ exclude?: string[];
292
+ expires?: number | string;
293
+ };
294
+ };
295
+ }
296
+
297
+ interface PermissionModule {
298
+ home_read?: boolean;
299
+ home_write?: boolean;
300
+ process_exec?: (string | ExecOptions)[];
301
+ }
302
+
303
+ interface ErrorModule {
304
+ out?: string | (err: Error, data: LogTypeValue, require?: NodeRequire) => void;
305
+ fatal?: boolean;
306
+ }
307
+
308
+ interface TempModule {
309
+ dir?: string;
310
+ env?: string;
311
+ write?: boolean;
312
+ }
313
+
314
+ interface LoggerModule {
315
+ enabled?: boolean;
316
+ level?: number,
317
+ production?: string[];
318
+ format?: {
319
+ title?: {
320
+ width?: number;
321
+ color?: ForegroundColor;
322
+ bg_color?: BackgroundColor;
323
+ bold?: boolean;
324
+ justify?: "left" | "center" | "right";
325
+ braces?: string;
326
+ as?: StringMap;
327
+ };
328
+ value?: {
329
+ width?: number;
330
+ color?: ForegroundColor;
331
+ bg_color?: BackgroundColor;
332
+ bold?: boolean;
333
+ justify?: "left" | "center" | "right";
334
+ },
335
+ hint?: {
336
+ width?: number;
337
+ color?: ForegroundColor;
338
+ bg_color?: BackgroundColor;
339
+ bold?: boolean;
340
+ braces?: [string, string];
341
+ as?: StringMap;
342
+ unit?: "auto" | "s" | "ms";
343
+ };
344
+ message?: {
345
+ width?: number;
346
+ color?: ForegroundColor;
347
+ bg_color?: BackgroundColor;
348
+ bold?: boolean;
349
+ braces?: [string, string];
350
+ };
351
+ meter?: {
352
+ color?: ForegroundColor;
353
+ bg_color?: BackgroundColor;
354
+ bg_alt_color?: BackgroundColor;
355
+ bold?: boolean;
356
+ };
357
+ error?: {
358
+ color?: ForegroundColor;
359
+ alt_color?: ForegroundColor;
360
+ bg_color?: BackgroundColor;
361
+ braces?: [string, string];
362
+ };
363
+ };
364
+ meter?: {
365
+ http?: number;
366
+ image?: number;
367
+ compress?: number;
368
+ process?: number;
369
+ };
370
+ broadcast?: {
371
+ enabled?: boolean;
372
+ out?: string | (value: string, options: LogMessageOptions, require?: NodeRequire) => void;
373
+ color?: boolean;
374
+ port?: number | number[];
375
+ secure?: {
376
+ port?: number | number[];
377
+ ca?: string;
378
+ key?: string;
379
+ cert?: string;
380
+ version?: SecureVersion
381
+ };
382
+ };
383
+ color?: boolean;
384
+ message?: boolean;
385
+ stdout?: boolean;
386
+ abort?: boolean;
387
+ status?: boolean | LoggerStatus;
388
+ progress?: LoggerProgress;
389
+ unknown?: boolean | LoggerColor;
390
+ system?: boolean | LoggerColor;
391
+ process?: boolean | LoggerProcessSettings;
392
+ image?: boolean | LoggerColor;
393
+ compress?: boolean | LoggerColor;
394
+ watch?: boolean | LoggerColor;
395
+ file?: boolean | LoggerColor;
396
+ cloud?: boolean | LoggerColor;
397
+ db?: boolean | LoggerColor;
398
+ time_elapsed?: boolean | LoggerColor;
399
+ time_process?: boolean | LoggerColor;
400
+ exec?: boolean | LoggerColor;
401
+ http?: boolean | LoggerColor;
402
+ node?: boolean | LoggerColor;
403
+ session_id?: boolean | number;
404
+ stack_trace?: boolean | number;
405
+ }
406
+ ```
407
+
408
+ ## References
409
+
410
+ - https://www.unpkg.com/@e-mc/types@0.10.3/lib/core.d.ts
411
+ - https://www.unpkg.com/@e-mc/types@0.10.3/lib/logger.d.ts
412
+ - https://www.unpkg.com/@e-mc/types@0.10.3/lib/module.d.ts
413
+ - https://www.unpkg.com/@e-mc/types@0.10.3/lib/node.d.ts
414
+ - https://www.unpkg.com/@e-mc/types@0.10.3/lib/settings.d.ts
415
+
416
+ * https://www.npmjs.com/package/@types/node
417
+
418
+ ## LICENSE
419
+
414
420
  BSD 3-Clause