@nu-art/ts-common 0.102.31 → 0.102.32

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.
@@ -1,7 +1,7 @@
1
1
  import { FunctionKeys, ReturnPromiseType } from '../utils/types';
2
2
  import { Logger } from './logger/Logger';
3
- export declare type ParamResolver<T, K extends keyof T> = T[K] extends (...args: any) => any ? Parameters<T[K]> : never;
4
- export declare type ReturnTypeResolver<T, K extends keyof T> = T[K] extends (...args: any) => any ? ReturnPromiseType<T[K]> : never;
3
+ export type ParamResolver<T, K extends keyof T> = T[K] extends (...args: any) => any ? Parameters<T[K]> : never;
4
+ export type ReturnTypeResolver<T, K extends keyof T> = T[K] extends (...args: any) => any ? ReturnPromiseType<T[K]> : never;
5
5
  export declare class Processor<T, K extends FunctionKeys<T>> extends Logger {
6
6
  static modulesResolver: () => any[];
7
7
  readonly method: K;
@@ -46,7 +46,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
46
46
  function verb(n) { return function (v) { return step([n, v]); }; }
47
47
  function step(op) {
48
48
  if (f) throw new TypeError("Generator is already executing.");
49
- while (_) try {
49
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
50
50
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
51
51
  if (y = 0, t) op = [op[0] & 2, t.value];
52
52
  switch (op[0]) {
@@ -1,5 +1,5 @@
1
1
  import { LogLevel, LogParam, LogPrefixComposer } from "./types";
2
- export declare type LogFilter = (level: LogLevel, tag: string) => boolean;
2
+ export type LogFilter = (level: LogLevel, tag: string) => boolean;
3
3
  export declare abstract class LogClient {
4
4
  private prefixComposer;
5
5
  private filter;
@@ -1,6 +1,6 @@
1
1
  import { LogClient } from "./LogClient";
2
2
  import { LogLevel, LogParam } from "./types";
3
- declare type LogRotateListener = () => void;
3
+ type LogRotateListener = () => void;
4
4
  export declare abstract class LogClient_BaseRotate extends LogClient {
5
5
  readonly name: string;
6
6
  readonly maxEntries: number;
@@ -6,5 +6,5 @@ export declare enum LogLevel {
6
6
  Error = "Error"
7
7
  }
8
8
  export declare const LogLevelOrdinal: LogLevel[];
9
- export declare type LogPrefixComposer = (tag: string, level: LogLevel) => string;
10
- export declare type LogParam = string | boolean | number | object | any[] | Error | undefined | null;
9
+ export type LogPrefixComposer = (tag: string, level: LogLevel) => string;
10
+ export type LogParam = string | boolean | number | object | any[] | Error | undefined | null;
package/core/module.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  import { ModuleManager } from './module-manager';
5
5
  import { Logger } from './logger/Logger';
6
6
  import { LogLevel, TimerHandler, ValidatorTypeResolver } from '..';
7
- declare type _FinalConfig<Config = any> = Config & {
7
+ type _FinalConfig<Config = any> = Config & {
8
8
  minLogLevel?: LogLevel;
9
9
  };
10
10
  export declare abstract class Module<Config = any, FinalConfig extends _FinalConfig<Config> = _FinalConfig<Config>> extends Logger {
@@ -7,13 +7,13 @@ import { ExportToCsv, Options } from 'export-to-csv';
7
7
  import { StringMap, TS_Object } from '../utils/types';
8
8
  import { Module } from '../core/module';
9
9
  import { Readable } from 'stream';
10
- declare type Config = {
10
+ type Config = {
11
11
  options: Options;
12
12
  };
13
- export declare type ReadPropsMap<K extends TS_Object = TS_Object> = {
13
+ export type ReadPropsMap<K extends TS_Object = TS_Object> = {
14
14
  [s: string]: keyof K;
15
15
  };
16
- export declare type WritePropsMap<K extends TS_Object = TS_Object> = {
16
+ export type WritePropsMap<K extends TS_Object = TS_Object> = {
17
17
  [P in keyof K]: string;
18
18
  };
19
19
  declare class CSVModule_Class extends Module<Config> {
@@ -46,7 +46,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
46
46
  function verb(n) { return function (v) { return step([n, v]); }; }
47
47
  function step(op) {
48
48
  if (f) throw new TypeError("Generator is already executing.");
49
- while (_) try {
49
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
50
50
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
51
51
  if (y = 0, t) op = [op[0] & 2, t.value];
52
52
  switch (op[0]) {
@@ -1,6 +1,6 @@
1
1
  import { Module } from '../core/module';
2
2
  import { TypedMap } from '../utils/types';
3
- export declare type CliParam<K, T extends string | string[] = string> = {
3
+ export type CliParam<K, T extends string | string[] = string> = {
4
4
  keys: string[];
5
5
  name: string;
6
6
  keyName: K;
@@ -10,8 +10,8 @@ export declare type CliParam<K, T extends string | string[] = string> = {
10
10
  isArray?: T extends string[] ? true : never;
11
11
  process?: (value: T) => T;
12
12
  };
13
- declare type Param = CliParam<string> | CliParam<string, string[]>;
14
- declare type Config = {
13
+ type Param = CliParam<string> | CliParam<string, string[]>;
14
+ type Config = {
15
15
  params: Param[];
16
16
  };
17
17
  declare class CliParamsModule_Class extends Module<Config> {
@@ -1,5 +1,5 @@
1
1
  import { TS_Object } from '../utils/types';
2
- export declare type CSVProps<T extends TS_Object = TS_Object> = {
2
+ export type CSVProps<T extends TS_Object = TS_Object> = {
3
3
  decimalSeparator?: string;
4
4
  withHeaders?: boolean;
5
5
  fieldWrapper?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nu-art/ts-common",
3
- "version": "0.102.31",
3
+ "version": "0.102.32",
4
4
  "description": "js and ts infra",
5
5
  "keywords": [
6
6
  "TacB0sS",
@@ -1,9 +1,9 @@
1
- export declare type TestCase<Input, Result> = {
1
+ export type TestCase<Input, Result> = {
2
2
  expected?: Result;
3
3
  input: Input;
4
4
  };
5
- export declare type TestProcessor<T extends TestCase<any, any>> = (input: T['input']) => Promise<T['expected']>;
6
- export declare type TestSuit<Model extends TestCase<any, any>> = {
5
+ export type TestProcessor<T extends TestCase<any, any>> = (input: T['input']) => Promise<T['expected']>;
6
+ export type TestSuit<Model extends TestCase<any, any>> = {
7
7
  key: string;
8
8
  label: string;
9
9
  models: Model[];
@@ -31,7 +31,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
31
31
  function verb(n) { return function (v) { return step([n, v]); }; }
32
32
  function step(op) {
33
33
  if (f) throw new TypeError("Generator is already executing.");
34
- while (_) try {
34
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
35
35
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
36
36
  if (y = 0, t) op = [op[0] & 2, t.value];
37
37
  switch (op[0]) {
@@ -1,4 +1,4 @@
1
- export declare type LogStyle = {
1
+ export type LogStyle = {
2
2
  'color'?: string;
3
3
  'background-color'?: string;
4
4
  'padding'?: string;
@@ -31,7 +31,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
31
31
  function verb(n) { return function (v) { return step([n, v]); }; }
32
32
  function step(op) {
33
33
  if (f) throw new TypeError("Generator is already executing.");
34
- while (_) try {
34
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
35
35
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
36
36
  if (y = 0, t) op = [op[0] & 2, t.value];
37
37
  switch (op[0]) {
@@ -6,7 +6,7 @@ export declare const Day: number;
6
6
  export declare const Week: number;
7
7
  export declare const Format_HHmmss_DDMMYYYY = "HH:mm:ss_DD-MM-YYYY";
8
8
  export declare const Format_YYYYMMDD_HHmmss = "YYYY-MM-DD_HH:mm:ss";
9
- export declare type TimerHandler = (...args: any[]) => void;
9
+ export type TimerHandler = (...args: any[]) => void;
10
10
  export declare function timeout(sleepMs: number): Promise<unknown>;
11
11
  export declare function _setTimeout(handler: TimerHandler, sleepMs?: number, ...args: any[]): number;
12
12
  export declare function _clearTimeout(handlerId?: number): void;
@@ -31,7 +31,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
31
31
  function verb(n) { return function (v) { return step([n, v]); }; }
32
32
  function step(op) {
33
33
  if (f) throw new TypeError("Generator is already executing.");
34
- while (_) try {
34
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
35
35
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
36
36
  if (y = 0, t) op = [op[0] & 2, t.value];
37
37
  switch (op[0]) {
@@ -1,4 +1,4 @@
1
- export declare type RouteParams = {
1
+ export type RouteParams = {
2
2
  [key: string]: string | number | boolean | undefined | (() => string | number);
3
3
  };
4
4
  export declare function composeQueryParams(params?: RouteParams): string;
package/utils/queue.js CHANGED
@@ -46,7 +46,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
46
46
  function verb(n) { return function (v) { return step([n, v]); }; }
47
47
  function step(op) {
48
48
  if (f) throw new TypeError("Generator is already executing.");
49
- while (_) try {
49
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
50
50
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
51
51
  if (y = 0, t) op = [op[0] & 2, t.value];
52
52
  switch (op[0]) {
package/utils/types.d.ts CHANGED
@@ -1,91 +1,91 @@
1
- export declare type CustomOptional<T, K> = {
1
+ export type CustomOptional<T, K> = {
2
2
  [P in keyof T]?: K;
3
3
  };
4
- export declare type Subset<T> = {
4
+ export type Subset<T> = {
5
5
  [P in keyof T]: T[P];
6
6
  };
7
- export declare type OptionalKeys<T extends TS_Object> = Exclude<{
7
+ export type OptionalKeys<T extends TS_Object> = Exclude<{
8
8
  [K in keyof T]: T extends Record<K, T[K]> ? never : K;
9
9
  }[keyof T], undefined>;
10
- export declare type MandatoryKeys<T extends TS_Object, V extends any = any> = Exclude<{
10
+ export type MandatoryKeys<T extends TS_Object, V extends any = any> = Exclude<{
11
11
  [K in keyof T]: T extends Record<K, T[K]> ? (T[K] extends V ? K : never) : never;
12
12
  }[keyof T], undefined>;
13
- export declare type RequireOptionals<T extends TS_Object, Keys extends OptionalKeys<T> = OptionalKeys<T>> = Pick<T, Exclude<keyof T, Keys>> & {
13
+ export type RequireOptionals<T extends TS_Object, Keys extends OptionalKeys<T> = OptionalKeys<T>> = Pick<T, Exclude<keyof T, Keys>> & {
14
14
  [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
15
15
  }[Keys];
16
- export declare type RequireOneOptional<T extends TS_Object, Keys extends OptionalKeys<T> = OptionalKeys<T>> = Pick<T, Exclude<keyof T, Keys>> & {
16
+ export type RequireOneOptional<T extends TS_Object, Keys extends OptionalKeys<T> = OptionalKeys<T>> = Pick<T, Exclude<keyof T, Keys>> & {
17
17
  [K in Keys]-?: Required<Pick<T, K>> & Partial<Record<Exclude<Keys, K>, undefined>>;
18
18
  }[Keys];
19
- export declare type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
19
+ export type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
20
20
  [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
21
21
  }[Keys];
22
- export declare type RequireOnlyOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
22
+ export type RequireOnlyOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
23
23
  [K in Keys]-?: Required<Pick<T, K>> & Partial<Record<Exclude<Keys, K>, undefined>>;
24
24
  }[Keys];
25
- export declare type Constructor<T> = new (...args: any) => T;
26
- export declare type ArrayType<T extends any[]> = T extends (infer I)[] ? I : never;
27
- export declare type PartialProperties<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
28
- export declare type KeyValue = TypedKeyValue<string, string>;
29
- export declare type TypedKeyValue<KeyType, ValueType> = {
25
+ export type Constructor<T> = new (...args: any) => T;
26
+ export type ArrayType<T extends any[]> = T extends (infer I)[] ? I : never;
27
+ export type PartialProperties<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
28
+ export type KeyValue = TypedKeyValue<string, string>;
29
+ export type TypedKeyValue<KeyType, ValueType> = {
30
30
  key: KeyType;
31
31
  value: ValueType;
32
32
  };
33
- export declare type Identity = {
33
+ export type Identity = {
34
34
  id: string;
35
35
  };
36
- export declare type StringMap = {
36
+ export type StringMap = {
37
37
  [s: string]: string;
38
38
  };
39
- export declare type TS_Object = {
39
+ export type TS_Object = {
40
40
  [s: string]: any;
41
41
  };
42
- export declare type TypedMap<ValueType> = {
42
+ export type TypedMap<ValueType> = {
43
43
  [s: string]: ValueType;
44
44
  };
45
- export declare type TypedMapValue<T extends TS_Object, ValueType> = {
45
+ export type TypedMapValue<T extends TS_Object, ValueType> = {
46
46
  [P in keyof T]: ValueType;
47
47
  };
48
- export declare type AtLeast<T, K extends keyof T> = Partial<T> & Pick<T, K>;
49
- export declare type DB_BaseObject = {
48
+ export type AtLeast<T, K extends keyof T> = Partial<T> & Pick<T, K>;
49
+ export type DB_BaseObject = {
50
50
  _id: string;
51
51
  };
52
- export declare type DB_Object = DB_BaseObject & {
52
+ export type DB_Object = DB_BaseObject & {
53
53
  _v?: string;
54
54
  __created: number;
55
55
  __updated: number;
56
56
  };
57
57
  export declare const KeysToKeepOnDelete: (keyof DB_Object)[];
58
- export declare type PreDB<T extends DB_Object> = PartialProperties<T, keyof DB_Object>;
59
- export declare type OmitDBObject<T extends DB_Object> = Omit<T, keyof DB_Object>;
60
- export declare type Draftable = {
58
+ export type PreDB<T extends DB_Object> = PartialProperties<T, keyof DB_Object>;
59
+ export type OmitDBObject<T extends DB_Object> = Omit<T, keyof DB_Object>;
60
+ export type Draftable = {
61
61
  _isDraft: boolean;
62
62
  };
63
- export declare type Auditable = {
63
+ export type Auditable = {
64
64
  _audit?: AuditBy;
65
65
  };
66
- export declare type AuditBy = {
66
+ export type AuditBy = {
67
67
  comment?: string;
68
68
  auditBy: string;
69
69
  auditAt: Timestamp;
70
70
  };
71
- export declare type Timestamp = {
71
+ export type Timestamp = {
72
72
  timestamp: number;
73
73
  pretty: string;
74
74
  timezone?: string;
75
75
  };
76
- export declare type FunctionKeys<T> = {
76
+ export type FunctionKeys<T> = {
77
77
  [K in keyof T]: T[K] extends (...args: any) => any ? K : never;
78
78
  }[keyof T];
79
79
  export declare const Void: void;
80
- export declare type PackageJson = {
80
+ export type PackageJson = {
81
81
  version: string;
82
82
  name: string;
83
83
  };
84
- export declare type DeflatePromise<T> = T extends Promise<infer A> ? A : T;
85
- export declare type ReturnPromiseType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? DeflatePromise<R> : never;
86
- export declare type RangeTimestamp = {
84
+ export type DeflatePromise<T> = T extends Promise<infer A> ? A : T;
85
+ export type ReturnPromiseType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? DeflatePromise<R> : never;
86
+ export type RangeTimestamp = {
87
87
  min: number;
88
88
  max: number;
89
89
  };
90
- export declare type ValidReturnValue = string | number | object;
91
- export declare type NarrowArray<Default, T1, T2, T3, T4, T5, T6> = T6 extends ValidReturnValue ? [T1, T2, T3, T4, T5, T6] : T5 extends ValidReturnValue ? [T1, T2, T3, T4, T5] : T4 extends ValidReturnValue ? [T1, T2, T3, T4] : T3 extends ValidReturnValue ? [T1, T2, T3] : T2 extends ValidReturnValue ? [T1, T2] : T1 extends ValidReturnValue ? [T1] : Default;
90
+ export type ValidReturnValue = string | number | object;
91
+ export type NarrowArray<Default, T1, T2, T3, T4, T5, T6> = T6 extends ValidReturnValue ? [T1, T2, T3, T4, T5, T6] : T5 extends ValidReturnValue ? [T1, T2, T3, T4, T5] : T4 extends ValidReturnValue ? [T1, T2, T3, T4] : T3 extends ValidReturnValue ? [T1, T2, T3] : T2 extends ValidReturnValue ? [T1, T2] : T1 extends ValidReturnValue ? [T1] : Default;
@@ -7,4 +7,4 @@
7
7
  * 0 if versions match
8
8
  * 1 if second is greater
9
9
  */
10
- export declare function compareVersions(firstVersion: string, secondVersion: string): 1 | -1 | 0;
10
+ export declare function compareVersions(firstVersion: string, secondVersion: string): 0 | 1 | -1;
@@ -1,16 +1,16 @@
1
1
  import { CustomException } from '../core/exceptions';
2
2
  import { ArrayType, AuditBy, RangeTimestamp, TS_Object } from '../utils/types';
3
- export declare type ValidatorTypeResolver<K> = K extends any[] ? Validator<K> : K extends TS_Object ? TypeValidator<K> | Validator<K> : Validator<K>;
4
- declare type ValidatorImpl<P> = (p?: P) => (InvalidResult<P> | undefined);
5
- export declare type Validator<P> = undefined | ValidatorImpl<P> | ValidatorImpl<P>[];
6
- export declare type TypeValidator<T extends TS_Object> = {
3
+ export type ValidatorTypeResolver<K> = K extends any[] ? Validator<K> : K extends TS_Object ? TypeValidator<K> | Validator<K> : Validator<K>;
4
+ type ValidatorImpl<P> = (p?: P) => (InvalidResult<P> | undefined);
5
+ export type Validator<P> = undefined | ValidatorImpl<P> | ValidatorImpl<P>[];
6
+ export type TypeValidator<T extends TS_Object> = {
7
7
  [P in keyof T]: ValidatorTypeResolver<T[P]>;
8
8
  };
9
- export declare type InvalidResultObject<T extends any> = {
9
+ export type InvalidResultObject<T extends any> = {
10
10
  [K in keyof T]?: InvalidResult<T[K]>;
11
11
  };
12
- export declare type InvalidResultArray<T extends any> = InvalidResult<T> | undefined;
13
- export declare type InvalidResult<T extends any> = T extends object ? InvalidResultObject<T> | string : T extends (infer I)[] ? (InvalidResultArray<I>[]) | string : string;
12
+ export type InvalidResultArray<T extends any> = InvalidResult<T> | undefined;
13
+ export type InvalidResult<T extends any> = T extends object ? InvalidResultObject<T> | string : T extends (infer I)[] ? (InvalidResultArray<I>[]) | string : string;
14
14
  export declare class ValidationException extends CustomException {
15
15
  input?: string;
16
16
  result?: InvalidResult<any>;