@zajno/common 2.7.1 → 2.7.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/cjs/api/call.js +5 -5
- package/cjs/api/call.js.map +1 -1
- package/cjs/api/config.js +30 -5
- package/cjs/api/config.js.map +1 -1
- package/cjs/api/index.js +5 -8
- package/cjs/api/index.js.map +1 -1
- package/cjs/api/interceptor.js +1 -1
- package/cjs/api/logging.js +3 -3
- package/cjs/api/logging.js.map +1 -1
- package/cjs/functions/assert.js +2 -4
- package/cjs/functions/assert.js.map +1 -1
- package/cjs/functions/disposer.js +10 -18
- package/cjs/functions/disposer.js.map +1 -1
- package/cjs/functions/throttle.js +8 -17
- package/cjs/functions/throttle.js.map +1 -1
- package/cjs/localization/LocalizationManager.js +9 -0
- package/cjs/localization/LocalizationManager.js.map +1 -1
- package/cjs/localization/index.js +0 -2
- package/cjs/localization/index.js.map +1 -1
- package/cjs/logger/batch.js +23 -3
- package/cjs/logger/batch.js.map +1 -1
- package/cjs/logger/buffered/base.js +52 -0
- package/cjs/logger/buffered/base.js.map +1 -0
- package/cjs/logger/buffered/buffered.logger.js +40 -0
- package/cjs/logger/buffered/buffered.logger.js.map +1 -0
- package/cjs/logger/buffered/buffered.memory.js +71 -0
- package/cjs/logger/buffered/buffered.memory.js.map +1 -0
- package/cjs/logger/buffered/file/buffered.file.js +43 -0
- package/cjs/logger/buffered/file/buffered.file.js.map +1 -0
- package/cjs/logger/buffered/file/index.js +5 -0
- package/cjs/logger/buffered/file/index.js.map +1 -0
- package/cjs/logger/buffered/index.js +7 -0
- package/cjs/logger/buffered/index.js.map +1 -0
- package/cjs/logger/console.js +1 -39
- package/cjs/logger/console.js.map +1 -1
- package/cjs/logger/empty.js +11 -0
- package/cjs/logger/empty.js.map +1 -0
- package/cjs/logger/index.js +5 -7
- package/cjs/logger/index.js.map +1 -1
- package/cjs/logger/loggable.js +39 -0
- package/cjs/logger/loggable.js.map +1 -0
- package/cjs/logger/manager.js +70 -20
- package/cjs/logger/manager.js.map +1 -1
- package/cjs/logger/named.js +15 -12
- package/cjs/logger/named.js.map +1 -1
- package/cjs/logger/provider.js +33 -0
- package/cjs/logger/provider.js.map +1 -0
- package/cjs/logger/proxy.js +3 -7
- package/cjs/logger/proxy.js.map +1 -1
- package/cjs/logger/types.js +9 -0
- package/cjs/logger/types.js.map +1 -0
- package/cjs/math/arrays.js.map +1 -1
- package/cjs/math/object/ops.composite.js.map +1 -1
- package/cjs/models/LogicModel.js +13 -11
- package/cjs/models/LogicModel.js.map +1 -1
- package/cjs/observing/event.js +5 -18
- package/cjs/observing/event.js.map +1 -1
- package/cjs/observing/event.late.js.map +1 -1
- package/cjs/observing/progressTracker.js +8 -15
- package/cjs/observing/progressTracker.js.map +1 -1
- package/cjs/observing/timer.js.map +1 -1
- package/cjs/observing/transition.js +177 -0
- package/cjs/observing/transition.js.map +1 -0
- package/cjs/structures/path/utils.js +4 -0
- package/cjs/structures/path/utils.js.map +1 -1
- package/cjs/structures/promiseCache.js +14 -20
- package/cjs/structures/promiseCache.js.map +1 -1
- package/cjs/structures/queue/parallel.js +11 -13
- package/cjs/structures/queue/parallel.js.map +1 -1
- package/cjs/structures/subscribersMap.js +9 -7
- package/cjs/structures/subscribersMap.js.map +1 -1
- package/cjs/validation/helpers.js +2 -2
- package/cjs/validation/helpers.js.map +1 -1
- package/cjs/validation/index.js +1 -1
- package/cjs/validation/index.js.map +1 -1
- package/cjs/validation/types.js +0 -9
- package/cjs/validation/types.js.map +1 -1
- package/cjs/validation/validationError.js +12 -0
- package/cjs/validation/validationError.js.map +1 -0
- package/esm/api/builder.js +1 -0
- package/esm/api/builder.js.map +1 -1
- package/esm/api/call.config.js +1 -0
- package/esm/api/call.config.js.map +1 -1
- package/esm/api/call.js +6 -5
- package/esm/api/call.js.map +1 -1
- package/esm/api/call.types.js +1 -1
- package/esm/api/call.types.js.map +1 -1
- package/esm/api/config.js +28 -4
- package/esm/api/config.js.map +1 -1
- package/esm/api/endpoint.types.js +1 -1
- package/esm/api/endpoint.types.js.map +1 -1
- package/esm/api/error.js +1 -0
- package/esm/api/error.js.map +1 -1
- package/esm/api/extensions/contentType.js +1 -0
- package/esm/api/extensions/contentType.js.map +1 -1
- package/esm/api/extensions/validation.js +2 -0
- package/esm/api/extensions/validation.js.map +1 -1
- package/esm/api/index.js +3 -3
- package/esm/api/index.js.map +1 -1
- package/esm/api/interceptor.js +1 -1
- package/esm/api/logging.js +4 -3
- package/esm/api/logging.js.map +1 -1
- package/esm/dates/calc.js +1 -0
- package/esm/dates/calc.js.map +1 -1
- package/esm/dates/format.js +1 -0
- package/esm/dates/format.js.map +1 -1
- package/esm/dates/period.js +1 -0
- package/esm/dates/period.js.map +1 -1
- package/esm/fields/update.js +1 -0
- package/esm/fields/update.js.map +1 -1
- package/esm/functions/assert.js +3 -3
- package/esm/functions/assert.js.map +1 -1
- package/esm/functions/disposer.js +11 -17
- package/esm/functions/disposer.js.map +1 -1
- package/esm/functions/throttle.js +7 -15
- package/esm/functions/throttle.js.map +1 -1
- package/esm/localization/LocalizationManager.js +9 -0
- package/esm/localization/LocalizationManager.js.map +1 -1
- package/esm/localization/defaults/ValidationErrorsLocalization.js +2 -0
- package/esm/localization/defaults/ValidationErrorsLocalization.js.map +1 -1
- package/esm/localization/index.js +0 -1
- package/esm/localization/index.js.map +1 -1
- package/esm/logger/batch.js +23 -3
- package/esm/logger/batch.js.map +1 -1
- package/esm/logger/buffered/base.js +48 -0
- package/esm/logger/buffered/base.js.map +1 -0
- package/esm/logger/buffered/buffered.logger.js +36 -0
- package/esm/logger/buffered/buffered.logger.js.map +1 -0
- package/esm/logger/buffered/buffered.memory.js +67 -0
- package/esm/logger/buffered/buffered.memory.js.map +1 -0
- package/esm/logger/buffered/file/buffered.file.js +38 -0
- package/esm/logger/buffered/file/buffered.file.js.map +1 -0
- package/esm/logger/buffered/file/index.js +2 -0
- package/esm/logger/buffered/file/index.js.map +1 -0
- package/esm/logger/buffered/index.js +4 -0
- package/esm/logger/buffered/index.js.map +1 -0
- package/esm/logger/console.js +0 -37
- package/esm/logger/console.js.map +1 -1
- package/esm/logger/empty.js +7 -0
- package/esm/logger/empty.js.map +1 -0
- package/esm/logger/index.js +3 -7
- package/esm/logger/index.js.map +1 -1
- package/esm/logger/loggable.js +35 -0
- package/esm/logger/loggable.js.map +1 -0
- package/esm/logger/manager.js +70 -20
- package/esm/logger/manager.js.map +1 -1
- package/esm/logger/named.js +8 -4
- package/esm/logger/named.js.map +1 -1
- package/esm/logger/provider.js +29 -0
- package/esm/logger/provider.js.map +1 -0
- package/esm/logger/proxy.js +2 -6
- package/esm/logger/proxy.js.map +1 -1
- package/esm/logger/types.js +6 -0
- package/esm/logger/types.js.map +1 -0
- package/esm/math/arrays.js.map +1 -1
- package/esm/math/object/ops.composite.js.map +1 -1
- package/esm/models/LogicModel.js +13 -11
- package/esm/models/LogicModel.js.map +1 -1
- package/esm/observing/event.js +5 -18
- package/esm/observing/event.js.map +1 -1
- package/esm/observing/event.late.js.map +1 -1
- package/esm/observing/progressTracker.js +9 -14
- package/esm/observing/progressTracker.js.map +1 -1
- package/esm/observing/timer.js.map +1 -1
- package/esm/observing/transition.js +172 -0
- package/esm/observing/transition.js.map +1 -0
- package/esm/structures/path/builder.js +1 -1
- package/esm/structures/path/builder.js.map +1 -1
- package/esm/structures/path/utils.js +4 -0
- package/esm/structures/path/utils.js.map +1 -1
- package/esm/structures/promiseCache.js +14 -20
- package/esm/structures/promiseCache.js.map +1 -1
- package/esm/structures/queue/parallel.js +11 -13
- package/esm/structures/queue/parallel.js.map +1 -1
- package/esm/structures/subscribersMap.js +9 -7
- package/esm/structures/subscribersMap.js.map +1 -1
- package/esm/validation/helpers.js +1 -1
- package/esm/validation/helpers.js.map +1 -1
- package/esm/validation/index.js +1 -1
- package/esm/validation/index.js.map +1 -1
- package/esm/validation/types.js +1 -7
- package/esm/validation/types.js.map +1 -1
- package/esm/validation/validationError.js +8 -0
- package/esm/validation/validationError.js.map +1 -0
- package/package.json +13 -1
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/tsconfig.esm.tsbuildinfo +1 -1
- package/tsconfig.types.tsbuildinfo +1 -1
- package/types/api/builder.d.ts +1 -1
- package/types/api/call.config.d.ts +1 -1
- package/types/api/call.types.d.ts +2 -2
- package/types/api/config.d.ts +11 -4
- package/types/api/endpoint.types.d.ts +1 -1
- package/types/api/extensions/endpointHooks.d.ts +1 -1
- package/types/api/extensions/validation.d.ts +1 -1
- package/types/api/index.d.ts +3 -3
- package/types/api/interceptor.d.ts +1 -1
- package/types/api/logging.d.ts +8 -6
- package/types/functions/assert.d.ts +3 -3
- package/types/functions/disposer.d.ts +7 -6
- package/types/functions/safe.d.ts +1 -1
- package/types/functions/throttle.d.ts +4 -5
- package/types/localization/LocalizationManager.d.ts +7 -0
- package/types/localization/LocalizedValidationErrors.d.ts +1 -1
- package/types/localization/index.d.ts +1 -1
- package/types/logger/batch.d.ts +3 -2
- package/types/logger/buffered/base.d.ts +23 -0
- package/types/logger/buffered/buffered.logger.d.ts +8 -0
- package/types/logger/buffered/buffered.memory.d.ts +19 -0
- package/types/logger/buffered/file/buffered.file.d.ts +9 -0
- package/types/logger/buffered/file/index.d.ts +1 -0
- package/types/logger/buffered/index.d.ts +3 -0
- package/types/logger/console.d.ts +1 -13
- package/types/logger/empty.d.ts +3 -0
- package/types/logger/index.d.ts +6 -10
- package/types/logger/loggable.d.ts +13 -0
- package/types/logger/manager.d.ts +31 -7
- package/types/logger/named.d.ts +4 -3
- package/types/logger/provider.d.ts +11 -0
- package/types/logger/proxy.d.ts +1 -2
- package/types/logger/types.d.ts +21 -0
- package/types/math/arrays.d.ts +1 -1
- package/types/math/object/helpers.d.ts +2 -2
- package/types/math/object/math.composite.d.ts +3 -3
- package/types/math/object/math.d.ts +2 -2
- package/types/math/object/ops.composite.d.ts +3 -3
- package/types/math/object/ops.d.ts +2 -2
- package/types/math/object/types.d.ts +1 -1
- package/types/models/LogicModel.d.ts +4 -4
- package/types/models/Model.d.ts +1 -1
- package/types/observing/event.d.ts +3 -6
- package/types/observing/event.late.d.ts +1 -1
- package/types/observing/progressTracker.d.ts +3 -4
- package/types/observing/timer.d.ts +2 -2
- package/types/observing/transition.d.ts +40 -0
- package/types/structures/path/builder.d.ts +1 -1
- package/types/structures/path/utils.d.ts +1 -1
- package/types/structures/promiseCache.d.ts +4 -5
- package/types/structures/promiseProxy.d.ts +1 -1
- package/types/structures/queue/parallel.d.ts +3 -3
- package/types/structures/subscribersMap.d.ts +4 -3
- package/types/types/deep.d.ts +1 -1
- package/types/types/functions.d.ts +1 -1
- package/types/types/ident.d.ts +0 -1
- package/types/validation/helpers.d.ts +2 -2
- package/types/validation/index.d.ts +2 -1
- package/types/validation/types.d.ts +1 -5
- package/types/validation/validationError.d.ts +5 -0
- package/types/validation/wrappers.d.ts +1 -1
- package/cjs/logger/abstractions.js +0 -3
- package/cjs/logger/abstractions.js.map +0 -1
- package/cjs/logger/file.js +0 -65
- package/cjs/logger/file.js.map +0 -1
- package/cjs/logger/shared.js +0 -18
- package/cjs/logger/shared.js.map +0 -1
- package/esm/logger/abstractions.js +0 -2
- package/esm/logger/abstractions.js.map +0 -1
- package/esm/logger/file.js +0 -60
- package/esm/logger/file.js.map +0 -1
- package/esm/logger/shared.js +0 -15
- package/esm/logger/shared.js.map +0 -1
- package/types/logger/abstractions.d.ts +0 -10
- package/types/logger/file.d.ts +0 -15
- package/types/logger/shared.d.ts +0 -15
package/types/logger/index.d.ts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { ILogger, LoggerFunction } from './
|
|
1
|
+
import type { ILogger, ILoggerFactory, LoggerFunction, LoggerModes } from './types.js';
|
|
2
2
|
import { ConsoleLogger } from './console.js';
|
|
3
3
|
import { batchLoggers } from './batch.js';
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import { LoggersManager } from './manager.js';
|
|
5
|
+
import { Loggable } from './loggable.js';
|
|
6
|
+
import { LoggerProvider } from './provider.js';
|
|
7
|
+
export type { ILogger, ILoggerFactory, LoggerFunction, LoggerModes };
|
|
6
8
|
export { NamedLogger } from './named.js';
|
|
7
|
-
export { ConsoleLogger, batchLoggers };
|
|
8
|
-
export { LoggersManager };
|
|
9
|
-
/** Shared logger instance used internally in this library.
|
|
10
|
-
*
|
|
11
|
-
* For internal default loggers to be enabled and working, don't forget to set the mode to this instance.
|
|
12
|
-
*/
|
|
13
|
-
export * as SharedLogger from './shared.js';
|
|
9
|
+
export { ConsoleLogger, batchLoggers, LoggersManager, Loggable, LoggerProvider, };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Getter } from '../types/getter.js';
|
|
2
|
+
import type { Nullable } from '../types/misc.js';
|
|
3
|
+
import type { ILogger, ILoggerFactory } from './types.js';
|
|
4
|
+
/** Helper base class for storing and using a logger instance. */
|
|
5
|
+
export declare class Loggable {
|
|
6
|
+
private _logger;
|
|
7
|
+
constructor(logger?: ILogger);
|
|
8
|
+
protected get logger(): ILogger | null;
|
|
9
|
+
setLogger(logger?: Getter<Nullable<ILogger>>): this;
|
|
10
|
+
setLoggerFactory(factory: ILoggerFactory | null, ...args: Parameters<ILoggerFactory>): this;
|
|
11
|
+
protected getLoggerName(name: string | undefined): string;
|
|
12
|
+
protected _createLogger(factory: ILoggerFactory, ...args: Parameters<ILoggerFactory>): ILogger;
|
|
13
|
+
}
|
|
@@ -1,22 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ILogger } from './abstractions.js';
|
|
1
|
+
import type { ILogger, LoggerModes } from './types.js';
|
|
3
2
|
import { ProxyLogger } from './proxy.js';
|
|
4
|
-
export type LoggerTypes = 'console';
|
|
5
|
-
export type LoggerModes = LoggerTypes | false | Getter<ILogger>;
|
|
6
3
|
export declare class LoggersManager {
|
|
4
|
+
/** Storage for instances created by this manager */
|
|
7
5
|
private readonly _managed;
|
|
6
|
+
/** Storage for all attached instances. */
|
|
8
7
|
private readonly _all;
|
|
8
|
+
/** Current main mode. */
|
|
9
9
|
private _mode;
|
|
10
|
+
/** Additionally attached logger destinations (e.g. for analytics) */
|
|
11
|
+
private readonly _destinations;
|
|
10
12
|
get mode(): LoggerModes;
|
|
11
13
|
/** Creates and attaches an logger instance created from the current mode */
|
|
12
14
|
create(name: string | undefined, mode?: undefined | LoggerModes): ILogger;
|
|
13
|
-
/** Attaches existing instance, optionally adds name prefix to it
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
/** Attaches existing instance, optionally adds name prefix to it.
|
|
16
|
+
*
|
|
17
|
+
* Useful when it's needed to enable/disable independent logger when this manager's mode changes.
|
|
18
|
+
*
|
|
19
|
+
* @returns - The attached logger instance wrapped in a ProxyLogger.
|
|
20
|
+
*/
|
|
21
|
+
attach(instance: ILogger, name?: string): ProxyLogger;
|
|
22
|
+
/**
|
|
23
|
+
* Adds a destination to the logger manager.
|
|
24
|
+
*
|
|
25
|
+
* This is useful for analytics or other purposes where you want to log to multiple destinations.
|
|
26
|
+
*
|
|
27
|
+
* @param target - Target logger instance that will recieve all logs disregarding current active mode.
|
|
28
|
+
* @param name - An optional name for the destination (prepended to every log message).
|
|
29
|
+
* @returns - A function to remove the destination.
|
|
30
|
+
*/
|
|
31
|
+
addDestination(target: ILogger, name?: string): () => void;
|
|
32
|
+
/**
|
|
33
|
+
* Sets the current mode if changed, for all attached instances.
|
|
34
|
+
*
|
|
35
|
+
* All internally created loggers implementation will be overridden with a new implementation according to the new mode.
|
|
36
|
+
*
|
|
37
|
+
* The rest just attached loggers will be just enabled/disabled based on input mode.
|
|
38
|
+
* */
|
|
16
39
|
setMode(mode: LoggerModes | null | undefined): void;
|
|
17
40
|
recognize(instance: ILogger): ProxyLogger | null;
|
|
18
41
|
/** Detaches instance so it won't be affected by setting mode later on, optionally disables it */
|
|
19
42
|
detach(instance: ILogger, terminate?: boolean): boolean;
|
|
43
|
+
private _updateAll;
|
|
20
44
|
private _findInstance;
|
|
21
45
|
private _createImplementation;
|
|
22
46
|
expose(): {
|
package/types/logger/named.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { ILogger, ILoggerSwitchable, LoggerFunction } from './
|
|
2
|
-
export declare const EMPTY_FUNCTION: () => void;
|
|
1
|
+
import type { ILogger, ILoggerSwitchable, LoggerFunction } from './types.js';
|
|
3
2
|
export declare abstract class NamedLogger implements ILogger, ILoggerSwitchable {
|
|
4
3
|
log: LoggerFunction;
|
|
5
4
|
warn: LoggerFunction;
|
|
6
5
|
error: LoggerFunction;
|
|
7
6
|
private _name;
|
|
7
|
+
private _enabled;
|
|
8
8
|
get name(): string | null;
|
|
9
|
-
protected abstract get implementation(): ILogger;
|
|
10
9
|
constructor(name?: string);
|
|
10
|
+
protected abstract get implementation(): ILogger;
|
|
11
|
+
get isEnabled(): boolean;
|
|
11
12
|
enable(overrideName?: string | null): this;
|
|
12
13
|
disable(): this;
|
|
13
14
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Loggable } from './loggable.js';
|
|
2
|
+
import type { ILogger, ILoggerFactory } from './types.js';
|
|
3
|
+
/** Logger instance holder, for re-usability */
|
|
4
|
+
export declare class LoggerProvider extends Loggable {
|
|
5
|
+
private _factory;
|
|
6
|
+
constructor(nameFormatter?: (name: string | undefined) => string, logger?: ILogger);
|
|
7
|
+
get logger(): ILogger | null;
|
|
8
|
+
get factory(): ILoggerFactory | null;
|
|
9
|
+
setLoggerFactory(factory: ILoggerFactory | null, ...args: Parameters<ILoggerFactory>): this;
|
|
10
|
+
createLogger(...args: Parameters<ILoggerFactory>): ILogger | null;
|
|
11
|
+
}
|
package/types/logger/proxy.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ILogger } from './
|
|
1
|
+
import type { ILogger } from './types.js';
|
|
2
2
|
import { NamedLogger } from './named.js';
|
|
3
|
-
export declare const EMPTY_LOGGER: ILogger;
|
|
4
3
|
export declare class ProxyLogger extends NamedLogger {
|
|
5
4
|
protected get implementation(): ILogger;
|
|
6
5
|
private _logger;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Getter } from '../types/getter.js';
|
|
2
|
+
export type LoggerFunction = (...args: any[]) => void;
|
|
3
|
+
export interface ILogger {
|
|
4
|
+
log: LoggerFunction;
|
|
5
|
+
warn: LoggerFunction;
|
|
6
|
+
error: LoggerFunction;
|
|
7
|
+
}
|
|
8
|
+
export interface ILoggerSwitchable {
|
|
9
|
+
enable(): void;
|
|
10
|
+
disable(): void;
|
|
11
|
+
}
|
|
12
|
+
export type LogLevelTypes = keyof ILogger;
|
|
13
|
+
export declare const LogLevels: {
|
|
14
|
+
readonly log: 1;
|
|
15
|
+
readonly warn: 2;
|
|
16
|
+
readonly error: 3;
|
|
17
|
+
};
|
|
18
|
+
export type LogLevelValues = typeof LogLevels[LogLevelTypes];
|
|
19
|
+
export type LoggerTypes = 'console';
|
|
20
|
+
export type LoggerModes = LoggerTypes | false | Getter<ILogger>;
|
|
21
|
+
export type ILoggerFactory = (name: string | undefined, mode?: LoggerModes) => ILogger;
|
package/types/math/arrays.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Comparator, Getter, Nullable, Predicate } from '../types/index.js';
|
|
1
|
+
import { Comparator, Getter, type Nullable, type Predicate } from '../types/index.js';
|
|
2
2
|
/** type-safe `Array.isArray` wrapper */
|
|
3
3
|
export declare function isArray<T>(value: any): value is T[];
|
|
4
4
|
export declare function arrayCompareG<T>(arr: ReadonlyArray<T> | null | undefined, cond: (current: T, previous: T | null) => boolean): T | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DeepReadonly, DeepReadonlyPartial } from '../../types/deep.js';
|
|
2
|
-
import { BasePair, IObjectOps, NumKey } from './types.js';
|
|
1
|
+
import type { DeepReadonly, DeepReadonlyPartial } from '../../types/deep.js';
|
|
2
|
+
import type { BasePair, IObjectOps, NumKey } from './types.js';
|
|
3
3
|
export declare function _getValue<T extends object, TKey extends NumKey<T> = NumKey<T>>(o: DeepReadonlyPartial<T>, key: TKey): T[TKey] | null;
|
|
4
4
|
export declare function _getInnerValue<T extends object, TKey extends string & keyof T>(o: DeepReadonly<T>, key: TKey): DeepReadonly<T[TKey]>;
|
|
5
5
|
export declare function _getInnerValue<T extends object, TKey extends string & keyof T>(o: DeepReadonly<T> | number, key: TKey): DeepReadonly<T[TKey]> | number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AnyObject } from '../../types/index.js';
|
|
2
|
-
import { DeepReadonly } from '../../types/deep.js';
|
|
1
|
+
import type { AnyObject } from '../../types/index.js';
|
|
2
|
+
import type { DeepReadonly } from '../../types/deep.js';
|
|
3
3
|
import { CompositeObjectOps } from './ops.composite.js';
|
|
4
|
-
import { AbsOptions, IObjectMath, MathPairsMap, RoundOptions } from './types.js';
|
|
4
|
+
import type { AbsOptions, IObjectMath, MathPairsMap, RoundOptions } from './types.js';
|
|
5
5
|
export declare class CompositeObjectMath<T extends AnyObject> extends CompositeObjectOps<T> implements IObjectMath<T> {
|
|
6
6
|
private readonly _math;
|
|
7
7
|
constructor(innerMath: MathPairsMap<T>);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DeepReadonly, DeepReadonlyPartial } from '../../types/deep.js';
|
|
1
|
+
import type { DeepReadonly, DeepReadonlyPartial } from '../../types/deep.js';
|
|
2
2
|
import { ObjectOps } from './ops.js';
|
|
3
|
-
import { AbsOptions, DELETE_TYPE, IObjectMath, NumKey, RoundOptions } from './types.js';
|
|
3
|
+
import type { AbsOptions, DELETE_TYPE, IObjectMath, NumKey, RoundOptions } from './types.js';
|
|
4
4
|
export declare class ObjectMath<T extends object> extends ObjectOps<T> implements IObjectMath<T> {
|
|
5
5
|
getTotal(o: DeepReadonlyPartial<T>): number;
|
|
6
6
|
contains(base: DeepReadonly<T>, target: DeepReadonly<T>): boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AnyObject } from '../../types/index.js';
|
|
2
|
-
import { DeepReadonly } from '../../types/deep.js';
|
|
3
|
-
import { IObjectOps, OpsPairsMap } from './types.js';
|
|
1
|
+
import type { AnyObject } from '../../types/index.js';
|
|
2
|
+
import type { DeepReadonly } from '../../types/deep.js';
|
|
3
|
+
import type { IObjectOps, OpsPairsMap } from './types.js';
|
|
4
4
|
export declare class CompositeObjectOps<T extends AnyObject> implements IObjectOps<T> {
|
|
5
5
|
readonly Empty: Readonly<T>;
|
|
6
6
|
private readonly _ops;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SkipCondition, SkipOptions } from '../../fields/skip.js';
|
|
2
|
-
import { AnyObject, DeepPartial, DeepReadonly, Predicate } from '../../types/index.js';
|
|
3
|
-
import { IObjectOps, NumKey } from './types.js';
|
|
2
|
+
import type { AnyObject, DeepPartial, DeepReadonly, Predicate } from '../../types/index.js';
|
|
3
|
+
import type { IObjectOps, NumKey } from './types.js';
|
|
4
4
|
type Keys<T extends AnyObject> = NumKey<T>[];
|
|
5
5
|
export declare class ObjectOps<T extends AnyObject> implements IObjectOps<T> {
|
|
6
6
|
readonly keys: Keys<T>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyObject, DeepReadonly, TypedKeys } from '../../types/index.js';
|
|
1
|
+
import type { AnyObject, DeepReadonly, TypedKeys } from '../../types/index.js';
|
|
2
2
|
export type NumKey<T extends AnyObject> = TypedKeys<T, number>;
|
|
3
3
|
export type AbsOptions = false | 'remove' | 'zero';
|
|
4
4
|
export type RoundOptions = 'floor' | 'ceil' | 'round';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ExclusiveLoadingError, LoadingModel } from './Loading.js';
|
|
2
2
|
import { Getter } from '../types/index.js';
|
|
3
3
|
import { PromiseExtended } from '../structures/promiseExtended.js';
|
|
4
|
-
import {
|
|
4
|
+
import { Loggable } from '../logger/loggable.js';
|
|
5
5
|
export type ActionRunOptions = {
|
|
6
6
|
/** Action name, required for logging and joining. */
|
|
7
7
|
name?: string;
|
|
@@ -21,13 +21,13 @@ export type ActionRunOptions = {
|
|
|
21
21
|
/** Whether to disable logging for the action. */
|
|
22
22
|
noLogs?: boolean;
|
|
23
23
|
};
|
|
24
|
-
export declare class LogicModel {
|
|
24
|
+
export declare class LogicModel extends Loggable {
|
|
25
25
|
protected readonly _loading: LoadingModel;
|
|
26
26
|
get isLoading(): boolean;
|
|
27
|
-
protected logger: ILogger;
|
|
28
27
|
private readonly _namedRunners;
|
|
29
28
|
private readonly _runningActionNames;
|
|
30
|
-
constructor(
|
|
29
|
+
constructor(useFirstInit?: boolean);
|
|
30
|
+
protected getLoggerName(name?: string): string;
|
|
31
31
|
protected pureConstructLoadingModel(useFirstInit: boolean): LoadingModel;
|
|
32
32
|
protected runAction<T = unknown>(worker: () => Promise<T>, options?: ActionRunOptions, errorCtx?: Getter<unknown>): ActionResult<T>;
|
|
33
33
|
}
|
package/types/models/Model.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IResetableModel, IValueModel } from './types.js';
|
|
2
2
|
import { Getter } from '../types/getter.js';
|
|
3
|
-
import { Nullable } from '../types/misc.js';
|
|
3
|
+
import type { Nullable } from '../types/misc.js';
|
|
4
4
|
export declare class Model<T> implements IValueModel<Nullable<T>>, IResetableModel {
|
|
5
5
|
private _value;
|
|
6
6
|
private readonly _defaultValue;
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import type { Predicate } from '../types/index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { Loggable } from '../logger/loggable.js';
|
|
3
3
|
export type EventHandler<T = any> = (data?: T) => void | Promise<void>;
|
|
4
4
|
type Unsubscribe = () => void;
|
|
5
5
|
export interface IEvent<T = any> {
|
|
6
6
|
on(handler: EventHandler<T>): () => void;
|
|
7
7
|
off(handler: EventHandler<T>): void;
|
|
8
8
|
}
|
|
9
|
-
export declare class Event<T = any> implements IEvent<T> {
|
|
9
|
+
export declare class Event<T = any> extends Loggable implements IEvent<T> {
|
|
10
10
|
private _handlers;
|
|
11
|
-
private _logger;
|
|
12
|
-
constructor(withDefaultLogger?: boolean);
|
|
13
11
|
get isEmpty(): boolean;
|
|
14
|
-
|
|
15
|
-
withLogger(name?: string | null): this;
|
|
12
|
+
protected getLoggerName(name: string | undefined): string;
|
|
16
13
|
/** Clears handlers list */
|
|
17
14
|
resetHandlers: () => void;
|
|
18
15
|
on(handler: EventHandler<T>): Unsubscribe;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type ILogger } from '../logger/
|
|
1
|
+
import { type ILogger } from '../logger/index.js';
|
|
2
2
|
export declare class ProgressTracker {
|
|
3
|
-
readonly
|
|
3
|
+
readonly logger?: ILogger | undefined;
|
|
4
4
|
private readonly _firstTimestamp;
|
|
5
5
|
private _lastTimestamp;
|
|
6
6
|
private _lastCompleted;
|
|
@@ -9,7 +9,7 @@ export declare class ProgressTracker {
|
|
|
9
9
|
private _currentProgress;
|
|
10
10
|
private readonly _deltas;
|
|
11
11
|
private readonly _changed;
|
|
12
|
-
constructor(
|
|
12
|
+
constructor(logger?: ILogger | undefined);
|
|
13
13
|
get changed(): import("./event.js").IEvent<{
|
|
14
14
|
completed: number;
|
|
15
15
|
total: number;
|
|
@@ -20,7 +20,6 @@ export declare class ProgressTracker {
|
|
|
20
20
|
get total(): number;
|
|
21
21
|
get completed(): number;
|
|
22
22
|
get current(): number;
|
|
23
|
-
private get logger();
|
|
24
23
|
setTotal(total: number): this;
|
|
25
24
|
add(amount?: number, restart?: boolean): void;
|
|
26
25
|
track(completed: number, total: number): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IDisposable } from '../functions/disposer.js';
|
|
2
|
-
import { EventHandler, IEvent } from './event.js';
|
|
1
|
+
import type { IDisposable } from '../functions/disposer.js';
|
|
2
|
+
import { type EventHandler, type IEvent } from './event.js';
|
|
3
3
|
export type TimerState = {
|
|
4
4
|
timer: Timer;
|
|
5
5
|
elapsed: number;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type IEvent } from './event.js';
|
|
2
|
+
import type { DisposeFunction, IDisposable } from '../functions/disposer.js';
|
|
3
|
+
import { Getter } from '../types/getter.js';
|
|
4
|
+
import type { Nullable } from '../types/misc.js';
|
|
5
|
+
import { Loggable } from '../logger/loggable.js';
|
|
6
|
+
export type TransitionReaction<T> = (getter: Getter<T>, handler: (v: T) => any) => DisposeFunction;
|
|
7
|
+
export declare class TransitionObserver<T> extends Loggable implements IDisposable {
|
|
8
|
+
protected readonly reaction: TransitionReaction<T>;
|
|
9
|
+
private _event;
|
|
10
|
+
private _getter;
|
|
11
|
+
private _filter;
|
|
12
|
+
private _disposer;
|
|
13
|
+
private _prev;
|
|
14
|
+
private _from;
|
|
15
|
+
private _to;
|
|
16
|
+
private _cb;
|
|
17
|
+
private _fireOnce;
|
|
18
|
+
private _promise;
|
|
19
|
+
private _promiseReject;
|
|
20
|
+
constructor(reaction: TransitionReaction<T>, getter?: () => T);
|
|
21
|
+
get event(): IEvent<T>;
|
|
22
|
+
get currentValue(): Nullable<T>;
|
|
23
|
+
get isObserving(): boolean;
|
|
24
|
+
private get isPromising();
|
|
25
|
+
observe(getter: () => T): this;
|
|
26
|
+
from(from: Getter<T>): this;
|
|
27
|
+
to(to: Getter<T>): this;
|
|
28
|
+
filter(filter: (next: T, prev: Nullable<T>) => boolean): this;
|
|
29
|
+
cb(cb: (v: Nullable<T>) => any): this;
|
|
30
|
+
forceCall(): this;
|
|
31
|
+
fireOnce(enable?: boolean): this;
|
|
32
|
+
forceCheck(): boolean;
|
|
33
|
+
andForceCheck(): this;
|
|
34
|
+
getPromise(timeout?: number | null): Promise<Nullable<T>>;
|
|
35
|
+
reverse(): TransitionObserver<T>;
|
|
36
|
+
dispose: () => void;
|
|
37
|
+
private _checkValue;
|
|
38
|
+
private _finishPromise;
|
|
39
|
+
}
|
|
40
|
+
export declare function waitFor<T>(reaction: TransitionReaction<T>, current: () => T, toBe: T): Promise<Nullable<T>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseInput, CombineBuilders, SwitchBuilder } from './types.js';
|
|
1
|
+
import type { BaseInput, CombineBuilders, SwitchBuilder } from './types.js';
|
|
2
2
|
export type * from './types.js';
|
|
3
3
|
export type { TemplateTransform } from './types.helpers.js';
|
|
4
4
|
/** Tagged template literal to create a path builder */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IMapModel, IValueModel } from '../models/types.js';
|
|
1
|
+
import { Loggable } from '../logger/loggable.js';
|
|
2
|
+
import type { IMapModel, IValueModel } from '../models/types.js';
|
|
3
3
|
export type DeferredGetter<T> = {
|
|
4
4
|
readonly current: T | null | undefined;
|
|
5
5
|
readonly promise: Promise<T | null>;
|
|
@@ -19,7 +19,7 @@ export declare namespace DeferredGetter {
|
|
|
19
19
|
* - batching of fetches.
|
|
20
20
|
* - auto-invalidation of cached items.
|
|
21
21
|
*/
|
|
22
|
-
export declare class PromiseCache<T, K = string> {
|
|
22
|
+
export declare class PromiseCache<T, K = string> extends Loggable {
|
|
23
23
|
private readonly fetcher;
|
|
24
24
|
private readonly keyAdapter?;
|
|
25
25
|
private readonly keyParser?;
|
|
@@ -31,7 +31,6 @@ export declare class PromiseCache<T, K = string> {
|
|
|
31
31
|
private _batch;
|
|
32
32
|
private _invalidationTimeMs;
|
|
33
33
|
private _keepInstanceDuringInvalidation;
|
|
34
|
-
private _logger;
|
|
35
34
|
private _version;
|
|
36
35
|
constructor(fetcher: (id: K) => Promise<T>, keyAdapter?: (K extends string ? null : (k: K) => string) | undefined, keyParser?: (K extends string ? null : (id: string) => K) | undefined);
|
|
37
36
|
get busyCount(): number;
|
|
@@ -40,7 +39,7 @@ export declare class PromiseCache<T, K = string> {
|
|
|
40
39
|
protected pure_createItemsStatus(): IMapModel<string, boolean>;
|
|
41
40
|
protected pure_createFetchCache(): IMapModel<string, Promise<T | null>>;
|
|
42
41
|
private _pk;
|
|
43
|
-
|
|
42
|
+
protected getLoggerName(name: string | undefined): string;
|
|
44
43
|
/**
|
|
45
44
|
* Provide a fetcher function that takes multiple ids and returns multiple results at once. Will be called with a slight delay to allow multiple ids to be collected.
|
|
46
45
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LazyPromise } from '../lazy/promise.js';
|
|
2
|
-
import { AnyObject, FunctionKeys, StringKeys } from '../types/index.js';
|
|
2
|
+
import type { AnyObject, FunctionKeys, StringKeys } from '../types/index.js';
|
|
3
3
|
declare const PromiseGetter = "__promise";
|
|
4
4
|
type AllowedFnKeys<T extends AnyObject> = FunctionKeys<T, any[], void>;
|
|
5
5
|
type PromiseProxy<T extends AnyObject, TKeys extends StringKeys<T> = StringKeys<T>, TFnKeys = never, TWrap extends object = object> = {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { Loggable } from '../../logger/loggable.js';
|
|
1
2
|
export type QueueItem = () => void | Promise<void>;
|
|
2
|
-
export declare class ParallelQueue {
|
|
3
|
+
export declare class ParallelQueue extends Loggable {
|
|
3
4
|
private readonly _queues;
|
|
4
5
|
private _inProgress;
|
|
5
6
|
private _currentIndex;
|
|
6
7
|
private _maxIndex;
|
|
7
|
-
private _logger;
|
|
8
8
|
private readonly _beforePriorityRun;
|
|
9
9
|
private readonly _afterPriorityRun;
|
|
10
10
|
private readonly _finished;
|
|
@@ -13,7 +13,7 @@ export declare class ParallelQueue {
|
|
|
13
13
|
get beforePriorityRun(): import("../../observing/event.js").IEvent<number>;
|
|
14
14
|
get afterPriorityRun(): import("../../observing/event.js").IEvent<number>;
|
|
15
15
|
get finished(): import("../../observing/event.js").IEvent<any>;
|
|
16
|
-
|
|
16
|
+
protected getLoggerName(name: string | undefined): string;
|
|
17
17
|
/** @returns A callback that will try to cancel queued item */
|
|
18
18
|
enqueue(cb: QueueItem, priority?: number): () => void;
|
|
19
19
|
start(): Promise<boolean | undefined>;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { IDisposable } from '../functions/disposer.js';
|
|
1
|
+
import { type IDisposable } from '../functions/disposer.js';
|
|
2
|
+
import { Loggable } from '../logger/loggable.js';
|
|
2
3
|
type Unsub = () => void;
|
|
3
|
-
export declare class SubscribersMap implements IDisposable {
|
|
4
|
+
export declare class SubscribersMap extends Loggable implements IDisposable {
|
|
4
5
|
readonly subscribe: null | ((key: string) => Promise<Unsub[]>);
|
|
5
6
|
readonly name?: string | undefined;
|
|
6
7
|
/** Unsubscribers map: key => unsub fn */
|
|
7
8
|
private readonly _map;
|
|
8
9
|
/** Timeouts map: key => timeout handle */
|
|
9
10
|
private readonly _timeouts;
|
|
10
|
-
private readonly _logger;
|
|
11
11
|
protected _count: number;
|
|
12
12
|
constructor(subscribe: null | ((key: string) => Promise<Unsub[]>), name?: string | undefined);
|
|
13
13
|
get count(): number;
|
|
14
|
+
protected getLoggerName(name: string | undefined): string;
|
|
14
15
|
getIsObserving(key: string): boolean;
|
|
15
16
|
getHasObserveTimeout(key: string): boolean;
|
|
16
17
|
enable(key: string, enable: boolean, clearAfter?: number | null, existingUnsubs?: Unsub[] | null): Promise<void>;
|
package/types/types/deep.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyFunction } from './misc.js';
|
|
1
|
+
import type { AnyFunction } from './misc.js';
|
|
2
2
|
export type DeepReadonly<T> = T extends Array<infer U> ? ReadonlyArray<DeepReadonly<U>> : (T extends AnyFunction ? T : (T extends object ? {
|
|
3
3
|
readonly [P in keyof T]: DeepReadonly<T[P]>;
|
|
4
4
|
} : T));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyFunction } from './misc.js';
|
|
1
|
+
import type { AnyFunction } from './misc.js';
|
|
2
2
|
export type TypedFn<A extends unknown[], R> = (...args: A) => R;
|
|
3
3
|
export type Asyncify<T> = {
|
|
4
4
|
[P in keyof T]: T[P] extends TypedFn<unknown[], Promise<unknown>> ? T[P] : (T[P] extends TypedFn<infer A, infer R> ? (...args: A) => Promise<R> : T[P]);
|
package/types/types/ident.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AnyObject } from '../types/index.js';
|
|
1
|
+
import type { AnyObject } from '../types/index.js';
|
|
2
2
|
import { ValidationErrors } from './ValidationErrors.js';
|
|
3
|
-
import { ValidationConfig, ValidationResults, ValidationVoid, ValidatorFunction, ValidatorFunctionAsync } from './types.js';
|
|
3
|
+
import type { ValidationConfig, ValidationResults, ValidationVoid, ValidatorFunction, ValidatorFunctionAsync } from './types.js';
|
|
4
4
|
export declare function createShouldBeEqualTo<T = string>(getter: () => T): ValidatorFunction<T>;
|
|
5
5
|
export declare function throwNotOk(result: ValidationErrors, message?: string): void;
|
|
6
6
|
export declare function validateObject<T extends AnyObject, TErrors = ValidationErrors>(obj: T, validators: ValidationConfig<T, TErrors>, onlyTruthy?: boolean, context?: T): ValidationResults<T, TErrors>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ValidationErrors } from './ValidationErrors.js';
|
|
1
|
+
import { type ValidationErrors } from './ValidationErrors.js';
|
|
2
2
|
export type ValidatorFunction<T = string, TErrors = ValidationErrors, TContext = any> = (val: T, ctx?: TContext) => TErrors;
|
|
3
3
|
export type ValidatorFunctionAsync<T = string, TErrors = ValidationErrors, TContext = any> = (val: T, ctx?: TContext) => Promise<TErrors>;
|
|
4
4
|
export type ValidationConfig<T, TErrors> = {
|
|
@@ -8,10 +8,6 @@ export type ValidationResults<T, TErrors> = {
|
|
|
8
8
|
[P in keyof T]?: TErrors;
|
|
9
9
|
};
|
|
10
10
|
export type WrapperFunction = (val: ValidatorFunction) => ValidatorFunction;
|
|
11
|
-
export declare class ValidationError<TErrors = ValidationErrors> extends Error {
|
|
12
|
-
readonly code: TErrors;
|
|
13
|
-
constructor(message: string, code: TErrors);
|
|
14
|
-
}
|
|
15
11
|
export interface ValidationVoid {
|
|
16
12
|
readonly error?: string | null | undefined;
|
|
17
13
|
validate(): Promise<boolean>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ValidatorFunction } from './types.js';
|
|
1
|
+
import type { ValidatorFunction } from './types.js';
|
|
2
2
|
export declare const Wrappers: {
|
|
3
3
|
required<T = string>(validator: ValidatorFunction<T>): ValidatorFunction<T>;
|
|
4
4
|
notRequired<T = string>(validator: ValidatorFunction<T>): ValidatorFunction<T>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"abstractions.js","sourceRoot":"","sources":["../../../src/logger/abstractions.ts"],"names":[],"mappings":""}
|
package/cjs/logger/file.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FileLoggerNode = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
/* eslint-disable no-console */
|
|
6
|
-
const Path = tslib_1.__importStar(require("path"));
|
|
7
|
-
const FS = tslib_1.__importStar(require("fs"));
|
|
8
|
-
const Util = tslib_1.__importStar(require("util"));
|
|
9
|
-
class FileLoggerNode {
|
|
10
|
-
extraLogger;
|
|
11
|
-
instantFlush;
|
|
12
|
-
_buffer = [];
|
|
13
|
-
_logFilePath = null;
|
|
14
|
-
constructor(extraLogger = console, instantFlush = false) {
|
|
15
|
-
this.extraLogger = extraLogger;
|
|
16
|
-
this.instantFlush = instantFlush;
|
|
17
|
-
this.setLogName('');
|
|
18
|
-
}
|
|
19
|
-
setLogFilePath(path) {
|
|
20
|
-
this._logFilePath = path;
|
|
21
|
-
return this;
|
|
22
|
-
}
|
|
23
|
-
setLogName(name) {
|
|
24
|
-
const n = name ? `-${name}` : '';
|
|
25
|
-
this._logFilePath = Path.resolve(process.cwd(), `run${n}.${new Date().toISOString()}.log`);
|
|
26
|
-
return this;
|
|
27
|
-
}
|
|
28
|
-
append(..._args) {
|
|
29
|
-
const str = Util.format.apply(null, _args) + '\n';
|
|
30
|
-
this._buffer.push(str);
|
|
31
|
-
if (this.instantFlush) {
|
|
32
|
-
this.flush();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
log = (...args) => {
|
|
36
|
-
this.extraLogger?.log(...args);
|
|
37
|
-
this.append(...args);
|
|
38
|
-
};
|
|
39
|
-
warn = (...args) => {
|
|
40
|
-
this.extraLogger?.warn(...args);
|
|
41
|
-
this.append(...args);
|
|
42
|
-
};
|
|
43
|
-
error = (...args) => {
|
|
44
|
-
this.extraLogger?.error(...args);
|
|
45
|
-
this.append(...args);
|
|
46
|
-
};
|
|
47
|
-
flush() {
|
|
48
|
-
if (!this._buffer.length) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
try {
|
|
52
|
-
if (this._logFilePath) {
|
|
53
|
-
FS.appendFileSync(this._logFilePath, this._buffer.join(''));
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
catch (err) {
|
|
57
|
-
console.warn('Failed to flush file, error', err);
|
|
58
|
-
}
|
|
59
|
-
finally {
|
|
60
|
-
this._buffer.length = 0;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
exports.FileLoggerNode = FileLoggerNode;
|
|
65
|
-
//# sourceMappingURL=file.js.map
|
package/cjs/logger/file.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../../src/logger/file.ts"],"names":[],"mappings":";;;;AACA,+BAA+B;AAC/B,mDAA6B;AAC7B,+CAAyB;AACzB,mDAA6B;AAI7B,MAAa,cAAc;IAIF;IAAyC;IAH7C,OAAO,GAAa,EAAE,CAAC;IAChC,YAAY,GAAkB,IAAI,CAAC;IAE3C,YAAqB,cAAuB,OAAO,EAAW,eAAe,KAAK;QAA7D,gBAAW,GAAX,WAAW,CAAmB;QAAW,iBAAY,GAAZ,YAAY,CAAQ;QAC9E,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC;IAED,cAAc,CAAC,IAAY;QACvB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,UAAU,CAAC,IAAY;QACnB,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAC3F,OAAO,IAAI,CAAC;IAChB,CAAC;IAEO,MAAM,CAAC,GAAG,KAAY;QAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;QAClD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEvB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,IAAI,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC;IACL,CAAC;IAED,GAAG,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE;QACrB,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;QAC/B,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;IACzB,CAAC,CAAC;IAEF,IAAI,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE;QACtB,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QAChC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;IACzB,CAAC,CAAC;IAEF,KAAK,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE;QACvB,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;IACzB,CAAC,CAAC;IAEF,KAAK;QACD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACvB,OAAO;QACX,CAAC;QAED,IAAI,CAAC;YACD,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;gBACpB,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;YAChE,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,OAAO,CAAC,IAAI,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;QACrD,CAAC;gBAAS,CAAC;YACP,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;QAC5B,CAAC;IACL,CAAC;CACJ;AA1DD,wCA0DC"}
|