@nu-art/ts-common 0.202.53 → 0.202.55

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.
@@ -16,8 +16,8 @@ export type ErrorMessage = {
16
16
  export interface OnApplicationNotification {
17
17
  __processApplicationNotification(errorLevel: ServerErrorSeverity, module: Module, message: ErrorMessage): Promise<void>;
18
18
  }
19
- export declare const dispatch_onApplicationNotification: Dispatcher<OnApplicationNotification, "__processApplicationNotification", [errorLevel: ServerErrorSeverity, module: Module<any, any>, message: ErrorMessage], void>;
19
+ export declare const dispatch_onApplicationNotification: Dispatcher<OnApplicationNotification, "__processApplicationNotification", [errorLevel: ServerErrorSeverity, module: Module<any, any, import("..").Validator<any> | import("..").TypeValidator<any>>, message: ErrorMessage], void>;
20
20
  export interface OnApplicationException {
21
21
  __processApplicationException(e: CustomException, module: Module): Promise<void>;
22
22
  }
23
- export declare const dispatch_onApplicationException: Dispatcher<OnApplicationException, "__processApplicationException", [e: CustomException, module: Module<any, any>], void>;
23
+ export declare const dispatch_onApplicationException: Dispatcher<OnApplicationException, "__processApplicationException", [e: CustomException, module: Module<any, any, import("..").Validator<any> | import("..").TypeValidator<any>>], void>;
@@ -3,10 +3,10 @@
3
3
  */
4
4
  import { Module } from './module';
5
5
  import { Logger } from './logger/Logger';
6
- export declare function moduleResolver(): Module<any, any>[];
6
+ export declare function moduleResolver(): Module<any, any, import("..").Validator<any> | import("..").TypeValidator<any>>[];
7
7
  export declare class ModuleManager extends Logger {
8
8
  protected config: any;
9
- readonly modules: Module<any, any>[];
9
+ readonly modules: Module<any, any, import("..").Validator<any> | import("..").TypeValidator<any>>[];
10
10
  static instance: ModuleManager;
11
11
  protected constructor();
12
12
  private static resetForTests;
package/core/module.d.ts CHANGED
@@ -6,23 +6,24 @@ import { Logger } from './logger/Logger';
6
6
  import { LogLevel } from './logger/types';
7
7
  import { ValidatorTypeResolver } from '../validator/validator-core';
8
8
  import { TimerHandler } from '../utils/date-time-tools';
9
- type _FinalConfig<Config = any> = Config & {
9
+ export declare abstract class Module<Config = any, ModuleConfig extends Config & {
10
10
  minLogLevel?: LogLevel;
11
- };
12
- export declare abstract class Module<Config = any, FinalConfig extends _FinalConfig<Config> = _FinalConfig<Config>> extends Logger {
11
+ } = Config & {
12
+ minLogLevel?: LogLevel;
13
+ }, ConfigValidator extends ValidatorTypeResolver<ModuleConfig> = ValidatorTypeResolver<ModuleConfig>> extends Logger {
13
14
  private name;
14
- readonly config: FinalConfig;
15
+ readonly config: ModuleConfig;
15
16
  protected readonly manager: ModuleManager;
16
17
  protected readonly initiated = false;
17
- protected readonly configValidator?: ValidatorTypeResolver<FinalConfig>;
18
+ protected readonly configValidator?: ConfigValidator;
18
19
  protected timeoutMap: {
19
20
  [k: string]: number;
20
21
  };
21
22
  constructor(tag?: string);
22
23
  debounce(handler: TimerHandler, key: string, ms?: number): void;
23
24
  throttle(handler: TimerHandler, key: string, ms?: number): void;
24
- setConfigValidator(validator: ValidatorTypeResolver<FinalConfig>): void;
25
- setDefaultConfig(config: Partial<FinalConfig>): void;
25
+ setConfigValidator(validator: ConfigValidator): void;
26
+ setDefaultConfig(config: Partial<ModuleConfig>): void;
26
27
  getName(): string;
27
28
  setName(name: string): void;
28
29
  private setConfig;
@@ -31,4 +32,3 @@ export declare abstract class Module<Config = any, FinalConfig extends _FinalCon
31
32
  protected init(): void;
32
33
  protected validate(): void;
33
34
  }
34
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nu-art/ts-common",
3
- "version": "0.202.53",
3
+ "version": "0.202.55",
4
4
  "description": "js and ts infra",
5
5
  "keywords": [
6
6
  "TacB0sS",
@@ -95,7 +95,7 @@ const tsValidateObject = (__validator, instance, path = '') => {
95
95
  // @ts-ignore
96
96
  if (!validatorKeys.includes(key))
97
97
  // @ts-ignore
98
- result[key] = `Unexpected key '${path}${key}'.\nIf you want to ignore the validation of this property,\n add the following to your validator:\n {\n ...\n ${key}: undefined\n ...\n}\n`;
98
+ result[key] = `Unexpected key '${path}${key}'.\nIf you want to ignore the validation of this property,\n add the following to your validator:\n {\n ...\n ${key}: tsValidateOptional\n ...\n}\n`;
99
99
  }
100
100
  for (const key of validatorKeys) {
101
101
  const value = instance[key];